diff --git a/zebra-chain/src/commitments/sapling.rs b/zebra-chain/src/commitments/sapling.rs index a7ac12663..b94e169fd 100644 --- a/zebra-chain/src/commitments/sapling.rs +++ b/zebra-chain/src/commitments/sapling.rs @@ -91,9 +91,9 @@ pub fn pedersen_hash_to_point(domain: [u8; 8], M: &BitVec) -> jubjub:: tmp -= tmp.double(); } - // tmp * 2^(4*j) if j > 0 { - tmp *= (1..(4 * j)).fold(jubjub::Fr::one(), |acc, _| acc.double()); + // Inclusive range! + tmp *= (1..=(4 * j)).fold(jubjub::Fr::one(), |acc, _| acc.double()); } m_i += tmp; @@ -108,8 +108,13 @@ pub fn pedersen_hash_to_point(domain: [u8; 8], M: &BitVec) -> jubjub:: // segment with zeros. // // https://zips.z.cash/protocol/protocol.pdf#concretepedersenhash - for (i, segment) in M.chunks(189).enumerate() { - result += I_i(domain, i) * M_i(&segment) + for (i, segment) in M.chunks(189).enumerate().map(|(j, seg)| (j + 1, seg)) { + println!( + "I_i: {:?}", + jubjub::AffinePoint::from(I_i(domain, i)).to_bytes() + ); + result += I_i(domain, i) * M_i(&segment); + println!("result: {:?}", jubjub::AffinePoint::from(result).to_bytes()) } result @@ -339,8 +344,6 @@ mod tests { &test_vector.input_bits.clone(), )); - println!("{:?}", result); - //assert_eq!(jubjub::AffinePoint::from(result), test_vector.hash_point); } }