authenticate() function verifies a previously enrolled biometric identity by re-deriving the key and comparing it to the stored public key.
Function Signature
Parameters
Relying Party ID - must match the ID used during enrollment
Return Value
Returns a Promise that resolves to a verification result:Always
true when the function returns successfully (throws error on failure)Re-derived public key (hex-encoded)
'prf': PRF extension was used to re-derive the key'rawid': HKDF fallback was used
How It Works
- WebAuthn Get: Requests credential assertion with PRF extension
- Re-Derivation: Uses the same method (PRF or rawId-HKDF) to re-derive the key
- Verification: Compares re-derived key against stored
identity.publicKey - Throws on Mismatch: Raises an error if keys don’t match or assertion fails
Example
Error Handling
The function throws errors in these cases:WebAuthn Configuration
The function configures WebAuthn assertions with:- Challenge: 32 random bytes
- Allowed Credentials: Only the provided credential ID
- User Verification: Required
- PRF Extension: Uses
evalByCredentialwith the same salt as enrollment - Timeout: 60 seconds
Security Notes
- The function verifies that the re-derived key matches the stored public key
- PRF output is hardware-backed and never leaves the authenticator
- rawId fallback is best-effort for environments without PRF support
- Always use the same
rpIdfor enrollment and authentication
Source Reference
See/packages/biokey-core/src/authenticate.js:9