Skip to content

Commit 227e2cd

Browse files
committed
fix: blob data exceeding BLS_MODULUS
1 parent 286cec8 commit 227e2cd

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

  • aggregation_mode/src/backend

aggregation_mode/src/backend/mod.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ mod merkle_tree;
44
mod s3;
55
mod types;
66

7-
use crate::aggregators::{lib::{AggregatedProof, ProofAggregationError}, sp1_aggregator::{aggregate_proofs, SP1AggregationInput}, AlignedProof, ZKVMEngine};
8-
7+
use crate::aggregators::{
8+
lib::{AggregatedProof, ProofAggregationError},
9+
sp1_aggregator::{aggregate_proofs, SP1AggregationInput},
10+
AlignedProof, ZKVMEngine,
11+
};
912

1013
use alloy::{
1114
consensus::{Blob, BlobTransactionSidecar},
@@ -25,7 +28,6 @@ use std::str::FromStr;
2528
use tracing::{error, info, warn};
2629
use types::{AlignedProofAggregationService, AlignedProofAggregationServiceContract};
2730

28-
2931
#[derive(Debug)]
3032
pub enum AggregatedProofSubmissionError {
3133
Aggregation(ProofAggregationError),
@@ -122,8 +124,7 @@ impl ProofAggregator {
122124
merkle_root,
123125
};
124126

125-
aggregate_proofs(input)
126-
.map_err(AggregatedProofSubmissionError::Aggregation)?
127+
aggregate_proofs(input).map_err(AggregatedProofSubmissionError::Aggregation)?
127128
}
128129
};
129130
info!("Proof aggregation program finished");
@@ -184,8 +185,17 @@ impl ProofAggregator {
184185
let data: Vec<u8> = leaves.iter().flat_map(|arr| arr.iter().copied()).collect();
185186
let mut blob_data: [u8; BYTES_PER_BLOB] = [0u8; BYTES_PER_BLOB];
186187

187-
for (i, byte) in data.iter().enumerate() {
188-
blob_data[i] = *byte;
188+
// We pad the data with 0x0 byte every 31 bytes so that the field elements
189+
// constructed from the bytes are less than BLS_MODULUS.
190+
//
191+
// See https://github.com/ethereum/consensus-specs/blob/86fb82b221474cc89387fa6436806507b3849d88/specs/deneb/polynomial-commitments.md#bytes_to_bls_field
192+
let mut offset = 0;
193+
for chunk in data.chunks(31) {
194+
blob_data[offset] = 0x00;
195+
let start = offset + 1;
196+
let end = start + chunk.len();
197+
blob_data[start..end].copy_from_slice(chunk);
198+
offset += 32;
189199
}
190200

191201
// calculate kzg commitments for blob

0 commit comments

Comments
 (0)