fix(ecash): verification fails on 32-bit platforms#6528
Open
code-zm wants to merge 1 commit intonymtech:developfrom
Open
fix(ecash): verification fails on 32-bit platforms#6528code-zm wants to merge 1 commit intonymtech:developfrom
code-zm wants to merge 1 commit intonymtech:developfrom
Conversation
…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.
|
@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. |
|
Thank you for making this first PR |
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
VerificationKeyAuth::to_bytes()andSecretKeyAuth::to_bytes()innym_offline_compact_ecashuseusize::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 viau64::from_le_bytes(), soto_bytes()should match.Fix
Cast
usizetou64before callingto_le_bytes().No behavioral change on 64-bit where
usizeis already 8 bytes.This change is