Skip to content
Prototype · demo records are simulated, the trusted setup is single-contributor · Make a proof, no wallet needed

Setup

The circuit and the keys. Everything a checker needs to reproduce a proof, with hashes.

Single-contributor setup, demo only. Phase 2 has one contribution, made on the build machine. Whoever made it could forge proofs if they kept the randomness, so a seal here is a demonstration, not something to rely on for real stakes. A multi-party ceremony is Concept.

Trusted setup

Proof systemGroth16 on BN254 (snarkjs 0.7.6)
Circuitcircuits/zkryn_threshold.circom · circom compiler 2.2.3
Constraints8,715 non-linear + 1,700 linear · 6 public inputs, 5 private, 2 outputs
Phase 1 (Powers of Tau)Privacy & Scaling Explorations perpetual powers of tau, contribution 80, prepared for 2^14 constraints. File · sha256 3ca1149e9349b22b0ee0649399cfb787677129b7b1189d1899fc0d615d9583db
Phase 2 contributionf474477a019a121068c17125ed6cca2d31307d2eb7f20f7a7d9086e48d197b3b2d982f9a5693003c4ecfa596338d3784c38c1f8bbe24d319a951a57e7c809021
Circuit hashcd8462118ab5ba57cdf1173a96f57b20cc5095b8e91bb475f121fb3f4007d5f735ffe4ae9d31c7a0b2cc7c5383f558a352b4f8ca342540434f09d9869e17f50e
r1cs sha25623fe6cc10b5a298aad04eb2cb54624f9f6c7ad15e65c3608dba18b936c91efcb

Files served to your browser

/zk/zkryn_threshold.wasmsha256 c5c32747eec52a20d7f793d4efd2a3d8af56859495d4d80cbe35628ff67705e2
/zk/zkryn_threshold_final.zkeysha256 edb36b5f2d7864da13a56c0de2f5e0dcb68f673d62f534298dd1be2b5fc52ce5
/zk/verification_key.jsonsha256 1e8bcd903c334d3d73e068d60803061fd9c11ceb93949c439d862cef11d2a838
/zk/snarkjs.min.jssha256 3f61bbd9ac0a10173902eaef65b510fa4e9a2c057f759c7f18a6d0446b20fd06

Rebuild them yourself: npm run circuit:build compiles the circuit, checks the Powers of Tau hash and makes a NEW phase 2 key (so a new verifier). The full list lives in /zk/manifest.json.

Test issuer (public key, simulated records)

EdDSA on Baby Jubjub with Poseidon. The private seed is published on purpose so the demo works for anyone; it is the reason every record it signs is simulated data.

Seedzkryn-test-issuer-v1
Ax16216127621238133708595298584463470849338998179679084316721861441985927187525
Ay2831494325277229381013688692150696262499304889502588210487753360489056656360

Sample account (public key)

Address0xC67857d26B81b0a71F233B6A33f0d316C5fE9509
Keykeccak256("zkryn sample account v1")

Contracts on Robinhood Chain

Verifier creation0xa1fe73b7…aea14ed2 · block 127,317,145
Gate book creation0xba28c6d7…fd26a9bf · block 127,317,254

The verifier is generated by snarkjs from this key. The gate book holds rules and seals: no funds, no global admin, no upgrade. Both were deployed by one wallet; anyone can confirm they run this repository's code with npm run verify-deployment.

Concept (not built)

  • · a real issuer that signs actual positions
  • · a multi-party phase 2 ceremony
  • · several assets or a sum of positions in one proof
  • · $ZKRYN token features

The circuit

pragma circom 2.1.6;

// Zkryn threshold proof.
// Proves: "the issuer signed a position record for this account, on this asset, at this time,
// and the amount in that record is at least `threshold`" without revealing the amount.
//
// Record message signed by the issuer (EdDSA over Baby Jubjub, Poseidon hash):
//   M = Poseidon(DOMAIN, asset, amount, timestamp, accountHash)
//   accountHash = Poseidon(account)   (account = the trader's 20-byte address as a field element)
//
// Public signals, in snarkjs order (outputs first, then public inputs):
//   [0] accountHash  [1] nullifier  [2] asset  [3] threshold  [4] timestamp
//   [5] issuerAx     [6] issuerAy   [7] ruleId

include "../node_modules/circomlib/circuits/poseidon.circom";
include "../node_modules/circomlib/circuits/eddsaposeidon.circom";
include "../node_modules/circomlib/circuits/comparators.circom";
include "../node_modules/circomlib/circuits/bitify.circom";

template ZkrynThreshold() {
    // "zkryn-v1" as ASCII bytes, big-endian. Ties a signature to this record format only.
    var DOMAIN = 0x7a6b72796e2d7631;

    signal input asset;
    signal input threshold;
    signal input timestamp;
    signal input issuerAx;
    signal input issuerAy;
    signal input ruleId;

    signal input amount;
    signal input account;
    signal input sigR8x;
    signal input sigR8y;
    signal input sigS;

    signal output accountHash;
    signal output nullifier;

    // Range checks keep the comparison honest (no wrap-around in the field).
    component amountBits = Num2Bits(64);
    amountBits.in <== amount;
    component thresholdBits = Num2Bits(64);
    thresholdBits.in <== threshold;
    component timeBits = Num2Bits(40);
    timeBits.in <== timestamp;
    component accountBits = Num2Bits(160);
    accountBits.in <== account;
    component assetBits = Num2Bits(160);
    assetBits.in <== asset;

    // amount >= threshold
    component enough = GreaterEqThan(64);
    enough.in[0] <== amount;
    enough.in[1] <== threshold;
    enough.out === 1;

    component acct = Poseidon(1);
    acct.inputs[0] <== account;
    accountHash <== acct.out;

    component msg = Poseidon(5);
    msg.inputs[0] <== DOMAIN;
    msg.inputs[1] <== asset;
    msg.inputs[2] <== amount;
    msg.inputs[3] <== timestamp;
    msg.inputs[4] <== accountHash;

    component sig = EdDSAPoseidonVerifier();
    sig.enabled <== 1;
    sig.Ax <== issuerAx;
    sig.Ay <== issuerAy;
    sig.R8x <== sigR8x;
    sig.R8y <== sigR8y;
    sig.S <== sigS;
    sig.M <== msg.out;

    // One pass per signed record and rule: the contract refuses a nullifier it has seen.
    component nf = Poseidon(2);
    nf.inputs[0] <== sigS;
    nf.inputs[1] <== ruleId;
    nullifier <== nf.out;
}

component main {public [asset, threshold, timestamp, issuerAx, issuerAy, ruleId]} = ZkrynThreshold();