Skip to content

Commit

Permalink
add get_subtree_index for proofs
Browse files Browse the repository at this point in the history
  • Loading branch information
ralexstokes committed Mar 28, 2024
1 parent b457df2 commit a0fff31
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ssz-rs/src/merkleization/proofs.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
use crate::merkleization::{MerkleizationError as Error, Node};
use crate::merkleization::{
generalized_index::log_2, GeneralizedIndex, MerkleizationError as Error, Node,
};
use sha2::{Digest, Sha256};

pub fn get_subtree_index(i: GeneralizedIndex) -> Result<usize, Error> {
let i_log2 = log_2(i).ok_or(Error::InvalidGeneralizedIndex)?;
Ok(i % 2usize.pow(i_log2))
}

/// `is_valid_merkle_branch` verifies the Merkle proof
/// against the `root` given the other metadata.
pub fn is_valid_merkle_branch<T: AsRef<[u8]>>(
Expand Down

0 comments on commit a0fff31

Please sign in to comment.