feat: merge-train/barretenberg#23560
Merged
Merged
Conversation
…zzer
Adds pippenger_constantine.hpp as a standalone primitive carved out of the
upcoming round-parallel Pippenger MSM rewrite. Self-contained header in
bb::scalar_multiplication::round_parallel_detail with no callers on this
branch — landed first so the recoder gets reviewed and CI-gated as a
mathematical primitive rather than buried inside the larger MSM PR.
The recoder implements Constantine's signedWindowEncoding / getSignedFullWindowAt
(constantine/math/arithmetic/bigints.nim): each window reads (c+1) bits including
the previous window's top bit and lets that shared boundary bit substitute for an
explicit carry, producing a (sign | bucket) packed digit. Two parallel families:
* Scalar path — ConstantineSliceParams + get_constantine_packed_digit
(uint64-indexed limbs)
* SIMD x4 path — ConstantineSliceParamsU32 + three specialised stores
(uint32-indexed limbs, GCC vector_size, 4 scalars/call)
The SIMD helpers split on slice-path (Localised / Bottom / Boundary) so the
per-window branch hoists out of the per-scalar inner loop.
Tests (pippenger_constantine.test.cpp, ~48 ms native / ~46 ms WASM):
1. ScalarMatchesReferenceOracleAllWindowBits — production scalar path vs a
textbook signed-window reference oracle. Sweeps window_bits in [1, 19]
(covers the [2, 19] choose_window_bits range plus the wb=1 final window
that build_var_window_schedule can emit) and bit_offset in [0, 255].
2. SimdX4MatchesScalarPathLanewise — SIMD x4 ≡ scalar lane-by-lane across
all three specialisations, with a coverage assertion that each fires.
3. RoundTripIdentityMatchesScalarMod2N — sum_w (-1)^{sign_w} · bucket_w ·
2^{B_w} ≡ scalar (mod 2^256). The load-bearing algebraic invariant.
4. EdgeCases — zero scalar, bottom-window classifier, top-window limb
clamp (incl. bit_offset 255), localised/boundary flag boundaries.
5. NamedSliceShapes — 12 named structural cases (bottom_wb*, local_*,
boundary_u64_at_{63,127,191}, boundary_u32_at_31, top_clamped,
top_wb1_final) so a regression at one shape shows up as a named failure.
6. ParamClassifierU64U32Consistency — asserts the u64 / u32 param structs
encode the same lookback bit position and bottom-window classification,
so a bug in one classifier alone is not masked by the final-digit oracle.
Fuzzer (pippenger_constantine.fuzzer.cpp):
Differential libFuzzer target — for each (window_bits, bit_offset, 4 random
scalars) checks (a) scalar path == reference oracle, (b) SIMD x4 == scalar
per lane. Verified clean under both `fuzzing` (30M iters / 30s) and
`fuzzing-asan` (30M iters / 46s) presets with a boundary-biased seed corpus
pinned to {0, 1, 31/32/33, 63/64/65, 127/128, 191/192, 253/254/255}.
Minor follow-on cleanup: extracted simd_u32x4_store() helper to dedupe the
three `#ifdef __wasm_simd128__` blocks across the SIMD specialisations.
[[gnu::always_inline]] makes it post-inline byte-identical to the previous
open-coded form.
Reverts d76a316 which was pushed directly to merge-train/barretenberg without a PR. Will re-land via proper PR from `si/pippenger-constantine`.
Collaborator
Author
|
🤖 Auto-merge enabled after 4 hours of inactivity. This PR will be merged automatically once all checks pass. |
Collaborator
Author
Flakey Tests🤖 says: This CI run detected 1 tests that failed, but were tolerated due to a .test_patterns.yml entry. |
Collaborator
Author
|
🤖 Auto-merge enabled after 4 hours of inactivity. This PR will be merged automatically once all checks pass. |
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.
BEGIN_COMMIT_OVERRIDE
fix: revert extract Constantine signed-Booth window recoder (#23561)
END_COMMIT_OVERRIDE