Skip to content

Shivannsh/ZKAttestify-Sp1-verifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SP1 Wasm verification example

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.

Repo overview

  • verifier: The rust sp1 verifier crate with wasm bindings.
  • example/dob-program: A SP1 program to verify date of birth offchain attestation .
  • example/dob-script: A simple script to generate proofs in a json format.
  • example/wasm_example: A short javascript example that verifies proofs in wasm.

Usage

Wasm Bindings

First, generate the wasm library for the verifier. From the verifier directory, run

wasm-pack build --target nodejs --dev 

Generate proofs

Next, run the script to generate DOB-Attestaion_groth16_proof.json and DOB-Attestaion_plonk_proof.json. From the example/dob-script directory, run:

cargo run --release -- --mode groth16
cargo run --release -- --mode plonk

By default, this will not generate fresh proofs from the program in example/dob-program. To generate fresh proofs, run:

SP1_PROVER=network SP1_PRIVATE_KEY=$SP1_PRIVATE_KEY cargo run --release -- --mode groth16 --prove
SP1_PROVER=network SP1_PRIVATE_KEY=$SP1_PRIVATE_KEY cargo run --release -- --mode plonk --prove

We 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 --prove

Verify proofs in wasm

To verify proofs in wasm, run the following command from the example/wasm_verifier directory:

pnpm install
pnpm run test

How Zero-Knowledge Proof Generation is happening

  1. The system employs Succinct ZKVM to validate the attestation's integrity without exposing the actual data.
  2. The ZKVM re-generates the EIP712 signature by calculating:
    • DomainHash
    • MessageHash
      This confirms the attestation is untampered.
  3. It checks specific conditions, such as verifying if the individual's date of birth shows they are above 18.
  4. This proof can be used anywhere where you want to prove that you are 18+ without actually revealing your actual Date of Birth.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published