fix: ecc/groups audit findings#22864
Conversation
0a84835 to
b61727c
Compare
87d90eb to
327252e
Compare
federicobarbacovi
left a comment
There was a problem hiding this comment.
Looks great, thanks for doing this! Just a few small comments
| } | ||
|
|
||
| // Regression test for element +/- affine_element when the affine operand is the infinity sentinel | ||
| // on the large-modulus path. The small-modulus path uses a different sentinel (MSB-of-x) and was |
There was a problem hiding this comment.
It's not clear to me why this bug didn't affect small modulus: the solution doesn't seem to take into account small/large moduli
There was a problem hiding this comment.
The small modulus case already handled the infinity edge case:
aztec-packages/barretenberg/cpp/src/barretenberg/ecc/groups/element_impl.hpp
Lines 170 to 178 in 327252e
But good point regardless, I edited the test to run for all curves.
| // verify_bn254_crs_integrity used by get_bn254_g1_data on the C++ download path; without | ||
| // it, bb.js (which downloads g1_compressed.dat externally and forwards the bytes here) | ||
| // would have no cryptographic gate against a tampered or wrong-trusted-setup payload. | ||
| // Partial trailing data is not chunk-hash-verified — instead the post-parse generator and |
There was a problem hiding this comment.
Can you please explain a bit more why it's ok not to hash check partial final data? Is it ok to have such data?
There was a problem hiding this comment.
Actually this is not a problem in how bb.js initialises SRS because it always fetches either numPoints buffer is NOT a multiple of 4 MiB (so basically a multiple of
327252e to
f8a5dbb
Compare
Summary
Addresses findings from the ecc/groups audit.
Commits
batch_affine_double_implslope formula to includeafor curves witha ≠ 0reject non-canonical x-coordinate encodings in(Opened its own PR)affine_element::from_compressedelement::mul_const_time(Montgomery ladder + Coron blinding)rhs = ∞in mixed-coordinateoperator+=y(andz) inself_set_infso the infinity representation is canonicalpairing.FinalExponentiationreference helper to iterate the full 256-bit exponentSrsInitSrs::execute, SHA-256-verify every fully-present compressed-G1 chunk againstBN254_G1_CHUNK_HASHESbefore decompression, ping1_points[0]to the canonical generator andg1_points[1]toτ·Gafter parsing, and SHA-256-pin the 128-byte G2 input. The subgroup check, on-disk G2 hash pin, infinity rejection, andis_in_prime_subgroupimplementation itself already landed in fix: harden BN254 G2 SRS ingress #22858.field::is_zeroconstant-timeTest plan
ecc_tests— pass (audit-related filter: 110 pass, 8 skipped, 0 failures)srs_tests(CrsFactory.*) — passbbapi_tests— pass (30/30)affine_element.test.cpp,element.test.cpp,pairing.test.cpp,prime_field.test.cpp