Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improved get_sigma_map() and fixed warnings #28

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions gen/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ use std::path::Path;
use std::{env, fs};
extern crate alloc;
use alloc::alloc::{alloc, Layout};
use alloc::boxed::Box;
use alloc::vec::Vec;

use plonky2_field::goldilocks_field::GoldilocksField;
use plonky2_field::ops::Square;
Expand Down
5 changes: 2 additions & 3 deletions plonky2/src/gates/high_degree_interpolation.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use alloc::string::String;
use alloc::vec::Vec;
use alloc::{format, vec};
use core::marker::PhantomData;
use core::ops::Range;
Expand Down Expand Up @@ -381,9 +379,10 @@ mod tests {
let coeffs = PolynomialCoeffs::new(vec![FF::rand(), FF::rand()]);
let eval_point = FF::rand();
let gate = HighDegreeInterpolationGate::<F, D>::new(1);
let wires = get_wires(&gate, shift, coeffs, eval_point);
let vars = EvaluationVars {
local_constants: &[],
local_wires: &get_wires(&gate, shift, coeffs, eval_point),
local_wires: wires.as_slice(),
public_inputs_hash: &HashOut::rand(),
};

Expand Down
3 changes: 3 additions & 0 deletions plonky2/src/gates/interpolation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ pub(crate) trait InterpolationGate<F: RichField + Extendable<D>, const D: usize>
{
fn new(subgroup_bits: usize) -> Self;

#[allow(dead_code)]
fn id(&self) -> String {
// Custom implementation to not have the entire lookup table
format!("InterpolationGate",)
}

#[allow(dead_code)]
fn serialize(
&self,
_dst: &mut Vec<u8>,
Expand All @@ -26,6 +28,7 @@ pub(crate) trait InterpolationGate<F: RichField + Extendable<D>, const D: usize>
todo!()
}

#[allow(dead_code)]
fn deserialize(_src: &mut Buffer, _common_data: &CommonCircuitData<F, D>) -> IoResult<Self> {
todo!()
}
Expand Down
5 changes: 2 additions & 3 deletions plonky2/src/gates/low_degree_interpolation.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use alloc::string::String;
use alloc::vec::Vec;
use alloc::{format, vec};
use core::marker::PhantomData;
use core::ops::Range;
Expand Down Expand Up @@ -701,9 +699,10 @@ mod tests {
let coeffs = PolynomialCoeffs::new(FF::rand_vec(1 << subgroup_bits));
let eval_point = FF::rand();
let gate = LowDegreeInterpolationGate::<F, D>::new(subgroup_bits);
let wires = get_wires(&gate, shift, coeffs, eval_point);
let vars = EvaluationVars {
local_constants: &[],
local_wires: &get_wires(&gate, shift, coeffs, eval_point),
local_wires: wires.as_slice(),
public_inputs_hash: &HashOut::rand(),
};

Expand Down
4 changes: 2 additions & 2 deletions plonky2/src/hash/poseidon2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ where
}

trait P2Permutation<T: Clone>: Clone + Sync {

#[allow(dead_code)]
fn permute(&self, mut input: T) -> T {
self.permute_mut(&mut input);
input
Expand Down Expand Up @@ -663,8 +665,6 @@ impl<F: RichField + Poseidon2> AlgebraicHasher<F> for Poseidon2Hash {

#[cfg(test)]
mod tests {
use alloc::vec::Vec;

use plonky2_field::goldilocks_field::GoldilocksField;
use plonky2_field::types::Field;
use rand::Rng;
Expand Down
22 changes: 22 additions & 0 deletions plonky2/src/plonk/permutation_argument.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,27 @@ impl WirePartition {
// other words, find the next wire in the given wire's partition. If the given wire is last in
// its partition, this will loop around. If the given wire has a partition all to itself, it
// is considered its own neighbor.

// This new version is faster (does not use HashMap)
let mut neighbors: Vec<Vec<Wire>> = vec![vec![Wire {row: 0, column: 0}; num_routed_wires]; degree];
for subset in &self.partition {
for n in 0..subset.len() {
let r = subset[n].row;
let c = subset[n].column;
neighbors[r][c] = subset[(n + 1) % subset.len()];
}
}
let mut sigma = Vec::with_capacity(num_routed_wires * degree);
for column in 0..num_routed_wires {
for row in 0..degree {
let neighbor = neighbors[row][column];
sigma.push(neighbor.column * degree + neighbor.row);
}
}
sigma

// Old version: TODO - delete
/*
let mut neighbors = HashMap::with_capacity(self.partition.len());
for subset in &self.partition {
for n in 0..subset.len() {
Expand All @@ -154,5 +175,6 @@ impl WirePartition {
}
}
sigma
*/
}
}
Loading