ZkpClient — internals
High-level usage is documented on ZkpClient. This page lists internal services and architecture for tooling, debugging, or custom flows.
Architecture
ZkpClient is a thin composition root. It holds no business logic — it wires platform-specific backends into services and exposes a ClientContext that wallets consume internally.
ZkpClient (composition root)
├── SolverService ← ISolverBackend (WASM / native)
├── ProverService ← IProverBackend (WASM / native) + CircuitLoader
├── publicClient ← viem (chain reads)
├── RelayerClient ← optional HTTP relayer
└── tokens map ← currency → contract address
ClientContext
The internal interface passed to ZkpWallet. Not part of the public SDK API.
| Field | Type | Description |
|---|---|---|
solverService | SolverService | Self-initializing — ElGamal decrypt + discrete-log solve |
proverService | ProverService | Self-initializing — circuit loading + proof generation |
publicClient | PublicClient | viem client for chain reads |
chain | Chain | viem chain object |
rpcUrl | string | RPC endpoint |
storage | StorageAdapter? | Persistent cache for history and balances |
relayerAccess | IRelayerAccess | hasRelayer() / getRelayer() |
tokens | ReadonlyMap<string, Address> | Currency → token contract address |
createWalletClient | (account) => WalletClient | Factory for viem write clients |
Services
SolverService
Wraps an ISolverBackend. Self-initializing — calls ensureReady() on first decrypt.
decrypt(ct, sk)— ElGamal decrypt + discrete-log solveensureReady()— eagerly init the solver backenddestroy()— teardown
ProverService
Wraps an IProverBackend + CircuitLoader. Self-initializing — loads circuits on first proof generation.
generateTransferProof(witness)— concealed transfer proofgenerateToPublicProof(params)— concealed → public proofensureReady()— eagerly load circuitsprewarm()— dummy proof to warm JITdestroy()— teardown
Transaction decoding (standalone helpers)
| Function | Description |
|---|---|
decryptTransferFromTx(publicClient, solverService, txHash, sk, bpk) | Incoming transfer amount |
decryptOutgoingTransferFromTx(publicClient, solverService, txHash, sk, bpk) | Outgoing transfer amount |
getTransferParties(publicClient, txHash) | Parse sender/recipient BPKs from calldata |
Default backends (web / Node)
DlogSolverBackend— WASM discrete-log solver (ISolverBackend).WasmProverBackend— Noir JS + bb.js (IProverBackendwithprove).
Custom mobile/native stacks implement the interfaces in @zk-privacy/core/types and pass them in ZkpClientConfig.
Helpers
DEFAULT_CHAIN_CONFIG— per-chain token addresses, RPC, relayer URL presets.resolveRecipient(to: Recipient)— normalize zk1 string orPointrecipient.