Skip to main content

Crate moonproof_prover

Crate moonproof_prover 

Source
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 of ZkirRelation from 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§

BuiltinResolver
Resolver that handles built-in ZSwap and Dust key locations with single-flight in-memory caching.
CachingParamsProvider
ParamsProverProvider that caches deserialized KZG SRS parameters in RAM per k, backed by MidnightDataProvider for cold loads / S3 fetches.
ContractKeyResolver
Contract keys first, built-ins second.
EngineProvingProvider
ProvingProvider implementation that delegates to a shared ProverEngine.
Fr
An element of our primary prime field.
HttpProvingProvider
HTTP delegate that POSTs check / prove calls to a remote Midnight proof-server.
IrSourceV2
A low-level IR allowing the prover to populate circuit witnesses.
IrSourceV3
A low-level IR allowing the prover to populate circuit witnesses.
KeyLocation
A hint on where keys for a circuit can be found.
MidnightDataProvider
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.
ProofPreimage
Everything necessary to produce a proof.
ProofResult
Result of a proof generation.
ProverEngine
High-level proof generation engine.
ProverStats
Live workload snapshot of a ProverEngine, surfaced by the HTTP proof-server’s /ready endpoint.
ProvingKeyMaterial
A container for the parts required for proving
WrappedIr
A container for just the IR part of [ProofData].

Enums§

ProofPreimageVersioned
Versioned proof preimage — matches the official ProofPreimageVersioned.
ProofVersioned
Versioned proof — matches the official ProofVersioned.
ProverError
VersionedIr
One parsed ZKIR, dynamically dispatched between the v2 and v3 crates’ IrSource types.

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/$USERPROFILE on Windows).
parse_zkir_json
Try to parse a Compact-emitted .zkir JSON document. Detects version by trying v2’s loader first (which only accepts major: 2), then v3’s (which only accepts major: 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§

ProveTxInput
Tagged-binary input/output type for /prove-tx. Mirrors upstream midnight-ledger/proof-server’s TransactionProvePayload.
ProveTxOutput