|
| 1 | +# General Specifications |
| 2 | + |
| 3 | +## System Architecture |
| 4 | + |
| 5 | +### Components |
| 6 | +1. **OIDC Provider (node-oidc-provider)** |
| 7 | + - Handles OIDC authentication flows |
| 8 | + - Issues ID tokens containing DIDs |
| 9 | + - Manages client registrations and interactions |
| 10 | + |
| 11 | +2. **Frontend Server (Next.js)** |
| 12 | + - Server-side rendered login interface |
| 13 | + - Handles Web3Auth MPC initialization |
| 14 | + - Manages DID generation and VC issuance |
| 15 | + - Processes OIDC interactions |
| 16 | + |
| 17 | +3. **Web3Auth MPC Core Kit** |
| 18 | + - Generates and manages Ed25519 key shares |
| 19 | + - Implements 2-of-3 threshold signature scheme |
| 20 | + - Provides secure key management without full key reconstruction |
| 21 | + |
| 22 | +4. **Sphereon SSI SDK (Veramo)** |
| 23 | + - DID generation and management |
| 24 | + - VC issuance and verification |
| 25 | + - Custom KMS integration with Web3Auth MPC |
| 26 | + |
| 27 | +### Data Flow |
| 28 | +1. Client initiates OIDC authorization request |
| 29 | +2. Frontend server renders login form |
| 30 | +3. User authenticates and triggers MPC key generation |
| 31 | +4. DID is generated using MPC key material |
| 32 | +5. Optional VC issuance occurs |
| 33 | +6. OIDC interaction completes with DID in ID token |
| 34 | + |
| 35 | +## Technical Specifications |
| 36 | + |
| 37 | +### Key Management |
| 38 | +- **Key Type**: Ed25519 |
| 39 | +- **Threshold Scheme**: 2-of-3 |
| 40 | +- **Share Distribution**: |
| 41 | + - Server-side share |
| 42 | + - Client-side share |
| 43 | + - Cloud backup share |
| 44 | +- **Security Requirements**: |
| 45 | + - No full key reconstruction |
| 46 | + - Secure share storage |
| 47 | + - Encrypted communication between shares |
| 48 | + |
| 49 | +### DID Specifications |
| 50 | +- **Method**: did:key |
| 51 | +- **Key Type**: Ed25519 |
| 52 | +- **Format**: Base58 encoded public key |
| 53 | +- **Storage**: Persistent database with user association |
| 54 | + |
| 55 | +### VC Specifications |
| 56 | +- **Format**: JWT VC |
| 57 | +- **Issuer**: User's DID |
| 58 | +- **Optional Claims**: |
| 59 | + - Login proof |
| 60 | + - Authentication timestamp |
| 61 | + - Additional user attributes |
| 62 | + |
| 63 | +### OIDC Integration |
| 64 | +- **ID Token Claims**: |
| 65 | + ```json |
| 66 | + { |
| 67 | + "sub": "did:key:z6Mkw...", |
| 68 | + "did": "did:key:z6Mkw..." |
| 69 | + } |
| 70 | + ``` |
| 71 | +- **Required Endpoints**: |
| 72 | + - `/authorize` |
| 73 | + - `/interaction/:uid/login` |
| 74 | + - `/token` |
| 75 | + |
| 76 | +## Implementation Details |
| 77 | + |
| 78 | +### Custom KMS Implementation |
| 79 | +```typescript |
| 80 | +interface Web3AuthMpcKMS { |
| 81 | + // Key management |
| 82 | + generateKey(): Promise<Key>; |
| 83 | + getKey(keyRef: string): Promise<Key>; |
| 84 | + |
| 85 | + // Signing operations |
| 86 | + sign(data: Buffer, keyRef: string): Promise<Buffer>; |
| 87 | + verify(data: Buffer, signature: Buffer, keyRef: string): Promise<boolean>; |
| 88 | +} |
| 89 | +``` |
| 90 | + |
| 91 | +### DID Generation Flow |
| 92 | +1. Initialize Web3Auth MPC |
| 93 | +2. Generate key shares |
| 94 | +3. Create did:key using public key material |
| 95 | +4. Store DID and key references |
| 96 | +5. Return DID for OIDC integration |
| 97 | + |
| 98 | +### VC Issuance Flow |
| 99 | +1. Prepare VC claims |
| 100 | +2. Sign VC using MPC shares |
| 101 | +3. Verify VC signature |
| 102 | +4. Store VC if needed |
| 103 | +5. Return signed VC |
| 104 | + |
| 105 | +## Security Considerations |
| 106 | + |
| 107 | +### Key Share Management |
| 108 | +- Secure storage of server-side share |
| 109 | +- Encrypted client-side share storage |
| 110 | +- Secure backup share management |
| 111 | +- Regular key rotation policies |
| 112 | + |
| 113 | +### Communication Security |
| 114 | +- TLS for all network communications |
| 115 | +- Encrypted share exchange |
| 116 | +- Secure session management |
| 117 | +- Protection against replay attacks |
| 118 | + |
| 119 | +### Access Control |
| 120 | +- Role-based access control for key operations |
| 121 | +- Audit logging for all key operations |
| 122 | +- Rate limiting for authentication attempts |
| 123 | +- Session timeout policies |
| 124 | + |
| 125 | +## Testing Requirements |
| 126 | + |
| 127 | +### Unit Tests |
| 128 | +- MPC key generation and management |
| 129 | +- DID generation and verification |
| 130 | +- VC issuance and verification |
| 131 | +- OIDC token generation |
| 132 | + |
| 133 | +### Integration Tests |
| 134 | +- End-to-end authentication flow |
| 135 | +- MPC share communication |
| 136 | +- DID integration with OIDC |
| 137 | +- VC issuance and verification |
| 138 | + |
| 139 | +### Security Tests |
| 140 | +- Key share security |
| 141 | +- Communication encryption |
| 142 | +- Access control enforcement |
| 143 | +- Session management |
| 144 | + |
| 145 | +## Deployment Considerations |
| 146 | + |
| 147 | +### Environment Requirements |
| 148 | +- Node.js runtime |
| 149 | +- Secure key storage |
| 150 | +- Database for DID/VC persistence |
| 151 | +- Network access for MPC communication |
| 152 | + |
| 153 | +### Scaling Considerations |
| 154 | +- Horizontal scaling of OIDC provider |
| 155 | +- Load balancing for frontend servers |
| 156 | +- Database sharding for DID storage |
| 157 | +- Caching strategies for VC verification |
| 158 | + |
| 159 | +### Monitoring and Logging |
| 160 | +- Authentication success/failure rates |
| 161 | +- Key operation metrics |
| 162 | +- DID generation statistics |
| 163 | +- VC issuance tracking |
0 commit comments