revert rand changes, update changelog and book
This commit is contained in:
parent
ebf5369912
commit
4536558560
7 changed files with 25 additions and 29 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1111,8 +1111,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"js-sys",
|
||||
"libc",
|
||||
"wasi 0.9.0+wasi-snapshot-preview1",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
@ -1 +1 @@
|
|||
Support for ark-groth16 implementation
|
||||
Support for the `groth16` scheme using the ark backend, support the usage of the `bls12_381` curve with the `gm17` and `marlin` scheme
|
|
@ -24,10 +24,10 @@ 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 |
|
||||
| [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.
|
||||
|
@ -46,10 +46,10 @@ 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 |
|
||||
| Ark | `--backend ark` | G16, GM17, MARLIN | ALTBN_128, BLS12_381, BLS12_377, BW6_761 |
|
||||
|
||||
Default: `bellman`
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ zokrates_common = { path = "../zokrates_common" }
|
|||
zokrates_embed = { version = "0.1.0", path = "../zokrates_embed" }
|
||||
getrandom = { version = "0.2", features = ["js"] }
|
||||
rand_0_4 = { version = "0.4", package = "rand" }
|
||||
rand_0_7 = { version = "0.7", package = "rand" }
|
||||
rand_0_7 = { version = "0.7", package = "rand", features = ["wasm-bindgen"] }
|
||||
csv = "1"
|
||||
phase2 = { git = "https://github.com/Zokrates/phase2", default-features = false }
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
|
|||
use zokrates_field::{ArkFieldExtensions, Bw6_761Field, Field};
|
||||
|
||||
use crate::ir::{ProgIterator, Statement, Witness};
|
||||
use crate::proof_system::ark::{get_random_seed, Computation};
|
||||
use crate::proof_system::ark::Computation;
|
||||
use crate::proof_system::ark::{parse_fr, parse_g1, parse_g2, parse_g2_fq};
|
||||
use crate::proof_system::ark::{serialization, Ark};
|
||||
use crate::proof_system::gm17::{ProofPoints, VerificationKey, GM17};
|
||||
|
@ -22,7 +22,7 @@ impl<T: Field + ArkFieldExtensions + NotBw6_761Field> NonUniversalBackend<T, GM1
|
|||
) -> SetupKeypair<<GM17 as Scheme<T>>::VerificationKey> {
|
||||
let computation = Computation::without_witness(program);
|
||||
|
||||
let rng = &mut rand_0_7::rngs::StdRng::from_seed(get_random_seed().unwrap());
|
||||
let rng = &mut rand_0_7::rngs::StdRng::from_entropy();
|
||||
let (pk, vk) = ArkGM17::<T::ArkEngine>::circuit_specific_setup(computation, rng).unwrap();
|
||||
|
||||
let mut pk_vec: Vec<u8> = Vec::new();
|
||||
|
@ -60,7 +60,7 @@ impl<T: Field + ArkFieldExtensions + NotBw6_761Field> Backend<T, GM17> for Ark {
|
|||
)
|
||||
.unwrap();
|
||||
|
||||
let rng = &mut rand_0_7::rngs::StdRng::from_seed(get_random_seed().unwrap());
|
||||
let rng = &mut rand_0_7::rngs::StdRng::from_entropy();
|
||||
let proof = ArkGM17::<T::ArkEngine>::prove(&pk, computation, rng).unwrap();
|
||||
|
||||
let proof_points = ProofPoints {
|
||||
|
@ -118,7 +118,7 @@ impl NonUniversalBackend<Bw6_761Field, GM17> for Ark {
|
|||
) -> SetupKeypair<<GM17 as Scheme<Bw6_761Field>>::VerificationKey> {
|
||||
let computation = Computation::without_witness(program);
|
||||
|
||||
let rng = &mut rand_0_7::rngs::StdRng::from_seed(get_random_seed().unwrap());
|
||||
let rng = &mut rand_0_7::rngs::StdRng::from_entropy();
|
||||
let (pk, vk) = ArkGM17::<BW6_761>::circuit_specific_setup(computation, rng).unwrap();
|
||||
|
||||
let mut pk_vec: Vec<u8> = Vec::new();
|
||||
|
@ -157,7 +157,7 @@ impl Backend<Bw6_761Field, GM17> for Ark {
|
|||
)
|
||||
.unwrap();
|
||||
|
||||
let rng = &mut rand_0_7::rngs::StdRng::from_seed(get_random_seed().unwrap());
|
||||
let rng = &mut rand_0_7::rngs::StdRng::from_entropy();
|
||||
let proof = ArkGM17::<BW6_761>::prove(&pk, computation, rng).unwrap();
|
||||
|
||||
let proof_points = ProofPoints {
|
||||
|
|
|
@ -10,7 +10,7 @@ use zokrates_field::{ArkFieldExtensions, Bw6_761Field};
|
|||
|
||||
use crate::ir::{ProgIterator, Statement, Witness};
|
||||
use crate::proof_system::ark::Computation;
|
||||
use crate::proof_system::ark::{get_random_seed, parse_fr, serialization, Ark};
|
||||
use crate::proof_system::ark::{parse_fr, serialization, Ark};
|
||||
use crate::proof_system::ark::{parse_g1, parse_g2};
|
||||
use crate::proof_system::groth16::{ProofPoints, VerificationKey, G16};
|
||||
use crate::proof_system::Scheme;
|
||||
|
@ -40,7 +40,7 @@ impl<T: Field + ArkFieldExtensions + NotBw6_761Field> Backend<T, G16> for Ark {
|
|||
)
|
||||
.unwrap();
|
||||
|
||||
let rng = &mut rand_0_7::rngs::StdRng::from_seed(get_random_seed().unwrap());
|
||||
let rng = &mut rand_0_7::rngs::StdRng::from_entropy();
|
||||
let proof = Groth16::<T::ArkEngine>::prove(&pk, computation, rng).unwrap();
|
||||
|
||||
let proof_points = ProofPoints {
|
||||
|
@ -97,7 +97,7 @@ impl<T: Field + ArkFieldExtensions + NotBw6_761Field> NonUniversalBackend<T, G16
|
|||
|
||||
let computation = Computation::without_witness(program);
|
||||
|
||||
let rng = &mut rand_0_7::rngs::StdRng::from_seed(get_random_seed().unwrap());
|
||||
let rng = &mut rand_0_7::rngs::StdRng::from_entropy();
|
||||
let (pk, vk) = Groth16::<T::ArkEngine>::circuit_specific_setup(computation, rng).unwrap();
|
||||
|
||||
let mut pk_vec: Vec<u8> = Vec::new();
|
||||
|
@ -134,7 +134,7 @@ impl Backend<Bw6_761Field, G16> for Ark {
|
|||
let pk =
|
||||
ProvingKey::<BW6_761>::deserialize_uncompressed(&mut proving_key.as_slice()).unwrap();
|
||||
|
||||
let rng = &mut rand_0_7::rngs::StdRng::from_seed(get_random_seed().unwrap());
|
||||
let rng = &mut rand_0_7::rngs::StdRng::from_entropy();
|
||||
let proof = Groth16::<BW6_761>::prove(&pk, computation, rng).unwrap();
|
||||
|
||||
let proof_points = ProofPoints {
|
||||
|
@ -191,7 +191,7 @@ impl NonUniversalBackend<Bw6_761Field, G16> for Ark {
|
|||
|
||||
let computation = Computation::without_witness(program);
|
||||
|
||||
let rng = &mut rand_0_7::rngs::StdRng::from_seed(get_random_seed().unwrap());
|
||||
let rng = &mut rand_0_7::rngs::StdRng::from_entropy();
|
||||
let (pk, vk) = Groth16::<BW6_761>::circuit_specific_setup(computation, rng).unwrap();
|
||||
|
||||
let mut pk_vec: Vec<u8> = Vec::new();
|
||||
|
|
|
@ -141,12 +141,6 @@ impl<T: Field + ArkFieldExtensions, I: IntoIterator<Item = Statement<T>>> ProgIt
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_random_seed() -> Result<[u8; 32], getrandom::Error> {
|
||||
let mut seed = [0u8; 32];
|
||||
getrandom::getrandom(&mut seed)?;
|
||||
Ok(seed)
|
||||
}
|
||||
|
||||
impl<T: Field + ArkFieldExtensions, I: IntoIterator<Item = Statement<T>>> Computation<T, I> {
|
||||
pub fn public_inputs_values(&self) -> Vec<<T::ArkEngine as PairingEngine>::Fr> {
|
||||
self.program
|
||||
|
|
Loading…
Reference in a new issue