Skip to content

Commit c2ada15

Browse files
committed
fix padding of bytecode claims (inside public input)
1 parent 2939726 commit c2ada15

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

crates/rec_aggregation/src/compilation.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ pub fn init_aggregation_bytecode() {
3030
fn compile_main_program(inner_program_log_size: usize, bytecode_zero_eval: F) -> Bytecode {
3131
let bytecode_point_n_vars = inner_program_log_size + log2_ceil_usize(N_INSTRUCTION_COLUMNS);
3232
let claim_data_size = (bytecode_point_n_vars + 1) * DIMENSION;
33+
let claim_data_size_padded = claim_data_size.next_multiple_of(DIGEST_LEN);
3334
// pub_input layout: n_sigs(1) + slice_hash(8) + slot_low(1) + slot_high(1)
34-
// + message + merkle_chunks_for_slot + bytecode_claim + bytecode_hash(8)
35-
let pub_input_size = 1 + DIGEST_LEN + 2 + MESSAGE_LEN_FE + N_MERKLE_CHUNKS_FOR_SLOT + claim_data_size + DIGEST_LEN;
35+
// + message + merkle_chunks_for_slot + bytecode_claim_padded + bytecode_hash(8)
36+
let pub_input_size =
37+
1 + DIGEST_LEN + 2 + MESSAGE_LEN_FE + N_MERKLE_CHUNKS_FOR_SLOT + claim_data_size_padded + DIGEST_LEN;
3638
let inner_public_memory_log_size = log2_ceil_usize(NONRESERVED_PROGRAM_INPUT_START + pub_input_size);
3739
let replacements = build_replacements(
3840
inner_program_log_size,

crates/rec_aggregation/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ fn build_non_reserved_public_input(
7474
pi.push(slot_hi);
7575
pi.extend(compute_merkle_chunks_for_slot(slot));
7676
pi.extend_from_slice(bytecode_claim_output);
77+
pi.extend(std::iter::repeat_n(
78+
F::ZERO,
79+
bytecode_claim_output.len().next_multiple_of(DIGEST_LEN) - bytecode_claim_output.len(),
80+
));
7781
pi.extend_from_slice(&poseidon16_compress_pair(bytecode_hash, &SNARK_DOMAIN_SEP));
7882
pi
7983
}

0 commit comments

Comments
 (0)