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ᵢ⟩
|
/// ⟨Mᵢ⟩
|
||||||
///
|
///
|
||||||
/// Σ j={0,k-1}: (1 - 2x₂)⋅(1 + x₀ + 2x₁)⋅2^(4⋅j)
|
/// Σ 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
|
// This is less efficient than it could be so that it can match the math
|
||||||
// closely.
|
// closely.
|
||||||
fn M_i(segment: &BitSlice<Lsb0, u8>) -> jubjub::Fr {
|
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
|
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
|
/// Mixing Pedersen Hash Function
|
||||||
///
|
///
|
||||||
/// Used to compute ρ from a note commitment and its position in the note
|
/// 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 proptest_derive::Arbitrary;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
commitments::sapling::pedersen_hash_to_point,
|
commitments::sapling::pedersen_hash,
|
||||||
serialization::{SerializationError, ZcashDeserialize, ZcashSerialize},
|
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 Hash Function
|
||||||
///
|
///
|
||||||
/// MerkleCRH^Sapling(layer, left, right) := PedersenHash(“Zcash_PH”, l || left ||right)
|
/// MerkleCRH^Sapling(layer, left, right) := PedersenHash(“Zcash_PH”, l || left ||right)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue