This repo demonstrates how to verify Groth16 and Plonk proofs in browser. We wrap the sp1-verifier crate in wasm bindings, and invoke it from javascript.
- Rust (install via https://rustup.rs/)
- SP1 (
curl -L https://sp1up.succinct.xyz | bash)
Proof of Age (DOB): Click hereProof of residence: Click here
verifier: The rust sp1 verifier crate with wasm bindings.example/dob/dob-program: A SP1 program to verify date of birth offchain attestation .example/dob/dob-script: A simple script to generate proofs in a json format.example/wasm_example: A short javascript example that verifies proofs in wasm.example/solidity-verifier: A solidity contract that verifies proof onchain.
First, generate the wasm library for the verifier. From the verifier directory, run
wasm-pack build --target nodejs --devNext, run the script to generate DOB-Attestaion_groth16_proof.json and DOB-Attestaion_plonk_proof.json. From the examples/dob/dob-script directory, run:
cargo run --release -- --mode groth16
cargo run --release -- --mode plonkBy default, this will not generate fresh proofs from the program in examples/dob/dob-program. To generate fresh proofs, from the examples/dob/dob-script directory, run:
SP1_PROVER=network NETWORK_PRIVATE_KEY=$SP1_PRIVATE_KEY cargo run --release -- --mode groth16 --prove
SP1_PROVER=network NETWORK_PRIVATE_KEY=$SP1_PRIVATE_KEY cargo run --release -- --mode plonk --proveWe used SP1 prover network in our example . You can also run it locally using the commands:
cargo run --release -- --mode groth16 --prove
cargo run --release -- --mode plonk --proveTo verify proofs in wasm, run the following command from the example/wasm_verifier directory:
pnpm install
pnpm run dob- The system employs Succinct ZKVM to validate the attestation's integrity without exposing the actual data.
- The ZKVM re-generates the EIP712 signature by calculating:
- DomainHash
- MessageHash
This confirms the attestation is untampered.
- It checks specific conditions, such as verifying if the individual's date of birth shows they are above 18.
- This proof can be used anywhere where you want to prove that you are 18+ without actually revealing your actual Date of Birth.