-
Notifications
You must be signed in to change notification settings - Fork 332
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
chore: removing leaf data type + related cleanup #3794
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,44 @@ | ||
use dep::protocol_types::{ | ||
abis::nullifier_leaf_preimage::{ | ||
NullifierLeafPreimage, | ||
NULLIFIER_LEAF_PREIMAGE_LENGTH, | ||
}, | ||
constants::NULLIFIER_TREE_HEIGHT, | ||
hash::pedersen_hash, | ||
}; | ||
use crate::utils::arr_copy_slice; | ||
|
||
global LEAF_DATA_LENGTH: Field = 3; | ||
// TODO: move this to constants.hpp so that it gets computed as INDEX_LENGTH + LEAF_DATA_LENGTH + NULLIFIER_TREE_HEIGHT | ||
// INDEX_LENGTH + NULLIFIER_LEAF_PREIMAGE_LENGTH + NULLIFIER_TREE_HEIGHT | ||
global NULLIFIER_MEMBERSHIP_WITNESS: Field = 24; | ||
|
||
// Noir version of LeafData interface from indexed merkle tree. | ||
// TODO(#3470) replace with /mnt/user-data/jan/aztec-packages/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/abis/nullifier_leaf_preimage.nr | ||
struct LeafData { | ||
value: Field, | ||
next_index: Field, | ||
next_value: Field, | ||
} | ||
|
||
impl LeafData { | ||
fn serialize(self) -> [Field; LEAF_DATA_LENGTH] { | ||
[self.value, self.next_index, self.next_value] | ||
} | ||
|
||
fn hash(self) -> Field { | ||
// Performs the same hashing as StandardIndexedTree::encodeLeaf(...) | ||
pedersen_hash(self.serialize(), 0) | ||
} | ||
} | ||
|
||
struct NullifierMembershipWitness { | ||
index: Field, | ||
leaf_data: LeafData, | ||
leaf_preimage: NullifierLeafPreimage, | ||
path: [Field; NULLIFIER_TREE_HEIGHT], | ||
} | ||
|
||
impl NullifierMembershipWitness { | ||
pub fn deserialize(fields: [Field; NULLIFIER_MEMBERSHIP_WITNESS]) -> Self { | ||
let leaf_preimage_fields = arr_copy_slice(fields, [0; NULLIFIER_LEAF_PREIMAGE_LENGTH], 1); | ||
Self { | ||
index: fields[0], | ||
leaf_preimage: NullifierLeafPreimage::deserialize(leaf_preimage_fields), | ||
path: arr_copy_slice(fields, [0; NULLIFIER_TREE_HEIGHT], 1 + NULLIFIER_LEAF_PREIMAGE_LENGTH) | ||
} | ||
} | ||
} | ||
|
||
#[oracle(getLowNullifierMembershipWitness)] | ||
fn get_low_nullifier_membership_witness_oracle(_block_number: u32, _nullifier: Field) -> [Field; NULLIFIER_MEMBERSHIP_WITNESS] {} | ||
fn get_low_nullifier_membership_witness_oracle( | ||
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. Was the formatting not run before this? 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. It was run but with an older nargo which did not wrap lines correctly. I will send a PR later in which I will fix it. |
||
_block_number: u32, | ||
_nullifier: Field | ||
) -> [Field; NULLIFIER_MEMBERSHIP_WITNESS] {} | ||
|
||
// Nullifier here refers to the nullifier we are looking to get non-inclusion proof for (by proving that a lower | ||
// nullifier's next_value is bigger than the nullifier) | ||
unconstrained pub fn get_low_nullifier_membership_witness(block_number: u32, nullifier: Field) -> NullifierMembershipWitness { | ||
let fields = get_low_nullifier_membership_witness_oracle(block_number, nullifier); | ||
NullifierMembershipWitness { | ||
index: fields[0], | ||
leaf_data: LeafData { value: fields[1], next_index: fields[2], next_value: fields[3] }, | ||
path: arr_copy_slice(fields, [0; NULLIFIER_TREE_HEIGHT], 1 + LEAF_DATA_LENGTH) | ||
} | ||
NullifierMembershipWitness::deserialize(fields) | ||
} | ||
|
||
#[oracle(getNullifierMembershipWitness)] | ||
|
@@ -54,9 +48,5 @@ fn get_nullifier_membership_witness_oracle(_block_number: u32, _nullifier: Field | |
// nullifier's next_value is bigger than the nullifier) | ||
unconstrained pub fn get_nullifier_membership_witness(block_number: u32, nullifier: Field) -> NullifierMembershipWitness { | ||
let fields = get_nullifier_membership_witness_oracle(block_number, nullifier); | ||
NullifierMembershipWitness { | ||
index: fields[0], | ||
leaf_data: LeafData { value: fields[1], next_index: fields[2], next_value: fields[3] }, | ||
path: arr_copy_slice(fields, [0; NULLIFIER_TREE_HEIGHT], 1 + LEAF_DATA_LENGTH) | ||
} | ||
} | ||
NullifierMembershipWitness::deserialize(fields) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
mod nullifier_leaf_preimage; | ||
mod public_data_tree_leaf; | ||
mod append_only_tree_snapshot; | ||
mod global_variables; | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be in the constants such that it is computed in there instead of being a custom value in here. The noir constants are used to generate the other values so should be fine for handling it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it now possible to compute a constant in Noir?
constants.hpp
is no longer used so as far as I know we don't have a way to do this anymore.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I was thinking just moving it into the constants, but guess it is already based on stuff from constants so might be useless actually.