ZKCG Verifier
ZK-Verified Computation Gateway (ZKCG)
ZKCG enables non-ZK systems to replace trusted oracle logic with verifiable off-chain computation.
Instead of relying on a trusted backend or oracle signer, consumers (on-chain contracts or off-chain services) can accept results only if a zero-knowledge proof of correct computation and policy compliance is provided.
ZKCG is a protocol-first verification primitive β not a chain, not a zk-rollup, and not a signature oracle.
It is designed for systems that want trustless decision gating using provable off-chain logic.
Learn more below π
Motivation
In many systems today (DeFi risk checks, compliance gating, permissioned access), off-chain computation results are submitted on-chain or to services using trusted oracles or signed responses. This creates a trust assumption:
- Contracts must trust an oracle identity
- Backends must be trusted not to lie
- Private data often must be revealed for validation
ZKCG replaces this with verifiable computation β results accepted only if a zero-knowledge proof of correct execution plus policy compliance is provided.
This eliminates the need for trust in a specific oracle signer and enables stronger guarantees for privacy and correctness.
What ZKCG Replaces
Many systems today rely on trusted oracle services or backend signers to bring off-chain computation results on-chain or into critical decision paths.
ZKCG replaces trust in the computation provider with verifiable computation.
| Today (Common Pattern) | With ZKCG |
|---|---|
| Trusted oracle signer | Zero-knowledge proof |
| Off-chain trust | Cryptographic verification |
| Backend promises | Enforced protocol policy |
| Revealed inputs | Private inputs (ZK) |
| Ad-hoc validation | Deterministic state transitions |
Instead of trusting who produced a result, consumers verify how it was produced.
Overview
ZKCG Verifier is the public, auditable verification layer of the ZKCG protocol.
- Phase 1: Halo2-based zk-SNARK verification
- Phase 2: zkVM-based verification (RISC0)
This repository is intentionally verifier-only. Anyone can independently verify proofs, audit the logic, and run verifier nodes.
High-Level Architecture
Modern systems often rely on oracles or trusted services to bring off-chain results on-chain or into backend logic. ZKCG replaces those with verifiable proofs.
Hereβs how a typical integration looks:
Off-chain computation
β
ZK proof generation
β
ZKCG Verifier
(policy + proof check)
β
Verified result consumed
(smart contract or service)
- The prover executes private logic off-chain and outputs a proof + public result.
- The verifier checks both correct computation and policy compliance.
- No trusted signer or back-end oracle identity is required.
Example Integration: Oracle Replacement
Instead of:
// Trusted oracle pattern
require(msg.sender == trustedOracle);
price = oraclePrice;
You can do:
// Verifiable off-chain computation
require(verifyZKCG(proof, publicInputs));
price = publicInputs.price;
With ZKCG, the contract accepts the result only if a proof of correct computation and policy compliance is provided β no need to trust a specific oracle address.
Who Should Use ZKCG
ZKCG is built for systems that currently rely on externally computed results where:
- Trusting a specific oracle signer is undesirable
- Privacy of inputs must be preserved
- Proof of correct logic matters
- Existing systems already rely on oracles or trusted backends
Typical adopters include:
- On-chain protocols replacing oracle signatures
- Off-chain services needing strong correctness guarantees
- Compliance and eligibility systems
- Risk-based access gating
Use Case (Phase 1): Private Eligibility Check
A common pattern across many systems is:
βCan this user or entity execute some action only if their private data satisfies a condition?β
Examples include:
- Credit score β₯ threshold
- Age β₯ 18
- Compliance metric below risk limit
- Private reputation above requirement
ZKCG enables these decisions to be verified without revealing private inputs and without trusting an oracle signer.
Repository Structure
ZKCG/
βββ common/ # Shared types, errors, and protocol utilities (zkcg-common crate)
βββ verifier/ # Core verifier logic (zkcg-verifier crate)
βββ api/ # HTTP API for proof submission
βββ SPEC.md # Full protocol specification
βββ CORE_FREEZE.md # Frozen circuit parameters and commitments
βββ SECURITY.md # Security assumptions and reporting
βββ LICENSE # Apache-2.0
βββ README.md # This file
Installation
Add the crates to your project:
Or manually in Cargo.toml:
[]
= "0.1.0"
= "0.1.0"
Features
zk-halo2β Enable Halo2 proof verification backendzk-vmβ Enable zkVM (RISC0) verification support
Example:
= { = "0.1.0", = ["zk-halo2"] }
π³ Docker Setup (Optional)
Docker is optional.
- Halo2 verification runs natively
- zkVM verification can run natively or in Docker
- Docker is recommended for reproducible environments and CI
Install Docker (Ubuntu / WSL2)
Verify:
Build Docker Image
From the repository root:
π Benchmarks
Environment
- Platform: Windows (WSL2, Ubuntu)
- CPU: Intel i5 (10th Gen)
- RAM: 16 GB
- Build: Release
- Parallelism: Default (no tuning)
Halo2 (BN254, k = 6)
Use case: Interactive / near-real-time ZK policy verification
- Prove: ~306β316 ms(before) -> ~75β80 ms(now)
- Verify: ~9β10 ms(before) -> ~4β4.5 ms(now)
- End-to-End: ~317β351 ms(before) -> 90-100ms(now)
zkVM (RISC0)
Use case: Audit-grade execution proofs
- Prove: ~13.7 seconds
- Verify: ~41β42 ns
Summary
| Backend | Prove Time | Verify Time | Intended Use |
|---|---|---|---|
| Halo2 | ~ 92.665 ms | ~4.3099 ms | Interactive ZK policies |
| zkVM | ~13β17 s | ~40 ns | Audit / attestation |
End-to-End Simulation Results
Sequential Halo2 Simulation (1000 proofs)
Loans evaluated: 1000
Approvals: 128 (12.8%)
Prove total: ~482.1 s
Verify total: ~7.7 s
Throughput: ~2.0 TPS
Parallel Halo2 Simulation (8 threads)
Loans evaluated: 1000
CPU threads: 8
Approvals: 130 (13.0%)
Prove total: ~127.4 s
Verify total: ~5.5 s
Throughput: ~7.5 TPS
Summary
| Backend | Prove Cost | Verify Cost | Throughput | Intended Use |
|---|---|---|---|---|
| Halo2 (seq) | ~480 ms | ~7 ms | ~2 TPS | Interactive ZK policies |
| Halo2 (8-core) | ~127 ms | ~5 ms | ~7.5 TPS | Batch / off-chain proving |
| zkVM | ~13β17 s | ~40 ns | Prove-bound | Audit & attestation |
Real-World Integration Example
ZKCG can be integrated into DeFi protocols for privacy-preserving verifications (e.g., credit score checks without revealing scores). See this demo in the collateral_vault repository, which shows the full on-chain + off-chain pipeline:
- Off-Chain Proof Generation: Generate a ZK proof using ZKCG's prover (Halo2 or zkVM) for conditions like "credit score > threshold".
- Off-Chain Verification: Call ZKCG's API (/v1/submit-proof) to verify the proof trustlessly.
- On-Chain Settlement: If verified, anchor the new state commitment on-chain (Solana program in collateral_vault) to approve loans or unlock collateral.
Run the demo: ts-node collateral_demo.ts (requires ZKCG API running locally).
This pipeline ensures fast off-chain processing (~340ms E2E for Halo2) with on-chain immutability.
Live Demo API (Stateless)
The ZKCG verifier exposes demo-only, stateless endpoints that allow anyone to try proof generation and verification without running the stack locally.
β οΈ These endpoints are for testing and demonstration only.
They do not persist protocol state and are rate-limited.
Base URL
https://zkcg-production.up.railway.app
1οΈβ£ Generate a Proof (/demo/prove)
Generate a zero-knowledge proof that a score satisfies a given threshold.
Request
Response
proofis a base64-encoded ZK proofproof_size_bytesshows the compact proof size- The proof is not stored server-side
2οΈβ£ Verify a Proof (/demo/verify)
Verify a previously generated proof against a threshold.
Request
Response
Proof-Based Compliance Evaluation API (For Sponsers Only)
This endpoint exposes a deterministic, proof-backed compliance oracle.
It evaluates a predefined policy over supplied inputs and returns:
- The policy decision
- The reasons for failure (if any)
- A cryptographic proof that the policy was evaluated correctly
β οΈ Important
This service does not source data, perform KYC, or assess fraud.
It proves correct execution of policy logic over caller-supplied claims.
Endpoint
POST /v1/compliance/evaluate
Content-Type: application/json
Request Schema
Field Semantics
| Field | Description |
|---|---|
applicant_id |
Caller-defined identifier for the subject being evaluated |
risk_score |
Precomputed risk score supplied by the caller |
threshold |
Maximum acceptable risk score |
monthly_income_cents |
Claimed monthly income (in cents) |
monthly_debt_cents |
Claimed monthly debt obligations (in cents) |
requested_credit_cents |
Credit amount being evaluated (in cents) |
All numeric values are treated as claims and are not independently verified.
Deterministic Policy Rules
The following rules are evaluated:
-
Risk Score Policy
risk_score β€ threshold -
Debt-to-Income (DTI) Policy
(monthly_debt / monthly_income) β€ 45% -
Credit-to-Income Policy
(requested_credit / monthly_income) β€ 300%
All calculations use fixed-point basis points (bps) for deterministic execution.
Example Request
Example Response
Proof Semantics (Oracle Replacement)
The returned proof attests that:
The declared policy rules were evaluated correctly over the supplied inputs and resulted in the reported outcome.
The proof guarantees:
- Deterministic policy execution
- Correct rule evaluation
- No reliance on trusted oracles
The proof does not guarantee:
- Correctness of inputs
- Identity validity
- Data freshness
- Absence of fraud
These are intentionally out of scope.
Notes
- Demo endpoints are stateless
- No protocol state is mutated
- Intended for:
- quick testing
- integration experiments
- understanding the proof flow
- Production / protocol endpoints are gated separately
What This Demonstrates
- End-to-end proof generation
- Compact proof size
- Deterministic verification
- Clean HTTP boundary for ZK systems
Contact
For questions, collaborations, or sponsorships, reach out:
- X (Twitter): @sujyot
- GitHub Issues: Open in this repo for discussions
Anyone can:
- Audit the verifier
- Run a verifier node
- Independently verify published proofs
Proof generation requires access to private components β contact @MRSKYWAY for collaboration or sponsored access.
License
Apache-2.0
Support the Project
ZKCG is built and maintained by a single developer.
π Sponsor: https://github.com/sponsors/MRSKYWAY