Skip to content

Commit 1728c8b

Browse files
authored
chore: minor nits (#126)
* row -> commitment * remove unused enum variant and change VerifierError -> Verifier
1 parent f557acf commit 1728c8b

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed

eip7594/src/errors.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ use crate::CellIndex;
66
#[derive(Debug)]
77
pub enum Error {
88
Prover(ProverError),
9-
VerifierError(VerifierError),
9+
Verifier(VerifierError),
1010
Serialization(SerializationError),
1111
}
1212

1313
impl Error {
1414
pub fn invalid_proof(&self) -> bool {
15-
matches!(self, Error::VerifierError(VerifierError::InvalidProof))
15+
matches!(self, Error::Verifier(VerifierError::InvalidProof))
1616
}
1717
}
1818

@@ -23,7 +23,7 @@ impl From<ProverError> for Error {
2323
}
2424
impl From<VerifierError> for Error {
2525
fn from(value: VerifierError) -> Self {
26-
Error::VerifierError(value)
26+
Error::Verifier(value)
2727
}
2828
}
2929
impl From<SerializationError> for Error {
@@ -35,8 +35,6 @@ impl From<SerializationError> for Error {
3535
/// Errors that can occur while calling a method in the Prover API
3636
#[derive(Debug)]
3737
pub enum ProverError {
38-
// TODO: This will be getting removed, waiting for consensus-specs PR
39-
NumProofsDoesNotEqualNumCells,
4038
RecoveryFailure(VerifierError),
4139
}
4240

@@ -71,13 +69,13 @@ pub enum VerifierError {
7169
cell_index: CellIndex,
7270
max_number_of_cells: u64,
7371
},
74-
InvalidRowIndex {
75-
row_index: u64,
76-
max_number_of_rows: u64,
72+
InvalidCommitmentIndex {
73+
commitment_index: u64,
74+
max_number_of_commitments: u64,
7775
},
7876
InvalidProof,
7977
BatchVerificationInputsMustHaveSameLength {
80-
row_indices_len: usize,
78+
commitment_indices_len: usize,
8179
cell_indices_len: usize,
8280
cells_len: usize,
8381
proofs_len: usize,

eip7594/src/verifier.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -210,31 +210,31 @@ mod validation {
210210

211211
/// Validation logic for `verify_cell_kzg_proof_batch`
212212
pub fn verify_cell_kzg_proof_batch(
213-
row_commitments_bytes: &[Bytes48Ref],
214-
row_indices: &[RowIndex],
213+
deduplicated_commitments_bytes: &[Bytes48Ref],
214+
commitment_indices: &[RowIndex],
215215
cell_indices: &[CellIndex],
216216
cells: &[CellRef],
217217
proofs_bytes: &[Bytes48Ref],
218218
) -> Result<(), VerifierError> {
219219
// All inputs must have the same length according to the specs.
220-
let same_length = (row_indices.len() == cell_indices.len())
221-
& (row_indices.len() == cells.len())
222-
& (row_indices.len() == proofs_bytes.len());
220+
let same_length = (commitment_indices.len() == cell_indices.len())
221+
& (commitment_indices.len() == cells.len())
222+
& (commitment_indices.len() == proofs_bytes.len());
223223
if !same_length {
224224
return Err(VerifierError::BatchVerificationInputsMustHaveSameLength {
225-
row_indices_len: row_indices.len(),
225+
commitment_indices_len: commitment_indices.len(),
226226
cell_indices_len: cell_indices.len(),
227227
cells_len: cells.len(),
228228
proofs_len: proofs_bytes.len(),
229229
});
230230
}
231231

232-
// Check that the row indices are within the correct range
233-
for row_index in row_indices {
234-
if *row_index >= row_commitments_bytes.len() as u64 {
235-
return Err(VerifierError::InvalidRowIndex {
236-
row_index: *row_index,
237-
max_number_of_rows: row_commitments_bytes.len() as u64,
232+
// Check that the commitment indices are within the correct range
233+
for commitment_index in commitment_indices {
234+
if *commitment_index >= deduplicated_commitments_bytes.len() as u64 {
235+
return Err(VerifierError::InvalidCommitmentIndex {
236+
commitment_index: *commitment_index,
237+
max_number_of_commitments: deduplicated_commitments_bytes.len() as u64,
238238
});
239239
}
240240
}

0 commit comments

Comments
 (0)