Skip to content

Commit

Permalink
Merge pull request #1091 from Zokrates/rc/0.7.11
Browse files Browse the repository at this point in the history
Release 0.7.11
  • Loading branch information
Schaeff committed Jan 21, 2022
2 parents 5a22eb6 + aa3f1fc commit 656923c
Show file tree
Hide file tree
Showing 38 changed files with 1,168 additions and 7,035 deletions.
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
command: cargo generate-lockfile
- restore_cache:
keys:
- v4-cargo-cache-{{ arch }}-{{ checksum "Cargo.lock" }}
- cargo-cache-{{ .Environment.CACHE_VERSION }}-{{ arch }}-{{ checksum "Cargo.lock" }}
- run:
name: Build
command: WITH_LIBSNARK=1 RUSTFLAGS="-D warnings" ./build.sh
Expand All @@ -33,7 +33,7 @@ jobs:
- target/debug/.fingerprint
- target/debug/build
- target/debug/deps
key: v4-cargo-cache-{{ arch }}-{{ checksum "Cargo.lock" }}
key: cargo-cache-{{ .Environment.CACHE_VERSION }}-{{ arch }}-{{ checksum "Cargo.lock" }}
test:
docker:
- image: zokrates/env:latest
Expand All @@ -48,7 +48,7 @@ jobs:
command: cargo generate-lockfile
- restore_cache:
keys:
- v4-cargo-cache-{{ arch }}-{{ checksum "Cargo.lock" }}
- cargo-cache-{{ .Environment.CACHE_VERSION }}-{{ arch }}-{{ checksum "Cargo.lock" }}
- run:
name: Check format
command: cargo fmt --all -- --check
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:
command: cargo generate-lockfile
- restore_cache:
keys:
- v4-cargo-cache-{{ arch }}-{{ checksum "Cargo.lock" }}
- cargo-cache-{{ .Environment.CACHE_VERSION }}-{{ arch }}-{{ checksum "Cargo.lock" }}
- run:
name: Test on firefox
command: |
Expand All @@ -103,14 +103,14 @@ jobs:
command: cargo generate-lockfile
- restore_cache:
keys:
- v4-cargo-cache-{{ arch }}-{{ checksum "Cargo.lock" }}
- cargo-cache-{{ .Environment.CACHE_VERSION }}-{{ arch }}-{{ checksum "Cargo.lock" }}
- run:
name: Run integration tests
no_output_timeout: "30m"
command: WITH_LIBSNARK=1 RUSTFLAGS="-D warnings" ./integration_test.sh
deploy:
docker:
- image: circleci/python:latest-node
- image: cimg/python:3.8-node
steps:
- checkout
- setup_remote_docker:
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.
## [Unreleased]
https://github.com/Zokrates/ZoKrates/compare/latest...develop

## [0.7.11] - 2022-01-21

### Release
- https://github.com/Zokrates/ZoKrates/releases/tag/0.7.11 <!-- markdown-link-check-disable-line -->

