Skip to content

Commit

Permalink
Arrabiata: define Arrabiata own challenges
Browse files Browse the repository at this point in the history
  • Loading branch information
dannywillems committed Oct 9, 2024
1 parent 4d7c283 commit 3e5f19f
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 6 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions arrabiata/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ once_cell.workspace = true
poly-commitment.workspace = true
rand.workspace = true
rayon.workspace = true
serde.workspace = true
strum.workspace = true
strum_macros.workspace = true
71 changes: 65 additions & 6 deletions arrabiata/src/columns.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
use kimchi::circuits::{
berkeley_columns::BerkeleyChallengeTerm,
expr::{CacheId, ConstantExpr, Expr, FormattedOutput},
use ark_ff::Field;
use kimchi::circuits::expr::{AlphaChallengeTerm, CacheId, ConstantExpr, Expr, FormattedOutput};
use serde::{Deserialize, Serialize};
use std::{
collections::HashMap,
fmt::{Display, Formatter, Result},
ops::Index,
};
use std::collections::HashMap;
use strum_macros::{EnumCount as EnumCountMacro, EnumIter};

/// This enum represents the different gadgets that can be used in the circuit.
Expand Down Expand Up @@ -48,8 +51,64 @@ pub enum Column {
X(usize),
}

// FIXME: We should use something different than BerkeleyChallengeTerm here
pub type E<Fp> = Expr<ConstantExpr<Fp, BerkeleyChallengeTerm>, Column>;
pub struct Challenges<F: Field> {
/// Challenge used to aggregate the constraints
pub alpha: F,

/// Both challenges used in the permutation argument
pub beta: F,
pub gamma: F,

/// Challenge to homogenize the constraints
pub homogenous_challenge: F,

/// Random coin used to aggregate witnesses while folding
pub r: F,
}

#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum ChallengeTerm {
/// Challenge used to aggregate the constraints
Alpha,
/// Both challenges used in the permutation argument
Beta,
Gamma,
/// Challenge to homogenize the constraints
HomogenousChallenge,
/// Random coin used to aggregate witnesses while folding
R,
}

impl Display for ChallengeTerm {
fn fmt(&self, f: &mut Formatter) -> Result {
match self {
ChallengeTerm::Alpha => write!(f, "alpha"),
ChallengeTerm::Beta => write!(f, "beta"),
ChallengeTerm::Gamma => write!(f, "gamma"),
ChallengeTerm::HomogenousChallenge => write!(f, "u"),
ChallengeTerm::R => write!(f, "r"),
}
}
}
impl<F: Field> Index<ChallengeTerm> for Challenges<F> {
type Output = F;

fn index(&self, term: ChallengeTerm) -> &Self::Output {
match term {
ChallengeTerm::Alpha => &self.alpha,
ChallengeTerm::Beta => &self.beta,
ChallengeTerm::Gamma => &self.gamma,
ChallengeTerm::HomogenousChallenge => &self.homogenous_challenge,
ChallengeTerm::R => &self.r,
}
}
}

impl<'a> AlphaChallengeTerm<'a> for ChallengeTerm {
const ALPHA: Self = Self::Alpha;
}

pub type E<Fp> = Expr<ConstantExpr<Fp, ChallengeTerm>, Column>;

// Code to allow for pretty printing of the expressions
impl FormattedOutput for Column {
Expand Down

0 comments on commit 3e5f19f

Please sign in to comment.