Specialize the constant-time Fp point formulas by curve shape (a=-3, a=0) - #183
Merged
Conversation
…a=0) Replace the generic-a RCB2016 complete addition/doubling formulas in the constant-time Fp scalar-multiplication point layer with curve-shape specialized variants, selected per curve on a public parameter, cutting the wasted mul-by-a work that dominated the doubling-heavy hot path: - a=-3 (NIST secp256r1/384r1/521r1): RCB2016 Algorithm 4 (add) + Algorithm 6 (double) - drop the per-op MulByA (3 modular adds, applied 3x) in favour of mul-by-3b. - a=0 (secp256k1): RCB2016 Algorithm 7 (add) + Algorithm 9 (double) - drop the MulByA terms entirely (doubling falls from 13 to 9 field-muls). A new TCTACoeff selector (General/MinusThree/Zero) dispatches the formula set per curve on public curve data (constant-time safe); curves without a specialization keep the general Algorithm 1/3 formulas unchanged. The new bodies are straight-line field ops with no secret-dependent branch or index, and remain complete (identity/exceptional inputs handled). Also trim SelectEntry: read masked table entries straight from the table, bounded to the live N limbs, instead of copying the full max-width point struct per scanned entry.
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.
Replace the generic-a RCB2016 complete addition/doubling formulas in the constant-time Fp scalar-multiplication point layer with curve-shape specialized variants, selected per curve on a public parameter, cutting the wasted mul-by-a work that dominated the doubling-heavy hot path:
A new TCTACoeff selector (General/MinusThree/Zero) dispatches the formula set per curve on public curve data (constant-time safe); curves without a specialization keep the general Algorithm 1/3 formulas unchanged. The new bodies are straight-line field ops with no secret-dependent branch or index, and remain complete (identity/exceptional inputs handled).
Also trim SelectEntry: read masked table entries straight from the table, bounded to the live N limbs, instead of copying the full max-width point struct per scanned entry.