### Changes
- Improve Merkle tree examples (#1077, @schaeff)
- Support for the `groth16` scheme using the ark backend, support the usage of the `bls12_381` curve with the `gm17` and `marlin` scheme (#1071, @dark64)
- Fix out of memory issues in `zokrates-js` (#1083, @dark64)
- Improve `inspect` command to include information about constraint count and curve (#1072, @dark64)

## [0.7.10] - 2021-12-16

### Release
Expand Down
31 changes: 25 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions Dockerfile.env
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain none -y \
&& rustup toolchain install $RUST_VERSION --allow-downgrade --profile minimal --component rustfmt clippy \
&& cargo install --git https://github.com/rustwasm/wasm-pack \
&& rm -rf /usr/local/cargo/registry \
&& curl -sL https://deb.nodesource.com/setup_lts.x | bash - && apt-get install -y nodejs && npm i -g solc \
&& curl -sL https://raw.githubusercontent.com/Sarcasm/run-clang-format/master/run-clang-format.py > /opt/run-clang-format.py \
&& chmod +x /opt/run-clang-format.py \
&& ln -s /opt/run-clang-format.py /usr/bin \
&& rustup --version; cargo --version; rustc --version; wasm-pack --version; echo nodejs $(node -v);
&& rustup --version; cargo --version; rustc --version; echo nodejs $(node -v);

RUN cd /opt && curl -LO https://github.com/mozilla/geckodriver/releases/download/v0.28.0/geckodriver-v0.28.0-linux64.tar.gz \
&& tar -xzf geckodriver-v0.28.0-linux64.tar.gz geckodriver \
Expand Down
22 changes: 11 additions & 11 deletions zokrates_book/src/toolbox/proving_schemes.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ When not using the default, the CLI flag has to be provided for the following co

ZoKrates supports different proving schemes. We identify the schemes by the reference to the paper that introduced them. Currently the options available are:

| Scheme | CLI flag | Curves | Universal |
| ---- | -------- | ------ | ------------|
| [G16](https://eprint.iacr.org/2016/260) | `--proving-scheme g16` | ALTBN_128, BLS12_381 | No |
| [GM17](https://eprint.iacr.org/2017/540) | `--proving-scheme gm17` | ALTBN_128, BLS12_377, BW6_761 | No |
| [Marlin](https://eprint.iacr.org/2019/1047) | `--proving-scheme marlin` | ALTBN_128, BLS12_377, BW6_761 | Yes |
| [PGHR13](https://eprint.iacr.org/2013/279) | `--proving-scheme pghr13` | ALTBN_128 | No |
| Scheme | CLI flag | Curves | Universal |
| ---- | -------- |------------------------------------------| ------------|
| [G16](https://eprint.iacr.org/2016/260) | `--proving-scheme g16` | ALTBN_128, BLS12_381 | No |
| [GM17](https://eprint.iacr.org/2017/540) | `--proving-scheme gm17` | ALTBN_128, BLS12_381, BLS12_377, BW6_761 | No |
| [Marlin](https://eprint.iacr.org/2019/1047) | `--proving-scheme marlin` | ALTBN_128, BLS12_381, BLS12_377, BW6_761 | Yes |
| [PGHR13](https://eprint.iacr.org/2013/279) | `--proving-scheme pghr13` | ALTBN_128 | No |

All schemes have a circuit-specific setup phase called `setup`. Universal schemes also feature a preliminary, circuit-agnostic step called `universal-setup`. The advantage of universal schemes is that only the `universal-setup` step requires trust, so that it can be run a single time and reused trustlessly for many programs.

Expand All @@ -45,11 +45,11 @@ When not using the default, the CLI flag has to be provided for the following co

ZoKrates supports multiple backends. The options are the following:

| Backend | CLI flag | Proving schemes | Curves |
| ---- | -------- | --------------- | ------ |
| Bellman | `--backend bellman` | G16 | ALTBN_128, BLS12_381 |
| Libsnark | `--backend libsnark` | GM17, PGHR13 | ALTBN_128 |
| Ark | `--backend ark` | GM17, MARLIN | ALTBN_128, BLS12_377, BW6_761 |
| Backend | CLI flag | Proving schemes | Curves |
| ---- | -------- |-------------------|------------------------------------------|
| Bellman | `--backend bellman` | G16 | ALTBN_128, BLS12_381 |
| Libsnark | `--backend libsnark` | GM17, PGHR13 | ALTBN_128 |
| Ark | `--backend ark` | G16, GM17, MARLIN | ALTBN_128, BLS12_381, BLS12_377, BW6_761 |

Default: `bellman`

Expand Down
2 changes: 1 addition & 1 deletion zokrates_cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "zokrates_cli"
version = "0.7.10"
version = "0.7.11"
authors = ["Jacob Eberhardt <jacob.eberhardt@tu-berlin.de>", "Dennis Kuhnert <mail@kyroy.com>", "Thibaut Schaeffer <thibaut@schaeff.fr>"]
repository = "https://github.com/Zokrates/ZoKrates.git"
edition = "2018"
Expand Down
29 changes: 12 additions & 17 deletions zokrates_cli/examples/merkleTree/pedersenPathProof3.zok
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
import "hashes/pedersen/512bit" as hash
import "ecc/edwardsCompress" as edwardsCompress
import "hashes/utils/256bitsDirectionHelper" as multiplex

// Merke-Tree inclusion proof for tree depth 3 using SNARK efficient pedersen hashes
// directionSelector=> true if current digest is on the rhs of the hash
const u32 DEPTH = 3

def main(u32[8] rootDigest, private u32[8] leafDigest, private bool[3] directionSelector, u32[8] PathDigest0, private u32[8] PathDigest1, private u32[8] PathDigest2):
//Setup
u32[8] currentDigest = leafDigest

//Loop up the tree
u32[16] preimage = multiplex(directionSelector[0], currentDigest, PathDigest0)
currentDigest = hash(preimage)
// Merke-Tree inclusion proof for tree depth 4 using SNARK-efficient pedersen hashes
// directionSelector => true if current digest is on the rhs of the hash

preimage = multiplex(directionSelector[1], currentDigest, PathDigest1)
currentDigest = hash(preimage)
def main(u32[8] root, private u32[8] leaf, private bool[DEPTH] directionSelector, private u32[DEPTH][8] path) -> bool:
// Start from the leaf
u32[8] digest = leaf

preimage = multiplex(directionSelector[2], currentDigest, PathDigest2)
currentDigest = hash(preimage)
// Loop up the tree
for u32 i in 0..DEPTH do
u32[16] preimage = multiplex(directionSelector[i], digest, path[i])
digest = hash(preimage)
endfor

assert(rootDigest == currentDigest)

return
return digest == root

40 changes: 16 additions & 24 deletions zokrates_cli/examples/merkleTree/sha256PathProof3.zok
Original file line number Diff line number Diff line change
@@ -1,31 +1,23 @@
import "hashes/sha256/512bit" as sha256
import "hashes/sha256/512bit" as hash
import "hashes/utils/256bitsDirectionHelper" as multiplex

def multiplex(bool selector, u32[8] left, u32[8] right) -> (u32[8]):
return if selector then right else left fi
const u32 DEPTH = 3

// Merkle-Tree inclusion proof for tree depth 3
def select(bool condition, u32[8] left, u32[8] right) -> (u32[8], u32[8]):
return if condition then right else left fi, if condition then left else right fi

def main(field treeDepth, u32[8] rootDigest, private u32[8] leafDigest, private bool[2] directionSelector, u32[8] PathDigest0, private u32[8] PathDigest1):
// Merke-Tree inclusion proof for tree depth 4 using sha256
// directionSelector => true if current digest is on the rhs of the hash

//Setup
u32[8] currentDigest = leafDigest
field counter = 1
bool currentDirection = false

//Loop up the tree
currentDirection = directionSelector[0]
u32[8] lhs = multiplex(currentDirection, currentDigest, PathDigest0)
u32[8] rhs = multiplex(!currentDirection, currentDigest, PathDigest0)
currentDigest = sha256(lhs, rhs)
counter = counter + 1
def main(u32[8] root, private u32[8] leaf, private bool[DEPTH] directionSelector, private u32[DEPTH][8] path) -> bool:
// Start from the leaf
u32[8] digest = leaf

currentDirection = directionSelector[1]
lhs = multiplex(currentDirection, currentDigest, PathDigest1)
rhs = multiplex(!currentDirection, currentDigest, PathDigest1)
currentDigest = sha256(lhs, rhs)
counter = counter + 1
// Loop up the tree
for u32 i in 0..DEPTH do
u32[8] left, u32[8] right = select(directionSelector[i], digest, path[i])
digest = hash(left, right)
endfor

assert(counter == treeDepth)
assert(rootDigest == currentDigest)
return digest == root

return
18 changes: 15 additions & 3 deletions zokrates_cli/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,28 @@ impl TryFrom<(&str, &str, &str)> for Parameters {
#[cfg(feature = "bellman")]
(BackendParameter::Bellman, CurveParameter::Bls12_381, SchemeParameter::G16) => Ok(()),
#[cfg(feature = "ark")]
(BackendParameter::Ark, CurveParameter::Bls12_377, SchemeParameter::GM17) => Ok(()),
(BackendParameter::Ark, CurveParameter::Bn128, SchemeParameter::G16) => Ok(()),
#[cfg(feature = "ark")]
(BackendParameter::Ark, CurveParameter::Bw6_761, SchemeParameter::GM17) => Ok(()),
(BackendParameter::Ark, CurveParameter::Bls12_381, SchemeParameter::G16) => Ok(()),
#[cfg(feature = "ark")]
(BackendParameter::Ark, CurveParameter::Bls12_377, SchemeParameter::G16) => Ok(()),
#[cfg(feature = "ark")]
(BackendParameter::Ark, CurveParameter::Bw6_761, SchemeParameter::G16) => Ok(()),
#[cfg(feature = "ark")]
(BackendParameter::Ark, CurveParameter::Bn128, SchemeParameter::GM17) => Ok(()),
#[cfg(feature = "ark")]
(BackendParameter::Ark, CurveParameter::Bls12_377, SchemeParameter::MARLIN) => Ok(()),
(BackendParameter::Ark, CurveParameter::Bls12_377, SchemeParameter::GM17) => Ok(()),
#[cfg(feature = "ark")]
(BackendParameter::Ark, CurveParameter::Bls12_381, SchemeParameter::GM17) => Ok(()),
#[cfg(feature = "ark")]
(BackendParameter::Ark, CurveParameter::Bw6_761, SchemeParameter::GM17) => Ok(()),
#[cfg(feature = "ark")]
(BackendParameter::Ark, CurveParameter::Bn128, SchemeParameter::MARLIN) => Ok(()),
#[cfg(feature = "ark")]
(BackendParameter::Ark, CurveParameter::Bls12_381, SchemeParameter::MARLIN) => Ok(()),
#[cfg(feature = "ark")]
(BackendParameter::Ark, CurveParameter::Bls12_377, SchemeParameter::MARLIN) => Ok(()),
#[cfg(feature = "ark")]
(BackendParameter::Ark, CurveParameter::Bw6_761, SchemeParameter::MARLIN) => Ok(()),
#[cfg(feature = "libsnark")]
(BackendParameter::Libsnark, CurveParameter::Bn128, SchemeParameter::GM17) => Ok(()),
Expand Down
17 changes: 13 additions & 4 deletions zokrates_cli/src/ops/generate_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,29 @@ pub fn exec(sub_matches: &ArgMatches) -> Result<(), String> {
_ => unreachable!(),
},
#[cfg(feature = "ark")]
Parameters(BackendParameter::Ark, _, SchemeParameter::G16) => match prog {
ProgEnum::Bn128Program(p) => cli_generate_proof::<_, _, G16, Ark>(p, sub_matches),
ProgEnum::Bls12_381Program(p) => cli_generate_proof::<_, _, G16, Ark>(p, sub_matches),
ProgEnum::Bls12_377Program(p) => cli_generate_proof::<_, _, G16, Ark>(p, sub_matches),
ProgEnum::Bw6_761Program(p) => cli_generate_proof::<_, _, G16, Ark>(p, sub_matches),
},
#[cfg(feature = "ark")]
Parameters(BackendParameter::Ark, _, SchemeParameter::GM17) => match prog {
ProgEnum::Bn128Program(p) => cli_generate_proof::<_, _, GM17, Ark>(p, sub_matches),
ProgEnum::Bls12_381Program(p) => cli_generate_proof::<_, _, GM17, Ark>(p, sub_matches),
ProgEnum::Bls12_377Program(p) => cli_generate_proof::<_, _, GM17, Ark>(p, sub_matches),
ProgEnum::Bw6_761Program(p) => cli_generate_proof::<_, _, GM17, Ark>(p, sub_matches),
ProgEnum::Bn128Program(p) => cli_generate_proof::<_, _, GM17, Ark>(p, sub_matches),
_ => unreachable!(),
},
#[cfg(feature = "ark")]
Parameters(BackendParameter::Ark, _, SchemeParameter::MARLIN) => match prog {
ProgEnum::Bn128Program(p) => cli_generate_proof::<_, _, Marlin, Ark>(p, sub_matches),
ProgEnum::Bls12_381Program(p) => {
cli_generate_proof::<_, _, Marlin, Ark>(p, sub_matches)
}
ProgEnum::Bls12_377Program(p) => {
cli_generate_proof::<_, _, Marlin, Ark>(p, sub_matches)
}
ProgEnum::Bw6_761Program(p) => cli_generate_proof::<_, _, Marlin, Ark>(p, sub_matches),
ProgEnum::Bn128Program(p) => cli_generate_proof::<_, _, Marlin, Ark>(p, sub_matches),
_ => unreachable!(),
},
#[cfg(feature = "libsnark")]
Parameters(BackendParameter::Libsnark, CurveParameter::Bn128, SchemeParameter::GM17) => {
Expand Down
Loading

0 comments on commit 656923c

Please sign in to comment.