mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-08 16:53:07 +00:00
Move permutations to their specific files
This commit is contained in:
parent
a0a42e4bef
commit
df2b6e76b7
@ -5,7 +5,7 @@ use unroll::unroll_for_loops;
|
||||
|
||||
use crate::gates::gmimc::GMiMCGate;
|
||||
use crate::hash::hash_types::{HashOut, RichField};
|
||||
use crate::hash::hashing::{compress, hash_n_to_hash, GMiMCPermutation, SPONGE_WIDTH};
|
||||
use crate::hash::hashing::{compress, hash_n_to_hash, PlonkyPermutation, SPONGE_WIDTH};
|
||||
use crate::iop::target::{BoolTarget, Target};
|
||||
use crate::plonk::circuit_builder::CircuitBuilder;
|
||||
use crate::plonk::config::{AlgebraicHasher, Hasher};
|
||||
@ -93,6 +93,13 @@ impl GMiMC<12> for GoldilocksField {
|
||||
const ROUND_CONSTANTS: [u64; NUM_ROUNDS] = GOLDILOCKS_ROUND_CONSTANTS;
|
||||
}
|
||||
|
||||
pub struct GMiMCPermutation;
|
||||
impl<F: RichField> PlonkyPermutation<F> for GMiMCPermutation {
|
||||
fn permute(input: [F; SPONGE_WIDTH]) -> [F; SPONGE_WIDTH] {
|
||||
F::gmimc_permute(input)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
pub struct GMiMCHash;
|
||||
impl<F: RichField> Hasher<F> for GMiMCHash {
|
||||
|
||||
@ -97,19 +97,6 @@ pub trait PlonkyPermutation<F: RichField> {
|
||||
fn permute(input: [F; SPONGE_WIDTH]) -> [F; SPONGE_WIDTH];
|
||||
}
|
||||
|
||||
pub struct PoseidonPermutation;
|
||||
impl<F: RichField> PlonkyPermutation<F> for PoseidonPermutation {
|
||||
fn permute(input: [F; SPONGE_WIDTH]) -> [F; SPONGE_WIDTH] {
|
||||
F::poseidon(input)
|
||||
}
|
||||
}
|
||||
pub struct GMiMCPermutation;
|
||||
impl<F: RichField> PlonkyPermutation<F> for GMiMCPermutation {
|
||||
fn permute(input: [F; SPONGE_WIDTH]) -> [F; SPONGE_WIDTH] {
|
||||
F::gmimc_permute(input)
|
||||
}
|
||||
}
|
||||
|
||||
/// If `pad` is enabled, the message is padded using the pad10*1 rule. In general this is required
|
||||
/// for the hash to be secure, but it can safely be disabled in certain cases, like if the input
|
||||
/// length is fixed.
|
||||
|
||||
@ -9,7 +9,7 @@ use crate::gates::gate::Gate;
|
||||
use crate::gates::poseidon::PoseidonGate;
|
||||
use crate::gates::poseidon_mds::PoseidonMdsGate;
|
||||
use crate::hash::hash_types::{HashOut, RichField};
|
||||
use crate::hash::hashing::{compress, hash_n_to_hash, PoseidonPermutation, SPONGE_WIDTH};
|
||||
use crate::hash::hashing::{compress, hash_n_to_hash, PlonkyPermutation, SPONGE_WIDTH};
|
||||
use crate::iop::ext_target::ExtensionTarget;
|
||||
use crate::iop::target::{BoolTarget, Target};
|
||||
use crate::plonk::circuit_builder::CircuitBuilder;
|
||||
@ -618,6 +618,13 @@ pub trait Poseidon: PrimeField {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct PoseidonPermutation;
|
||||
impl<F: RichField> PlonkyPermutation<F> for PoseidonPermutation {
|
||||
fn permute(input: [F; SPONGE_WIDTH]) -> [F; SPONGE_WIDTH] {
|
||||
F::poseidon(input)
|
||||
}
|
||||
}
|
||||
|
||||
/// Poseidon hash function.
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
pub struct PoseidonHash;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user