pub fn merkle_tree_hash(
    tree_type: TreeType,
    depth: usize,
    left: &<Scalar as PrimeField>::Repr,
    right: &<Scalar as PrimeField>::Repr,
) -> <Scalar as PrimeField>::Repr {
    assert_eq!(depth >> 8, 0);

    let left = {
        let mut tmp = [false; 256];
        for (a, b) in tmp.iter_mut().zip(left.as_bits::<order::Lsb0>()) {
            *a = *b;
        }
        tmp
    };

    let right = {
        let mut tmp = [false; 256];
        for (a, b) in tmp.iter_mut().zip(right.as_bits::<order::Lsb0>()) {
            *a = *b;
        }
        tmp
    };

    jubjub::ExtendedPoint::from(pedersen_hash(
        Personalisation::MerkleTree(tree_type, depth),
        left.iter()
            .copied()
            .take(Scalar::NUM_BITS as usize)
            .chain(right.iter().copied().take(Scalar::NUM_BITS as usize)),
    ))
    .to_affine()
    .get_u()
    .to_repr()
}
/// Compute the hash of two nodes `left` and `right` in a Merkle tree with the given personalisation.
Compute the hash of two nodes `left` and `right` in a Merkle tree with the given personalisation.
Compute the hash of two nodes ` left ` and ` right ` in a Merkle tree with the given personalisation .
pub fn merkle_tree_hash(
    tree_type: TreeType,
    depth: usize,
    left: &<Scalar as PrimeField>::Repr,
    right: &<Scalar as PrimeField>::Repr,
) -> <Scalar as PrimeField>::Repr {
    assert_eq!(depth >> 8, 0);
    let left = {
        let mut tmp = [false; 256];
        for (a, b) in tmp.iter_mut().zip(left.as_bits::<order::Lsb0>()) {
            *a = *b;
        }
        tmp
    };
    let right = {
        let mut tmp = [false; 256];
        for (a, b) in tmp.iter_mut().zip(right.as_bits::<order::Lsb0>()) {
            *a = *b;
        }
        tmp
    };
    jubjub::ExtendedPoint::from(pedersen_hash(
        Personalisation::MerkleTree(tree_type, depth),
        left.iter()
            .copied()
            .take(Scalar::NUM_BITS as usize)
            .chain(right.iter().copied().take(Scalar::NUM_BITS as usize)),
    ))
    .to_affine()
    .get_u()
    .to_repr()
}
pub fn merkle_tree_hash ( tree_type : TreeType , depth : usize , left : & < Scalar as PrimeField > :: Repr , right : & < Scalar as PrimeField > :: Repr , ) -> < Scalar as PrimeField > :: Repr { assert_eq ! ( depth 8 0 ) ; let left = { let mut tmp = [ false ; 256 ] ; for ( a , b ) in tmp . iter_mut ( ) . zip ( left . as_bits :: < order :: Lsb0 > ( ) ) { * a = * b ; } tmp } ; let right = { let mut tmp = [ false ; 256 ] ; for ( a , b ) in tmp . iter_mut ( ) . zip ( right . as_bits :: < order :: Lsb0 > ( ) ) { * a = * b ; } tmp } ; jubjub :: ExtendedPoint :: from ( pedersen_hash ( Personalisation :: MerkleTree ( tree_type , depth ) , left . iter ( ) . copied ( ) . take ( Scalar :: NUM_BITS as usize ) . chain ( right . iter ( ) . copied ( ) . take ( Scalar :: NUM_BITS as usize ) ) , ) ) . to_affine ( ) . get_u ( ) . to_repr ( ) }
Compute the hash of two nodes `left` and `right` in a Merkle tree with the given personalisation.
Compute the hash of two nodes ` left ` and ` right ` in a Merkle tree with the given personalisation .
tree_type
TreeType
depth
usize
left
&<Scalar as PrimeField>::Repr
right
&<Scalar as PrimeField>::Repr
tree_type
TreeType
depth
usize
left
&<Scalar as PrimeField>::Repr
right
&<Scalar as PrimeField>::Repr