-
Notifications
You must be signed in to change notification settings - Fork 580
chore: transcript+codec+poseidon2 fixes #19419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: merge-train/barretenberg
Are you sure you want to change the base?
chore: transcript+codec+poseidon2 fixes #19419
Conversation
| EXPECT_TRUE(CircuitChecker::check(builder)); | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super!
| * the resulting hash must be different from the canonical representation. | ||
| * Also verifies consistency between stdlib and native Poseidon2 implementations. | ||
| */ | ||
| TYPED_TEST(StdlibPoseidon2, PointCoordinatesVsAliasProduceDifferentHashes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice test. Nit suggestion (optional): create a helper function (fixture) like other tests and call that in the test.
suyash67
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thanks for adding the codec readme, its very useful!
Summary
This PR addresses findings from the external audit of the Transcript and Poseidon2 components. The changes ensure consistent behavior between native and in-circuit verification, particularly around field element serialization/deserialization.
1. Field Element Serialization/Deserialization (Issues 5, 6, 9, 10, 11)
Problem: Inconsistent handling of field elements during serialization, particularly around edge cases involving the field modulus and aliased values.
validate_split_in_field_unsafenow properly rejectshi||lo == field_modulus(Issue 5)max_bits(Issue 6)lois constant (Issue 10)FrCodec(native) andStdlibCodec(in-circuit) now useassert_is_in_field()to reject unreduced values (Issues 9 & 11)Megaarithmetization, validation is deferred toTranslator+ECCVM; forUltra, strict validation happens immediately viabigfield2. Transcript Round Tracking (Issues 3, 4)
round_numberfield, now using onlyround_index(Issue 4)prover_init_emptyandverifier_init_emptyare now properly marked as testing methods (Issue 3)3. Poseidon2 Cleanup (Issues 1, 2, 7, 8)
Strategy:
used.internal_matrix_diagonal(Issue 2)matrix_multiplication_external(Issue 7)Commits:
FieldSponge::hash_internalis not marked as usedinternal_matrix_diagonalprover_init_emptyandverifier_init_emptyare testing methodsround_numberis redundant withround_indexvalidate_split_in_field_unsafeacceptshi||lo == modulus+ hardcodeddeserialize_from_fieldsrejects unreducedfqs + (fq_modulus, fq_modulus) handlingvalidate_split_in_field_unsafeskips borrow check whenlois constantDocumentation
Added barretenberg/cpp/src/barretenberg/stdlib/primitives/field/CODEC_README.md documenting:
New Tests
field_utils.test.cpp (new file):
field_conversion.test.cpp:
poseidon2.test.cpp:
poseidon2.circuit.failure.test.cpp: