-
Notifications
You must be signed in to change notification settings - Fork 92
chore: add poseidon hash input error for non 32 bytes inputs #2337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
78699fa
e63151f
be86090
eb2e1e1
a3bb797
3b42764
6b99654
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -171,7 +171,8 @@ pub fn get_batch_update_inputs<const HEIGHT: usize>( | |
| let merkle_proof_array = merkle_proof.try_into().unwrap(); | ||
|
|
||
| // Use the adjusted index bytes for computing the nullifier. | ||
| let index_bytes = (*index).to_be_bytes(); | ||
| let mut index_bytes = [0u8; 32]; | ||
| index_bytes[28..].copy_from_slice(&(*index).to_be_bytes()); | ||
| let nullifier = Poseidon::hashv(&[leaf, &index_bytes, &tx_hashes[i]]).unwrap(); | ||
|
Comment on lines
+174
to
176
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Centralize this nullifier index encoding. This 32-byte/right-aligned layout is now open-coded in the prover, tests, and the on-chain nullifier path. In this codepath, any serialization drift changes every nullifier and derived root, so please move the index-buffer construction behind a single shared helper and call that here instead of rebuilding it inline. ♻️ Proposed refactor+fn nullifier_index_bytes(index: u32) -> [u8; 32] {
+ let mut bytes = [0u8; 32];
+ bytes[28..].copy_from_slice(&index.to_be_bytes());
+ bytes
+}
+
...
- let mut index_bytes = [0u8; 32];
- index_bytes[28..].copy_from_slice(&(*index).to_be_bytes());
+ let index_bytes = nullifier_index_bytes(*index);
let nullifier = Poseidon::hashv(&[leaf, &index_bytes, &tx_hashes[i]]).unwrap();🤖 Prompt for AI Agents |
||
| let (root, changelog_entry) = | ||
| compute_root_from_merkle_proof(nullifier, &merkle_proof_array, *index); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.