This commit is contained in:
Giacomo Pasini 2024-12-23 16:19:48 +01:00
parent f5af878540
commit 720a7f458e
No known key found for this signature in database
GPG Key ID: FC08489D2D895D4B
2 changed files with 7 additions and 7 deletions

View File

@ -28,9 +28,9 @@ pub fn sparse_root(elems: &BTreeSet<[u8; 32]>) -> [u8; 32] {
fn sparse_root_rec(prefix: u64, elems: &BTreeSet<[u8; 32]>) -> [u8; 32] {
if elems.is_empty() {
return empty_tree_root(256 - prefix);
return empty_tree_root(64 - prefix);
}
if prefix == 256 {
if prefix == 64 {
assert_eq!(elems.len(), 1);
return PRESENT;
}
@ -50,7 +50,7 @@ pub fn sparse_path(elem: [u8; 32], elems: &BTreeSet<[u8; 32]>) -> Vec<merkle::Pa
elem: [u8; 32],
elems: &BTreeSet<[u8; 32]>,
) -> Vec<merkle::PathNode> {
if prefix == 256 {
if prefix == 64 {
return Vec::new();
}
// partition the elements
@ -79,7 +79,7 @@ pub fn sparse_path(elem: [u8; 32], elems: &BTreeSet<[u8; 32]>) -> Vec<merkle::Pa
}
pub fn path_key(path: &[merkle::PathNode]) -> [u8; 32] {
assert_eq!(path.len(), 256);
assert_eq!(path.len(), 64);
let mut key = [0u8; 32];
for byte_i in (0..32).rev() {

View File

@ -51,7 +51,7 @@ impl CompactNullifierProofs {
for path in input {
let mut path_bits = [0u8; 32];
assert_eq!(path.len(), 256);
assert_eq!(path.len(), 64);
for (i, node) in path.iter().enumerate().rev() {
match node {
@ -102,9 +102,9 @@ impl<'a> Iterator for CompactNfIterator {
let path = self.paths.pop().unwrap();
let mut res = Vec::with_capacity(256);
let mut res = Vec::with_capacity(64);
for i in 0..=255 {
for i in 0..=63 {
if get_bit(i, path) {
res.push(merkle::PathNode::Right(
self.siblings[self.siblings.len() - 32..]