Welcome to your new plonk_verifier_on_icp
project and to the Internet Computer development community. By default, creating a new project adds this README and some template files to your project directory. You can edit these template files to customize your project and to include your own code to speed up the development cycle.
To get started, you might want to explore the project directory structure and the default configuration file. Working with this project in your development environment will not affect any production deployment or identity tokens.
To learn more before you start working with plonk_verifier_on_icp
, see the following documentation available online:
- Quick Start
- SDK Developer Tools
- Rust Canister Development Guide
- ic-cdk
- ic-cdk-macros
- Candid Introduction
ganrk Plonk Verifer - A Canister can verify proof generated by gnark @BN254 curve,is a crucial part of the zkBTC project, which bridges Bitcoin to Ethereum and other major blockchains including L2s, fully decentralized.
- lib.rs: the entrance for user on ICP, provides verify_bytes() and verify_hex() two functions.
- verifer.rs: plonk verifier
- vk.rs: build verifyingkey from bytes.
- proof.rs: build proof from bytes
- witness.rs: build witness from bytes
- fiat_shamir.rs: implement fiat_shamir function
- hash_to_field.rs: implement hash_to_field function
- fr.rs: build fr from bytes
- point.rs: build BN254 G1/G2 point from bytes
thre are 2 types proof
- compressed, where g1 points are compressed, it is the result of proof.WriteTo
- uncompressed, where g1 points are uncompressed, it is the result of proof.MarshalSolidity()
This repo is based on ganrk v0.11.0.
- start ICP locally in one terminal,
dfx start --clean
- download repo and deploy plonk verifer in another terminal,
git clone https://github.com/lightec-xyz/plonk_verifier_on_icp.git
cd plonk_verifier_on_icp
dfx deploy plonk_verifier_on_icp_backend
after deployed, get the cansiter id(e.g. bkyz2-fmaaa-aaaaa-qaaaq-cai) for later use
Installing canisters...
Creating UI canister on the local network.
The UI canister on the "local" network is "bd3sg-teaaa-aaaaa-qaaba-cai"
Installing code for canister plonk_verifier_on_icp_backend, with canister ID bkyz2-fmaaa-aaaaa-qaaaq-cai
Deployed canisters.
URLs:
Backend canister via Candid interface:
plonk_verifier_on_icp_backend: http://127.0.0.1:4943/?canisterId=bd3sg-teaaa-aaaaa-qaaba-cai&id=bkyz2-fmaaa-aaaaa-qaaaq-cai
- build the one circuit(e.g. hasher) in examples directory, and execute it, which will generate verifyingkey, proof, and witness and then call verify_bytes() to verify the proof/witness.
cd examples
go mod tidy
cd hasher
go build
./hasher -canister bkyz2-fmaaa-aaaaa-qaaaq-cai
plonk_verifer is deployed at https://a4gq6-oaaaa-aaaab-qaa4q-cai.raw.icp0.io/?id=3luut-nqaaa-aaaao-qbcwa-cai. you can run the example on ICP mainnet with the following command.
cd examples
go mod tidy
cd hasher
go build
./hasher -canister 3luut-nqaaa-aaaao-qbcwa-cai -network ic
Or, build circuit and retrieve verifyingkey, proof, and witness and take them as input parameters in verify_hex().
Any modification in verifyingkey, proof, and witness will cause verify fail as shown below.