fix: BN254 G2 msgpack serialization in barretenberg-rs#22360
Open
johnathan79717 wants to merge 4 commits intomerge-train/barretenbergfrom
Open
fix: BN254 G2 msgpack serialization in barretenberg-rs#22360johnathan79717 wants to merge 4 commits intomerge-train/barretenbergfrom
johnathan79717 wants to merge 4 commits intomerge-train/barretenbergfrom
Conversation
G2 tests currently fail due to missing serde_bytes annotations on Bn254G2Point fields (AztecProtocol/barretenberg#1669).
The Rust codegen was missing serde handling for the field2 primitive type ([Vec<u8>; 2]), causing Bn254G2Point fields to serialize as msgpack integer arrays instead of bin32 blobs. The C++ backend expects bin32, so G2 operations would abort on deserialization. Fixes AztecProtocol/barretenberg#1669
Verify 2*(3*G) == 3*(2*G) for both G1 and G2 instead of just multiplying by 1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
serde_byteshandling forfield2primitive type ([Vec<u8>; 2]) in Rust codegen, which causedBn254G2Pointfields to serialize as msgpack integer arrays instead ofbin32blobs. The C++ backend expectsbin32, sobn254_g2_mulwould abort on deserialization.serde_array2_bytesmodule (same pattern as existingserde_array4_bytes) and detection logic in the codegen.bn254_g1_mulandbn254_g2_mulusing the EIP-197 G2 generator.Fixes AztecProtocol/barretenberg#1669. Reported by Porco from Obsidion.
Test plan
test_bn254_g1_mul_by_onepasses (baseline, confirms G1 serialization is correct)test_bn254_g2_mul_by_onepasses (1 * G2 = G2, confirms fix)test_bn254_g2_mul_by_twopasses (2 * G2 != G2, confirms non-trivial operation works)Commands used: