Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't output errorneous proofs for invalid cell indices, return error… #40

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions kate/src/com.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ pub enum Error {
BaseGridDomainSizeInvalid(usize),
/// The extended grid width does not fit cleanly into a domain for FFTs
ExtendedGridDomianSizeInvalid(usize),
IndexOutOfRange,
}

impl From<TryFromIntError> for Error {
Expand Down Expand Up @@ -376,7 +377,7 @@ pub fn build_proof<M: Metrics>(
for (cell, res) in cell_iter {
let r_index = usize::try_from(cell.row.0)?;
if r_index >= ext_rows || cell.col >= block_dims.cols {
res.fill(0); // for bad cell identifier, fill whole proof with zero bytes !
return Err(Error::IndexOutOfRange);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we please use avail_core::ensure here? That could remove the if-else

} else {
let c_index = usize::try_from(cell.col.0)?;
let get_ext_data_matrix =
Expand All @@ -401,6 +402,7 @@ pub fn build_proof<M: Metrics>(
// row has to be a power of 2, otherwise interpolate() function panics TODO: cache evaluations
let poly = Evaluations::from_vec_and_domain(row, row_eval_domain).interpolate();
let witness = prover_key.compute_single_witness(&poly, &row_dom_x_pts[c_index]);

match prover_key.commit(&witness) {
Ok(commitment_to_witness) => {
let evaluated_point =
Expand All @@ -409,9 +411,7 @@ pub fn build_proof<M: Metrics>(
res[0..PROOF_SIZE].copy_from_slice(&commitment_to_witness.to_bytes());
res[PROOF_SIZE..].copy_from_slice(&evaluated_point.to_bytes());
},
Err(_) => {
res.fill(0); // for bad cell identifier, fill whole proof with zero bytes !
},
Err(e) => return Err(Error::PlonkError(e)),
};
}
}
Expand Down
Loading