Skip to content

Commit

Permalink
small polishing & rebase to latest main branch updates
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaucube committed Oct 3, 2024
1 parent 4789eef commit 2e1039e
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 20 deletions.
20 changes: 13 additions & 7 deletions folding-schemes/src/folding/nova/circuits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,15 @@ where
pp_hash: C::ScalarField, // public params hash
U_i: &CI,
u_i: &CI,
cmT: &C,
cmT: Option<&C>,
) -> Vec<bool> {
transcript.absorb(&pp_hash);
transcript.absorb(&U_i);
transcript.absorb(&u_i);
transcript.absorb_nonnative(cmT);
// in the Nova case we absorb the cmT, in Ova case we don't since it is not used.
if let Some(cmT_value) = cmT {
transcript.absorb_nonnative(cmT_value);
}
transcript.squeeze_bits(NOVA_N_BITS_RO)
}

Expand All @@ -198,12 +201,15 @@ where
pp_hash: FpVar<CF1<C>>, // public params hash
U_i_vec: Vec<FpVar<CF1<C>>>, // apready processed input, so we don't have to recompute these values
u_i: CommittedInstanceVar<C>,
cmT: NonNativeAffineVar<C>,
cmT: Option<NonNativeAffineVar<C>>,
) -> Result<Vec<Boolean<C::ScalarField>>, SynthesisError> {
transcript.absorb(&pp_hash)?;
transcript.absorb(&U_i_vec)?;
transcript.absorb(&u_i)?;
transcript.absorb_nonnative(&cmT)?;
// in the Nova case we absorb the cmT, in Ova case we don't since it is not used.
if let Some(cmT_value) = cmT {
transcript.absorb_nonnative(&cmT_value)?;
}
transcript.squeeze_bits(NOVA_N_BITS_RO)
}
}
Expand Down Expand Up @@ -382,7 +388,7 @@ where
pp_hash.clone(),
U_i_vec,
u_i.clone(),
cmT.clone(),
Some(cmT.clone()),
)?;
let r = Boolean::le_bits_to_fp_var(&r_bits)?;
// Also convert r_bits to a `NonNativeFieldVar`
Expand Down Expand Up @@ -692,7 +698,7 @@ pub mod tests {
pp_hash,
&U_i,
&u_i,
&cmT,
Some(&cmT),
);
let r = Fr::from_bigint(BigInteger::from_bits_le(&r_bits)).unwrap();

Expand Down Expand Up @@ -721,7 +727,7 @@ pub mod tests {
pp_hashVar,
U_iVar_vec,
u_iVar,
cmTVar,
Some(cmTVar),
)
.unwrap();
assert!(cs.is_satisfied().unwrap());
Expand Down
2 changes: 1 addition & 1 deletion folding-schemes/src/folding/nova/decider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use ark_std::{One, Zero};
use core::marker::PhantomData;

use super::decider_circuits::{DeciderCircuit1, DeciderCircuit2};
use super::{nifs::NIFS, CommittedInstance, Nova};
use super::{nifs::NIFS, traits::NIFSTrait, CommittedInstance, Nova};
use crate::commitment::CommitmentScheme;
use crate::folding::circuits::{
cyclefold::CycleFoldCommittedInstance,
Expand Down
2 changes: 1 addition & 1 deletion folding-schemes/src/folding/nova/decider_circuits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ where
pp_hash,
U_i_vec,
u_i.clone(),
cmT.clone(),
Some(cmT.clone()),
)?;
// 5.1.
let (incircuit_c_W, incircuit_c_E) =
Expand Down
4 changes: 2 additions & 2 deletions folding-schemes/src/folding/nova/decider_eth_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ where
nova.pp_hash,
&nova.U_i,
&nova.u_i,
&cmT,
Some(&cmT),
);
let r_Fr = C1::ScalarField::from_bigint(BigInteger::from_bits_le(&r_bits))
.ok_or(Error::OutOfBounds)?;
Expand Down Expand Up @@ -490,7 +490,7 @@ where
pp_hash,
U_i_vec,
u_i.clone(),
cmT.clone(),
Some(cmT),
)?;
// 5.1.
let (incircuit_c_W, incircuit_c_E) =
Expand Down
2 changes: 1 addition & 1 deletion folding-schemes/src/folding/nova/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ where
self.pp_hash,
&self.U_i,
&self.u_i,
&cmT,
Some(&cmT),
);
let r_Fr = C1::ScalarField::from_bigint(BigInteger::from_bits_le(&r_bits))
.ok_or(Error::OutOfBounds)?;
Expand Down
8 changes: 7 additions & 1 deletion folding-schemes/src/folding/nova/nifs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,16 @@ where
aux: &Self::VerifierAux, // cmT
) -> Vec<bool> {
ChallengeGadget::<C, Self::CommittedInstance>::get_challenge_native(
transcript, pp_hash, U_i, u_i, aux,
transcript,
pp_hash,
U_i,
u_i,
Some(aux),
)
}

// Notice: `prove` method is implemented at the trait level.

fn verify(
// r comes from the transcript, and is a n-bit (N_BITS_CHALLENGE) element
r: C::ScalarField,
Expand Down
10 changes: 4 additions & 6 deletions folding-schemes/src/folding/nova/ova.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,22 +169,20 @@ where
) -> Vec<bool> {
// reuse Nova's get_challenge method
ChallengeGadget::<C, Self::CommittedInstance>::get_challenge_native(
transcript,
pp_hash,
U_i,
u_i,
&C::zero(), // empty in Ova's case
transcript, pp_hash, U_i, u_i, None, // empty in Ova's case
)
}

// Notice: `prove` method is implemented at the trait level.

fn verify(
// r comes from the transcript, and is a n-bit (N_BITS_CHALLENGE) element
r: C::ScalarField,
U_i: &Self::CommittedInstance,
u_i: &Self::CommittedInstance,
_aux: &Self::VerifierAux,
) -> Self::CommittedInstance {
// recall that r <==> alpha, and u <==} mu between Nova and Ova respectively
// recall that r <==> alpha, and u <==> mu between Nova and Ova respectively
let u = U_i.u + r; // u_i.u is always 1 IN ova as we just can do sequential IVC.
let cmWE = U_i.cmWE + u_i.cmWE.mul(r);
let x = U_i
Expand Down
6 changes: 5 additions & 1 deletion folding-schemes/src/folding/nova/zk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ where
cmT: C1,
) -> Result<C1::ScalarField, Error> {
let r_bits = ChallengeGadget::<C1, CommittedInstance<C1>>::get_challenge_native(
sponge, pp_hash, &U_i, &u_i, &cmT,
sponge,
pp_hash,
&U_i,
&u_i,
Some(&cmT),
);
C1::ScalarField::from_bigint(BigInteger::from_bits_le(&r_bits)).ok_or(Error::OutOfBounds)
}
Expand Down

0 comments on commit 2e1039e

Please sign in to comment.