Skip to main content

state_mask Circuit

state_mask proves properties about hidden state without revealing it: that a collateral_ratio lies within a required range and that a hidden_balance exceeds a threshold — while committing to the secret values with a Poseidon hash. It is a good first circuit for learning the ZeroStyl workflow. Size: k=10.


What it proves

For witnesses state_value, nonce, collateral_ratio, hidden_balance, and a public threshold, the circuit proves:

  1. commitment = Poseidon(state_value, collateral_ratio, hidden_balance, nonce) — a hash chain binding all the secret values, exposed as a public input.
  2. collateral_ratio ∈ [150, 300] — a bounded range proof.
  3. hidden_balance > threshold — a comparison (both operands are range-checked first, so the comparison is sound).

Because the range and comparison operate on the same cells that feed the commitment, the statements are provably about the committed values — not free witnesses.

Use cases: private solvency ("my collateral ratio is healthy and my balance clears this bar") without disclosing the ratio or the balance; credit-scoring; eligibility checks.


Witness

state_mask.json
{
"state_value": "42",
"nonce": "7",
"collateral_ratio": "200",
"hidden_balance": "5000",
"threshold": "1000"
}
FieldTypeVisibilityDescription
state_valueu64privateSecret value committed via Poseidon
noncefieldprivateCommitment randomness
collateral_ratiou64privateMust lie in [150, 300]
hidden_balanceu64privateMust be strictly greater than threshold
thresholdu64publicPublic minimum balance

Public inputs

InputDescription
commitmentPoseidon(state_value, collateral_ratio, hidden_balance, nonce)
thresholdThe public minimum balance

Run it

zerostyl-debug debug --circuit state_mask --witnesses state_mask.json
zerostyl-prove generate --circuit state_mask --witnesses state_mask.json --output proof.bin
zerostyl-prove verify --circuit state_mask --proof proof.bin --inputs public_inputs.json