Skip to content

Commit eb97f7c

Browse files
committed
Merge branch 'master' of https://github.com/meilof/pysnark
2 parents 616c66c + e6c2ff3 commit eb97f7c

File tree

1 file changed

+32
-15
lines changed

1 file changed

+32
-15
lines changed

README.md

+32-15
Original file line numberDiff line numberDiff line change
@@ -70,39 +70,54 @@ By default, if available, the libsnark backend will be used. In this case, the f
7070
* `pysnark_vk`: key material to verify proofs for this computation
7171
* `pysnark_log`: computation log that can be verified with the `pysnark_vk` key: number of inputs/outputs, followed by the inputs/outputs themselves, followed by a proof that the input/outputs were correctly computed
7272

73+
PySNARK with libsnark can use the more recent Groth16 proof system instead of traditional Pinocchio proofs by using the libsnarkgg backend:
74+
75+
```
76+
cd examples
77+
rm pysnark_*
78+
PYSNARK_BACKEND=libsnarkgg python3 cube.py 3
79+
```
7380

7481
### Combining with snarkjs
7582

76-
PySNARK with the libsnark backend can automatically produce snarkjs `public.json`, `proof.json` and `verification_key.json` files for the performed verifiable computation:
83+
**Note: this feature has been recently updated, please use the latest Git version**
84+
85+
PySNARK with the libsnarkgg backend can automatically produce snarkjs `public.json`, `proof.json` and `verification_key.json` files for the performed verifiable computation:
7786

7887
```
79-
meilofs-air:examples meilof$ python3 cube.py 33
88+
meilofs-air:examples meilof$ PYSNARK_BACKEND=libsnarkgg python3 cube.py 33
8089
The cube of 33 is 35937
8190
*** Trying to read pysnark_ek
8291
*** PySNARK: generating proof pysnark_log (sat=True, #io=2, #witness=2, #constraint=3)
8392
*** Public inputs: 33 35937
8493
*** Verification status: True
85-
meilofs-air:examples meilof$ python3 -m pysnark.libsnark.tosnarkjs
86-
meilofs-air:examples meilof$ snarkjs verify
87-
OK
88-
$ snarkjs generateverifier
89-
$ snarkjs generatecall
94+
meilofs-air:examples meilof$ python3 -m pysnark.libsnark.tosnarkjsgg
95+
meilofs-air:examples meilof$ snarkjs groth16 verify verification_key.json public.json proof.json
96+
[INFO] snarkJS: OK!
9097
```
9198

9299
## Using PySNARK (snarkjs backend)
93100

101+
**Note: this feature has been recently updated, please use the latest Git version**
102+
103+
PySNARK can be used in combination with snarkjs as a drop-in replacement of programming circuits using circom. PySNARK generates the `circuit.r1cs` file corresponding to the computation constraints and the `witness.wtns` file containing the values for the current computation:
104+
94105
```
95-
$ cd examples
96106
$ PYSNARK_BACKEND=snarkjs python3 cube.py 33
97107
The cube of 33 is 35937
98-
witness.json and circuit.json written; use 'snarkjs setup', 'snarkjs proof', and 'snarkjs verify'
99-
$ snarkjs setup
100-
$ snarkjs proof
101-
$ snarkjs verify
102-
OK
103-
$ snarkjs generateverifier
104-
$ snarkjs generatecall
108+
snarkjs witness.wtns and circuit.r1cs written; see readme
109+
$ snarkjs powersoftau new bn128 12 pot.ptau -v
110+
...
111+
$ snarkjs powersoftau prepare phase2 pot.ptau pott.ptau -v
105112
...
113+
$ snarkjs zkey new circuit.r1cs pott.ptau circuit.zkey
114+
...
115+
$ snarkjs zkey export verificationkey circuit.zkey verification_key.json
116+
$ snarkjs groth16 prove circuit.zkey witness.wtns proof.json public.json
117+
$ snarkjs groth16 verify verification_key.json public.json proof.json
118+
[INFO] snarkJS: OK!
119+
$ snarkjs zkey export solidityverifier circuit.zkey verifier.sol
120+
$ snarkjs zkey export soliditycalldata public.json proof.json
106121
```
107122

108123
## Using PySNARK (zkinterface backend)
@@ -241,6 +256,8 @@ When a particular functon is used multiple times in a verifiable computation, us
241256

242257
The `qaptools` backand of PySNARK supports the automatic generation of Solidity smart contracts that verify the correctness of the given zk-SNARK.
243258

259+
(Smart contracts can also be implemented using snarkjs with the snarkjs backend, see above.)
260+
244261
First, run a verifiable computation using the `qaptools` backend:
245262

246263
```

0 commit comments

Comments
 (0)