Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
9fe1c11
docs(adr): ADR-0052 exponential ElGamal on Jubjub (proposed)
satran004 Oct 5, 2026
f1007ff
docs(adr): ADR-0052 r2 — address review round 1 (F1–F4)
satran004 Oct 5, 2026
092cf6b
docs(adr): ADR-0052 r3 — address review round 2 (F3 completion)
satran004 Oct 5, 2026
dabc80d
docs(adr): ADR-0052 status Accepted (design)
satran004 Oct 5, 2026
7f7a0d8
docs(adr): ADR-0053 threshold key generation and decryption for elgam…
satran004 Oct 5, 2026
e3fbb4e
docs(adr): ADR-0053 r2 — address review round 1 (F5–F8)
satran004 Oct 5, 2026
cc038a7
docs(adr): ADR-0053 status Accepted (design)
satran004 Oct 5, 2026
0f7d6e7
feat(elgamal): ADR-0052 M0 — normative elgamal-jubjub-v1 spec and ind…
satran004 Oct 5, 2026
5985efb
feat(elgamal): ADR-0052 M1 — elgamal-jubjub-v1 host API with fast pub…
satran004 Oct 5, 2026
67a5ac6
feat(elgamal): ADR-0052 M2 — in-circuit elgamal-jubjub-v1 relations a…
satran004 Oct 5, 2026
972fc9f
refactor(elgamal): ElGamalPublicKey.affineU()/affineV() instead of u(…
satran004 Oct 5, 2026
fb6fdf2
feat(dkg): ADR-0053 M0 — normative elgamal-jubjub-threshold-v1 spec a…
satran004 Oct 5, 2026
644d207
feat(dkg): ADR-0053 M1 — Pedersen/Feldman VSS primitives, Lagrange an…
satran004 Oct 5, 2026
21b20ca
feat(dkg): ADR-0053 M2 — GJKR07 participant, transcript and library-c…
satran004 Oct 5, 2026
43fb062
feat(dkg): ADR-0053 M3 — threshold decryption on the elgamal-jubjub-v…
satran004 Oct 5, 2026
8a5078a
docs(elgamal): ADR-0052/0053 M4 — support matrix, guides and benchmar…
satran004 Oct 5, 2026
bab42a9
fix(elgamal): implementation review round 2 — integer overflows (F9–F11)
satran004 Oct 5, 2026
449dbe6
docs(elgamal): correct the BLAKE2b last-block offset comment (review …
satran004 Oct 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
649 changes: 649 additions & 0 deletions docs/adr/0052-exponential-elgamal-jubjub.md

Large diffs are not rendered by default.

614 changes: 614 additions & 0 deletions docs/adr/0053-threshold-elgamal-jubjub-dkg.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions docs/adr/circuit-annotation/cardano-gadget-support-matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ Relevant source:
| `ZkPedersen` | Symbolic Jubjub Pedersen commitment adapter | Requires BLS12-381 scalar field | Direct | Yes, pending external review | Asserts both scalars `< l` through the sound range-constrained comparator, and reuses owned decompositions at each scalar's declared width. The blinding must be declared at exactly 252 bits and must not be a public input or constant (ADR-0051 D2). Complete commitment with both coordinates bound as public inputs: 2,410 rows (64-bit value) / 4,042 rows (252-bit value); a value narrower than 252 bits is canonical by its own range, so only a full-width value carries the comparator. Spec: `docs/specs/pedersen-jubjub-v1.md`. |
| `ZkPedersenCommitment`, `ZkPedersen.assertBalanced` | Typed in-circuit commitments with origin tracking; no-wraparound balance helper (ADR-0051 D3/D3a) | Requires BLS12-381 scalar field | Direct | Experimental, pending review and external review | Unopened external commitments enter only through `witnessInSubgroup` (in-circuit subgroup proof, 5,547 rows) or `fromVerifierCheckedPublic` (public coordinates; the verifier runs `PedersenCommitment.decode`). `assertBalanced` refuses, at definition time, any side whose maximum `Σ coefficient·(2^width − 1)` reaches `l`, then asserts the integer relation on committed values. |
| `ZkPedersenVector`, `InCircuitPedersenVector`, `PedersenVectorCommitment` | `pedersen-jubjub-vector-v1`: commitment to up to 16 values (ADR-0051 D5) | Requires BLS12-381 scalar field | Direct | Experimental, pending spec review and external review | Bases from Zcash `FindGroupHash` (`ZeroJ_PV`), pinned and checked against Zcash known answers. The point binds neither length nor schema: every proof binds a public schema digest (`bindSchema`) checked against `PedersenSchemaRegistry`, and received commitments need an authenticated issuance record. 2,411 / 3,581 / 8,261 rows at n = 1 / 4 / 16 (64-bit values). |
| `InCircuitElGamal`, `ZkElGamal` | `elgamal-jubjub-v1` encryption relation and DLEQ trustee relation (ADR-0052 D3) | Requires BLS12-381 scalar field | Direct | Experimental, pending review and external review | Message width 1–64; 252-bit private randomness consumed by one decomposition; keys via `fromVerifierFixedPublic` (verifier checks subgroup) or `witnessInSubgroup`, identity refused; DLEQ needs all six coordinates public and `X ∈ 𝔾` as a verifier precondition. 6,558 / 6,938 rows (width 1 / 64); DLEQ 6,546. Spec: `docs/specs/elgamal-jubjub-v1.md`. |
| `ElGamal` host API; `DkgParticipant`, `ThresholdKeyContext` | Admission, bounds, verified shares; t-of-n key generation and decryption (ADR-0052, ADR-0053) | Jubjub over BLS12-381 scalar field | Not a circuit gadget | Experimental; **offline/isolated secret operations only** | Secret multiplications use the blinded best-effort schedule (no constant-time claim). The DKG's transport (broadcast with agreement, private channels, deadlines) and the admission verifier's authenticity/closure checks are the application's. Spec: `docs/specs/elgamal-jubjub-threshold-v1.md`. |
| `PedersenCommitment.commit` (off-circuit) | Host-side commitment generation | Jubjub over BLS12-381 scalar field | Not a circuit gadget | **Offline/isolated generation only (ADR-0038)** | Both secret scalars use a fresh multiple-of-`l` blinding and fixed 316-add/316-double schedule. The former loop-bound/operation-count channel is removed and the raw trailing-zero signal is blinded, but Java branches and `BigInteger` remain variable-time. The commitment's hiding and binding are unaffected; the restriction is on secret-bearing execution. |
| `InCircuitEdDSAJubjub` / `ZkEdDSAJubjub` | EdDSA-Jubjub verification | Requires BLS12-381 scalar field | Direct | Yes for verification, pending external review; signing is not constant-time | Use `verifyStrict` when `pk` is prover-supplied, `verifyWithRegisteredKey` when it is a public input or constant. No unqualified `verify`. Spec: `docs/specs/jubjub-eddsa-v1.md`. |
| `zeroj-bls12381` | BLS12-381 field, G1/G2, pairing, hash-to-curve | BLS12-381 | Not a circuit gadget | Supports off-chain proof verification and conversion paths; Cardano has BLS builtins | Use for proof systems and BBS, not directly inside symbolic circuits unless a circuit gadget is built. |
Expand Down
72 changes: 72 additions & 0 deletions docs/benchmarks/elgamal-jubjub-2026-10-05.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# ElGamal on Jubjub and threshold key generation — host measurements (ADR-0052, ADR-0053)

**Date:** 2026-10-05
**Harness:** `ElGamalBenchmark`, run in its own JVM with
`./gradlew :zeroj-circuit-lib:elgamalBenchmark`.
**Machine:** Apple M4 Max (arm64, 16 processors), macOS, Java 25.0.2, 2 GB max heap.

These numbers are evidence for this JVM and CPU only. They record throughput and make no
timing-side-channel claim. Secret operations are compatibility/offline class (ADR-0039).

## Host operations

| Operation | µs/op |
|---|---:|
| Point decode (`JubjubPoint.fromBytes`, no subgroup check) | 38 (185 before the Tonelli–Shanks change) |
| Subgroup check, `BigInteger` (`JubjubPoint.isInSubgroup`) | 960 |
| Subgroup check, Montgomery fast path (public data) | 85 |
| Ciphertext decode (64 bytes, two subgroup checks) | 221 (523 before) |
| Encrypt (three blinded secret multiplications) | 4,700 |
| Decryption share (one blinded secret multiplication) | 1,650 |
| Homomorphic sum, per ciphertext (2,000-term `sum`) | 1.6 |

The secret multiplications use the fixed 316-iteration blinded schedule of ADR-0038. They
dominate encryption and share computation, which are client-side and once per ballot or tally.
Public-data work (decoding, subgroup checks, sums, verification equations, search) runs on
Montgomery limbs.

## Bounded discrete log (baby-step giant-step)

| Bound | Table build | Solve, random `t` | Solve, `t = bound` (worst case) |
|---|---:|---:|---:|
| `2^16` | 0.3 ms | 0.2 ms | 0.2 ms |
| `2^24` | 1.6 ms | 1.8 ms | 1.6 ms |
| `2^32` | 21 ms | 7 ms | 19 ms |
| `2^40` | 108 ms | 551 ms | 819–904 ms |

The default caps (`2^18` baby steps, about 6 MiB of table, and `2^24` giant steps) reach bounds
near `2^43`. A table is immutable and reusable across decryptions.

## Threshold key generation (all `n` participants in one JVM)

| `(t, n)` | Whole run | Per participant |
|---|---:|---:|
| (1, 3) | 62 ms | 21 ms |
| (2, 5) | 176 ms | 35 ms |
| (3, 7) | 346 ms | 49 ms |
| (5, 11) | 963 ms | 88 ms |
| (10, 21) | 4,503 ms | 214 ms |

Each participant does the following:
- deals `2(t + 1)` blinded commitments;
- decodes and subgroup-checks every broadcast point;
- checks `n − 1` received pairs with equations (4) and (5), whose right-hand sides it evaluates
by Horner's rule with a small multiplier;
- recomputes the public rules and every `Y_j`, by Horner over the coefficient-wise sum of the
extraction vectors.

ADR-0053 estimated this work as host-side only; these figures confirm it. The ballot circuit and
its proofs are unchanged.

## In-circuit relations (rows)

| Circuit | Rows |
|---|---:|
| Encryption, width 1, verifier-fixed key | 6,558 |
| Encryption, width 16 | 6,650 |
| Encryption, width 64 | 6,938 |
| Encryption, width 1, key witnessed in the subgroup | 12,105 |
| DLEQ (possession or decryption share) | 6,546 |

These counts are pinned in `ZkElGamalTest`. Groth16 proving at this size takes about 1–2 s
with the pure-Java prover (compare the Pedersen measurements of 2026-10-03).
11 changes: 11 additions & 0 deletions docs/circuit-annotation-user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,17 @@ The homomorphic and vector APIs work in annotated circuits too (both are experim
`@Public @UInt` fee) and `AnnotatedVectorCommitment` (`ZkPedersenVector` with the schema digest as
a `@Public ZkField`) in `zeroj-integration-tests`. Each is proved with Groth16 and verified in
`AnnotatedPedersenProfilesTest`.

ElGamal encryption (`elgamal-jubjub-v1`, experimental) has typed adapters too:
- `ZkElGamalPublicKey.fromVerifierFixedPublic` or `witnessInSubgroup` for the key;
- `ZkElGamal.encrypt(zk, message, randomness, key)`, with the message declared 1–64 bits and the
randomness exactly 252 bits;
- `ZkElGamal.assertDiscreteLogEquality` for trustee proofs, whose six coordinates must be
`@Public`.

See `AnnotatedElGamalBallot` and `AnnotatedElGamalDleq`, proved and verified in
`AnnotatedElGamalTest`. The test also runs the full flow: verified admission of ballots,
possession proofs, threshold key generation, and verified decryption shares.
Jubjub adapters use BLS12-381.

Bind every prover-supplied point with `ZkJubjubPoint.witnessAffine(zk, u, v)`. It asserts the
Expand Down
Loading