Use dedicated squaring for public powers and fixed-base windows - #333
Merged
Conversation
Contributor
Author
|
ValarDragon
force-pushed
the
agent/vartime-prover-local-phases-20260903
branch
from
September 3, 2026 17:06
f9db992 to
47cf57d
Compare
ValarDragon
marked this pull request as ready for review
September 3, 2026 17:19
|
Note Complete: Audit complete. V12 did not find any issues that need review. Open the full results here. Analyzed nine files, diff |
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
x^(2^k)used by Halo2 proof creation andverification with Pasta's dedicated repeated-squaring routines;
invoking constant-time exponentiation.
Proof bytes, transcripts, constraints, verifying keys, and generated fixed-base
tables are unchanged.
Repeated squaring
The prover and verifier need
x^n, where the evaluation domain size isn = 2^k. Calling generic constant-time exponentiation processes the completeexponent representation. This change instead performs exactly
ksquarings,using Pasta's dedicated fused repeated-squaring implementation for
FpandFqand a generic repeated-squarefallback for other fields.The same bridge replaces a five-exponent constant-time power used to construct
Orchard's public
2^245circuit constant with two squarings and onemultiplication.
Fixed-base preprocessing
The generic Halo2 fixed-base table generator previously recomputed
8^wforevery window and each term of its final offset. It now advances a shared public
window scale and offset by multiplication with 8.
Orchard overrides the generic coefficient generator with checked-in precomputed
coefficient arrays. The fixed-base change therefore applies to the generic
Halo2 utility and must not be interpreted as an Orchard key-generation
speedup.
Isolated performance
Candidate is
47cf57d; values are medians from Criterion runs with 50 samples,2 s warm-up, and 4 s measurement.
Fp/ Apple M4Fq/ Apple M4Fp/ Linux x86_64Fq/ Linux x86_64For an 85-window full-width fixed-base table, the old implementation invoked
constant-time exponentiation 764 times: 672 times for the first 84 windows,
84 times for the final offset, and eight times for the final window. The new
implementation replaces those calls with 84 window-scale and 84 offset
multiplications. Scalar multiplication and interpolation work common to both
implementations is unchanged.
The repeated-squaring change saves about 7.0 us per call on M4 and 11.8 us per
call on Linux. It occurs once per proof and once per verification, so no
measurable complete-prover movement is claimed.
Validation
FpandFqsquaring bridges match repeatedField::squareforcounts 0, 1, 2, 11, and 64;
CommitIvkcircuit test passes;The identical fixed-base implementation also passed the complete randomized
coefficient suite on the superseded draft before this diff was narrowed.
API
This adds two doc-hidden public cross-crate bridge functions,
pasta_curves::arithmetic::{square_fp_n, square_fq_n}. Nopub(crate)surfaceis added or widened, and no existing signature or visibility changes.