From c6889cd797548fc9802ccc911e3a7026f3c4ba49 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Tue, 4 Feb 2025 13:03:52 +0100 Subject: [PATCH] Arrabbiata: use "verifier" as often as possible instead of IVC --- arrabbiata/src/constraints.rs | 12 ++++++------ arrabbiata/src/interpreter.rs | 6 +++--- arrabbiata/src/lib.rs | 12 ++++++------ arrabbiata/src/main.rs | 14 +++++++------- arrabbiata/src/prover.rs | 2 +- arrabbiata/src/witness.rs | 16 ++++++++-------- arrabbiata/tests/constraints.rs | 4 ++-- 7 files changed, 33 insertions(+), 33 deletions(-) diff --git a/arrabbiata/src/constraints.rs b/arrabbiata/src/constraints.rs index 4f72c381aa..c6119519ae 100644 --- a/arrabbiata/src/constraints.rs +++ b/arrabbiata/src/constraints.rs @@ -320,19 +320,19 @@ impl Env 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> { + pub fn get_all_constraints_for_verifier(&self) -> Vec> { // Copying the instance we got in parameter, and making it mutable to // avoid modifying the original instance. let mut env = self.clone(); @@ -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> { - 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. diff --git a/arrabbiata/src/interpreter.rs b/arrabbiata/src/interpreter.rs index 3f5264fd0f..9c4711b236 100644 --- a/arrabbiata/src/interpreter.rs +++ b/arrabbiata/src/interpreter.rs @@ -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). @@ -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 diff --git a/arrabbiata/src/lib.rs b/arrabbiata/src/lib.rs index 4a08b21c8a..91902f7846 100644 --- a/arrabbiata/src/lib.rs +++ b/arrabbiata/src/lib.rs @@ -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 @@ -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 @@ -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. diff --git a/arrabbiata/src/main.rs b/arrabbiata/src/main.rs index 393bb4f647..6e0f5a4de3 100644 --- a/arrabbiata/src/main.rs +++ b/arrabbiata/src/main.rs @@ -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}; @@ -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}"); @@ -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(); @@ -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); diff --git a/arrabbiata/src/prover.rs b/arrabbiata/src/prover.rs index 9fbac08c9b..c1452a12fe 100644 --- a/arrabbiata/src/prover.rs +++ b/arrabbiata/src/prover.rs @@ -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< diff --git a/arrabbiata/src/witness.rs b/arrabbiata/src/witness.rs index 30f7a78a99..0077e30a22 100644 --- a/arrabbiata/src/witness.rs +++ b/arrabbiata/src/witness.rs @@ -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". /// @@ -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. @@ -911,7 +911,7 @@ where srs_e2, // ------- // ------- - // IVC only + // verifier only ivc_accumulator_e1, ivc_accumulator_e2, previous_committed_state_e1, @@ -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, @@ -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) { @@ -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 γ diff --git a/arrabbiata/tests/constraints.rs b/arrabbiata/tests/constraints.rs index a2f86da979..8f44d6b31c 100644 --- a/arrabbiata/tests/constraints.rs +++ b/arrabbiata/tests/constraints.rs @@ -103,7 +103,7 @@ fn test_gadget_elliptic_curve_addition() { fn test_ivc_total_number_of_constraints_ivc() { let constraints_fp = constraints::Env::::new(); - let constraints = constraints_fp.get_all_constraints_for_ivc(); + let constraints = constraints_fp.get_all_constraints_for_verifier(); assert_eq!(constraints.len(), 28); } @@ -111,7 +111,7 @@ fn test_ivc_total_number_of_constraints_ivc() { fn test_degree_of_constraints_ivc() { let constraints_fp = constraints::Env::::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| {