Skip to content

Commit

Permalink
Arrabiata: remove "permutation" gadget
Browse files Browse the repository at this point in the history
  • Loading branch information
dannywillems committed Oct 8, 2024
1 parent fdc6268 commit 1b1459d
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 30 deletions.
4 changes: 0 additions & 4 deletions arrabiata/src/columns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ use strum_macros::{EnumCount as EnumCountMacro, EnumIter};
#[derive(Debug, Clone, Copy, PartialEq, EnumCountMacro, EnumIter)]
pub enum Gadget {
App,
// Permutation argument
PermutationArgument,
// Two old gadgets
/// Decompose a 255 bits scalar into 16 chunks of 16 bits.
SixteenBitsDecomposition,
Expand Down Expand Up @@ -57,7 +55,6 @@ impl FormattedOutput for Column {
match self {
Column::Selector(sel) => match sel {
Gadget::App => "q_app".to_string(),
Gadget::PermutationArgument => "q_perm".to_string(),
Gadget::SixteenBitsDecomposition => "q_16bits".to_string(),
Gadget::BitDecompositionFrom16Bits => "q_bit_from_16bits".to_string(),
Gadget::BitDecomposition => "q_bits".to_string(),
Expand All @@ -75,7 +72,6 @@ impl FormattedOutput for Column {
match self {
Column::Selector(sel) => match sel {
Gadget::App => "q_app".to_string(),
Gadget::PermutationArgument => "q_perm".to_string(),
Gadget::SixteenBitsDecomposition => "q_16bits".to_string(),
Gadget::BitDecompositionFrom16Bits => "q_bit_from_16bits".to_string(),
Gadget::BitDecomposition => "q_bits".to_string(),
Expand Down
10 changes: 0 additions & 10 deletions arrabiata/src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -841,9 +841,6 @@ pub fn run_ivc<E: InterpreterEnv>(env: &mut E, instr: Instruction) {
env.activate_gadget(Gadget::EllipticCurveScaling);
// When processing the first bit, we must load the scalar, and it
// comes from previous computation.
if processing_bit == 0 {
env.activate_gadget(Gadget::PermutationArgument);
}
// The two first columns are supposed to be used for the output.
// It will be used to write the result of the scalar multiplication
// in the next row.
Expand Down Expand Up @@ -985,7 +982,6 @@ pub fn run_ivc<E: InterpreterEnv>(env: &mut E, instr: Instruction) {
};
}
Instruction::EllipticCurveAddition(i_comm) => {
env.activate_gadget(Gadget::PermutationArgument);
env.activate_gadget(Gadget::EllipticCurveAddition);
assert!(i_comm < NUMBER_OF_COLUMNS, "Invalid index. We do only support the addition of the commitments to the columns, for now. We must additionally support the scaling of cross-terms and error terms");
let (x1, y1) = {
Expand Down Expand Up @@ -1029,7 +1025,6 @@ pub fn run_ivc<E: InterpreterEnv>(env: &mut E, instr: Instruction) {
};
}
Instruction::Poseidon(curr_round) => {
env.activate_gadget(Gadget::PermutationArgument);
env.activate_gadget(Gadget::Poseidon);
debug!("Executing instruction Poseidon({curr_round})");
if curr_round < POSEIDON_ROUNDS_FULL {
Expand Down Expand Up @@ -1111,7 +1106,6 @@ pub fn run_ivc<E: InterpreterEnv>(env: &mut E, instr: Instruction) {
// calls, like when we need to hash the public inputs, and the
// state might be from a previous place in the execution trace.
let state: Vec<E::Variable> = if curr_round == 0 {
env.activate_gadget(Gadget::PermutationArgument);
round_input_positions
.iter()
.enumerate()
Expand Down Expand Up @@ -1171,16 +1165,12 @@ pub fn run_ivc<E: InterpreterEnv>(env: &mut E, instr: Instruction) {
.collect();
// If we are at the last round, we save the state in the
// environment.
// It does require the permutation argument to be activated.
// FIXME: activating the permutation argument has no effect
// for now.
// FIXME/IMPROVEME: we might want to execute more Poseidon
// full hash in sequentially, and then save one row. For
// now, we will save the state at the end of the last round
// and reload it at the beginning of the next Poseidon full
// hash.
if round == POSEIDON_ROUNDS_FULL - 1 {
env.activate_gadget(Gadget::PermutationArgument);
state.iter().enumerate().for_each(|(i, x)| {
unsafe { env.save_poseidon_state(x.clone(), i) };
});
Expand Down
16 changes: 0 additions & 16 deletions arrabiata/src/witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,6 @@ where
}

fn load_poseidon_state(&mut self, pos: Self::Position, i: usize) -> Self::Variable {
assert!(
self.selectors[Gadget::PermutationArgument as usize][self.current_row],
"The permutation argument should be activated"
);
let state = if self.current_iteration % 2 == 0 {
self.sponge_e1[i].clone()
} else {
Expand Down Expand Up @@ -471,10 +467,6 @@ where
}

unsafe fn save_poseidon_state(&mut self, x: Self::Variable, i: usize) {
assert!(
self.selectors[Gadget::PermutationArgument as usize][self.current_row],
"The permutation argument should be activated"
);
if self.current_iteration % 2 == 0 {
let modulus: BigInt = Fp::modulus_biguint().into();
self.sponge_e1[i] = x.mod_floor(&modulus)
Expand Down Expand Up @@ -549,10 +541,6 @@ where
pos_y: Self::Position,
side: Side,
) -> (Self::Variable, Self::Variable) {
assert!(
self.selectors[Gadget::PermutationArgument as usize][self.current_row],
"The permutation argument should be activated"
);
match self.current_instruction {
Instruction::EllipticCurveScaling(i_comm, bit) => {
// If we're processing the leftmost bit (i.e. bit == 0), we must load
Expand Down Expand Up @@ -657,10 +645,6 @@ where
y: Self::Variable,
side: Side,
) {
assert!(
self.selectors[Gadget::PermutationArgument as usize][self.current_row],
"The permutation argument should be activated"
);
match side {
Side::Left => {
self.temporary_accumulators.0 = (x, y);
Expand Down

0 comments on commit 1b1459d

Please sign in to comment.