Skip to content

Commitments & encryption, explained

View Markdown

A zero-knowledge proof answers a question about secret data. Often that’s all you need: “is this person over 18?” But many applications also have to keep a secret value on a public ledger: a balance, a salary, a bid, a vote. Somebody needs to check it now, somebody else may need to read it later, and everyone else should see nothing.

Four tools cover almost every case. This page explains each one with an everyday picture, and Choose how to disclose helps you pick between them.

ToolEveryday pictureWhat it gives you
CommitmentA sealed envelopePublish a value without revealing it; prove facts about it; open it later
Encryption to a keyA lockbox with a slotAnyone can put a value in; only the key holder can read it
Encrypted deliveryA letter to named readersHand the opening of a commitment to the owner and an auditor, on-chain
Shared key (threshold)A safe that needs two of three keysNobody alone can decrypt; a quorum can

A commitment lets you fix a value now and reveal it later, or never. ZeroJ uses Pedersen commitments. To commit to a value v, you pick a large random number r, the blinding, and publish one point on an elliptic curve:

C = v·G + r·H

G and H are two fixed public points. You don’t need to follow the math to use it; three properties matter:

  • Hiding. Because r is random, C reveals nothing about v. Two commitments to the same amount look unrelated.
  • Binding. Once you publish C, you can’t later claim it held a different value. Finding a second opening is as hard as breaking the curve.
  • Adding. Commitments add up: C(a, r) + C(b, s) = C(a + b, r + s). A ledger can total balances, or check that inputs equal outputs, without seeing any single amount.

Step through it. Drag the amount, roll a new blinding, and try opening the envelope to a different number.

Commitment · step 1 / 5
Alicecommits to an amount
amount vSECRETHIDDEN4,200 ADA████████
blinding r (random, 252 bits)SECRETHIDDEN0x209b…0cf4████████
Proves, without openingthe amount in C is at least 1,000 ADA
Public ledgeranyone can read it
C = v·G + r·HPUBLIC0x1d4a…86b2
Same amount, new blinding
C′ (also 4,200 ADA)PUBLIC0x283b…52a7
C and C′ look unrelated: nobody can tell they hide the same amount
Bob commits too
D (Bob)PUBLIC0x50b5…29db
C + DPUBLIC0x3fe7…5ca4
Anyone can add the points. Only someone who knows both openings can open the sum.
Verifieran auditor, a validator, a counterparty

Sees only C. Learns nothing about the amount.

Alice opens C to the verifiercommit(4,200 ADA, r) = C: acceptedTry another number. Some blinding would make it match C, but Alice can't feasibly find it: that would mean finding a second opening.
Opening the totalC + D opens to 6,700 ADA with blinding r + sThe verifier learns the total, not who put in what.
Checks π against Cproof valid: at least 1,000 ADA, amount still hidden

1. Seal

Alice picks an amount and a fresh random blinding and publishes one curve point, C = v·G + r·H. Think of a sealed envelope: everyone can see it, nobody can read it. Drag the amount or roll a new blinding and watch C change.

2. Hiding

Commit to the same amount again with a new blinding, and you get a completely different point. Because the blinding is random, C reveals nothing about the amount, not even whether two commitments hide the same one.

3. Open (binding)

Later, Alice can hand the opening (v, r) to someone she chooses. They recompute the point and compare it with C. A second opening for a different amount exists, but she can't feasibly find one, so C locks her in. Type another amount to see it fail.

4. Add

Commitments add up: C + D is the commitment to the sum of the amounts, with the sum of the blindings. A ledger can total balances, or check that inputs equal outputs, without seeing any single amount.

5. Prove without opening

A zero-knowledge proof can show a fact about the hidden amount, such as "at least 1,000 ADA", while C stays sealed. Drag Alice's amount below 1,000 ADA and no valid proof exists.

SECRET only Alice knows itPUBLIC anyone can see itPoint values are illustrative.

A commitment on its own only lets you open or not open. Its real power comes with a zero-knowledge proof over the hidden value: “the amount in C is at least 1,000”, “these three commitments add up to that one”, “this commitment holds a 0 or a 1”. The proof reveals nothing else, and C stays sealed.

Encryption to a key: a lockbox with a slot

Section titled “Encryption to a key: a lockbox with a slot”

A commitment can only be opened by someone who knows the opening. Sometimes a third party must be able to read the value without the owner’s cooperation: a tax authority reading salaries, an auctioneer reading bids, election trustees counting votes. For that you encrypt the value to their public key.

ZeroJ uses exponential ElGamal on the same curve. A ciphertext is two points, and it has two useful properties:

  • Fresh randomness every time, so the same value encrypted twice gives unrelated ciphertexts.
  • Adding. Ciphertexts add up like commitments, so a ledger can keep an encrypted running total.

The catch: decrypting ends with a lookup, so it only works for small numbers, such as votes or amounts split into 32-bit pieces (called limbs). Decrypting a 64-bit amount directly would take too long.

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.

Encryption and commitments work well together. A proof can show “this ciphertext encrypts the same amount as this commitment”, so the auditor’s copy can’t be faked. That’s how the sealed-bid auction forces every bid to be readable by the auctioneer, and how confidential payroll stops an employer from under-reporting a salary.

Encrypted delivery: a letter to named readers

Section titled “Encrypted delivery: a letter to named readers”

Suppose a payment is a commitment on-chain. Its owner needs the opening, (v, r), to spend it later, and an auditor may need it too. You could send it privately, but then a lost message means lost money. A confidential note puts the opening on-chain, encrypted separately to each reader.

  • Each reader has a viewing key. The sender seals the opening for each reader with a fresh one-time key, the way Zcash notes are encrypted.
  • A reader scans the chain, opens the deliveries addressed to them, and accepts a note only if the opening recomputes the commitment. A garbage delivery can’t trick them; it shows up as “unopenable”.
  • Everyone else sees the commitment and a few bytes of ciphertext per reader (89 bytes each).

Delivery is about convenience and recovery: a lost wallet can rebuild its balance from the chain. On its own it doesn’t force the sender to tell the auditor the truth; pair it with an encrypted amount and a proof when that matters. See Confidential notes.

A single auditor or trustee is a single point of failure: they could read everything, or lose the key. Threshold decryption splits the secret key among n trustees so that any t + 1 of them can decrypt together, and t or fewer learn nothing.

The trustees create the key together with a distributed key generation (DKG): each one deals shares to the others, and the full secret key never exists anywhere. ZeroJ implements a well-studied DKG (Gennaro, Jarecki, Krawczyk and Rabin) and delivers the private shares over a public board with HPKE (RFC 9180) encryption. A typical policy is: decrypt only the final total, never a single ballot. See Threshold decryption.

Real applications combine the tools:

Use caseCommitmentEncryptionDeliveryThreshold
Private voting with an encrypted tally✓ votes to the election keyShared key: the demo needs all 3 trustees (n-of-n); a t-of-n DKG is available
Confidential loyalty points✓ balances✓ amounts to an auditor✓ to owner and auditor
Confidential payroll✓ salaries✓ to the tax authority, proven✓ to employee and tax authority
Sealed-bid auction✓ bids to the auctioneer, proven
Proof of solvency with hidden balances✓ customer balances✓ to each customer and the auditor
  • They don’t authorize anything. A valid opening or proof says nothing about who may spend a UTxO. Validators still check signatures, replay and the transaction itself. See Application security.
  • They don’t hide the transaction graph. Who pays whom, and when, is still visible on Cardano unless the application hides it separately.
  • Key holders are trusted with what they can read. An auditor who can decrypt can also leak. Threshold keys reduce that risk; they don’t remove it.