Skip to content

Commit

Permalink
Merge pull request #380 from Zokrates/rc/0.4.7
Browse files Browse the repository at this point in the history
Release 0.4.7
  • Loading branch information
stefandeml authored Jun 14, 2019
2 parents 28fe629 + fb3b4eb commit 03cc69e
Show file tree
Hide file tree
Showing 63 changed files with 3,355 additions and 4,621 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ matrix:
# *BSD
- env: TARGET=x86_64-unknown-freebsd

# Windows
- env: TARGET=x86_64-pc-windows-gnu

before_install:
- set -e
- rustup self update
Expand Down
716 changes: 496 additions & 220 deletions Cargo.lock

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion ci/before_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,22 @@ main() {
;;
esac

case $TARGET in
x86_64-pc-windows-gnu)
BINARY_NAME=zokrates.exe
;;
*)
BINARY_NAME=zokrates
;;
esac

test -f Cargo.lock || cargo generate-lockfile

cross build --bin zokrates --target $TARGET --release

# Package artifacts
# Binary
cp target/$TARGET/release/zokrates $stage/
cp target/$TARGET/release/$BINARY_NAME $stage/
# Standard library
cp -r zokrates_stdlib/stdlib $stage

Expand Down
4 changes: 2 additions & 2 deletions full_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Exit if any subcommand fails
set -e

cargo test --release -- --ignored

if [ -n "$WITH_LIBSNARK" ]; then
cargo -Z package-features test --release --package zokrates_cli --features="libsnark" -- --ignored
else
cargo test --release -- --ignored
fi
4 changes: 2 additions & 2 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Exit if any subcommand fails
set -e

cargo test --release

if [ -n "$WITH_LIBSNARK" ]; then
cargo -Z package-features test --release --package zokrates_cli --features="libsnark"
else
cargo test --release
fi
2 changes: 1 addition & 1 deletion zokrates_book/src/gettingstarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ You can build the container yourself from [source](https://github.com/ZoKrates/Z
```bash
git clone https://github.com/ZoKrates/ZoKrates
cd ZoKrates
cargo build --release
cargo +nightly build --release
cd target/release
```

Expand Down
16 changes: 8 additions & 8 deletions zokrates_book/src/sha256example.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,17 @@ Based on that Victor can run the setup phase and export verifier smart contract
./zokrates export-verifier
```

`setup` creates a `verifiation.key` file and a `proving.key` file. Victor gives the proving key to Alice.
`setup` creates a `verifiation.key` file and a `proving.key` file. Victor gives the proving key to Peggy.

`export-verifier` creates a `verifier.sol` contract that contains our verification key and a function `verifyTx`. Victor deploys this smart contract to the Ethereum network.

Alice provides the correct pre-image as an argument to the program.
Peggy provides the correct pre-image as an argument to the program.

```sh
./zokrates compute-witness -a 0 0 0 5
```

Finally, Alice can run the command to construct the proof:
Finally, Peggy can run the command to construct the proof:

```sh
./zokrates generate-proof
Expand All @@ -111,18 +111,18 @@ ZoKrates creates a file, `proof.json`, consisting of the eight variables that m
* any public inputs to the main function, declared without the `private` keyword
* the return values of the ZoKrates function

In the example we're considering, all inputs are private and there is a single return value of `1`, hence Alice has to define her public input array as follows: `[1]`
In the example we're considering, all inputs are private and there is a single return value of `1`, hence Peggy has to define her public input array as follows: `[1]`

Alice can then submit her proof by calling `verifyTx`.
Peggy can then submit her proof by calling `verifyTx`.

Victor monitors the verification smart contract for the `Verified` event, which is emitted upon successful verification of a transaction. As soon as he observes the event triggered by a transaction from Alice's public address, he can be sure that Alice has a valid pre-image for the hash he set in the smart contract.
Victor monitors the verification smart contract for the `Verified` event, which is emitted upon successful verification of a transaction. As soon as he observes the event triggered by a transaction from Peggy's public address, he can be sure that Peggy has a valid pre-image for the hash he set in the smart contract.

## Conclusion

At this point, you’ve successfully ran you first zkSNARK on the Ethereum blockchain. Congratulations!

>Remember that in this example only two parties were involved. This special case makes it easy to deal with the trust assumptions of zkSNARKs: only Victor was interested in verifying the claim by Alice, hence he can trust his execution of the setup phase.
>Remember that in this example only two parties were involved. This special case makes it easy to deal with the trust assumptions of zkSNARKs: only Victor was interested in verifying the claim by Peggy, hence he can trust his execution of the setup phase.
>
>In general, multiple parties may be interested in verifying the correctness of Alice's statement. For example, in the zero-knowledge based cryptocurrency Zcash, each node needs to be able to validate the correctness of transactions. In order to generalize the setup phase to these multi-party use-cases a tricky process, commonly referred to as “trusted setup” or "ceremony" needs to be conducted.
>In general, multiple parties may be interested in verifying the correctness of Peggy's statement. For example, in the zero-knowledge based cryptocurrency Zcash, each node needs to be able to validate the correctness of transactions. In order to generalize the setup phase to these multi-party use-cases a tricky process, commonly referred to as “trusted setup” or "ceremony" needs to be conducted.
>
>ZoKrates would welcome ideas to add support for such ceremonies!
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.4.6"
version = "0.4.7"
authors = ["Jacob Eberhardt <jacob.eberhardt@tu-berlin.de>", "Dennis Kuhnert <mail@kyroy.com>", "Thibaut Schaeffer <thibaut@schaeff.fr>"]
repository = "https://github.com/JacobEberhardt/ZoKrates.git"
edition = "2018"
Expand Down
74 changes: 73 additions & 1 deletion zokrates_cli/src/bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use bincode::{deserialize_from, serialize_into, Infinite};
use clap::{App, AppSettings, Arg, SubCommand};
use serde_json::Value;
use std::env;
use std::fs::File;
use std::io::{stdin, BufReader, BufWriter, Read, Write};
Expand Down Expand Up @@ -200,6 +201,26 @@ fn cli() -> Result<(), String> {
.required(false)
.default_value(&default_scheme)
)
)
.subcommand(SubCommand::with_name("print-proof")
.about("Prints proof in chosen format [remix, json]")
.arg(Arg::with_name("proofpath")
.short("j")
.long("proofpath")
.help("Path of the JSON proof file")
.value_name("FILE")
.takes_value(true)
.required(false)
.default_value(JSON_PROOF_PATH)
).arg(Arg::with_name("format")
.short("f")
.long("format")
.value_name("FORMAT")
.help("Format in which the proof should be printed. [remix, json]")
.takes_value(true)
.possible_values(&["remix", "json", "testingV1", "testingV2"])
.required(true)
)
)
.get_matches();

