diff --git a/src/hash/hashing.rs b/src/hash/hashing.rs index ae14e058..00cd0a74 100644 --- a/src/hash/hashing.rs +++ b/src/hash/hashing.rs @@ -2,6 +2,7 @@ use crate::field::extension_field::Extendable; use crate::field::field_types::RichField; +use crate::gates::poseidon::PoseidonGate; use crate::hash::hash_types::{HashOut, HashOutTarget}; use crate::iop::target::Target; use crate::plonk::circuit_builder::CircuitBuilder; @@ -11,6 +12,7 @@ pub(crate) const SPONGE_CAPACITY: usize = 4; pub(crate) const SPONGE_WIDTH: usize = SPONGE_RATE + SPONGE_CAPACITY; pub(crate) const HASH_FAMILY: HashFamily = HashFamily::Poseidon; +pub(crate) type HashGate = PoseidonGate; pub(crate) enum HashFamily { GMiMC, diff --git a/src/hash/merkle_proofs.rs b/src/hash/merkle_proofs.rs index 793e114c..7a176dd9 100644 --- a/src/hash/merkle_proofs.rs +++ b/src/hash/merkle_proofs.rs @@ -6,9 +6,8 @@ use serde::{Deserialize, Serialize}; use crate::field::extension_field::target::ExtensionTarget; use crate::field::extension_field::Extendable; use crate::field::field_types::{Field, RichField}; -use crate::gates::gmimc::GMiMCGate; use crate::hash::hash_types::{HashOut, HashOutTarget, MerkleCapTarget}; -use crate::hash::hashing::{compress, hash_or_noop}; +use crate::hash::hashing::{compress, hash_or_noop, HashGate}; use crate::hash::merkle_tree::MerkleCap; use crate::iop::target::{BoolTarget, Target}; use crate::iop::wire::Wire; @@ -107,10 +106,10 @@ impl, const D: usize> CircuitBuilder { let mut state: HashOutTarget = self.hash_or_noop(leaf_data); for (&bit, &sibling) in leaf_index_bits.iter().zip(&proof.siblings) { - let gate_type = GMiMCGate::::new(); + let gate_type = HashGate::::new(); let gate = self.add_gate(gate_type, vec![]); - let swap_wire = GMiMCGate::::WIRE_SWAP; + let swap_wire = HashGate::::WIRE_SWAP; let swap_wire = Target::Wire(Wire { gate, input: swap_wire, @@ -121,7 +120,7 @@ impl, const D: usize> CircuitBuilder { .map(|i| { Target::Wire(Wire { gate, - input: GMiMCGate::::wire_input(i), + input: HashGate::::wire_input(i), }) }) .collect::>(); @@ -137,7 +136,7 @@ impl, const D: usize> CircuitBuilder { .map(|i| { Target::Wire(Wire { gate, - input: GMiMCGate::::wire_output(i), + input: HashGate::::wire_output(i), }) }) .collect(), diff --git a/src/hash/poseidon.rs b/src/hash/poseidon.rs index d3c42bc6..16f9117d 100644 --- a/src/hash/poseidon.rs +++ b/src/hash/poseidon.rs @@ -545,10 +545,7 @@ where x: ExtensionTarget, ) -> ExtensionTarget { // x |--> x^7 - let x2 = builder.mul_extension(x, x); - let x4 = builder.mul_extension(x2, x2); - let x3 = builder.mul_extension(x, x2); - builder.mul_extension(x3, x4) + builder.exp_u64_extension(x, 7) } #[inline(always)]