2021-01-29 06:26:52 -08:00
|
|
|
//! Gadget and chips for the Poseidon algebraic hash function.
|
|
|
|
|
|
|
|
use std::fmt;
|
|
|
|
|
|
|
|
use halo2::{
|
|
|
|
arithmetic::FieldExt,
|
|
|
|
circuit::{Chip, Layouter},
|
|
|
|
plonk::Error,
|
|
|
|
};
|
|
|
|
|
2021-02-08 14:56:58 -08:00
|
|
|
mod pow5t3;
|
|
|
|
pub use pow5t3::{Pow5T3Chip, Pow5T3Config};
|
|
|
|
|
2021-04-01 21:03:56 -07:00
|
|
|
use crate::primitives::poseidon::{Spec, State};
|
|
|
|
|
|
|
|
/// The set of circuit instructions required to use the Poseidon permutation.
|
|
|
|
pub trait PoseidonInstructions<F: FieldExt, S: Spec<F, T, RATE>, const T: usize, const RATE: usize>:
|
|
|
|
Chip<F>
|
|
|
|
{
|
|
|
|
/// Variable representing the word over which the Poseidon permutation operates.
|
|
|
|
type Word: fmt::Debug;
|
2021-01-29 06:26:52 -08:00
|
|
|
|
|
|
|
/// Applies the Poseidon permutation to the given state.
|
|
|
|
fn permute(
|
|
|
|
&self,
|
|
|
|
layouter: &mut impl Layouter<F>,
|
2021-04-01 21:03:56 -07:00
|
|
|
initial_state: &State<Self::Word, T>,
|
|
|
|
) -> Result<State<Self::Word, T>, Error>;
|
2021-01-29 06:26:52 -08:00
|
|
|
}
|