arnaucube
arnaucube/davinci-paperPublic Self-hosted repository
davinci-paper/v3-pq/spec.md
v3-pq/spec.mdRaw
   1# DAVINCI v3-PQ — Post-Quantum Protocol Specification
   2
   3**Status:** draft v1.2 · 2026-10-20 · **unified Blake3 profile** (supersedes v1.0's
   4mixed Poseidon2/SHA-256/Blake3 profile) · incorporates the first external design review ·
   5v2 remains the deployed protocol. Reviewed: three adversarial soundness rounds (protocol
   6reviewer) + audience-representative sign-off + one external design review; a final
   7consolidated review gates implementation (Phase 0 of the migration plan).
   8**Audience:** engineers who already know [DAVINCI v2](https://spec.davinci.vote). This document only
   9specifies what *changes*. Everything not mentioned here (settlement flow, grace window, blob
  10verification via the point-evaluation precompile, census origins, sequencer lifecycle, process
  11registry mechanics) works exactly as in v2 [DAV2].
  12
  13---
  14
  15## 1. Why v3, in one paragraph
  16
  17Every ballot DAVINCI v2 publishes in Ethereum blobs [EIP4844] is an ElGamal ciphertext over
  18BabyJubjub. Published blob data can be archived by anyone indefinitely, and ElGamal falls to
  19Shor's algorithm — so a future quantum computer decrypts **past elections retroactively**
  20("harvest now, decrypt later"). Integrity is less urgent (a settled chain cannot be rewritten
  21under Ethereum's finality assumptions), but **ballot privacy must be post-quantum today**.
  22v3-PQ removes the quantum-vulnerable primitives from the ballot *confidentiality* path: no
  23shared-key homomorphic encryption, no pairings, no DKG, no Groth16. Ballot secrecy rests on
  24polynomial secret sharing, hashes, STARKs, and one NIST-standardized KEM (a post-quantum
  25"public-key lockbox" — all such terms are defined plainly in §2.4). The KEM is never
  26proven inside the voter's circuit (the batch guest performs encapsulations, and rare complaint
  27proofs perform decapsulations; see §8.5, §9.2). During the hybrid period voter authentication
  28still *also* uses ECDSA (§11), and the settlement wrapper and KZG blob commitments remain
  29inherited non-PQ dependencies (§12.5).
  30
  31### Changes at a glance
  32
  33| Component | v2 | v3-PQ |
  34|---|---|---|
  35| Ballot confidentiality | ElGamal over BabyJubjub (threshold key) | Shamir shares + PRF masks over KEM transport (§3) |
  36| Ballot proof | Groth16 over BN254 (circom, trusted setup) | Plonky3 STARK over Goldilocks, browser WASM (§6) |
  37| Election key | DKG / council ceremony (BabyJubjub) | **None.** Wardens register ML-KEM keys (§4) |
  38| Tally | Threshold decryption + BSGS search | Lagrange interpolation of θ proven warden sums (§10) |
  39| Running tally | Homomorphic ciphertext accumulator | Padded plain-sum accumulator over Goldilocks (§8.4) |
  40| Silent revoting | Re-encryption of stored ciphertexts | Hash-chained opaque slot leaves (§7) + padded accumulator |
  41| Revotes | Slot overwrite + ciphertext subtraction | One-live-chain packages + revocation nullifiers (§5.3) |
  42| Voter authentication | ECDSA (secp256k1) | Hash-preimage proof in-STARK; `hybrid` verifies **both**; `hybrid-legacy` admits unenrolled voters on ECDSA (§11) |
  43| CSP credentials | ECDSA | SLH-DSA (SPHINCS+) [FIPS 205] |
  44| Batch proof | ZisK, verifies Groth16 (BN254 precompiles) | ZisK [ZISK], verifies ballot STARKs (Blake3 precompile) |
  45| Protocol hash | Poseidon (circuits) + SHA-256 (state) + Keccak (Ethereum) | **Blake3 everywhere the protocol chooses** (§2); keccak/SHAKE/SHA-2 survive only as fixed islands |
  46| Tally bound | maxValue·maxVoters ≤ 10^12 (BSGS limit) | ≤ 2^61 (field headroom; no search) |
  47
  48![What changes from v2 to v3-PQ](figures/architecture-delta.svg)
  49
  50---
  51
  52## Protocol intuition — read this first
  53
  54*A plain-English walkthrough of a v3 election, phase by phase, mapped onto the v2 flow you
  55already know. Every term used loosely here gets a precise definition from §2 onward; the
  56jargon cheat-sheet is §2.4.*
  57
  58**Setup.** The organizer creates the election exactly as in v2 — census, ballot rules,
  59duration. One thing changed: instead of waiting for a key ceremony, the organizer points at a
  60committee of ν key wardens (say 5, or 16), each of which has already published a post-quantum
  61"lockbox" public key: anyone can lock a small secret so that only that warden can open it.
  62There is **no election encryption key** — nothing is generated jointly, and v2's whole DKG
  63phase is simply gone.
  64
  65**Casting.** The voter's browser takes each ballot value and splits it into ν puzzle pieces,
  66one per warden, using the Shamir trick: any θ pieces (the *threshold* — e.g. 3 of 5) fit
  67together to reconstruct the value, while θ−1 or fewer are pure noise that says nothing at
  68all. The browser then hides each piece under a one-time mask (a random-looking number added
  69to it), locks each mask key into the matching warden's lockbox, and attaches a STARK proof —
  70generated right there in the browser — that the whole construction is consistent: the pieces
  71encode one valid ballot that follows the election rules, the masks match their commitments,
  72and the voter is who they claim to be. The published vote (a *package*) is just masked
  73pieces + locked boxes + commitments. Everything visible is noise; nothing about the choice
  74can be read from it, now or ever, by anything short of θ wardens cooperating.
  75
  76**Voting period.** Sequencers collect packages and settle batches with a zkVM proof, as in
  77v2. The chain maintains one new object: a public **running total** — for each warden, the sum
  78of all masked pieces addressed to it. Adding masked numbers keeps them masked, so the running
  79total is public yet unreadable. A revote cancels the voter's previous package through an
  80unlinkable **nullifier** (same idea as Tornado/Semaphore nullifiers), and the batch proof
  81subtracts the old package's pieces from the running total. Meanwhile, refreshes keep
  82re-hashing slot entries so an outside observer still cannot tell who revoted — v2's "silent
  83revoting", achieved by different means.
  84
  85**End of election.** After the grace window come two short new phases: first a
  86**complaint window**, where any warden that finds a broken package — a lockbox that doesn't
  87open to what was promised — can prove that on-chain and have the package excluded; then the
  88exclusion list freezes.
  89
  90![Election timeline: the two new phases before results](figures/timeline.svg)
  91
  92**Results.** Any θ wardens now each do one job: open all their lockboxes, strip their own
  93masks off their column of the frozen running total, and publish the resulting **partial
  94sum** — with a proof that they did exactly that and nothing else. The punchline: those θ
  95partial sums are θ points on a single polynomial, and that polynomial's value at zero *is*
  96the exact election result. The smart contract draws the unique curve through the θ points and
  97reads it at zero — ordinary integer math, done on-chain. No shared-key decryption ever
  98happens — there is no shared key to decrypt with (each warden only ever opens its own
  99lockboxes).
 100
 101![How the tally emerges from θ partial sums](figures/tally-algebra.svg)
 102
 103What this buys you:
 104- **There is no *shared* election decryption key.** (Threshold-shared *batch-payload* keys do exist and are reconstructed at tally — §8.5/§10.4 — but no key ever decrypts the ballot aggregate.) Not distributed as an election key, that is —
 105  it does not exist, and neither does the key-generation ceremony that managed it in v2
 106  (wardens keep ordinary per-warden lockbox keys, and tally time still has its own
 107  coordinated ceremony — §10).
 108- **Harvest-now-decrypt-later is dead below θ wardens.** The published pieces are
 109  information-theoretic noise; the only cryptography protecting them is the lockboxes
 110  (ML-KEM) and hashes — both post-quantum.
 111- **Every step is proof-checked** — browser proof, batch proof, warden proofs — so voters,
 112  sequencers and wardens are checked, not trusted, for correctness.
 113- **The tally is exact integer arithmetic.** No decryption failures, no noise budgets, no
 114  brute-force search at the end.
 115
 116---
 117
 118## 2. Notation, parameters and encodings
 119
 120- $\mathbb{F}$ — the **Goldilocks field**, $p = 2^{64} - 2^{32} + 1$ (the Plonky3 [P3] and ZisK
 121  native field). All shares, masks and tally arithmetic live here. Canonical encoding of an
 122  element: 8 bytes little-endian, value < $p$.
 123- $\nu$ — number of **key wardens**; $\theta$ — tally threshold. **v3.0 supports
 124  $1 \le \theta \le \nu \le 8$**, enforced at creation and in the pinned profile (DA and
 125  in-circuit cost are linear in ν — ν=8 halves both vs 16; the protocol structures support
 126  up to 16, which returns as a future profile once DA/verification optimizations land;
 127  committee size is unrelated to the 16 *ballot fields*, which stay). Size rosters with the
 128  availability margin in mind: tolerating $f$ unavailable or faulty wardens through the
 129  complaint window and tally ceremony needs $f < \theta \le \nu - f$ — an 8-of-8 election
 130  tolerates none — and ceremony replacements come from the pinned committee, with blinding
 131  still requiring ≥ 1 honest *accepted dealer*. The complaint-capacity bound (§9.2) depends
 132  on admitted casts, not ν: fewer wardens means less aggregate proving/archival redundancy,
 133  so deadlines and hardware budgets must be revalidated per roster size.
 134- `nf` — active ballot fields, 1..16, as in v2. A ballot is a vector $b_1..b_{16}$; fields
 135  beyond `nf` are **inactive and MUST be 0** (enforced by the ballot proof; their shares are
 136  shares of 0).
 137- **KEM** — ML-KEM-768 [FIPS 203] (ct 1088 B) by default; ML-KEM-512 (ct 768 B) is an allowed
 138  profile for DA-sensitive deployments — note it still requires pinning a vetted browser
 139  implementation (the commonly cited WASM wrapper [KEMB] exposes ML-KEM-768 only). One
 140  *encapsulation* yields `(ct, K)` with a 32-byte shared secret `K`; arbitrary payloads are
 141  carried KEM-DEM style (encapsulate, derive a wrapping key from `K`, then DEM-encrypt —
 142  §2.1).
 143- **Blake3** — standard Blake3 [B3] is **the protocol hash, everywhere the protocol gets to
 144  choose**: the ballot STARK's Merkle trees and Fiat–Shamir challenger; all in-circuit
 145  hashing (PRF masks, commitments, voteID, nullifiers — via a re-laid Blake3 AIR section,
 146  §6); the census tree; the state SMT and the nullifier SMT; `pkgDigest`/`ctsDigest`; and
 147  every DEM/PRF/key-derivation role through Blake3's standard *keyed*, *derive_key* and
 148  *XOF* modes (§2.1). Digests are 32 bytes. Rationale: fastest software hash in the browser
 149  (~1.4 GB/s in WASM; measured on the prototype: proving 3.24 s → 0.69 s, proofs
 150  544 → 324 KB), a standard-conformant ZisK precompile (`blake3f`) for every guest
 151  recomputation, and a conservative, long-studied ARX design (§12.4). One hash = one
 152  implementation to audit on each platform (AIR, guest, browser, warden).
 153- **Hash islands the protocol cannot choose**, stated plainly: **keccak256** for values
 154  Solidity contracts must compute (blob evaluation points $z_b$, the v2 processID prefix,
 155  the origin-3 running registration commitment of §8.2) and for hybrid-mode Ethereum
 156  addresses; **SHAKE** inside ML-KEM and **SHA-2** inside SLH-DSA (FIPS-fixed internals of
 157  black-box primitives); **Poseidon2** inside ZisK's own prover (an inherited proof-system
 158  dependency — framing in §12.4; [POS2]). Poseidon2 and SHA-256 hold **no
 159  application-level role** in v3-PQ.
 160- **256-bit values in circuits** (DEM keys, Blake3 digests crossing into Goldilocks
 161  arithmetic): encoded as **eight 32-bit limbs**, each range-checked < 2^32. Never as four
 162  64-bit limbs (not injective: $p^4 < 2^{256}$), and never reduced mod $p$.
 163
 164### 2.1 DEM (authenticated encryption for warden payloads)
 165
 166Built from Blake3's standard modes, normative for **every protocol payload** (voter→warden is
 167pure KEM+PRF and needs no DEM; this DEM covers batch payloads, batch-key share wrapping, and
 168ceremony deliveries):
 169- **Key separation**: `k_enc = Blake3.derive_key("davinci v3-pq DEM enc key", K)` and
 170  `k_mac = Blake3.derive_key("davinci v3-pq DEM mac key", K)` — fixed application context
 171  strings, exactly the standard derive_key mode. `derive_key` creates *separation, not
 172  entropy*: `K` must be a ≥256-bit KEM secret or CSPRNG secret.
 173- **Keystream**: keyed-Blake3 **XOF** — `keystream = Blake3.keyed(k_enc, nonce ‖ AAD).xof()`,
 174  with the counter being the XOF output offset (bounded: payloads < 2^32 blocks, no offset
 175  wraparound); ciphertext = plaintext ⊕ keystream. An XOF is a seekable output stream, not
 176  repeated hashing of previous output.
 177- **Authentication**: encrypt-then-MAC — `tag = Blake3.keyed(k_mac, nonce ‖ AAD ‖ ciphertext)`;
 178  receivers verify the **full 32-byte tag before releasing any plaintext**.
 179- **Uniqueness**: `nonce = Blake3(AAD)`; the AAD is the canonical, length-unambiguous
 180  serialization of a **DEM context** that always includes a purpose tag, the election
 181  context, the **batch number or ceremony (session, attempt) identifier**, sender and
 182  recipient — unique per encryption *including retries* (a ceremony restart is a new attempt
 183  id ⇒ fresh masks, keys and nonces; the same derived key and nonce never encrypt two
 184  different plaintexts).
 185
 186Honest label: these are standard Blake3 modes, but their composition is a
 187**protocol-specific authenticated-encryption construction — not a standardized AEAD**; the
 188needed assumption is keyed-Blake3's PRF security (§12.4). AES-256-GCM may be used by clients
 189for unrelated local storage/transport, never as a substitute encoding of protocol payloads.
 190
 191### 2.2 Domain-separated contexts
 192
 193Every derived value uses a purpose-tagged context; nothing is derived without one. Purpose
 194tags map to Blake3 `derive_key` context strings; the tuple itself is serialized canonically
 195(fixed order, length-prefixed variable fields).
 196
 197| Purpose | Context contents |
 198|---|---|
 199| `pkgCtx` — the package context tuple | `(protocolVersion, chainID, registry, processID, wardenEpoch, voteID)` — the common prefix below |
 200| `streamCtx(i)` — mask stream for masked shares | `("v3/mask", pkgCtx, recipient i)` — **one keyed XOF stream per (package, warden)**, no field index: `stream_i = Blake3.keyed(K_i, streamCtx(i)).xof()`, 256 bytes of output; field $f$ uses bytes $[16(f{-}1), 16f)$ via the LE128-mod-$p$ rule below. This is a **normative masking definition** — browser, ballot AIR, batch guest and warden implementations must match it bit-exactly (test vectors required) |
 201| `hCtx(i)` — share/pad commitment | `("v3/hcommit", pkgCtx, recipient i)` |
 202| `commitCtx` — package commitment | `("v3/pkgcommit", pkgCtx)` — the `ctx` argument of `pkgCommit` (§5.1) |
 203| `nullCtx` — revocation nullifier | `("v3/null", protocolVersion, chainID, registry, processID)` — **predecessor-only**: `NULL = Blake3(nullCtx ‖ sk ‖ prevPkgDigest)` with `sk` the voter's census-bound secret or `sk_pkg` (§11). Never depends on the successor package, batch, or recipients. |
 204| `slotCtx` / `refreshCtx` — slot leaves | `"davinci-slot-v3"` / `"davinci-refresh-v3"` (§7) |
 205
 206The package's mask nonce is its **voteID** — public, unique per package, authenticated, and
 207independent of the masked values (it derives from the secret `k`, §5.2, before any masking),
 208so wardens can recompute every `streamCtx` from public data with no circularity. (Earlier
 209drafts derived one PRF output per *field*; that definition contradicted the in-AIR cost
 210estimates — ≥16 final keyed computations per warden, 256 at ν=16 — and was replaced by the
 211single per-warden stream above, which needs only one context block plus four 64-byte XOF
 212output blocks per warden.)
 213
 214**Byte→field mapping (normative).** Blake3 outputs bytes; masks and other derived field
 215elements are obtained as **LE128 of 16 XOF bytes, reduced mod $p$** — statistical distance
 216from uniform ≈ $2^{-96}$ *per element* (pseudorandom/nearly uniform — not exact uniformity, and not a whole-election bound). Never `LE64(8 bytes) mod p`: its distance is
 217≈ $2^{-32}$, which is not.
 218
 219### 2.3 Protocol parameters
 220
 221| Parameter | Value | Why |
 222|---|---|---|
 223| Share/tally field | Goldilocks $p$ | native in the ballot AIR and ~native u64 in ZisK guests |
 224| Registry tally cap | `maxValue · maxVoters ≤ 2^61` | per-field tally stays below $p$ with headroom (weights don't change this: each field is individually bounded by `maxValue`) |
 225| **Integer-cost profile (enforced)** | `nf · maxValue^costExponent < 2^61`, checked by the registry at creation **and** recomputed overflow-safe in the ballot proof | the cost sum must not wrap mod $p$ (e.g. `costExponent=192` would give $2^{192} \equiv 1$); v2 only *advised* this profile — v3 enforces it |
 226| Warden evaluation points | $x_i = i$, $i \in 1..\nu$ | Shamir positions, pairwise distinct, nonzero |
 227| Max votes per batch | profile-dependent (§8.6) | in-guest verification cost + the 32-blob batch cap inherited from v2's batch program (see §8.6) |
 228| Max refreshed slots per batch | 2048, rule as v2 | unchanged |
 229| `maxRevotesPerVoter` | immutable election parameter | **per-voter revote bound, enforced in-proof** via the private chain counter (§5.3); prevents any single voter from consuming other voters' casting capacity |
 230| Global admitted-cast capacity | `maxVoters × (1 + maxRevotesPerVoter)` | sizes the complaint budget (§9.2); the `+1` is the initial vote — a revote bound alone is not a cast bound |
 231| Nullifier tree | Blake3 SMT, depth 256 | full-width nullifiers (no truncation into the 64-bit key space) |
 232| Ballot STARK profile | Goldilocks, **blowup 32, 18 FRI queries + 16-bit query grinding**, hiding PCS, **Blake3 everywhere** (Merkle/challenger AND the in-AIR hashing section) | ≈106-bit conjectured FRI soundness (§12.4, same heuristic dial as before); chosen verifier-side: −35% in-guest steps and −39% proof size vs blowup-8/34-queries, for ~2.7× prover cost — measured (§8.1). Fallback if browser benchmarks disappoint: blowup 16 / 26 queries. Profile pinned in full by `ballotVKHash`; grinding makes the wasm32 challenger fix (§6) strictly mandatory |
 233| Commitments | **salted unkeyed Blake3**, domain-separated | hiding from an independent 256-bit CSPRNG salt (or the secret inputs); binding from collision resistance. Keyed-Blake3 is reserved for MACs/PRFs — a MAC is not automatically a hiding/binding commitment |
 234
 235### 2.4 Terminology for software engineers
 236
 237Plain definitions, anchored in things an Ethereum engineer already knows. Skim once; the rest
 238of the document assumes them.
 239
 240- **KEM** (Key Encapsulation Mechanism; here **ML-KEM**, the standardized Kyber) — a
 241  public-key *lockbox*: anyone can "encapsulate" against your public key and obtain a fresh
 242  32-byte shared secret plus a ciphertext; only you (with the private key) can recover that
 243  secret from the ciphertext. Think of it as the post-quantum replacement for ECDH key
 244  exchange — except there is no shared-curve math and the two parties never need to be online
 245  together.
 246- **PRF** (pseudorandom function) — a keyed hash used as a deterministic random-number
 247  generator: same key + input ⇒ same output, and without the key the outputs are
 248  indistinguishable from random. Mentally: `keccak256(key, input)` used the way you'd use a
 249  seeded RNG. Here PRFs expand a KEM secret into the masks that hide shares.
 250- **Shamir secret sharing** — split a value into ν pieces by choosing a random polynomial of
 251  degree θ−1 whose value at x=0 is the secret, and handing out its values at x=1..ν. Any θ
 252  pieces determine the polynomial (and hence the secret); any θ−1 pieces are statistically
 253  independent of it — noise, not "hard to crack".
 254- **Threshold θ-of-ν** — ν parties hold pieces; any θ of them suffice to act (here: tally);
 255  fewer than θ learn nothing and can block nothing except by being too few.
 256- **Lagrange interpolation** — given θ points, there is exactly one polynomial of degree
 257  ≤ θ−1 through them; evaluating it at x=0 recovers a Shamir secret. "Draw the unique curve
 258  through the points, read it at zero." A few multiplications and additions — cheap even in
 259  Solidity.
 260- **STARK** — a zero-knowledge proof system built only from hashes (no trusted setup, no
 261  elliptic curves, post-quantum). Bigger proofs than Groth16 (hundreds of KB), but
 262  browser-provable and cheap to verify.
 263- **AIR** — the constraint system of a STARK: its "circuit".
 264- **FRI** — the polynomial-checking engine inside a STARK; the reason STARK verification is
 265  mostly hashing.
 266- **Hiding PCS** — the polynomial commitment inside the STARK is randomized so the proof
 267  leaks nothing about private inputs; this is what makes the proof *zero-knowledge* rather
 268  than merely succinct.
 269- **Witness** — the prover's private inputs (the ballot, the shares, the keys). Never leaves
 270  the prover.
 271- **Nullifier** — a one-way tag published to mark something as spent without revealing what;
 272  exactly the Tornado Cash / Semaphore pattern. Here: marks a vote package as replaced.
 273- **Accumulator** (as used here) — just a running sum vector of field elements maintained by
 274  the batch program. *Not* an RSA or Merkle accumulator.
 275- **Blake3** — a modern general-purpose hash: ARX design (add–rotate–xor, the ChaCha/BLAKE/
 276  BLAKE2 lineage; BLAKE was a SHA-3 finalist), extremely fast in software, with standard
 277  built-in modes for keyed hashing (MAC), key derivation (`derive_key`) and arbitrary-length
 278  output (XOF). v3's single protocol hash.
 279- **DEM / AEAD** — symmetric authenticated encryption (ciphertext + tamper-proof tag), the
 280  AES-GCM role; v3 instantiates it from Blake3's keyed + XOF modes so one hash covers it and
 281  zk-proofs about it stay cheap (§2.1).
 282- **Domain separation** — namespacing every hash/PRF input with a purpose tag and context so
 283  a value from one context can never be replayed in another — the same reason EIP-712 typed
 284  signing exists (§2.2).
 285- **Dealer** — a party that generates a secret and distributes shares of it (used in the
 286  tally ceremony, §10.3).
 287- **CSPRNG** — a cryptographically secure random generator (`crypto.getRandomValues`,
 288  `/dev/urandom`); "fresh CSPRNG randomness" means sampled from this, never derived.
 289
 290---
 291
 292## 3. The core idea: tally without a shared decryption key
 293
 294v2 hides a ballot inside a ciphertext and adds ciphertexts homomorphically. v3 hides a ballot
 295inside **polynomials** and adds polynomials. If you know Lagrange interpolation, you know the
 296whole trick:
 297
 2981. For each ballot field value $b$, the voter picks a random polynomial $f$ of degree
 299   $\theta-1$ with $f(0) = b$, and computes one **share** per warden: $s_i = f(i)$. Any
 300   $\theta$ shares reconstruct $b$; any $\theta-1$ shares are statistically independent of
 301   $b$. Plain Shamir [Sha79]: no curves, just polynomial evaluation in $\mathbb{F}$.
 3022. Shares are never published in the clear. The voter publishes **masked shares**
 303   $e_i = s_i + \mathrm{mask}_i$, where the masks are sliced from one keyed Blake3 XOF
 304   stream per warden (§2.2) and the stream key $K_i$ travels to warden $i$ inside an ML-KEM
 305   ciphertext. To everyone except warden $i$, $e_i$ is a uniformly random field element.
 3063. Polynomials add: the per-field sum of every active voter's polynomial is itself a
 307   degree-$(\theta-1)$ polynomial whose value at 0 is the **tally**. So the protocol only
 308   ever needs to add public field elements. The batch program maintains a public
 309   **accumulator** $A \in \mathbb{F}^{\nu \times 16}$: coordinate $(i, f)$ is the running
 310   sum of the masked shares addressed to warden $i$ for field $f$ (plus batch pads, §8.4).
 3114. At the end, each participating warden decapsulates its KEM ciphertexts, subtracts its pads
 312   from its row, and publishes its **sum-share** $S_i$ — with a ZisK proof that it did exactly
 313   that against on-chain-committed data. Lagrange interpolation of any $\theta$ published
 314   sum-shares at $x=0$ **is** the tally. Exact field arithmetic: no decryption of any
 315   aggregate, no noise, no discrete-log search.
 316
 317![How the tally emerges without a shared decryption key](figures/tally-algebra.svg)
 318
 319(*This section is the intuition; the full computation also handles the exclusion set, batch
 320pads, and a blinding term — §9–§10.*)
 321
 322The ballot STARK (§6) makes steps 1–2 trustworthy, the batch proof (§8) step 3, the warden
 323proofs (§10) step 4. **The zkVM proof chain replaces the homomorphic algebra** — the
 324structural difference from academic PQ voting designs ([TEV], [PQK]), which obtain the same
 325guarantee from lattice commitments. (Some public-key encryption is unavoidable for ballots
 326addressed to offline wardens [IR89]; v3 confines it to KEM transport. Threshold *lattice*
 327decryption — the known hard part of lattice voting [NOAH] — is avoided entirely: the
 328threshold lives at the plaintext layer.)
 329
 330Privacy in one sentence: below $\theta$ colluding wardens, shares are information-theoretically
 331useless in isolation, and the computational assumptions protecting ballots are ML-KEM, the
 332PRF/hash, and the zero-knowledge of the STARKs — all post-quantum (full leakage model: §12).
 333
 334---
 335
 336## 4. Roles: what changed
 337
 338- **Organizer, sequencers, provers, observers** — unchanged from v2.
 339- **Key wardens** no longer run a DKG or hold shares of a secret key. Per *epoch*, each warden
 340  generates an ML-KEM keypair and calls the **WardenRegistry** contract with: `H(pk)`, a URI
 341  where the full public key is served (IPFS or HTTPS), and a ZisK **well-formedness proof**
 342  (the key pair derives from a committed seed and passes an encaps/decaps self-test). The
 343  registry verifies the proof on-chain. An election pins its committee in `wardenSetHash`
 344  (config leaf `0x3`, §7): `(ν, θ, epoch, the ν registered H(pk) values)`. A voter's client
 345  fetches the ν public keys (from their URIs or any sequencer), recomputes each `H(pk)` and
 346  the set hash, and verifies it against the on-chain value before casting; it refuses to cast
 347  otherwise. The registry refuses to create an election whose warden set is not fully
 348  registered. During the election a warden has one standing duty: **continuously archive the
 349  election's blobs** — EIP-4844 blobs are pruned after ≈18 days, so for any longer election a
 350  warden that waits until the end cannot expect ordinary Ethereum nodes to still serve the
 351  history, and missing payload history prevents the tally from completing (§9.3). Wardens MAY
 352  process incrementally during the voting period (decapsulation and share recovery don't need
 353  to wait for the end); at the end they run the complaint scan and one tally ceremony
 354  (§9–§10).
 355- **Key modes.** *Committee* (lottery over registered operators) and *council*
 356  (organizer-invited set) map 1:1 from v2 — they only select *which* registered warden keys
 357  form the set. *Sequencer mode* is the degenerate $\nu = \theta = 1$ case (the sequencer is
 358  the only warden; ~1 KB per ballot — cheaper than v2). **Locked mode is deferred**: it
 359  requires an organizer-side share column and a separately reviewed extension of the tally
 360  equations; it is not part of v3.0.
 361
 362---
 363
 364## 5. The ballot package
 365
 366A vote is one **package**. Its public part goes into blobs; its private part exists only in
 367the voter's browser — except the *revote metadata* the chosen sequencer needs (§5.4).
 368
 369![Building a ballot package in the browser](figures/ballot-package.svg)
 370
 371### 5.1 Public package contents and CanonicalPackage
 372
 373| # | Field | Size (ν=16, ML-KEM-768) | Description |
 374|---|---|---|---|
 375| 1 | `version` | 1 B (`0x03`) | package format version |
 376| 2 | `processID` | 31 B | as v2 |
 377| 3 | `voteID` | 8 B LE | §5.2; also the package's mask nonce (§2.2) |
 378| 4 | `E` | ν·16·8 B = 2,048 B | masked shares, row-major (warden-major, field-minor), canonical LE |
 379| 5 | `cts` | ν·1,088 B = 17,408 B | ML-KEM ciphertexts, warden order 1..ν |
 380| 6 | `h` | ν·32 B = 512 B | commitments $h_i = \mathrm{Blake3}(hCtx(i) \,\|\, s_{i,1..16} \,\|\, K_i)$ — salted unkeyed Blake3 per §2.3 (the secret $K_i$ and shares are the hiding material here) |
 381| 7 | `pkgCommit` | 32 B | $\mathrm{Blake3}(\mathrm{commitCtx} \,\|\, slot \,\|\, pk_{\text{voter}} \,\|\, \mathrm{prevPkgDigest} \,\|\, \mathrm{sharesDigest} \,\|\, t \,\|\, \mathrm{salt})$ — hiding comes from `salt`, an independent **256-bit CSPRNG commitment salt** kept in the package opening (share entropy alone is NOT enough: given θ−1 shares and a candidate ballot, the whole polynomial is determined); `prevPkgDigest = 0^{32}` for a first vote; `t` is the **private chain counter** (§5.3) |
 382| 8 | `hybridSig` | 65 B or absent | hybrid mode only: ECDSA over `pkgDigest`, Ethereum personal-message format (§11); travels voter→sequencer→batch guest only — **never published** (§5.4) |
 383
 384`CanonicalPackage` = the concatenation of fields 1–7 exactly as listed (fixed order, fixed
 385sizes, no framing). **`pkgDigest = Blake3(CanonicalPackage)`** is the package's chain
 386identity: it is the value stored at the vote-ID leaf, the input to revocation nullifiers, and
 387what complaints reference. **`sharesDigest = Blake3(h_1 ‖ … ‖ h_ν)`** — despite the name it
 388binds the shares *through* the per-warden commitments $h_i$ (each AIR-bound to the exact
 389$(s_i, K_i)$ used in masking, fixed order and count), which is equivalent binding at an
 390eighth of the in-circuit hashing cost. The ballot STARK (~195 KB at the pinned profile) accompanies the package to
 391the sequencer but is **not** published in blobs.
 392
 393### 5.2 Construction (browser, pseudocode)
 394
 395```text
 396k         = fresh random scalar (or PRF(sk, "v3/k", processID, counter) in recovery mode)
 397voteID    = N + trunc63(Blake3("v3/voteid" || processID || address || k))
 398                                                                 # trunc63 = lowest 63 bits;
 399                                                                 # N = 2^63 (v2's namespace offset)
 400for f in 1..nf:
 401    poly_f = random polynomial, degree θ-1, poly_f(0) = ballot[f]
 402for f in nf+1..16:  poly_f = random polynomial with poly_f(0) = 0  # inactive fields: shares of 0
 403s[i][f]   = poly_f(i)                                            # ν shares per field
 404for i in 1..ν:
 405    (ct[i], K[i]) = MLKEM.Encaps(pk_warden[i])                   # fresh randomness per package, NEVER reused
 406    stream = Blake3.keyed(K[i], streamCtx(i)).xof(256 bytes)     # ONE mask stream per warden (§2.2)
 407    for f in 1..16: e[i][f] = s[i][f] + LE128(stream[16(f-1)..16f]) mod p
 408    h[i]  = Blake3(hCtx(i) || s[i][1..16] || K[i])
 409t           = 0 for a first vote; prev.t + 1 for a revote       # private chain counter, ≤ maxRevotesPerVoter
 410salt        = fresh 256-bit CSPRNG value                         # hiding salt, kept in the opening
 411sharesDigest = Blake3(h[1] || .. || h[ν])
 412pkgCommit   = Blake3(commitCtx || slot || pk_voter || prevPkgDigest || sharesDigest || t || salt)
 413ctsDigest   = Blake3(ct[1] || .. || ct[ν])                       # binds the ciphertext bytes (§6)
 414proof       = BallotSTARK.prove(...)                             # §6
 415```
 416
 417ML-KEM encapsulation costs ~1–2 ms per warden in browser WASM [KEMB]; the dominant client
 418cost is the STARK (§6). **Freshness warning:** encapsulations are fresh per package and per
 419attempt — including candidate packages that are never admitted. Reused KEM randomness yields
 420identical ciphertexts (publicly linkable); actual *pad* reuse (same key AND same stream
 421context) would publish the difference of two sharings, which interpolates to the ballot
 422difference. Distinct voteIDs give distinct stream contexts for admitted packages, but
 423clients must keep freshness across retries and rejected submissions too.
 424
 425**Client state.** Default: `k`, the polynomials and the KEM randomness are **independent
 426CSPRNG randomness**, and the client stores the package opening — including the commitment
 427salt — (needed to revote). Optional *recovery mode* derives them **and the salt** as
 428`PRF(sk_voter, purpose, processID, counter)` with distinct purpose tags (salt included:
 429`"v3/salt"`). Any device holding `sk` can then reconstruct past packages. The documented
 430trade-off: whoever later obtains `sk` can also reconstruct that voter's own historical
 431ballots. Counter recovery, in the only order that actually works (`pkgDigest` depends on
 432ballot-dependent data, so it cannot be derived from `sk` and a counter alone): the client
 433trial-derives `k` and hence `voteID` for counters 0, 1, 2, …; looks each `voteID` up
 434on-chain (the vote-ID leaf yields the admitted `pkgDigest`); fetches that package's bytes
 435from the blob archive; re-derives the salt and KEM randomness from the counter's seeds, and
 436recovers the shares by unmasking the fetched package's public E with the re-derived pad
 437keys (shares are not derivable from seeds alone); checks the result against the package's
 438commitments; and checks the nullifier tree to find which package is still live. Gaps from
 439collision-resamples (§14) are skipped naturally.
 440
 441### 5.3 Revoting: the one-live-chain rule
 442
 443v2 overwrote the voter's slot and subtracted the stored ciphertext. v3 has no stored
 444ciphertext, so the *voter's proof* identifies what to remove:
 445
 446![Revote lifecycle: the one-live-chain rule](figures/revote-lifecycle.svg)
 447
 448- Each voter has, per election, a chain of packages $P_0 \to P_1 \to \dots$; exactly one is
 449  **live**. A revote package $P_{t+1}$ consumes $P_t$: the STARK proves knowledge of $P_t$'s
 450  opening (same slot, same key) and the nullifier derivation
 451  $\mathrm{NULL}_t = \mathrm{Blake3}(\mathrm{nullCtx} \,\|\, sk \,\|\, \mathrm{pkgDigest}_t)$, where
 452  `sk` is the voter's census-bound secret (or the self-chosen `sk_pkg` for unenrolled hybrid
 453  voters — §11).
 454- The batch program checks $P_t$ **was admitted and is settled**: an inclusion proof of
 455  `voteID_t → pkgDigest_t` under the current root (consequently, a predecessor cast in the
 456  *same* batch cannot be consumed yet — §14). It inserts $\mathrm{NULL}_t$ into the nullifier
 457  tree (insert-once: double consumption is impossible), subtracts $P_t$'s public `E` from the
 458  accumulator, and adds $P_{t+1}$'s.
 459- Invariants enforced by the batch program: an **empty slot admits exactly one initial
 460  package**; a package for an **occupied slot must consume exactly one admitted, unconsumed
 461  predecessor of the same owner and slot**; refreshes never create occupancy.
 462- **Per-voter cast budget (the chain counter).** Each package opening carries a private
 463  counter `t`, bound inside `pkgCommit` (§5.1): a first package proves `t = 0`; a revote
 464  proves `t_new = t_prev + 1` against the predecessor's opening and
 465  `t_new ≤ maxRevotesPerVoter` (an immutable election parameter, §2.3). The counter is
 466  **private** — publishing it would leak revote patterns — and the ballot STARK enforces it,
 467  with `maxRevotesPerVoter` authenticated from the immutable election parameters and all
 468  counter/capacity arithmetic in bounded integers (no wraparound). `t` is distinct from the
 469  recovery-mode randomness counter (§5.2): a voteID-collision retry advances randomness
 470  allocation, not the number of admitted predecessors.
 471  Why it exists: with only a global cast capacity, one eligible voter could legally consume
 472  it all (e.g. a 100-slot election with a 200-cast budget: one voter casts once, then revotes
 473  199 times, each with a valid proof and fresh nullifier — and no other voter can cast a
 474  first ballot). The per-voter bound makes that impossible, and the global capacity
 475  `maxVoters × (1 + maxRevotesPerVoter)` then holds by construction rather than by racing.
 476
 477Nullifiers are unlinkable to packages for third parties (they depend on `sk`). The coercion
 478consequences are stated in §12.3.
 479
 480### 5.4 Submission interface (voter → sequencer)
 481
 482The voter submits to one sequencer, over an encrypted channel as in v2:
 483`{CanonicalPackage, hybridSig?, ballotProof, censusProof?, and — for a revote — the
 484predecessor reference (voteID_t, pkgDigest_t) with its inclusion path}`. The sequencer (and
 485its prover) therefore **learns revote events and predecessor linkage for the votes it seals —
 486the same boundary as v2**, where the sealing sequencer learns which updates are overwrites.
 487It never learns ballots, shares, pads, or `sk`: those stay inside the STARK witness. The
 488batch program receives the predecessor's public data as ordinary host input; the STARK is
 489what makes it *authorized* (nullifier + ownership), and the chain is what makes it
 490*authentic* (vote-ID leaf).
 491
 492**What never enters public data availability:** `hybridSig` (a recoverable signature would
 493link the package to its Ethereum address), the ballot proof, the inner proof's public
 494vector, and the predecessor/revote metadata all stop at the voter→sequencer→guest boundary.
 495Blobs carry only `CanonicalPackage` and the batch-level data of §8.6.
 496
 497---
 498
 499## 6. The ballot proof (Plonky3 STARK)
 500
 501The Groth16 circuit is replaced by a STARK over Goldilocks, proven in the browser via WASM —
 502the production descendant of the davinci-stark prototype [DST], minus its elliptic-curve
 503section. No trusted setup.
 504
 505**Public inputs: the raw public vector.** There is no binding hash (v1.0's `inputsHash` is
 506removed): the proof exposes the public statement **directly as a pinned, ordered vector of
 507Goldilocks elements/limbs** — at least: `version` · `processID` · `packedBallotMode` ·
 508`voteID` · the identity binding (`address` limbs and `pk_PQ` or the legacy branch's
 509`H(sk_pkg)`) · `slot` · `authMode` · `isRevote` · `weight` · all `E` coordinates (ν·16
 510elements) · all `h_i` (ν × 8×32-bit limbs) · `pkgCommit` limbs · `ctsDigest` limbs ·
 511`prevPkgDigest` limbs · `NULL` limbs — **≈ 420+ elements at ν=16**. The vector layout is
 512length-prefixed per ν and never truncates. `ctsDigest = Blake3(cts)` is computed *outside*
 513the circuit and enters as opaque limbs — this **binds** the ciphertext bytes without proving
 514anything about ML-KEM.
 515
 516**Statement contract (normative).** The batch program **constructs the expected public
 517vector itself** — from the canonical package it admits, the authenticated election
 518parameters, the authenticated census data (§8.2), and the predecessor metadata — and
 519verifies the proof against *that* vector. It never verifies a supplied vector and then
 520processes different package data. Inside the AIR, every value used by ballot validation,
 521share generation, masking, commitments and nullifier derivation is constrained equal to
 522these publics, so an admitted package is byte-for-byte the one the voter's proof authorized.
 523`censusRoot` is **not** a ballot public input: membership is the batch program's job (§8.2).
 524Privacy note: the inner proof's public inputs live at the voter→sequencer/guest boundary —
 525they are **not** published in blobs beyond what the package itself already publishes.
 526
 527**The proof shows:**
 5281. **Ballot validity** — v2's ballot protocol (ranges, uniqueness, cost sum vs
 529   `maxValueSum`/weight, `ballotMode` unpacking), with three normative strengthenings over
 530   the v2-era prototype: the weight bound is enforced when `maxValueSum = 0`; all comparisons
 531   use sound borrow-checked integer gadgets (no Goldilocks wraparound); and the cost sum is
 532   computed overflow-safe under the enforced integer-cost profile (§2.3).
 5332. **Share consistency** — for every field (including inactive ones, with constant term 0),
 534   the ν shares lie on one polynomial of degree ≤ θ−1 whose constant term is the ballot
 535   value. Cost: ν·16·(θ−1) ≈ 1.8k multiplications at ν=16, θ=8 — trivial for the AIR.
 5363. **Mask consistency** — $e_{i,f} = s_{i,f} + \mathrm{mask}_{i,f}$ where the 16 masks of
 537   warden $i$ are the LE128-mod-$p$ slices of the single keyed XOF stream
 538   $\mathrm{Blake3.keyed}(K_i, \mathrm{streamCtx}(i))$ (§2.2), with the same $(s_i, K_i)$
 539   committed in $h_i$.
 5404. **voteID derivation** from `(processID, address, k)` (Blake3, §5.2), with all of these
 541   bound in the public vector.
 5425. **Authentication** (§11): knowledge of `sk` with `H(sk) = pk_PQ`, where `pk_PQ` is a
 543   public input that the **batch program** binds to the authenticated census leaf (§8.2) —
 544   census membership itself is *not* proven in the ballot AIR. For an unenrolled hybrid
 545   voter (census `pk_PQ = 0` means "no enrolled key" — the proof never requires
 546   `H(sk_pkg) = 0`): knowledge of the self-chosen `sk_pkg` bound in the chain's first
 547   `pkgCommit` (§11), with identity resting on `hybridSig`. For a revote, additionally the
 548   predecessor opening (same slot, same key), the `NULL` derivation of §5.3, and the chain
 549   counter rule `t_new = t_prev + 1 ≤ maxRevotesPerVoter` (§5.3). Authentication relies on
 550   the proof system's **knowledge soundness**: the proof must establish that the prover
 551   *knows* the preimage/witness (bound to this entire authorized package), not merely that
 552   one exists.
 553
 554**The in-AIR Blake3 section.** All in-circuit hashing runs in a **re-laid Blake3 section**
 555(~25–32 rows per compression at the circuit's width). Honest compression budget under the
 556§2.2 stream-masking definition: per warden ≈ 1 context block + 4 XOF output blocks for the
 557masks + ≥ 4 for $h_i$ (its input is ≥ 219 bytes: processID, registry, voteID, 16 shares,
 558$K_i$, before context fields); plus ≈ 12 for `pkgCommit`, `sharesDigest`, voteID, `NULL`
 559and the counter — **provisionally ≈ 57 compressions at ν=5, ≈ 156 at ν=16**, to be fixed by
 560instrumented counts of the exact canonical encodings for both admission paths (first vote
 561and revote). Earlier drafts said ~45/~110 against a per-field masking rule that would
 562actually have needed ≥ 80/256; the stream rule above is what makes counts this low possible.
 563It MUST constrain full standard-Blake3 semantics, not merely a compression gadget:
 564canonical input bytes, exact lengths and zero padding; correct IV / keyed / `derive_key`
 565initialization per mode; the full 7-round schedule with both feed-forward halves; the
 56664-byte-block and 1024-byte-chunk structure with correct counters and
 567`CHUNK_START`/`CHUNK_END`/`ROOT` flags; correct chaining between compressions; XOF
 568output-block counters (an XOF is a seekable stream, not repeated hashing); outputs
 569constrained equal to the values consumed elsewhere in the AIR; and selector/phase
 570constraints that cannot skip or disconnect any check. Negative test vectors regenerate
 571otherwise-correct traces with wrong flags, counters, lengths or chaining values.
 572
 573What the proof deliberately does **not** show: that `ct_i` decapsulates to the committed
 574$K_i$. Proving ML-KEM in-circuit would drag SHAKE through the AIR. Instead, mismatched
 575transport is *harmless to integrity* (no tally proof ever runs Decaps — §10.2) and *publicly
 576excludable* (complaints — §9.2). A STARK-friendly verifiable encryption removing this
 577trade-off is the main tracked upgrade (§15).
 578
 579**Indicative numbers.** Measured on the prototype [DST]: the Blake3 Merkle/challenger profile
 580proves in **0.69 s native** (vs 3.2 s for the old Poseidon2 profile) with **~324 KB proofs**;
 581a standalone Blake3 compression AIR costs ≈3.4 ms/compression at its wide layout. The
 582full-Blake3 ballot (re-laid in-AIR section) is a **projection, not a measurement**:
 583**~2–4 s native (ν-dependent; the blowup-32 profile costs ~2.7× the old blowup-8 prover time, bought back for the batch guest — §8.1)**, ~195 KB proofs — to be re-benchmarked once the
 584re-laid AIR exists (equal cell counts do not guarantee equal proving cost; the degree and
 585quotient profile must be recomputed). Browser proving is expected at a few × native (mobile
 586slower — to be benchmarked; the proof uploads once to one sequencer and is never stored
 587on-chain). Benchmark provenance: all prototype figures in this document come from internal
 588prototype commits; exact commits, hardware, compiler flags and proof settings will be
 589published with the reference implementation. Standing adoption gates (from review): fix the
 590vendored challenger's wasm32 query-sampler bug; production hiding CSPRNG; implement full
 591Blake3 chunk/tree semantics over the `blake3f` precompile with boundary-length test vectors
 592(0/63/64/65/1023/1024/1025 B); measure real browser and whole-batch guest costs before
 593deployment guarantees. Before `ballotVKHash` is pinned, the **complete proof profile** must
 594be fixed and published: the challenge extension field and its defining polynomial; trace
 595shapes, maximum constraint degree and quotient construction; FRI folding and final-polynomial
 596parameters; hiding dimensions and the blinding-randomness source; the complete Fiat–Shamir
 597transcript (observe/sample schedule, domain-separated initialization, the Merkle-commitment (MMCS) matrix layout and shape
 598checks, serialization); and the knowledge-soundness assumptions with the claimed quantum
 599security model.
 600
 601---
 602
 603## 7. State tree changes
 604
 605Same sparse-Merkle-tree structure, depth 64, same namespaces as v2 — now hashed with
 606**Blake3** (leaf: `Blake3(key_LE8 ‖ value_32 ‖ 0x01)`, node: `Blake3(left ‖ right)`), plus
 607four changes:
 608
 609![State tree v3 layout](figures/state-tree-v3.svg)
 610
 6111. **Vote-ID leaves carry the package digest**: `voteID → pkgDigest` (v2 stored 0). This lets
 612   revotes and complaints authenticate a package *body* against the chain.
 6132. **Slot leaves are chained opaque digests** (no ballot data):
 614   - first vote / overwrite: `leaf = Blake3("davinci-slot-v3" ‖ pkgDigest ‖ s_batch)`
 615   - refresh: `leaf' = Blake3("davinci-refresh-v3" ‖ leaf ‖ s_batch)`
 616   with `s_batch` the sequencer's secret batch seed (proven in-guest, never published — the
 617   same trust class as v2's re-encryption seed). A refresh needs only the **public current
 618   leaf** plus the refresher's own secret, so **any sequencer can refresh any occupied slot**
 619   — permissionless sequencing is preserved and a vanished sequencer blocks nothing. Both
 620   update types produce fresh-looking 32-byte values; this plus the padded accumulator is
 621   what replaced re-encryption-based silent revoting.
 6223. **Config namespace**: `0x3` = `wardenSetHash` (§4) instead of an encryption key; `0x4` =
 623   `Blake3(A)` (the accumulator value itself is published in every batch's blobs); `0x5`
 624   (reserved in v2) = the root of the **nullifier tree**, a dedicated Blake3 SMT of depth
 625   256. A nullifier is a 32-byte Blake3 digest used directly as the 256-bit key; leaf
 626   value = 1.
 6274. **Genesis predicate replaces on-chain genesis computation.** The EVM has no Blake3
 628   precompile, so the registry no longer computes the genesis root itself. Instead it stores
 629   the election parameters and an **initialization flag**, and the **first transition's batch
 630   proof constructs the genesis tree deterministically in-guest** from the registry-supplied
 631   parameters — the canonical empty tree plus *exactly* the prescribed config leaves, the
 632   zero accumulator in its prescribed encoding, an empty nullifier tree, no slots, no
 633   packages, correct initial counters — and proves `oldRoot` equals that construction.
 634   Membership proofs under a prover-chosen root are **never** accepted as a substitute (they
 635   show presence, not absence of extra state). Registry rules: the genesis branch is
 636   selected by the stored initialization flag (never caller input); parameters come from
 637   registry storage, not calldata; the first transition and initialization are recorded
 638   atomically; thereafter `oldRoot == storedRoot` always, and re-initialization is
 639   impossible; the outer proof binds the full `(chainID, registry, processID)` (not just
 640   v2's 4-byte prefix); and an **initialization-only transition** (zero ballots) is an
 641   explicit path so empty elections can still finalize.
 642
 643---
 644
 645## 8. The batch program (ZisK guest)
 646
 647In one line: the batch program is the referee — it re-checks every vote package, applies the
 648state updates, and maintains the masked running total.
 649
 650Same role, same settlement flow, same public-output pattern (`ok`/`failMask`, old/new roots,
 651counters, census root, blobs digest) as v2. The constraint groups change as follows.
 652
 653![Batch program v3 dataflow](figures/batch-flow.svg)
 654
 655### 8.1 Ballot proof verification — measured cost, honest sizing
 656Verifies the n ballot STARKs **in-guest**. This cost has now been **measured on the real
 657emulator** (a ZisK guest running the Plonky3 verifier on an actual ballot proof; internal
 658prototype — exact commits/hardware/flags to be published with the reference
 659implementation, §6), and it is
 660the dominant cost of the v3 batch program — far above the earlier modeled figure, because
 661hashing turns out to be a minor component: at the pinned profile (§2.3) one verification
 662costs **≈14.5M guest steps** (22.1M at the former blowup-8/34-query profile), of which
 663hashing via the `blake3f` precompile is only ~1.5M (4,681 compressions); the rest is FRI
 664field arithmetic, Merkle path bookkeeping, the symbolic constraint rebuild (1.49M,
 665**amortized once per batch** since all proofs share one AIR), and proof deserialization.
 666Two further optimizations are **normative implementation requirements**: Goldilocks
 667inversions use ZisK `fcall` hints (hint + multiply check, replacing ~1.4k-step software
 668inversions — the mechanism ZisK already uses for secp256k1/BN254 inverses), and opened rows
 669are hashed as words, not per-byte streams. **GPU-measured** (RTX 5090,
 670cargo-zisk 1.3.0-alpha, this exact profile, after a reviewed no-precompile optimization
 671pass — per-batch setup hoisting, the existing `uint256_inv_mod` fcall as the Goldilocks
 672inverse hint, word-level hashing, and a differentially-tested fork of the FRI verifier
 673factoring query-independent sums): per-proof cost fell from 14.45M to **2.62M steps**
 674(−82%), and proving the verification of 1 / 8 / 32 proofs takes **10.4 / 12.5 / 19.8 s** —
 675a ≈10 s fixed pipeline plus **≈0.30 s marginal per verification**, i.e. ≈1.6
 676verifications/s at K=32 and a projected ≈2.7/s at K=128 per GPU. A 256-ballot batch's
 677verification layer proves in ≈1.5–2 minutes; the fixed pipeline cost, not per-ballot work,
 678now dominates.
 679With the amortization and inverse hints above (and a proposed upstream Goldilocks-ext²
 680precompile), ~1 verification/s/GPU is the modeled target. Practical batch sizes today:
 68132–128 ballots for v2-like latency, 256 where ~8-minute batches are acceptable; throughput
 682scales across provers as in v2 — the price of post-quantum ballots is paid in parallelizable
 683sequencer GPU time, not voter experience. The guest implements Blake3's chunk/tree layout
 684over the compression syscall; Merkle parents are `BLAKE3(left ‖ right)`. The ballot verifier
 685configuration (AIR identity, FRI profile, transcript and hash profile) is pinned via
 686`ballotVKHash` at config leaf `0x7`, as in v2, and the guest constructs each proof's expected
 687public vector per the §6 statement contract.
 688
 689### 8.2 Census, authentication, binding
 690Census membership is verified **here**, as in v2 (not in the ballot AIR): the program
 691authenticates the census leaf `Blake3(address ‖ weight ‖ pk_PQ)` with a Merkle path under an
 692accepted root, derives the slot by the census-origin rule, and proves the **join equality**:
 693
 694$$\text{ballot publics } (\text{identity key},\, weight,\, slot,\, authMode) \;=\; \text{authenticated census values and policy}$$
 695
 696The census root it checks is bound in the **batch statement** and must be accepted under the
 697election's origin-specific registry policy — never chosen freely by the prover. `authMode` is
 698derived from the immutable election auth policy plus the creation-time enrollment snapshot
 699(§11) and compared against the proof's public input — never prover-chosen. Authentication
 700then follows the policy: `pq-only` relies on the in-STARK preimage proof alone; `hybrid`
 701*additionally* verifies `hybridSig` (ECDSA over `pkgDigest`, secp256k1 precompile, recovered
 702address = census address) for every package; `hybrid-legacy` dispatches per census leaf as
 703specified in §11. The program recomputes `ctsDigest` and `pkgDigest` from the package body
 704and constructs the proof's full expected public vector from that body (§6 statement
 705contract) — so an admitted package is byte-for-byte the one the voter's proof authorized.
 706
 707**On-chain censuses and the PQKeyRegistry (origin 3).** Contracts cannot hash Blake3
 708cheaply, so on-chain censuses maintain an incremental **keccak256 running commitment** of
 709their authorized registrations (one `keccak256(prev, entry)` per registration — Solidity-
 710native). A permissionless **census-root conversion proof** — a small ZisK guest — attests
 711"running commitment `c` corresponds to Blake3 lean-IMT root `r`"; the registry verifies it
 712and stores the accepted `(c, r)` pair, and batches then use `r` under the origin-3 root
 713policy. No unauthenticated off-chain root ever enters the system.
 714
 715### 8.3 State transitions
 716In fixed order, each proven against the previous root, as v2: (1) insert
 717`voteID → pkgDigest`; (2) insert revocation nullifiers with the one-live-chain checks of
 718§5.3 (predecessors must be settled under the starting root); (3) write slot leaves (votes +
 719overwrites), then refresh the sample $\mathcal{R}$ (§7.2; sample-size rule as v2); (4) update
 720`0x4` with the new accumulator digest and `0x5` with the new nullifier root.
 721
 722### 8.4 Accumulator update and the batch pad
 723$$A' = A + \sum_{\text{new pkgs}} E \; - \sum_{\text{consumed pkgs}} E \; + \; B$$
 724
 725In words: the new accumulator is the old one, plus the masked shares of every package this
 726batch adds, minus the masked shares of every package it revokes, plus a fresh secret pad $B$
 727whose only job is to hide *which* rows were subtracted.
 728
 729Here $B \in \mathbb{F}^{\nu \times 16}$ is a fresh **uniform** batch pad derived in-guest
 730from the secret batch seed. Without $B$, the public batch delta minus the (public) new-package
 731sums would equal $-\sum_{\text{consumed}} E$, letting anyone identify revoked packages by
 732matching public `E` rows. $B$ is deliberately *unstructured* — a Shamir-codeword-shaped pad
 733would vanish under the code's public parity checks and leak the same information.
 734
 735### 8.5 The warden payload (KEM-DEM, proven)
 736Per batch, the guest: derives a 256-bit batch key $k_b$ and the ML-KEM encapsulation
 737randomness from the secret batch seed (guest-internal derivation under the pinned program, so
 738it is as trustworthy as the proof itself); DEM-encrypts (§2.1)
 739`payload = (B ‖ consumed pkgDigests ‖ context)` under $k_b$; Shamir-shares $k_b$
 740**coordinate-wise over its 32-bit limbs** θ-of-ν; and for each warden $i$: one in-guest
 741ML-KEM encapsulation to $pk_i$ → wrapping secret → DEM-encrypts share $i$, and publishes a
 742salted Blake3 **commitment to each recipient's share** (opening salts travel inside the
 743respective DEM ciphertexts; these commitments are what lets tally participants validate
 744forwarded shares in §10.4 without decapsulating each other's ciphertexts). The proof binds
 745$B$ to the accumulator update, the consumed list to the nullifier insertions, every
 746ciphertext to its registered recipient key and context, and the share commitments to the
 747shared $k_b$. **Unlike voter transport, a malformed
 748batch payload is unprovable, not merely complainable** — it would hide an accepted
 749transition's revocations and pads from the tally. All of it is published in the batch's blobs.
 750
 751### 8.6 Blob layout v3 and honest DA numbers
 752Blob cells carry 31 payload bytes each (a v3 codec choice — v2 packed typed values; v3 packs
 753an opaque byte stream per section), 4096 cells per blob ⇒ 126,976 B per blob. Sections, in
 754order: header · new packages (CanonicalPackage bytes) · slot-update list
 755(slot index 8 B + new leaf 32 B — so a refresh costs 40 B framed, vs ~1–2 KB in v2) ·
 756nullifiers (32 B each) · accumulator value $A'$ (ν·16·8 B) · warden payload (§8.5).
 757Byte-exact cell maps live in the davinci-zkvm normative docs, as in v2. One divergence from
 758v2's blob flow: the evaluation point becomes
 759$z_b = \mathrm{keccak256}(\text{processID} \,\|\, \text{stateRoot}^{old} \,\|\, \text{blobCommitment}_b) \bmod q_{BLS}$
 760— keccak because the **registry contract** computes it (Solidity-native; the guest recomputes
 761it via the keccak precompile, one call per blob — a §2 island).
 762
 763Per-package size: `72 + ν·(160 + ct_len)` bytes (72 B fixed fields; per warden: 128 B of
 764masked shares + 32 B commitment + one ciphertext) ⇒ **20,040 B** at ν=16/ML-KEM-768;
 76514,920 B at ν=16/ML-KEM-512; 6,312 B at ν=5/768; 1,320 B at ν=1.
 766
 767| Profile (256 votes + 256 refreshes) | batch bytes | blobs (126,976 B each) | vs v2 (~5 blobs) |
 768|---|---|---|---|
 769| **ν=8, ML-KEM-768 (v3.0 max)** | ≈ 2.6 MB | **≈ 21** | ~4× |
 770| ν=5, ML-KEM-768 | ≈ 1.7 MB | ≈ 14 | ~2.7× |
 771| ν=1 (sequencer mode) | ≈ 0.35 MB | ≈ 3 | ~0.7× — *cheaper than v2* |
 772| ν=16, ML-KEM-768 (future profile) | ≈ 5.2 MB | ≈ 41 — exceeds the 32-blob cap ⇒ ~195 votes/batch or ML-KEM-512 (≈31) | ~8× |
 773
 774**The two settlement modes reach the same 32-blob cap — by different mechanisms.**
 775**L1-blob mode** posts blobs across multiple Ethereum transactions and proves their chain
 776inclusion on the rollup, as v2's OP-Stack path. **Native blob mode** is no longer limited
 777to one blob-carrying transaction (EIP-7594's 6 blobs): a state transition may be published
 778as a **sequence of blob transactions followed by the settlement call**. Each blob
 779transaction calls `registerBlobs(processID, batchSeq, index)` on the registry, which reads
 780its own transaction's versioned hashes via the `blobhash` opcode — the only trustworthy
 781on-chain binding between a versioned hash and an actually-published blob — and records them
 782— with the registration **block number** — keyed by `(processID, msg.sender, batchSeq,
 783index)` (never a caller-supplied identity). Rules, all reverting on violation (reviewed;
 784conditions incorporated):
 785- **Freshness.** A registration set snapshots the current state root; a root change
 786  invalidates it immediately (a lost race kills the set, not merely the next
 787  registration). Settlement must land within a **maximum registration age** safely inside
 788  the DA-retention window — stored hashes prove *historical publication*, not *present
 789  availability* — and wardens/observers collect pre-published blobs from registration
 790  time, not settlement time.
 791- **Exact manifest.** Indices are batch-global (0..nBlobs−1, ≤ 32), slots immutable and
 792  non-overlapping once written, `blobhash` values nonzero; the settlement transaction's
 793  own blobs fill the remaining indices in ascending order (one deterministic merge rule);
 794  every position the proof's blob count requires must be present in the exact proof-bound
 795  order — gaps, overlaps, reordering and partial settlement revert. `batchSeq` is per
 796  `(processID, sender)`, monotonic and non-wrapping; consumed sequence numbers are never
 797  reusable. Verification, root update and consumption are atomic.
 798- **Storage lifecycle.** One bounded active manifest per (sender, process); slots are
 799  reused or explicitly deleted; expired records are permissionlessly cleanable in bounded
 800  batches; registrants pay registration gas (≈640k gas of fresh SSTOREs for a full
 801  32-slot manifest), cleanup is deposit/bounty-funded, and no settlement or lifecycle
 802  path ever iterates over all registrants.
 803Per-sender keying prevents another sender from occupying this sender's registration slots
 804— it is not a general anti-griefing claim. For every manifest position the registry
 805preserves the full binding chain: stored versioned hash → commitment via the
 806point-evaluation precompile → `z_b = keccak(processID ‖ stateRoot_old ‖ commitment)` with
 807`stateRoot_old` required to equal the current root → the proof-bound ordered blob digest.
 808Cross-transaction publication therefore adds **no new KZG assumption**. The first 6 blobs
 809may still ride the settlement transaction itself; native mode supports every v3.0
 810profile, and small batches settle exactly as in v2 with zero extra transactions.
 811
 812DA is v3's main cost regression and is linear in ν: size committees to the election's
 813stakes. Classic McEliece transport (96–128 B ciphertexts ⇒ 4.2–4.7 KB/package at ν=16 by the
 814same formula) is the tracked reduction path for large committees [MCE].
 815
 816---
 817
 818## 9. End of election: freeze, complaints, exclusions
 819
 820The v2 timeline (end → grace window) gains two phases before results:
 821
 822![Election timeline v3](figures/timeline.svg)
 823
 824### 9.1 Casting freeze
 825When the grace window closes the registry stops accepting transitions (as v2) and the
 826accumulator freezes as $A_{\text{cast}}$, bound to the frozen final root.
 827
 828### 9.2 Complaint window and the exclusion set X
 829During a scheduled window (an election parameter, like the grace bounds), **registered
 830wardens of the election** may submit complaints: `submitComplaint(processID, pkgDigest,
 831publicValues, proof)` where the ZisK proof shows `Decaps(sk_i, ct_i)` yields a key
 832inconsistent with the package's admitted $h_i$ (witness: the warden's registered key seed;
 833statement bound to the admitted `pkgDigest` and the frozen root). The registry verifies the
 834proof and appends the package to an **idempotent, append-only exclusion set $X$**. Complaints
 835**never touch the accumulator** — so no complaint needs to know whether its package was
 836already consumed, and ordering cannot matter. Submission is allow-listed to the election's ν
 837wardens; the submitter pays gas. **Capacity is sized to the workload, not an arbitrary cap**:
 838total admitted casts are bounded by `maxVoters × (1 + maxRevotesPerVoter)` (§2.3 — the
 839per-voter bound of §5.3 enforced in-proof, times the electorate), and the complaint window
 840length and the wardens' proving/fee budget must cover that bound in the worst case (an
 841adversary can make the complaint path linear in admitted casts — this is an explicit
 842liveness assumption, §9.3, not an exceptional path). At the
 843deadline $X$ freezes on-chain; every tally proof binds the frozen
 844$(\text{root}, A_{\text{cast}}, X)$ snapshot.
 845
 846Semantics, stated plainly: a voter whose *live* package ends up in $X$ is not counted (their
 847earlier packages stay consumed) — a deliberately malformed revote is a provable
 848self-abstention, and a voter+warden coalition gains a bounded post-close withdrawal option
 849for that voter's own ballot. A package malformed toward warden $i$ that is *not* excluded
 850still tallies correctly from wardens that can open it (§10.2); warden $i$ either complains in
 851the window or sits out.
 852
 853### 9.3 Liveness
 854The tally needs at least θ wardens (the tally threshold) that complete the archive scan (and any complaints) inside the
 855window, complete the ceremony (§10.3), and publish proven contributions — plus, as in v2,
 856timely inclusion of their transactions, **plus complaint capacity (proving + fees + window
 857length) provisioned for the election's admitted-cast bound in the worst case (§9.2)**,
 858**plus availability of the complete blob archive**: blobs prune after ≈18 days (§4), so for
 859elections longer than the retention window, continuous redundant archival by wardens (or
 860archivers they trust) is itself a tally-liveness assumption — missing payload history means
 861the tally cannot complete.
 862Fewer ⇒ results are lost, exactly as v2's "θ of ν wardens take part in decryption".
 863
 864---
 865
 866## 10. Tally: warden sums and Lagrange
 867
 868In one line: this is where the masked running total becomes the election result — in public,
 869with proofs, and without any decryption key.
 870
 871### 10.1 What each participating warden computes
 872After the exclusion freeze, each participating warden $i$:
 8731. holds the complete blob archive (continuously collected during the election — §4; work is
 874   linear in *total casts*, not final voters, and decapsulation/share recovery MAY run
 875   incrementally during the voting period);
 8762. decapsulates its per-package ciphertexts, regenerates each package's mask stream
 877   ($\mathrm{Blake3.keyed}(K_{v,i}, \mathrm{streamCtx}(i))$, §2.2), recovers shares
 878   $s_{v,i,f} = e_{v,i,f} - \mathrm{mask}_{v,i,f}$, and checks each against
 879   the admitted $h_{v,i}$;
 8803. joins the **tally ceremony**: the participants exchange batch-payload-key shares
 881   **privately** (§10.4 — never in public), reconstruct the per-batch payload
 882   keys (θ shares each), decrypt the payloads — obtaining every batch pad $B$ and the full
 883   consumed set $R$, verified against the batch proofs that committed them — and run the
 884   zero-blinding round producing $G_f$ (§10.3);
 8854. computes, over $\mathrm{Active} = \mathrm{Admitted} \setminus (R \cup X)$:
 886
 887$$S_{i,f} = A_{\text{cast},i,f} - \sum_{v \in X \setminus R} e_{v,i,f} - \sum_{v \in \mathrm{Active}} \mathrm{mask}_{v,i,f} - \sum_{b} B_{b,i,f} + G_f(i)$$
 888
 889In words: start from the frozen running total; remove the rows of excluded-but-never-revoked
 890packages; strip your own masks for every counted package; strip the batch pads; add your
 891blinding share.
 892
 893One-line sanity check: $A_{\text{cast}}$ = (masked shares of all admitted-minus-consumed
 894packages) + (all batch pads); removing the still-present excluded rows, all pads, and all
 895batch pads leaves exactly $\sum_{\mathrm{Active}} s_{v,i,f}$; adding $G_f(i)$ with
 896$G_f(0)=0$ doesn't change the interpolation at 0.
 897
 8985. publishes $S_i$ with a **ZisK proof** whose statement binds: the election, the frozen
 899   $(\text{root}, A_{\text{cast}}, X)$ snapshot, the complete archive commitment, its
 900   recipient index, and the accepted ceremony transcript (§10.3–§10.4) — and whose witness
 901   contains
 902   its KEM key seed (authenticating it as warden $i$ against the registered commitment), the
 903   per-package $(s, K)$ openings **for every counted active package** (each checked against
 904   its admitted $h_{v,i}$), the reconstructed payload keys and payload openings, and its
 905   blinding evaluations. The program enforces **complete, exactly-once processing** of every
 906   admitted package in the archive (counted, consumed, or excluded — nothing skipped) and
 907   that $R$ and $B$ are the values authenticated by the accepted batch payloads.
 908   **The complete archive commitment, concretely**: the **registry itself maintains the
 909   authenticated terminal checkpoint**: on every accepted transition it folds the batch into
 910   a contract-side running accumulator, `archiveAcc' = keccak256(archiveAcc ‖ batchNumber ‖
 911   stateRoot_new ‖ blobsDigest)` (keccak: it is contract-computed — the island rule), and
 912   stores `(archiveAcc, batchNumber)`. At the exclusion freeze this pair is frozen with the
 913   snapshot, and **every contribution proof must bind exactly that frozen pair** — a warden
 914   cannot supply its own batch list and commitment (consistency with a chosen list is not
 915   completeness). The proof re-folds the canonical ordered batch list (batch 0 = the genesis
 916   transition; every accepted batch including zero-ballot initialization transitions and
 917   their payloads) and must reach the frozen accumulator and count; every admitted package
 918   of every batch is processed exactly once. For scale, chunked proving authenticates its
 919   **continuation state** — progress index, the running accumulator AND the partial sums —
 920   between segments; carrying the hash alone does not certify earlier computation.
 9216. `submitTallyShare(processID, i, S_i, publicValues, proof)`; after θ verified shares,
 922   anyone calls `finalizeResults(processID)`: **the registry performs the Lagrange
 923   interpolation on-chain** (θ ≤ 16 points over Goldilocks — a few u64 mulmods per field),
 924   records the per-field results, and emits `ProcessResultsSet`.
 925
 926Wardens run their **own provers**: the witness contains their secrets, and a shared proving
 927service used by θ wardens would itself hold reconstruction capability. Proving cost scales
 928with total casts, and "a few hashes per package" is **not** the honest model: rehashing each
 929`CanonicalPackage` for the archive-commitment check alone costs ≈99 input-block compressions
 930per package at ν=5/ML-KEM-768 (≈314 at ν=16) before Blake3 tree merges, mask regeneration,
 931commitment checks, payload and ceremony verification — so a million-cast tally job is on the
 932order of **10^8–3×10^8 compressions plus bookkeeping** (an **unvalidated projection**, to be
 933benchmarked with the v3 implementation before warden hardware guidance is given). A tracked
 934optimization (§15) is an authenticated per-warden view / preprocessing proof that avoids
 935re-hashing full packages in every warden's proof.
 936
 937### 10.2 Why malformed voter transport cannot corrupt anything
 938**Decapsulation never appears in any tally proof** — contributions open the admitted
 939commitments $h$ instead, and under commitment binding every accepted $S_i$ lies on the same
 940aggregate polynomial. A voter publishing a bad `ct_i` only deprives warden $i$ of its opening
 941witness (warden $i$ complains or sits out; the voter could even re-supply the opening
 942out-of-band, which is safe — correctness is tied to $h$, not to the transport). Every clean
 943θ-subset interpolates the same tally, because the ballot STARK proved all ν shares lie on one
 944valid polynomial. Malformed transport is an availability lever against one warden, never an
 945integrity lever against the election.
 946
 947### 10.3 The zero-blinding ceremony
 948In plain terms: before publishing their partial sums, the participating wardens jointly add
 949noise that cancels out exactly at the finish line (x = 0), so the published sums reveal the
 950result and nothing else. Why it's needed: published raw, θ sum-shares determine the aggregate
 951polynomial $F$; any single warden — participant or not — could evaluate it at its own index,
 952compare with the sum of its decoded per-package shares, and fingerprint the revoked set. The
 953ceremony prevents that:
 954
 9551. A `tallySession` is recorded on-chain: session id = `H(processID ‖ root ‖ X ‖ roster ‖ attempt)`, where `attempt` is a **registry-controlled monotonic nonce** incremented on every restart (the id must change even with an identical roster and snapshot); the registry tracks exactly one active attempt, rejects messages and contributions bound to stale attempts, and fixes the point at which the dealer set becomes immutable,
 956   with the participant roster and dealer set fixed (dealers = the participants).
 9572. Each dealer $k$ samples a seed and derives, per field, blinding coefficients
 958   $c_{k,f,1..\theta-1}$, defining $g_{k,f}(x) = \sum_j c_{k,f,j} x^j$ — **the constant term
 959   is structurally absent, so $g_{k,f}(0) = 0$ by construction** (this is the
 960   "zero-certificate": the committed coefficient vector simply has no degree-0 entry).
 9613. Dealer $k$ publishes (in a session blob): a hiding commitment to its coefficients
 962   (salted unkeyed Blake3, §2.3); **per-recipient hiding evaluation commitments**
 963   $cm_{k,i} = \mathrm{Blake3}(g_{k,1..16}(i) \,\|\, r_{k,i})$; the KEM-DEM ciphertexts to each
 964   co-participant $i$ encrypting $(g_{k,1..16}(i), r_{k,i})$; and a **ZisK dealer proof**
 965   that the committed coefficients, the evaluation commitments, and the ciphertexts are all
 966   consistent, under the recipients' registered keys and this session's context.
 9674. Contributions use $G_f(i) = \sum_{k \in D} g_{k,f}(i)$ over the **accepted dealer set
 968   $D$** — fixed on-chain after the dealer deadline; every contribution proof binds the same
 969   $D$ and session id, and **opens the evaluation commitments $cm_{k,i}$** (the recipient
 970   learned the opening by decapsulating off-circuit — decapsulation still never enters any
 971   tally proof). A dealer whose proof is missing or invalid is excluded and the session
 972   restarts with fresh masks (roster must stay ≥ θ).
 973
 974As long as one accepted dealer is honest, no one outside the ceremony — and no
 975non-participating warden — learns anything about $F$ beyond what the public tally
 976$F(0)$ itself reveals. Participants do jointly learn the
 977revoked set $R$; that is the documented θ-gated metadata leakage (§12.2).
 978
 979### 10.4 The private batch-key exchange and the session state machine
 980
 981The batch-payload keys $k_b$ (§8.5) are θ-of-ν shared; **reconstructing them must not leak
 982them**: publicly releasing enough shares of any $k_b$ reveals $B_b$ and the consumed-package
 983list — exactly the revocation metadata the batch pads exist to conceal. So the share
 984exchange is **private, pairwise and authenticated**, never part of the public transcript:
 985
 986- Each participant sends its share of each needed $k_b$ to each co-participant via
 987  **pairwise KEM-DEM** (encapsulate to the recipient's registered warden key; DEM context
 988  bound to election, batch, session and attempt — §2.1), recipient-authenticated.
 989- A recipient **validates** every received share against the batch's published per-share
 990  commitments before using it. To make that possible, §8.5's payload includes, per
 991  recipient share, a salted Blake3 **share commitment** (bound in the batch proof); the
 992  sender's pairwise message carries the share value and the commitment's salt, so any
 993  recipient can check the opening without decapsulating the sender's ciphertext. An invalid
 994  opening proves the *message* bad — but KEM encryption authenticates the recipient, not the
 995  sender (anyone can encapsulate to a public key), so **the protocol does not claim
 996  cryptographic fault attribution**: a failed exchange (invalid or missing shares, from
 997  whatever cause) simply triggers a restart with a roster-policy-chosen replacement, and
 998  liveness assumes a successfully communicating honest roster. (Sender-authenticated
 999  transport via warden SLH-DSA keys is a tracked hardening, §15.) "Fresh masks" on restart
1000  means fresh ceremony blinding and transport randomness — settled batch keys and batch
1001  pads never change.
1002- Plaintext key shares and reconstructed keys never appear on-chain or in blobs; contribution
1003  proofs reference the payload *openings* (witness), not the keys.
1004
1005**Session state machine** (contract-side): any registered warden of the election may open a
1006`tallySession` after the exclusion freeze; the roster is accepted when θ wardens have joined
1007by the roster deadline; the dealer set $D$ is fixed at that moment (dealers = participants);
1008dealer publications (§10.3) have their own deadline, after which $D$ freezes; a missing or
1009invalid dealer, or a failed share exchange, triggers **restart**: a new session id and
1010attempt id, fresh masks, and automatic **invalidation of all contributions bound to the
1011stale session**. `finalizeResults` accepts only θ distinct wardens' contributions **bound to
1012one accepted session and its frozen dealer set**. Honest framing: **removing the
1013election-key DKG does not remove coordinated cryptographic ceremonies — v3 replaces it with
1014different (smaller, tally-time-only) coordination work.**
1015
1016---
1017
1018## 11. Census and authentication
1019
1020- **Census trees** migrate from Poseidon-BN254 to **Blake3** (a breaking format change; same
1021  lean-IMT structure; membership verified by the batch program, §8.2). Leaf encoding:
1022  `leaf = Blake3(address ‖ weight ‖ pk_PQ)` with `pk_PQ = H(sk)` for a CSPRNG-generated
1023  secret, or `pk_PQ = 0` for a not-yet-enrolled voter (hybrid-legacy censuses only).
1024- **PQ-key enrollment.** The Ethereum wallet signs an enrollment message binding
1025  `address ↔ pk_PQ`; the signature *authorizes* the binding and is never key entropy (a
1026  future ECDSA break must not reveal PQ secrets). Enrollment paths per census origin:
1027  off-chain censuses collect `pk_PQ` at census construction; on-chain/token censuses read a
1028  global **PQKeyRegistry** contract where voters register once (one transaction, reusable
1029  across all elections); CSP censuses include `pk_PQ` in the credential.
1030- **Election auth policy** (immutable registry parameter, fixed at creation):
1031  - `pq-only`: every leaf must carry `pk_PQ`; authentication is the in-STARK preimage proof
1032    alone; no ECDSA anywhere in the ballot path.
1033  - `hybrid`: every leaf must carry `pk_PQ`, and every package is verified on **both**
1034    authenticators — the in-STARK preimage proof *and* `hybridSig` (ECDSA over `pkgDigest`,
1035    verified by the batch program). No OR-downgrade exists in this mode.
1036  - `hybrid-legacy`: like `hybrid`, but leaves with `pk_PQ = 0` are admitted with identity
1037    resting on ECDSA alone; the STARK's auth clause (§6.5) switches to a **self-chosen
1038    package key**: the voter generates `sk_pkg` (CSPRNG; kept with the package opening). The
1039    first package binds `H(sk_pkg)` inside `pkgCommit`. Every later package in the chain
1040    proves knowledge of the *same* `sk_pkg` (predecessor opening) and derives its nullifier
1041    as `NULL = Blake3(nullCtx ‖ sk_pkg ‖ prevPkgDigest)`. The batch program dispatches per
1042    leaf: `pk_PQ ≠ 0` ⇒ both authenticators against the census key; `pk_PQ = 0` ⇒ mandatory
1043    `hybridSig` + the `sk_pkg` clause. Anyone can count the legacy-status census members
1044    (leaf contents are public census data) — though not, of course, which *final* packages
1045    are theirs beyond what slot-participation already reveals. Ballot *privacy* is fully PQ
1046    for these voters; the election's **integrity assumptions include ECDSA security for its
1047    legacy voters** (§12.1). This mode is what makes existing token censuses usable before
1048    universal enrollment.
1049- **Enrollment snapshot rule.** A voter's authentication status and key for an election are
1050  pinned at the election's **creation snapshot**: for on-chain/token censuses the registry
1051  records the PQKeyRegistry root at the creation block, and membership proofs must present
1052  the enrollment status under that snapshot regardless of which (newer) eligibility root the
1053  census contract later accepts. Enrolling *after* an election was created affects
1054  subsequent elections only — an existing package chain never changes keys mid-election.
1055- **CSP censuses**: credentials become SLH-DSA signatures [FIPS 205] over the v2 message
1056  format extended with `pk_PQ`; verification is pure hashing via the SHA-256 precompile
1057  (SLH-DSA's internal SHA-2 is a FIPS island, §2 — not an application-level hash choice).
1058- Slot derivation, participation visibility, census origins 1–4 mechanics: as v2, with the
1059  enrollment additions above. The v2 census invariants (slot uniqueness across the census;
1060  stable distinct CSP indexes) remain assumptions of integrity.
1061
1062---
1063
1064## 12. Security properties, stated plainly
1065
1066### 12.1 What holds, under what
1067
1068| Property | Holds if |
1069|---|---|
1070| **Tally integrity** | STARK/zkVM soundness (FRI + hashes), binding commitments, correct pinned programs, the settlement chain executes the registry, and the v2 census invariants (unique slots / stable CSP indexes). Then no coalition of voters, sequencers, provers or wardens can shift a tally — including via malformed KEM transport (§10.2). |
1071| **Ballot privacy** | fewer than θ warden keys compromised **over their whole lifetime** (not just the active epoch), ML-KEM IND-CCA, PRF/hash security, hiding STARKs, and honest voter devices. Below θ, shares in isolation are information-theoretically independent of the ballot. **Post-quantum computational privacy — not "everlasting"**: an unbounded adversary could attack archived KEM transcripts. |
1072| **Revote hiding (public data)** | hash security + the sealing sequencer/prover draws the batch seed *and the refresh set* from fresh randomness and keeps them secret (v2's exact trust statement). Public data reveals participation per slot, update counts/timing, `numOverwrites` — v2's leakage surface. |
1073| **Exact tally** | unconditional arithmetic (mod-$p$ sums, Lagrange). ML-KEM's residual decapsulation-failure probability (≈2^-139 per pair at ML-KEM-512, ≈2^-164 at -768; election-wide union bound over *all* encapsulations: per-ballot, batch shares, ceremony deliveries) is not zero even for proven-correct encapsulations. Each failure degrades gracefully: a per-ballot failure becomes a complaint; a batch-key *share* failure is tolerated provided at least θ valid shares remain available (with ν=θ, or only θ responsive wardens, one failed share means that payload cannot be reconstructed and the tally cannot complete — size ν above θ accordingly); a ceremony delivery failure excludes the dealer and restarts the session. Deliberately malformed batch transport is a different thing entirely — it is unprovable (§8.5), so it cannot appear in an accepted batch. |
1074| **Liveness** | ≥1 honest sequencer with proving capacity and timely inclusion (as v2), plus ≥θ wardens through the scan window and ceremony (§9.3), plus **continuous archival of the blob history** (blobs prune in ≈18 days; missing payload history prevents tally completion — §4, §9.3), plus complaint capacity sized to the admitted-cast bound (§9.2). |
1075
1076### 12.2 What wardens and insiders learn
1077θ colluding wardens can reconstruct **every package's ballot** — exactly v2's boundary, where
1078θ wardens can decrypt every ballot. New, and narrower: the **tally participants** — a θ-sized set *per attempt*: if a session aborts after key reconstruction and restarts with a different roster, every participant of every attempt that reached reconstruction capability is in the leakage set (fresh blinding cannot revoke knowledge already obtained) — (a θ-sized
1079set) jointly learn the revoked-package set $R$ — metadata, not contents — and any one of them
1080can leak it onward; non-participating wardens and the public learn nothing about $R$ (batch
1081pads §8.4 + blinding §10.3 close those channels, given ≥1 honest accepted dealer). The
1082sequencer/prover that seals a vote learns its revote linkage (§5.4) — as in v2.
1083
1084### 12.3 The honest coercion statement
1085v3 keeps v2's informal posture (no formal receipt-freeness; revotes hidden among refreshes)
1086with **one new residual, stated openly**: a coercer who obtains a package's *revocation
1087token* — by extracting the voter's identity key, **or** by demanding a ZK proof of the
1088token's derivation, **or** a valid unsubmitted revote authorization — can watch the public
1089nullifier tree and detect whether that package was later consumed. v2's re-encryption resists
1090even that (testing re-encryptions is a DDH-type problem). This is the main new
1091coercion-relevant difference from v2 (alongside the §12.2 participant metadata); mitigations
1092are Track-2 research (§15). Deployments for coercion-sensitive elections should weigh it.
1093
1094### 12.4 Proof-system notes
1095The pinned ballot STARK profile targets **≈106-bit** *conjectured* FRI soundness (18 queries × log₂32 + 16 grinding bits; ethSTARK heuristic
1096[ETHS]) — an explicit engineering dial (queries × log-blowup + grinding), to be raised for
1097high-stakes deployments, and **not** claimed as 128-bit PQ security. The Blake3
1098Merkle/challenger layer uses **full** Blake3 (7 rounds is the standard, not a reduction) with
1099256-bit digests: ~128-bit classical collision resistance — adequate for the classical target
1100above — while generic *quantum* collision bounds on any 256-bit hash are ~2^85 query bounds
1101(BHT is the generic quantum collision-search algorithm — a query-count bound under heavy memory assumptions, not a practical attack cost); the profile is therefore justified against the
1102classical conjectured target, not claimed as ≥102-bit end-to-end quantum security (the same
1103caveat applies to a Poseidon2 profile). The ~2^85 figure concerns **collision resistance —
1104commitments and binding**; it does not mean 256-bit *keys* have 85-bit confidentiality
1105(generic quantum key search is the Grover ~2^128 regime). The v2-era prototype's
1106three known defects (weight-bound bypass at `maxValueSum=0`; wraparound-prone comparators;
1107weak hiding-PCS blinding RNG with a constant fallback seed) are normatively fixed in v3
1108(§6.1; 256-bit CSPRNG blinding seed, fail-closed).
1109
1110**Where Poseidon2 still lives, honestly.** Blake3 replaces Poseidon2 in application hashing
1111and the ballot proof system. Poseidon2 remains an **inherited ZisK proof-system dependency**:
1112a break there may compromise accepted state transitions and tally integrity, and can thereby
1113compromise privacy *during protocol execution* (e.g. forged transitions could mark packages
1114consumed without authorization and mislead honest wardens into revealing a skewed aggregate).
1115Passive confidentiality of archived ballot transport and masking no longer relies on
1116application-level Poseidon2. "Repairable" means future executions can migrate to a repaired
1117verifier — not that past disclosures or finalized decisions can be undone. Why the move: the
1118Poseidon2 cryptanalysis landscape is young and moving — round-estimate revisions [TOSC25],
1119the EF Poseidon attack-reward program [PINIT], and the FreeLunch family of algebraic attacks
1120on arithmetization-oriented primitives [FL24] — while Blake3 carries long-standing ARX
1121analysis. This is a conservatism call, not a response to any full-round break.
1122
1123**Every published proof must be hiding, not merely sound.** The ballot STARK is not the only
1124proof carrying secrets: batch proofs (batch seeds, pads, revocation data), complaint proofs
1125(warden key seeds), dealer proofs (blinding coefficients), warden contributions (KEM seeds,
1126shares, payload keys) and key-registration proofs all have sensitive witnesses. Each proof
1127profile must therefore be verified to be **zero-knowledge/hiding**, not only sound. Known
1128status: the BN254 PlonK wrapper applies explicit blinding; the hiding of ZisK's *native*
1129VADCOP-final STARK path (ZisK's last recursion stage, the proof the wrapper wraps) is **unverified** — which makes "drop the wrapper for direct STARK
1130verification" (§15) a **privacy question, not only a cost change**.
1131
1132### 12.5 Out of scope / inherited
1133EIP-4844 KZG commitments (Ethereum's own PQ roadmap), organizer/sequencer Ethereum accounts,
1134hybrid-mode ECDSA (by construction), and the BN254 PlonK wrapper around ZisK proofs. These
1135classical dependencies are **integrity-critical — and an integrity failure during execution
1136can compromise privacy (§12.4)**; what they cannot do — provided the published proof paths
1137retain their required hiding and the KEM/PRF assumptions hold — is retroactively decrypt
1138archived ballots (breaking a proof system's *soundness* does not by itself recover
1139witnesses). The wrapper is replaceable by direct on-chain STARK verification (indicative public
1140data point: ~5–6 MGas for a WHIR/FRI verifier on the EVM [WHIR]; not a measured cost for ZisK
1141proofs; and a privacy-gated change, §12.4) — tracked as the final migration phase.
1142
1143---
1144
1145## 13. Cost summary
1146
1147| Metric | v2 | v3-PQ (estimates unless marked measured) |
1148|---|---|---|
1149| Browser proving | seconds (Groth16, 35.5 MiB key download) | projected ~2–4 s native (ν-dependent, re-laid full-Blake3 AIR at the blowup-32 profile, §6 — needs recalculation/benchmark against the §2.2 stream-masking counts; no key download; the Blake3-trees prototype measured 0.69 s native at blowup 8) |
1150| Ballot upload to sequencer | ~2 KB | ~20 KB package + ~195 KB proof (proof not stored on-chain) |
1151| DA per ballot | ~2 KB | 1.7–20.5 KB depending on ν and KEM (§8.6 table) |
1152| DA per refresh | ~1–2 KB | 40 B (framed) |
1153| Batch proving | 2.3–4.0×10^8 steps | **+ ≈0.30 s GPU per ballot for in-guest STARK verification (measured on RTX 5090 after the optimization pass: 32 verifications proven in 19.8 s; 2.62M steps each, §8.1)** — 256-ballot batches ≈ 2–3 min total; state-tree hashing −30%/byte vs v2's SHA-256; commitment recomputations +13% vs a Poseidon2 precompile |
1154| Tally | θ partial decryptions of one accumulator + BSGS | archive-linear warden jobs (§10.1) + one ceremony + on-chain Lagrange |
1155| Registry tally cap | 10^12 | 2^61 |
1156
1157---
1158
1159## 14. Errors and edge cases (normative)
1160
1161- **voteID collision** (admission finds the leaf occupied): resample `k` (recovery mode:
1162  bump the counter) and re-cast — as v2. Skipped counters are harmless (§5.2 recovery scan).
1163- **Unsettled predecessor**: a revote consuming a predecessor not yet settled under the
1164  batch's starting root is rejected at admission and retried by the sequencer in a later
1165  batch automatically; clients should submit revotes to the sequencer that holds their
1166  pending vote, as in v2.
1167- **Duplicate revocation race** (two sequencers hold revotes of the same package): the first
1168  settles; the loser's re-validation drops the vote at admission (nullifier present) and
1169  notifies the voter — the v2 "voteID already in state" pattern.
1170- **Live package excluded** ($P_t \in X$): the client detects it (public $X$) and informs
1171  the voter they are not counted; no recovery within the election (casting is closed when
1172  complaints run).
1173- **Warden key unavailable at cast time**: the client refuses to cast (it cannot build a
1174  complete package); election creation already requires all ν keys registered (§4).
1175- **Ceremony dealer failure**: dealer excluded, session restarted with fresh masks (§10.3);
1176  if the roster drops below θ, the tally is lost — counted under liveness (§9.3).
1177
1178---
1179
1180## 15. Tracked upgrades
1181
11821. **STARK-friendly verifiable encryption** (RLWE-LPR with a Blake3-based FO transform) to
1183   prove warden transport at admission — removes the complaint window entirely. Requires its
1184   own security review before adoption.
11852. **PQ re-randomizable package representation** — would restore v2-grade resistance to
1186   revocation-token coercion (§12.3). Open research.
11873. **Locked mode** as a separately specified and reviewed extension (§4).
11884. Direct on-chain STARK verification (drop the PlonK wrapper) once rollup gas permits —
1189   **gated on establishing the native proof path's hiding, not only its cost** (§12.4).
11905. Classic McEliece transport profile for large committees [MCE].
11916. **Batched complaint proofs / proof-certified exclusion-root updates** for large elections
1192   (one proof excluding many packages, with precise completeness and deadline semantics) —
1193   the per-complaint path is O(admitted casts) in the worst case (§9.2).
11947. **Authenticated per-warden views / preprocessing proofs** so warden contributions don't
1195   re-hash every full `CanonicalPackage` (§10.1 cost model).
11968. **Per-election warden keys** as an operational-lifecycle option: the §12.1 *lifetime*
1197   key-compromise assumption means rotating epochs does not protect old ballots if old
1198   secrets survive; per-election keys plus specified destruction (including backups) make the
1199   retention story auditable.
1200
1201**First implementation target (from the external design review).** A complete, reproducible
1202**3-of-5, ML-KEM-768 end-to-end election prototype** — browser casting through settlement,
1203complaints, exclusions, the private ceremony, warden proofs, and on-chain finalization —
1204with these measured gates: the complete 16-field ballot relation including the revote path,
1205production hiding randomness, the exact pinned proof profile verified inside ZisK, full
1206batch proving cost, complaint throughput under adversarial load, and the complete warden
1207tally job (archive authentication included). Browser latency/memory and deployment limits
1208(electorate sizes, committee sizes, deadlines, hardware) are derived from those measurements
1209— not from component benchmarks.
1210
1211---
1212
1213## 16. References
1214
1215- [DAV2] Vocdoni, *DAVINCI protocol specification v2*. https://spec.davinci.vote
1216- [FIPS 203] NIST, *Module-Lattice-Based Key-Encapsulation Mechanism Standard (ML-KEM)*, 2024. https://doi.org/10.6028/NIST.FIPS.203
1217- [FIPS 205] NIST, *Stateless Hash-Based Digital Signature Standard (SLH-DSA)*, 2024. https://doi.org/10.6028/NIST.FIPS.205
1218- [Sha79] A. Shamir, *How to Share a Secret*, CACM 22(11), 1979.
1219- [DST] Vocdoni, *davinci-stark: Plonky3 ballot proof prototype*. https://github.com/vocdoni/davinci-stark
1220- [P3] Polygon Zero, *Plonky3*. https://github.com/Plonky3/Plonky3
1221- [ZISK] Polygon, *ZisK zkVM*. https://github.com/0xPolygonHermez/zisk
1222- [POS2] L. Grassi et al., *Poseidon2: A Faster Version of the Poseidon Hash Function*, ePrint 2023/323.
1223- [TOSC25] *Poseidon and Neptune: Gröbner Basis Cryptanalysis Exploiting Subspace Trails*, IACR ToSC. https://tosc.iacr.org/index.php/ToSC/article/view/12244
1224- [FL24] A. Bariant et al., *The Algebraic FreeLunch: Efficient Gröbner Basis Attacks Against Arithmetization-Oriented Primitives*, CRYPTO 2024 (ePrint 2024/347).
1225- [PINIT] Ethereum Foundation, *Poseidon Initiative — cryptanalysis attack reward program*. https://www.poseidon-initiative.info
1226- [B3] J. O'Connor, J.-P. Aumasson, S. Neves, Z. Wilcox-O'Hearn, *BLAKE3: one function, fast everywhere*. https://blake3.io
1227- [ETHS] StarkWare, *ethSTARK Documentation*, ePrint 2021/582.
1228- [EIP4844] V. Buterin et al., *EIP-4844: Shard Blob Transactions*, 2022.
1229- [IR89] R. Impagliazzo, S. Rudich, *Limits on the Provable Consequences of One-Way Permutations*, STOC 1989.
1230- [NOAH] M. Dahl et al., *Noah's Ark: Efficient Threshold-FHE Using Noise Flooding*, WAHC/CCS 2023.
1231- [TEV] J. Alizadeh, *Threshold Post-Quantum E-Voting from Lattice Commitments*, ePrint 2026/2500.
1232- [PQK] N. Huber et al., *PQKryvos: Post-Quantum Secure E-Voting With Flexible Ballot Formats and Public Tally-Hiding*, PoPETs 2026.
1233- [MCE] D. J. Bernstein et al., *Classic McEliece*. https://classic.mceliece.org
1234- [KEMB] *ML-KEM WebAssembly implementations and benchmarks*. https://github.com/dchest/mlkem-wasm
1235- [WHIR] *EVM Verification of WHIR over a 31-bit Field*, ethresear.ch, 2025.