Skip to content

Commit

Permalink
Arrabiata/Interpreter: remove unused methods
Browse files Browse the repository at this point in the history
  • Loading branch information
dannywillems committed Oct 10, 2024
1 parent d13ecf4 commit 8871a89
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 124 deletions.
20 changes: 0 additions & 20 deletions arrabiata/src/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,6 @@ impl<Fp: PrimeField> InterpreterEnv for Env<Fp> {
self.read_position(pos)
}

// FIXME
fn range_check16(&mut self, _x: Self::Position) {}

fn square(&mut self, pos: Self::Position, x: Self::Variable) -> Self::Variable {
let v = self.read_position(pos);
let x = x.square();
Expand All @@ -161,23 +158,6 @@ impl<Fp: PrimeField> InterpreterEnv for Env<Fp> {
self.read_position(pos)
}

unsafe fn read_sixteen_bits_chunks_folding_combiner(
&mut self,
pos: Self::Position,
_i: u32,
) -> Self::Variable {
let (col, row) = pos;
Expr::Atom(ExprInner::Cell(Variable { col, row }))
}

unsafe fn read_bit_of_folding_combiner(
&mut self,
pos: Self::Position,
_i: u64,
) -> Self::Variable {
self.read_position(pos)
}

fn load_poseidon_state(&mut self, pos: Self::Position, _i: usize) -> Self::Variable {
self.read_position(pos)
}
Expand Down
28 changes: 0 additions & 28 deletions arrabiata/src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,6 @@ pub trait InterpreterEnv {
/// Assert that the two variables are equal
fn assert_equal(&mut self, x: Self::Variable, y: Self::Variable);

/// Check if the variable is between [0, 2^16 - 1]
fn range_check16(&mut self, x: Self::Position);

fn add_constraint(&mut self, x: Self::Variable);

fn constrain_boolean(&mut self, x: Self::Variable);
Expand Down Expand Up @@ -476,31 +473,6 @@ pub trait InterpreterEnv {
/// Return the folding combiner
fn coin_folding_combiner(&mut self, pos: Self::Position) -> Self::Variable;

/// Get the 16bits chunks of the folding combiner, and save it into `pos`.
///
/// # Safety
///
/// There are no constraints saying that it is actually the previous
/// computed value. We should do something like a runtime lookup/permutation
/// check. It is left for when the lookup is implemented.
unsafe fn read_sixteen_bits_chunks_folding_combiner(
&mut self,
pos: Self::Position,
i: u32,
) -> Self::Variable;

/// Read the i-th bit of the folding combiner, in little endian, and safe it
/// in the column given by `pos`.
///
/// # Safety
///
/// There is no check that the output is actually a boolean
unsafe fn read_bit_of_folding_combiner(
&mut self,
pos: Self::Position,
i: u64,
) -> Self::Variable;

/// Compute the x^5 of the given variable
fn compute_x5(&self, x: Self::Variable) -> Self::Variable {
let x_square = x.clone() * x.clone();
Expand Down
34 changes: 0 additions & 34 deletions arrabiata/src/witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,20 +302,6 @@ where
assert_eq!(x, y);
}

// FIXME: it should not be a check, but it should build the related logup
// values
// FIXME: we should have additional columns for the lookups.
// This will be implemented when the first version of the IVC is
// implemented and we can make recursive arguments
fn range_check16(&mut self, pos: Self::Position) {
let (col, _) = pos;
let Column::X(idx) = col else {
unimplemented!("Only works for private columns")
};
let x = self.state[idx].clone();
assert!(x < BigInt::from(2_usize).pow(16));
}

fn square(&mut self, pos: Self::Position, x: Self::Variable) -> Self::Variable {
let res = x.clone() * x.clone();
self.write_column(pos, res.clone());
Expand Down Expand Up @@ -389,26 +375,6 @@ where
r
}

unsafe fn read_sixteen_bits_chunks_folding_combiner(
&mut self,
pos: Self::Position,
i: u32,
) -> Self::Variable {
let r = self.r.clone();
self.bitmask_be(&r, 16 * (i + 1), 16 * i, pos)
}

unsafe fn read_bit_of_folding_combiner(
&mut self,
pos: Self::Position,
i: u64,
) -> Self::Variable {
let r = self.r.clone();
let bit = (r >> i) & BigInt::from(1_usize);
self.write_column(pos, bit.clone());
bit
}

fn load_poseidon_state(&mut self, pos: Self::Position, i: usize) -> Self::Variable {
let state = if self.current_iteration % 2 == 0 {
self.sponge_e1[i].clone()
Expand Down
42 changes: 0 additions & 42 deletions arrabiata/tests/witness_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,6 @@ use mina_curves::pasta::{Fp, Fq, Pallas, Vesta};
use num_bigint::BigInt;
use o1_utils::FieldHelpers;

#[test]
fn test_read_bit_of_folding_combiner() {
let srs_log2_size = 6;
let mut env = {
let combiner = BigInt::from(42u64);
let z0 = BigInt::from(1u64);
let sponge_e1: [BigInt; POSEIDON_STATE_SIZE] = std::array::from_fn(|_i| BigInt::from(0u64));
let mut env = Env::<Fp, Fq, Vesta, Pallas>::new(
srs_log2_size,
z0,
sponge_e1.clone(),
sponge_e1.clone(),
);
env.r = combiner;
env
};

let zero_bi = BigInt::from(0u64);
let one_bi = BigInt::from(1u64);

// Checking the first bits, verifying it is in little endian
let pos = env.allocate();
let res = unsafe { env.read_bit_of_folding_combiner(pos, 0) };
assert_eq!(res, zero_bi);
let res = unsafe { env.read_bit_of_folding_combiner(pos, 1) };
assert_eq!(res, one_bi);
let res = unsafe { env.read_bit_of_folding_combiner(pos, 2) };
assert_eq!(res, zero_bi);
let res = unsafe { env.read_bit_of_folding_combiner(pos, 3) };
assert_eq!(res, one_bi);
let res = unsafe { env.read_bit_of_folding_combiner(pos, 4) };
assert_eq!(res, zero_bi);
let res = unsafe { env.read_bit_of_folding_combiner(pos, 5) };
assert_eq!(res, one_bi);
let res = unsafe { env.read_bit_of_folding_combiner(pos, 6) };
assert_eq!(res, zero_bi);
let res = unsafe { env.read_bit_of_folding_combiner(pos, 7) };
assert_eq!(res, zero_bi);
let res = unsafe { env.read_bit_of_folding_combiner(pos, 8) };
assert_eq!(res, zero_bi);
}

#[test]
#[should_panic]
fn test_constrain_boolean_witness_negative_value() {
Expand Down

0 comments on commit 8871a89

Please sign in to comment.