Skip to content

Commit 32ffd88

Browse files
authored
fix(new-execution): assign bls12_381 output properly (#1895)
1 parent 7b96336 commit 32ffd88

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

extensions/algebra/circuit/src/fields.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ pub fn field_element_to_blocks<F: PrimeField<Repr = [u8; 32]>, const BLOCK_SIZE:
281281
field_element: &F,
282282
output: &mut [[u8; BLOCK_SIZE]],
283283
) {
284+
debug_assert!(output.len() * BLOCK_SIZE == 32);
284285
let bytes = field_element.to_repr();
285286
let mut byte_idx = 0;
286287

@@ -312,6 +313,7 @@ pub fn field_element_to_blocks_bls12_381_coordinate<const BLOCK_SIZE: usize>(
312313
field_element: &halo2curves_axiom::bls12_381::Fq,
313314
output: &mut [[u8; BLOCK_SIZE]],
314315
) {
316+
debug_assert!(output.len() * BLOCK_SIZE == 48);
315317
let bytes = field_element.to_bytes();
316318
let mut byte_idx = 0;
317319

extensions/ecc/circuit/src/weierstrass_chip/curves.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ fn ec_double_bls12_381<const BLOCKS: usize, const BLOCK_SIZE: usize>(
170170

171171
// Final output
172172
let mut output = [[0u8; BLOCK_SIZE]; BLOCKS];
173-
field_element_to_blocks_bls12_381_coordinate(&x3, &mut output);
174-
field_element_to_blocks_bls12_381_coordinate(&y3, &mut output);
173+
field_element_to_blocks_bls12_381_coordinate(&x3, &mut output[..BLOCKS / 2]);
174+
field_element_to_blocks_bls12_381_coordinate(&y3, &mut output[BLOCKS / 2..]);
175175
output
176176
}
177177

0 commit comments

Comments
 (0)