mirror of https://github.com/zcash/halo2.git
Rename poseidon::nullifier -> poseidon::p128pow5t3.
This commit is contained in:
parent
8e00f69d63
commit
764c445a81
|
@ -3,7 +3,7 @@ use std::array;
|
|||
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
|
||||
use ff::Field;
|
||||
use orchard::primitives::{
|
||||
poseidon::{self, ConstantLength, OrchardNullifier},
|
||||
poseidon::{self, ConstantLength, P128Pow5T3},
|
||||
sinsemilla,
|
||||
};
|
||||
|
||||
|
@ -21,7 +21,7 @@ fn bench_primitives(c: &mut Criterion) {
|
|||
let message = [pallas::Base::random(rng), pallas::Base::random(rng)];
|
||||
|
||||
group.bench_function("2-to-1", |b| {
|
||||
b.iter(|| poseidon::Hash::init(OrchardNullifier, ConstantLength).hash(message))
|
||||
b.iter(|| poseidon::Hash::init(P128Pow5T3, ConstantLength).hash(message))
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -244,7 +244,7 @@ impl plonk::Circuit<pallas::Base> for Circuit {
|
|||
// Configuration for the Poseidon hash.
|
||||
let poseidon_config = PoseidonChip::configure(
|
||||
meta,
|
||||
poseidon::OrchardNullifier,
|
||||
poseidon::P128Pow5T3,
|
||||
// We place the state columns after the partial_sbox column so that the
|
||||
// pad-and-add region can be layed out more efficiently.
|
||||
advices[6..9].try_into().unwrap(),
|
||||
|
@ -499,7 +499,7 @@ impl plonk::Circuit<pallas::Base> for Circuit {
|
|||
|| value.ok_or(plonk::Error::SynthesisError),
|
||||
)?;
|
||||
region.constrain_equal(var, message[i].cell())?;
|
||||
Ok(Word::<_, _, poseidon::OrchardNullifier, 3, 2>::from_inner(
|
||||
Ok(Word::<_, _, poseidon::P128Pow5T3, 3, 2>::from_inner(
|
||||
StateWord::new(var, value),
|
||||
))
|
||||
};
|
||||
|
|
|
@ -627,7 +627,7 @@ mod tests {
|
|||
use super::{PoseidonInstructions, Pow5T3Chip, Pow5T3Config, StateWord, WIDTH};
|
||||
use crate::{
|
||||
circuit::gadget::poseidon::{Hash, Word},
|
||||
primitives::poseidon::{self, ConstantLength, OrchardNullifier, Spec},
|
||||
primitives::poseidon::{self, ConstantLength, P128Pow5T3 as OrchardNullifier, Spec},
|
||||
};
|
||||
|
||||
struct PermuteCircuit {}
|
||||
|
|
|
@ -15,8 +15,8 @@ pub(crate) mod mds;
|
|||
#[cfg(test)]
|
||||
pub(crate) mod test_vectors;
|
||||
|
||||
mod nullifier;
|
||||
pub use nullifier::OrchardNullifier;
|
||||
mod p128pow5t3;
|
||||
pub use p128pow5t3::P128Pow5T3;
|
||||
|
||||
use grain::SboxType;
|
||||
|
||||
|
@ -365,7 +365,7 @@ mod tests {
|
|||
use halo2::arithmetic::FieldExt;
|
||||
use pasta_curves::pallas;
|
||||
|
||||
use super::{permute, ConstantLength, Hash, OrchardNullifier, Spec};
|
||||
use super::{permute, ConstantLength, Hash, P128Pow5T3 as OrchardNullifier, Spec};
|
||||
|
||||
#[test]
|
||||
fn orchard_spec_equivalence() {
|
||||
|
|
|
@ -13,9 +13,9 @@ use super::{
|
|||
/// This is conveniently an even number of partial rounds, making it easier to
|
||||
/// construct a Halo 2 circuit.
|
||||
#[derive(Debug)]
|
||||
pub struct OrchardNullifier;
|
||||
pub struct P128Pow5T3;
|
||||
|
||||
impl Spec<pallas::Base, 3, 2> for OrchardNullifier {
|
||||
impl Spec<pallas::Base, 3, 2> for P128Pow5T3 {
|
||||
fn full_rounds() -> usize {
|
||||
8
|
||||
}
|
||||
|
@ -53,9 +53,9 @@ mod tests {
|
|||
|
||||
use crate::primitives::poseidon::{permute, ConstantLength, Hash, Spec};
|
||||
|
||||
use super::{OrchardNullifier, MDS, MDS_INV, ROUND_CONSTANTS};
|
||||
use super::{MDS, MDS_INV, ROUND_CONSTANTS};
|
||||
|
||||
/// The same Poseidon specification as poseidon::OrchardNullifier, but constructed
|
||||
/// The same Poseidon specification as poseidon::P128Pow5T3, but constructed
|
||||
/// such that its constants will be generated at runtime.
|
||||
#[derive(Debug)]
|
||||
pub struct P128Pow5T3<F: FieldExt> {
|
||||
|
@ -166,7 +166,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn permute_test_vectors() {
|
||||
let (round_constants, mds, _) = OrchardNullifier.constants();
|
||||
let (round_constants, mds, _) = super::P128Pow5T3.constants();
|
||||
|
||||
for tv in crate::primitives::poseidon::test_vectors::permute() {
|
||||
let mut state = [
|
||||
|
@ -175,7 +175,7 @@ mod tests {
|
|||
pallas::Base::from_repr(tv.initial_state[2]).unwrap(),
|
||||
];
|
||||
|
||||
permute::<pallas::Base, OrchardNullifier, 3, 2>(&mut state, &mds, &round_constants);
|
||||
permute::<pallas::Base, super::P128Pow5T3, 3, 2>(&mut state, &mds, &round_constants);
|
||||
|
||||
for (expected, actual) in tv.final_state.iter().zip(state.iter()) {
|
||||
assert_eq!(&actual.to_repr(), expected);
|
||||
|
@ -191,7 +191,7 @@ mod tests {
|
|||
pallas::Base::from_repr(tv.input[1]).unwrap(),
|
||||
];
|
||||
|
||||
let result = Hash::init(OrchardNullifier, ConstantLength).hash(message);
|
||||
let result = Hash::init(super::P128Pow5T3, ConstantLength).hash(message);
|
||||
|
||||
assert_eq!(result.to_repr(), tv.output);
|
||||
}
|
|
@ -212,7 +212,7 @@ pub(crate) fn diversify_hash(d: &[u8; 11]) -> NonIdentityPallasPoint {
|
|||
///
|
||||
/// [concreteprfs]: https://zips.z.cash/protocol/nu5.pdf#concreteprfs
|
||||
pub(crate) fn prf_nf(nk: pallas::Base, rho: pallas::Base) -> pallas::Base {
|
||||
poseidon::Hash::init(poseidon::OrchardNullifier, poseidon::ConstantLength).hash([nk, rho])
|
||||
poseidon::Hash::init(poseidon::P128Pow5T3, poseidon::ConstantLength).hash([nk, rho])
|
||||
}
|
||||
|
||||
/// Defined in [Zcash Protocol Spec § 5.4.5.5: Orchard Key Agreement][concreteorchardkeyagreement].
|
||||
|
|
Loading…
Reference in New Issue