Skip to content

Commit 2c65b3f

Browse files
committed
Add the missing check of in-circuit state against initial state for i=0
1 parent 3a86594 commit 2c65b3f

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

crates/ivc/src/compilers/cyclefold/circuits.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
33
use ark_ff::PrimeField;
44
use ark_r1cs_std::{
5-
GR1CSVar,
6-
alloc::AllocVar,
7-
fields::{FieldVar, fp::FpVar},
5+
GR1CSVar, alloc::AllocVar, eq::EqGadget, fields::{FieldVar, fp::FpVar}
86
};
97
use ark_relations::gr1cs::{ConstraintSynthesizer, ConstraintSystemRef, SynthesisError};
108
use sonobe_fs::{
@@ -99,6 +97,9 @@ where
9997
let cf_U = AllocVar::new_witness(cs.clone(), || Ok(cf_U))?;
10098
let cf_proofs = Vec::new_witness(cs.clone(), || Ok(cf_proofs))?;
10199

100+
// 0. Check initial state consistency
101+
initial_state.conditional_enforce_equal(&current_state, &is_basecase)?;
102+
102103
// 1. Fold primary instances.
103104
// 1.a. Derive the public input to the primary (augmented) circuit in
104105
// the `i-1`-th step, which is `u.x = H(i, z_0, z_i, U, cf_U)`.

crates/primitives/src/circuits/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! This module defines circuits and helpers used by Sonobe.
22
33
use ark_ff::{Field, PrimeField};
4-
use ark_r1cs_std::{GR1CSVar, alloc::AllocVar, fields::fp::FpVar};
4+
use ark_r1cs_std::{GR1CSVar, alloc::AllocVar, eq::EqGadget, fields::fp::FpVar};
55
use ark_relations::gr1cs::{
66
ConstraintSynthesizer, ConstraintSystem, ConstraintSystemRef, SynthesisError, SynthesisMode,
77
};
@@ -74,7 +74,8 @@ pub trait FCircuit {
7474
/// implement the required traits for the corresponding variable type.
7575
type StateVar: GR1CSVar<Self::Field, Value = Self::State>
7676
+ AllocVar<Self::State, Self::Field>
77-
+ AbsorbableVar<Self::Field>;
77+
+ AbsorbableVar<Self::Field>
78+
+ EqGadget<Self::Field>;
7879
/// [`FCircuit::ExternalInputs`] is the type of external inputs provided to
7980
/// each step of the circuit.
8081
type ExternalInputs;

0 commit comments

Comments
 (0)