A Plutus implementation of the Groth16 ZKP-verification algorithm.
Using snarkjs, the setup and proof parts of the Groth16 protocol generate the files:
verification.json
proof.json
public.json
We assume that you have cloned Plutus-Apps and have Nix installed and configured with the proper substituters. At the Plutus-Apps
directory, execute
git checkout v1.2.0
nix develop
After allowing enough time for the nix-shell to start, go to the directory where you cloned this repo and then to ./onchain/
. Then execute
cabal repl
The REPL should open in module Test_BLS6_6
.
Inside the REPL, execute:
testValidator1
Change to module Test
:
:m Test
To test the validator you need to provide the snarkjs output files:
testValidator2 "pathTo/verification.json" "pathTo/proof.json" "pathTo/public.json"
You can find sample snarkjs output files in directory snarkjs
.
The onchain verification code is contained in the following files in directory src
:
Params.hs
: global parameters associated with elliptic curve BN128.ParseDatum.hs
: utility code for parsing the json files produced by snarkjs.ZKPVerification.hs
: implementation of the verification part of the Groth16 protocol and associated Plutus validator.Test.hs
: allows convenient testing of the validator in the REPL.
Additionally, directory src/BLS6_6
provides:
Params_BLS6_6
: global parameters associated with elliptic curve BLS6_6.ZKPPVerification_BLS6_6
: identical toZKPVerification.hs
except that imports BLS6_6 parameters.Test_BLS6_6
: allows convenient testing of the validator in the REPL.
-
Directory
snarkjs
contains output files that can be used to test the validator using the BN128 elliptic curve.- files in
snarkjs/test00
were obtained implementing in snarkjs the 3-factorization problem described in [1]. - files in
snarkjs/test01
,snarkjs/test02
andsnarkjs/test03
correspond to outputs generated by our ZK-Mastermind game.
- files in
-
Elliptic curve
BLS6_6
is described in detail in [1]. Datum in fileTest_BLS6_6.hs
was obtained from the ZK-SNARK setup and proof associated with the 3-factorization problem as explained in [1].