generated from noir-lang/noir-library-starter
-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
pub fn check_membership<let N: u32, H>(
leaf: Field,
index: Field,
sibling_path: [Field; N],
root: Field,
) -> bool
where
H: Hasher + Default,
{
let calculated_root = compute_root_from_sibling_path::<N, H>(leaf, index, sibling_path);
calculated_root == root
}
pub fn assert_check_membership<let TREE_HEIGHT: u32, H>(
leaf: Field,
index: Field,
sibling_path: [Field; TREE_HEIGHT],
root: Field,
)
where
H: Hasher + Default,
{
assert(
check_membership::<TREE_HEIGHT, H>(leaf, index, sibling_path, root),
"membership check failed",
);
}
This function can be used to verify membership of internal nodes in addition to leaves. Maybe rename leaf to internal node, TREE_HEIGHT to SIBLING_PATH_LENGTH
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels