Skip to content

Commit e3ce784

Browse files
authored
readme zkp (#224)
1 parent 56c07d4 commit e3ce784

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ On Ubuntu `coinor-cbc` and `coinor-libcbc-dev`.
2626

2727
You'll also need a stable Rust compiler.
2828

29+
## Quickstart
30+
31+
For an example of doing ZKP compilation, look [here](./doc/zkp.md).
32+
2933
## Architecture
3034

3135
* Components:

doc/zkp.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Quickstart for ZKPs using the Z# front-end
2+
3+
1. Configure CirC's example compiler: `./driver.py --features bellman r1cs poly zok`
4+
* turns on the [bellman](https://github.com/zkcrypto/bellman/) ZKP backend,
5+
the R1CS compiler extension needed to target it,
6+
support for finite field polynomials,
7+
and the Z# (an extended ZoKrates) frontend
8+
2. Build the CirC library and example compiler `./driver.py -b`
9+
3. Compile an example program to ZKPs and sample ZKP paramaters: `./target/release/examples/circ examples/ZoKrates/pf/maj.zok r1cs --action setup`
10+
* creates a proving key in file `./P`
11+
* creates a verifying key in file `./V`
12+
* The program does a bitwise majority of three 8-bit arguments; the inputs are secret, the output is public.
13+
4. Create a proof: `./target/release/examples/zk --inputs examples/ZoKrates/pf/maj.zok.pin --action prove`
14+
* creates a proof in file `./pi`
15+
* the (secret) program inputs are in the input file `examples/ZoKrates/pf/maj.zok.pin`
16+
5. Verify the proof against a claimed program output: `./target/release/examples/zk --inputs examples/ZoKrates/pf/maj.zok.vin --action verify`
17+
* the output is `return` in the input file `examples/ZoKrates/pf/maj.zok.vin`
18+
* if verification fails, the command will return an error

examples/ZoKrates/pf/maj.zok

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
def main(u8 a, u8 b, u8 c) -> u8:
1+
def main(private u8 a, private u8 b, private u8 c) -> u8:
22
return (a & b) ^ (a & c) ^ (b & c)

examples/ZoKrates/pf/maj.zok.vin

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
(let (
2+
(return #xD9)
3+
)
4+
false
5+
)
6+

0 commit comments

Comments
 (0)