Skip to content

Commit

Permalink
feat(bellman): declare naive main gate (#28)
Browse files Browse the repository at this point in the history
This PR introduces a new main gate type that has only 3 columns without
support for custom gates and lookup.
  • Loading branch information
saitima authored Oct 29, 2024
1 parent 6579bdb commit 5f563e0
Show file tree
Hide file tree
Showing 4 changed files with 632 additions and 2 deletions.
14 changes: 12 additions & 2 deletions crates/bellman/src/plonk/better_better_cs/cs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::bit_vec::BitVec;
use crate::pairing::ff::{Field, PrimeField, PrimeFieldRepr};
use crate::pairing::{CurveAffine, CurveProjective, Engine};

Expand Down Expand Up @@ -146,6 +145,7 @@ pub trait Gate<E: Engine>: GateInternal<E> + Sized + Clone + std::hash::Hash + s
}
}

use bit_vec::BitVec;
use serde::{Deserialize, Serialize};
use smallvec::SmallVec;

Expand Down Expand Up @@ -665,6 +665,16 @@ pub trait ConstraintSystem<E: Engine> {
fn get_current_aux_gate_number(&self) -> usize;
}

#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub struct PlonkCsWidth3Params;
impl<E: Engine> PlonkConstraintSystemParams<E> for PlonkCsWidth3Params {
const STATE_WIDTH: usize = 3;
const WITNESS_WIDTH: usize = 0;
const HAS_WITNESS_POLYNOMIALS: bool = false;
const HAS_CUSTOM_GATES: bool = false;
const CAN_ACCESS_NEXT_TRACE_STEP: bool = false;
}

#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub struct PlonkCsWidth4WithNextStepParams;
impl<E: Engine> PlonkConstraintSystemParams<E> for PlonkCsWidth4WithNextStepParams {
Expand Down Expand Up @@ -2043,7 +2053,7 @@ impl_assembly! {
non_residues.push(E::Fr::one());
non_residues.extend(make_non_residues::<E::Fr>(P::STATE_WIDTH - 1));

assert_eq!(non_residues.len(), 4);
assert_eq!(non_residues.len(), P::STATE_WIDTH);

let mut sigmas = vec![];
for i in 0..P::STATE_WIDTH {
Expand Down
1 change: 1 addition & 0 deletions crates/bellman/src/plonk/better_better_cs/gates/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ use crate::plonk::cs::variable::*;
use crate::plonk::fft::cooley_tukey_ntt::*;

pub mod main_gate_with_d_next;
pub mod naive_main_gate;
pub mod selector_optimized_with_d_next;
Loading

0 comments on commit 5f563e0

Please sign in to comment.