API/API

Private flows and credentials

TESTNET

The self-serve API issues the dregg membership credential that every private flow proves inside its zero-knowledge proof, and publishes the ids the private flows use.

RouteSessionWhat it does
GET /v1/private/config—The private-flow ids: packages, Access, PassKey, the three shielded pools, Seal servers, the relayer, and the lending market
POST /v1/private/credentialOwnerSigns a dregg credential for the owner's commitment
POST /v1/agent/credentialAgentSigns a dregg credential for the agent's commitment

What the issuer signs#

Exactly one message: Poseidon(commitment, expiry, epoch), with a dedicated Baby Jubjub key. The request carries only commitment; the server sets the expiry and reads the epoch from the on-chain PassKey.

  • The agent route is the SDK's EsseyService.credential(commitment), the call inside provedPassFor. Any key signs in for it (POST /v1/agent/challenge, then /v1/agent/session): the route needs a session, not an account, and the commitment is pinned to the session's address.
  • One commitment per account. It stays pinned across epochs and issuer-key rotations. Asking again with the same commitment returns the live credential; a different commitment is refused until a cooled-down reset.
  • The issuer never sees the member's secret. It learns the commitment, the account and the time.
  • Revocation by epoch. Bumping the epoch on chain opens the next round and retires the last one.
  • The signing key lives in a KMS or a mode-600 file, never in an environment value, a log, an error or a reply. A failure of the key or the signer answers CREDENTIAL_UNAVAILABLE.
GET/v1/private/config

Returns private.network and private.chainId, private.packages (privacy, access, saleRoom, esseySui), private.access, private.passKey, private.lending (pkg, market, pool, treasury), private.loanMarkets (USDSUI, USDC, SUI: each has id, collateral, loan, quote, reader, witness, openable, and reason when id is null), private.shieldedPools (USDC, USDSUI, SUI), private.seal (saleKeyServers, loanKeyServers, threshold 2), private.relayer (baseUrl, address, paths), private.credential.configured, and the v2 sections private.saleRoomV2 and private.privateLoanV2 (each pkg, privacyPkg, verifier, access, passKey, keyServers, threshold, pools; privateLoanV2 adds esseyPkg). private.lending.market is Market<SUI, USDC> only. A loan market's reader is the oracle function its Readings come from, and witness the type they carry: pyth_oracle::read / PythOracle for the USDC and USDSUI markets, pyth_oracle::read_inverse / PythOracleInverse for the SUI market.

The relayer#

private.relayer names the hosted relayer. Post a JSON body to baseUrl + paths.<coin> (sui, usdc, usdsui) with Content-Type: application/json. A spend's ext.relayer must be address. The relayer accepts one checked kind, rebuilds the Move call, dry-runs it and signs with its own key. GET /healthz on baseUrl returns { ok: true, kinds }. A success is { ok: true, digest }. A refusal is { ok: false, error, submitted }. submitted: true means the relayer already called execute, so the spend may have landed. There is no repay_v2 kind. A v2 loan repays a public coin with repay_coin (SDK repayCoinV2Tx, MCP essey_loan_repay_v2), which the borrower sends. The v1 shielded repay is kind=repay. kind=repay_coin, kind=repay_relayed and kind=settle are refused. Raw txBytes are refused.

Numbers are canonical decimal strings (no leading zero). Bytes are 0x hex. Addresses are 0x and 64 hex digits. member, gate and pass are { tag, expiryMs, proof }. member is the room credential bound to the spend's nullifier n0 and is required on bids and offers. gate is the Access pass bound the same way, or null while Access is PUBLIC. Omit kind only for a classic bid. An unknown kind names the eight kinds below.

The hosted fee floors are 10000000 on /relay/sui (0.01 SUI) and 10000 on /relay/usdc and /relay/usdsui (0.01 of that coin). The API does not return the floor. A fee under it answers fee below MIN_FEE with no number in the text: raise ext.fee and post again.

publicSignals is seven canonical decimals: root, publicAmount, extDataHash, n0, n1, c0, c1. The proof object is a bn128 Groth16 proof: pi_a and pi_c are ["x", "y", "1"], pi_b is [["x0", "x1"], ["y0", "y1"], ["1", "0"]], protocol is groth16, curve is bn128.

