This repository enables verification of PLONK and Groth16 proofs generated by SP1 and RISC Zero zkVMs inside o1js circuits, making them compatible with zkApps built on the Mina Protocol. The codebase employs a parallel and recursive architecture to efficiently verify non-native proofs in o1js.
While the infrastructure in this project is optimized for SP1 proofs, it is designed to be more general. Specifically, any gnark-based PLONK proofs can be verified using the existing code.
Additionally, the repository provides infrastructure for Groth16 verification, enabling the consumption of Groth16-based proofs produced by other frameworks such as circom, arkworks, gnark, Risc Zero, and many others.
The latest version is moving towards, migrating away from having a mix of languages (TS, Bash, and Rust) to having a homogeneous TS-first approach utilizing WebAssembly to incorporate the Rust components and striving to deprecate Bash.
npm install @nori-zk/proof-conversion --save
import { ComputationalPlanExecutor, performSp1ToPlonk, Sp1, LogPrinter } from '@nori-zk/proof-conversion';
import { readFileSync } from 'fs';
async function main() {
new LogPrinter('[NoriProofConverter]', ['log', 'info', 'warn', 'error', 'debug', 'fatal', 'verbose']);
const maxProcesses = 10;
const executor = new ComputationalPlanExecutor(maxProcesses);
const sp1ProofStr = readFileSync('./example-proofs/v4.json', 'utf8');
const sp1Proof = JSON.parse(sp1ProofStr) as Sp1;
const result = await performSp1ToPlonk(executor, sp1Proof);
console.log('Finished conversion', result);
}
main().catch(console.error);
Run npm run relink to install proof-conversion bash command.
npm install @nori-zk/proof-conversion -g (note may require sudo depending on your configuration)
nori-proof-converter <command> <input-json-file-path1> <input-json-file-path2>
Currently supported commands:
- sp1ToPlonk
- risc0ToGroth16
You can change the number of child processes it spawns by setting the MAX_PROCESSES environment variable before running the cli:
export MAX_PROCESSES=8
Examples:
nori-proof-converter sp1ToPlonk example-proofs/v4.jsonnori-proof-converter risc0ToGroth16 example-proofs/risc_zero_proof.json example-proofs/risc_zero_raw_vk.json
Run npm run relink
npm unlink -g nori-proof-converter && npm uninstall -g nori-proof-converter && npm install -g @nori-zk/proof-conversion
- If getting a permission denied check npm's awareness of linked modules
npm ls -g --depth=0 --link=trueremove symlinks manually if nessesary and runnpm run relink
Refer to the Gitbook documentation for details on o1js-blobstream.
sudo sysctl -w vm.zone_reclaim_mode=0
sudo sysctl -w vm.overcommit_memory=1
sudo sysctl -w vm.swappiness=10
sudo cpupower frequency-set -g performance
sudo apt install parallelDepending on the CPU model, specificaly NUMA nodes setup, you may need to adjust values in
scrips/plonk_tree.sh
This project is licensed under either:
at your option.
The SPDX license identifier for this project is:
MIT OR Apache-2.0.