Skip to content
Open app

Circuits

The Membership circuit's signals, constraints and files, and how the browser proves with it.

Plaza has one circuit, Membership(32), written in circom 2.2.3 with circomlib's Poseidon. It compiles to 11,057 constraints with seven public signals, and is proven with snarkjs as Groth16 on BN254. The program verifies it with alt_bn128 syscalls (groth16-solana) against the verifying key built into the program.

Public signals

In the order the proof carries them and transact reads them:

authorizationField
Output. Poseidon(nullifierSecret, intent).
rootField
A root of the chosen set. Must be in the ASP's window.
nullifierField
The spent note's nullifier. Must equal the one in the SPP transaction.
outputs[0]Field
The first output's commitment.
outputs[1]Field
The second output's commitment, or 0 when there is none.
exitLabelField
0 for a spend; the label on the ragequit path.
intentField
The payout hash; see The policy proof.

Private signals

labelField
The note's label.
directionField[32]
The label's path bits, leaf to root. Each is 0 (left) or 1 (right).
siblingsField[32]
The sibling at each level of that path.
inputFieldsField[6]
The spent note's fields in SDK order: tree id, hashed asset address, amount, data hash, owner field, blinding.
nullifierSecretField
The holder's nullifier secret for this note.
outputFieldsField[2][6]
Each output's fields, in the same order.
presentField[2]
1 for an output that exists, 0 for none.
exitModeField
1 on the ragequit path, else 0.

Constraints

  • label is not zero, each direction bit and present flag and exitMode is 0 or 1, and exitLabel = exitMode × label.
  • Hashing label up the path with Poseidon(left, right), where direction picks the side, gives root.
  • A note's commitment is Poseidon(3, treeId, assetHash, amount, dataHash, Poseidon(label, ring), Poseidon(ownerField, blinding)), where ring is a fixed field element for Plaza's ring. The amount is range-checked to 64 bits and the tree id to 16.
  • nullifier = Poseidon(inputCommitment, blinding, nullifierSecret), the nullifier SPP uses.
  • outputs[i] = present[i] × commitment(outputFields[i], label): every output carries the input's label.
  • authorization = Poseidon(nullifierSecret, intent).

Files

The API serves the compiled circuit for the browser:

FileRouteSize
Witness generator/artifacts/membership.wasm3,370,024 bytes
Proving key/artifacts/membership.zkey7,559,022 bytes
Verifying key/artifacts/verification_key.json

A proof is 256 bytes. In the localnet flows, Node proved the membership proof in 392 to 460 ms and SPP's proof in 88 to 136 ms.

Building a witness

The leaves come from GET /sets/{asp}/roots/{root}/leaves. The SDK's AssociationTree rebuilds the root from them and gives the label's siblings and direction:

path.ts
import { AssociationTree, initializePoseidon } from '@plaza/sdk'

await initializePoseidon()
const tree = new AssociationTree(leaves.map(BigInt))
if (tree.root !== BigInt(root)) throw new Error('Leaves do not match the published root')
const { siblings, direction } = tree.path(label)