Conversation
…reward quantum alignment ## Description Remediates load-bearing security invariants in `pallet-zk-tree` and `pallet-mining-rewards` that were previously enforced only via `debug_assert!` and compiled out of production (`--release`) builds. ## Key Changes & Remediations * **Structural Leaf-Recipient Canonicalization (`chain/pallets/zk-tree/src/tree.rs`)**: - Replaced the debug-only assertion in `hash_leaf` with in-place canonicalization via `canonicalize_account_bytes()` across all build profiles[cite: 70, 71]. - Ensures non-canonical 8-byte limbs (`>= GOLDILOCKS_P`) are reduced modulo P before felt encoding, eliminating non-injective leaf aliasing and preventing shared nullifier lockups in the zk-wormhole[cite: 70, 71]. - Preserved fallback handling for non-32-byte account implementations to avoid runtime panics[cite: 70, 71]. * **Release-Enforced Quantum Alignment & Zero-Division Guard (`chain/pallets/mining-rewards/src/lib.rs`)**: - Hardened `quantize()` to return `(zero, amount)` when `leaf_quantum()` is zero, preventing potential divide-by-zero panics inside the critical `on_finalize` consensus hook[cite: 70, 72]. - Re-derived quantum alignment directly inside `mint_reward()`, ensuring only multiples of `AMOUNT_SCALE_DOWN_FACTOR` are minted into circulation while retaining sub-quantum dust in `CollectedFees` across all build targets[cite: 70, 72]. ## Verification - Verified byte-compatibility of `canonicalize_account_bytes` with existing lossy encoding paths[cite: 70, 71]. - Confirmed zero-quantum edge cases return cleanly without triggering integer division panics[cite: 70, 72]. - Validated no changes to public input layouts, storage keys, or honest issuance mechanics[cite: 70].
This branch has not been deployed
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.
Description
Remediates load-bearing security invariants in
pallet-zk-treeandpallet-mining-rewardsthat were previously enforced only viadebug_assert!and compiled out of production (--release) builds.Key Changes & Remediations
Structural Leaf-Recipient Canonicalization (
chain/pallets/zk-tree/src/tree.rs):hash_leafwith in-place canonicalization viacanonicalize_account_bytes()across all build profiles[cite: 70, 71].>= GOLDILOCKS_P) are reduced modulo P before felt encoding, eliminating non-injective leaf aliasing and preventing shared nullifier lockups in the zk-wormhole[cite: 70, 71].Release-Enforced Quantum Alignment & Zero-Division Guard (
chain/pallets/mining-rewards/src/lib.rs):quantize()to return(zero, amount)whenleaf_quantum()is zero, preventing potential divide-by-zero panics inside the criticalon_finalizeconsensus hook[cite: 70, 72].mint_reward(), ensuring only multiples ofAMOUNT_SCALE_DOWN_FACTORare minted into circulation while retaining sub-quantum dust inCollectedFeesacross all build targets[cite: 70, 72].Verification
canonicalize_account_byteswith existing lossy encoding paths[cite: 70, 71].