Proofs

Proofs

What a send and a withdraw prove about numbers the chain never sees.

When you send, the chain has to be sure of three things it can't see: that the amount isn't negative, that your balance covers it, and that the ciphertext the recipient receives holds the same amount your balance lost. You prove each with a zero-knowledge proof, made in your browser or by the SDK, and the ZK ElGamal Proof program verifies it on chain. A proof shows a statement is true and carries nothing else about the numbers in it.

The proofs of a send

ProofWhat it shows
EqualityThe ciphertext of your balance after the send holds the same number as a commitment you supply, which the range proof then works on.
Ciphertext validityThe amount's ciphertexts are well formed and hold one amount, encrypted to the sender's key and to the recipient's.
RangeThe amount and your balance after the send are both zero or more, so you can't send more than you have.

The proofs of a withdraw

A withdraw's amount is public, so there is nothing to encrypt for a recipient and no validity proof. It carries the other two:

ProofWhat it shows
EqualityYour balance after the withdraw matches the commitment you supply.
RangeThat balance is zero or more.

The proof of set up

Setting up a Hush account carries one small proof, that you hold the secret half of the encryption key you are registering.

Where the proofs go

Verification is the heavy part of a send. These are the compute units the ZK ElGamal Proof program spends on each. A range proof is priced by how many bits it covers in total: a send's covers the amount's two parts and the new balance together, and a withdraw's covers the new balance alone.

ProofCompute units
Equality8,000
Ciphertext validity6,400 to 16,400
Range, 64-bit111,000
Range, 128-bit200,000
Range, 256-bit368,000

A range proof alone is 672 to 800 bytes, and a Solana transaction holds 1,232. The three proofs of a send don't fit in one transaction beside the transfer, so they go ahead of it. A send is 6 transactions:

  1. Equality proof and ciphertext validity proof

    Each is sent to the ZK ElGamal Proof program, which verifies it and writes the result into a small context-state account. One transaction each.

  2. Stage the range proof

    The range proof is too large to ride in the transaction that verifies it. Two transactions write its bytes into a record account.

  3. Range proof

    The ZK ElGamal Proof program reads the staged bytes, verifies them, and writes the result into a third context-state account.

  4. Send

    The transfer instruction names the three context-state accounts in place of carrying the proofs. The token program reads the verified results, checks they describe this transfer, and moves the ciphertexts. The proof accounts are closed in the flow and their rent returns to your wallet.

A withdraw's encrypted step has the same shape with one proof fewer: 4 transactions, equality proof, stage range proof, range proof, withdraw to public balance. Its release is 1 more.

You approve a send's transactions together, in one wallet request, and the app shows them as the progress of one send. Measured figures has the compute units and sizes of each flow.