Skip to content

Commit ef47a78

Browse files
committed
chore: remove fixed test vector from consensus_specs
1 parent 99f7e98 commit ef47a78

File tree

5 files changed

+9
-350
lines changed

5 files changed

+9
-350
lines changed

eip7594/benches/benchmark.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
use bls12_381::Scalar;
12
use criterion::{criterion_group, criterion_main, Criterion};
2-
use eip7594::consensus_specs_fixed_test_vector::eth_polynomial;
33
use kzg_multi_open::{
44
create_eth_commit_opening_keys, fk20::naive, polynomial::domain::Domain, reverse_bit_order,
55
};
@@ -8,7 +8,9 @@ use kzg_multi_open::{
88
pub fn bench_compute_proof_with_naive_fk20(c: &mut Criterion) {
99
const POLYNOMIAL_LEN: usize = 4096;
1010

11-
let mut polynomial_4096 = eth_polynomial();
11+
let mut polynomial_4096: Vec<_> = (0..POLYNOMIAL_LEN)
12+
.map(|i| -Scalar::from(i as u64))
13+
.collect();
1214
reverse_bit_order(&mut polynomial_4096);
1315
let domain = Domain::new(POLYNOMIAL_LEN);
1416
let polynomial_4096 = domain.ifft_scalars(polynomial_4096);

eip7594/src/consensus_specs_fixed_test_vector.rs

-196
This file was deleted.

eip7594/src/lib.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ use constants::{BYTES_PER_BLOB, BYTES_PER_CELL, BYTES_PER_COMMITMENT};
22
use prover::ProverContext;
33
use verifier::VerifierContext;
44

5-
// TODO: We can remove this once we hook up the consensus-specs fixed test vectors.
6-
pub mod consensus_specs_fixed_test_vector;
7-
85
pub mod constants;
96
pub mod prover;
107
mod serialization;
@@ -51,14 +48,13 @@ impl PeerDASContext {
5148

5249
#[cfg(test)]
5350
mod tests {
51+
use bls12_381::Scalar;
5452
use kzg_multi_open::polynomial::domain::Domain;
5553
use kzg_multi_open::{
5654
create_eth_commit_opening_keys, fk20::naive, proof::compute_multi_opening_naive,
5755
reverse_bit_order,
5856
};
5957

60-
use crate::consensus_specs_fixed_test_vector::eth_polynomial;
61-
6258
// This test becomes redundant once we have consensus-specs fixed test vectors
6359
// added. Although, it may be beneficial to test consensus-specs fixed test vectors against
6460
// the naive implementation, if it doesn't add too much overhead.
@@ -81,7 +77,9 @@ mod tests {
8177

8278
const NUMBER_OF_PROOFS: usize = NUMBER_OF_POINTS_TO_EVALUATE / NUMBER_OF_POINTS_PER_PROOF;
8379
let proof_domain = Domain::new(NUMBER_OF_PROOFS);
84-
let mut polynomial = eth_polynomial();
80+
let mut polynomial: Vec<_> = (0..POLYNOMIAL_LEN)
81+
.map(|i| -Scalar::from(i as u64))
82+
.collect();
8583
// Polynomial really corresponds to the evaluation form, so we need
8684
// to apply bit reverse order and then IFFT to get the coefficients
8785
reverse_bit_order(&mut polynomial);

eip7594/src/prover.rs

-48
Original file line numberDiff line numberDiff line change
@@ -188,51 +188,3 @@ pub(crate) fn evaluation_sets_to_cells<T: AsRef<[Scalar]>>(
188188
.try_into()
189189
.unwrap_or_else(|_| panic!("expected {} number of cells", CELLS_PER_EXT_BLOB))
190190
}
191-
192-
#[cfg(test)]
193-
mod tests {
194-
use crate::{
195-
consensus_specs_fixed_test_vector::{eth_commitment, BLOB_STR, CELLS_STR, PROOFS_STR},
196-
prover::ProverContext,
197-
};
198-
199-
#[test]
200-
fn test_polynomial_commitment_matches() {
201-
let ctx = ProverContext::new();
202-
203-
let blob_bytes = hex::decode(BLOB_STR).unwrap();
204-
205-
let got_commitment = ctx
206-
.blob_to_kzg_commitment(&blob_bytes.try_into().unwrap())
207-
.unwrap();
208-
let expected_commitment = eth_commitment().to_compressed();
209-
210-
assert_eq!(got_commitment, expected_commitment);
211-
}
212-
213-
#[test]
214-
fn test_computing_proofs() {
215-
// Setup
216-
let ctx = ProverContext::new();
217-
218-
let blob_bytes = hex::decode(BLOB_STR).unwrap();
219-
220-
let (got_cells, got_proofs) = ctx
221-
.compute_cells_and_kzg_proofs(&blob_bytes.try_into().unwrap())
222-
.unwrap();
223-
224-
let expected_proofs = PROOFS_STR;
225-
let expected_cells = CELLS_STR;
226-
227-
for k in 0..expected_proofs.len() {
228-
let expected_proof_str = expected_proofs[k];
229-
let expected_cell_str = expected_cells[k];
230-
231-
let got_proof_str = hex::encode(&got_proofs[k]);
232-
let got_cells_str = hex::encode(&*got_cells[k]);
233-
234-
assert_eq!(got_cells_str, expected_cell_str);
235-
assert_eq!(got_proof_str, expected_proof_str);
236-
}
237-
}
238-
}

eip7594/src/verifier.rs

+1-98
Original file line numberDiff line numberDiff line change
@@ -307,13 +307,7 @@ fn sanity_check_cells_and_cell_ids(
307307
#[cfg(test)]
308308
mod tests {
309309

310-
use std::ops::Range;
311-
312-
use crate::{
313-
consensus_specs_fixed_test_vector::{CELLS_STR, COMMITMENT_STR, PROOFS_STR},
314-
constants::CELLS_PER_EXT_BLOB,
315-
verifier::{is_cell_ids_unique, VerifierContext},
316-
};
310+
use crate::verifier::is_cell_ids_unique;
317311

318312
#[test]
319313
fn test_cell_ids_unique() {
@@ -326,95 +320,4 @@ mod tests {
326320
let cell_ids = vec![0, 0, 0];
327321
assert!(!is_cell_ids_unique(&cell_ids));
328322
}
329-
330-
#[test]
331-
fn test_proofs_verify() {
332-
// Setup
333-
let ctx = VerifierContext::new();
334-
335-
let commitment_str = COMMITMENT_STR;
336-
let commitment_bytes: [u8; 48] = hex::decode(commitment_str).unwrap().try_into().unwrap();
337-
338-
let proofs_str = PROOFS_STR;
339-
let proofs_bytes: Vec<[u8; 48]> = proofs_str
340-
.iter()
341-
.map(|proof_str| hex::decode(proof_str).unwrap().try_into().unwrap())
342-
.collect();
343-
344-
let cells_str = CELLS_STR;
345-
let cells_bytes: Vec<Vec<u8>> = cells_str
346-
.into_iter()
347-
.map(|cell_str| hex::decode(cell_str).unwrap())
348-
.collect();
349-
350-
for k in 0..proofs_bytes.len() {
351-
let proof_bytes = proofs_bytes[k];
352-
let cell_bytes = cells_bytes[k].clone().try_into().unwrap();
353-
let cell_id = k as u64;
354-
355-
assert!(ctx
356-
.verify_cell_kzg_proof(&commitment_bytes, cell_id, &cell_bytes, &proof_bytes)
357-
.is_ok());
358-
}
359-
360-
assert!(ctx
361-
.verify_cell_kzg_proof_batch(
362-
vec![&commitment_bytes; proofs_bytes.len()],
363-
vec![0; proofs_bytes.len()],
364-
(0..proofs_bytes.len()).map(|x| x as u64).collect(),
365-
cells_bytes
366-
.iter()
367-
.map(Vec::as_slice)
368-
.map(|cell| cell.try_into().unwrap())
369-
.collect(),
370-
proofs_bytes
371-
.iter()
372-
.map(|proof| proof.try_into().unwrap())
373-
.collect(),
374-
)
375-
.is_ok());
376-
}
377-
378-
#[test]
379-
fn test_recover_all_cells() {
380-
let ctx = VerifierContext::new();
381-
let num_cells_to_keep = CELLS_PER_EXT_BLOB / 2;
382-
383-
fn generate_unique_random_numbers(range: Range<u64>, n: usize) -> Vec<u64> {
384-
use rand::prelude::SliceRandom;
385-
let mut numbers: Vec<_> = range.into_iter().collect();
386-
numbers.shuffle(&mut rand::thread_rng());
387-
numbers.into_iter().take(n).collect()
388-
}
389-
390-
let cell_ids_to_keep = generate_unique_random_numbers(0..128, num_cells_to_keep);
391-
let cells_as_hex_strings: Vec<_> = cell_ids_to_keep
392-
.iter()
393-
.map(|cell_id| CELLS_STR[*cell_id as usize])
394-
.collect();
395-
let cells_to_keep: Vec<_> = cells_as_hex_strings
396-
.into_iter()
397-
.map(|cell_str| hex::decode(cell_str).unwrap())
398-
.collect();
399-
400-
let all_cells: Vec<_> = CELLS_STR
401-
.into_iter()
402-
.map(|cell_str| hex::decode(cell_str).unwrap())
403-
.collect();
404-
405-
let recovered_cells = ctx
406-
.recover_all_cells(
407-
cell_ids_to_keep,
408-
cells_to_keep
409-
.iter()
410-
.map(Vec::as_slice)
411-
.map(|v| v.try_into().unwrap())
412-
.collect(),
413-
)
414-
.unwrap();
415-
416-
for (recovered_cell, expected_cell) in recovered_cells.into_iter().zip(all_cells) {
417-
assert_eq!(&recovered_cell[..], &expected_cell[..])
418-
}
419-
}
420323
}

0 commit comments

Comments
 (0)