Overview
The KMS provides encrypted authentication for:- User passcodes (login authentication)
- Transaction PINs (payment authorization)
Authentication Flow
Generate encryption key
First, obtain a public key for encrypting sensitive data:Store both the
publicKey (for encryption) and keyId (for server-side decryption) on the client.Encrypt sensitive data client-side
Use the public key to encrypt the passcode or PIN before sending to the server:
Setting User Passcode
GraphQL Mutation
Input Type
Server-Side Implementation
The server decrypts and securely stores the passcode using bcrypt hashing:Verifying User Passcode
GraphQL Mutation
Input Type
Server-Side Implementation
Setting Transaction PIN
GraphQL Mutation
Input Type
Server-Side Implementation
Verifying Transaction PIN
GraphQL Mutation
Input Type
Server-Side Implementation
Complete Example
Security Best Practices
Client-Side Encryption
Always encrypt sensitive data on the client before transmission. Never send plaintext passcodes or PINs.
Key Management
Store the keyId securely on the client. Use the same key for verification that was used during setup.
Server-Side Hashing
The server decrypts and immediately hashes passwords using bcrypt with 10 salt rounds.
No Plaintext Storage
Only hashed values are stored in the database. Plaintext is never persisted.
Error Handling
The authentication mutations returnfalse on failure without throwing errors for verification operations:
setUserPasscode/setTransactionPin: Throws error on failureverifyUserPasscode/verifyTransactionPin: Returnsfalseon failure
Next Steps
Key Generation
Learn about key generation and rotation strategies
Encryption & Decryption
Understand the encryption/decryption workflow