Move pedersen_hash() to go with the other Sapling hash functions, for now

This commit is contained in:
Deirdre Connolly 2020-08-05 22:39:30 -04:00 committed by Deirdre Connolly
parent 0242df30cb
commit a3530b0eed
2 changed files with 9 additions and 11 deletions

View File

@ -55,8 +55,6 @@ pub fn pedersen_hash_to_point(domain: [u8; 8], M: &BitVec<Lsb0, u8>) -> jubjub::
/// ⟨Mᵢ⟩
///
/// Σ j={0,k-1}: (1 - 2x₂)⋅(1 + x₀ + 2x₁)⋅2^(4⋅j)
// XXX: Are internal functions doc'd?
//
// This is less efficient than it could be so that it can match the math
// closely.
fn M_i(segment: &BitSlice<Lsb0, u8>) -> jubjub::Fr {
@ -115,6 +113,14 @@ pub fn pedersen_hash_to_point(domain: [u8; 8], M: &BitVec<Lsb0, u8>) -> jubjub::
result
}
/// Pedersen Hash Function
///
/// https://zips.z.cash/protocol/protocol.pdf#concretepedersenhash
#[allow(non_snake_case)]
pub fn pedersen_hash(domain: [u8; 8], M: &BitVec<Lsb0, u8>) -> jubjub::Fq {
jubjub::AffinePoint::from(pedersen_hash_to_point(domain, M)).get_u()
}
/// Mixing Pedersen Hash Function
///
/// Used to compute ρ from a note commitment and its position in the note

View File

@ -20,18 +20,10 @@ use bitvec::prelude::*;
use proptest_derive::Arbitrary;
use crate::{
commitments::sapling::pedersen_hash_to_point,
commitments::sapling::pedersen_hash,
serialization::{SerializationError, ZcashDeserialize, ZcashSerialize},
};
/// Pedersen Hash Function
///
/// https://zips.z.cash/protocol/protocol.pdf#concretepedersenhash
#[allow(non_snake_case)]
fn pedersen_hash(domain: [u8; 8], M: &BitVec<Lsb0, u8>) -> jubjub::Fq {
jubjub::AffinePoint::from(pedersen_hash_to_point(domain, M)).get_u()
}
/// MerkleCRH^Sapling Hash Function
///
/// MerkleCRH^Sapling(layer, left, right) := PedersenHash(“Zcash_PH”, l || left ||right)