Skip to content

Sealed-bid auction

View Markdown

In an open auction, every bid is visible, so late bidders can shade their bid against the others, and on a public ledger the same thing happens automatically: anyone can read every bid in the mempool and on-chain. A sealed-bid auction fixes that. Each bidder submits one hidden bid, and the highest wins.

The usual way to seal a bid on a blockchain is commit and reveal: publish a hash of your bid, then reveal the bid after the deadline. That has a weak spot. A bidder who sees they’re losing, or who wants to disrupt the auction, can simply not reveal. Forfeiting a deposit is the most you can do about it, and the auction then ends with a wrong price.

This design closes that gap. Each bid is encrypted so that only the auctioneer’s key opens it, and a zero-knowledge proof shows the hidden bid is valid. The auctioneer can read every bid from the moment it’s placed, so there’s nothing left to reveal and no way to back out. A second proof then forces the auctioneer to settle honestly: it reads the bids but can’t change who wins.

Sealed-bid auction · step 1 / 6
Bidderseach knows only its own bid
Alice's bidSECRETHIDDEN40 ADA████████proof: 10 ≤ bid ≤ 100, sealed to the auctioneer
Bob's bidSECRETHIDDEN70 ADA████████proof: 10 ≤ bid ≤ 100, sealed to the auctioneer
Carol's bidSECRETHIDDEN70 ADA████████proof: 10 ≤ bid ≤ 100, sealed to the auctioneer

Alice, Bob and Carol each have 100 ADA ready for the deposit.

Nobody can withdraw a bid or refuse to reveal it: the auctioneer can already read it.

Lot on CardanoSealedBidAuction
item · deposit · reservePUBLICPainting · 100 ADA · 10 ADA
auctioneer key (from its registry)PUBLIC0x3704…7c76
Bids in the lot datum
  • Alice0x305d…fec2
  • Bob0xb196…95a1
  • Carol0x8ec0…d826
