feat(mobile): verify fee-payer HKDF derivation on native - #598
Open
Lazyartist1 wants to merge 1 commit into
Open
feat(mobile): verify fee-payer HKDF derivation on native#598Lazyartist1 wants to merge 1 commit into
Lazyartist1 wants to merge 1 commit into
Conversation
Confirm the deterministic fee-payer (sponsor) keypair the SDK derives from the passkey is byte-identical on native and web. The wallet is fee-sponsored, so a mismatch would pay fees from the wrong account. The web derives the Ed25519 seed with WebCrypto HKDF (crypto.subtle), which has no equivalent under React Native's crypto polyfills, so this native port uses @noble/hashes HKDF-SHA-256 with the same salt/info. HKDF is a fixed standard, so the two produce the same 32 bytes and therefore the same G… address — checked against a golden address derived through the web WebCrypto path. - lib/deriveFeePayer.ts: deriveFeePayerKeypair (base64url credential id → noble HKDF → Ed25519 seed → Keypair) and deriveStoredFeePayer (from the secure-store credential id). Closes Miracle656#448
|
@Lazyartist1 is attempting to deploy a commit to the miracle656's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Lazyartist1 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds and verifies the native fee-payer (sponsor) key derivation (backlog item 20). The wallet is fee-sponsored, so the deterministic keypair the SDK derives from the passkey must be byte-identical on web and native — a mismatch would pay fees from the wrong account. This is a correctness check on the HKDF path under the native crypto polyfills.
Approach
The web derives the Ed25519 seed with WebCrypto HKDF (
crypto.subtle.deriveBits), which has no equivalent under React Native's crypto polyfills. The native port uses@noble/hashesHKDF-SHA-256 with the same salt/info. HKDF (RFC 5869) is a fixed standard, so both implementations produce the same 32 bytes → the same Ed25519 seed → the sameG…address.Changes
lib/deriveFeePayer.ts(new) — native port offrontend/wallet/lib/deriveFeePayer.ts:deriveFeePayerKeypair(credentialIdBase64url)— base64url credential id → noble HKDF-SHA-256 (saltveil:feepayer:salt:v1, infoveil:feepayer:ed25519:v1) → 32-byte Ed25519 seed →Keypair.deriveStoredFeePayer()— derives from the credential id in secure store; null when no passkey is registered.Acceptance
G…fee-payer address on web and nativeVerified: for credential id
AQIDBAUGBwgJCgsMDQ4PEA, both the web WebCrypto path and the native noble path deriveGDNLN66V4YFQQPDVNMADJSWUF2EFSLM2BHOF2LDUGVQPQUBG7H4WRFDQ. That address is pinned as the golden value in the test, so any drift in the native derivation fails CI.Testing
tsc --noEmitcleanjest lib/__tests__/deriveFeePayer.test.ts— 5/5 passing (matches the web-derived golden address, deterministic, distinct id → distinct account, derives from stored credential, null when unregistered)Closes #448