kindMove callFields
bid (or omit kind)sale_room::room::pool_bidproof, publicSignals, ext (room, relayer, fee, refundPubkey, refundBlinding, encOut1, encOut2), sealed, member, gate
withdrawpool::withdrawproof, publicSignals, ext (recipient, amount, relayer, fee, encOut1, encOut2)
loan_offerprivate_room::room::offerthe bid fields, plus commit (32 bytes) and repayPubkey, repayBlinding (field elements). The v1 loan room publishes every losing rate at settle. Open loan_offer_v2 instead.
settle_relayedprivate_room::room::settle_relayedsender, room, nonce, action, pass (128-byte proof), rates, salts (each empty or at least 16 bytes), principalPubkey, principalBlinding, encNote. No pool spend. Unknown body fields are refused.
repayprivate_room::room::repayproof, publicSignals, ext (room, relayer, fee, encOut1, encOut2), lenderEnc. Do not send refundPubkey or refundBlinding. Unknown body or ext fields are refused.
bid_v2sale_room_v2::room::pool_bida bid, plus commit (field element, Poseidon(price, salt)) and claimCommit (32 bytes)
loan_offer_v2private_room_v2::room::offera bid, plus commit (field element, Poseidon(rateBps, salt)), repayPubkey, repayBlinding
settle_relayed_v2private_room_v2::room::settle_relayedroom, nonce, action, pass, winner, rateBps, principalPubkey, principalBlinding, encNote, proof (128 bytes). No pool spend. Unknown body fields are refused.

kind=repay and kind=settle_relayed are the v1 loan room. Its settle writes every losing rate on chain. New loans use the v2 rows. The caller of repay, repay_coin, liquidate and claim_default chooses lenderEnc. An empty value leaves the lender's note unscannable. The lender rebuilds it with ShieldedWallet.recoverRoomNote (MCP essey_shielded_recover) from the room's stored opening and the event amount. The winning lender's repay note reuses the room's public lender_pubkey and lender_blinding, so that repayment is linkable to the winning offer. Losing v2 offers stay sealed.

The SDK builds the bodies: buildBid (body), buildWithdraw (body), buildPoolBidV2 and buildOfferV2 (body), bidV2Body, loanOfferV2Body, settleRelayedV2Body. Field-by-field MCP maps are in Private-flow tools. The examples below are the wire shape. Placeholder proofs and signals are refused once the relayer checks them against the pool.

