Midnight

Proofs in the browser, no wallet

How a person's browser builds, proves and seals an answer to Midnight without a wallet, a proof server or tokens, and how Mitome pays for it.

Answering a Midnight contract normally needs a wallet: to hold keys, to prove, and to pay. Mitome's answers need none of that. Every part below is Midnight's own code, wired together in a way the official examples don't show.

  1. 01

    Throwaway keys

    Made in the browser for this call

    ZswapSecretKeys.fromSeed

  2. 02

    Build the call

    Run against the chain's current state

    createUnprovenCallTx

  3. 03

    Prove it

    In a Web Worker, about 12 s

    zkir-v3 prove

  4. 04

    Seal it

    Nothing to balance: an answer moves no value

    bind()

  5. 05

    Mitome pays

    Adds the DUST fee, submits

    receipt on Midnight

One answer, from the person's browser to a receipt on Midnight
Sequence of one answer: the person's browser starts the checks, proves a work email with a 6-digit code, gets a pass, the worker checks it hasn't answered and proves submitChecked in about 12 seconds, the sealed answer goes to Mitome's API, which adds the DUST fee and submits to Midnight; the receipt is recorded, and the owner's browser later reads the sealed answers and the receipts and finds all verified
One answer to a form with a work-email check, from the person's browser to the owner's results.

In the browser

All of Midnight runs in one Web Worker, so typing never stutters while it works.

  1. Load early. When the form opens (or, in an embed, at the first tap), the worker starts and fetches the circuit's keys: about 4 MB for the answer circuit, cached by the browser after the first form. A module worker drops messages sent while its WebAssembly is still loading, so it says "ready" first and the page waits for that.
  2. The person's secret. A random 32-byte secret for this form, made once and kept in the browser's storage. It's the private input the circuit uses; it never leaves the worker.
  3. Prove before Submit. A form without checks is proven as soon as it opens; a form with checks right after the last check passes. Building the call runs the contract against the chain's current state first, so "already answered", "paused" or "closed" show at once, before anything is sent.
  4. Seal. The proven transaction is bound (bind()), which locks its contents: a sponsor can add a fee to it, nothing else.
  5. Submit is instant. At Submit the page only encrypts the answers to the team's keys (read from Midnight; on Preprod through Mitome's read-only window), signs them with the answer's one-time key and sends. If the proof is older than 45 minutes, it's made again first.

No proof server is involved: a hosted prover would see the person's secret and could link their answers.

Mitome's API receives the sealed transaction and the sealed answer. Before paying, it checks:

  • the signature on the sealed answer, by the one-time key sent with it (once the call is on chain, that key must match the one it recorded);
  • that the transaction is a single call to submitChecked or submitOpen on this form's contract, moving no value;
  • the form is live, inside its times, under its response limit, the sender's network address is under 30 answers an hour, and the form under 60 a minute.

Then its sponsor wallet adds the DUST fee and submits. The person sees Recording on Midnight… at once; Mitome follows the transaction until it's included and the receipt is in the contract, then marks the answer Recorded on Midnight.

Stale proofs

A proof states how much its call writes, sized against the contract's state when it was built. If other answers change the receipts map before it's included, Midnight can turn it down (error 104). Mitome marks the answer for a rebuild, the person's browser makes a fresh proof with the same answer key and pass, signs it, and Mitome sends it again, up to four more times (five tries in all). In testing this happened to 2 of about 11 answers, and 0 of 8 in a dedicated run.

Measured

On a local Midnight network, 2026-11-20 and 21:

MeasuredResult
Proof in the browser, first answer14.8 s (15.1 s inside an embed on another site)
Proof in the browser, warm12.35 to 12.39 s
Worker ready after the page loadsabout 0.5 s
Submit to thank-you, proof already made0.15 s
Sealed answer transaction5 KiB
Fee added, included and indexed16 to 20 s
Deploying a form15 to 18 s

On Midnight Preview, 2026-11-23:

MeasuredResult
Publishing a form17.6 to 22.7 s; fee about 5.5 DUST
Submit to thank-you, proof already made0.0 s (open form), 0.8 s (work-email check)
Submit to "Recorded on Midnight"18.0 s (open form), 23.5 s (work-email check)
Fee for an answer0.36 DUST, paid by Mitome

No special headers are needed (no cross-origin isolation), so the same works inside an embed on any site.

On this page