Skip to content

Commit 461eb1a

Browse files
UltraDAGcomClaude Opus 4.7 (1M context)
andcommitted
test(smart-account): fix webauthn verification test double-hashing
The test signed `SHA256(authenticatorData || SHA256(clientDataJSON))`, then passed that prehash to `p256_sk.sign()` — which SHA-256s again via the Signer trait, producing SHA-256(SHA-256(...)). Neither verification path in verify_webauthn expects a double-hashed signature, so the test failed regardless of the verification code being correct. Fix: pass the raw `signed_data` concatenation to sign(), matching how a real WebAuthn authenticator produces the signature. All other webauthn tests already used this pattern. Production verify_webauthn is unchanged — it was already correct. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 826e2a2 commit 461eb1a

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

crates/ultradag-coin/src/tx/smart_account.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,15 +1645,17 @@ mod tests {
16451645
challenge_b64
16461646
).into_bytes();
16471647

1648-
// 4. Compute what the browser would sign: SHA-256(authenticatorData || SHA-256(clientDataJSON))
1648+
// 4. Compute the bytes the browser signs: authenticatorData || SHA-256(clientDataJSON).
1649+
// The ECDSA Signer trait applies SHA-256 internally, so we pass the raw
1650+
// concatenation — prehashing here would produce SHA-256(SHA-256(...)),
1651+
// which neither verification path in verify_webauthn expects.
16491652
let client_data_hash = Sha256::digest(&client_data_json);
16501653
let mut signed_data = Vec::new();
16511654
signed_data.extend_from_slice(&authenticator_data);
16521655
signed_data.extend_from_slice(&client_data_hash);
1653-
let signed_message = Sha256::digest(&signed_data);
16541656

1655-
// 5. Sign with P256
1656-
let p256_signature: p256::ecdsa::Signature = p256_sk.sign(&signed_message);
1657+
// 5. Sign with P256 — raw bytes; the Signer internally SHA-256s.
1658+
let p256_signature: p256::ecdsa::Signature = p256_sk.sign(&signed_data);
16571659

16581660
// 6. Package into WebAuthnSignature
16591661
tx.webauthn = Some(WebAuthnSignature {

0 commit comments

Comments
 (0)