Skip to content

Commit

Permalink
improve: use a single sponge
Browse files Browse the repository at this point in the history
  • Loading branch information
dmpierre committed Aug 7, 2024
1 parent bf541e7 commit b2adecb
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions folding-schemes/src/folding/nova/zk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,10 @@ where
}

// 1. Check that u_i.x is correct
let sponge = PoseidonSponge::<C1::ScalarField>::new(&poseidon_config);
let expected_u_i_x = proof.U_i.hash(&sponge, pp_hash, i, z_0, z_i);
let mut sponge = PoseidonSponge::<C1::ScalarField>::new(&poseidon_config);
let expected_u_i_x = proof
.U_i
.hash(&sponge, pp_hash, i, z_0.clone(), z_i.clone());
if expected_u_i_x != proof.u_i.x[0] {
return Err(Error::zkIVCVerificationFail);
}
Expand All @@ -270,9 +272,8 @@ where

// 3. Obtain the U_f folded instance
// a. Compute folding challenge
let mut challenges_sponge = PoseidonSponge::<C1::ScalarField>::new(&poseidon_config);
let r = RandomizedIVCProof::<C1, C2>::get_folding_challenge(
&mut challenges_sponge,
&mut sponge,
pp_hash,
proof.U_i.clone(),
proof.u_i.clone(),
Expand All @@ -282,15 +283,15 @@ where
// b. Get the U_f instance
let U_f = NIFS::<C1, CS1, true>::fold_committed_instance(
r,
&proof.u_i,
&proof.U_i,
&proof.u_i,
&proof.pi.cmT,
);

// 4. Obtain the U^{\prime}_i folded instance
// a. Compute folding challenge
let r_2 = RandomizedIVCProof::<C1, C2>::get_folding_challenge(
&mut challenges_sponge,
&mut sponge,
pp_hash,
U_f.clone(),
proof.U_r.clone(),
Expand Down Expand Up @@ -322,7 +323,7 @@ where
// 6. Check cyclefold proof
// a. Compute folding challenge
let cf_r = RandomizedIVCProof::<C1, C2>::get_cyclefold_folding_challenge::<GC2>(
&mut challenges_sponge,
&mut sponge,
pp_hash,
proof.cf_U_i.clone(),
proof.cf_U_j.clone(),
Expand Down

0 comments on commit b2adecb

Please sign in to comment.