You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BN254 G2 msgpack serialization bug in barretenberg-rs #1669
Bn254G2Point in barretenberg-rs is missing serde_bytes annotations on its [Vec<u8>; 2] fields, causing msgpack serialization to produce arrays of integers instead of bin32 blobs. The C++ bbapi expects bin32 (via uint256_t::msgpack_unpack), so bn254_g2_mul calls fail with a deserialization abort.
Reported by Porco from Obsidion.
Details
Bn254G1Point works correctly because its Vec<u8> fields use #[serde(with = "serde_bytes")]:
Bn254G2Point is missing the equivalent annotation:
pubstructBn254G2Point{pubx:[Vec<u8>;2],// no serde annotationpuby:[Vec<u8>;2],// no serde annotation}
Without the annotation, rmp-serde serializes each Vec<u8> element as a msgpack array of integers rather than a bin32 blob.
Root cause
The Rust code generator (rust_codegen.ts) handles serde_bytes for bytes primitives and serde_array4_bytes for [Vec<u8>; 4] arrays, but has no handling for the field2 primitive type which maps to [Vec<u8>; 2].
Fix
Add a serde_array2_bytes module (same pattern as existing serde_array4_bytes)
Add needsSerdeArray2Bytes() detection for field2 primitive types in rust_codegen.ts
Annotate Bn254G2Point fields with #[serde(with = "serde_array2_bytes")]
Affected versions
Every published version from 4.1.0-rc.2 through 5.0.0-private.20260319. There are no tests for bn254_g2_mul which is why this was never caught.
Activity
test: add bn254 G1/G2 scalar multiplication tests
fix: add serde_array2_bytes for Bn254G2Point field2 serialization
fix: BN254 G2 msgpack serialization in barretenberg-rs (#22360)
AztecBot commentedon Apr 29, 2026
This issue was automatically closed because it was referenced in AztecProtocol/aztec-packages PR #22360 which has been merged to the default branch.
View workflow run