Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.

Commit 8afe2f5

Browse files
committed
don't make unused powers of 256
1 parent 71a30dd commit 8afe2f5

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

aggregator/src/aggregation/batch_data.rs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::{
2-
aggregation::rlc::POWS_OF_256, aggregation::util::constrain_crt_equals_bytes,
3-
blob_consistency::BLOB_WIDTH, constants::N_BYTES_U256, BatchHash, ChunkInfo, RlcConfig,
2+
aggregation::util::constrain_crt_equals_bytes, blob_consistency::BLOB_WIDTH,
3+
constants::N_BYTES_U256, BatchHash, ChunkInfo, RlcConfig,
44
};
55
use eth_types::{H256, U256};
66
use ethers_core::utils::keccak256;
@@ -579,6 +579,14 @@ impl<const N_SNARKS: usize> BatchDataConfig<N_SNARKS> {
579579
region.constrain_equal(four.cell(), four_cell)?;
580580
four
581581
};
582+
let two_fifty_six = {
583+
let two_fifty_six =
584+
rlc_config.load_private(region, &Fr::from(256), &mut rlc_config_offset)?;
585+
let two_fifty_six_cell = rlc_config.four_cell(two_fifty_six.cell().region_index);
586+
region.constrain_equal(two_fifty_six.cell(), two_fifty_six_cell)?;
587+
two_fifty_six
588+
};
589+
582590
let fixed_chunk_indices = {
583591
let mut fixed_chunk_indices = vec![one.clone()];
584592
for i in 2..=N_SNARKS {
@@ -594,22 +602,6 @@ impl<const N_SNARKS: usize> BatchDataConfig<N_SNARKS> {
594602
};
595603
let two = fixed_chunk_indices.get(1).expect("N_SNARKS >= 2");
596604
let n_snarks = fixed_chunk_indices.last().expect("N_SNARKS >= 2");
597-
let pows_of_256 = {
598-
let mut pows_of_256 = vec![one.clone()];
599-
for (exponent, pow_of_256) in (1..=POWS_OF_256).zip_eq(
600-
std::iter::successors(Some(Fr::from(256)), |n| Some(n * Fr::from(256)))
601-
.take(POWS_OF_256),
602-
) {
603-
let pow_cell =
604-
rlc_config.load_private(region, &pow_of_256, &mut rlc_config_offset)?;
605-
let fixed_pow_cell = rlc_config
606-
.pow_of_two_hundred_and_fifty_six_cell(pow_cell.cell().region_index, exponent);
607-
region.constrain_equal(pow_cell.cell(), fixed_pow_cell)?;
608-
pows_of_256.push(pow_cell);
609-
}
610-
pows_of_256
611-
};
612-
let two_fifty_six = pows_of_256[1].clone();
613605

614606
// read randomness challenges for RLC computations.
615607
let r_keccak =

0 commit comments

Comments
 (0)