ProvingKeyManager
Manages proving key download, caching, and version tracking for local ZK proving.
Proving keys are downloaded from Midnight's S3 once (~24MB total) and cached in app internal storage. The phone can then prove transactions offline.
Key locations match the SDK's WasmProver.makeDefaultKeyMaterialProvider():
zswap/{ver}/spend.prover(10.5 MB)zswap/{ver}/output.prover(5.5 MB)zswap/{ver}/sign.prover(2.7 MB)dust/{ver}/spend.prover(2.1 MB)bls_midnight_2p13(1.5 MB)Corresponding
.verifierand.bzkirfiles
Properties
Functions
Total size of cached keys in bytes.
Delete all cached proving keys.
Directory for a specific contract's proving keys. Keys are stored at: proving_keys/contracts/{contractName}/{circuit}.{prover,verifier,bzkir}
Download all wallet proving keys from S3.
One-call wallet-key provisioning. Tries the dev shortcut first (installFromLocalTmp — adb-pushed files in /data/local/tmp/), then falls back to the S3 download (downloadWalletKeys) when the local-tmp pass didn't populate the BLS params + zswap/dust keys. After this returns, hasWalletKeys is true unless the download itself failed (in which case the underlying IOException propagates).
Whether BLS parameters are available (needed for all proving).
Whether all required circuit keys are cached for a contract.
Whether the prover can find circuit keys at the root keys directory.
Whether all wallet-required proving keys are cached and current version.
Install a dApp's own contract circuit keys from the APK's bundled assets into the prover's keysDir, where the local prover resolves them.
Dev-only convenience: install proving keys from a local-tmp staging area pushed via adb push (the convention used by Kicks's build script, the SDK e2e test, and BBoard's canary). Looks at two well-known directories on the device:
Remove all cached keys for a contract.