davinci-paper/v3-pq/spec.md
v3-pq/spec.mdRaw
1# DAVINCI v3-PQ — Post-Quantum Protocol Specification
2
3**Status:** draft v1.1 · 2026-10-20 · **unified Blake3 profile** (supersedes v1.0's
4mixed Poseidon2/SHA-256/Blake3 profile) · v2 remains the deployed protocol. Reviewed: three
5adversarial soundness rounds (protocol reviewer) + audience-representative sign-off; a final
6consolidated review gates implementation (Phase 0 of the migration plan).
7**Audience:** engineers who already know [DAVINCI v2](https://spec.davinci.vote). This document only
8specifies what *changes*. Everything not mentioned here (settlement flow, grace window, blob
9verification via the point-evaluation precompile, census origins, sequencer lifecycle, process
10registry mechanics) works exactly as in v2 [DAV2].
11
12---
13
14## 1. Why v3, in one paragraph
15
16Every ballot DAVINCI v2 publishes in Ethereum blobs [EIP4844] is an ElGamal ciphertext over
17BabyJubjub. Published blob data can be archived by anyone indefinitely, and ElGamal falls to
18Shor's algorithm — so a future quantum computer decrypts **past elections retroactively**
19("harvest now, decrypt later"). Integrity is less urgent (a settled chain cannot be rewritten
20under Ethereum's finality assumptions), but **ballot privacy must be post-quantum today**.
21v3-PQ removes the quantum-vulnerable primitives from the ballot *confidentiality* path: no
22shared-key homomorphic encryption, no pairings, no DKG, no Groth16. Ballot secrecy rests on
23polynomial secret sharing, hashes, STARKs, and one NIST-standardized KEM (a post-quantum
24"public-key lockbox" — all such terms are defined plainly in §2.4). The KEM is never
25proven inside the voter's circuit (the batch guest performs encapsulations, and rare complaint
26proofs perform decapsulations; see §8.5, §9.2). During the hybrid period voter authentication
27still *also* uses ECDSA (§11), and the settlement wrapper and KZG blob commitments remain
28inherited non-PQ dependencies (§12.5).
29
30### Changes at a glance
31
32| Component | v2 | v3-PQ |
33|---|---|---|
34| Ballot confidentiality | ElGamal over BabyJubjub (threshold key) | Shamir shares + PRF masks over KEM transport (§3) |
35| Ballot proof | Groth16 over BN254 (circom, trusted setup) | Plonky3 STARK over Goldilocks, browser WASM (§6) |
36| Election key | DKG / council ceremony (BabyJubjub) | **None.** Wardens register ML-KEM keys (§4) |
37| Tally | Threshold decryption + BSGS search | Lagrange interpolation of θ proven warden sums (§10) |
38| Running tally | Homomorphic ciphertext accumulator | Padded plain-sum accumulator over Goldilocks (§8.4) |
39| Silent revoting | Re-encryption of stored ciphertexts | Hash-chained opaque slot leaves (§7) + padded accumulator |
40| Revotes | Slot overwrite + ciphertext subtraction | One-live-chain packages + revocation nullifiers (§5.3) |
41| Voter authentication | ECDSA (secp256k1) | Hash-preimage proof in-STARK; `hybrid` verifies **both**; `hybrid-legacy` admits unenrolled voters on ECDSA (§11) |
42| CSP credentials | ECDSA | SLH-DSA (SPHINCS+) [FIPS 205] |
43| Batch proof | ZisK, verifies Groth16 (BN254 precompiles) | ZisK [ZISK], verifies ballot STARKs (Blake3 precompile) |
44| Protocol hash | Poseidon (circuits) + SHA-256 (state) + Keccak (Ethereum) | **Blake3 everywhere the protocol chooses** (§2); keccak/SHAKE/SHA-2 survive only as fixed islands |
45| Tally bound | maxValue·maxVoters ≤ 10^12 (BSGS limit) | ≤ 2^61 (field headroom; no search) |
46
47
48
49---
50
51## Protocol intuition — read this first
52
53*A plain-English walkthrough of a v3 election, phase by phase, mapped onto the v2 flow you
54already know. Every term used loosely here gets a precise definition from §2 onward; the
55jargon cheat-sheet is §2.4.*
56
57**Setup.** The organizer creates the election exactly as in v2 — census, ballot rules,
58duration. One thing changed: instead of waiting for a key ceremony, the organizer points at a
59committee of ν key wardens (say 5, or 16), each of which has already published a post-quantum
60"lockbox" public key: anyone can lock a small secret so that only that warden can open it.
61There is **no election encryption key** — nothing is generated jointly, and v2's whole DKG
62phase is simply gone.
63
64**Casting.** The voter's browser takes each ballot value and splits it into ν puzzle pieces,
65one per warden, using the Shamir trick: any θ pieces (the *threshold* — e.g. 3 of 5) fit
66together to reconstruct the value, while θ−1 or fewer are pure noise that says nothing at
67all. The browser then hides each piece under a one-time mask (a random-looking number added
68to it), locks each mask key into the matching warden's lockbox, and attaches a STARK proof —
69generated right there in the browser — that the whole construction is consistent: the pieces
70encode one valid ballot that follows the election rules, the masks match their commitments,
71and the voter is who they claim to be. The published vote (a *package*) is just masked
72pieces + locked boxes + commitments. Everything visible is noise; nothing about the choice
73can be read from it, now or ever, by anything short of θ wardens cooperating.
74
75**Voting period.** Sequencers collect packages and settle batches with a zkVM proof, as in
76v2. The chain maintains one new object: a public **running total** — for each warden, the sum
77of all masked pieces addressed to it. Adding masked numbers keeps them masked, so the running
78total is public yet unreadable. A revote cancels the voter's previous package through an
79unlinkable **nullifier** (same idea as Tornado/Semaphore nullifiers), and the batch proof
80subtracts the old package's pieces from the running total. Meanwhile, refreshes keep
81re-hashing slot entries so an outside observer still cannot tell who revoted — v2's "silent
82revoting", achieved by different means.
83
84**End of election.** After the grace window come two short new phases: first a
85**complaint window**, where any warden that finds a broken package — a lockbox that doesn't
86open to what was promised — can prove that on-chain and have the package excluded; then the
87exclusion list freezes.
88
89
90
91**Results.** Any θ wardens now each do one job: open all their lockboxes, strip their own
92masks off their column of the frozen running total, and publish the resulting **partial
93sum** — with a proof that they did exactly that and nothing else. The punchline: those θ
94partial sums are θ points on a single polynomial, and that polynomial's value at zero *is*
95the exact election result. The smart contract draws the unique curve through the θ points and
96reads it at zero — ordinary integer math, done on-chain. No decryption ever happens, because
97there is nothing to decrypt.
98
99
100
101What this buys you:
102- **There is no decryption key.** Not distributed, not threshold-shared — it does not exist,
103 and neither does the ceremony machinery that managed it in v2.
104- **Harvest-now-decrypt-later is dead below θ wardens.** The published pieces are
105 information-theoretic noise; the only cryptography protecting them is the lockboxes
106 (ML-KEM) and hashes — both post-quantum.
107- **Every step is proof-checked** — browser proof, batch proof, warden proofs — so voters,
108 sequencers and wardens are checked, not trusted, for correctness.
109- **The tally is exact integer arithmetic.** No decryption failures, no noise budgets, no
110 brute-force search at the end.
111
112---
113
114## 2. Notation, parameters and encodings
115
116- $\mathbb{F}$ — the **Goldilocks field**, $p = 2^{64} - 2^{32} + 1$ (the Plonky3 [P3] and ZisK
117 native field). All shares, masks and tally arithmetic live here. Canonical encoding of an
118 element: 8 bytes little-endian, value < $p$.
119- $\nu$ — number of **key wardens**; $\theta$ — tally threshold ($1 \le \theta \le \nu \le 16$;
120 the cap matches v2 committee/council sizes, and data availability cost is linear in ν).
121- `nf` — active ballot fields, 1..16, as in v2. A ballot is a vector $b_1..b_{16}$; fields
122 beyond `nf` are **inactive and MUST be 0** (enforced by the ballot proof; their shares are
123 shares of 0).
124- **KEM** — ML-KEM-768 [FIPS 203] (ct 1088 B) by default; ML-KEM-512 (ct 768 B) is an allowed
125 profile for DA-sensitive deployments. One *encapsulation* yields `(ct, K)` with a 32-byte
126 shared secret `K`; arbitrary payloads are carried KEM-DEM style (encapsulate, derive a
127 wrapping key from `K`, then DEM-encrypt — §2.1).
128- **Blake3** — standard Blake3 [B3] is **the protocol hash, everywhere the protocol gets to
129 choose**: the ballot STARK's Merkle trees and Fiat–Shamir challenger; all in-circuit
130 hashing (PRF masks, commitments, voteID, nullifiers — via a re-laid Blake3 AIR section,
131 §6); the census tree; the state SMT and the nullifier SMT; `pkgDigest`/`ctsDigest`; and
132 every DEM/PRF/key-derivation role through Blake3's standard *keyed*, *derive_key* and
133 *XOF* modes (§2.1). Digests are 32 bytes. Rationale: fastest software hash in the browser
134 (~1.4 GB/s in WASM; measured on the prototype: proving 3.24 s → 0.69 s, proofs
135 544 → 324 KB), a standard-conformant ZisK precompile (`blake3f`) for every guest
136 recomputation, and a conservative, long-studied ARX design (§12.4). One hash = one
137 implementation to audit on each platform (AIR, guest, browser, warden).
138- **Hash islands the protocol cannot choose**, stated plainly: **keccak256** for values
139 Solidity contracts must compute (blob evaluation points $z_b$, the v2 processID prefix,
140 the origin-3 running registration commitment of §8.2) and for hybrid-mode Ethereum
141 addresses; **SHAKE** inside ML-KEM and **SHA-2** inside SLH-DSA (FIPS-fixed internals of
142 black-box primitives); **Poseidon2** inside ZisK's own prover (an inherited proof-system
143 dependency — framing in §12.4; [POS2]). Poseidon2 and SHA-256 hold **no
144 application-level role** in v3.1.
145- **256-bit values in circuits** (DEM keys, Blake3 digests crossing into Goldilocks
146 arithmetic): encoded as **eight 32-bit limbs**, each range-checked < 2^32. Never as four
147 64-bit limbs (not injective: $p^4 < 2^{256}$), and never reduced mod $p$.
148
149### 2.1 DEM (authenticated encryption for warden payloads)
150
151Built from Blake3's standard modes, normative for **every protocol payload** (voter→warden is
152pure KEM+PRF and needs no DEM; this DEM covers batch payloads, batch-key share wrapping, and
153ceremony deliveries):
154- **Key separation**: `k_enc = Blake3.derive_key("davinci v3-pq DEM enc key", K)` and
155 `k_mac = Blake3.derive_key("davinci v3-pq DEM mac key", K)` — fixed application context
156 strings, exactly the standard derive_key mode. `derive_key` creates *separation, not
157 entropy*: `K` must be a ≥256-bit KEM secret or CSPRNG secret.
158- **Keystream**: keyed-Blake3 **XOF** — `keystream = Blake3.keyed(k_enc, nonce ‖ AAD).xof()`,
159 with the counter being the XOF output offset (bounded: payloads < 2^32 blocks, no offset
160 wraparound); ciphertext = plaintext ⊕ keystream. An XOF is a seekable output stream, not
161 repeated hashing of previous output.
162- **Authentication**: encrypt-then-MAC — `tag = Blake3.keyed(k_mac, nonce ‖ AAD ‖ ciphertext)`;
163 receivers verify the **full 32-byte tag before releasing any plaintext**.
164- **Uniqueness**: `nonce = Blake3(AAD)`; the AAD is the canonical, length-unambiguous
165 serialization of a **DEM context** that always includes a purpose tag, the election
166 context, the **batch number or ceremony (session, attempt) identifier**, sender and
167 recipient — unique per encryption *including retries* (a ceremony restart is a new attempt
168 id ⇒ fresh masks, keys and nonces; the same derived key and nonce never encrypt two
169 different plaintexts).
170
171Honest label: these are standard Blake3 modes, but their composition is a
172**protocol-specific authenticated-encryption construction — not a standardized AEAD**; the
173needed assumption is keyed-Blake3's PRF security (§12.4). AES-256-GCM may be used by clients
174for unrelated local storage/transport, never as a substitute encoding of protocol payloads.
175
176### 2.2 Domain-separated contexts
177
178Every derived value uses a purpose-tagged context; nothing is derived without one. Purpose
179tags map to Blake3 `derive_key` context strings; the tuple itself is serialized canonically
180(fixed order, length-prefixed variable fields).
181
182| Purpose | Context contents |
183|---|---|
184| `pkgCtx` — the package context tuple | `(protocolVersion, chainID, registry, processID, wardenEpoch, voteID)` — the common prefix below |
185| `maskCtx(i, f)` — PRF pad for masked shares | `("v3/mask", pkgCtx, recipient i, field f)` |
186| `hCtx(i)` — share/pad commitment | `("v3/hcommit", pkgCtx, recipient i)` |
187| `commitCtx` — package commitment | `("v3/pkgcommit", pkgCtx)` — the `ctx` argument of `pkgCommit` (§5.1) |
188| `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. |
189| `slotCtx` / `refreshCtx` — slot leaves | `"davinci-slot-v3"` / `"davinci-refresh-v3"` (§7) |
190
191The package's mask nonce is its **voteID** — public, unique per package, authenticated, and
192independent of the masked values (it derives from the secret `k`, §5.2, before any masking),
193so wardens can recompute every `maskCtx` from public data with no circularity.
194
195**Byte→field mapping (normative).** Blake3 outputs bytes; masks and other derived field
196elements are obtained as **LE128 of 16 XOF bytes, reduced mod $p$** — statistical distance
197from uniform ≈ $2^{-96}$, negligible. Never `LE64(8 bytes) mod p`: its distance is
198≈ $2^{-32}$, which is not.
199
200### 2.3 Protocol parameters
201
202| Parameter | Value | Why |
203|---|---|---|
204| Share/tally field | Goldilocks $p$ | native in the ballot AIR and ~native u64 in ZisK guests |
205| 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`) |
206| **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 |
207| Warden evaluation points | $x_i = i$, $i \in 1..\nu$ | Shamir positions, pairwise distinct, nonzero |
208| 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) |
209| Max refreshed slots per batch | 2048, rule as v2 | unchanged |
210| Nullifier tree | Blake3 SMT, depth 256 | full-width nullifiers (no truncation into the 64-bit key space) |
211| Ballot STARK profile | Goldilocks, blowup 8, 34 FRI queries, hiding PCS, **Blake3 everywhere** (Merkle/challenger AND the in-AIR hashing section) | ≈102-bit conjectured FRI soundness (§12.4); profile pinned in full by `ballotVKHash` |
212| 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 |
213
214### 2.4 Terminology for software engineers
215
216Plain definitions, anchored in things an Ethereum engineer already knows. Skim once; the rest
217of the document assumes them.
218
219- **KEM** (Key Encapsulation Mechanism; here **ML-KEM**, the standardized Kyber) — a
220 public-key *lockbox*: anyone can "encapsulate" against your public key and obtain a fresh
221 32-byte shared secret plus a ciphertext; only you (with the private key) can recover that
222 secret from the ciphertext. Think of it as the post-quantum replacement for ECDH key
223 exchange — except there is no shared-curve math and the two parties never need to be online
224 together.
225- **PRF** (pseudorandom function) — a keyed hash used as a deterministic random-number
226 generator: same key + input ⇒ same output, and without the key the outputs are
227 indistinguishable from random. Mentally: `keccak256(key, input)` used the way you'd use a
228 seeded RNG. Here PRFs expand a KEM secret into the masks that hide shares.
229- **Shamir secret sharing** — split a value into ν pieces by choosing a random polynomial of
230 degree θ−1 whose value at x=0 is the secret, and handing out its values at x=1..ν. Any θ
231 pieces determine the polynomial (and hence the secret); any θ−1 pieces are statistically
232 independent of it — noise, not "hard to crack".
233- **Threshold θ-of-ν** — ν parties hold pieces; any θ of them suffice to act (here: tally);
234 fewer than θ learn nothing and can block nothing except by being too few.
235- **Lagrange interpolation** — given θ points, there is exactly one polynomial of degree
236 ≤ θ−1 through them; evaluating it at x=0 recovers a Shamir secret. "Draw the unique curve
237 through the points, read it at zero." A few multiplications and additions — cheap even in
238 Solidity.
239- **STARK** — a zero-knowledge proof system built only from hashes (no trusted setup, no
240 elliptic curves, post-quantum). Bigger proofs than Groth16 (hundreds of KB), but
241 browser-provable and cheap to verify.
242- **AIR** — the constraint system of a STARK: its "circuit".
243- **FRI** — the polynomial-checking engine inside a STARK; the reason STARK verification is
244 mostly hashing.
245- **Hiding PCS** — the polynomial commitment inside the STARK is randomized so the proof
246 leaks nothing about private inputs; this is what makes the proof *zero-knowledge* rather
247 than merely succinct.
248- **Witness** — the prover's private inputs (the ballot, the shares, the keys). Never leaves
249 the prover.
250- **Nullifier** — a one-way tag published to mark something as spent without revealing what;
251 exactly the Tornado Cash / Semaphore pattern. Here: marks a vote package as replaced.
252- **Accumulator** (as used here) — just a running sum vector of field elements maintained by
253 the batch program. *Not* an RSA or Merkle accumulator.
254- **Blake3** — a modern general-purpose hash: ARX design (add–rotate–xor, the ChaCha/BLAKE/
255 BLAKE2 lineage; BLAKE was a SHA-3 finalist), extremely fast in software, with standard
256 built-in modes for keyed hashing (MAC), key derivation (`derive_key`) and arbitrary-length
257 output (XOF). v3's single protocol hash.
258- **DEM / AEAD** — symmetric authenticated encryption (ciphertext + tamper-proof tag), the
259 AES-GCM role; v3 instantiates it from Blake3's keyed + XOF modes so one hash covers it and
260 zk-proofs about it stay cheap (§2.1).
261- **Domain separation** — namespacing every hash/PRF input with a purpose tag and context so
262 a value from one context can never be replayed in another — the same reason EIP-712 typed
263 signing exists (§2.2).
264- **Dealer** — a party that generates a secret and distributes shares of it (used in the
265 tally ceremony, §10.3).
266- **CSPRNG** — a cryptographically secure random generator (`crypto.getRandomValues`,
267 `/dev/urandom`); "fresh CSPRNG randomness" means sampled from this, never derived.
268
269---
270
271## 3. The core idea: tally without a decryption key
272
273v2 hides a ballot inside a ciphertext and adds ciphertexts homomorphically. v3 hides a ballot
274inside **polynomials** and adds polynomials. If you know Lagrange interpolation, you know the
275whole trick:
276
2771. For each ballot field value $b$, the voter picks a random polynomial $f$ of degree
278 $\theta-1$ with $f(0) = b$, and computes one **share** per warden: $s_i = f(i)$. Any
279 $\theta$ shares reconstruct $b$; any $\theta-1$ shares are statistically independent of
280 $b$. Plain Shamir [Sha79]: no curves, just polynomial evaluation in $\mathbb{F}$.
2812. Shares are never published in the clear. The voter publishes **masked shares**
282 $e_i = s_i + \mathrm{PRF}(K_i, \mathrm{maskCtx})$, where the pad key $K_i$ travels to
283 warden $i$ inside an ML-KEM ciphertext. To everyone except warden $i$, $e_i$ is a
284 uniformly random field element.
2853. Polynomials add: the per-field sum of every active voter's polynomial is itself a
286 degree-$(\theta-1)$ polynomial whose value at 0 is the **tally**. So the protocol only
287 ever needs to add public field elements. The batch program maintains a public
288 **accumulator** $A \in \mathbb{F}^{\nu \times 16}$: coordinate $(i, f)$ is the running
289 sum of the masked shares addressed to warden $i$ for field $f$ (plus batch pads, §8.4).
2904. At the end, each participating warden decapsulates its KEM ciphertexts, subtracts its pads
291 from its row, and publishes its **sum-share** $S_i$ — with a ZisK proof that it did exactly
292 that against on-chain-committed data. Lagrange interpolation of any $\theta$ published
293 sum-shares at $x=0$ **is** the tally. Exact field arithmetic: no decryption of any
294 aggregate, no noise, no discrete-log search.
295
296
297
298(*This section is the intuition; the full computation also handles the exclusion set, batch
299pads, and a blinding term — §9–§10.*)
300
301The ballot STARK (§6) makes steps 1–2 trustworthy, the batch proof (§8) step 3, the warden
302proofs (§10) step 4. **The zkVM proof chain replaces the homomorphic algebra** — the
303structural difference from academic PQ voting designs ([TEV], [PQK]), which obtain the same
304guarantee from lattice commitments. (Some public-key encryption is unavoidable for ballots
305addressed to offline wardens [IR89]; v3 confines it to KEM transport. Threshold *lattice*
306decryption — the known hard part of lattice voting [NOAH] — is avoided entirely: the
307threshold lives at the plaintext layer.)
308
309Privacy in one sentence: below $\theta$ colluding wardens, shares are information-theoretically
310useless in isolation, and the computational assumptions protecting ballots are ML-KEM, the
311PRF/hash, and the zero-knowledge of the STARKs — all post-quantum (full leakage model: §12).
312
313---
314
315## 4. Roles: what changed
316
317- **Organizer, sequencers, provers, observers** — unchanged from v2.
318- **Key wardens** no longer run a DKG or hold shares of a secret key. Per *epoch*, each warden
319 generates an ML-KEM keypair and calls the **WardenRegistry** contract with: `H(pk)`, a URI
320 where the full public key is served (IPFS or HTTPS), and a ZisK **well-formedness proof**
321 (the key pair derives from a committed seed and passes an encaps/decaps self-test). The
322 registry verifies the proof on-chain. An election pins its committee in `wardenSetHash`
323 (config leaf `0x3`, §7): `(ν, θ, epoch, the ν registered H(pk) values)`. A voter's client
324 fetches the ν public keys (from their URIs or any sequencer), recomputes each `H(pk)` and
325 the set hash, and verifies it against the on-chain value before casting; it refuses to cast
326 otherwise. The registry refuses to create an election whose warden set is not fully
327 registered. During the election wardens do nothing; at the end they run one archive scan,
328 optional complaints, and one tally ceremony (§9–§10).
329- **Key modes.** *Committee* (lottery over registered operators) and *council*
330 (organizer-invited set) map 1:1 from v2 — they only select *which* registered warden keys
331 form the set. *Sequencer mode* is the degenerate $\nu = \theta = 1$ case (the sequencer is
332 the only warden; ~1 KB per ballot — cheaper than v2). **Locked mode is deferred**: it
333 requires an organizer-side share column and a separately reviewed extension of the tally
334 equations; it is not part of v3.0.
335
336---
337
338## 5. The ballot package
339
340A vote is one **package**. Its public part goes into blobs; its private part exists only in
341the voter's browser — except the *revote metadata* the chosen sequencer needs (§5.4).
342
343
344
345### 5.1 Public package contents and CanonicalPackage
346
347| # | Field | Size (ν=16, ML-KEM-768) | Description |
348|---|---|---|---|
349| 1 | `version` | 1 B (`0x03`) | package format version |
350| 2 | `processID` | 31 B | as v2 |
351| 3 | `voteID` | 8 B LE | §5.2; also the package's mask nonce (§2.2) |
352| 4 | `E` | ν·16·8 B = 2,048 B | masked shares, row-major (warden-major, field-minor), canonical LE |
353| 5 | `cts` | ν·1,088 B = 17,408 B | ML-KEM ciphertexts, warden order 1..ν |
354| 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) |
355| 7 | `pkgCommit` | 32 B | $\mathrm{Blake3}(\mathrm{commitCtx} \,\|\, slot \,\|\, pk_{\text{voter}} \,\|\, \mathrm{prevPkgDigest} \,\|\, \mathrm{sharesDigest} \,\|\, \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 |
356| 8 | `hybridSig` | 65 B or absent | hybrid mode only: ECDSA over `pkgDigest`, Ethereum personal-message format (§11) |
357
358`CanonicalPackage` = the concatenation of fields 1–7 exactly as listed (fixed order, fixed
359sizes, no framing). **`pkgDigest = Blake3(CanonicalPackage)`** is the package's chain
360identity: it is the value stored at the vote-ID leaf, the input to revocation nullifiers, and
361what complaints reference. **`sharesDigest = Blake3(h_1 ‖ … ‖ h_ν)`** — despite the name it
362binds the shares *through* the per-warden commitments $h_i$ (each AIR-bound to the exact
363$(s_i, K_i)$ used in masking, fixed order and count), which is equivalent binding at an
364eighth of the in-circuit hashing cost. The ballot STARK (~325 KB) accompanies the package to
365the sequencer but is **not** published in blobs.
366
367### 5.2 Construction (browser, pseudocode)
368
369```text
370k = fresh random scalar (or PRF(sk, "v3/k", processID, counter) in recovery mode)
371voteID = N + trunc63(Blake3("v3/voteid" || processID || address || k))
372 # trunc63 = lowest 63 bits;
373 # N = 2^63 (v2's namespace offset)
374for f in 1..nf:
375 poly_f = random polynomial, degree θ-1, poly_f(0) = ballot[f]
376for f in nf+1..16: poly_f = random polynomial with poly_f(0) = 0 # inactive fields: shares of 0
377s[i][f] = poly_f(i) # ν shares per field
378for i in 1..ν:
379 (ct[i], K[i]) = MLKEM.Encaps(pk_warden[i]) # fresh randomness per package, NEVER reused
380 for f in 1..16: e[i][f] = s[i][f] + PRF(K[i], maskCtx(i, f)) mod p # PRF = keyed-Blake3 XOF, §2.2 mapping
381 h[i] = Blake3(hCtx(i) || s[i][1..16] || K[i])
382salt = fresh 256-bit CSPRNG value # hiding salt, kept in the opening
383sharesDigest = Blake3(h[1] || .. || h[ν])
384pkgCommit = Blake3(commitCtx || slot || pk_voter || prevPkgDigest || sharesDigest || salt)
385ctsDigest = Blake3(ct[1] || .. || ct[ν]) # binds the ciphertext bytes (§6)
386proof = BallotSTARK.prove(...) # §6
387```
388
389ML-KEM encapsulation costs ~1–2 ms per warden in browser WASM [KEMB]; the dominant client
390cost is the STARK (§6). **Pad-reuse warning:** reusing KEM randomness across two packages
391would publish the *difference* of two sharings, which interpolates to the difference of the
392ballots — encapsulations are fresh per package, enforced by convention and by the fresh
393`voteID` in every `maskCtx`.
394
395**Client state.** Default: `k`, the polynomials and the KEM randomness are **independent
396CSPRNG randomness**, and the client stores the package opening — including the commitment
397salt — (needed to revote). Optional *recovery mode* derives them **and the salt** as
398`PRF(sk_voter, purpose, processID, counter)` with distinct purpose tags (salt included:
399`"v3/salt"`). Any device holding `sk` can then reconstruct past packages. The documented
400trade-off: whoever later obtains `sk` can also reconstruct that voter's own historical
401ballots. Counter recovery: the
402client trial-derives counters 0,1,2…, computes each candidate `pkgDigest`, and checks which
403are admitted (vote-ID leaves) and which are consumed (nullifier tree) to find its live
404package; gaps from collision-resamples (§14) are skipped naturally.
405
406### 5.3 Revoting: the one-live-chain rule
407
408v2 overwrote the voter's slot and subtracted the stored ciphertext. v3 has no stored
409ciphertext, so the *voter's proof* identifies what to remove:
410
411
412
413- Each voter has, per election, a chain of packages $P_0 \to P_1 \to \dots$; exactly one is
414 **live**. A revote package $P_{t+1}$ consumes $P_t$: the STARK proves knowledge of $P_t$'s
415 opening (same slot, same key) and the nullifier derivation
416 $\mathrm{NULL}_t = \mathrm{Blake3}(\mathrm{nullCtx} \,\|\, sk \,\|\, \mathrm{pkgDigest}_t)$, where
417 `sk` is the voter's census-bound secret (or the self-chosen `sk_pkg` for unenrolled hybrid
418 voters — §11).
419- The batch program checks $P_t$ **was admitted and is settled**: an inclusion proof of
420 `voteID_t → pkgDigest_t` under the current root (consequently, a predecessor cast in the
421 *same* batch cannot be consumed yet — §14). It inserts $\mathrm{NULL}_t$ into the nullifier
422 tree (insert-once: double consumption is impossible), subtracts $P_t$'s public `E` from the
423 accumulator, and adds $P_{t+1}$'s.
424- Invariants enforced by the batch program: an **empty slot admits exactly one initial
425 package**; a package for an **occupied slot must consume exactly one admitted, unconsumed
426 predecessor of the same owner and slot**; refreshes never create occupancy.
427
428Nullifiers are unlinkable to packages for third parties (they depend on `sk`). The coercion
429consequences are stated in §12.3.
430
431### 5.4 Submission interface (voter → sequencer)
432
433The voter submits to one sequencer, over an encrypted channel as in v2:
434`{CanonicalPackage, hybridSig?, ballotProof, censusProof?, and — for a revote — the
435predecessor reference (voteID_t, pkgDigest_t) with its inclusion path}`. The sequencer (and
436its prover) therefore **learns revote events and predecessor linkage for the votes it seals —
437the same boundary as v2**, where the sealing sequencer learns which updates are overwrites.
438It never learns ballots, shares, pads, or `sk`: those stay inside the STARK witness. The
439batch program receives the predecessor's public data as ordinary host input; the STARK is
440what makes it *authorized* (nullifier + ownership), and the chain is what makes it
441*authentic* (vote-ID leaf).
442
443---
444
445## 6. The ballot proof (Plonky3 STARK)
446
447The Groth16 circuit is replaced by a STARK over Goldilocks, proven in the browser via WASM —
448the production descendant of the davinci-stark prototype [DST], minus its elliptic-curve
449section. No trusted setup.
450
451**Public inputs: the raw public vector.** There is no binding hash (v1.0's `inputsHash` is
452removed): the proof exposes the public statement **directly as a pinned, ordered vector of
453Goldilocks elements/limbs** — at least: `version` · `processID` · `packedBallotMode` ·
454`voteID` · the identity binding (`address` limbs and `pk_PQ` or the legacy branch's
455`H(sk_pkg)`) · `slot` · `authMode` · `isRevote` · `weight` · all `E` coordinates (ν·16
456elements) · all `h_i` (ν × 8×32-bit limbs) · `pkgCommit` limbs · `ctsDigest` limbs ·
457`prevPkgDigest` limbs · `NULL` limbs — **≈ 420+ elements at ν=16**. The vector layout is
458length-prefixed per ν and never truncates. `ctsDigest = Blake3(cts)` is computed *outside*
459the circuit and enters as opaque limbs — this **binds** the ciphertext bytes without proving
460anything about ML-KEM.
461
462**Statement contract (normative).** The batch program **constructs the expected public
463vector itself** — from the canonical package it admits, the authenticated election
464parameters, the authenticated census data (§8.2), and the predecessor metadata — and
465verifies the proof against *that* vector. It never verifies a supplied vector and then
466processes different package data. Inside the AIR, every value used by ballot validation,
467share generation, masking, commitments and nullifier derivation is constrained equal to
468these publics, so an admitted package is byte-for-byte the one the voter's proof authorized.
469`censusRoot` is **not** a ballot public input: membership is the batch program's job (§8.2).
470Privacy note: the inner proof's public inputs live at the voter→sequencer/guest boundary —
471they are **not** published in blobs beyond what the package itself already publishes.
472
473**The proof shows:**
4741. **Ballot validity** — v2's ballot protocol (ranges, uniqueness, cost sum vs
475 `maxValueSum`/weight, `ballotMode` unpacking), with three normative strengthenings over
476 the v2-era prototype: the weight bound is enforced when `maxValueSum = 0`; all comparisons
477 use sound borrow-checked integer gadgets (no Goldilocks wraparound); and the cost sum is
478 computed overflow-safe under the enforced integer-cost profile (§2.3).
4792. **Share consistency** — for every field (including inactive ones, with constant term 0),
480 the ν shares lie on one polynomial of degree ≤ θ−1 whose constant term is the ballot
481 value. Cost: ν·16·(θ−1) ≈ 1.8k multiplications at ν=16, θ=8 — trivial for the AIR.
4823. **Mask consistency** — $e_{i,f} = s_{i,f} + \mathrm{PRF}(K_i, \mathrm{maskCtx}(i,f))$ with
483 the same $(s_i, K_i)$ committed in $h_i$.
4844. **voteID derivation** from `(processID, address, k)` (Blake3, §5.2), with all of these
485 bound in the public vector.
4865. **Authentication** (§11): knowledge of `sk` with `H(sk) = pk_PQ`, where `pk_PQ` is a
487 public input that the **batch program** binds to the authenticated census leaf (§8.2) —
488 census membership itself is *not* proven in the ballot AIR. For an unenrolled hybrid
489 voter (census `pk_PQ = 0` means "no enrolled key" — the proof never requires
490 `H(sk_pkg) = 0`): knowledge of the self-chosen `sk_pkg` bound in the chain's first
491 `pkgCommit` (§11), with identity resting on `hybridSig`. For a revote, additionally the
492 predecessor opening (same slot, same key) and the `NULL` derivation of §5.3.
493
494**The in-AIR Blake3 section.** All in-circuit hashing runs in a **re-laid Blake3 section**
495(~25–32 rows per compression at the circuit's width; ~45 compressions at ν=5, ~110 at ν=16).
496It MUST constrain full standard-Blake3 semantics, not merely a compression gadget:
497canonical input bytes, exact lengths and zero padding; correct IV / keyed / `derive_key`
498initialization per mode; the full 7-round schedule with both feed-forward halves; the
49964-byte-block and 1024-byte-chunk structure with correct counters and
500`CHUNK_START`/`CHUNK_END`/`ROOT` flags; correct chaining between compressions; XOF
501output-block counters (an XOF is a seekable stream, not repeated hashing); outputs
502constrained equal to the values consumed elsewhere in the AIR; and selector/phase
503constraints that cannot skip or disconnect any check. Negative test vectors regenerate
504otherwise-correct traces with wrong flags, counters, lengths or chaining values.
505
506What the proof deliberately does **not** show: that `ct_i` decapsulates to the committed
507$K_i$. Proving ML-KEM in-circuit would drag SHAKE through the AIR. Instead, mismatched
508transport is *harmless to integrity* (no tally proof ever runs Decaps — §10.2) and *publicly
509excludable* (complaints — §9.2). A STARK-friendly verifiable encryption removing this
510trade-off is the main tracked upgrade (§15).
511
512**Indicative numbers.** Measured on the prototype [DST]: the Blake3 Merkle/challenger profile
513proves in **0.69 s native** (vs 3.2 s for the old Poseidon2 profile) with **~324 KB proofs**;
514a standalone Blake3 compression AIR costs ≈3.4 ms/compression at its wide layout. The
515full-Blake3 ballot (re-laid in-AIR section) is a **projection, not a measurement**:
516**~0.7 s native at ν=5 to ~1.4 s at ν=16**, ~325 KB proofs — to be re-benchmarked once the
517re-laid AIR exists (equal cell counts do not guarantee equal proving cost; the degree and
518quotient profile must be recomputed). Browser proving is expected at a few × native (mobile
519slower — to be benchmarked; the proof uploads once to one sequencer and is never stored
520on-chain). Standing adoption gates (from review): fix the vendored challenger's wasm32
521query-sampler bug; production hiding CSPRNG; pin the exact transcript (observe/sample
522schedule, domain-separated initialization, MMCS layout and shape checks) into
523`ballotVKHash`; implement full Blake3 chunk/tree semantics over the `blake3f` precompile
524with boundary-length test vectors (0/63/64/65/1023/1024/1025 B); measure real browser and
525whole-batch guest costs before deployment guarantees.
526
527---
528
529## 7. State tree changes
530
531Same sparse-Merkle-tree structure, depth 64, same namespaces as v2 — now hashed with
532**Blake3** (leaf: `Blake3(key_LE8 ‖ value_32 ‖ 0x01)`, node: `Blake3(left ‖ right)`), plus
533four changes:
534
535
536
5371. **Vote-ID leaves carry the package digest**: `voteID → pkgDigest` (v2 stored 0). This lets
538 revotes and complaints authenticate a package *body* against the chain.
5392. **Slot leaves are chained opaque digests** (no ballot data):
540 - first vote / overwrite: `leaf = Blake3("davinci-slot-v3" ‖ pkgDigest ‖ s_batch)`
541 - refresh: `leaf' = Blake3("davinci-refresh-v3" ‖ leaf ‖ s_batch)`
542 with `s_batch` the sequencer's secret batch seed (proven in-guest, never published — the
543 same trust class as v2's re-encryption seed). A refresh needs only the **public current
544 leaf** plus the refresher's own secret, so **any sequencer can refresh any occupied slot**
545 — permissionless sequencing is preserved and a vanished sequencer blocks nothing. Both
546 update types produce fresh-looking 32-byte values; this plus the padded accumulator is
547 what replaced re-encryption-based silent revoting.
5483. **Config namespace**: `0x3` = `wardenSetHash` (§4) instead of an encryption key; `0x4` =
549 `Blake3(A)` (the accumulator value itself is published in every batch's blobs); `0x5`
550 (reserved in v2) = the root of the **nullifier tree**, a dedicated Blake3 SMT of depth
551 256. A nullifier is a 32-byte Blake3 digest used directly as the 256-bit key; leaf
552 value = 1.
5534. **Genesis predicate replaces on-chain genesis computation.** The EVM has no Blake3
554 precompile, so the registry no longer computes the genesis root itself. Instead it stores
555 the election parameters and an **initialization flag**, and the **first transition's batch
556 proof constructs the genesis tree deterministically in-guest** from the registry-supplied
557 parameters — the canonical empty tree plus *exactly* the prescribed config leaves, the
558 zero accumulator in its prescribed encoding, an empty nullifier tree, no slots, no
559 packages, correct initial counters — and proves `oldRoot` equals that construction.
560 Membership proofs under a prover-chosen root are **never** accepted as a substitute (they
561 show presence, not absence of extra state). Registry rules: the genesis branch is
562 selected by the stored initialization flag (never caller input); parameters come from
563 registry storage, not calldata; the first transition and initialization are recorded
564 atomically; thereafter `oldRoot == storedRoot` always, and re-initialization is
565 impossible; the outer proof binds the full `(chainID, registry, processID)` (not just
566 v2's 4-byte prefix); and an **initialization-only transition** (zero ballots) is an
567 explicit path so empty elections can still finalize.
568
569---
570
571## 8. The batch program (ZisK guest)
572
573In one line: the batch program is the referee — it re-checks every vote package, applies the
574state updates, and maintains the masked running total.
575
576Same role, same settlement flow, same public-output pattern (`ok`/`failMask`, old/new roots,
577counters, census root, blobs digest) as v2. The constraint groups change as follows.
578
579
580
581### 8.1 Ballot proof verification
582Verifies the n ballot STARKs **in-guest**. FRI verification is hash-dominated and ZisK
583exposes a standard-conformant Blake3 compression precompile (`blake3f`); the measured count
584on the prototype verifier is **7,601 compressions per proof** (vs 7,515 permutations for the
585Poseidon2 profile — same Merkle structure), giving a *modeled* in-guest cost of roughly 1M
586steps per ballot (to be benchmarked). The guest implements Blake3's chunk/tree layout over
587the compression syscall; Merkle parents are `BLAKE3(left ‖ right)`. The ballot verifier
588configuration (AIR identity, FRI profile, transcript and hash profile) is pinned via
589`ballotVKHash` at config leaf `0x7`, as in v2, and the guest constructs each proof's expected
590public vector per the §6 statement contract.
591
592### 8.2 Census, authentication, binding
593Census membership is verified **here**, as in v2 (not in the ballot AIR): the program
594authenticates the census leaf `Blake3(address ‖ weight ‖ pk_PQ)` with a Merkle path under an
595accepted root, derives the slot by the census-origin rule, and proves the **join equality**:
596
597$$\text{ballot publics } (\text{identity key},\, weight,\, slot,\, authMode) \;=\; \text{authenticated census values and policy}$$
598
599The census root it checks is bound in the **batch statement** and must be accepted under the
600election's origin-specific registry policy — never chosen freely by the prover. `authMode` is
601derived from the immutable election auth policy plus the creation-time enrollment snapshot
602(§11) and compared against the proof's public input — never prover-chosen. Authentication
603then follows the policy: `pq-only` relies on the in-STARK preimage proof alone; `hybrid`
604*additionally* verifies `hybridSig` (ECDSA over `pkgDigest`, secp256k1 precompile, recovered
605address = census address) for every package; `hybrid-legacy` dispatches per census leaf as
606specified in §11. The program recomputes `ctsDigest` and `pkgDigest` from the package body
607and constructs the proof's full expected public vector from that body (§6 statement
608contract) — so an admitted package is byte-for-byte the one the voter's proof authorized.
609
610**On-chain censuses and the PQKeyRegistry (origin 3).** Contracts cannot hash Blake3
611cheaply, so on-chain censuses maintain an incremental **keccak256 running commitment** of
612their authorized registrations (one `keccak256(prev, entry)` per registration — Solidity-
613native). A permissionless **census-root conversion proof** — a small ZisK guest — attests
614"running commitment `c` corresponds to Blake3 lean-IMT root `r`"; the registry verifies it
615and stores the accepted `(c, r)` pair, and batches then use `r` under the origin-3 root
616policy. No unauthenticated off-chain root ever enters the system.
617
618### 8.3 State transitions
619In fixed order, each proven against the previous root, as v2: (1) insert
620`voteID → pkgDigest`; (2) insert revocation nullifiers with the one-live-chain checks of
621§5.3 (predecessors must be settled under the starting root); (3) write slot leaves (votes +
622overwrites), then refresh the sample $\mathcal{R}$ (§7.2; sample-size rule as v2); (4) update
623`0x4` with the new accumulator digest and `0x5` with the new nullifier root.
624
625### 8.4 Accumulator update and the batch pad
626$$A' = A + \sum_{\text{new pkgs}} E \; - \sum_{\text{consumed pkgs}} E \; + \; B$$
627
628In words: the new accumulator is the old one, plus the masked shares of every package this
629batch adds, minus the masked shares of every package it revokes, plus a fresh secret pad $B$
630whose only job is to hide *which* rows were subtracted.
631
632Here $B \in \mathbb{F}^{\nu \times 16}$ is a fresh **uniform** batch pad derived in-guest
633from the secret batch seed. Without $B$, the public batch delta minus the (public) new-package
634sums would equal $-\sum_{\text{consumed}} E$, letting anyone identify revoked packages by
635matching public `E` rows. $B$ is deliberately *unstructured* — a Shamir-codeword-shaped pad
636would vanish under the code's public parity checks and leak the same information.
637
638### 8.5 The warden payload (KEM-DEM, proven)
639Per batch, the guest: derives a 256-bit batch key $k_b$ and the ML-KEM encapsulation
640randomness from the secret batch seed (guest-internal derivation under the pinned program, so
641it is as trustworthy as the proof itself); DEM-encrypts (§2.1)
642`payload = (B ‖ consumed pkgDigests ‖ context)` under $k_b$; Shamir-shares $k_b$
643**coordinate-wise over its 32-bit limbs** θ-of-ν; and for each warden $i$: one in-guest
644ML-KEM encapsulation to $pk_i$ → wrapping secret → DEM-encrypts share $i$. The proof binds
645$B$ to the accumulator update, the consumed list to the nullifier insertions, and every
646ciphertext to its registered recipient key and context. **Unlike voter transport, a malformed
647batch payload is unprovable, not merely complainable** — it would hide an accepted
648transition's revocations and pads from the tally. All of it is published in the batch's blobs.
649
650### 8.6 Blob layout v3 and honest DA numbers
651Blob cells carry 31 payload bytes each (a v3 codec choice — v2 packed typed values; v3 packs
652an opaque byte stream per section), 4096 cells per blob ⇒ 126,976 B per blob. Sections, in
653order: header · new packages (CanonicalPackage bytes) · slot-update list
654(slot index 8 B + new leaf 32 B — so a refresh costs 40 B framed, vs ~1–2 KB in v2) ·
655nullifiers (32 B each) · accumulator value $A'$ (ν·16·8 B) · warden payload (§8.5).
656Byte-exact cell maps live in the davinci-zkvm normative docs, as in v2. One divergence from
657v2's blob flow: the evaluation point becomes
658$z_b = \mathrm{keccak256}(\text{processID} \,\|\, \text{stateRoot}^{old} \,\|\, \text{blobCommitment}_b) \bmod q_{BLS}$
659— keccak because the **registry contract** computes it (Solidity-native; the guest recomputes
660it via the keccak precompile, one call per blob — a §2 island).
661
662Per-package size: `72 + ν·(160 + ct_len)` bytes (72 B fixed fields; per warden: 128 B of
663masked shares + 32 B commitment + one ciphertext) ⇒ **20,040 B** at ν=16/ML-KEM-768;
66414,920 B at ν=16/ML-KEM-512; 6,312 B at ν=5/768; 1,320 B at ν=1.
665
666| Profile (256 votes + 256 refreshes) | batch bytes | blobs (126,976 B each) | vs v2 (~5 blobs) |
667|---|---|---|---|
668| ν=16, ML-KEM-768 | ≈ 5.2 MB | **≈ 41 — exceeds the 32-blob batch cap** ⇒ max ~195 votes/batch, or use ML-KEM-512 | ~8× |
669| ν=16, ML-KEM-512 | ≈ 3.9 MB | ≈ 31 | ~6× |
670| ν=5, ML-KEM-768 | ≈ 1.7 MB | ≈ 14 | ~2.7× |
671| ν=1 (sequencer mode) | ≈ 0.35 MB | ≈ 3 | ~0.7× — *cheaper than v2* |
672
673DA is v3's main cost regression and is linear in ν: size committees to the election's
674stakes. Classic McEliece transport (96–128 B ciphertexts ⇒ 4.2–4.7 KB/package at ν=16 by the
675same formula) is the tracked reduction path for large committees [MCE].
676
677---
678
679## 9. End of election: freeze, complaints, exclusions
680
681The v2 timeline (end → grace window) gains two phases before results:
682
683
684
685### 9.1 Casting freeze
686When the grace window closes the registry stops accepting transitions (as v2) and the
687accumulator freezes as $A_{\text{cast}}$, bound to the frozen final root.
688
689### 9.2 Complaint window and the exclusion set X
690During a scheduled window (an election parameter, like the grace bounds), **registered
691wardens of the election** may submit complaints: `submitComplaint(processID, pkgDigest,
692publicValues, proof)` where the ZisK proof shows `Decaps(sk_i, ct_i)` yields a key
693inconsistent with the package's admitted $h_i$ (witness: the warden's registered key seed;
694statement bound to the admitted `pkgDigest` and the frozen root). The registry verifies the
695proof and appends the package to an **idempotent, append-only exclusion set $X$**. Complaints
696**never touch the accumulator** — so no complaint needs to know whether its package was
697already consumed, and ordering cannot matter. Submission is allow-listed to the election's ν
698wardens; the submitter pays gas. **Capacity is sized to the workload, not an arbitrary cap**:
699the registry bounds total admitted casts (`maxVoters × maxRevotes`, a new creation
700parameter), and the complaint window length and the wardens' proving/fee budget must cover
701that bound in the worst case (an adversary can make the complaint path linear in admitted
702casts — this is an explicit liveness assumption, §9.3, not an exceptional path). At the
703deadline $X$ freezes on-chain; every tally proof binds the frozen
704$(\text{root}, A_{\text{cast}}, X)$ snapshot.
705
706Semantics, stated plainly: a voter whose *live* package ends up in $X$ is not counted (their
707earlier packages stay consumed) — a deliberately malformed revote is a provable
708self-abstention, and a voter+warden coalition gains a bounded post-close withdrawal option
709for that voter's own ballot. A package malformed toward warden $i$ that is *not* excluded
710still tallies correctly from wardens that can open it (§10.2); warden $i$ either complains in
711the window or sits out.
712
713### 9.3 Liveness
714The tally needs at least θ wardens (the tally threshold) that complete the archive scan (and any complaints) inside the
715window, complete the ceremony (§10.3), and publish proven contributions — plus, as in v2,
716timely inclusion of their transactions, **plus complaint capacity (proving + fees + window
717length) provisioned for the election's admitted-cast bound in the worst case (§9.2)**.
718Fewer ⇒ results are lost, exactly as v2's "θ of ν wardens take part in decryption".
719
720---
721
722## 10. Tally: warden sums and Lagrange
723
724In one line: this is where the masked running total becomes the election result — in public,
725with proofs, and without any decryption key.
726
727### 10.1 What each participating warden computes
728After the exclusion freeze, each participating warden $i$:
7291. downloads the complete blob archive (same DA story as any v2 observer; work is linear in
730 *total casts*, not final voters);
7312. decapsulates its per-package ciphertexts, recovers shares
732 $s_{v,i,f} = e_{v,i,f} - \mathrm{PRF}(K_{v,i}, \mathrm{maskCtx})$, and checks each against
733 the admitted $h_{v,i}$;
7343. joins the **tally ceremony** (§10.3): the participants reconstruct the per-batch payload
735 keys (θ shares each), decrypt the payloads — obtaining every batch pad $B$ and the full
736 consumed set $R$, verified against the batch proofs that committed them — and run the
737 zero-blinding round producing $G_f$;
7384. computes, over $\mathrm{Active} = \mathrm{Admitted} \setminus (R \cup X)$:
739
740$$S_{i,f} = A_{\text{cast},i,f} - \sum_{v \in X \setminus R} e_{v,i,f} - \sum_{v \in \mathrm{Active}} \mathrm{PRF}(K_{v,i}, \mathrm{maskCtx}) - \sum_{b} B_{b,i,f} + G_f(i)$$
741
742In words: start from the frozen running total; remove the rows of excluded-but-never-revoked
743packages; strip your own masks for every counted package; strip the batch pads; add your
744blinding share.
745
746One-line sanity check: $A_{\text{cast}}$ = (masked shares of all admitted-minus-consumed
747packages) + (all batch pads); removing the still-present excluded rows, all pads, and all
748batch pads leaves exactly $\sum_{\mathrm{Active}} s_{v,i,f}$; adding $G_f(i)$ with
749$G_f(0)=0$ doesn't change the interpolation at 0.
750
7515. publishes $S_i$ with a **ZisK proof** whose statement binds: the election, the frozen
752 $(\text{root}, A_{\text{cast}}, X)$ snapshot, the complete archive commitment, its
753 recipient index, and the accepted ceremony transcript (§10.3) — and whose witness contains
754 its KEM key seed (authenticating it as warden $i$ against the registered commitment), the
755 per-package $(s, K)$ openings **for every counted active package** (each checked against
756 its admitted $h_{v,i}$), the reconstructed payload keys and payload openings, and its
757 blinding evaluations. The program enforces **complete, exactly-once processing** of every
758 admitted package in the archive (counted, consumed, or excluded — nothing skipped) and
759 that $R$ and $B$ are the values authenticated by the accepted batch payloads.
7606. `submitTallyShare(processID, i, S_i, publicValues, proof)`; after θ verified shares,
761 anyone calls `finalizeResults(processID)`: **the registry performs the Lagrange
762 interpolation on-chain** (θ ≤ 16 points over Goldilocks — a few u64 mulmods per field),
763 records the per-field results, and emits `ProcessResultsSet`.
764
765Wardens run their **own provers**: the witness contains their secrets, and a shared proving
766service used by θ wardens would itself hold reconstruction capability. Proving cost scales
767with total casts (a few Blake3 compressions per package; as an **unvalidated projection**
768— archive, payload and ceremony checks included — on the order of 10^8 guest steps for a
769million-cast election, to be benchmarked with the v3 implementation before warden hardware
770guidance is given).
771
772### 10.2 Why malformed voter transport cannot corrupt anything
773**Decapsulation never appears in any tally proof** — contributions open the admitted
774commitments $h$ instead, and under commitment binding every accepted $S_i$ lies on the same
775aggregate polynomial. A voter publishing a bad `ct_i` only deprives warden $i$ of its opening
776witness (warden $i$ complains or sits out; the voter could even re-supply the opening
777out-of-band, which is safe — correctness is tied to $h$, not to the transport). Every clean
778θ-subset interpolates the same tally, because the ballot STARK proved all ν shares lie on one
779valid polynomial. Malformed transport is an availability lever against one warden, never an
780integrity lever against the election.
781
782### 10.3 The zero-blinding ceremony
783In plain terms: before publishing their partial sums, the participating wardens jointly add
784noise that cancels out exactly at the finish line (x = 0), so the published sums reveal the
785result and nothing else. Why it's needed: published raw, θ sum-shares determine the aggregate
786polynomial $F$; any single warden — participant or not — could evaluate it at its own index,
787compare with the sum of its decoded per-package shares, and fingerprint the revoked set. The
788ceremony prevents that:
789
7901. A `tallySession` is recorded on-chain: session id = `H(processID ‖ root ‖ X ‖ roster)`,
791 with the participant roster and dealer set fixed (dealers = the participants).
7922. Each dealer $k$ samples a seed and derives, per field, blinding coefficients
793 $c_{k,f,1..\theta-1}$, defining $g_{k,f}(x) = \sum_j c_{k,f,j} x^j$ — **the constant term
794 is structurally absent, so $g_{k,f}(0) = 0$ by construction** (this is the
795 "zero-certificate": the committed coefficient vector simply has no degree-0 entry).
7963. Dealer $k$ publishes (in a session blob): a hiding commitment to its coefficients
797 (salted unkeyed Blake3, §2.3); **per-recipient hiding evaluation commitments**
798 $cm_{k,i} = \mathrm{Blake3}(g_{k,1..16}(i) \,\|\, r_{k,i})$; the KEM-DEM ciphertexts to each
799 co-participant $i$ encrypting $(g_{k,1..16}(i), r_{k,i})$; and a **ZisK dealer proof**
800 that the committed coefficients, the evaluation commitments, and the ciphertexts are all
801 consistent, under the recipients' registered keys and this session's context.
8024. Contributions use $G_f(i) = \sum_{k \in D} g_{k,f}(i)$ over the **accepted dealer set
803 $D$** — fixed on-chain after the dealer deadline; every contribution proof binds the same
804 $D$ and session id, and **opens the evaluation commitments $cm_{k,i}$** (the recipient
805 learned the opening by decapsulating off-circuit — decapsulation still never enters any
806 tally proof). A dealer whose proof is missing or invalid is excluded and the session
807 restarts with fresh masks (roster must stay ≥ θ).
808
809As long as one accepted dealer is honest, no one outside the ceremony — and no
810non-participating warden — learns anything about $F$ beyond what the public tally
811$F(0)$ itself reveals. Participants do jointly learn the
812revoked set $R$; that is the documented θ-gated metadata leakage (§12.2).
813
814---
815
816## 11. Census and authentication
817
818- **Census trees** migrate from Poseidon-BN254 to **Blake3** (a breaking format change; same
819 lean-IMT structure; membership verified by the batch program, §8.2). Leaf encoding:
820 `leaf = Blake3(address ‖ weight ‖ pk_PQ)` with `pk_PQ = H(sk)` for a CSPRNG-generated
821 secret, or `pk_PQ = 0` for a not-yet-enrolled voter (hybrid-legacy censuses only).
822- **PQ-key enrollment.** The Ethereum wallet signs an enrollment message binding
823 `address ↔ pk_PQ`; the signature *authorizes* the binding and is never key entropy (a
824 future ECDSA break must not reveal PQ secrets). Enrollment paths per census origin:
825 off-chain censuses collect `pk_PQ` at census construction; on-chain/token censuses read a
826 global **PQKeyRegistry** contract where voters register once (one transaction, reusable
827 across all elections); CSP censuses include `pk_PQ` in the credential.
828- **Election auth policy** (immutable registry parameter, fixed at creation):
829 - `pq-only`: every leaf must carry `pk_PQ`; authentication is the in-STARK preimage proof
830 alone; no ECDSA anywhere in the ballot path.
831 - `hybrid`: every leaf must carry `pk_PQ`, and every package is verified on **both**
832 authenticators — the in-STARK preimage proof *and* `hybridSig` (ECDSA over `pkgDigest`,
833 verified by the batch program). No OR-downgrade exists in this mode.
834 - `hybrid-legacy`: like `hybrid`, but leaves with `pk_PQ = 0` are admitted with identity
835 resting on ECDSA alone; the STARK's auth clause (§6.5) switches to a **self-chosen
836 package key**: the voter generates `sk_pkg` (CSPRNG; kept with the package opening). The
837 first package binds `H(sk_pkg)` inside `pkgCommit`. Every later package in the chain
838 proves knowledge of the *same* `sk_pkg` (predecessor opening) and derives its nullifier
839 as `NULL = Blake3(nullCtx ‖ sk_pkg ‖ prevPkgDigest)`. The batch program dispatches per
840 leaf: `pk_PQ ≠ 0` ⇒ both authenticators against the census key; `pk_PQ = 0` ⇒ mandatory
841 `hybridSig` + the `sk_pkg` clause. Anyone can count the legacy-status census members
842 (leaf contents are public census data) — though not, of course, which *final* packages
843 are theirs beyond what slot-participation already reveals. Ballot *privacy* is fully PQ
844 for these voters; the election's **integrity assumptions include ECDSA security for its
845 legacy voters** (§12.1). This mode is what makes existing token censuses usable before
846 universal enrollment.
847- **Enrollment snapshot rule.** A voter's authentication status and key for an election are
848 pinned at the election's **creation snapshot**: for on-chain/token censuses the registry
849 records the PQKeyRegistry root at the creation block, and membership proofs must present
850 the enrollment status under that snapshot regardless of which (newer) eligibility root the
851 census contract later accepts. Enrolling *after* an election was created affects
852 subsequent elections only — an existing package chain never changes keys mid-election.
853- **CSP censuses**: credentials become SLH-DSA signatures [FIPS 205] over the v2 message
854 format extended with `pk_PQ`; verification is pure hashing via the SHA-256 precompile
855 (SLH-DSA's internal SHA-2 is a FIPS island, §2 — not an application-level hash choice).
856- Slot derivation, participation visibility, census origins 1–4 mechanics: as v2, with the
857 enrollment additions above. The v2 census invariants (slot uniqueness across the census;
858 stable distinct CSP indexes) remain assumptions of integrity.
859
860---
861
862## 12. Security properties, stated plainly
863
864### 12.1 What holds, under what
865
866| Property | Holds if |
867|---|---|
868| **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). |
869| **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. |
870| **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. |
871| **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. |
872| **Liveness** | ≥1 honest sequencer with proving capacity and timely inclusion (as v2), plus ≥θ wardens through the scan window and ceremony (§9.3). |
873
874### 12.2 What wardens and insiders learn
875θ colluding wardens can reconstruct **every package's ballot** — exactly v2's boundary, where
876θ wardens can decrypt every ballot. New, and narrower: the **tally participants** (a θ-sized
877set) jointly learn the revoked-package set $R$ — metadata, not contents — and any one of them
878can leak it onward; non-participating wardens and the public learn nothing about $R$ (batch
879pads §8.4 + blinding §10.3 close those channels, given ≥1 honest accepted dealer). The
880sequencer/prover that seals a vote learns its revote linkage (§5.4) — as in v2.
881
882### 12.3 The honest coercion statement
883v3 keeps v2's informal posture (no formal receipt-freeness; revotes hidden among refreshes)
884with **one new residual, stated openly**: a coercer who obtains a package's *revocation
885token* — by extracting the voter's identity key, **or** by demanding a ZK proof of the
886token's derivation, **or** a valid unsubmitted revote authorization — can watch the public
887nullifier tree and detect whether that package was later consumed. v2's re-encryption resists
888even that (testing re-encryptions is a DDH-type problem). This is the main new
889coercion-relevant difference from v2 (alongside the §12.2 participant metadata); mitigations
890are Track-2 research (§15). Deployments for coercion-sensitive elections should weigh it.
891
892### 12.4 Proof-system notes
893The ballot STARK profile targets ~102-bit *conjectured* FRI soundness (ethSTARK heuristic
894[ETHS]) — an explicit engineering dial (queries × log-blowup + grinding), to be raised for
895high-stakes deployments, and **not** claimed as 128-bit PQ security. The Blake3
896Merkle/challenger layer uses **full** Blake3 (7 rounds is the standard, not a reduction) with
897256-bit digests: ~128-bit classical collision resistance — adequate for the classical target
898above — while generic *quantum* collision bounds on any 256-bit hash are ~2^85 query bounds
899(BHT model, with heavy resource assumptions); the profile is therefore justified against the
900classical conjectured target, not claimed as ≥102-bit end-to-end quantum security (the same
901caveat applies to a Poseidon2 profile). The v2-era prototype's
902three known defects (weight-bound bypass at `maxValueSum=0`; wraparound-prone comparators;
903weak hiding-PCS blinding RNG with a constant fallback seed) are normatively fixed in v3
904(§6.1; 256-bit CSPRNG blinding seed, fail-closed).
905
906**Where Poseidon2 still lives, honestly.** Blake3 replaces Poseidon2 in application hashing
907and the ballot proof system. Poseidon2 remains an **inherited ZisK proof-system dependency**:
908a break there may compromise accepted state transitions and tally integrity, and can thereby
909compromise privacy *during protocol execution* (e.g. forged transitions could mark packages
910consumed without authorization and mislead honest wardens into revealing a skewed aggregate).
911Passive confidentiality of archived ballot transport and masking no longer relies on
912application-level Poseidon2. "Repairable" means future executions can migrate to a repaired
913verifier — not that past disclosures or finalized decisions can be undone. Why the move: the
914Poseidon2 cryptanalysis landscape is young and moving — round-estimate revisions [TOSC25],
915the EF Poseidon attack-reward program [PINIT], and the FreeLunch family of algebraic attacks
916on arithmetization-oriented primitives [FL24] — while Blake3 carries long-standing ARX
917analysis. This is a conservatism call, not a response to any full-round break.
918
919### 12.5 Out of scope / inherited
920EIP-4844 KZG commitments (Ethereum's own PQ roadmap), organizer/sequencer Ethereum accounts,
921hybrid-mode ECDSA (by construction), and the BN254 PlonK wrapper around ZisK proofs —
922integrity-only, replaceable by direct on-chain STARK verification (indicative public data
923point: ~5–6 MGas for a WHIR/FRI verifier on the EVM [WHIR]; not a measured cost for ZisK
924proofs) — tracked as the final migration phase.
925
926---
927
928## 13. Cost summary
929
930| Metric | v2 | v3-PQ (estimates unless marked measured) |
931|---|---|---|
932| Browser proving | seconds (Groth16, 35.5 MiB key download) | projected 0.7–1.4 s native (ν-dependent, re-laid full-Blake3 AIR — to be benchmarked; no key download; the Blake3-trees prototype measured 0.69 s native) |
933| Ballot upload to sequencer | ~2 KB | ~20 KB package + ~325 KB proof (proof not stored on-chain) |
934| DA per ballot | ~2 KB | 1.7–20.5 KB depending on ν and KEM (§8.6 table) |
935| DA per refresh | ~1–2 KB | 40 B (framed) |
936| Batch proving | 2.3–4.0×10^8 steps | + ~1M steps × votes for STARK verification (7,601 Blake3 compressions/proof **measured**); state-tree hashing −30%/byte vs v2's SHA-256 (Blake3 precompile 97 vs 137 units/B); commitment recomputations +13% vs a Poseidon2 precompile |
937| Tally | θ partial decryptions of one accumulator + BSGS | archive-linear warden jobs (§10.1) + one ceremony + on-chain Lagrange |
938| Registry tally cap | 10^12 | 2^61 |
939
940---
941
942## 14. Errors and edge cases (normative)
943
944- **voteID collision** (admission finds the leaf occupied): resample `k` (recovery mode:
945 bump the counter) and re-cast — as v2. Skipped counters are harmless (§5.2 recovery scan).
946- **Unsettled predecessor**: a revote consuming a predecessor not yet settled under the
947 batch's starting root is rejected at admission and retried by the sequencer in a later
948 batch automatically; clients should submit revotes to the sequencer that holds their
949 pending vote, as in v2.
950- **Duplicate revocation race** (two sequencers hold revotes of the same package): the first
951 settles; the loser's re-validation drops the vote at admission (nullifier present) and
952 notifies the voter — the v2 "voteID already in state" pattern.
953- **Live package excluded** ($P_t \in X$): the client detects it (public $X$) and informs
954 the voter they are not counted; no recovery within the election (casting is closed when
955 complaints run).
956- **Warden key unavailable at cast time**: the client refuses to cast (it cannot build a
957 complete package); election creation already requires all ν keys registered (§4).
958- **Ceremony dealer failure**: dealer excluded, session restarted with fresh masks (§10.3);
959 if the roster drops below θ, the tally is lost — counted under liveness (§9.3).
960
961---
962
963## 15. Tracked upgrades
964
9651. **STARK-friendly verifiable encryption** (RLWE-LPR with a Blake3-based FO transform) to
966 prove warden transport at admission — removes the complaint window entirely. Requires its
967 own security review before adoption.
9682. **PQ re-randomizable package representation** — would restore v2-grade resistance to
969 revocation-token coercion (§12.3). Open research.
9703. **Locked mode** as a separately specified and reviewed extension (§4).
9714. Direct on-chain STARK verification (drop the PlonK wrapper) once rollup gas permits.
9725. Classic McEliece transport profile for large committees [MCE].
973
974---
975
976## 16. References
977
978- [DAV2] Vocdoni, *DAVINCI protocol specification v2*. https://spec.davinci.vote
979- [FIPS 203] NIST, *Module-Lattice-Based Key-Encapsulation Mechanism Standard (ML-KEM)*, 2024. https://doi.org/10.6028/NIST.FIPS.203
980- [FIPS 205] NIST, *Stateless Hash-Based Digital Signature Standard (SLH-DSA)*, 2024. https://doi.org/10.6028/NIST.FIPS.205
981- [Sha79] A. Shamir, *How to Share a Secret*, CACM 22(11), 1979.
982- [DST] Vocdoni, *davinci-stark: Plonky3 ballot proof prototype*. https://github.com/vocdoni/davinci-stark
983- [P3] Polygon Zero, *Plonky3*. https://github.com/Plonky3/Plonky3
984- [ZISK] Polygon, *ZisK zkVM*. https://github.com/0xPolygonHermez/zisk
985- [POS2] L. Grassi et al., *Poseidon2: A Faster Version of the Poseidon Hash Function*, ePrint 2023/323.
986- [TOSC25] *Poseidon and Neptune: Gröbner Basis Cryptanalysis Exploiting Subspace Trails*, IACR ToSC. https://tosc.iacr.org/index.php/ToSC/article/view/12244
987- [FL24] A. Bariant et al., *The Algebraic FreeLunch: Efficient Gröbner Basis Attacks Against Arithmetization-Oriented Primitives*, CRYPTO 2024 (ePrint 2024/347).
988- [PINIT] Ethereum Foundation, *Poseidon Initiative — cryptanalysis attack reward program*. https://www.poseidon-initiative.info
989- [B3] J. O'Connor, J.-P. Aumasson, S. Neves, Z. Wilcox-O'Hearn, *BLAKE3: one function, fast everywhere*. https://blake3.io
990- [ETHS] StarkWare, *ethSTARK Documentation*, ePrint 2021/582.
991- [EIP4844] V. Buterin et al., *EIP-4844: Shard Blob Transactions*, 2022.
992- [IR89] R. Impagliazzo, S. Rudich, *Limits on the Provable Consequences of One-Way Permutations*, STOC 1989.
993- [NOAH] M. Dahl et al., *Noah's Ark: Efficient Threshold-FHE Using Noise Flooding*, WAHC/CCS 2023.
994- [TEV] J. Alizadeh, *Threshold Post-Quantum E-Voting from Lattice Commitments*, ePrint 2026/2500.
995- [PQK] N. Huber et al., *PQKryvos: Post-Quantum Secure E-Voting With Flexible Ballot Formats and Public Tally-Hiding*, PoPETs 2026.
996- [MCE] D. J. Bernstein et al., *Classic McEliece*. https://classic.mceliece.org
997- [KEMB] *ML-KEM WebAssembly implementations and benchmarks*. https://github.com/dchest/mlkem-wasm
998- [WHIR] *EVM Verification of WHIR over a 31-bit Field*, ethresear.ch, 2025.