Skip to content

Commit

Permalink
Arrabbiata: use "verifier" as often as possible instead of IVC
Browse files Browse the repository at this point in the history
  • Loading branch information
dannywillems committed Feb 4, 2025
1 parent e77f8c3 commit c6889cd
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 33 deletions.
12 changes: 6 additions & 6 deletions arrabbiata/src/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,19 +320,19 @@ impl<C: ArrabbiataCurve> Env<C>
where
C::BaseField: PrimeField,
{
/// Get all the constraints for the IVC circuit, only.
/// Get all the constraints for the verifier circuit, only.
///
/// The following gadgets are used in the IVC circuit:
/// The following gadgets are used in the verifier circuit:
/// - [Instruction::Poseidon] to verify the challenges and the public
/// IO
/// - [Instruction::EllipticCurveScaling] and
/// [Instruction::EllipticCurveAddition] to accumulate the commitments
// FIXME: the IVC circuit might not be complete, yet. For instance, we might
// FIXME: the verifier circuit might not be complete, yet. For instance, we might
// need to accumulate the challenges and add a row to verify the output of
// the computation of the challenges.
// FIXME: add a test checking that whatever the value given in parameter of
// the gadget, the constraints are the same
pub fn get_all_constraints_for_ivc(&self) -> Vec<E<C::ScalarField>> {
pub fn get_all_constraints_for_verifier(&self) -> Vec<E<C::ScalarField>> {
// Copying the instance we got in parameter, and making it mutable to
// avoid modifying the original instance.
let mut env = self.clone();
Expand Down Expand Up @@ -365,12 +365,12 @@ where
constraints
}

/// Get all the constraints for the IVC circuit and the application.
/// Get all the constraints for the verifier circuit and the application.
// FIXME: the application should be given as an argument to handle Rust
// zkApp. It is only for the PoC.
// FIXME: the selectors are not added for now.
pub fn get_all_constraints(&self) -> Vec<E<C::ScalarField>> {
let mut constraints = self.get_all_constraints_for_ivc();
let mut constraints = self.get_all_constraints_for_verifier();

// Copying the instance we got in parameter, and making it mutable to
// avoid modifying the original instance.
Expand Down
6 changes: 3 additions & 3 deletions arrabbiata/src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@
//!
//! ## Fiat-Shamir challenges
//!
//! The challenges sent by the verifier must also be simulated by the IVC
//! The challenges sent by the verifier must also be simulated by the verifier
//! circuit. It is done by passing "messages" as public inputs to the next
//! instances. Diagrams recapitulating the messages that must be passed are
//! available in the section [Message passing](#message-passing).
Expand Down Expand Up @@ -443,8 +443,8 @@ use num_bigint::BigInt;
/// `fetch_next_instruction` and `fetch_instruction` on a witness environnement.
/// See the [Witness environment](crate::witness::Env) for more details.
///
/// Mostly, the instructions will be used to build the IVC circuit, but it can be
/// generalized.
/// Mostly, the instructions will be used to build the verifier circuit, but it
/// can be generalized.
///
/// When the circuit is predefined, the instructions can be accompanied by a
/// public selector. When implementing a virtual machine, where instructions are
Expand Down
12 changes: 6 additions & 6 deletions arrabbiata/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ pub const MIN_SRS_LOG2_SIZE: usize = 16;
/// The maximum number of columns that can be used in the circuit.
pub const NUMBER_OF_COLUMNS: usize = 15;

/// The number of rows the IVC circuit requires.
/// The number of rows the verifier circuit requires.
// FIXME:
// We will increase the IVC circuit size step by step, while we are finishing
// We will increase the verifier circuit size step by step, while we are finishing
// the implementation.
// 1. We start by absorbing all the accumulators of each column. Adding one for
// now as the Poseidon circuit writes on the next row. This would be changing in
// the near future as we're polishing the circuit.
pub const IVC_CIRCUIT_SIZE: usize =
pub const VERIFIER_CIRCUIT_SIZE: usize =
(PlonkSpongeConstants::PERM_ROUNDS_FULL / 5) * NUMBER_OF_COLUMNS + 1;

/// The maximum number of public inputs the circuit can use per row
Expand All @@ -45,7 +45,7 @@ pub const NUMBER_OF_PUBLIC_INPUTS: usize = 15 + 2;

/// The maximum number of bits the fields can be.
/// It is critical as we have some assumptions for the gadgets describing the
/// IVC.
/// verifier circuit.
pub const MAXIMUM_FIELD_SIZE_IN_BITS: u64 = 255;

/// Define the number of values we must absorb when computating the hash to the
Expand All @@ -56,8 +56,8 @@ pub const MAXIMUM_FIELD_SIZE_IN_BITS: u64 = 255;
/// accumulators, which consists of 2 native field elements. However, it doesn't
/// make the protocol sound. We must absorb, in addition to that the index,
/// the application inputs/outputs.
/// It is left for the future as at this time, we're still sketching the IVC
/// circuit.
/// It is left for the future as at this time, we're still sketching the
/// verifier circuit.
pub const NUMBER_OF_VALUES_TO_ABSORB_PUBLIC_IO: usize = NUMBER_OF_COLUMNS * 2;

/// The number of selectors used in the circuit.
Expand Down
14 changes: 7 additions & 7 deletions arrabbiata/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use arrabbiata::{
curve::PlonkSpongeConstants,
interpreter::{self, InterpreterEnv},
witness::Env,
IVC_CIRCUIT_SIZE, MIN_SRS_LOG2_SIZE,
MIN_SRS_LOG2_SIZE, VERIFIER_CIRCUIT_SIZE,
};
use log::{debug, info};
use mina_curves::pasta::{Fp, Fq, Pallas, Vesta};
Expand Down Expand Up @@ -47,7 +47,7 @@ pub fn main() {

assert!(
*srs_log2_size >= MIN_SRS_LOG2_SIZE,
"SRS size must be at least 2^{MIN_SRS_LOG2_SIZE} to support IVC"
"SRS size must be at least 2^{MIN_SRS_LOG2_SIZE} to support the verifier circuit size"
);

info!("Instantiating environment to execute square-root {n_iteration} times with SRS of size 2^{srs_log2_size}");
Expand All @@ -65,7 +65,7 @@ pub fn main() {
sponge_e1.clone(),
);

let n_iteration_per_fold = domain_size - IVC_CIRCUIT_SIZE;
let n_iteration_per_fold = domain_size - VERIFIER_CIRCUIT_SIZE;

while env.current_iteration < *n_iteration {
let start_iteration = Instant::now();
Expand All @@ -80,17 +80,17 @@ pub fn main() {
}

info!(
"Building the IVC circuit. A total number of {} rows will be filled from the witness row {}",
IVC_CIRCUIT_SIZE, env.current_row,
"Building the verifier circuit. A total number of {} rows will be filled from the witness row {}",
VERIFIER_CIRCUIT_SIZE, env.current_row,
);
// Build the verifier circuit
// FIXME: Minus one as the last row of the verifier circuit is a
// Poseidon hash, and we write on the next row. We don't want to execute
// a new instruction for the verifier circuit here.
for i in 0..IVC_CIRCUIT_SIZE - 1 {
for i in 0..VERIFIER_CIRCUIT_SIZE - 1 {
let instr = env.fetch_instruction();
debug!(
"Running IVC row {} (instruction = {:?}, witness row = {})",
"Running verifier row {} (instruction = {:?}, witness row = {})",
i, instr, env.current_row
);
interpreter::run_ivc(&mut env, instr);
Expand Down
2 changes: 1 addition & 1 deletion arrabbiata/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use ark_ff::PrimeField;

use crate::witness::Env;

/// Generate a proof for the IVC circuit.
/// Generate a proof.
/// All the information to make a proof is available in the environment given in
/// parameter.
pub fn prove<
Expand Down
16 changes: 8 additions & 8 deletions arrabbiata/src/witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::{
/// The first instruction in the verifier circuit (often shortened in "IVC" in
/// the crate) is the Poseidon permutation. It is used to start hashing the
/// public input.
pub const IVC_STARTING_INSTRUCTION: Instruction = Instruction::Poseidon(0);
pub const VERIFIER_STARTING_INSTRUCTION: Instruction = Instruction::Poseidon(0);

/// An environment is used to contain the state of a long "running program".
///
Expand Down Expand Up @@ -155,7 +155,7 @@ pub struct Env<
/// state.
pub verifier_sponge_state: [BigInt; PlonkSpongeConstants::SPONGE_WIDTH],

/// The current iteration of the IVC
/// The current iteration of the IVC.
pub current_iteration: u64,

/// The digest of the program state before executing the last iteration.
Expand Down Expand Up @@ -911,7 +911,7 @@ where
srs_e2,
// -------
// -------
// IVC only
// verifier only
ivc_accumulator_e1,
ivc_accumulator_e2,
previous_committed_state_e1,
Expand All @@ -927,7 +927,7 @@ where
public_state: std::array::from_fn(|_| BigInt::from(0_usize)),
selectors,
challenges,
current_instruction: IVC_STARTING_INSTRUCTION,
current_instruction: VERIFIER_STARTING_INSTRUCTION,
sponge_e1,
sponge_e2,
prover_sponge_state,
Expand Down Expand Up @@ -965,12 +965,12 @@ where
self.current_row = 0;
self.state = std::array::from_fn(|_| BigInt::from(0_usize));
self.idx_var = 0;
self.current_instruction = IVC_STARTING_INSTRUCTION;
self.current_instruction = VERIFIER_STARTING_INSTRUCTION;
self.idx_values_to_absorb = 0;
}

/// The blinder used to commit, to avoid committing to the zero polynomial
/// and accumulate it in the IVC.
/// and accumulated in the IVC.
///
/// It is part of the instance, and it is accumulated in the IVC.
pub fn accumulate_commitment_blinder(&mut self) {
Expand Down Expand Up @@ -1091,8 +1091,8 @@ where

/// Describe the control-flow for the IVC circuit.
///
/// For a step i + 1, the IVC circuit receives as public input the following
/// values:
/// For a step i + 1, the verifier circuit receives as public input the
/// following values:
///
/// - The commitments to the previous witnesses.
/// - The previous challenges (α_{i}, β_{i}, γ_{i}) - the challenges β and γ
Expand Down
4 changes: 2 additions & 2 deletions arrabbiata/tests/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ fn test_gadget_elliptic_curve_addition() {
fn test_ivc_total_number_of_constraints_ivc() {
let constraints_fp = constraints::Env::<Vesta>::new();

let constraints = constraints_fp.get_all_constraints_for_ivc();
let constraints = constraints_fp.get_all_constraints_for_verifier();
assert_eq!(constraints.len(), 28);
}

#[test]
fn test_degree_of_constraints_ivc() {
let constraints_fp = constraints::Env::<Vesta>::new();

let constraints = constraints_fp.get_all_constraints_for_ivc();
let constraints = constraints_fp.get_all_constraints_for_verifier();

let mut degree_per_constraints = HashMap::new();
constraints.iter().for_each(|c| {
Expand Down

0 comments on commit c6889cd

Please sign in to comment.