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
add constant-time x86-64 inline-assembly paths for Pasta field addition and
subtraction
use the addition path for [ff::Field::double]
extend the randomized canonical-residue sweep to cover add and subtract
make the existing double Criterion cases measure the selected trait
backend instead of the inherent portable helper
The implementation remains behind the existing opt-in x86_64-asm feature,
which requires BMI2 and ADX because the same backend also contains the
multiplication and squaring kernels.
Companion PR #432 forwards that feature through zakura-halo2-proofs and zakura-orchard, so top-level consumers can select the backend without
patching dependency manifests.
Validation
200,000 random operand pairs per field matched the portable add, subtract,
multiply, and square implementations on Intel Ice Lake and AMD Zen 4
cargo test --locked -p zakura-pasta-curves passes on macOS
source-isolated benchmark builds used separate Cargo target directories and
distinct executable hashes; measurements ran control-candidate-candidate-
control to expose order effects
Benchmarks
Criterion: 2 s warm-up, 8 s measurement, 100 samples. Midpoint averages from
the two measurement orders:
Host
Kernel
Fp
Fq
Intel Ice Lake
add
11.2% faster
12.2% faster
Intel Ice Lake
subtract
13.0% faster
12.8% faster
Intel Ice Lake
double
2.2% faster
2.0% faster
AMD Zen 4
add
11.0% slower
10.7% slower
AMD Zen 4
subtract
0.5% faster
2.8% faster
AMD Zen 4
double
15.0% faster
15.3% faster
The AMD add regression is real, but doubling is substantially faster and is
the more important path in the prover. End-to-end Ironwood k=11 proving was
consistently faster across both action counts and thread counts:
Host
1 thread
8 threads
Intel Ice Lake
3.1–4.3% faster
4.3–4.9% faster
AMD Zen 4
3.5–4.9% faster
3.4–4.0% faster
Full-prover runs used 2 s warm-up, 15 s measurement, 10 samples, with one and
four actions. No runtime CPU dispatch is added here; generic builds remain on
the portable path unless x86_64-asm is explicitly enabled.
When the x86_64-asm backend is selected, the newly routed addition, subtraction, and ff::Field::double paths execute debug_assert!(is_canonical(...)) before entering the straight-line assembly. The is_canonical helper scans limbs from most significant to least significant and returns at the first limb that differs from the modulus. Canonical field values therefore take different branch counts: values whose high limb is below the modulus exit immediately, while values matching the modulus's high limbs continue through additional comparisons. The assembly kernels themselves are branchless, but the complete field operations are not constant-time in builds where debug assertions are enabled. Builds with debug assertions disabled do not execute these checks.
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
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
subtraction
ff::Field::double]doubleCriterion cases measure the selected traitbackend instead of the inherent portable helper
The implementation remains behind the existing opt-in
x86_64-asmfeature,which requires BMI2 and ADX because the same backend also contains the
multiplication and squaring kernels.
Companion PR #432 forwards that feature through
zakura-halo2-proofsandzakura-orchard, so top-level consumers can select the backend withoutpatching dependency manifests.
Validation
multiply, and square implementations on Intel Ice Lake and AMD Zen 4
cargo test --locked -p zakura-pasta-curvespasses on macOSdistinct executable hashes; measurements ran control-candidate-candidate-
control to expose order effects
Benchmarks
Criterion: 2 s warm-up, 8 s measurement, 100 samples. Midpoint averages from
the two measurement orders:
The AMD add regression is real, but doubling is substantially faster and is
the more important path in the prover. End-to-end Ironwood
k=11proving wasconsistently faster across both action counts and thread counts:
Full-prover runs used 2 s warm-up, 15 s measurement, 10 samples, with one and
four actions. No runtime CPU dispatch is added here; generic builds remain on
the portable path unless
x86_64-asmis explicitly enabled.