Skip to content

Commit

Permalink
chore: minor nits (#126)
Browse files Browse the repository at this point in the history
* row -> commitment

* remove unused enum variant and change VerifierError -> Verifier
  • Loading branch information
kevaundray authored Aug 1, 2024
1 parent f557acf commit 1728c8b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
16 changes: 7 additions & 9 deletions eip7594/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ use crate::CellIndex;
#[derive(Debug)]
pub enum Error {
Prover(ProverError),
VerifierError(VerifierError),
Verifier(VerifierError),
Serialization(SerializationError),
}

impl Error {
pub fn invalid_proof(&self) -> bool {
matches!(self, Error::VerifierError(VerifierError::InvalidProof))
matches!(self, Error::Verifier(VerifierError::InvalidProof))
}
}

Expand All @@ -23,7 +23,7 @@ impl From<ProverError> for Error {
}
impl From<VerifierError> for Error {
fn from(value: VerifierError) -> Self {
Error::VerifierError(value)
Error::Verifier(value)
}
}
impl From<SerializationError> for Error {
Expand All @@ -35,8 +35,6 @@ impl From<SerializationError> for Error {
/// Errors that can occur while calling a method in the Prover API
#[derive(Debug)]
pub enum ProverError {
// TODO: This will be getting removed, waiting for consensus-specs PR
NumProofsDoesNotEqualNumCells,
RecoveryFailure(VerifierError),
}

Expand Down Expand Up @@ -71,13 +69,13 @@ pub enum VerifierError {
cell_index: CellIndex,
max_number_of_cells: u64,
},
InvalidRowIndex {
row_index: u64,
max_number_of_rows: u64,
InvalidCommitmentIndex {
commitment_index: u64,
max_number_of_commitments: u64,
},
InvalidProof,
BatchVerificationInputsMustHaveSameLength {
row_indices_len: usize,
commitment_indices_len: usize,
cell_indices_len: usize,
cells_len: usize,
proofs_len: usize,
Expand Down
24 changes: 12 additions & 12 deletions eip7594/src/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,31 +210,31 @@ mod validation {

/// Validation logic for `verify_cell_kzg_proof_batch`
pub fn verify_cell_kzg_proof_batch(
row_commitments_bytes: &[Bytes48Ref],
row_indices: &[RowIndex],
deduplicated_commitments_bytes: &[Bytes48Ref],
commitment_indices: &[RowIndex],
cell_indices: &[CellIndex],
cells: &[CellRef],
proofs_bytes: &[Bytes48Ref],
) -> Result<(), VerifierError> {
// All inputs must have the same length according to the specs.
let same_length = (row_indices.len() == cell_indices.len())
& (row_indices.len() == cells.len())
& (row_indices.len() == proofs_bytes.len());
let same_length = (commitment_indices.len() == cell_indices.len())
& (commitment_indices.len() == cells.len())
& (commitment_indices.len() == proofs_bytes.len());
if !same_length {
return Err(VerifierError::BatchVerificationInputsMustHaveSameLength {
row_indices_len: row_indices.len(),
commitment_indices_len: commitment_indices.len(),
cell_indices_len: cell_indices.len(),
cells_len: cells.len(),
proofs_len: proofs_bytes.len(),
});
}

// Check that the row indices are within the correct range
for row_index in row_indices {
if *row_index >= row_commitments_bytes.len() as u64 {
return Err(VerifierError::InvalidRowIndex {
row_index: *row_index,
max_number_of_rows: row_commitments_bytes.len() as u64,
// Check that the commitment indices are within the correct range
for commitment_index in commitment_indices {
if *commitment_index >= deduplicated_commitments_bytes.len() as u64 {
return Err(VerifierError::InvalidCommitmentIndex {
commitment_index: *commitment_index,
max_number_of_commitments: deduplicated_commitments_bytes.len() as u64,
});
}
}
Expand Down

0 comments on commit 1728c8b

Please sign in to comment.