Skip to content

feat(passkey-crypto): add @bitgo/passkey-crypto package#8596

Open
derranW26 wants to merge 1 commit intomasterfrom
WCN-186/passkey-crypto-package
Open

feat(passkey-crypto): add @bitgo/passkey-crypto package#8596
derranW26 wants to merge 1 commit intomasterfrom
WCN-186/passkey-crypto-package

Conversation

@derranW26
Copy link
Copy Markdown
Contributor

Summary

  • Adds new modules/passkey-crypto/ package (@bitgo/passkey-crypto) as the cryptographic foundation for the passkey feature (Ticket 1 of 9)
  • derivePassword(prfResult: ArrayBuffer): string — converts WebAuthn PRF output to a hex walletPassphrase for SJCL encryption
  • deriveEnterpriseSalt(baseSalt: string, enterpriseId: string): string — HMAC-SHA256 enterprise-scoped salt to prevent cross-enterprise key reuse

Test plan

  • yarn unit-test in modules/passkey-crypto/ — 11 tests passing (known vectors for both functions)
  • No any types
  • Package builds via yarn build in the module

@linear
Copy link
Copy Markdown

linear Bot commented Apr 22, 2026

@derranW26 derranW26 force-pushed the WCN-186/passkey-crypto-package branch 2 times, most recently from e57cafc to 8708c6e Compare April 22, 2026 15:20
@derranW26 derranW26 marked this pull request as ready for review April 22, 2026 16:57
@derranW26 derranW26 requested review from a team as code owners April 22, 2026 16:57
@derranW26 derranW26 requested a review from lokesh-bitgo April 22, 2026 16:57
Comment thread modules/passkey-crypto/package.json Outdated
@@ -0,0 +1,39 @@
{
"name": "@bitgo/passkey-crypto",
"version": "1.0.0",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"version": "1.0.0",
"version": "0.1.0",

still in development

Comment thread modules/passkey-crypto/src/deriveEnterpriseSalt.ts
@derranW26 derranW26 force-pushed the WCN-186/passkey-crypto-package branch 4 times, most recently from e993fc3 to 6a6ee30 Compare April 22, 2026 21:53
Comment on lines +11 to +16
export function derivePassword(prfResult: ArrayBuffer | undefined): string {
if (!prfResult) {
throw new Error('Failed to derive password');
}
return Buffer.from(prfResult).toString('hex');
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems redundant to allow undefined prfResult but throw an error if it's passed in. We should just update the signature to only allow passing ArrayBuffer

* @returns Base64-encoded HMAC-SHA256 digest
* @throws If baseSalt is missing
*/
export function deriveEnterpriseSalt(baseSalt: string | undefined, enterpriseId: string): string {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here.

Pure cryptographic primitives for WebAuthn PRF-based key derivation:
- derivePassword: converts ArrayBuffer PRF result to hex walletPassphrase
- deriveEnterpriseSalt: HMAC-SHA256 via SJCL matching retail implementation exactly

TICKET: WCN-186
@derranW26 derranW26 force-pushed the WCN-186/passkey-crypto-package branch from 6a6ee30 to 9ca1f7d Compare April 23, 2026 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants