Skip to content

Split the trust (threshold decryption)

View Markdown

Use this when nobody should be able to see individual values on their own, but a group must be able to reveal an agreed result: an election tally, a total of private bids, an aggregate statistic.

Trustees run a distributed key generation (DKG) together. It produces one public key, and each trustee keeps a share of the secret key; the full secret key never exists anywhere. Values are encrypted to the public key and added up while still encrypted. At the end, any t + 1 of the n trustees publish decryption shares of the total, each with a proof it was computed honestly, and the total comes out. Fewer than t + 1 learn nothing.

Encryption · step 1 / 5
Sendersencrypt to the public key
Alice's amountSECRETHIDDEN4,200████████
Bob's amountSECRETHIDDEN2,500████████

Anyone can encrypt with the public key. Only the secret key opens the result.

Public ledgeranyone can read it
public key PKPUBLIC0x4158…ab07
Enc(Alice) = (A, B)PUBLIC0x3b8b…e711
Enc(Bob) = (A, B)PUBLIC0xa271…b8ac
sum of ciphertextsPUBLIC0x6a55…8892

Adding ciphertexts adds the amounts inside. Nobody had to decrypt anything.

AuditorTrusteesholds the secret keyeach holds one share
secret key skSECRETHIDDEN0x195a…09e4████████
Decrypt the sumB − sk·A = 6,700·Glook up 6,700 in a table of small numbersOnly small amounts (up to 2³² here) can be looked up, so values are kept small or split into limbs.
Pick who takes part (need 2 of 3)
0 of 3: not enough shares, nothing decrypts

1. Key

An auditor makes a key pair and publishes the public key. Think of a lockbox with a slot: anyone can drop something in, only the auditor has the key.

2. Encrypt

Alice encrypts her amount to the auditor's public key and publishes the ciphertext. Each encryption uses fresh randomness, so encrypting the same amount twice gives unrelated ciphertexts. Press "Encrypt again".

3. Add

Bob does the same. Because this is exponential ElGamal, adding two ciphertexts gives a ciphertext of the sum. A ledger can keep a running encrypted total that nobody can read.

4. Decrypt

The auditor uses the secret key to recover the total. Decryption ends in a lookup, which is why encrypted amounts must be small numbers, such as votes or 32-bit limbs.

5. Split the key

To stop any one party reading the ciphertexts, trustees run a distributed key generation: nobody ever holds the whole secret key. Decrypting needs 2 of 3 trustees to cooperate. Pick trustees to try it.

SECRET only its owner knows itPUBLIC anyone can see itKey and ciphertext values are illustrative.

Step 5 of the illustration is this page’s idea: pick trustees and see when the total decrypts.

PartyLearns
Each senderTheir own value
Any single trusteeNothing beyond the public data
t + 1 trustees togetherWhatever they agree to decrypt; the policy is to decrypt only the total
Everyone elseCiphertexts, then the total once decrypted

A 2-of-3 setup (t = 1, n = 3) with an in-process key generation and a five-vote tally:

ThresholdTally.java (core)
import org.zeroj.circuit.lib.jubjub.DkgConfig;
import org.zeroj.circuit.lib.jubjub.ElGamal;
import org.zeroj.circuit.lib.jubjub.ElGamalCiphertext;
import org.zeroj.circuit.lib.jubjub.ThresholdKeyContext;
import org.zeroj.circuit.lib.jubjub.VerifiedDecryptionShare;
// Agreed by everyone, e.g. in an election manifest: tolerate t = 1 fault, so any 2 of 3 decrypt
DkgConfig config = DkgConfig.create(1, 3, roster, "demo-election-2026".getBytes(UTF_8), 1);
// ... the trustees run the 7-round key generation (see the guide) and each keeps its share ...
ThresholdKeyContext election = shares.get(0).context();
// Voters encrypt 0 or 1 (width 1); anyone adds the ciphertexts
List<ElGamalCiphertext> ballots = new ArrayList<>();
for (int vote : new int[] {1, 0, 1, 1, 0}) ballots.add(ElGamal.encrypt(election, vote, 1, random));
ElGamalCiphertext total = ElGamalCiphertext.sum(ballots);
// After the deadline, trustees 1 and 3 publish decryption shares of the total only
List<VerifiedDecryptionShare> published = List.of(
ElGamal.decryptionShare(shares.get(0), total),
ElGamal.decryptionShare(shares.get(2), total));
long yes = ElGamal.decrypt(total, published, total.bound().longValueExact()); // 3

The full program, including the key generation and the HPKE-encrypted delivery of trustee shares over a public board, is in the Threshold decryption guide.

  • Private voting. Each ballot is encrypted to the election key with a proof it’s a 0 or a 1; trustees decrypt only the final count. The demo shares the key n-of-n among three trustees, so all three must take part; the threshold key generation here is the t-of-n upgrade. (use case)
  • Sealed-bid totals and statistics. A consortium learns the total or average of private submissions, and no member sees another’s.
  • Key escrow with a quorum. Recovery data is readable only when, say, 3 of 5 custodians agree.
Policytn
Any 2 of 313
Any 3 of 525
Any 4 of 737

Any t + 1 trustees decrypt. The rule 2t + 1 ≤ n ≤ 64 is about faults, not the quorum: at most t trustees may misbehave during key generation, so the honest ones must outnumber them. It allows “2 of 5” (t = 1, n = 5) but not “4 of 5”, which would need n ≥ 7.

  • A quorum can read anything. t + 1 colluding trustees can decrypt any single ciphertext, not just the total. The “decrypt only the total” rule is a policy the library can’t enforce; publish it, and pick independent trustees.
  • Decrypt once. Decrypting a running total twice and subtracting reveals the values in between.
  • Verify every share. Accept decryption shares only with VerifiedDecryptionShare.verify and a DLEQ proof (a proof that the share was made with the trustee’s real key share); an unverified share lets a trustee choose the result.
  • Small results reveal. A unanimous vote, or a total of one, reveals the individual values.
  • Maturity. Experimental. Secret operations are offline/isolated only, and the encrypted share delivery’s assumption A1 awaits external review.