300 ADA of deposits locked
Settle redeemerwinner = Bob, price = 70 ADA: proof validOnly the winner and the price become public. Losing bids never do.
Payouts, all checked by the validator
    A dishonest settleno settlement proof exists: rejected
    Auctioneerreads every bid, can't fake the result
    secret keySECRETHIDDEN0x5f07…6e23████████
    Decrypted, privately
    AliceSECRETHIDDEN40 ADA████████
    BobSECRETHIDDEN70 ADA████████
    CarolSECRETHIDDEN70 ADA████████
    πsettlement proofover every bid
    Tries to claimCarol wins at 70 ADAthe decryptions say otherwise: no proof can be made
    Try other bidsValid bids are 10 ADA to 100 ADA. Ties go to the earlier bid.

    1. Open the lot

    The seller locks the Painting in a lot on Cardano, with a deposit of 100 ADA and a reserve of 10 ADA. The lot names the auctioneer's public key, taken from the auctioneer's on-chain key registry.

    2. Sealed bids

    Each bidder encrypts its bid so that only the auctioneer's key opens it, proves the hidden bid is between the reserve and the deposit, and locks the 100 ADA deposit. Drag a bid outside that range below: no proof exists, so the bid can't be placed.

    3. Bidding closes

    After the deadline the lot accepts no more bids. Everyone can see who bid and how many deposits are locked, but not one amount. Unlike commit-and-reveal, there's no reveal phase for a losing bidder to skip.

    4. Settle with a proof

    The auctioneer decrypts every bid privately and proves, over all the bids in the lot, that Bob's bid of 70 ADA is the earliest highest. Only the winner and the price are published.

    5. Payouts

    The validator checks every payout in the settle transaction: the seller gets the price, the winner gets the item and the rest of its deposit, and every other bidder gets its whole deposit back. If nobody settles in time, anyone can trigger a full refund.

    6. A cheating auctioneer

    The auctioneer can read the bids but can't change the result: a proof for any other winner or price doesn't exist. Copying another bidder's ciphertext fails too, because each bid proof is bound to its bidder's key.

    SECRET visible only in the views allowed to see itPUBLIC on-chain for anyoneKeys and ciphertexts are illustrative.

    A bidder proves “this ciphertext, which only the auctioneer can decrypt, holds a bid between the reserve and my deposit”. The auctioneer later proves “decrypting every bid in the lot, the earliest highest bid is bid number w, at price p”.

    Two building blocks make this work:

    • ElGamal encryption on the Jubjub curve. A bid b becomes a ciphertext (A, B) under the auctioneer’s public key. Anyone can encrypt; only the auctioneer’s secret key decrypts. ZeroJ’s ZkElGamal.encrypt lets a circuit prove what a ciphertext contains without opening it. See Commitments & encryption.
    • Groth16 proofs. One per bid (BidProof), and one for settlement (SettleProof), each checked by the auction’s validator on Cardano.

    Bidders lock the same deposit, so the ADA moving on-chain doesn’t leak the bid. The deposit is also the upper limit: a bid can never exceed what the bidder has locked.

    ValueBidderAuctioneerSellerPublic
    Its own bidKnows itDecrypts it—Hidden
    Other bidders’ bidsHiddenDecrypts themHiddenHidden
    Auctioneer’s secret key—Holds it—Hidden
    Who bid, and how many bidsPublicPublicPublicPublic
    Deposit, reserve, deadlines, itemPublicPublicPublicPublic
    Bid ciphertexts and bid proofsPublicPublicPublicPublic
    Winner and winning pricePublic after settlementProves themPublic after settlementPublic after settlement
    Losing bid amountsOnly its ownDecrypts themBounded, never publishedBounded, never published

    The winning price is public by design: the seller is paid in ADA, so the amount shows up in the settlement transaction anyway.

    Losing bids never appear on-chain in the clear, but they aren’t fully hidden either. Every bid is proved to lie between the reserve and the deposit, and settlement proves the winner is the earliest highest bid. So once the price is public, everyone knows each losing bid lies in [reserve, price], and a losing bid placed before the winner’s lies strictly below the price.

    1. Register the auctioneer’s key. The auctioneer publishes its ElGamal public key in an on-chain key registry, with proofs that it knows the matching secret key.
    2. Open a lot. The seller locks the item in a lot UTxO and sets the deposit, the reserve, the bidding deadline and the settlement deadline. The lot names the auctioneer’s key from the registry.
    3. Bid. Each bidder encrypts its bid to the lot’s key, proves reserve ≤ bid ≤ deposit in zero knowledge, signs, and adds exactly the deposit to the lot. The validator appends the bid to the lot’s datum. The proof is bound to the bidder’s key hash, so a copied ciphertext and proof fail for anyone else.
    4. Close. After the bidding deadline the validator accepts no more bids.
    5. Settle. The auctioneer decrypts every bid privately, finds the earliest highest bid and proves it. The validator checks the proof against every bid in the datum, then checks the payouts: the seller gets the price, the winner gets the item plus the rest of its deposit, and every other bidder gets its deposit back.
    6. Refund. If nobody settles before the settlement deadline, anyone can return every deposit and give the item back to the seller. A lot with no bids goes back to the seller.

    Both circuits are from the demo’s auction/circuit package. This is the bid proof, as in the demo apart from the Javadoc:

    BidProof.java
    import org.zeroj.circuit.annotation.*;
    import org.zeroj.circuit.lib.zk.ZkElGamal;
    import org.zeroj.circuit.lib.zk.ZkElGamalPublicKey;
    @ZKCircuit(name = "sealed-bid", version = 1)
    public class BidProof {
    @Prove
    void prove(ZkContext zk,
    @Public ZkField bidderInt, // the bidder's key hash, as a number
    @Public @UInt(bits = 32) ZkUInt deposit,
    @Public @UInt(bits = 32) ZkUInt reserve,
    @Public ZkField pkU, @Public ZkField pkV, // the auctioneer's public key
    @Public ZkField aU, @Public ZkField aV, // the ciphertext (A, B)
    @Public ZkField bU, @Public ZkField bV,
    @Secret @UInt(bits = 32) ZkUInt bid,
    @Secret @UInt(bits = 252) ZkUInt k, // encryption randomness
    @Secret ZkField bidderSquared) {
    // A public input that no constraint uses doesn't affect Groth16 verification, so the
    // bidder is bound with a trivial constraint. Without it, a proof could be copied.
    bidderInt.mul(bidderInt).assertEqual(bidderSquared);
    var key = ZkElGamalPublicKey.fromVerifierFixedPublic(zk, pkU, pkV);
    ZkElGamal.encrypt(zk, bid, k, key).assertAffineEquals(zk, aU, aV, bU, bV);
    bid.lte(deposit).assertTrue();
    bid.gte(reserve).assertTrue();
    }
    }

    The settlement proof is the interesting part. The auctioneer’s secret key sk and the decrypted bids m_i are private inputs. For each bid it reuses the encryption gadget backwards: encrypting m_i with randomness sk under the “key” A_i must give (PK, B_i). That says [sk]·G = PK and [m_i]·G + [sk]·A_i = B_i, which is exactly “m_i is the decryption of bid i”. Then it picks the winner and checks the price. This is the core of the demo’s SettleProof:

    SettleProof.java (core)
    for (int i = 0; i < bids; i++) {
    // m_i is the decryption of bid i under the auctioneer's key
    var handle = ZkElGamalPublicKey.fromVerifierFixedPublic(zk, cts.get(4 * i), cts.get(4 * i + 1));
    ZkElGamal.encrypt(zk, m.get(i), sk, handle)
    .assertAffineEquals(zk, pkU, pkV, cts.get(4 * i + 2), cts.get(4 * i + 3));
    isWinner[i] = w.isEqual(zk.constant(i + 1));
    selected = selected.add(isWinner[i].asField());
    price = price.add(isWinner[i].asField().mul(m.get(i).asField()));
    }
    selected.assertEqual(one); // exactly one winner
    price.assertEqual(p.asField()); // the published price is the winner's bid
    for (int i = 0; i < bids; i++) {
    m.get(i).lte(p).assertTrue(); // nobody bid more
    // a bid before the winner must be strictly lower, so the earliest highest bid wins ties
    ZkField beforeWinner = zero;
    for (int j = i + 1; j < bids; j++) beforeWinner = beforeWinner.add(isWinner[j].asField());
    beforeWinner.mul(one.sub(m.get(i).lt(p).asField())).assertEqual(zero);
    }
    CircuitConstraintsPublic inputs
    sealed-bid7,0119
    sealed-bid-settle, 1 bid6,9508
    sealed-bid-settle, 2 bids13,33012
    sealed-bid-settle, 3 bids19,71016

    There’s one settlement circuit per bid count, so the demo caps a lot at three bids.

    The demo’s SealedBidAuction is one JuLC multi-validator: a minting policy for the one-shot lot token and a spending validator for the lot. Its actions are:

    ActionWhat the validator checks
    Open (mint)The seller signs; exactly one lot with the item and no bids; the key matches the auctioneer’s current registry entry
    Bid (spend)Before the bidding deadline; a new bidder signs; exactly the deposit is added; the datum is the old one plus exactly this bid; BidProof verifies
    Settle (spend + burn)Between the two deadlines; SettleProof verifies over every bid in the datum; the seller, the winner and every loser are paid
    NoBids (spend + burn)After bidding, with no bids, signed by the seller: the item goes back
    Refund (spend + burn)After the settlement deadline, submitted by anyone: every deposit and the item go back

    Every payout goes to the recipient’s exact address and carries a datum naming the lot token, so one output can’t count as a payout for two lots at once.

    Measured on Yaci DevKit with mainnet protocol parameters (ADR-0008 r4 in the demo repository, at commit 814b2f0):

    TransactionCPU steps (share of the per-transaction limit)Fee
    Open3.3%about 0.51 ADA
    Bidabout 46%about 0.90 ADA
    Settle, 3 bids60.7%about 1.03 ADA
    Refund4.1%about 0.53 ADA

    These were measured before ZeroJ PRs #85 and #86 cut the cost of the on-chain Groth16 verifier, so bids and settlements cost less on ZeroJ 0.1.0-pre13 and later.

    • The auctioneer sees every bid. It’s trusted for confidentiality, not for the outcome. It could leak bids to a favoured bidder while bidding is open, and nothing here prevents that. Removing that trust needs a different design, such as a key split among several trustees.
    • Demo custody. The demo server holds the auctioneer’s decryption key, and GET /api/auction returns the auctioneer’s view (auctioneerView, every decrypted bid) to anyone who calls it. That is the demo operator’s view. Privacy here holds against chain and mempool observers, not against the demo server.
    • No forward secrecy. The ciphertexts stay on-chain. Whoever holds the auctioneer’s secret key, now or in the future, can read every bid ever placed in its lots.
    • The auctioneer can refuse to settle. Bidders then wait until the settlement deadline and refund. They lose time, not funds.
    • No Sybil protection. The first three distinct keys fill a lot, so one party with three keys can shut others out. A real auction needs more bid slots or bidder admission.
    • The settlement argument needs review. Reusing the encryption gadget as a decryption check is the demo’s own argument. Its design reviewers checked it, but it hasn’t been externally reviewed.
    • Development setup. The demo’s circuits use a single-party development setup, so whoever ran it could forge proofs. Real keys come from a multi-party ceremony (Trusted setup, explained).
    • Not audited. ZeroJ’s ElGamal profile is experimental and not externally audited. Treat the demo as a blueprint, not a production auction.

    The demo is the Sealed-bid auction tab of the pedersen-commitments app in zeroj-usecases. With Yaci DevKit running (see Run the demos):

    Terminal window
    ./demo.sh pedersen
    # opens http://localhost:8093; pick the "Sealed-bid auction" tab

    To run it without Docker, use Java 25 and ./gradlew -p pedersen-commitments bootRun -PwithFrontend from the repository root.

    The first start runs development setups for every circuit, which takes several minutes; later starts reuse the cached keys. In the tab you can open a lot (default: “Painting”, 100 ADA deposit, 10 ADA reserve), place bids from Alice, Bob and Carol, watch the auctioneer’s private panel, settle, and try the cheats:

    • a bid above the deposit or below the reserve: no bid proof exists, so the app refuses it;
    • the auctioneer naming the wrong winner: no settlement proof exists;
    • copying another bidder’s ciphertext and proof: the validator rejects it, because the proof is bound to the original bidder.

    The DevKit end-to-end test also submits a late bid, which the validator rejects.