A privacy-preserving credential system built with BBS+ signatures, enabling selective disclosure and zero-knowledge proofs.
- Go: Version 1.23.0 or later (tested with 1.23.8)
- Node.js: Version 18 or later (tested with v22.14.0)
- npm: Version 10 or later (tested with 10.9.2)
- Build and run the issuer service:
cd ./gnark-bbs-example
go build ./cmd/issuer
./issuerThe service will start on http://localhost:8080
- Test using the provided script:
chmod +x ./scripts/simple-university-test.sh
./scripts/simple-university-test.sh- Install dependencies:
cd web
npm install- Start the development server:
npm run devThe app will be available at http://localhost:3000
POST /api/v1/issuers- Create a new issuerGET /api/v1/issuers/:did- Get issuer informationGET /api/v1/credentials- List all credentialsPOST /api/v1/credentials- Issue a new credentialGET /api/v1/credentials/:id- Get credential detailsPOST /api/v1/credentials/:id/revoke- Revoke a credentialGET /api/v1/schemas- List available schemasPOST /api/v1/schemas- Create a new schemaGET /api/v1/schemas/:id- Get schema detailsGET /api/v1/schemas/:id/selective-fields- Get schema selective disclosure fieldsGET /api/v1/public-keys/:issuer-did- Get issuer public key
POST /api/v1/presentations- Create a selective disclosure presentationPOST /api/v1/presentations/verify- Verify a presentationPOST /api/v1/presentations/bbs- Create BBS+ presentation
GET /api/v1/proofs/data/:credentialId- Get proof creation dataPOST /api/v1/proofs/create- Create proofPOST /api/v1/proofs/verify-client- Verify client proofPOST /api/v1/proofs/verify-bbs- Verify BBS+ proof
curl -X POST http://localhost:8080/api/v1/issuers \
-H "Content-Type: application/json" \
-d '{
"did": "did:example:issuer123",
"name": "Demo University",
"description": "A demo university issuing BBS+ credentials",
"website": "https://demo-university.edu"
}'curl -X POST http://localhost:8080/api/v1/credentials \
-H "Content-Type: application/json" \
-d '{
"issuer_did": "did:example:issuer123",
"subject_did": "did:example:student456",
"schema_id": "identity-card-v1",
"attributes": {
"name": "Alice Johnson",
"age": 25,
"university": "Demo University",
"degree": "Computer Science",
"graduation_year": 2023
}
}'curl -X POST http://localhost:8080/api/v1/presentations \
-H "Content-Type: application/json" \
-d '{
"credential_id": "cred_12345",
"revealed_attributes": ["name", "degree"],
"verifier_did": "did:example:verifier789"
}'graph TB
subgraph "Frontend Layer"
A[Next.js App Router 15.4.6]
B[React 19.1.0]
C[TypeScript 5.x]
D[Tailwind CSS 4.x]
end
subgraph "Backend Layer"
E[Gin HTTP Server]
F[Go 1.23.8]
G[REST API]
end
subgraph "Cryptographic Layer"
H[BBS+ Signatures]
I[gnark-crypto v0.18.0]
J[BLS12-381 Curve]
K[Selective Disclosure]
end
subgraph "Storage Layer"
L[In-Memory Storage]
M[Credential Repository]
N[Schema Repository]
end
A --> E
B --> G
E --> H
H --> I
I --> J
G --> L
L --> M
L --> N
- BBS+ Key Generation: Cryptographically secure key pairs using BLS12-381
- Credential Issuance: Sign credentials with multiple attributes
- Selective Disclosure: Reveal only chosen attributes in presentations
- Zero-Knowledge Proofs: Prove possession without revealing hidden attributes
- Unlinkability: Randomized signatures prevent correlation
- REST API: Complete HTTP interface for issuers and holders
- Next.js Frontend: Modern React-based UI with App Router
- Schema Management: Dynamic credential schema creation and validation
- Client-side Proofs: Browser-based proof generation and verification
- Enhanced UI/UX: Improved credential management interface
- QR Code Integration: Easy credential exchange via QR codes
- Mobile Responsiveness: Optimized mobile experience
- DID Resolution: β
W3C DID standard support implemented
- DID Document implementation with W3C compliance
- Support for
key,web, andbbsDID methods - DID resolver and universal resolver functionality
- Verifier Interface: β
Complete verification workflow implemented
- Verifier registration and management
- Policy creation and enforcement
- Verification request handling and processing
- Database Integration: π΄ Persistent storage with PostgreSQL
- Currently using in-memory storage only
- Database configuration prepared in
.env.example - Need to implement repository layer with PostgreSQL
- Unit Testing: π΄ Comprehensive test coverage
- Only integration test script available
- Need unit tests for all modules and handlers
- Test coverage reporting
- Production Deployment: π΄ Docker containers and CI/CD
- Missing
Dockerfileanddocker-compose.yml - No CI/CD pipeline (GitHub Actions)
- Production environment configuration
- Missing
- Performance Optimization: π΄ Caching and batch processing
- No caching layer (Redis/Memcached)
- No batch processing for bulk operations
- Need performance monitoring and optimization
- Security Audit: π΄ Third-party security review
- Code security analysis needed
- Vulnerability assessment
- Penetration testing
- Database Integration (High Priority)
- Unit Testing (High Priority)
- Docker & CI/CD (Medium Priority)
- Performance Optimization (Medium Priority)
- Security Audit (Low Priority)
gnark-bbs-example/
βββ cmd/ # Application entry points
β βββ issuer/ # Issuer service main
β βββ holder-api/ # Holder backend API (future)
βββ internal/ # Private application code
β βββ domain/ # Business entities
β β βββ credential/ # Credential domain logic
β β βββ did/ # DID-related entities
β β βββ signature/ # Signature domain
β βββ application/ # Use cases
β β βββ credential/ # Credential services
β β βββ holder/ # Holder services
β β βββ issuer/ # Issuer services
β βββ infrastructure/ # External adapters
β β βββ crypto/ # Cryptographic implementations
β β βββ http/ # HTTP server setup
β β βββ storage/ # Storage implementations
β βββ interfaces/ # API handlers
β βββ rest/ # REST API handlers
β βββ websocket/ # WebSocket handlers (future)
βββ pkg/ # Shared libraries
β βββ bbs/ # BBS+ implementation
β βββ did/ # DID utilities
β βββ zkproof/ # Zero-knowledge proofs
βββ web/ # Next.js frontend application
β βββ src/
β β βββ app/ # App Router pages
β β βββ components/ # React components
β β βββ hooks/ # Custom React hooks
β β βββ lib/ # Utility libraries
β β βββ services/ # API services
β β βββ stores/ # State management (Zustand)
β β βββ types/ # TypeScript type definitions
β βββ public/ # Static assets
βββ scripts/ # Development and test scripts
βββ docs/ # Documentation
-
BBS+ Core (
pkg/bbs/)types.go- Core data structures and interfaceskeygen.go- Key generation and managementsigner.go- Signing and verification logicprover.go- Selective disclosure proof generation
-
HTTP Server (
internal/infrastructure/http/)server.go- Gin HTTP server setup with CORS- Middleware stack for logging and security
-
REST Handlers (
internal/interfaces/rest/handlers/)issuer_handler.go- Issuer operations (create, list, manage)holder_handler.go- Holder operations (presentations)proof_handler.go- Client-side proof operations
-
Frontend (
web/src/)- App Router: Next.js 15.4.6 with React 19.1.0
- Components: Modular UI components with Tailwind CSS
- Services: API client services for backend communication
- Stores: Zustand state management for credentials and presentations
- Hooks: Custom React hooks for selective disclosure
Backend:
- Language: Go 1.23.8
- Framework: Gin HTTP framework
- Cryptography: gnark-crypto v0.18.0 (BLS12-381)
- Storage: In-memory (temporary)
Frontend:
- Framework: Next.js 15.4.6 with App Router
- Language: TypeScript 5.x
- UI Library: React 19.1.0
- Styling: Tailwind CSS 4.x
- State Management: Zustand 5.0.7
- HTTP Client: Axios 1.11.0
- Cryptography: @noble/curves, crypto-js
- Cryptographic Unlinkability: Each presentation uses fresh randomness
- Zero-Knowledge Proofs: Hidden attributes remain private
- Signature Randomization: Prevents tracking across verifiers
- Selective Disclosure: Minimal information disclosure principle
- BLS12-381 Security: Industry-standard elliptic curve
- Credential Issuance: < 500ms typical response time
- Proof Generation: < 200ms for 5 attributes
- Verification: < 100ms typical response time
- Frontend Loading: < 2s initial page load
- API Response: < 50ms for cached data
The project includes a comprehensive test script that demonstrates the full workflow:
# Make the script executable
chmod +x ./scripts/simple-university-test.sh
# Run the complete test suite
./scripts/simple-university-test.shThis script will:
- Create a university credential schema
- Generate an issuer with BBS+ keys
- Issue a sample credential
- Create selective disclosure presentations
- Verify the presentations
You can also test individual endpoints manually. See the API examples in the original documentation above.
- Fork the repository and create a feature branch
- Follow the coding standards outlined in the general instructions
- Keep files under 500 lines for maintainability
- Add tests for new features and bug fixes
- Update documentation for API changes
- Ensure security best practices are followed
- Run the test script before submitting PRs
# Clone your fork
git clone https://github.com/your-username/gnark-bbs-example.git
cd gnark-bbs-example
# Install dependencies
go mod download
cd web && npm install
# Run tests
./scripts/simple-university-test.sh
# Start development servers
go run cmd/issuer/main.go & # Backend on :8080
cd web && npm run dev # Frontend on :3000This project is licensed under the MIT License - see the LICENSE file for details.
- β Commercial use
- β Modification
- β Distribution
- β Private use
- β No liability
- β No warranty