Skip to content

Commit

Permalink
removed unnecessary function defined inside check()
Browse files Browse the repository at this point in the history
Co-authored-by: Cesar Descalzo <Cesar199999@users.noreply.github.com>
  • Loading branch information
Antonio95 and Cesar199999 committed Jun 4, 2024
1 parent 6c5e096 commit 18a3d84
Showing 1 changed file with 13 additions and 25 deletions.
38 changes: 13 additions & 25 deletions poly-commit/src/linear_codes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ where

// 3. Hash the received columns into leaf hashes.
let mut col_hashes: Vec<C::Leaf> = Vec::new();

for c in proof.opening.columns.iter() {
match H::evaluate(vk.col_hash_params(), c.clone()) {
Ok(a) => col_hashes.push(a.into()),
Expand All @@ -447,15 +447,6 @@ where
}
}

// Helper closure: checks if a.b = c.
let check_inner_product = |a, b, c| -> Result<(), Error> {
if inner_product(a, b) != c {
return Err(Error::InvalidCommitment);
}

Ok(())
};

// 5. Compute the encoding w = E(v).
let w = L::encode(&proof.opening.v, vk);

Expand All @@ -468,24 +459,21 @@ where
if let (Some(well_formedness), Some(r)) = out {
let w_well_formedness = L::encode(well_formedness, vk);
for (transcript_index, matrix_index) in indices.iter().enumerate() {
check_inner_product(
&r,
&proof.opening.columns[transcript_index],
w_well_formedness[*matrix_index],
)?;
check_inner_product(
&b,
&proof.opening.columns[transcript_index],
w[*matrix_index],
)?;
if inner_product(&r, &proof.opening.columns[transcript_index])
!= w_well_formedness[*matrix_index]
|| inner_product(&b, &proof.opening.columns[transcript_index])
!= w[*matrix_index]
{
return Err(Error::InvalidCommitment);
}
}
} else {
for (transcript_index, matrix_index) in indices.iter().enumerate() {
check_inner_product(
&b,
&proof.opening.columns[transcript_index],
w[*matrix_index],
)?;
if inner_product(&b, &proof.opening.columns[transcript_index])
!= w[*matrix_index]
{
return Err(Error::InvalidCommitment);
}
}
}

Expand Down

0 comments on commit 18a3d84

Please sign in to comment.