Expand Down Expand Up @@ -427,12 +448,63 @@ fn cli() -> Result<(), String> {
scheme.generate_proof(program, witness, pk_path, proof_path)
);
}
("print-proof", Some(sub_matches)) => {
let format = sub_matches.value_of("format").unwrap();

let path = Path::new(sub_matches.value_of("proofpath").unwrap());

let file = File::open(&path)
.map_err(|why| format!("couldn't open {}: {}", path.display(), why))?;

let proof_object: Value =
serde_json::from_reader(file).map_err(|why| format!("{:?}", why))?;

match format {
"json" => {
println!("~~~~~~~~ Copy the output below for valid ABIv2 format ~~~~~~~~");
println!();
print!("{}", proof_object["proof"]);
print!(",");
println!("{}", proof_object["inputs"]);
println!();
println!("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
}
"remix" => {
println!("~~~~~~~~ Copy the output below for valid ABIv1 format ~~~~~~~~");
println!();

for (_, value) in proof_object["proof"].as_object().unwrap().iter() {
print!("{}", value);
print!(",");
}

println!("{}", proof_object["inputs"]);
println!();
println!("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
}
"testingV1" => {
//used by testing pipeline to generate arguments for contract call
for (_, value) in proof_object["proof"].as_object().unwrap().iter() {
print!("{}", value);
print!(",");
}
println!("{}", proof_object["inputs"]);
}
"testingV2" => {
//used by testing pipeline to generate arguments for contract call
print!("{}", proof_object["proof"]);
print!(",");
println!("{}", proof_object["inputs"]);
}
_ => unreachable!(),
}
}
_ => unreachable!(),
}
Ok(())
}

fn get_scheme(scheme_str: &str) -> Result<&'static ProofSystem, String> {
fn get_scheme(scheme_str: &str) -> Result<&'static dyn ProofSystem, String> {
match scheme_str.to_lowercase().as_ref() {
#[cfg(feature = "libsnark")]
"pghr13" => Ok(&PGHR13 {}),
Expand Down
Loading

0 comments on commit 03cc69e

Please sign in to comment.