mudra-zkvm
v1.0.2
Published
Mudra — hash-chain sealed zero-knowledge virtual machine
Readme
mudra-zkvm
Verify ZK proofs in the browser. Lightweight WASM — no CLI, no Rust toolchain, no params required.
Quick Start
import { init, loadProofArtifacts, verifyProof } from 'mudra-zkvm';
await init();
// Load proof artifacts from a CLI output directory
const { proof, vk, publicInputs } = await loadProofArtifacts('./output');
// Verify
const valid = verifyProof(proof, vk, publicInputs);
console.log(valid ? 'Proof is valid' : 'Proof is INVALID');That's it. Three functions. One import.
Installation
npm:
npm install mudra-zkvmCDN (esm.sh):
import { init, verifyProof, loadProofArtifacts } from 'https://esm.sh/mudra-zkvm';CDN (unpkg):
import { init, verifyProof, loadProofArtifacts } from 'https://unpkg.com/mudra-zkvm/pkg/index.js';Usage
Verify a Proof
The simplest path — artifacts are already loaded:
import { init, verifyProof } from 'mudra-zkvm';
await init();
const valid = verifyProof(proofBytes, vkBytes, publicInputsBytes);For full cryptographic verification (recommended for production), pass the Halo2 params:
const params = await fetch('./params').then(r => r.arrayBuffer());
const valid = verifyProof(proofBytes, vkBytes, publicInputsBytes, new Uint8Array(params));Load & Verify from a Directory
Load everything from a mudra prove --outdir directory and verify in one call:
import { init, verifyFromDirectory } from 'mudra-zkvm';
await init();
const valid = await verifyFromDirectory('./output');Or load first, then verify:
import { init, loadProofArtifacts, verifyProof } from 'mudra-zkvm';
await init();
const { proof, vk, publicInputs } = await loadProofArtifacts('./output');
const valid = verifyProof(proof, vk, publicInputs);Verify from Arweave
If the proof was posted to Arweave, verify it directly by TXID:
import { init, verify_from_arweave } from 'mudra-zkvm';
await init();
const valid = await verify_from_arweave('your-txid-here');Where Proofs Come From
This package verifies proofs. Proofs are generated by the mudra CLI (mudra prove). The CLI runs natively (Rust) and produces proof.bin, vk.bin, and public_inputs.bin — the three files this package expects.
See the main repository and CLI docs for proof generation.
API Overview
| Export | Kind | What it does |
|--------|------|-------------|
| verifyProof(proof, vk, inputs, params?) | Helper | One-call proof verification |
| loadProofArtifacts(dirUrl) | Helper | Fetch proof.bin, vk.bin, public_inputs.bin from a URL |
| verifyFromDirectory(dirUrl, params?) | Helper | Load + verify in one call |
| verify_from_arweave(txid) | WASM | Fetch and verify a proof from Arweave by TXID |
| Proof | WASM class | Low-level proof type (new Proof(bytes), .verify(), .as_bytes()) |
| VerifyingKey | WASM class | Verification key management |
| ProvingKey | WASM class | Proving key management |
| init() / initSync() | WASM init | Load the WASM module |
For most use cases, the three helper functions are all you need. Use the WASM classes directly only when you need fine-grained control over byte arrays. See api.md for the full reference.
Features
- Lightweight WASM verifier — checks one hash chain, not thousands of instruction constraints
- Constant circuit size — 21 field elements regardless of program complexity. One verifying key for everything.
- Browser-compatible — verify proofs in any modern browser
- Arweave audit trail — permanent, immutable, one-time cost
- Private by default — only hashes touch the network; formulas and data stay local
Arweave: Free by Default
Verification is free by default, thanks to Ardrive Turbo's free tier (100 KiB per upload). Genesis anchors (params, VK, verifier WASM) are deterministic per spec_digest/k — pre-published once by the project. Only the per-execution hash chain record (~6 KB) is uploaded per run.
| Artifact | Size | How It's Handled | |---|---|---| | Hash chain record + proof | ~6 KB | Uploaded per execution — always free | | Verification Key (VK) | ~17 KB | Pre-published by project as genesis anchor, referenced by default | | Verifier WASM | ~403 KB | Pre-uploaded by project as well-known TXID | | Halo2 Params (k=15) | ~2 MB | Pre-uploaded by project as well-known TXID |
No payment required. See docs/arweave-verification.md.
Quick Links
| For | See | |-----|-----| | Project overview | codeberg.org/PatrickM123/mudra | | JS/TypeScript API | docs/api.md | | Browser / npm guide | docs/npm-package.md | | Arweave verification | docs/arweave-verification.md | | Architecture | docs/ARCHITECTURE.md |
License
AGPL-3.0-only — See LICENSE for details.
