The transact circuit
The one zero-knowledge circuit behind every private spend - its inputs, constraints, public inputs, ExtData binding, sizes and toolchain.
Every private spend, whether a send, an exit, a payment link or its claim, is one proof of the transact circuit
(circuits/crates/transact). It spends three notes and creates four, in three groups:
| Group | Inputs | Outputs | Asset | What may leave |
|---|---|---|---|---|
| Main pair | in[0], in[1] | out[0], out[1] | One private asset: HYPE or a listed token | exit_shares of asset |
| Fee pair | in[2] | out[2] | HYPE | fee_shares of HYPE: a token operation's gas |
| Pad | out[3] | HYPE, zero shares | Nothing |
The pad exists so that a transaction always inserts two pairs of leaves into the note tree. All three inputs are owned by one wallet key. The vault verifies the proof with an on-chain UltraHonk verifier.
Public inputs
In this exact order, the order PrivateVault._publicInputs builds (and the public view publicInputs(t) returns):
| # | Circuit name | Contract field | Meaning |
|---|---|---|---|
| 0 | root | t.root | A Merkle root the vault knows (isKnownRoot) |
| 1-3 | nullifiers[3] | t.nullifiers | Nullifiers of the three inputs: the main pair, then the fee note |
| 4-7 | out_commitments[4] | t.commitments | Commitments of the four outputs: the main pair, the fee change, the pad |
| 8 | exit_shares | t.exitAmount | Base units of exit_asset leaving the main pair |
| 9 | exit_asset | uint160(t.exitAsset) | The asset leaving the main pair: 0 for HYPE, or when nothing leaves it |
| 10 | fee_shares | t.feeAmount | Wei of HYPE leaving the fee pair |
| 11 | ext_data_hash | extDataHash(t.ext) | keccak256(abi.encode(ext)) mod p |
| 12 | domain_hi | High 128 bits of the vault's EIP-712 domain separator | |
| 13 | domain_lo | Low 128 bits of the domain separator |
The vault computes ext_data_hash from the calldata and the domain halves from its own _domainSeparatorV4(); the
prover does not choose them. The verifier's NUMBER_OF_PUBLIC_INPUTS constant is 22: these 14 plus the 8 field
elements of the pairing-point object (PAIRING_POINTS_SIZE) that the proof itself carries.
Private inputs
| Name | Type | Meaning |
|---|---|---|
asset | Field | The main pair's asset: 0 for HYPE, otherwise uint160(token) |
in_nk | [Field; 3] | Nullifier key of each input. Index 0 and 1: the main pair; 2: the HYPE fee note |
in_rho, in_r | [Field; 3] | Note secrets of each input |
in_shares | [Field; 3] | Amount of each input, in its asset's base units |
in_index | [u32; 3] | Leaf index of each input in its tree |
in_path | [[Field; 24]; 3] | Merkle siblings of each input, bottom to top |
out_stub | [Field; 4] | Stub of each output, H(opk, rho, r) of its owner. Index 3, the pad's, is free |
out_shares | [Field; 4] | Amount of each output. out_shares[3] must be 0 |
pk_x, pk_y | [u8; 32] each | The owner's wallet key, uncompressed secp256k1, big-endian |
signature | [u8; 64] | The wallet's Spend signature, `r |
Constraints
The wallet key enters as four 128-bit limbs, x_hi, x_lo, y_hi, y_lo, taken big-endian from pk_x and pk_y.
Each note is hashed in its slot's asset, with asset_commitment (see Notes):
asset < 2^160
in_asset = [asset, asset, 0] 0 = HYPE
out_asset = [asset, asset, 0, 0]For each input i:
in_shares[i] < 2^120
in_index[i] < 2^24
cm_i = asset_commitment(H(H(in_nk[i], x_hi, x_lo, y_hi, y_lo), in_rho[i], in_r[i]), in_shares[i], in_asset[i])
if in_shares[i] != 0: merkle_root(cm_i, in_index[i], in_path[i]) == root
nullifiers[i] == H(2, in_nk[i], cm_i, in_index[i])The three nullifiers are pairwise distinct. Without this, the same note given as in[0] and in[1] would count
twice, and only the vault's own duplicate check would stop it.
For each output j:
out_shares[j] < 2^120
out_commitments[j] == asset_commitment(out_stub[j], out_shares[j], out_asset[j])
out_shares[3] == 0 the pad carries nothingThen conservation of value, per pair:
exit_shares < 2^120, fee_shares < 2^120
in_shares[0] + in_shares[1] == out_shares[0] + out_shares[1] + exit_shares main pair, in asset
in_shares[2] == out_shares[2] + fee_shares fee pair, in HYPEAnd the asset of what leaves:
if exit_shares != 0: exit_asset == asset
else: exit_asset == 0The 120-bit range checks make the sums unable to wrap the field: no sum of three amounts reaches 2^122, far below
p. Without them an output of p - 1 could balance a larger second output. Every input is owned by the same wallet
key, because one (pk_x, pk_y) enters every owner key. A zero-value input is a
dummy and needs no membership, but its nullifier is still checked. Value cannot move
between assets: the main pair balances in one asset and the fee pair in HYPE, and a token note can never hash as a
HYPE note.
exit_asset does not reveal the asset of a private send, since nothing leaves the main pair. The circuit lets a
HYPE main pair pay its gas from the fee pair too (fee_shares, with exit_shares = 0), as a token operation must:
the SDK does so for a private HYPE send whenever the wallet holds a spare HYPE note, and such a send has the same
public inputs as a token send. A HYPE send that pays its gas out of the main pair (exit_shares the gas fee,
fee_shares = 0) is recognisable as HYPE.
Finally, the authorization:
transaction = H(root, nf0, nf1, nf2, cm0, cm1, cm2, cm3, exit_shares, exit_asset, fee_shares, ext_data_hash)
as 32 bytes, big-endian
struct_hash = keccak256(SPEND_TYPEHASH || transaction) SPEND_TYPEHASH = keccak256("Spend(bytes32 transaction)")
domain_hi, domain_lo < 2^128
digest = keccak256(0x19 || 0x01 || domain_hi (16 bytes) || domain_lo (16 bytes) || struct_hash)
ecdsa_secp256k1_verify(pk_x, pk_y, signature, digest) == trueThis is the EIP-712 digest the wallet signed (see Keys). H is Poseidon2 over BN254 and
merkle_root hashes the leaf up 24 levels, taking the sibling from in_path and the side from each bit of the index
(see The note tree).
Checks outside the circuit
PrivateVault adds the checks that need chain state or calldata:
rootis a known root: one of the last 64, or the final root of a full tree (UnknownRoot);- the three nullifiers differ and none is spent (
DuplicateNullifier,NullifierAlreadySpent); - commitments and nullifiers are below
p(NotAFieldElement), andexitAmountandfeeAmountare below 2^120 (AmountTooLarge); - the HYPE leaving is
feeAmount, plusexitAmountwhenexitAssetis 0, andext.gasFeeis at most that (FeeExceedsExit); - if HYPE leaves beyond the gas fee,
ext.recipientis not zero (ZeroAddress); - for a token exit (
exitAssetnot 0): the token is listed (TokenNotListed),exitAmountis not zero (ZeroAmount),ext.recipientis not zero (ZeroAddress), andfeeAmount == ext.gasFee(FeeAmountNotGasFee), so the HYPE side pays the gas and nothing else, and one operation never pays out two assets; - through
transact:ext.calleris zero or the sender, never the vault (WrongCaller), andext.gasFeeis zero (GasFeeNotAllowed); - through
validateUserOp:ext.calleris the vault (WrongCaller), the operation's call gas limit is at least the minimum inext.data, andext.gasFeecovers the operation's maximum cost (GasFeeBelowCost). See Gas and ERC-4337.
An invalid proof reverts transact with InvalidProof. In validateUserOp it returns the ERC-4337 signature-failure
code instead, and nothing is written.
ExtData
struct ExtData {
address recipient; // receives the exit, less the gas fee and the exit fee
address caller; // if non-zero, the only allowed submitter: the vault itself for ERC-4337
uint256 gasFee; // wei of HYPE leaving: the operation's gas (ERC-4337 only; zero for transact)
bytes data; // ERC-4337: abi.encode(minCallGasLimit)
bytes ciphertext0; // encrypted output note 0
bytes ciphertext1; // encrypted output note 1
bytes ciphertext2; // encrypted output note 2, the HYPE fee change
bytes ciphertext3; // encrypted output note 3, the pad
}
function extDataHash(ExtData memory ext) public pure returns (uint256) {
return uint256(keccak256(abi.encode(ext))) % NoteHash.FIELD;
}Everything in ExtData is bound to the proof and to the wallet's signature, so no submitter can change it:
| Field | What binding it prevents |
|---|---|
recipient | Redirecting an exit |
caller | Submitting an ERC-4337 proof some other way, for example straight to transact |
gasFee | Raising the gas fee a user pays |
data | Lowering the minimum call gas, which would let a bundler starve the execution step that pays an exit |
ciphertext0 to ciphertext3 | Replacing the encrypted notes, which would make them unfindable for their owners |
Sizes
| Measure | Value |
|---|---|
| Circuit size | 87,298 gates, in a domain of 2^17 |
| ACIR | 2,144 opcodes |
| Public inputs | 14 field elements, 448 bytes |
| Proof | 9,152 bytes |
A transact that verifies the real proof and updates state | about 5.1M gas (5,139,206 for a token unshield in the end-to-end test) |
The circuit grew by one Merkle path and two outputs and still fits 2^17, so the same reference string serves.
Measured numbers are listed with the rest in Constants.
Proof system and toolchain
| Component | Version | Where it is pinned |
|---|---|---|
nargo | 1.0.0 | circuits/scripts/toolchain.sh |
bb (Barretenberg) | 5.2.1 | circuits/scripts/toolchain.sh |
@noir-lang/noir_js | 1.0.0 | packages/sdk/package.json, packages/mcp/package.json |
@aztec/bb.js | 5.2.1 | packages/sdk/package.json, packages/mcp/package.json |
| noir-lang/poseidon | v0.3.0 | circuits/crates/*/Nargo.toml |
| noir-lang/keccak256 | v0.1.3 | circuits/crates/transact/Nargo.toml |
| Solidity (verifier) | 0.8.38, 10,000 optimizer runs | contracts/foundry.toml |
toolchain.sh downloads nargo and bb from their GitHub releases into circuits/.toolchain/bin and checks each
download against its release SHA-256 digest; the versions are never resolved by bbup. The checks behind these
versions are recorded in docs/elysium/dependency-check.md.
The proof system is UltraHonk. It needs no circuit-specific trusted setup: it uses Barretenberg's universal CRS
(common reference string). The verifier is generated with the EVM target (bb write_vk -t evm,
bb write_solidity_verifier -t evm): the zero-knowledge variant with a keccak transcript. It is deployed as
HonkVerifier (0x29688590CA80928f8f0039334D9f723180cd482a):
| Verifier constant | Value |
|---|---|
VK_HASH | 0x078b97d5f97a98f75ff6ba5ffddaf4f675624b082d2e489bce86ee88b3dbb39a |
N, LOG_N | 131072 (2^17), 17 |
NUMBER_OF_PUBLIC_INPUTS | 22 |
NUM_SMALL_IPA_OPENING_CLAIMS | 5: the small-subgroup IPA also opens the grand sum at 1 |
HonkVerifier calls two linked libraries, RelationsLib and ZKTranscriptLib. The deploy scripts refuse a verifier
source without NUM_SMALL_IPA_OPENING_CLAIMS = 5, or whose keccak256 differs from the pinned bb 5.2.1 output. Before
the vault is deployed they check that the deployed verifier is the 10,000-run build of that source and that it
accepts the repository's fixture proof.
Where proving happens
Proofs are built on the user's device. The app runs noir_js to solve the witness and bb.js (UltraHonkBackend,
verifierTarget: "evm") to prove, in the browser, loading 2^17 CRS points. The page is cross-origin isolated
(Cross-Origin-Opener-Policy: same-origin, Cross-Origin-Embedder-Policy: require-corp) so bb.js can use
WebAssembly threads. The witness, which holds nk, the note secrets and the signature, never leaves the device.
The CRS files (g1_compressed.dat, g2.dat, grumpkin_g1_v2.dat) are served by the app itself from /crs. They
match SHA-256 hashes pinned in apps/web/scripts/fetch-crs.mjs, which can re-check them. Otherwise bb.js would fetch them from Aztec's CDN, which would see
the user's IP each time they prepare a private transaction.
The verifier is an immutable of the vault's implementation. A changed circuit needs a new verifier, and so a new implementation behind the same vault proxy; see The vault.
Keys
How the privacy keys are derived from one wallet signature, why every spend needs a fresh wallet signature, and how keys are registered.
The vault
PrivateVault in depth: its state, shielding HYPE and listed tokens, private transactions, exits with the 1% fee and the 24-hour hold on large ones, per-token limits and books, the fee sweeps, the pause, the three roles, the upgrades and the invariants the tests check.