Move pedersen_hash() to go with the other Sapling hash functions, for now
This commit is contained in:
parent
0242df30cb
commit
a3530b0eed
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue