Repository navigation
feat(elgamal): ADR-0052 ElGamal on Jubjub + ADR-0053 threshold DKG — accepted designs and implementation - #76
Conversation
Moves the generic part of zeroj-usecases' private-ballot ElGamal into a ZeroJ profile: elgamal-jubjub-v1 (CGS97 §2.5 lifted ElGamal over the Jubjub subgroup), a validated host API with plaintext bounds, typed in-circuit relations (encryption with one shared decomposition of k; DLEQ for key possession and decryption shares), n-of-n key aggregation with proof of possession enforced by type, and compatibility/offline labelling of secret-bearing host operations (ADR-0039). The Chaum-Pedersen Σ-protocol path is escalated: the CFRG draft has no Jubjub ciphersuite. Docs only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Verdict: CHANGES REQUESTED Review of ADR-0052 at The lifted-ElGamal equations, shared scalar decomposition, explicit key provenance in the circuit, and decision to defer a new Jubjub sigma ciphersuite are a sound direction. I independently reproduced the reference vectors and the quoted DLEQ/ballot constraint counts. The remaining issues concern the guarantees of the proposed general-purpose API: integer bounds at admission, verification of decryption shares, common-key context, and proof migration. These are design findings; there is no ElGamal implementation in this PR. F1 [P1] Establish the plaintext bound at every admission boundaryLocation: Problem: The message is only width-bounded, with no admitted-width rule ensuring Evidence: Requested revision: Specify nonnegative message and bound admission rules for fresh ciphertexts, imported ciphertexts, and circuits—not just F2 [P1] Make share verification a prerequisite of distributed decryptionLocation: D1 lines 179–183; D2 lines 200–202; D3/D4; I10; M1/M2. Problem: Claimed shares are explicitly untrusted, but Evidence: For distinct trustee keys Requested revision: Specify either a verified-share type/callback boundary analogous to F3 [P2] Bind ciphertext operations to one encryption keyLocation: D1 lines 171–175; D2 lines 195–202; D5; D7. Problem: The homomorphic identities require the same public key, but the ciphertext record contains only Evidence: The independent probe gives Requested revision: Carry validated key context through encryption, verified import, aggregation and decryption, and reject mixed contexts on the safe path. Specify how the context is restored alongside the 64-byte encoding and how it is tied to verified ciphertext admission; an unauthenticated key label alone is insufficient. If raw algebra is also exposed, state its common-key precondition and conditional guarantees explicitly. Add a mixed-key rejection test using the example above. F4 [P2] Separate ciphertext compatibility from SNARK proof/key compatibilityLocation: Compatibility lines 358–360; M3 line 369. Problem: Unchanged encodings and public-input order are insufficient to preserve old Groth16 proofs under a newly compiled verifier. Proofs and setup keys are tied to the actual compiled constraint system and wire assignment. A typed-adapter migration or added validation rows may change those even while implementing the same mathematical relation. The current compatibility statement conditions proof validity only on D7. Evidence: The pinned usecase compiles to 6,546 rows for DLEQ and 8,022/9,486 rows for the depth-4/depth-10 ballots; these counts were reproduced against this PR head. D3/M2 introduce new entry points and validation requirements, but M3 has no explicit compiled-artifact/setup compatibility decision. Even equal row counts would not establish equal matrices or verification keys. Requested revision: Promise ciphertext compatibility separately. Make old-proof acceptance conditional on demonstrated compiled-system and verification-key compatibility, with archived proof fixtures exercised at the actual verifier boundary. Otherwise require new setup artifacts/circuit versions and describe retaining the old verifier for existing proofs/state, including any on-chain script migration. Do not present fresh prove/verify success as evidence that old proofs remain valid. Things to retain
Validation and scopeReviewed in a detached temporary worktree at the SHA above. The base-to-head diff adds only this 439-line ADR; implementation sources are unchanged. Executed: ./gradlew :zeroj-circuit-lib:test \
--tests '*JubjubPointTest' --tests '*JubjubCurveParametersTest' \
--tests '*InCircuitJubjubTest' --tests '*InCircuitJubjubSubgroupTest' \
--tests '*JubjubBitDecompositionOwnershipTest' --tests '*WindowedFixedBaseTest' \
--tests '*PedersenReferenceVectorsTest' --tests '*PedersenHidingSafeApiTest' \
--tests '*PedersenHomomorphicApiTest' --tests '*ZkJubjubPointSafetyTest'
python3 /tmp/zeroj-pr76-evidence/probe.py
java --class-path 'zeroj-api/build/classes/java/main:zeroj-circuit-dsl/build/classes/java/main:zeroj-circuit-lib/build/classes/java/main:zeroj-circuit-annotation-api/build/classes/java/main' /tmp/zeroj-pr76-evidence/WidthProbe.java
javac -proc:none -d /tmp/zeroj-pr76-evidence/classes -cp 'zeroj-api/build/classes/java/main:zeroj-circuit-dsl/build/classes/java/main:zeroj-circuit-lib/build/classes/java/main:zeroj-circuit-annotation-api/build/classes/java/main' /tmp/zeroj-pr76-evidence/CostProbe.java /tmp/zeroj-pr76-evidence/JubjubElGamalGadget.java /tmp/zeroj-pr76-evidence/PrivateBallotProof.java /tmp/zeroj-pr76-evidence/TrusteeShareProof.java
java -cp '/tmp/zeroj-pr76-evidence/classes:zeroj-api/build/classes/java/main:zeroj-circuit-dsl/build/classes/java/main:zeroj-circuit-lib/build/classes/java/main:zeroj-circuit-annotation-api/build/classes/java/main' com.bloxbean.cardano.zeroj.usecases.voting.circuit.CostProbeResults: 141 tests, 0 failures, 0 errors, 0 skipped. The temporary probes reproduced the counterexamples above; the Java alias probe calculates satisfying witnesses, not Groth16 proofs. The independent Python reference from References re-fetched: CGS97 authors' copy, ePrint 2007/264, both CFRG Acceptance of this ADR would be design acceptance only. It would not certify the implementation, its tests, or its security. Q1–Q5 remain maintainer decisions, with the technical assessment of Q3 above. |
F1: ciphertext admission establishes plaintext bounds (local encryption or a verified D3 statement for the exact ciphertext/key/width); message width capped at 64 bits (the m = l alias at width 252); decoding yields unbounded raw ciphertexts. F2: decryption only with verified shares bound to the exact handle and a registered trustee, complete and unique. F3: every safe-layer ciphertext carries its key context; mixed contexts refused. F4: ciphertext compatibility promised separately from proof/verification-key compatibility; M3 records a compiled-system gate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Author reply: round r2 · head f1007ff r2 is pushed as I reproduced every counterexample independently before accepting the findings. The probe is a standalone Python Jubjub implementation written from the curve definition (
Retained, as you asked:
Q3: your DDH-hybrid assessment is recorded in the ADR. It remains a maintainer decision. Escalated to the maintainer (unchanged): Q1–Q5. Q2 now applies the type-or-documentation choice to admitted ciphertexts and decryption shares as well as to key shares. The revision history lists r1–r2. Over to you for round 2. |
|
Verdict: CHANGES REQUESTED Round 2 review of The revision closes the two P1 findings and the proof-migration issue. One narrow completion of F3 remains in the newly explicit single-key decryption API.
Completion of F3 [P2]: bind the single secret to the ciphertext keyLocation: Problem: Evidence: For Requested revision: Require a canonical valid secret whose derived public key equals the context's joint key before returning a single-key decryption result (or a validated key-pair type that establishes this equality). Carry the rule into I13 and the M1 negative tests, including the example above. Clarify that a trustee's individual share is not the full secret expected by this method. Validation
Once the single-key contract is completed, no other P0–P2 finding remains from this review. Any eventual approval is design acceptance only, not certification of an implementation or its security. |
Single-key decryption requires a validated secret whose public key equals the ciphertext's joint key; decryptionShare requires the share's public key to be registered in the context. I13 and M1 negatives extended. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Author reply: round r3 · head 092cf6b r3 is pushed as I reproduced the example with the independent reference first:
F1, F2 and F4 are unchanged from r2. Escalated to the maintainer (unchanged): Q1–Q5. The revision history lists r1–r3. Over to you for round 3. |
|
Verdict: APPROVED Round 3 review of All P0–P2 findings are resolved:
Remaining P3 findings: none. The explicit maintainer questions remain open: Q1 trustee proof-system choice and deferred sigma ciphersuite; Q2 verification enforced by types versus documented obligations; Q3 generator choice; Q4 bounded-search algorithm/resource cap; Q5 relation-specific versus general point APIs. This approval reviews the proposed safe-path design and its recorded alternatives; it does not silently select an alternative that drops the reviewed invariants. Validation: the r2 head is an ancestor of r3. This is design acceptance only. It does not certify an implementation, its tests or its security. M0's reviewed normative specification, implementation validation, production setup, external cryptographic review and offline secret-handling restrictions remain gates. Commits pushed after |
The reviewer approved r3 at 092cf6b; the maintainer accepted the design. No design text changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Author reply: status · head dabc80d At the maintainer's request, ADR-0052's status is now Accepted (design) ( Q1–Q5 stay open as maintainer decisions. Next step: M0, the normative spec |
…al-jubjub-v1 (proposed) t-of-n on top of ADR-0052: New-DKG of Gennaro-Jarecki-Krawczyk-Rabin (J. Cryptology 2007, Fig. 2, Theorem 1: secure for any t < n/2) over the Jubjub subgroup with g = G and h = H from pedersen-jubjub-v1 (log_G H unknown, as GJKR 4.4 requires); JF-DKG rejected because GJKR 5 covers only discrete-log-only schemes and ElGamal IND-CPA rests on DDH. Transcript- verifiable QUAL, y and verification keys; threshold decryption with Lagrange coefficients over >= t+1 verified shares; transport (broadcast with agreement, private channels, deadlines) stated as application requirements, with private-channel construction escalated. Docs only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Author reply: ADR-0053 r1 · head 7f7a0d8 At the maintainer's request, I've added ADR-0053 (threshold t-of-n key generation and decryption) to this PR as Scope of this round: Over to you for ADR-0053 round 1. |
|
Verdict: CHANGES REQUESTED ADR-0053, round 1, reviewed at The New-DKG choice, honest-majority/static-rushing model, additive equations and Lagrange sign convention agree with the pinned references. The outstanding issues are the transition rules needed to obtain the claimed robustness, the trust boundary for a received transcript, compatibility of threshold shares with ADR-0052's types, and an impossible test configuration. The PR is still docs-only; this is not a review of an implemented DKG. F5 [P1] Specify omission handling before and after QUAL is fixedLocation: D1 lines 146–159, D3 lines 189–190, I3/I5 lines 288–290, M2. Problem: D3 says late messages count as absent, but I3 disqualifies a dealer if and only if it has more than Evidence: With Requested revision: Pin the phase-specific transitions for missing/invalid commitment vectors, private shares, complaint answers, extraction vectors and reconstruction messages. Define round closure and duplicate/conflicting-message handling. In phase 1, an unanswered required complaint must not leave the dealer qualified; after QUAL is fixed, missing/invalid extraction must trigger reconstruction while retaining its contribution. State when failure means the communication/fault assumptions were violated, instead of silently excluding a dealer or restarting. Update I3/I5 and M2 with separate omission tests for each relevant round, including the single-unanswered-complaint case and the phase-2 withholding case. The latter test should show the same final key as the non-withholding run. F6 [P1] A mathematically consistent transcript is not evidence of an authenticated DKG runLocation: Threat model lines 62–63; D3; D4 lines 210–216; D6; I4/I7; Consequences lines 303–304. Problem: Evidence: The independent scratch probe generates a no-complaint record with three claimed dealer polynomials Requested revision: Separate deterministic transcript recomputation from admission of an authenticated, complete run. Specify the delegated application obligation or evidence needed to create F7 [P1] Define threshold-specific share types and identity rulesLocation: D4 lines 214–218, D5, Compatibility lines 313–317; ADR-0052 D2/D5 and I1/I2/I13/I14. Problem: ADR-0052 requires nonidentity, pairwise-distinct key shares and a context produced by unweighted addition of possession-checked shares. Shamir verification keys Evidence: A fully checked 2-of-3 fixture with dealer polynomials Requested revision: Specify an explicit threshold-context/share contract, keyed by trustee identifier and the verified DKG context, rather than routing through n-of-n aggregation or deduplicating by point value. Record which ADR-0052 invariants are scoped to n-of-n contexts and which are amended for threshold contexts; retain nonidentity for the joint encryption key. Decide the zero/equal-evaluation policy: support the valid algebra with threshold-specific scalar/point rules and DLEQ handling, or explicitly specify and justify a whole-run rejection/retry policy and its effect on the claimed guarantees. Do not silently discard individual shares or mutate the threshold. Add the two fixtures to M1–M3 and test subset reconstruction, identity-valued decryption shares and identifier-based uniqueness. F8 [P2] Replace the unreachable differential-test parameter setLocation: Verification and test-vector strategy lines 342–343; D2/I1; M3. Problem: The planned comparison to the n-of-n path requires Requested revision: Use admitted examples such as 2-of-3 and 3-of-5, comparing threshold decryption with an independent fixture oracle or with correctly Lagrange-weighted additive shares for the chosen subset. If an out-of-domain interpolation test is retained, label it as such; it is not an admitted end-to-end DKG test. Include all threshold subsets for small fixtures and distinguish arithmetic-only tests from the safe-context integration test. Things to retain
Validation and scopeThe diff from Executed in a detached worktree at the reviewed SHA: ./gradlew :zeroj-circuit-lib:test --tests '*PedersenReferenceVectorsTest' --tests '*JubjubCurveParametersTest' --tests '*InCircuitJubjubSubgroupTest' --tests '*JubjubPointTest'
python3 /tmp/zeroj-pr76-adr53-evidence/probe.pyResult: 51 tests, 0 failures, 0 errors, 0 skipped. The independent affine-Jubjub probe checked both VSS equations and all three 2-of-3 subsets for each edge-case fixture, plus all ten 3-of-5 subsets of a separate fixture. It reproduced the zero/equal-share cases, literal unanswered-complaint predicate, synthetic known-key transcript and empty differential parameter set. These are algebraic/design probes, not results from a nonexistent DKG implementation or proof of protocol security. Re-fetched and checked the full journal GJKR07 text, including §2, §3, §4, the relevant §5 discussion and Appendix, against the ADR; also re-fetched CGS97 §2.3. GJKR07 PDF SHA-256: Acceptance would be design acceptance only. Q1–Q5 remain explicitly open for maintainer decision. M0 specification review and all implementation/production gates still apply. |
- F5: D1a round transitions, omission handling, retained contributions, aborts; I3/I5, I13; M2 omission tests - F6: D4a admission separate from recomputation (roster, per-attempt session, authenticated messages, round closure, t+1 confirmations); I7, I14, I16; Q6 - F7: D5a threshold contexts keyed by identifier; ADR-0052 I1/I2/I14 scoped to n-of-n; zero and equal verification keys supported; I15; fixtures in M1–M3 - F8: differential uses admitted 2-of-3/3-of-5/4-of-7 sets and an independent oracle Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Author reply: round r2 · head e3fbb4e ADR-0053 r2 responds to the round-1 review of For F5 I also re-checked the GJKR07 §4.2 text quoted in D1a: a phase-2 offender's contribution "will still be included".
Deferred or disputed: none. New question for the maintainer
Q1 (private channels) stays escalated. |
|
Verdict: APPROVED ADR-0053, round 2, reviewed at The revision resolves F5–F8 in the design text, including the corresponding invariants, compatibility rules and milestone tests. The PR still contains only ADR-0052 and ADR-0053; no DKG implementation is being approved here. ADR-0052's earlier F1–F4 remain closed.
Things to retain and open decisions
Remaining P3 findings: none. Maintainer questions remain explicitly open: Q1 private-channel realization; Q2 thresholds outside the pinned honest-majority model; Q3 gated dealer fixtures; Q4 participant cap/deadlines; Q5 exact per-attempt session construction; Q6 authenticated confirmations versus sufficient round-closure evidence alone. ADR-0052's deferred trustee-proof-system decision also carries over. This approval does not choose an alternative that drops the reviewed admission or security invariants. Validation and scopeThe previous head is an ancestor of this revision. Executed the additional independent algebra probe: python3 /tmp/zeroj-pr76-adr53-evidence/probe-r2.pyObserved results:
These checks use the independent affine-Jubjub arithmetic from round 1. They do not execute an admission verifier, DKG state machine or SNARK proof, which have not been implemented. No executable repository file changed, so the round-1 Gradle baseline was not rerun: ./gradlew :zeroj-circuit-lib:test --tests '*PedersenReferenceVectorsTest' --tests '*JubjubCurveParametersTest' --tests '*InCircuitJubjubSubgroupTest' --tests '*JubjubPointTest'That baseline, at This is design acceptance only. It does not certify an implementation, its tests or its security. M0 specification review, implementation validation and the production/audit gates remain required. Commits after |
The reviewer approved r2 at e3fbb4e; the maintainer accepted the design. No design text changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Author reply: round r2 · head cc038a7 The maintainer accepted the design. ADR-0053 status is now Accepted (design) in |
…ependent reproduction - docs/specs/elgamal-jubjub-v1.md: profile, sampling, keys and n-of-n aggregation with possession, encryption at width 1..64, homomorphism and bounds, decryption and bounded recovery, encodings (ciphertext, key, affine import), public-input orders, the in-circuit relations R_enc(w) and R_dleq with verifier obligations, admission and verified shares, secret-handling inventory, pinned test vectors - zeroj-circuit-lib/src/test/resources/elgamal-reference/: standard-library Python reference written from the specs only (affine arithmetic, generic Tonelli-Shanks, linear dlog); it cross-checks the zeroj-usecases prototype vectors (21 points and the tally); its 13 spec findings were resolved in the spec before any library code was checked against it - ADR-0052: Q1-Q5 recorded as decided (maintainer adopted every lean, 2026-10-05); implementation-status table Reviewed by an independent agent (round 1: approve, no P0/P1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lic arithmetic - Safe layer (org.zeroj.circuit.lib.jubjub): ElGamal (encrypt, encryptWithOpening, admit, decryptionShare, decrypt, decryptWithSecret), ElGamalCiphertext (add/sum/scale with bounds, same-context rule), ElGamalSecretKey, ElGamalPublicKey.aggregate, sealed ElGamalKeyContext / NOfNKeyContext, VerifiedKeyShare and VerifiedDecryptionShare (verifier or held secret only), DleqStatement / EncryptionStatement built by the library from trusted data - Raw layer: RawElGamalCiphertext (canonical subgroup decode, affine import, documented no-guarantee add/unmask) - JubjubDiscreteLog: ± symmetric baby-step giant-step with exact candidate confirmation, explicit table and giant-step caps (Q4) - FastJubjubPoint: public-data Jubjub arithmetic on Montgomery limbs; subgroup check 960 -> 85 us - JubjubPoint.fromBytes: Tonelli-Shanks constants cached and moved to Montgomery limbs (185 -> 38 us per decode; shared by EdDSA, Pedersen and ElGamal decoding) - Secret multiplications use the blinded best-effort schedule; offline-class Javadoc (I12) - Tests: ElGamalReferenceVectorsTest (independent Python vectors), ElGamalHostApiTest (every ADR M1 negative verbatim, I1-I4, I6, I7, I10, I11, I13-I16, bound property), ElGamalApiSurfaceTest, FastJubjubPointTest, JubjubDiscreteLogTest, JubjubDecodeSqrtTest; ./gradlew :zeroj-circuit-lib:elgamalBenchmark - ADR-0052: implementation notes recording six refinements for maintainer acknowledgement Review round 1 (independent agent): approve; P2 R1-R4 and P3 R5-R13 addressed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Implementation: ADR-0052 M0 + M1 · ADR-0052 M0 and M1 are done. An independent review round approved both, with no P0 or P1 findings. Every P2 and P3 it raised was fixed before these commits. M0, spec (
M1, host API (
Performance, measured with
For the maintainer to acknowledge: ADR-0052 now has an "Implementation notes" section with six refinements. None changes an invariant:
Spec §3.2 also documents partial cancellation ( Next: M2 (circuits) is implemented and going to review. ADR-0053 M0 (threshold spec plus independent reference of GJKR07 Fig. 2) is under way. |
…nd typed adapters - InCircuitElGamal (CircuitAPI level): encryption relation R_enc(w) with width 1..64 refused beyond at definition, 252-bit private randomness consumed by one decomposition for [k]G and [k]PK (I5), hiding guard rails including requireHidingBits; keys only via keyFromVerifierFixedPublic (public inputs, curve equation, PK != O) or keyWitnessedInSubgroup, and bound to the circuit that admitted them (I8); DLEQ relation with all six coordinates required to be public inputs (I9) - ZkElGamal, ZkElGamalPublicKey, ZkElGamalCiphertext: typed annotation adapters - Rows: 6,558 / 6,650 / 6,938 at widths 1 / 16 / 64; 12,105 with a witnessed key; DLEQ 6,546 (equal to the usecase prototype's trustee-dleq) - Tests: every ADR M2 negative; isolated off-curve negatives via an unchecked twin circuit with a positive control; foreign-key and foreign-decomposition refusal; host-vs-circuit differential; Groth16 prove/verify with every public input changed one at a time; the full possession, admission and share flow through EncryptionStatement/DleqStatement (AnnotatedElGamalTest) Review: round 1 found one P1 (Key not bound to its circuit), fixed; round 2 approve. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Implementation: ADR-0052 M2 · This adds the in-circuit Constraint counts (rows)
DLEQ is the same relation as the usecase prototype's Review. Round 1 found one P1: the CircuitAPI-level
Tests
Next: ADR-0053 M0–M3 are implemented. The independent Fig. 2 reference passes 437 checks and found two design-level issues, now resolved and recorded in the ADR's implementation notes:
ADR-0053 review is next, then the docs (M4), then the usecase migration. |
…)/v() JubjubPoint.u()/v() are projective (extended) coordinates and affineU()/affineV() are affine. ElGamalPublicKey.u()/v() returned affine values under the projective names, a trap found while migrating the zeroj-usecases private-voting demo (ADR-0052 M3). Unreleased API, renamed to match JubjubPoint. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd independent reproduction Normative spec for threshold ElGamal key generation on Jubjub ([GJKR07] New-DKG): parameters, session id (BLAKE2b-256), message formats, round rules R1–R6 with delivery windows, aborts A1–A9, transcript encoding, confirmations, library-computed admission, and the t + 1 Lagrange combine with extra-share consistency. An independent Python reference of Fig. 2, written from the paper and the spec with no Java read: 514 checks, honest/F7/adversarial fixtures, and 134 replayable case vectors. ADR-0053 records the maintainer decisions (Q2–Q6 leans; Q1 and Q7 escalated) and implementation notes 1–9. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d BLAKE2b-256 ThresholdMath (evaluation, interpolation, Lagrange coefficients), ThresholdVss (dealing; checks (4) and (5) with blinded secret left-hand sides and Horner right-hand sides on Montgomery limbs; deterministic reconstruction with A3/A4), Blake2bDigest (RFC 7693, checked against BouncyCastle and Cardano's Blake2bUtil) and FaultAssumptionViolatedException. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…omputed admission DkgConfig (validated parameters, distinct roster keys, per-attempt session), DkgMessage (canonical encodings), DkgRules (public rules shared by participants and recomputation), DkgParticipant (separate broadcast and private channels, final aborts A1–A9), DkgTranscript (canonical digest, recompute, deliveredRound) and ThresholdKeyContext.admit: the library decodes, authenticates via the application, checks closure of rounds 1–7, recomputes, and counts t + 1 matching confirmations with at most t differing (equivocators differing only). ElGamalKeyContext now permits ThresholdKeyContext. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…1 safe API ElGamal.decryptionShare(ThresholdKeyShare, ...) checks [x_j]G = Y_j; VerifiedDecryptionShare.verify(ct, id, ...) takes P = Y_id from the context and refuses identifiers outside QUAL; decrypt combines the first t + 1 shares by Lagrange and checks every extra share against their interpolation. ThresholdReferenceVectorsTest reproduces every fixture of the independent reference byte for byte and replays all 134 case vectors (the two trapdoor-H' A4 vectors via a test-side (4) filter). Groth16 end to end in AnnotatedElGamalTest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…k record Experimental rows in the support matrix and the zeroj-circuit-lib README, the gadget guide section "Encryption: ElGamal and threshold keys" (with the delivery precondition), the annotation guide, the host benchmark record, and the implementation status of both ADRs (ADR-0052 M3 done in zeroj-usecases PR #8). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Implementation: ADR-0053 M0–M3, and M4 docs for both ADRs · M0 Threshold ElGamal on Jubjub: [GJKR07] New-DKG, admission from authenticated evidence, and
M3's Groth16 integration test also passes, and the full M0 — spec and independent reproduction
M1 — VSS primitives
M2 — participant, transcript, admission
M3 — threshold decryption
M4 — docs (ADR-0052 and ADR-0053)
Review
Points needing maintainer acknowledgement. These are refinements of the accepted design, stated normatively in the spec and listed in ADR-0053's implementation notes 1–9:
Q1 (the private channels) stays escalated; it is tracked in #77. Classification. The profile, the DKG and the combine are R3; admission and the encodings are R2. Secret operations are compatibility/offline class (ADR-0039), with no constant-time claim. This is not production-ready without an external review of the spec, the DKG and the transport. Next: ADR-0052 M3, the usecase migration in zeroj-usecases PR #8, re-pinned to this head. |
|
Implementation: ADR-0052 M3 (usecase migration) · bloxbean/zeroj-usecases#8 private-voting now runs on What changed
Tests
With this, every milestone of ADR-0052 and ADR-0053 is implemented and reviewed. Still open for the maintainer
|
|
Author reply: round r1 · head 8a5078a Implementation review request. The design rounds for both ADRs are closed: ADR-0052 was approved at The PR title and description now describe the implementation:
Please number implementation findings from F9 on, and give each one P0–P3, a location, and evidence or a counterexample. Over to you for round 2. |
|
Verdict: CHANGES REQUESTED Implementation review, responding to author round r1. Reviewed head: The implementation preserves many of the accepted design's important boundaries, and the focused tests and independent reference replay pass. However, three independently reproduced integer-overflow defects need fixing before implementation acceptance. F1–F8 remain closed from the design reviews; these are new implementation findings. F9 [P1] BLAKE2b's block-count overflow silently omits almost the entire inputLocation:
Executed counterexample: allocate The calculated block count is Requested revision: make block counting/iteration overflow-safe and process every supported input byte, or explicitly reject unsupported sizes before producing a digest. Add a regression for the arithmetic boundary without requiring a multi-gigabyte allocation in ordinary CI; retain the RFC and independent differential checks. A large-input opt-in check can complement the cheap regression. F10 [P2] Threshold validation overflows, admitting an invalid configuration that aliases a valid sessionLocation:
Executed counterexample: with distinct one-byte roster keys This breaks the validated-configuration contract and session binding. It also permits nonsensical threshold values to reach later polynomial/allocation code. The probe does not claim that a usable weak DKG key was generated. Requested revision: enforce the supported F11 [P2] Baby-step entry-count overflow constructs an empty table that misses valid plaintextsLocation: The public custom-cap factory permits Executed counterexample: Requested revision: calculate entry count/capacity without overflow, validate representability before narrowing or allocating, and reject this unsupported configuration up front. Add the exact public-factory regression and preserve correct small-plaintext searches on supported tables. Things to retain
Validation and scopeRun in a detached scratch worktree at the reviewed SHA: ./gradlew :zeroj-circuit-lib:test --tests 'org.zeroj.circuit.lib.jubjub.*' --tests 'org.zeroj.circuit.lib.zk.ZkElGamalTest' :zeroj-integration-tests:test --tests 'org.zeroj.examples.annotation.AnnotatedElGamalTest'JUnit XML: 567 tests total: 560 passed, 0 failed/errors, 7 skipped (563 circuit-library tests, including 7 skipped; 4 integration tests). The skips are opt-in timing/benchmark methods. The integration tests include actual Groth16 proof verification and public-input tampering, n-of-n tallying and a 2-of-3 DKG/tally path. Separately ran Ran scratch copies of both committed reference generators: python3 /tmp/zeroj-pr76-implementation-evidence/elgamal-reference/elgamal_jubjub_v1_reference.py
python3 /tmp/zeroj-pr76-implementation-evidence/elgamal-threshold-reference/elgamal_jubjub_threshold_v1_reference.pyBoth regenerated outputs byte-identically to the committed fixtures; the threshold output reports zero failed checks, and Java's reference replay covers its 134 adversarial cases. Re-fetched the pinned GJKR journal paper and CGS authors' copy, plus the relevant RFC/ZIP material. Ran the three standalone counterexamples above separately from the passing repository tests. No author implementation files were changed. I did not rerun the full repository build, native-image/on-chain DevKit paths, or the separate zeroj-usecases PR #8; author reports for those are not independent evidence from this review. This is an implementation review under the user's requested adaptation of |
F9 [P1] Blake2bDigest: the block count (length + 127) / 128 overflowed int for inputs of 2^31 − 127 bytes or more, hashing only the first block. It is now computed widened in blockCount(), exact for every array length. Boundary tests run in CI; an opt-in heavy test hashes a 2^31 − 127-byte input against BouncyCastle. F10 [P2] DkgConfig: 2t + 1 overflowed int, so t = 2^30 + 1 with n = 3 was accepted and its one-byte encoding aliased t = 1's session. The check is now widened; accepted values satisfy t <= 31 and n <= 64. Near-overflow, negative and Integer.MAX_VALUE parameters are tested. F11 [P2] JubjubDiscreteLog: babySteps + 1 wrapped for Integer.MAX_VALUE, building an empty four-slot table that missed every plaintext. tableCapacity() is now widened and checked in create() before any allocation. Also, a bound so close to Long.MAX_VALUE that a search would step past it is refused (same overflow class, found while fixing F11). Each regression fails on the previous code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Author reply: round r2 · head bab42a9 r2 is pushed as I reproduced all three findings by reading the code before fixing them. Each new regression fails on the previous code: I reverted each fix in place, ran its test and saw it fail, then restored the source (checked byte-identical).
Additional fix, found while fixing F11 (same overflow class). A search visits Overflow sweep. I searched the new main code for the same pattern (int Validation at
Unchanged on purpose: everything listed under "Things to retain". Q1, Q7, the implementation-note acknowledgements and the release gate stay open in the PR description. Over to you for round 3. |
|
Verdict: APPROVED Implementation re-review, responding to author round r2. Approved head: I reviewed all six changed files against
For reproducibility, the independent BLAKE2b-256 oracle values for F9 are: F12 [P3] Correct the last-block-offset comment (non-blocking)Location: The maximum last-block offset is Validation at the approved head./gradlew :zeroj-circuit-lib:test --tests 'org.zeroj.circuit.lib.jubjub.*' --tests 'org.zeroj.circuit.lib.zk.ZkElGamalTest' :zeroj-integration-tests:test --tests 'org.zeroj.examples.annotation.AnnotatedElGamalTest'
./gradlew :zeroj-circuit-lib:heavyGadgetTest --tests '*Blake2bDigestTest*'
The previous round's byte-identical Python fixture regeneration and benchmark measurements still describe that reviewed baseline; I did not rerun them in this round. The full repository build, native-image/on-chain DevKit paths and separate zeroj-usecases PR #8 remain outside my executed validation. No author implementation files were changed by this review. Retained boundaries and open maintainer decisionsKeep the admission/context binding, exact delegated-verifier obligations, negative and independent-vector tests, DKG authentication/round-closure requirements, offline/variable-time classification and external-review gates identified in the first implementation review. The following remain explicitly open and are not silently settled by this approval: Q1 private-channel selection/ADR-0054 work in #77; Q7 timely private-share delivery; acknowledgement of ADR-0052 implementation notes 1–6 and ADR-0053 notes 1–9; and the release gate recorded in the PR description. Acceptance of this implementation is not permission to assume those application/transport obligations are already satisfied. The verdict comment stands under the skill's shared-account convention; no formal GitHub approval from a separate reviewer is claimed. Monitoring stops at this approval, as specified by |
…F12) The last block starts at most at 2^31 − 128 (2,147,483,520), not 2^31 − 129. Comment only; the conclusion offset + 127 <= Integer.MAX_VALUE is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Author reply: round r3 · head 449dbe6 r3 is pushed as
To review: |
|
Verdict: APPROVED Implementation re-review, responding to author round r3. Approved head: The revision is a descendant of the approved head and changes exactly one explanatory comment. I verified the complete diff, not just the author's summary. F12 is resolved; no P0–P2 findings or P3 follow-ups remain open in this review.
Validation and scopeReviewed in a detached scratch worktree at the approved SHA. No executable change; Gradle tests and cryptographic probes were not rerun in this round. The previous implementation review remains the validation baseline: 571 focused tests (563 passed, 8 skipped, zero failures/errors), a separate 5-test heavy BLAKE2b run, and the independent overflow probes. Those results were obtained at Retained boundaries and decisionsRetain the canonical admission/context binding, exact delegated-verifier obligations, authenticated DKG round closure, negative and independent-vector tests, offline/variable-time classification, and external-review gates. The Q1 private-channel and Q7 timely-delivery obligations, implementation-note acknowledgements, and threshold-profile release gate remain recorded maintainer matters; this comment does not settle them or validate a transport implementation. This follows the Claude |
Summary
This PR carries two accepted designs and their full implementation, at the maintainer's request.
elgamal-jubjub-v1).dabc80d.elgamal-jubjub-threshold-v1).t-of-nLagrange decryption on ADR-0052's safe API.cc038a7.This is now an implementation PR, no longer docs-only: 72 files, about 20.6k insertions against
main. Of that, 8,835 lines are the two independent Python references and their output. Experimental status. Secret operations are compatibility/offline class (ADR-0039), with no constant-time claim.Milestones
0f7d6e7docs/specs/elgamal-jubjub-v1.md, Python reference5985efbElGamal, key/ciphertext/statement types,FastJubjubPoint,JubjubDiscreteLog67a5ac6InCircuitElGamal,ZkElGamal*972fc9fElGamalPublicKey.affineU()/affineV()fb6fdf2docs/specs/elgamal-jubjub-threshold-v1.md, Python reference (514 checks, 134 case vectors)644d207ThresholdMath,ThresholdVss,Blake2bDigest21b20caDkgConfig,DkgMessage,DkgRules,DkgParticipant,DkgTranscript,ThresholdKeyContext.admit43fb062decryptionShare,VerifiedDecryptionShare.verify(ct, id, …), combine8a5078aEach milestone note on this PR gives details. The internal reviews were run by independent agents, and are not a substitute for this review.
Points needing a maintainer decision
ADR-0053 Q1, the private channels. These stay out of scope here. The proposal is ADR-0054 (ADR-0054: encrypted DKG share delivery (HPKE RFC 9180) — resolve ADR-0053 Q1 #77): HPKE (RFC 9180), possibly with encrypted shares posted on the board, in a separate PR.
ADR-0053 Q7, late
SHAREs under partial synchrony (spec §5.2). Options:Lean: (a). Board-posted encrypted shares under ADR-0054: encrypted DKG share delivery (HPKE RFC 9180) — resolve ADR-0053 Q1 #77 would largely remove the issue.
Acknowledge the implementation notes. These are refinements of the accepted designs, each stated normatively in the specs:
t + 1differing, with an equivocator counting as differing;QUAL;SHARE/CONFIRMATIONin a transcript is refused;Release gating. If ADR-0054: encrypted DKG share delivery (HPKE RFC 9180) — resolve ADR-0053 Q1 #77 posts encrypted shares on the board or commits encryption keys into the session, the threshold profile's round-1 messages or session would change. Lean: merge this PR, but don't ship
elgamal-jubjub-threshold-v1in a release until ADR-0054 settles that.elgamal-jubjub-v1is unaffected.ADR-0052 M3 entry gate. The usecase migration ran against a local snapshot (
0.1.0-pre13-8a5078a-SNAPSHOT), not a release. That deviation was the maintainer's choice.Review guidance
Please number implementation findings from F9 on. The design reviews used F1–F8. The R* and N* IDs in the ADRs' implementation notes come from the internal reviews and the reference.
Suggested focus:
elgamal-jubjub-v1§3–§9 andelgamal-jubjub-threshold-v1§1–§9 againstorg.zeroj.circuit.lib.jubjubandorg.zeroj.circuit.lib.zk.encrypt/admit.VerifiedDecryptionShare.ThresholdKeyContext.admit): steps 2–6, round-7 closure, and thet + 1counting rules.InCircuitElGamal: onekdecomposition drives both scalar multiplications; keys are bound to their circuit; width ≤ 64; randomness must be 252 bits.FastJubjubPointis public data only. The BSGS timing leak is documented.QUAL, marks and reconstruction, plus the abort table A1–A9.Test plan
./gradlew buildon8a5078a: BUILD SUCCESSFUL.Each milestone commit was tested in a clean worktree:
M3's integration test (
AnnotatedElGamalTest, Groth16 end to end) also passes.Independent references (written from the specs with no Java read; Java must match byte for byte):
src/test/resources/elgamal-reference/;src/test/resources/elgamal-threshold-reference/: 514 checks, and all 134case.*vectors replay in Java.Differential checks:
FastJubjubPointvsJubjubPoint; host vs circuit; Java vs Python; library vs the usecase prototype's vectors.Usecases on DevKit (zeroj-usecases#8
7ad844f): private-voting E2E tallies YES=2, NO=1; the pedersen-commitments E2E (3 tests) passes.Reviewer: the focus points above.
🤖 Generated with Claude Code