Skip to content

Commit

Permalink
Revert orthogonal changes to kzg_verify_cell_kzg_proof_batch
Browse files Browse the repository at this point in the history
  • Loading branch information
kevaundray committed Aug 27, 2024
1 parent c8aec80 commit bd89823
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions testing/ef_tests/src/cases/kzg_verify_cell_kzg_proof_batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,37 +37,32 @@ impl<E: EthSpec> Case for KZGVerifyCellKZGProofBatch<E> {
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {
let parse_input = |input: &KZGVerifyCellKZGProofBatchInput| -> Result<_, Error> {
let (cells, proofs) = parse_cells_and_proofs(&input.cells, &input.proofs)?;
// TODO: We are not pulling in the latest consensus-specs
// TODO: whereas the kzg libraries are using the new API, so
// TODO: we need to update this code to work for the new API.
let row_commitments = input
.row_commitments
.iter()
.map(|s| parse_commitment(s))
.collect::<Result<Vec<_>, _>>()?;
// The new API requires the duplicated commitments
let commitments: Vec<_> = input
let coordinates = input
.row_indices
.iter()
.filter_map(|row_index| row_commitments.get(*row_index).cloned())
.collect();
// The new API only requires the cell indices
let cell_indices = input
.column_indices
.iter()
.map(|&col| col as u64)
.zip(&input.column_indices)
.map(|(&row, &col)| (row as u64, col as u64))
.collect::<Vec<_>>();

Ok((cells, proofs, cell_indices, commitments))
Ok((cells, proofs, coordinates, row_commitments))
};

let result =
parse_input(&self.input).and_then(|(cells, proofs, cell_indices, commitments)| {
parse_input(&self.input).and_then(|(cells, proofs, coordinates, commitments)| {
let proofs: Vec<Bytes48> = proofs.iter().map(|&proof| proof.into()).collect();
let commitments: Vec<Bytes48> = commitments.iter().map(|&c| c.into()).collect();
let cells = cells.iter().map(|c| c.as_ref()).collect::<Vec<_>>();
let kzg = get_kzg();
match kzg.verify_cell_proof_batch(&cells, &proofs, cell_indices, &commitments) {
let column_indices = coordinates
.into_iter()
.map(|(_row, col)| col)
.collect::<Vec<_>>();
let kzg = get_kzg()?;
match kzg.verify_cell_proof_batch(&cells, &proofs, column_indices, &commitments) {
Ok(_) => Ok(true),
Err(KzgError::KzgVerificationFailed) => Ok(false),
Err(e) => Err(Error::InternalError(format!(
Expand Down

0 comments on commit bd89823

Please sign in to comment.