Expand description
Core proof generation library wrapping midnight-ledger’s ZKIR pipeline.
Provides a high-level API for parsing Compact-compiled ZKIR circuits and generating/verifying zk-SNARK proofs using the Midnight ZK stack.
Dispatches across both ZKIR v2 (midnight-zkir) and ZKIR v3
(midnight-zkir-v3), mirroring the upstream
midnight-ledger/proof-server/src/versioned_ir.rs dispatch layer.
Compactc emits v2 by default; --feature-zkir-v3 toggles to v3.
The prover sniffs the IR version (text or tagged-binary) and picks
the matching Zkir impl when calling ProofPreimage::prove.
Key properties:
- Uses
IrSource(v2/v3) from midnight-ledger instead ofZkirRelationfrom midnight-zk - Supports the full Compact instruction set
(
constrain_bits,persistent_hash, etc.) - SRS files are managed by
MidnightDataProvider(auto-download from S3) - Proof generation uses
ProofPreimage(matches the official proof-server protocol)
Structs§
- Builtin
Resolver - Resolver that handles built-in
ZSwapand Dust key locations with single-flight in-memory caching. - Caching
Params Provider ParamsProverProviderthat caches deserialized KZG SRS parameters in RAM perk, backed byMidnightDataProviderfor cold loads / S3 fetches.- Contract
KeyResolver - Contract keys first, built-ins second.
- Engine
Proving Provider ProvingProviderimplementation that delegates to a sharedProverEngine.- Fr
- An element of our primary prime field.
- Http
Proving Provider - HTTP delegate that POSTs
check/provecalls to a remote Midnight proof-server. - IrSource
V2 - A low-level IR allowing the prover to populate circuit witnesses.
- IrSource
V3 - A low-level IR allowing the prover to populate circuit witnesses.
- KeyLocation
- A hint on where keys for a circuit can be found.
- Midnight
Data Provider - Retrieves various static cryptographic artifacts from a data server. This keeps a local file system cache of the parameters, prover keys, verifier keys, and IR, that can also be fetched remotely.
- Proof
- A zero-knowledge proof.
- Proof
Preimage - Everything necessary to produce a proof.
- Proof
Result - Result of a proof generation.
- Prover
Engine - High-level proof generation engine.
- Prover
Stats - Live workload snapshot of a
ProverEngine, surfaced by the HTTP proof-server’s/readyendpoint. - Proving
KeyMaterial - A container for the parts required for proving
- Wrapped
Ir - A container for just the IR part of [
ProofData].
Enums§
- Proof
Preimage Versioned - Versioned proof preimage — matches the official
ProofPreimageVersioned. - Proof
Versioned - Versioned proof — matches the official
ProofVersioned. - Prover
Error - Versioned
Ir - One parsed ZKIR, dynamically dispatched between the v2 and v3
crates’
IrSourcetypes.
Traits§
- Resolver
- A mechanism to retrieve / resolve zero-knowledge key material from a short location string.
Functions§
- params_
dir - Where keys and SRS parameters are cached:
$MIDNIGHT_PP, else$XDG_CACHE_HOME/midnight/zk-params, else$HOME/.cache/midnight/zk-params(or$LOCALAPPDATA/$USERPROFILEon Windows). - parse_
zkir_ json - Try to parse a Compact-emitted
.zkirJSON document. Detects version by trying v2’s loader first (which only acceptsmajor: 2), then v3’s (which only acceptsmajor: 3). - parse_
zkir_ tagged - Try to parse the binary tagged ZKIR carried inside a
ProvingKeyMaterial::ir_source. Sniffs the tagged header first so v3 circuits don’t pay a failed v2 parse attempt before parsing as v3. - prove_
offthread - Build the proving future on a persistent proving worker thread and await its result.
- prove_
versioned - Generate a proof, dispatching across v2 / v3. Mirrors the upstream
proof-server’s
versioned_ir::prove. Prefer [ProverEngine::prove_preimage] for cached SRS + parsed key reuse. - tagged_
deserialize - tagged_
serialize
Type Aliases§
- Prove
TxInput - Tagged-binary input/output type for
/prove-tx. Mirrors upstreammidnight-ledger/proof-server’sTransactionProvePayload. - Prove
TxOutput