fix: correct nonce/nullifier confusion in serialized zswap local state (PM-22025)#1128
Open
fix: correct nonce/nullifier confusion in serialized zswap local state (PM-22025)#1128
Conversation
2984da9 to
3095ff3
Compare
…erialization Verify that EncodedZswapLocalState::from_zswap_state uses the coin value's Nonce field, not the Nullifier map key, when serializing coin info. Prevents reintroduction of the type-semantic confusion identified in the Least Authority Q1 2026 Node DIFF audit (Issue E). JIRA: PM-22025 Made-with: Cursor
Apply cargo fmt to test helper signature and use full Jira URL in change file to satisfy CI checks. Made-with: Cursor
LGLO
reviewed
Mar 31, 2026
| ); | ||
| assert_ne!( | ||
| encoded.outputs[0].coin_info.nonce, nullifier_bytes, | ||
| "serialized nonce must NOT be the Nullifier (map key)" |
Contributor
There was a problem hiding this comment.
This is redundant. Previous check proves the value equals "serialized nonce must match the coin value's Nonce, not the map key Nullifier". Also "not equal" for nontrivial human readable English is likely to be true.
LGLO
approved these changes
Mar 31, 2026
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
Add regression tests verifying that serialized zswap local state uses the actual coin nonce (randomness), not the nullifier map key (spend identifier). Addresses Least Authority Q1 2026 Node DIFF audit Issue E (PM-22025). All 3 tests pass, clippy clean.
🎫 Ticket 📐 Engineering
Motivation
The Least Authority Q1 2026 Node DIFF audit (Issue E, Medium severity) identified a type-semantic confusion in
EncodedZswapLocalState::from_zswap_statewherecoin_info.noncewas populated from the coin map key (aNullifier/spend identifier) instead of the actual coinNonce(randomness value). Both types are structurally identical newtypes aroundHashOutput([u8; 32]), making the confusion compile without error.The code fix was applied in PR #895 (
encoded_zswap_local_state.rs, Mar 11) and PR #1074 (fork/common/generate_intent.rs, Mar 25). This PR adds regression tests and a change file to prevent reintroduction and formally close the audit finding.Changes
encoded_zswap_local_state.rsthat construct aWalletStatewith distinct nonce (0xAA) and nullifier (0xBB) byte patterns, serialize viafrom_zswap_state, and assert the serialized nonce matches the coin value'sNonce— not theNullifiermap keychanges/changed/audit-nonce-nullifier-regression-tests.mddocumenting the audit remediation📌 Submission Checklist
🔱 Fork Strategy
🗹 TODO before merging