fix: correct nonce/nullifier confusion in serialized zswap local state (PM-22025)#1128
Merged
Merged
Conversation
2984da9 to
3095ff3
Compare
LGLO
reviewed
Mar 31, 2026
LGLO
approved these changes
Mar 31, 2026
39f9414 to
197611f
Compare
Signed-off-by: Mike Clay <mike.clay@shielded.io>
…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 Signed-off-by: Mike Clay <mike.clay@shielded.io>
Made-with: Cursor Signed-off-by: Mike Clay <mike.clay@shielded.io>
Apply cargo fmt to test helper signature and use full Jira URL in change file to satisfy CI checks. Made-with: Cursor Signed-off-by: Mike Clay <mike.clay@shielded.io>
The assert_eq already proves the nonce equals nonce_bytes (0xAA..), making the assert_ne against nullifier_bytes (0xBB..) tautologically true. Addresses review feedback from LGLO. Signed-off-by: Mike Clay <mike.clay@shielded.io>
197611f to
a86a8c6
Compare
m2ux
added a commit
that referenced
this pull request
Apr 23, 2026
…e (PM-22025) (#1128) * chore: initialize branch for PM-22025 * test: add regression tests for nonce/nullifier distinction in zswap serialization 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 * chore: add change file for nonce/nullifier audit remediation (PM-22025) Made-with: Cursor * chore: fix formatting and JIRA link in change file Apply cargo fmt to test helper signature and use full Jira URL in change file to satisfy CI checks. Made-with: Cursor * chore: remove redundant assert_ne in nonce regression test The assert_eq already proves the nonce equals nonce_bytes (0xAA..), making the assert_ne against nullifier_bytes (0xBB..) tautologically true. Addresses review feedback from LGLO. --------- Signed-off-by: Mike Clay <mike.clay@shielded.io>
m2ux
added a commit
that referenced
this pull request
Apr 23, 2026
…e (PM-22025) (#1128) * chore: initialize branch for PM-22025 * test: add regression tests for nonce/nullifier distinction in zswap serialization 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 * chore: add change file for nonce/nullifier audit remediation (PM-22025) Made-with: Cursor * chore: fix formatting and JIRA link in change file Apply cargo fmt to test helper signature and use full Jira URL in change file to satisfy CI checks. Made-with: Cursor * chore: remove redundant assert_ne in nonce regression test The assert_eq already proves the nonce equals nonce_bytes (0xAA..), making the assert_ne against nullifier_bytes (0xBB..) tautologically true. Addresses review feedback from LGLO. --------- Signed-off-by: Mike Clay <mike.clay@shielded.io>
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