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

Arrabbiata: use "combiner" instead of "randomiser" for challenges #3031

Merged
merged 3 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
34 changes: 17 additions & 17 deletions arrabbiata/src/challenge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub enum ChallengeTerm {
/// Used to aggregate the constraints describing the relation. It is used to
/// enforce all constraints are satisfied at the same time.
/// Often noted `α`.
ConstraintRandomiser,
ConstraintCombiner,
/// Both challenges used in the permutation argument
Beta,
Gamma,
Expand All @@ -24,17 +24,17 @@ pub enum ChallengeTerm {
/// Used by the accumulation protocol (folding) to perform a random linear
/// transformation of the witnesses and the public values.
/// Often noted `r` in the paper mentioning "folding protocols".
RelationRandomiser,
RelationCombiner,
}

impl Display for ChallengeTerm {
fn fmt(&self, f: &mut Formatter) -> Result {
match self {
ChallengeTerm::ConstraintRandomiser => write!(f, "alpha"),
ChallengeTerm::ConstraintCombiner => write!(f, "alpha"),
ChallengeTerm::Beta => write!(f, "beta"),
ChallengeTerm::Gamma => write!(f, "gamma"),
ChallengeTerm::ConstraintHomogeniser => write!(f, "u"),
ChallengeTerm::RelationRandomiser => write!(f, "r"),
ChallengeTerm::RelationCombiner => write!(f, "r"),
}
}
}
Expand All @@ -43,7 +43,7 @@ pub struct Challenges<F> {
/// Used to aggregate the constraints describing the relation. It is used to
/// enforce all constraints are satisfied at the same time.
/// Often noted `α`.
pub constraint_randomiser: F,
pub constraint_combiner: F,

/// Both challenges used in the permutation argument.
pub beta: F,
Expand All @@ -57,23 +57,23 @@ pub struct Challenges<F> {
/// Used by the accumulation protocol (folding) to perform a random linear
/// transformation of the witnesses and the public values.
/// Often noted `r` in the paper mentioning "folding protocols".
pub relation_randomiser: F,
pub relation_combiner: F,
}

impl<F> Index<usize> for Challenges<F> {
type Output = F;

fn index(&self, index: usize) -> &Self::Output {
if index == 0 {
&self.constraint_randomiser
&self.constraint_combiner
} else if index == 1 {
&self.beta
} else if index == 2 {
&self.gamma
} else if index == 3 {
&self.constraint_homogeniser
} else if index == 4 {
&self.relation_randomiser
&self.relation_combiner
} else {
panic!(
"Index out of bounds, only {} are defined",
Expand All @@ -86,15 +86,15 @@ impl<F> Index<usize> for Challenges<F> {
impl<F> IndexMut<usize> for Challenges<F> {
fn index_mut(&mut self, index: usize) -> &mut F {
if index == 0 {
&mut self.constraint_randomiser
&mut self.constraint_combiner
} else if index == 1 {
&mut self.beta
} else if index == 2 {
&mut self.gamma
} else if index == 3 {
&mut self.constraint_homogeniser
} else if index == 4 {
&mut self.relation_randomiser
&mut self.relation_combiner
} else {
panic!(
"Index out of bounds, only {} are defined",
Expand All @@ -107,23 +107,23 @@ impl<F> IndexMut<usize> for Challenges<F> {
impl<F> IndexMut<ChallengeTerm> for Challenges<F> {
fn index_mut(&mut self, term: ChallengeTerm) -> &mut F {
match term {
ChallengeTerm::ConstraintRandomiser => &mut self.constraint_randomiser,
ChallengeTerm::ConstraintCombiner => &mut self.constraint_combiner,
ChallengeTerm::Beta => &mut self.beta,
ChallengeTerm::Gamma => &mut self.gamma,
ChallengeTerm::ConstraintHomogeniser => &mut self.constraint_homogeniser,
ChallengeTerm::RelationRandomiser => &mut self.relation_randomiser,
ChallengeTerm::RelationCombiner => &mut self.relation_combiner,
}
}
}

impl<F: Zero> Default for Challenges<F> {
fn default() -> Self {
Self {
constraint_randomiser: F::zero(),
constraint_combiner: F::zero(),
beta: F::zero(),
gamma: F::zero(),
constraint_homogeniser: F::zero(),
relation_randomiser: F::zero(),
relation_combiner: F::zero(),
}
}
}
Expand All @@ -133,15 +133,15 @@ impl<F> Index<ChallengeTerm> for Challenges<F> {

fn index(&self, term: ChallengeTerm) -> &Self::Output {
match term {
ChallengeTerm::ConstraintRandomiser => &self.constraint_randomiser,
ChallengeTerm::ConstraintCombiner => &self.constraint_combiner,
ChallengeTerm::Beta => &self.beta,
ChallengeTerm::Gamma => &self.gamma,
ChallengeTerm::ConstraintHomogeniser => &self.constraint_homogeniser,
ChallengeTerm::RelationRandomiser => &self.relation_randomiser,
ChallengeTerm::RelationCombiner => &self.relation_combiner,
}
}
}

impl<'a> AlphaChallengeTerm<'a> for ChallengeTerm {
const ALPHA: Self = Self::ConstraintRandomiser;
const ALPHA: Self = Self::ConstraintCombiner;
}
8 changes: 4 additions & 4 deletions arrabbiata/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ pub fn main() {
// ----- Permutation argument -----

// Coin challenge α for combining the constraints
env.coin_challenge(ChallengeTerm::ConstraintRandomiser);
env.coin_challenge(ChallengeTerm::ConstraintCombiner);
debug!(
"Coin challenge α: 0x{chal}",
chal = env.challenges[ChallengeTerm::ConstraintRandomiser].to_str_radix(16)
chal = env.challenges[ChallengeTerm::ConstraintCombiner].to_str_radix(16)
);

// ----- Accumulation/folding argument -----
Expand All @@ -145,10 +145,10 @@ pub fn main() {
// FIXME: we must do the step before first! Skipping for now to achieve
// the next step, i.e. accumulating on the prover side the different
// values below.
env.coin_challenge(ChallengeTerm::RelationRandomiser);
env.coin_challenge(ChallengeTerm::RelationCombiner);
debug!(
"Coin challenge r: 0x{r}",
r = env.challenges[ChallengeTerm::RelationRandomiser].to_str_radix(16)
r = env.challenges[ChallengeTerm::RelationCombiner].to_str_radix(16)
);
env.accumulate_program_state();

Expand Down
6 changes: 3 additions & 3 deletions arrabbiata/src/witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,7 @@ where
/// ```
/// where acc and w are vectors of the same size.
pub fn accumulate_program_state(&mut self) {
let chal = self.challenges[ChallengeTerm::RelationRandomiser].clone();
let chal = self.challenges[ChallengeTerm::RelationCombiner].clone();
if self.current_iteration % 2 == 0 {
let modulus: BigInt = E1::ScalarField::modulus_biguint().into();
self.accumulated_program_state_e1 = self
Expand Down Expand Up @@ -1385,7 +1385,7 @@ where
/// the columns to accumulate the committed state.
pub fn accumulate_committed_state(&mut self) {
if self.current_iteration % 2 == 0 {
let chal = self.challenges[ChallengeTerm::RelationRandomiser].clone();
let chal = self.challenges[ChallengeTerm::RelationCombiner].clone();
let chal: BigUint = chal.to_biguint().unwrap();
let chal: E2::ScalarField = E2::ScalarField::from_biguint(&chal).unwrap();
self.accumulated_committed_state_e2 = self
Expand All @@ -1395,7 +1395,7 @@ where
.map(|(l, r)| l + &r.scale(chal))
.collect();
} else {
let chal = self.challenges[ChallengeTerm::RelationRandomiser].clone();
let chal = self.challenges[ChallengeTerm::RelationCombiner].clone();
let chal: BigUint = chal.to_biguint().unwrap();
let chal: E1::ScalarField = E1::ScalarField::from_biguint(&chal).unwrap();
self.accumulated_committed_state_e1 = self
Expand Down
Loading