JSON
{
  "kind": "bid",
  "proof": { "pi_a": ["1", "2", "1"], "pi_b": [["3", "4"], ["5", "6"], ["1", "0"]], "pi_c": ["7", "8", "1"], "protocol": "groth16", "curve": "bn128" },
  "publicSignals": ["11", "22", "33", "12", "13", "14", "15"],
  "ext": { "room": "0x2222222222222222222222222222222222222222222222222222222222222222", "relayer": "0x1111111111111111111111111111111111111111111111111111111111111111", "fee": "10000000", "refundPubkey": "17", "refundBlinding": "19", "encOut1": "0x01", "encOut2": "0x02" },
  "sealed": "0x03",
  "member": { "tag": "7", "expiryMs": "1893456000000", "proof": "0xabababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab" },
  "gate": null
}
JSON
{
  "kind": "withdraw",
  "proof": { "pi_a": ["1", "2", "1"], "pi_b": [["3", "4"], ["5", "6"], ["1", "0"]], "pi_c": ["7", "8", "1"], "protocol": "groth16", "curve": "bn128" },
  "publicSignals": ["11", "22", "33", "12", "13", "14", "15"],
  "ext": { "recipient": "0x3333333333333333333333333333333333333333333333333333333333333333", "amount": "1000000", "relayer": "0x1111111111111111111111111111111111111111111111111111111111111111", "fee": "10000", "encOut1": "0x01", "encOut2": "0x02" }
}
JSON
{
  "kind": "loan_offer",
  "proof": { "pi_a": ["1", "2", "1"], "pi_b": [["3", "4"], ["5", "6"], ["1", "0"]], "pi_c": ["7", "8", "1"], "protocol": "groth16", "curve": "bn128" },
  "publicSignals": ["11", "22", "33", "12", "13", "14", "15"],
  "ext": { "room": "0x2222222222222222222222222222222222222222222222222222222222222222", "relayer": "0x1111111111111111111111111111111111111111111111111111111111111111", "fee": "10000", "refundPubkey": "17", "refundBlinding": "19", "encOut1": "0x01", "encOut2": "0x02" },
  "sealed": "0x03",
  "commit": "0x1111111111111111111111111111111111111111111111111111111111111111",
  "repayPubkey": "31",
  "repayBlinding": "37",
  "member": { "tag": "7", "expiryMs": "1893456000000", "proof": "0xab" },
  "gate": null
}
JSON
{
  "kind": "settle_relayed",
  "sender": "0x1111111111111111111111111111111111111111111111111111111111111111",
  "room": "0x2222222222222222222222222222222222222222222222222222222222222222",
  "nonce": "0",
  "action": "3",
  "pass": { "tag": "7", "expiryMs": "1893456000000", "proof": "0xabababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab" },
  "rates": ["900"],
  "salts": ["0x11111111111111111111111111111111"],
  "principalPubkey": "11",
  "principalBlinding": "13",
  "encNote": "0x010203"
}
JSON
{
  "kind": "repay",
  "proof": { "pi_a": ["1", "2", "1"], "pi_b": [["3", "4"], ["5", "6"], ["1", "0"]], "pi_c": ["7", "8", "1"], "protocol": "groth16", "curve": "bn128" },
  "publicSignals": ["11", "22", "33", "12", "13", "14", "15"],
  "ext": { "room": "0x2222222222222222222222222222222222222222222222222222222222222222", "relayer": "0x1111111111111111111111111111111111111111111111111111111111111111", "fee": "10000", "encOut1": "0x01", "encOut2": "0x02" },
  "lenderEnc": "0x03"
}
JSON
{
  "kind": "bid_v2",
  "proof": { "pi_a": ["1", "2", "1"], "pi_b": [["3", "4"], ["5", "6"], ["1", "0"]], "pi_c": ["7", "8", "1"], "protocol": "groth16", "curve": "bn128" },
  "publicSignals": ["11", "22", "33", "12", "13", "14", "15"],
  "ext": { "room": "0x2222222222222222222222222222222222222222222222222222222222222222", "relayer": "0x1111111111111111111111111111111111111111111111111111111111111111", "fee": "10000000", "refundPubkey": "17", "refundBlinding": "19", "encOut1": "0x01", "encOut2": "0x02" },
  "sealed": "0x03",
  "commit": "23",
  "claimCommit": "0x2929292929292929292929292929292929292929292929292929292929292929",
  "member": { "tag": "7", "expiryMs": "1893456000000", "proof": "0xab" },
  "gate": null
}
JSON
{
  "kind": "loan_offer_v2",
  "proof": { "pi_a": ["1", "2", "1"], "pi_b": [["3", "4"], ["5", "6"], ["1", "0"]], "pi_c": ["7", "8", "1"], "protocol": "groth16", "curve": "bn128" },
  "publicSignals": ["11", "22", "33", "12", "13", "14", "15"],
  "ext": { "room": "0x2222222222222222222222222222222222222222222222222222222222222222", "relayer": "0x1111111111111111111111111111111111111111111111111111111111111111", "fee": "10000", "refundPubkey": "17", "refundBlinding": "19", "encOut1": "0x01", "encOut2": "0x02" },
  "sealed": "0x03",
  "commit": "23",
  "repayPubkey": "31",
  "repayBlinding": "37",
  "member": { "tag": "7", "expiryMs": "1893456000000", "proof": "0xab" },
  "gate": null
}
JSON
{
  "kind": "settle_relayed_v2",
  "room": "0x2222222222222222222222222222222222222222222222222222222222222222",
  "nonce": "0",
  "action": "3",
  "pass": { "tag": "7", "expiryMs": "1893456000000", "proof": "0xabababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab" },
  "winner": "0",
  "rateBps": "900",
  "principalPubkey": "11",
  "principalBlinding": "13",
  "encNote": "0x010203",
  "proof": "0xabababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab"
}

private.credential.configured is true when the server has loaded ESSEY_ISSUER_KEY_FILE (a mode-600 file of the Baby Jubjub scalar, 32 raw bytes or 64 hex) and can read the PassKey (ESSEY_MEMBERSHIP_PASS_KEY, or the passKey in this response). The credential routes answer 404 until that file is loaded. A request with no session answers 401.

ErrorStatusWhen
BAD_REQUEST400The body is not {commitment} alone, or commitment is not a positive decimal below the field order.
ALREADY_ISSUED409Another commitment is pinned for this account, or a reset is cooling down.
TRY_LATER429More than 20 requests in an hour from this address.
CREDENTIAL_UNAVAILABLE503The key or the signer failed.
PIN_LOCK_TIMEOUT503The account's lock was not free within 10 seconds.

Without a private-flow record on the server, GET /v1/private/config answers 404.