Skip to content

Bound random sampling domains and Paillier challenge widths - #15

Merged
piotr-roslaniec merged 4 commits into
devfrom
codex/sampling-bounds
Sep 29, 2026
Merged

piotr-roslaniec merged 4 commits into
devfrom
codex/sampling-bounds

Conversation

@mswilkison

@mswilkison mswilkison commented Sep 14, 2026 •

Copy link
Copy Markdown

Depends on #13: the safe-prime result handoff must observe cancellation before the newly accepted small parameter sizes are used. This PR is stacked on codex/helper-lifecycle.

Reject empty prime and unit sampling domains and structurally unsupported Paillier key sizes. Mask expanded GenerateXs candidates to the modulus width before rejection, and propagate empty sampler results through encryption, quadratic-residue generation, and direct MtA prover callers. The fixed-size Paillier proof constructor reports an invalid challenge domain with an explicit panic. The 18-bit structural floor is an implementation boundary, not a cryptographic security recommendation.

The 2048-bit challenge output is unchanged, checked against a digest of all 13 deterministic challenges captured from the unmodified base. Validation includes bounded parameter checks, modulus-width controls, full common and crypto tests, and ordinary 2048-bit Paillier/MtA tests with GOMAXPROCS=2 and go test -p 1. Formatting, diff checks, and independent patch review passed.

Source-level adaptation of public upstream dc9b957db02aa186e5e438cf9bd840c57e789008 and b64213a53a9a1f822c8dcdd9ad949cdfd27d6468.

Full test CI and formatting CI were dispatched for this branch because the automatic PR trigger only covers master.

mswilkison and others added 4 commits September 13, 2026 20:29
Adapt the common prime-size and unit-domain guards from public upstream
dc9b957.

Adapt the Paillier sampling changes from public upstream
b64213a to this base. Use an 18-bit
minimum for the local safe-prime candidate range and separation condition.
Propagate empty sampler results through direct callers while preserving
function signatures and the ordinary 2048-bit challenge output.

These are source-level adaptations, not cherry-picks. This base has no
quadratic-non-residue sampling helper, and its ModProof is outside the
scope of this change.

Add bounded domain checks, modulus-width controls, and a fixed 2048-bit
challenge digest captured from base 86bd1a3.
Resolve crypto/paillier/paillier.go Proof(): keep this branch's len(xs) !=
iters guard together with dev's #11/#17-compatible constant-time branches
(ExpCT/Exp behind common.IsConstantTimeEnabled()). The inverse M = N^-1 mod
PhiN stays on math/big (PhiN is even; bigmod requires an odd modulus).
crypto/mta/proofs.go and range_proof.go auto-merged: this branch's
beta/random-sampler nil guards and current CT exponent-width call sites are
preserved; dev dependency versions win.
Absorb #17/#23 constant-time defaults/bounds and signing-coverage changes from
advanced origin/dev. Preserve this branch's nil/sampling guards in
crypto/paillier/paillier.go and crypto/mta/proofs.go/range_proof.go; dev wins
on Go toolchain and dependency versions.
Absorb #12 input guards on top of #17/#23. Preserve this branch's
nil/sampling guards in crypto/paillier/paillier.go and crypto/mta;
dev wins on Go toolchain and dependency versions.
@piotr-roslaniec
piotr-roslaniec changed the base branch from codex/helper-lifecycle to dev September 29, 2026 14:56
@piotr-roslaniec
piotr-roslaniec merged commit a0b4c1f into dev Sep 29, 2026
2 checks passed
@piotr-roslaniec

Copy link
Copy Markdown

Merged into dev after integrating the final #13/dev head. The earlier paillier.go conflict kept both sides: #15's nil/length guards and the CT branches from #17/#23.

Verification:

  • CI Test and Go fmt green on final head.
  • Local tidy, build, vet, format green; focused new boundary/sampling tests green.
  • Distribution checks found no masking bias (chi-square p-values 0.17-0.78).
  • Deterministic 2048-bit challenge digest is byte-identical before/after.
  • Negative controls: GetRandomPositiveRelativelyPrimeInt(1) and non-256-multiple GenerateXs widths hung before this PR; the new guards/masking terminate and pass.
  • The fixed-size Proof panic is local-key-only and not wire-reachable in shipped GG18 paths.

One local broad regex run timed out while stochastic 2048-bit safe-prime generation was still in ProbablyPrime. Code tracing shows #15 does not change the 2048-bit generator/retry path (only rejects modulus sizes <18), and full CI completed the same test on this exact head. The timeout is therefore resource/stochastic prime generation, not a #15 logic regression.

Full report: agent-docs/pr-integration/15.md (local).

piotr-roslaniec added a commit that referenced this pull request Sep 29, 2026
Merge current origin/dev (includes #12/#13/#15) into PR #14.

Conflict choices:
- No textual conflicts; clean automatic merge.
- Go toolchain/deps, CT hardening, input guards and sampling-bounds
  changes kept from origin/dev.
- Preserved PR #14 changes on top of dev: BaseParty fatal-error latch
  (abort/abortedWith), keygen unmarshalVSSCommitment part-count guard,
  and all earlier integration changes.
piotr-roslaniec added a commit that referenced this pull request Sep 29, 2026
Bring PR #9 current with dev after #17/#23/#12/#13/#15/#14/#26 landed.

Conflicts resolved:
- CHANGELOG.md: retain dev's PR #17/#23 composing-PR entry alongside PR #9;
  keep the rollout-only historical Bob compatibility (8ae2cf8) risk text.
- crypto/mta/proofs.go: preserve #9 legacy vs security-v2 tau/gamma sampling
  branches; keep dev's #15 nil sampling guard on beta. P1 8ae2cf8 opt-in
  historical Bob compatibility (default tight maxT1, opt-in (q+1)*N bound)
  unchanged.
- crypto/schnorr/schnorr_proof.go: combine #9 legacy/v2 challenge API split
  with dev's #23 constant-time MulCT branch for t = a + c*x.
- ecdsa/keygen/round_3.go: keep #14 unmarshalVSSCommitment part-count guard
  and re-apply #9 mode-conditional round.proofContext(j) for FactorVerify.
- ecdsa/signing/round_ct_wiring_test.go: select ProtocolModeSecurityV2 +
  nonce for the CT wiring test that constructs local signing parties.

Auto-merged and preserved: dev toolchain (Go 1.25.7 / 1.26.8) and deps in
go.mod/go.sum, #17 CT default-on behavior and fixed public-width ExpCTWithBitLen
calls, #12 arity/input guards, #15 nil/bounds guards, #14 keygen changes, and
dev workflows/tests. No transcript mode or CT path was dropped.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants