Skip to content

fix(ecash): verification fails on 32-bit platforms#6528

Open
code-zm wants to merge 1 commit intonymtech:developfrom
dial0ut:fix/ecash-32bit-verification
Open

fix(ecash): verification fails on 32-bit platforms#6528
code-zm wants to merge 1 commit intonymtech:developfrom
dial0ut:fix/ecash-32bit-verification

Conversation

@code-zm
Copy link
Copy Markdown

@code-zm code-zm commented Mar 7, 2026

Summary

VerificationKeyAuth::to_bytes() and SecretKeyAuth::to_bytes() in nym_offline_compact_ecash use usize::to_le_bytes() to serialize vector lengths. This produces 4 bytes on 32-bit platforms and 8 bytes on 64-bit platforms.

This causes ecash ticket verification to fail on all 32-bit targets because VerificationKeyAuth::to_bytes() is called in the ZK proof challenge hash computation (src/proofs/proof_spend.rs lines 227 and 381). The 32-bit client computes a different challenge than the 64-bit gateway, so the proof never verifies.

The corresponding from_bytes() implementations read 8 bytes via u64::from_le_bytes(), so to_bytes() should match.

Fix

Cast usize to u64 before calling to_le_bytes().
No behavioral change on 64-bit where usize is already 8 bytes.


This change is Reviewable

…tibility

VerificationKeyAuth::to_bytes() and SecretKeyAuth::to_bytes() used
usize::to_le_bytes() to serialize vector lengths, producing 4 bytes on
32-bit and 8 bytes on 64-bit. Since from_bytes() always reads 8 bytes
(u64), this caused ZK proof challenge hash mismatches when a 32-bit
client's proof was verified by a 64-bit gateway, resulting in
"the provided ticket failed to get verified" on all 32-bit platforms.
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 7, 2026

@code-zm is attempting to deploy a commit to the nyx-network Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 7, 2026

Thank you for making this first PR

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.

1 participant