mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-08 16:53:07 +00:00
new fmt
This commit is contained in:
parent
bd427cd629
commit
f2ec2cadf4
@ -19,7 +19,7 @@ pub(crate) fn bench_gmimc<F: GMiMC<WIDTH>, const WIDTH: usize>(c: &mut Criterion
|
||||
|
||||
pub(crate) fn bench_poseidon<F: Poseidon<WIDTH>, const WIDTH: usize>(c: &mut Criterion)
|
||||
where
|
||||
[(); WIDTH - 1]: ,
|
||||
[(); WIDTH - 1]:,
|
||||
{
|
||||
c.bench_function(&format!("poseidon<{}, {}>", type_name::<F>(), WIDTH), |b| {
|
||||
b.iter_batched(
|
||||
|
||||
@ -34,7 +34,7 @@ mod tests {
|
||||
|
||||
fn test_add<F: ReducibleAVX2>()
|
||||
where
|
||||
[(); PackedPrimeField::<F>::WIDTH]: ,
|
||||
[(); PackedPrimeField::<F>::WIDTH]:,
|
||||
{
|
||||
let a_arr = test_vals_a::<F>();
|
||||
let b_arr = test_vals_b::<F>();
|
||||
@ -52,7 +52,7 @@ mod tests {
|
||||
|
||||
fn test_mul<F: ReducibleAVX2>()
|
||||
where
|
||||
[(); PackedPrimeField::<F>::WIDTH]: ,
|
||||
[(); PackedPrimeField::<F>::WIDTH]:,
|
||||
{
|
||||
let a_arr = test_vals_a::<F>();
|
||||
let b_arr = test_vals_b::<F>();
|
||||
@ -70,7 +70,7 @@ mod tests {
|
||||
|
||||
fn test_square<F: ReducibleAVX2>()
|
||||
where
|
||||
[(); PackedPrimeField::<F>::WIDTH]: ,
|
||||
[(); PackedPrimeField::<F>::WIDTH]:,
|
||||
{
|
||||
let a_arr = test_vals_a::<F>();
|
||||
|
||||
@ -86,7 +86,7 @@ mod tests {
|
||||
|
||||
fn test_neg<F: ReducibleAVX2>()
|
||||
where
|
||||
[(); PackedPrimeField::<F>::WIDTH]: ,
|
||||
[(); PackedPrimeField::<F>::WIDTH]:,
|
||||
{
|
||||
let a_arr = test_vals_a::<F>();
|
||||
|
||||
@ -102,7 +102,7 @@ mod tests {
|
||||
|
||||
fn test_sub<F: ReducibleAVX2>()
|
||||
where
|
||||
[(); PackedPrimeField::<F>::WIDTH]: ,
|
||||
[(); PackedPrimeField::<F>::WIDTH]:,
|
||||
{
|
||||
let a_arr = test_vals_a::<F>();
|
||||
let b_arr = test_vals_b::<F>();
|
||||
@ -120,7 +120,7 @@ mod tests {
|
||||
|
||||
fn test_interleave_is_involution<F: ReducibleAVX2>()
|
||||
where
|
||||
[(); PackedPrimeField::<F>::WIDTH]: ,
|
||||
[(); PackedPrimeField::<F>::WIDTH]:,
|
||||
{
|
||||
let a_arr = test_vals_a::<F>();
|
||||
let b_arr = test_vals_b::<F>();
|
||||
@ -144,7 +144,7 @@ mod tests {
|
||||
|
||||
fn test_interleave<F: ReducibleAVX2>()
|
||||
where
|
||||
[(); PackedPrimeField::<F>::WIDTH]: ,
|
||||
[(); PackedPrimeField::<F>::WIDTH]:,
|
||||
{
|
||||
let in_a: [F; 4] = [
|
||||
F::from_noncanonical_u64(00),
|
||||
|
||||
@ -15,7 +15,7 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
pub fn permute<const W: usize>(&mut self, inputs: [Target; W]) -> [Target; W]
|
||||
where
|
||||
F: GMiMC<W> + Poseidon<W>,
|
||||
[(); W - 1]: ,
|
||||
[(); W - 1]:,
|
||||
{
|
||||
// We don't want to swap any inputs, so set that wire to 0.
|
||||
let _false = self._false();
|
||||
@ -31,7 +31,7 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
) -> [Target; W]
|
||||
where
|
||||
F: GMiMC<W> + Poseidon<W>,
|
||||
[(); W - 1]: ,
|
||||
[(); W - 1]:,
|
||||
{
|
||||
match HASH_FAMILY {
|
||||
HashFamily::GMiMC => self.gmimc_permute_swapped(inputs, swap),
|
||||
@ -88,7 +88,7 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
) -> [Target; W]
|
||||
where
|
||||
F: Poseidon<W>,
|
||||
[(); W - 1]: ,
|
||||
[(); W - 1]:,
|
||||
{
|
||||
let gate_type = PoseidonGate::<F, D, W>::new();
|
||||
let gate = self.add_gate(gate_type, vec![]);
|
||||
|
||||
@ -26,7 +26,7 @@ pub struct PoseidonGate<
|
||||
const D: usize,
|
||||
const WIDTH: usize,
|
||||
> where
|
||||
[(); WIDTH - 1]: ,
|
||||
[(); WIDTH - 1]:,
|
||||
{
|
||||
_phantom: PhantomData<F>,
|
||||
}
|
||||
@ -34,7 +34,7 @@ pub struct PoseidonGate<
|
||||
impl<F: RichField + Extendable<D> + Poseidon<WIDTH>, const D: usize, const WIDTH: usize>
|
||||
PoseidonGate<F, D, WIDTH>
|
||||
where
|
||||
[(); WIDTH - 1]: ,
|
||||
[(); WIDTH - 1]:,
|
||||
{
|
||||
pub fn new() -> Self {
|
||||
PoseidonGate {
|
||||
@ -91,7 +91,7 @@ where
|
||||
impl<F: RichField + Extendable<D> + Poseidon<WIDTH>, const D: usize, const WIDTH: usize> Gate<F, D>
|
||||
for PoseidonGate<F, D, WIDTH>
|
||||
where
|
||||
[(); WIDTH - 1]: ,
|
||||
[(); WIDTH - 1]:,
|
||||
{
|
||||
fn id(&self) -> String {
|
||||
format!("{:?}<WIDTH={}>", self, WIDTH)
|
||||
@ -396,7 +396,7 @@ struct PoseidonGenerator<
|
||||
const D: usize,
|
||||
const WIDTH: usize,
|
||||
> where
|
||||
[(); WIDTH - 1]: ,
|
||||
[(); WIDTH - 1]:,
|
||||
{
|
||||
gate_index: usize,
|
||||
_phantom: PhantomData<F>,
|
||||
@ -405,7 +405,7 @@ struct PoseidonGenerator<
|
||||
impl<F: RichField + Extendable<D> + Poseidon<WIDTH>, const D: usize, const WIDTH: usize>
|
||||
SimpleGenerator<F> for PoseidonGenerator<F, D, WIDTH>
|
||||
where
|
||||
[(); WIDTH - 1]: ,
|
||||
[(); WIDTH - 1]:,
|
||||
{
|
||||
fn dependencies(&self) -> Vec<Target> {
|
||||
(0..WIDTH)
|
||||
|
||||
@ -21,7 +21,7 @@ pub struct PoseidonMdsGate<
|
||||
const D: usize,
|
||||
const WIDTH: usize,
|
||||
> where
|
||||
[(); WIDTH - 1]: ,
|
||||
[(); WIDTH - 1]:,
|
||||
{
|
||||
_phantom: PhantomData<F>,
|
||||
}
|
||||
@ -29,7 +29,7 @@ pub struct PoseidonMdsGate<
|
||||
impl<F: RichField + Extendable<D> + Poseidon<WIDTH>, const D: usize, const WIDTH: usize>
|
||||
PoseidonMdsGate<F, D, WIDTH>
|
||||
where
|
||||
[(); WIDTH - 1]: ,
|
||||
[(); WIDTH - 1]:,
|
||||
{
|
||||
pub fn new() -> Self {
|
||||
PoseidonMdsGate {
|
||||
@ -116,7 +116,7 @@ where
|
||||
impl<F: RichField + Extendable<D> + Poseidon<WIDTH>, const D: usize, const WIDTH: usize> Gate<F, D>
|
||||
for PoseidonMdsGate<F, D, WIDTH>
|
||||
where
|
||||
[(); WIDTH - 1]: ,
|
||||
[(); WIDTH - 1]:,
|
||||
{
|
||||
fn id(&self) -> String {
|
||||
format!("{:?}<WIDTH={}>", self, WIDTH)
|
||||
@ -207,7 +207,7 @@ where
|
||||
#[derive(Clone, Debug)]
|
||||
struct PoseidonMdsGenerator<const D: usize, const WIDTH: usize>
|
||||
where
|
||||
[(); WIDTH - 1]: ,
|
||||
[(); WIDTH - 1]:,
|
||||
{
|
||||
gate_index: usize,
|
||||
}
|
||||
@ -215,7 +215,7 @@ where
|
||||
impl<F: RichField + Extendable<D> + Poseidon<WIDTH>, const D: usize, const WIDTH: usize>
|
||||
SimpleGenerator<F> for PoseidonMdsGenerator<D, WIDTH>
|
||||
where
|
||||
[(); WIDTH - 1]: ,
|
||||
[(); WIDTH - 1]:,
|
||||
{
|
||||
fn dependencies(&self) -> Vec<Target> {
|
||||
(0..WIDTH)
|
||||
|
||||
@ -147,7 +147,7 @@ pub const ALL_ROUND_CONSTANTS: [u64; MAX_WIDTH * N_ROUNDS] = [
|
||||
pub trait Poseidon<const WIDTH: usize>: PrimeField
|
||||
where
|
||||
// magic to get const generic expressions to work
|
||||
[(); WIDTH - 1]: ,
|
||||
[(); WIDTH - 1]:,
|
||||
{
|
||||
// Total number of round constants required: width of the input
|
||||
// times number of rounds.
|
||||
@ -634,7 +634,7 @@ pub(crate) mod test_helpers {
|
||||
test_vectors: Vec<([u64; WIDTH], [u64; WIDTH])>,
|
||||
) where
|
||||
F: Poseidon<WIDTH>,
|
||||
[(); WIDTH - 1]: ,
|
||||
[(); WIDTH - 1]:,
|
||||
{
|
||||
for (input_, expected_output_) in test_vectors.into_iter() {
|
||||
let mut input = [F::ZERO; WIDTH];
|
||||
@ -652,7 +652,7 @@ pub(crate) mod test_helpers {
|
||||
pub(crate) fn check_consistency<F: Field, const WIDTH: usize>()
|
||||
where
|
||||
F: Poseidon<WIDTH>,
|
||||
[(); WIDTH - 1]: ,
|
||||
[(); WIDTH - 1]:,
|
||||
{
|
||||
let mut input = [F::ZERO; WIDTH];
|
||||
for i in 0..WIDTH {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user