Skip to main content
Version: 0.1.0

ZK Agent Integration

This page documents the ZK agent flow for submitting proofs and receiving decisions without exposing raw scores.

Endpoints

MethodEndpointDescription
GET/api/v1/policiesReturns active policy hashes by context
POST/api/v1/agent/submitSubmits a verified decision on-chain via relayer

Getting Policy Hashes

Use the policy listing endpoint to retrieve the correct policyHash for your context:

curl https://www.zkbasecred.xyz/api/v1/policies

200 OK

{
"policies": [
{
"context": "allowlist.general",
"policyHash": "sha256:<hash>",
"normalizationVersion": "v1"
}
]
}

Submit Decision On-Chain

POST

/api/v1/agent/submit

Submits a verified decision on-chain via the relayer wallet. The relayer pays gas and writes the decision to the DecisionRegistry contract on Base mainnet.

Request body

{
"subject": "0xabc123...",
"context": "allowlist.general",
"decision": "ALLOW",
"policyHash": "sha256:<policy-hash>",
"proof": {
"a": ["0x...", "0x..."],
"b": [["0x...", "0x..."], ["0x...", "0x..."]],
"c": ["0x...", "0x..."]
},
"publicSignals": ["<policyHash>", "<contextId>", "<decision>"]
}
FieldTypeRequiredDescription
subjectstringYesWallet address
contextstringYesDecision context
decision"ALLOW" | "DENY" | "ALLOW_WITH_LIMITS"YesThe decision to record
policyHashstringYesPolicy hash used for the decision
proof{ a, b, c }YesGroth16 proof in contract-ready format
publicSignals[string, string, string]Yes[policyHash, contextId, decision]

Response

200 OK

{
"success": true,
"transactionHash": "0x...",
"subjectHash": "0x<bytes32>",
"contextBytes32": "0x<bytes32>",
"policyHashBytes32": "0x<bytes32>"
}
FieldTypeDescription
successbooleanWhether the transaction was submitted
transactionHashstringOn-chain transaction hash
subjectHashstringbytes32 hash of the subject
contextBytes32stringbytes32 encoding of the context
policyHashBytes32stringbytes32 encoding of the policy hash

Error responses

StatusCodeDescription
400INVALID_REQUESTMissing or invalid fields
400SUBMIT_ERRORInvalid proof or mismatch
422SUBMIT_ERRORTransaction reverted on-chain
503CONFIG_ERRORRelayer not configured
500SUBMIT_ERRORServer error

Typical Agent Flow

  1. Get policiesGET /api/v1/policies to fetch the current policyHash for your context.
  2. Generate proofPOST /api/v1/decide-with-proof to evaluate the subject and get a ZK proof.
  3. Submit on-chainPOST /api/v1/agent/submit to write the decision to the DecisionRegistry.

Notes

  • The verifier expects Groth16 proofs in snarkjs format.
  • Policy hashes are derived from the canonical policy definitions in the decision engine.
  • The API will reject requests when the policy hash does not match the active policy for the requested context.
  • The /agent/submit endpoint requires a configured relayer wallet (RELAYER_PRIVATE_KEY). If the relayer is not configured, the endpoint returns 503.