Skip to content

Commit

Permalink
Reorder Hyrax checks (#66)
Browse files Browse the repository at this point in the history
Co-authored-by: Antonio Mejías Gil <[email protected]>
  • Loading branch information
Cesar199999 and Antonio95 authored Jun 14, 2024
1 parent 3f39dbf commit 16ed9b8
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions poly-commit/src/hyrax/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,12 +470,6 @@ where
});
}

// Computing t_prime with a multi-exponentiation
let l_bigint = cfg_iter!(l)
.map(|chi| chi.into_bigint())
.collect::<Vec<_>>();
let t_prime: G = <G::Group as VariableBaseMSM>::msm_bigint(&row_coms, &l_bigint).into();

// Absorbing public parameters
sponge.absorb(
&Blake2s256::digest(serialize_to_vec!(*vk).map_err(|_| Error::TranscriptError)?)
Expand All @@ -499,15 +493,22 @@ where
// it from the transcript.
let c: G::ScalarField = sponge.squeeze_field_elements(1)[0];

// First check
let com_z_zd = (Self::pedersen_commit(&vk.com_key, z) + vk.h * z_d).into();
if com_z_zd != (t_prime.mul(c) + com_d).into() {
// Second check from the paper (figure 6, equation (14))
// Moved here for potential early return
let com_dp = (vk.com_key[0] * inner_product(&r, z) + vk.h * z_b).into();
if com_dp != (com_eval.mul(c) + com_b).into() {
return Ok(false);
}

// Second check
let com_dp = (vk.com_key[0] * inner_product(&r, z) + vk.h * z_b).into();
if com_dp != (com_eval.mul(c) + com_b).into() {
// Computing t_prime with a multi-exponentiation
let l_bigint = cfg_iter!(l)
.map(|chi| chi.into_bigint())
.collect::<Vec<_>>();
let t_prime: G = <G::Group as VariableBaseMSM>::msm_bigint(&row_coms, &l_bigint).into();

// First check from the paper (figure 6, equation (13))
let com_z_zd = (Self::pedersen_commit(&vk.com_key, z) + vk.h * z_d).into();
if com_z_zd != (t_prime.mul(c) + com_d).into() {
return Ok(false);
}
}
Expand Down

0 comments on commit 16ed9b8

Please sign in to comment.