fix(crypto): handle CT exponent bounds, zero values, and toggle changes - #10
Draft
mswilkison wants to merge 2 commits into
Draft
mswilkison wants to merge 2 commits into
mswilkison wants to merge 2 commits into
Conversation
This was referenced Sep 14, 2026
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.
Stacked on #8 (
constant-time-hardening) and kept as a draft alongside its parent. All review fixes are in this PR; #8 is unchanged.With CT enabled, a Paillier modulus wider than the auxiliary proof modulus could leave secret exponents encoded at their own byte length. Add
ExpCTWithBitLenso callers select a fixed width from a public bound. MtA usespk.Nfor Alice's plaintext and Bob's two witnesses; factor proofs use the prover's publicN0for both factors, independently of the verifier's modulus.ExpCTretains the modulus-byte-width default and now rejects oversized exponents instead of silently extending their encoding. Callers needing larger exponents must use the explicit public-width API. Negative exponents and insufficient bounds panic; exponents are never truncated or reduced.This also includes the earlier review fixes: zero exponents execute the padded
bigmod.Exppath, andModProofuses one CT-toggle snapshot for context allocation and every use of that context.Validation:
-count=3).TestExpCTtests pass with race detection.go vet ./common ./crypto/mta ./crypto/paillier, formatting, andgit diff --checkpass.make test_unitpasses on Go 1.24.1 for this stacked branch. Its inherited tree still contains EdDSA and resharing; EdDSA results were cached. Those protocols were removed frommasterby Remove unused EdDSA and resharing protocols #5. The feat(crypto): opt-in constant-time path for secret-exponent modexps [DO NOT MERGE] #8/fix(crypto): handle CT exponent bounds, zero values, and toggle changes #10 stack shares ancestor1b1da04with currentmasterand does not yet include that removal or the other subsequent master changes. This result validates the stack's present tree, not its eventual integration with currentmaster; integration and validation against currentmasterremain required before merging.cf15377f96bf8f3d522c6de7a626f4a13e6e3649.The guarantee addressed here is fixed public-width exponentiation work in
bigmod; the existing coverage limitations aroundmath/bigpreprocessing and operations outside the CT path remain.