Repository navigation
test(crypto): restore unequal-width MtA CT regression - #27
Merged
Merged
Conversation
Restore the closed #10 test-only regression that #17 dropped when backporting #10's functional fixes (finding 17-S1): TestShareProtocolUnequalWidthsCTEquivalence in crypto/mta/constant_time_equiv_test.go. The test byte-exactly compares the complete MtA share-protocol transcript (AliceInit -> BobMid/BobMidWC -> AliceEnd/AliceEndWC, incl. all proof bytes, homomorphic ciphertexts, and decrypted shares) with a fixed replayed entropy stream across constant-time ops off vs on. It guards the regression class where the CT path's secret-exponent modular arithmetic diverges from the math/big path in the full share protocol: an exponent padding width reintroduced from the auxiliary modulus instead of the public plaintext bound (pk.N.BitLen()), or any width change breaking CT-path determinism. Adapted to the current APIs and dev's hardened verifiers: - uses the keygen fixture's ~2048-bit auxiliary moduli (NTildei/h1i/h2i, NTildej/h1j/h2j) so the protocol's internal Verify calls complete, which is impossible with #10's tiny 11*23 modulus under dev's 2048-bit unknown-order-modulus verifier floor. - explicitly sets and restores the ambient CT mode per subtest via the same cleanup pattern as the sibling tests (the #23 withCTMode isolation pattern), and compares the consumer-visible transcript bytes, not just the absence of a panic. - replaces the #10 'witness wider than aux modulus' width assertion (sound only against the tiny NTilde) with exact guards: betaPrm is a valid Paillier plaintext, the homomorphic result does not wrap the domain, and the MtA shares sum to a*b mod q. No production code changes; no new dependencies; no timing assertions.
Author
|
Merged into Verification:
|
This was referenced Sep 29, 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.
Summary
Test-only PR that closes the one remaining test-only gap tracked from the #8/#10
supersession review (
agent-docs/pr-integration/8-10.md, finding 17-S1).#17 (
codex/ct-defaults-and-bounds) backported all of #10's functional fixes ontodev, but dropped #10's
TestShareProtocolUnequalWidthsCTEquivalenceinstead ofadapting it. That test is the only guard that byte-exact-compares the complete MtA
share protocol transcript (AliceInit → BobMid/BobMidWC → AliceEnd/AliceEndWC,
including all proof bytes, the homomorphic ciphertexts, and the decrypted shares)
across constant-time ops off vs on, with a q5-width
betaPrmsecret witness.Regression this test catches
A future change that makes the CT path's secret-exponent modular arithmetic diverge
from the math/big path anywhere in the full share-protocol path would make the CT-on
transcript stop matching the CT-off one and fail this test. Concretely:
the public plaintext bound (
pk.N.BitLen(), per fix(crypto): handle CT exponent bounds, zero values, and toggle changes #10'sExpCTWithBitLenfix), orh1^b,h1^betaPrmin
ProveBobWC,h1^minProveRangeAlice, plus the CTEncrypt/HomoMultpaths) that makes the two modes produce different bytes.
Without it, that regression class is uncaught in the full MtA path on dev.
Adaptation notes (dev vs #10)
unknown-order-modulus floor (
verifyMinModulusBitLen), so the full protocol'sinternal
Verifycalls cannot complete against fix(crypto): handle CT exponent bounds, zero values, and toggle changes #10's tiny11*23modulus. Thisadaptation uses the keygen fixture's ~2048-bit auxiliary moduli
(
NTildei/h1i/h2i,NTildej/h1j/h2jfromLoadNTildeH1H2FromTestFixture),matching the neighboring
TestShareProtocolWCConstantTime. ThebetaPrmwitnessremains a
q5-width random (up to five secp256k1 curve orders) exercised throughthe CT exponentiations with the
pk.N.BitLen()width bound.betaPrm.BitLen() > 8*len(NTilde.Bytes())+16assertion was sound only against the tiny modulus; with the 2048-bit fixture
modulus it would be false. It is replaced by exact guards:
betaPrmis a validPaillier plaintext (
betaPrm < pk.N), the homomorphic result does not wrap theplaintext domain, and the MtA shares sum to
a*b mod q.and restored on cleanup (same pattern as the sibling
setMTAProofTestModetests andfix(crypto): extend constant-time coverage to Schnorr proofs and signing rounds 3-5 #23's
withCTModeisolation), so the test does not leak state into other tests andworks under dev's default-on CT mode.
proof parts, ciphertexts, and shares), not merely that the protocol does not panic.
Scope
crypto/mta/constant_time_equiv_test.go).with Enable bounded bigmod operations by default #17; this PR restores only the dropped full-protocol test.
Supersedes finding 17-S1 from
agent-docs/pr-integration/8-10.md§5 ("Proposeddurable tests").