Move pedersen hashes to sapling module.

This commit is contained in:
Kris Nuttycombe 2021-03-04 14:23:24 -07:00 committed by Jack Grigg
parent 88d58aac0a
commit bc087a5ff7
8 changed files with 13 additions and 15 deletions

View File

@ -1,6 +1,6 @@
use criterion::{criterion_group, criterion_main, Criterion}; use criterion::{criterion_group, criterion_main, Criterion};
use rand_core::{OsRng, RngCore}; use rand_core::{OsRng, RngCore};
use zcash_primitives::pedersen_hash::{pedersen_hash, Personalization}; use zcash_primitives::sapling::pedersen_hash::{pedersen_hash, Personalization};
fn bench_pedersen_hash(c: &mut Criterion) { fn bench_pedersen_hash(c: &mut Criterion) {
let rng = &mut OsRng; let rng = &mut OsRng;

View File

@ -15,7 +15,6 @@ pub mod legacy;
pub mod memo; pub mod memo;
pub mod merkle_tree; pub mod merkle_tree;
pub mod note_encryption; pub mod note_encryption;
pub mod pedersen_hash;
pub mod primitives; pub mod primitives;
pub mod sapling; pub mod sapling;
pub mod serialize; pub mod serialize;

View File

@ -10,7 +10,7 @@ use crate::constants;
use crate::sapling::group_hash::group_hash; use crate::sapling::group_hash::group_hash;
use crate::pedersen_hash::{pedersen_hash, Personalization}; use crate::sapling::pedersen_hash::{pedersen_hash, Personalization};
use byteorder::{LittleEndian, WriteBytesExt}; use byteorder::{LittleEndian, WriteBytesExt};

View File

@ -1,6 +1,7 @@
//! Structs and constants specific to the Sapling shielded pool. //! Structs and constants specific to the Sapling shielded pool.
pub mod group_hash; pub mod group_hash;
pub mod pedersen_hash;
pub mod prover; pub mod prover;
pub mod redjubjub; pub mod redjubjub;
pub mod util; pub mod util;
@ -12,14 +13,12 @@ use lazy_static::lazy_static;
use rand_core::{CryptoRng, RngCore}; use rand_core::{CryptoRng, RngCore};
use std::io::{self, Read, Write}; use std::io::{self, Read, Write};
use crate::{ use crate::{constants::SPENDING_KEY_GENERATOR, merkle_tree::Hashable, primitives::Note};
constants::SPENDING_KEY_GENERATOR,
merkle_tree::Hashable,
pedersen_hash::{pedersen_hash, Personalization},
primitives::Note,
};
use self::redjubjub::{PrivateKey, PublicKey, Signature}; use self::{
pedersen_hash::{pedersen_hash, Personalization},
redjubjub::{PrivateKey, PublicKey, Signature},
};
pub const SAPLING_COMMITMENT_TREE_DEPTH: usize = 32; pub const SAPLING_COMMITMENT_TREE_DEPTH: usize = 32;

View File

@ -1,6 +1,6 @@
//! Test vectors from https://github.com/zcash-hackworks/zcash-test-vectors/blob/master/sapling_pedersen.py //! Test vectors from https://github.com/zcash-hackworks/zcash-test-vectors/blob/master/sapling_pedersen.py
use crate::pedersen_hash::{test::TestVector, Personalization}; use crate::sapling::pedersen_hash::{test::TestVector, Personalization};
pub fn get_vectors<'a>() -> Vec<TestVector<'a>> { pub fn get_vectors<'a>() -> Vec<TestVector<'a>> {
return vec![ return vec![

View File

@ -4,7 +4,7 @@ use super::ecc::{EdwardsPoint, MontgomeryPoint};
use bellman::gadgets::boolean::Boolean; use bellman::gadgets::boolean::Boolean;
use bellman::gadgets::lookup::*; use bellman::gadgets::lookup::*;
use bellman::{ConstraintSystem, SynthesisError}; use bellman::{ConstraintSystem, SynthesisError};
pub use zcash_primitives::pedersen_hash::Personalization; pub use zcash_primitives::sapling::pedersen_hash::Personalization;
use crate::constants::PEDERSEN_CIRCUIT_GENERATORS; use crate::constants::PEDERSEN_CIRCUIT_GENERATORS;
@ -111,7 +111,7 @@ mod test {
use group::Curve; use group::Curve;
use rand_core::{RngCore, SeedableRng}; use rand_core::{RngCore, SeedableRng};
use rand_xorshift::XorShiftRng; use rand_xorshift::XorShiftRng;
use zcash_primitives::pedersen_hash; use zcash_primitives::sapling::pedersen_hash;
/// Predict the number of constraints of a Pedersen hash /// Predict the number of constraints of a Pedersen hash
fn ph_num_constraints(input_bits: usize) -> usize { fn ph_num_constraints(input_bits: usize) -> usize {

View File

@ -517,8 +517,8 @@ fn test_input_circuit_with_bls12_381() {
use rand_core::{RngCore, SeedableRng}; use rand_core::{RngCore, SeedableRng};
use rand_xorshift::XorShiftRng; use rand_xorshift::XorShiftRng;
use zcash_primitives::{ use zcash_primitives::{
pedersen_hash,
primitives::{Diversifier, Note, ProofGenerationKey, Rseed}, primitives::{Diversifier, Note, ProofGenerationKey, Rseed},
sapling::pedersen_hash,
}; };
let mut rng = XorShiftRng::from_seed([ let mut rng = XorShiftRng::from_seed([
@ -660,8 +660,8 @@ fn test_input_circuit_with_bls12_381_external_test_vectors() {
use rand_core::{RngCore, SeedableRng}; use rand_core::{RngCore, SeedableRng};
use rand_xorshift::XorShiftRng; use rand_xorshift::XorShiftRng;
use zcash_primitives::{ use zcash_primitives::{
pedersen_hash,
primitives::{Diversifier, Note, ProofGenerationKey, Rseed}, primitives::{Diversifier, Note, ProofGenerationKey, Rseed},
sapling::pedersen_hash,
}; };
let mut rng = XorShiftRng::from_seed([ let mut rng = XorShiftRng::from_seed([