From b972e6d7eae5ab6ebe37302a7a41637d5bca6bdb Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Wed, 23 Sep 2020 15:13:51 +0200 Subject: [PATCH 01/20] use rust based fil-blst --- storage-proofs/core/Cargo.toml | 2 +- storage-proofs/core/src/compound_proof.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/storage-proofs/core/Cargo.toml b/storage-proofs/core/Cargo.toml index 6083013ad..cfa171492 100644 --- a/storage-proofs/core/Cargo.toml +++ b/storage-proofs/core/Cargo.toml @@ -43,7 +43,7 @@ neptune = { version = "=1.2.1", features = ["gpu"] } cpu-time = { version = "1.0", optional = true } gperftools = { version = "0.2", optional = true } num_cpus = "1.10.1" -fil-blst = "0.1.1" +fil-blst = { git = "https://github.com/filecoin-project/fil-blst", branch = "rustify" } [dev-dependencies] proptest = "0.10" diff --git a/storage-proofs/core/src/compound_proof.rs b/storage-proofs/core/src/compound_proof.rs index 518531520..42c27decd 100644 --- a/storage-proofs/core/src/compound_proof.rs +++ b/storage-proofs/core/src/compound_proof.rs @@ -2,7 +2,7 @@ use std::path::Path; use anyhow::{ensure, Context}; use bellperson::{groth16, Circuit}; -use fil_blst::{blst_fr, blst_scalar, scalar_from_u64, verify_batch_proof}; +use fil_blst::{blst::blst_scalar, blst_fr_from_fr, scalar_from_u64, verify_batch_proof}; use log::info; use paired::bls12_381::{Bls12, Fr}; use rand::{rngs::OsRng, RngCore}; @@ -193,7 +193,7 @@ where let blst_inputs: Vec<_> = inputs .iter() - .flat_map(|pis| pis.iter().map(|pi| blst_fr::from(*pi))) + .flat_map(|pis| pis.iter().map(|pi| blst_fr_from_fr(*pi))) .collect(); // choose random coefficients for combining the proofs @@ -213,9 +213,9 @@ where let res = verify_batch_proof( proof_vec, num_proofs, - &blst_inputs, + &blst_inputs[..], inputs[0].len(), - &r, + &r[..], 128, vk_path, ); From 51cfc924344565e8841b143e1ccd3a89a8dd36b7 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Thu, 24 Sep 2020 16:40:48 +0200 Subject: [PATCH 02/20] storage-proofs-core: integrate bellperson::bls --- storage-proofs/core/Cargo.toml | 9 +++++---- storage-proofs/core/benches/blake2s.rs | 2 +- storage-proofs/core/benches/fr.rs | 2 +- storage-proofs/core/benches/sha256.rs | 2 +- storage-proofs/core/benches/xor.rs | 2 +- storage-proofs/core/src/compound_proof.rs | 2 +- storage-proofs/core/src/crypto/sloth.rs | 4 ++-- storage-proofs/core/src/fr32.rs | 2 +- storage-proofs/core/src/gadgets/constraint.rs | 5 ++--- storage-proofs/core/src/gadgets/encode.rs | 3 +-- storage-proofs/core/src/gadgets/insertion.rs | 5 ++--- storage-proofs/core/src/gadgets/por.rs | 2 +- storage-proofs/core/src/gadgets/uint64.rs | 3 +-- storage-proofs/core/src/gadgets/variables.rs | 3 +-- storage-proofs/core/src/gadgets/xor.rs | 3 +-- storage-proofs/core/src/hasher/blake2s.rs | 2 +- storage-proofs/core/src/hasher/poseidon.rs | 2 +- storage-proofs/core/src/hasher/sha256.rs | 4 ++-- storage-proofs/core/src/hasher/types.rs | 2 +- storage-proofs/core/src/merkle/proof.rs | 2 +- storage-proofs/core/src/multi_proof.rs | 2 +- storage-proofs/core/src/parameter_cache.rs | 2 +- storage-proofs/core/src/por.rs | 2 +- storage-proofs/core/src/sector.rs | 2 +- storage-proofs/core/src/util.rs | 5 ++--- 25 files changed, 34 insertions(+), 40 deletions(-) diff --git a/storage-proofs/core/Cargo.toml b/storage-proofs/core/Cargo.toml index cfa171492..59dd1455b 100644 --- a/storage-proofs/core/Cargo.toml +++ b/storage-proofs/core/Cargo.toml @@ -30,8 +30,7 @@ blake2b_simd = "0.5" blake2s_simd = "0.5" toml = "0.5" ff = { version = "0.2.3", package = "fff" } -bellperson = "0.9.1" -paired = { version = "0.20.0", features = ["serde"] } +bellperson = { git = "https://github.com/filecoin-project/bellman", branch = "blstrs", default-features = false } serde_json = "1.0" log = "0.4.7" rand_chacha = "0.2.1" @@ -39,7 +38,7 @@ hex = "0.4.0" generic-array = "0.13.2" anyhow = "1.0.23" thiserror = "1.0.6" -neptune = { version = "=1.2.1", features = ["gpu"] } +neptune = { git = "https://github.com/filecoin-project/neptune", branch = "blst", default-features = false, features = ["gpu"] } cpu-time = { version = "1.0", optional = true } gperftools = { version = "0.2", optional = true } num_cpus = "1.10.1" @@ -54,13 +53,15 @@ pretty_assertions = "0.6.1" sha2raw = { path = "../../sha2raw", version = "^2.0.0"} [features] -default = ["gpu"] +default = ["gpu", "pairing"] simd = [] asm = ["sha2/sha2-asm"] big-sector-sizes-bench = [] gpu = ["bellperson/gpu"] measurements = ["cpu-time", "gperftools"] profile = ["measurements"] +pairing = ["bellperson/pairing", "fil-sapling-crypto/pairing", "neptune/pairing"] +blst = ["bellperson/blst", "fil-sapling-crypto/blst", "neptune/blst"] [[bench]] name = "sha256" diff --git a/storage-proofs/core/benches/blake2s.rs b/storage-proofs/core/benches/blake2s.rs index bca13282e..36cf7c325 100644 --- a/storage-proofs/core/benches/blake2s.rs +++ b/storage-proofs/core/benches/blake2s.rs @@ -3,7 +3,7 @@ use bellperson::groth16::*; use bellperson::util_cs::bench_cs::BenchCS; use bellperson::{Circuit, ConstraintSystem, SynthesisError}; use criterion::{black_box, criterion_group, criterion_main, Criterion, ParameterizedBenchmark}; -use paired::bls12_381::Bls12; +use bellperson::bls::Bls12; use rand::{thread_rng, Rng}; struct Blake2sExample<'a> { diff --git a/storage-proofs/core/benches/fr.rs b/storage-proofs/core/benches/fr.rs index b793be308..aaf71fa4f 100644 --- a/storage-proofs/core/benches/fr.rs +++ b/storage-proofs/core/benches/fr.rs @@ -1,6 +1,6 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion}; use ff::Field; -use paired::bls12_381::Fr; +use bellperson::bls::Fr; use rand::thread_rng; use storage_proofs_core::fr32::{bytes_into_fr, fr_into_bytes}; diff --git a/storage-proofs/core/benches/sha256.rs b/storage-proofs/core/benches/sha256.rs index 270d68bcf..e5137755e 100644 --- a/storage-proofs/core/benches/sha256.rs +++ b/storage-proofs/core/benches/sha256.rs @@ -5,7 +5,7 @@ use bellperson::{Circuit, ConstraintSystem, SynthesisError}; use criterion::{ black_box, criterion_group, criterion_main, Criterion, ParameterizedBenchmark, Throughput, }; -use paired::bls12_381::Bls12; +use bellperson::bls::Bls12; use rand::{thread_rng, Rng}; use sha2::{Digest, Sha256}; diff --git a/storage-proofs/core/benches/xor.rs b/storage-proofs/core/benches/xor.rs index 71be99751..a0fe0fee9 100644 --- a/storage-proofs/core/benches/xor.rs +++ b/storage-proofs/core/benches/xor.rs @@ -3,7 +3,7 @@ use bellperson::groth16::*; use bellperson::util_cs::bench_cs::BenchCS; use bellperson::{Circuit, ConstraintSystem, SynthesisError}; use criterion::{black_box, criterion_group, criterion_main, Criterion, ParameterizedBenchmark}; -use paired::bls12_381::Bls12; +use bellperson::bls::Bls12; use rand::{thread_rng, Rng}; use storage_proofs_core::crypto::xor; use storage_proofs_core::gadgets; diff --git a/storage-proofs/core/src/compound_proof.rs b/storage-proofs/core/src/compound_proof.rs index 42c27decd..a184c3a3c 100644 --- a/storage-proofs/core/src/compound_proof.rs +++ b/storage-proofs/core/src/compound_proof.rs @@ -4,7 +4,7 @@ use anyhow::{ensure, Context}; use bellperson::{groth16, Circuit}; use fil_blst::{blst::blst_scalar, blst_fr_from_fr, scalar_from_u64, verify_batch_proof}; use log::info; -use paired::bls12_381::{Bls12, Fr}; +use bellperson::bls::{Bls12, Fr}; use rand::{rngs::OsRng, RngCore}; use rayon::prelude::*; diff --git a/storage-proofs/core/src/crypto/sloth.rs b/storage-proofs/core/src/crypto/sloth.rs index c4a991aa0..d6d672337 100644 --- a/storage-proofs/core/src/crypto/sloth.rs +++ b/storage-proofs/core/src/crypto/sloth.rs @@ -1,5 +1,5 @@ use ff::Field; -use paired::bls12_381::Fr; +use bellperson::bls::Fr; /// Sloth based encoding. #[inline] @@ -24,7 +24,7 @@ pub fn decode(key: &Fr, ciphertext: &Fr) -> Fr { mod tests { use super::*; use ff::PrimeField; - use paired::bls12_381::{Fr, FrRepr}; + use bellperson::bls::{Fr, FrRepr}; use proptest::{prop_compose, proptest}; // the modulus from `bls12_381::Fr` diff --git a/storage-proofs/core/src/fr32.rs b/storage-proofs/core/src/fr32.rs index 81b64f2e7..feb00eb3d 100644 --- a/storage-proofs/core/src/fr32.rs +++ b/storage-proofs/core/src/fr32.rs @@ -3,7 +3,7 @@ use crate::error::*; use anyhow::{ensure, Context}; use byteorder::{ByteOrder, LittleEndian, WriteBytesExt}; use ff::{PrimeField, PrimeFieldRepr}; -use paired::bls12_381::{Fr, FrRepr}; +use bellperson::bls::{Fr, FrRepr}; // Contains 32 bytes whose little-endian value represents an Fr. // Invariants: diff --git a/storage-proofs/core/src/gadgets/constraint.rs b/storage-proofs/core/src/gadgets/constraint.rs index d6ae000ed..9d16251e3 100644 --- a/storage-proofs/core/src/gadgets/constraint.rs +++ b/storage-proofs/core/src/gadgets/constraint.rs @@ -1,6 +1,5 @@ -use bellperson::{gadgets::num, ConstraintSystem, SynthesisError}; +use bellperson::{gadgets::num, ConstraintSystem, SynthesisError, bls::Engine}; use ff::Field; -use paired::Engine; /// Adds a constraint to CS, enforcing an equality relationship between the allocated numbers a and b. /// @@ -120,7 +119,7 @@ mod tests { use super::*; use bellperson::util_cs::test_cs::TestConstraintSystem; - use paired::bls12_381::{Bls12, Fr}; + use bellperson::bls::{Bls12, Fr}; use rand::SeedableRng; use rand_xorshift::XorShiftRng; diff --git a/storage-proofs/core/src/gadgets/encode.rs b/storage-proofs/core/src/gadgets/encode.rs index 08486b439..a4421b7d5 100644 --- a/storage-proofs/core/src/gadgets/encode.rs +++ b/storage-proofs/core/src/gadgets/encode.rs @@ -1,6 +1,5 @@ use bellperson::gadgets::num; -use bellperson::{ConstraintSystem, SynthesisError}; -use paired::Engine; +use bellperson::{ConstraintSystem, SynthesisError, bls::Engine}; use crate::gadgets::constraint; diff --git a/storage-proofs/core/src/gadgets/insertion.rs b/storage-proofs/core/src/gadgets/insertion.rs index ca016f954..7cde5a5ea 100644 --- a/storage-proofs/core/src/gadgets/insertion.rs +++ b/storage-proofs/core/src/gadgets/insertion.rs @@ -5,9 +5,8 @@ use bellperson::gadgets::boolean::{AllocatedBit, Boolean}; use bellperson::gadgets::num::AllocatedNum; -use bellperson::{ConstraintSystem, SynthesisError}; +use bellperson::{ConstraintSystem, SynthesisError, bls::Engine}; use ff::Field; -use paired::Engine; /// Insert `element` after the nth 1-indexed element of `elements`, where `path_bits` represents n, least-significant bit first. /// The returned result contains a new vector of `AllocatedNum`s with `element` inserted, and constraints are enforced. @@ -352,7 +351,7 @@ mod tests { use bellperson::gadgets::boolean::AllocatedBit; use bellperson::util_cs::test_cs::TestConstraintSystem; use ff::Field; - use paired::bls12_381::{Bls12, Fr}; + use bellperson::bls::{Bls12, Fr}; use rand::SeedableRng; use rand_xorshift::XorShiftRng; diff --git a/storage-proofs/core/src/gadgets/por.rs b/storage-proofs/core/src/gadgets/por.rs index 7566ad0c7..f7e21cbfb 100644 --- a/storage-proofs/core/src/gadgets/por.rs +++ b/storage-proofs/core/src/gadgets/por.rs @@ -7,7 +7,7 @@ use bellperson::gadgets::{multipack, num}; use bellperson::{Circuit, ConstraintSystem, SynthesisError}; use ff::PrimeField; use generic_array::typenum::Unsigned; -use paired::bls12_381::{Bls12, Fr, FrRepr}; +use bellperson::bls::{Bls12, Fr, FrRepr}; use crate::compound_proof::{CircuitComponent, CompoundProof}; use crate::error::Result; diff --git a/storage-proofs/core/src/gadgets/uint64.rs b/storage-proofs/core/src/gadgets/uint64.rs index da51f2ae3..62b5ef532 100644 --- a/storage-proofs/core/src/gadgets/uint64.rs +++ b/storage-proofs/core/src/gadgets/uint64.rs @@ -1,7 +1,6 @@ use bellperson::gadgets::boolean::{AllocatedBit, Boolean}; use bellperson::gadgets::multipack::pack_into_inputs; -use bellperson::{ConstraintSystem, SynthesisError}; -use paired::Engine; +use bellperson::{ConstraintSystem, SynthesisError, bls::Engine}; /// Represents an interpretation of 64 `Boolean` objects as an unsigned integer. #[derive(Clone)] diff --git a/storage-proofs/core/src/gadgets/variables.rs b/storage-proofs/core/src/gadgets/variables.rs index 5b6ed606b..3621f049e 100644 --- a/storage-proofs/core/src/gadgets/variables.rs +++ b/storage-proofs/core/src/gadgets/variables.rs @@ -3,8 +3,7 @@ use std::fmt; use anyhow::Result; use bellperson::gadgets::num::AllocatedNum; -use bellperson::{ConstraintSystem, SynthesisError}; -use paired::Engine; +use bellperson::{ConstraintSystem, SynthesisError, bls::Engine}; /// Root represents a root commitment which may be either a raw value or an already-allocated number. /// This allows subcomponents to depend on roots which may optionally be shared with their parent diff --git a/storage-proofs/core/src/gadgets/xor.rs b/storage-proofs/core/src/gadgets/xor.rs index eaf127542..2684de7e2 100644 --- a/storage-proofs/core/src/gadgets/xor.rs +++ b/storage-proofs/core/src/gadgets/xor.rs @@ -35,8 +35,7 @@ mod tests { use crate::util::{bits_to_bytes, bytes_into_boolean_vec}; use bellperson::gadgets::boolean::Boolean; use bellperson::util_cs::test_cs::TestConstraintSystem; - use bellperson::ConstraintSystem; - use paired::bls12_381::Bls12; + use bellperson::{ConstraintSystem, bls::Bls12}; use rand::{Rng, SeedableRng}; use rand_xorshift::XorShiftRng; diff --git a/storage-proofs/core/src/hasher/blake2s.rs b/storage-proofs/core/src/hasher/blake2s.rs index 89df68a81..9a621e5c7 100644 --- a/storage-proofs/core/src/hasher/blake2s.rs +++ b/storage-proofs/core/src/hasher/blake2s.rs @@ -8,7 +8,7 @@ use blake2s_simd::{Hash as Blake2sHash, Params as Blake2s, State}; use ff::{Field, PrimeField, PrimeFieldRepr}; use merkletree::hash::{Algorithm, Hashable}; use merkletree::merkle::Element; -use paired::bls12_381::{Bls12, Fr, FrRepr}; +use bellperson::bls::{Bls12, Fr, FrRepr}; use rand::RngCore; use serde::{Deserialize, Serialize}; diff --git a/storage-proofs/core/src/hasher/poseidon.rs b/storage-proofs/core/src/hasher/poseidon.rs index 81e7b8e0d..013811309 100644 --- a/storage-proofs/core/src/hasher/poseidon.rs +++ b/storage-proofs/core/src/hasher/poseidon.rs @@ -17,7 +17,7 @@ use merkletree::hash::{Algorithm as LightAlgorithm, Hashable}; use merkletree::merkle::Element; use neptune::circuit::poseidon_hash; use neptune::poseidon::Poseidon; -use paired::bls12_381::{Bls12, Fr, FrRepr}; +use bellperson::bls::{Bls12, Fr, FrRepr}; use serde::{Deserialize, Serialize}; #[derive(Default, Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] diff --git a/storage-proofs/core/src/hasher/sha256.rs b/storage-proofs/core/src/hasher/sha256.rs index 96557b0ab..229f30025 100644 --- a/storage-proofs/core/src/hasher/sha256.rs +++ b/storage-proofs/core/src/hasher/sha256.rs @@ -6,7 +6,7 @@ use bellperson::{ConstraintSystem, SynthesisError}; use ff::{Field, PrimeField, PrimeFieldRepr}; use merkletree::hash::{Algorithm, Hashable}; use merkletree::merkle::Element; -use paired::bls12_381::{Bls12, Fr, FrRepr}; +use bellperson::bls::{Bls12, Fr, FrRepr}; use rand::RngCore; use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; @@ -360,7 +360,7 @@ mod tests { use bellperson::ConstraintSystem; use ff::Field; use merkletree::hash::Algorithm; - use paired::bls12_381::{Bls12, Fr}; + use bellperson::bls::{Bls12, Fr}; use rand::SeedableRng; use rand_xorshift::XorShiftRng; diff --git a/storage-proofs/core/src/hasher/types.rs b/storage-proofs/core/src/hasher/types.rs index 1e5cfd739..0f3823bd1 100644 --- a/storage-proofs/core/src/hasher/types.rs +++ b/storage-proofs/core/src/hasher/types.rs @@ -5,7 +5,7 @@ use lazy_static::lazy_static; use merkletree::hash::{Algorithm as LightAlgorithm, Hashable as LightHashable}; use merkletree::merkle::Element; use neptune::poseidon::PoseidonConstants; -use paired::bls12_381::{Bls12, Fr, FrRepr}; +use bellperson::bls::{Bls12, Fr, FrRepr}; use serde::de::DeserializeOwned; use serde::ser::Serialize; diff --git a/storage-proofs/core/src/merkle/proof.rs b/storage-proofs/core/src/merkle/proof.rs index de7278544..2742e674e 100644 --- a/storage-proofs/core/src/merkle/proof.rs +++ b/storage-proofs/core/src/merkle/proof.rs @@ -6,7 +6,7 @@ use anyhow::{ensure, Result}; use generic_array::typenum::{Unsigned, U0}; use merkletree::hash::Algorithm; use merkletree::proof; -use paired::bls12_381::Fr; +use bellperson::bls::Fr; use serde::{Deserialize, Serialize}; use crate::drgraph::graph_height; diff --git a/storage-proofs/core/src/multi_proof.rs b/storage-proofs/core/src/multi_proof.rs index 0f4360539..1711b88bf 100644 --- a/storage-proofs/core/src/multi_proof.rs +++ b/storage-proofs/core/src/multi_proof.rs @@ -2,7 +2,7 @@ use bellperson::groth16; use crate::error::Result; use anyhow::{ensure, Context}; -use paired::bls12_381::Bls12; +use bellperson::bls::Bls12; use rayon::prelude::*; use std::io::{self, Read, Write}; diff --git a/storage-proofs/core/src/parameter_cache.rs b/storage-proofs/core/src/parameter_cache.rs index b1e34864a..4b9e7b2af 100644 --- a/storage-proofs/core/src/parameter_cache.rs +++ b/storage-proofs/core/src/parameter_cache.rs @@ -7,7 +7,7 @@ use fs2::FileExt; use itertools::Itertools; use lazy_static::lazy_static; use log::info; -use paired::bls12_381::Bls12; +use bellperson::bls::Bls12; use rand::RngCore; use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; diff --git a/storage-proofs/core/src/por.rs b/storage-proofs/core/src/por.rs index c2e60edfd..89e1a23c3 100644 --- a/storage-proofs/core/src/por.rs +++ b/storage-proofs/core/src/por.rs @@ -152,7 +152,7 @@ mod tests { use ff::Field; use generic_array::typenum; - use paired::bls12_381::Fr; + use bellperson::bls::Fr; use rand::SeedableRng; use rand_xorshift::XorShiftRng; diff --git a/storage-proofs/core/src/sector.rs b/storage-proofs/core/src/sector.rs index 26f63def1..3f9e0b64e 100644 --- a/storage-proofs/core/src/sector.rs +++ b/storage-proofs/core/src/sector.rs @@ -3,7 +3,7 @@ use std::fmt; use byteorder::ByteOrder; use ff::PrimeField; -use paired::bls12_381::{Fr, FrRepr}; +use bellperson::bls::{Fr, FrRepr}; use serde::{Deserialize, Serialize}; /// An ordered set of `SectorId`s. diff --git a/storage-proofs/core/src/util.rs b/storage-proofs/core/src/util.rs index 94cabac00..41b75f758 100644 --- a/storage-proofs/core/src/util.rs +++ b/storage-proofs/core/src/util.rs @@ -1,9 +1,8 @@ use crate::error; use anyhow::ensure; use bellperson::gadgets::boolean::{self, AllocatedBit, Boolean}; -use bellperson::{ConstraintSystem, SynthesisError}; +use bellperson::{ConstraintSystem, SynthesisError, bls::Engine}; use merkletree::merkle::get_merkle_tree_row_count; -use paired::Engine; use super::settings; @@ -183,7 +182,7 @@ mod tests { use bellperson::gadgets::num; use bellperson::util_cs::test_cs::TestConstraintSystem; use ff::Field; - use paired::bls12_381::*; + use bellperson::bls::*; use rand::{Rng, SeedableRng}; use rand_xorshift::XorShiftRng; From 5385ce7abec788bb0c58613379f120891972c779 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Thu, 24 Sep 2020 21:46:11 +0200 Subject: [PATCH 03/20] storage-proofs-core compiles --- fil-proofs-tooling/Cargo.toml | 5 +++-- filecoin-proofs/Cargo.toml | 6 ++++-- storage-proofs/Cargo.toml | 5 +++-- storage-proofs/core/Cargo.toml | 4 ++-- storage-proofs/core/src/compound_proof.rs | 5 +++-- storage-proofs/porep/Cargo.toml | 8 +++++--- storage-proofs/post/Cargo.toml | 9 +++++++-- 7 files changed, 27 insertions(+), 15 deletions(-) diff --git a/fil-proofs-tooling/Cargo.toml b/fil-proofs-tooling/Cargo.toml index 63f259999..b92f4547d 100644 --- a/fil-proofs-tooling/Cargo.toml +++ b/fil-proofs-tooling/Cargo.toml @@ -20,7 +20,7 @@ regex = "1.3.7" commandspec = "0.12.2" chrono = { version = "0.4.7", features = ["serde"] } memmap = "0.7.0" -bellperson = "0.9.1" +bellperson = { git = "https://github.com/filecoin-project/bellman", branch = "blstrs", default-features = false } paired = "0.20.0" rand = "0.7" storage-proofs = { path = "../storage-proofs"} @@ -51,7 +51,8 @@ default = ["gpu", "measurements"] gpu = ["storage-proofs/gpu", "filecoin-proofs/gpu", "bellperson/gpu"] measurements = ["storage-proofs/measurements"] profile = ["storage-proofs/profile", "measurements"] - +pairing = ["storage-proofs/pairing", "filecoin-proofs/pairing", "bellperson/pairing"] +blst = ["storage-proofs/blst", "filecoin-proofs/blst", "bellperson/blst"] [target.'cfg(target_arch = "x86_64")'.dependencies] raw-cpuid = "7.0.3" diff --git a/filecoin-proofs/Cargo.toml b/filecoin-proofs/Cargo.toml index 9a88df9d9..c273cd398 100644 --- a/filecoin-proofs/Cargo.toml +++ b/filecoin-proofs/Cargo.toml @@ -23,7 +23,7 @@ serde_json = "1.0" regex = "1.3.7" ff = { version = "0.2.3", package = "fff" } blake2b_simd = "0.5" -bellperson = "0.9.1" +bellperson = { git = "https://github.com/filecoin-project/bellman", branch = "blstrs", default-features = false } paired = "0.20.0" clap = "2" log = "0.4.7" @@ -65,12 +65,14 @@ failure = "0.1.7" tempfile = "3" [features] -default = ["gpu"] +default = ["gpu", "pairing"] cpu-profile = ["gperftools"] heap-profile = ["gperftools/heap"] simd = ["storage-proofs/simd"] asm = ["storage-proofs/asm"] gpu = ["storage-proofs/gpu", "bellperson/gpu"] +pairing = ["storage-proofs/pairing", "bellperson/pairing"] +blst = ["storage-proofs/blst", "bellperson/blst"] [[bench]] name = "preprocessing" diff --git a/storage-proofs/Cargo.toml b/storage-proofs/Cargo.toml index 22de6d12a..8a666d5e0 100644 --- a/storage-proofs/Cargo.toml +++ b/storage-proofs/Cargo.toml @@ -14,11 +14,12 @@ storage-proofs-post = { path = "./post", version = "^5.0.0"} storage-proofs-porep = { path = "./porep", version = "^5.0.0"} [features] -default = ["gpu"] +default = ["gpu", "pairing"] simd = ["storage-proofs-core/simd"] asm = ["storage-proofs-core/asm"] gpu = ["storage-proofs-core/gpu"] measurements = ["storage-proofs-core/measurements"] profile = ["measurements"] - +pairing = ["storage-proofs-core/pairing", "storage-proofs-post/pairing", "storage-proofs-porep/pairing"] +blst = ["storage-proofs-core/blst", "storage-proofs-post/blst", "storage-proofs-porep/blst"] diff --git a/storage-proofs/core/Cargo.toml b/storage-proofs/core/Cargo.toml index 59dd1455b..865a390c8 100644 --- a/storage-proofs/core/Cargo.toml +++ b/storage-proofs/core/Cargo.toml @@ -60,8 +60,8 @@ big-sector-sizes-bench = [] gpu = ["bellperson/gpu"] measurements = ["cpu-time", "gperftools"] profile = ["measurements"] -pairing = ["bellperson/pairing", "fil-sapling-crypto/pairing", "neptune/pairing"] -blst = ["bellperson/blst", "fil-sapling-crypto/blst", "neptune/blst"] +pairing = ["bellperson/pairing", "fil-sapling-crypto/pairing", "neptune/pairing", "bellperson/pairing-serde"] +blst = ["bellperson/blst", "fil-sapling-crypto/blst", "neptune/blst", "bellperson/blst-serde"] [[bench]] name = "sha256" diff --git a/storage-proofs/core/src/compound_proof.rs b/storage-proofs/core/src/compound_proof.rs index a184c3a3c..1b60aef7d 100644 --- a/storage-proofs/core/src/compound_proof.rs +++ b/storage-proofs/core/src/compound_proof.rs @@ -191,10 +191,11 @@ where .map(|k| Self::generate_public_inputs(public_inputs, vanilla_public_params, Some(k))) .collect::>()?; - let blst_inputs: Vec<_> = inputs + + let blst_inputs: Vec<_> = todo!();/*inputs .iter() .flat_map(|pis| pis.iter().map(|pi| blst_fr_from_fr(*pi))) - .collect(); + .collect();*/ // choose random coefficients for combining the proofs let mut r: Vec = Vec::with_capacity(num_proofs); diff --git a/storage-proofs/porep/Cargo.toml b/storage-proofs/porep/Cargo.toml index 425e76ba3..23a7a034a 100644 --- a/storage-proofs/porep/Cargo.toml +++ b/storage-proofs/porep/Cargo.toml @@ -23,13 +23,13 @@ rayon = "1.0.0" serde = { version = "1.0", features = ["derive"]} serde_json = "1.0" ff = { version = "0.2.3", package = "fff" } -bellperson = "0.9.1" +bellperson = { git = "https://github.com/filecoin-project/bellman", branch = "blstrs", default-features = false } paired = { version = "0.20.0", features = ["serde"] } log = "0.4.7" pretty_assertions = "0.6.1" generic-array = "0.13.2" anyhow = "1.0.23" -neptune = { version = "=1.2.1", features = ["gpu"] } +neptune = { git = "https://github.com/filecoin-project/neptune", branch = "blst", default-features = false, features = ["gpu"] } num_cpus = "1.10.1" hex = "0.4.2" bincode = "1.1.2" @@ -47,7 +47,9 @@ glob = "0.3.0" pretty_env_logger = "0.4.0" [features] -default = [] +default = ["pairing"] +pairing = ["storage-proofs-core/pairing", "bellperson/pairing", "fil-sapling-crypto/pairing"] +blst = ["storage-proofs-core/blst", "bellperson/blst", "fil-sapling-crypto/blst"] [[bench]] name = "encode" diff --git a/storage-proofs/post/Cargo.toml b/storage-proofs/post/Cargo.toml index 334f2b4e1..a12c55719 100644 --- a/storage-proofs/post/Cargo.toml +++ b/storage-proofs/post/Cargo.toml @@ -20,16 +20,21 @@ serde = { version = "1.0", features = ["derive"]} blake2b_simd = "0.5" blake2s_simd = "0.5" ff = { version = "0.2.3", package = "fff" } -bellperson = "0.9.1" +bellperson = { git = "https://github.com/filecoin-project/bellman", branch = "blstrs", default-features = false } paired = { version = "0.20.0", features = ["serde"] } log = "0.4.7" hex = "0.4.0" generic-array = "0.13.2" anyhow = "1.0.23" -neptune = { version = "=1.2.1", features = ["gpu"] } +neptune = { git = "https://github.com/filecoin-project/neptune", branch = "blst", default-features = false, features = ["gpu"] } num_cpus = "1.10.1" [dev-dependencies] tempfile = "3" pretty_assertions = "0.6.1" rand_xorshift = "0.2.0" + +[features] +default = ["pairing"] +pairing = ["storage-proofs-core/pairing", "bellperson/pairing", "fil-sapling-crypto/pairing"] +blst = ["storage-proofs-core/blst", "bellperson/blst", "fil-sapling-crypto/blst"] \ No newline at end of file From d8dedc3a94b998aaa52cac4b8d85725eb5179344 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Thu, 24 Sep 2020 22:10:59 +0200 Subject: [PATCH 04/20] use updated phase2 --- filecoin-proofs/Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/filecoin-proofs/Cargo.toml b/filecoin-proofs/Cargo.toml index c273cd398..3ff76e640 100644 --- a/filecoin-proofs/Cargo.toml +++ b/filecoin-proofs/Cargo.toml @@ -42,7 +42,7 @@ sha2 = "0.9.1" typenum = "1.11.2" bitintr = "0.3.0" gperftools = { version = "0.2", optional = true } -phase2 = { version = "0.8.0", package = "phase21" } +phase2 = { git = "https://github.com/filecoin-project/phase2", branch = "blst", package = "phase21", default-features = false } simplelog = "0.8.0" rand_chacha = "0.2.1" dialoguer = "0.6.2" @@ -71,8 +71,8 @@ heap-profile = ["gperftools/heap"] simd = ["storage-proofs/simd"] asm = ["storage-proofs/asm"] gpu = ["storage-proofs/gpu", "bellperson/gpu"] -pairing = ["storage-proofs/pairing", "bellperson/pairing"] -blst = ["storage-proofs/blst", "bellperson/blst"] +pairing = ["storage-proofs/pairing", "bellperson/pairing", "phase2/pairing"] +blst = ["storage-proofs/blst", "bellperson/blst", "phase2/blst"] [[bench]] name = "preprocessing" From 3d5e373ae89462720c7205251f1e574343c79bb2 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Thu, 24 Sep 2020 22:49:07 +0200 Subject: [PATCH 05/20] commit things --- storage-proofs/core/benches/blake2s.rs | 2 +- storage-proofs/core/benches/fr.rs | 2 +- storage-proofs/core/benches/sha256.rs | 2 +- storage-proofs/core/benches/xor.rs | 2 +- storage-proofs/core/src/compound_proof.rs | 11 +++++------ storage-proofs/core/src/crypto/sloth.rs | 4 ++-- storage-proofs/core/src/fr32.rs | 19 ++++++++++++++++++- storage-proofs/core/src/gadgets/constraint.rs | 4 ++-- storage-proofs/core/src/gadgets/encode.rs | 2 +- storage-proofs/core/src/gadgets/insertion.rs | 4 ++-- storage-proofs/core/src/gadgets/por.rs | 2 +- storage-proofs/core/src/gadgets/uint64.rs | 2 +- storage-proofs/core/src/gadgets/variables.rs | 2 +- storage-proofs/core/src/gadgets/xor.rs | 2 +- storage-proofs/core/src/hasher/blake2s.rs | 2 +- storage-proofs/core/src/hasher/poseidon.rs | 2 +- storage-proofs/core/src/hasher/sha256.rs | 4 ++-- storage-proofs/core/src/hasher/types.rs | 2 +- storage-proofs/core/src/merkle/proof.rs | 2 +- storage-proofs/core/src/parameter_cache.rs | 2 +- storage-proofs/core/src/por.rs | 2 +- storage-proofs/core/src/sector.rs | 2 +- storage-proofs/core/src/util.rs | 4 ++-- 23 files changed, 49 insertions(+), 33 deletions(-) diff --git a/storage-proofs/core/benches/blake2s.rs b/storage-proofs/core/benches/blake2s.rs index 36cf7c325..de14ba8e9 100644 --- a/storage-proofs/core/benches/blake2s.rs +++ b/storage-proofs/core/benches/blake2s.rs @@ -1,9 +1,9 @@ +use bellperson::bls::Bls12; use bellperson::gadgets::boolean::{self, Boolean}; use bellperson::groth16::*; use bellperson::util_cs::bench_cs::BenchCS; use bellperson::{Circuit, ConstraintSystem, SynthesisError}; use criterion::{black_box, criterion_group, criterion_main, Criterion, ParameterizedBenchmark}; -use bellperson::bls::Bls12; use rand::{thread_rng, Rng}; struct Blake2sExample<'a> { diff --git a/storage-proofs/core/benches/fr.rs b/storage-proofs/core/benches/fr.rs index aaf71fa4f..0f30f8554 100644 --- a/storage-proofs/core/benches/fr.rs +++ b/storage-proofs/core/benches/fr.rs @@ -1,6 +1,6 @@ +use bellperson::bls::Fr; use criterion::{black_box, criterion_group, criterion_main, Criterion}; use ff::Field; -use bellperson::bls::Fr; use rand::thread_rng; use storage_proofs_core::fr32::{bytes_into_fr, fr_into_bytes}; diff --git a/storage-proofs/core/benches/sha256.rs b/storage-proofs/core/benches/sha256.rs index e5137755e..4b7f10c2e 100644 --- a/storage-proofs/core/benches/sha256.rs +++ b/storage-proofs/core/benches/sha256.rs @@ -1,3 +1,4 @@ +use bellperson::bls::Bls12; use bellperson::gadgets::boolean::{self, Boolean}; use bellperson::groth16::*; use bellperson::util_cs::bench_cs::BenchCS; @@ -5,7 +6,6 @@ use bellperson::{Circuit, ConstraintSystem, SynthesisError}; use criterion::{ black_box, criterion_group, criterion_main, Criterion, ParameterizedBenchmark, Throughput, }; -use bellperson::bls::Bls12; use rand::{thread_rng, Rng}; use sha2::{Digest, Sha256}; diff --git a/storage-proofs/core/benches/xor.rs b/storage-proofs/core/benches/xor.rs index a0fe0fee9..f3fbd785c 100644 --- a/storage-proofs/core/benches/xor.rs +++ b/storage-proofs/core/benches/xor.rs @@ -1,9 +1,9 @@ +use bellperson::bls::Bls12; use bellperson::gadgets::boolean::{self, Boolean}; use bellperson::groth16::*; use bellperson::util_cs::bench_cs::BenchCS; use bellperson::{Circuit, ConstraintSystem, SynthesisError}; use criterion::{black_box, criterion_group, criterion_main, Criterion, ParameterizedBenchmark}; -use bellperson::bls::Bls12; use rand::{thread_rng, Rng}; use storage_proofs_core::crypto::xor; use storage_proofs_core::gadgets; diff --git a/storage-proofs/core/src/compound_proof.rs b/storage-proofs/core/src/compound_proof.rs index 1b60aef7d..fc3766b8a 100644 --- a/storage-proofs/core/src/compound_proof.rs +++ b/storage-proofs/core/src/compound_proof.rs @@ -1,10 +1,10 @@ use std::path::Path; use anyhow::{ensure, Context}; +use bellperson::bls::{Bls12, Fr}; use bellperson::{groth16, Circuit}; use fil_blst::{blst::blst_scalar, blst_fr_from_fr, scalar_from_u64, verify_batch_proof}; use log::info; -use bellperson::bls::{Bls12, Fr}; use rand::{rngs::OsRng, RngCore}; use rayon::prelude::*; @@ -191,11 +191,10 @@ where .map(|k| Self::generate_public_inputs(public_inputs, vanilla_public_params, Some(k))) .collect::>()?; - - let blst_inputs: Vec<_> = todo!();/*inputs - .iter() - .flat_map(|pis| pis.iter().map(|pi| blst_fr_from_fr(*pi))) - .collect();*/ + let blst_inputs: Vec<_> = todo!(); /*inputs + .iter() + .flat_map(|pis| pis.iter().map(|pi| blst_fr_from_fr(*pi))) + .collect();*/ // choose random coefficients for combining the proofs let mut r: Vec = Vec::with_capacity(num_proofs); diff --git a/storage-proofs/core/src/crypto/sloth.rs b/storage-proofs/core/src/crypto/sloth.rs index d6d672337..bea2dd2e3 100644 --- a/storage-proofs/core/src/crypto/sloth.rs +++ b/storage-proofs/core/src/crypto/sloth.rs @@ -1,5 +1,5 @@ -use ff::Field; use bellperson::bls::Fr; +use ff::Field; /// Sloth based encoding. #[inline] @@ -23,8 +23,8 @@ pub fn decode(key: &Fr, ciphertext: &Fr) -> Fr { #[cfg(test)] mod tests { use super::*; - use ff::PrimeField; use bellperson::bls::{Fr, FrRepr}; + use ff::PrimeField; use proptest::{prop_compose, proptest}; // the modulus from `bls12_381::Fr` diff --git a/storage-proofs/core/src/fr32.rs b/storage-proofs/core/src/fr32.rs index feb00eb3d..a9481eba1 100644 --- a/storage-proofs/core/src/fr32.rs +++ b/storage-proofs/core/src/fr32.rs @@ -1,9 +1,9 @@ use crate::error::*; use anyhow::{ensure, Context}; +use bellperson::bls::{Fr, FrRepr}; use byteorder::{ByteOrder, LittleEndian, WriteBytesExt}; use ff::{PrimeField, PrimeFieldRepr}; -use bellperson::bls::{Fr, FrRepr}; // Contains 32 bytes whose little-endian value represents an Fr. // Invariants: @@ -25,6 +25,7 @@ pub type Fr32Ary = [u8; 32]; // Takes a slice of bytes and returns an Fr if byte slice is exactly 32 bytes and does not overflow. // Otherwise, returns a BadFrBytesError. +#[cfg(feature = "pairing")] pub fn bytes_into_fr(bytes: &[u8]) -> Result { ensure!(bytes.len() == 32, Error::BadFrBytes); @@ -34,6 +35,14 @@ pub fn bytes_into_fr(bytes: &[u8]) -> Result { Fr::from_repr(fr_repr).map_err(|_| Error::BadFrBytes.into()) } +#[cfg(feature = "blst")] +pub fn bytes_into_fr(bytes: &[u8]) -> Result { + use std::convert::TryInto; + + Fr::from_bytes_le(bytes.try_into().map_err(|_| Error::BadFrBytes)?) + .ok_or_else(|| Error::BadFrBytes.into()) +} + #[inline] pub fn trim_bytes_to_fr_safe(r: &[u8]) -> Result> { ensure!(r.len() == 32, Error::BadFrBytes); @@ -65,12 +74,20 @@ pub fn bytes_into_fr_repr_safe(r: &[u8]) -> FrRepr { } // Takes an Fr and returns a vector of exactly 32 bytes guaranteed to contain a valid Fr. +#[cfg(feature = "pairing")] pub fn fr_into_bytes(fr: &Fr) -> Fr32Vec { let mut out = Vec::with_capacity(32); fr.into_repr().write_le(&mut out).expect("write_le failure"); out } +#[cfg(feature = "blst")] +pub fn fr_into_bytes(fr: &Fr) -> Fr32Vec { + use std::convert::TryInto; + + fr.to_bytes_le().to_vec() +} + // Takes a slice of bytes and returns a vector of Fr -- or an error if either bytes is not a multiple of 32 bytes // or any 32-byte chunk overflows and does not contain a valid Fr. pub fn bytes_into_frs(bytes: &[u8]) -> Result> { diff --git a/storage-proofs/core/src/gadgets/constraint.rs b/storage-proofs/core/src/gadgets/constraint.rs index 9d16251e3..bffc86f14 100644 --- a/storage-proofs/core/src/gadgets/constraint.rs +++ b/storage-proofs/core/src/gadgets/constraint.rs @@ -1,4 +1,4 @@ -use bellperson::{gadgets::num, ConstraintSystem, SynthesisError, bls::Engine}; +use bellperson::{bls::Engine, gadgets::num, ConstraintSystem, SynthesisError}; use ff::Field; /// Adds a constraint to CS, enforcing an equality relationship between the allocated numbers a and b. @@ -118,8 +118,8 @@ pub fn difference>( mod tests { use super::*; - use bellperson::util_cs::test_cs::TestConstraintSystem; use bellperson::bls::{Bls12, Fr}; + use bellperson::util_cs::test_cs::TestConstraintSystem; use rand::SeedableRng; use rand_xorshift::XorShiftRng; diff --git a/storage-proofs/core/src/gadgets/encode.rs b/storage-proofs/core/src/gadgets/encode.rs index a4421b7d5..f5d14bd15 100644 --- a/storage-proofs/core/src/gadgets/encode.rs +++ b/storage-proofs/core/src/gadgets/encode.rs @@ -1,5 +1,5 @@ use bellperson::gadgets::num; -use bellperson::{ConstraintSystem, SynthesisError, bls::Engine}; +use bellperson::{bls::Engine, ConstraintSystem, SynthesisError}; use crate::gadgets::constraint; diff --git a/storage-proofs/core/src/gadgets/insertion.rs b/storage-proofs/core/src/gadgets/insertion.rs index 7cde5a5ea..ad1236cc3 100644 --- a/storage-proofs/core/src/gadgets/insertion.rs +++ b/storage-proofs/core/src/gadgets/insertion.rs @@ -5,7 +5,7 @@ use bellperson::gadgets::boolean::{AllocatedBit, Boolean}; use bellperson::gadgets::num::AllocatedNum; -use bellperson::{ConstraintSystem, SynthesisError, bls::Engine}; +use bellperson::{bls::Engine, ConstraintSystem, SynthesisError}; use ff::Field; /// Insert `element` after the nth 1-indexed element of `elements`, where `path_bits` represents n, least-significant bit first. @@ -348,10 +348,10 @@ where mod tests { use super::*; + use bellperson::bls::{Bls12, Fr}; use bellperson::gadgets::boolean::AllocatedBit; use bellperson::util_cs::test_cs::TestConstraintSystem; use ff::Field; - use bellperson::bls::{Bls12, Fr}; use rand::SeedableRng; use rand_xorshift::XorShiftRng; diff --git a/storage-proofs/core/src/gadgets/por.rs b/storage-proofs/core/src/gadgets/por.rs index f7e21cbfb..22984a124 100644 --- a/storage-proofs/core/src/gadgets/por.rs +++ b/storage-proofs/core/src/gadgets/por.rs @@ -2,12 +2,12 @@ use std::convert::TryFrom; use std::marker::PhantomData; use anyhow::ensure; +use bellperson::bls::{Bls12, Fr, FrRepr}; use bellperson::gadgets::boolean::{AllocatedBit, Boolean}; use bellperson::gadgets::{multipack, num}; use bellperson::{Circuit, ConstraintSystem, SynthesisError}; use ff::PrimeField; use generic_array::typenum::Unsigned; -use bellperson::bls::{Bls12, Fr, FrRepr}; use crate::compound_proof::{CircuitComponent, CompoundProof}; use crate::error::Result; diff --git a/storage-proofs/core/src/gadgets/uint64.rs b/storage-proofs/core/src/gadgets/uint64.rs index 62b5ef532..34c288ac6 100644 --- a/storage-proofs/core/src/gadgets/uint64.rs +++ b/storage-proofs/core/src/gadgets/uint64.rs @@ -1,6 +1,6 @@ use bellperson::gadgets::boolean::{AllocatedBit, Boolean}; use bellperson::gadgets::multipack::pack_into_inputs; -use bellperson::{ConstraintSystem, SynthesisError, bls::Engine}; +use bellperson::{bls::Engine, ConstraintSystem, SynthesisError}; /// Represents an interpretation of 64 `Boolean` objects as an unsigned integer. #[derive(Clone)] diff --git a/storage-proofs/core/src/gadgets/variables.rs b/storage-proofs/core/src/gadgets/variables.rs index 3621f049e..2e0e31a97 100644 --- a/storage-proofs/core/src/gadgets/variables.rs +++ b/storage-proofs/core/src/gadgets/variables.rs @@ -3,7 +3,7 @@ use std::fmt; use anyhow::Result; use bellperson::gadgets::num::AllocatedNum; -use bellperson::{ConstraintSystem, SynthesisError, bls::Engine}; +use bellperson::{bls::Engine, ConstraintSystem, SynthesisError}; /// Root represents a root commitment which may be either a raw value or an already-allocated number. /// This allows subcomponents to depend on roots which may optionally be shared with their parent diff --git a/storage-proofs/core/src/gadgets/xor.rs b/storage-proofs/core/src/gadgets/xor.rs index 2684de7e2..513549551 100644 --- a/storage-proofs/core/src/gadgets/xor.rs +++ b/storage-proofs/core/src/gadgets/xor.rs @@ -35,7 +35,7 @@ mod tests { use crate::util::{bits_to_bytes, bytes_into_boolean_vec}; use bellperson::gadgets::boolean::Boolean; use bellperson::util_cs::test_cs::TestConstraintSystem; - use bellperson::{ConstraintSystem, bls::Bls12}; + use bellperson::{bls::Bls12, ConstraintSystem}; use rand::{Rng, SeedableRng}; use rand_xorshift::XorShiftRng; diff --git a/storage-proofs/core/src/hasher/blake2s.rs b/storage-proofs/core/src/hasher/blake2s.rs index 9a621e5c7..74e52644c 100644 --- a/storage-proofs/core/src/hasher/blake2s.rs +++ b/storage-proofs/core/src/hasher/blake2s.rs @@ -2,13 +2,13 @@ use std::fmt; use std::hash::Hasher as StdHasher; use anyhow::ensure; +use bellperson::bls::{Bls12, Fr, FrRepr}; use bellperson::gadgets::{blake2s as blake2s_circuit, boolean, num}; use bellperson::{ConstraintSystem, SynthesisError}; use blake2s_simd::{Hash as Blake2sHash, Params as Blake2s, State}; use ff::{Field, PrimeField, PrimeFieldRepr}; use merkletree::hash::{Algorithm, Hashable}; use merkletree::merkle::Element; -use bellperson::bls::{Bls12, Fr, FrRepr}; use rand::RngCore; use serde::{Deserialize, Serialize}; diff --git a/storage-proofs/core/src/hasher/poseidon.rs b/storage-proofs/core/src/hasher/poseidon.rs index 013811309..b71c235a9 100644 --- a/storage-proofs/core/src/hasher/poseidon.rs +++ b/storage-proofs/core/src/hasher/poseidon.rs @@ -8,6 +8,7 @@ use crate::hasher::types::{ }; use crate::hasher::{Domain, HashFunction, Hasher}; use anyhow::ensure; +use bellperson::bls::{Bls12, Fr, FrRepr}; use bellperson::gadgets::{boolean, num}; use bellperson::{ConstraintSystem, SynthesisError}; use ff::{Field, PrimeField, PrimeFieldRepr, ScalarEngine}; @@ -17,7 +18,6 @@ use merkletree::hash::{Algorithm as LightAlgorithm, Hashable}; use merkletree::merkle::Element; use neptune::circuit::poseidon_hash; use neptune::poseidon::Poseidon; -use bellperson::bls::{Bls12, Fr, FrRepr}; use serde::{Deserialize, Serialize}; #[derive(Default, Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] diff --git a/storage-proofs/core/src/hasher/sha256.rs b/storage-proofs/core/src/hasher/sha256.rs index 229f30025..85a36dec7 100644 --- a/storage-proofs/core/src/hasher/sha256.rs +++ b/storage-proofs/core/src/hasher/sha256.rs @@ -1,12 +1,12 @@ use std::hash::Hasher as StdHasher; use anyhow::ensure; +use bellperson::bls::{Bls12, Fr, FrRepr}; use bellperson::gadgets::{boolean, num, sha256::sha256 as sha256_circuit}; use bellperson::{ConstraintSystem, SynthesisError}; use ff::{Field, PrimeField, PrimeFieldRepr}; use merkletree::hash::{Algorithm, Hashable}; use merkletree::merkle::Element; -use bellperson::bls::{Bls12, Fr, FrRepr}; use rand::RngCore; use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; @@ -356,11 +356,11 @@ mod tests { use crate::util::bytes_into_boolean_vec; use bellperson::util_cs::test_cs::TestConstraintSystem; + use bellperson::bls::{Bls12, Fr}; use bellperson::gadgets::boolean::Boolean; use bellperson::ConstraintSystem; use ff::Field; use merkletree::hash::Algorithm; - use bellperson::bls::{Bls12, Fr}; use rand::SeedableRng; use rand_xorshift::XorShiftRng; diff --git a/storage-proofs/core/src/hasher/types.rs b/storage-proofs/core/src/hasher/types.rs index 0f3823bd1..aae9f204c 100644 --- a/storage-proofs/core/src/hasher/types.rs +++ b/storage-proofs/core/src/hasher/types.rs @@ -1,3 +1,4 @@ +use bellperson::bls::{Bls12, Fr, FrRepr}; use bellperson::gadgets::{boolean, num}; use bellperson::{ConstraintSystem, SynthesisError}; use generic_array::typenum::{U0, U11, U16, U2, U24, U36, U4, U8}; @@ -5,7 +6,6 @@ use lazy_static::lazy_static; use merkletree::hash::{Algorithm as LightAlgorithm, Hashable as LightHashable}; use merkletree::merkle::Element; use neptune::poseidon::PoseidonConstants; -use bellperson::bls::{Bls12, Fr, FrRepr}; use serde::de::DeserializeOwned; use serde::ser::Serialize; diff --git a/storage-proofs/core/src/merkle/proof.rs b/storage-proofs/core/src/merkle/proof.rs index 2742e674e..5db3cd391 100644 --- a/storage-proofs/core/src/merkle/proof.rs +++ b/storage-proofs/core/src/merkle/proof.rs @@ -3,10 +3,10 @@ use std::marker::PhantomData; use anyhow::{ensure, Result}; +use bellperson::bls::Fr; use generic_array::typenum::{Unsigned, U0}; use merkletree::hash::Algorithm; use merkletree::proof; -use bellperson::bls::Fr; use serde::{Deserialize, Serialize}; use crate::drgraph::graph_height; diff --git a/storage-proofs/core/src/parameter_cache.rs b/storage-proofs/core/src/parameter_cache.rs index 4b9e7b2af..603ef1a11 100644 --- a/storage-proofs/core/src/parameter_cache.rs +++ b/storage-proofs/core/src/parameter_cache.rs @@ -1,5 +1,6 @@ use crate::error::*; use anyhow::bail; +use bellperson::bls::Bls12; use bellperson::groth16::Parameters; use bellperson::{groth16, Circuit}; use blake2b_simd::Params as Blake2bParams; @@ -7,7 +8,6 @@ use fs2::FileExt; use itertools::Itertools; use lazy_static::lazy_static; use log::info; -use bellperson::bls::Bls12; use rand::RngCore; use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; diff --git a/storage-proofs/core/src/por.rs b/storage-proofs/core/src/por.rs index 89e1a23c3..a96f1227a 100644 --- a/storage-proofs/core/src/por.rs +++ b/storage-proofs/core/src/por.rs @@ -150,9 +150,9 @@ impl<'a, Tree: 'a + MerkleTreeTrait> ProofScheme<'a> for PoR { mod tests { use super::*; + use bellperson::bls::Fr; use ff::Field; use generic_array::typenum; - use bellperson::bls::Fr; use rand::SeedableRng; use rand_xorshift::XorShiftRng; diff --git a/storage-proofs/core/src/sector.rs b/storage-proofs/core/src/sector.rs index 3f9e0b64e..223214292 100644 --- a/storage-proofs/core/src/sector.rs +++ b/storage-proofs/core/src/sector.rs @@ -1,9 +1,9 @@ use std::collections::BTreeSet; use std::fmt; +use bellperson::bls::{Fr, FrRepr}; use byteorder::ByteOrder; use ff::PrimeField; -use bellperson::bls::{Fr, FrRepr}; use serde::{Deserialize, Serialize}; /// An ordered set of `SectorId`s. diff --git a/storage-proofs/core/src/util.rs b/storage-proofs/core/src/util.rs index 41b75f758..5940d2470 100644 --- a/storage-proofs/core/src/util.rs +++ b/storage-proofs/core/src/util.rs @@ -1,7 +1,7 @@ use crate::error; use anyhow::ensure; use bellperson::gadgets::boolean::{self, AllocatedBit, Boolean}; -use bellperson::{ConstraintSystem, SynthesisError, bls::Engine}; +use bellperson::{bls::Engine, ConstraintSystem, SynthesisError}; use merkletree::merkle::get_merkle_tree_row_count; use super::settings; @@ -179,10 +179,10 @@ mod tests { use super::*; use crate::fr32::fr_into_bytes; + use bellperson::bls::*; use bellperson::gadgets::num; use bellperson::util_cs::test_cs::TestConstraintSystem; use ff::Field; - use bellperson::bls::*; use rand::{Rng, SeedableRng}; use rand_xorshift::XorShiftRng; From 0a1970be0af71d070acdba3ad74639cd3ff222f0 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Fri, 25 Sep 2020 14:41:15 +0200 Subject: [PATCH 06/20] update imports --- fil-proofs-tooling/Cargo.toml | 1 - fil-proofs-tooling/src/bin/benchy/hash_fns.rs | 2 +- fil-proofs-tooling/src/bin/benchy/prodbench.rs | 2 +- fil-proofs-tooling/src/bin/check_parameters/main.rs | 2 +- filecoin-proofs/Cargo.toml | 1 - filecoin-proofs/src/api/mod.rs | 2 +- filecoin-proofs/src/api/seal.rs | 2 +- filecoin-proofs/src/api/util.rs | 2 +- filecoin-proofs/src/bin/phase2.rs | 2 +- filecoin-proofs/src/caches.rs | 2 +- filecoin-proofs/src/pieces.rs | 2 +- filecoin-proofs/tests/api.rs | 2 +- storage-proofs/core/Cargo.toml | 4 ++-- storage-proofs/porep/Cargo.toml | 5 ++--- storage-proofs/porep/benches/encode.rs | 2 +- storage-proofs/porep/src/drg/circuit.rs | 3 +-- storage-proofs/porep/src/drg/compound.rs | 2 +- storage-proofs/porep/src/drg/vanilla.rs | 2 +- storage-proofs/porep/src/encode.rs | 2 +- storage-proofs/porep/src/stacked/circuit/column.rs | 2 +- storage-proofs/porep/src/stacked/circuit/column_proof.rs | 2 +- storage-proofs/porep/src/stacked/circuit/create_label.rs | 2 +- storage-proofs/porep/src/stacked/circuit/hash.rs | 4 ++-- storage-proofs/porep/src/stacked/circuit/params.rs | 2 +- storage-proofs/porep/src/stacked/circuit/proof.rs | 2 +- storage-proofs/porep/src/stacked/vanilla/column.rs | 2 +- storage-proofs/porep/src/stacked/vanilla/column_proof.rs | 2 +- storage-proofs/porep/src/stacked/vanilla/encoding_proof.rs | 2 +- storage-proofs/porep/src/stacked/vanilla/hash.rs | 2 +- storage-proofs/porep/src/stacked/vanilla/proof.rs | 4 ++-- storage-proofs/post/Cargo.toml | 5 ++--- storage-proofs/post/src/election/circuit.rs | 4 ++-- storage-proofs/post/src/election/compound.rs | 2 +- storage-proofs/post/src/election/vanilla.rs | 2 +- storage-proofs/post/src/fallback/circuit.rs | 3 +-- storage-proofs/post/src/fallback/compound.rs | 2 +- storage-proofs/post/src/fallback/vanilla.rs | 2 +- storage-proofs/post/src/rational/circuit.rs | 4 ++-- storage-proofs/post/src/rational/compound.rs | 2 +- 39 files changed, 44 insertions(+), 50 deletions(-) diff --git a/fil-proofs-tooling/Cargo.toml b/fil-proofs-tooling/Cargo.toml index b92f4547d..3d823c6fd 100644 --- a/fil-proofs-tooling/Cargo.toml +++ b/fil-proofs-tooling/Cargo.toml @@ -21,7 +21,6 @@ commandspec = "0.12.2" chrono = { version = "0.4.7", features = ["serde"] } memmap = "0.7.0" bellperson = { git = "https://github.com/filecoin-project/bellman", branch = "blstrs", default-features = false } -paired = "0.20.0" rand = "0.7" storage-proofs = { path = "../storage-proofs"} filecoin-proofs = { path = "../filecoin-proofs"} diff --git a/fil-proofs-tooling/src/bin/benchy/hash_fns.rs b/fil-proofs-tooling/src/bin/benchy/hash_fns.rs index 06be36d2a..5fd21219f 100644 --- a/fil-proofs-tooling/src/bin/benchy/hash_fns.rs +++ b/fil-proofs-tooling/src/bin/benchy/hash_fns.rs @@ -2,7 +2,7 @@ use bellperson::gadgets::boolean::Boolean; use bellperson::util_cs::test_cs::TestConstraintSystem; use bellperson::ConstraintSystem; use fil_proofs_tooling::metadata::Metadata; -use paired::bls12_381::Bls12; +use bellperson::bls::Bls12; use rand::RngCore; use serde::Serialize; use storage_proofs::util::{bits_to_bytes, bytes_into_boolean_vec, bytes_into_boolean_vec_be}; diff --git a/fil-proofs-tooling/src/bin/benchy/prodbench.rs b/fil-proofs-tooling/src/bin/benchy/prodbench.rs index 3d5038467..542b643ab 100644 --- a/fil-proofs-tooling/src/bin/benchy/prodbench.rs +++ b/fil-proofs-tooling/src/bin/benchy/prodbench.rs @@ -11,7 +11,7 @@ use filecoin_proofs::{ validate_cache_for_commit, PoRepConfig, }; use log::info; -use paired::bls12_381::Bls12; +use bellperson::bls::Bls12; use rand::SeedableRng; use rand_xorshift::XorShiftRng; use serde::{Deserialize, Serialize}; diff --git a/fil-proofs-tooling/src/bin/check_parameters/main.rs b/fil-proofs-tooling/src/bin/check_parameters/main.rs index bd1ffb6ae..1c40bf4eb 100644 --- a/fil-proofs-tooling/src/bin/check_parameters/main.rs +++ b/fil-proofs-tooling/src/bin/check_parameters/main.rs @@ -3,7 +3,7 @@ use std::path::PathBuf; use anyhow::Result; use bellperson::groth16::MappedParameters; use clap::{value_t, App, Arg, SubCommand}; -use paired::bls12_381::Bls12; +use bellperson::bls::Bls12; use storage_proofs::parameter_cache::read_cached_params; diff --git a/filecoin-proofs/Cargo.toml b/filecoin-proofs/Cargo.toml index 3ff76e640..89972edc7 100644 --- a/filecoin-proofs/Cargo.toml +++ b/filecoin-proofs/Cargo.toml @@ -24,7 +24,6 @@ regex = "1.3.7" ff = { version = "0.2.3", package = "fff" } blake2b_simd = "0.5" bellperson = { git = "https://github.com/filecoin-project/bellman", branch = "blstrs", default-features = false } -paired = "0.20.0" clap = "2" log = "0.4.7" fil_logger = "0.1" diff --git a/filecoin-proofs/src/api/mod.rs b/filecoin-proofs/src/api/mod.rs index 53b545dae..bb96fcd2d 100644 --- a/filecoin-proofs/src/api/mod.rs +++ b/filecoin-proofs/src/api/mod.rs @@ -587,8 +587,8 @@ where mod tests { use super::*; + use bellperson::bls::Fr; use ff::Field; - use paired::bls12_381::Fr; use rand::SeedableRng; use rand_xorshift::XorShiftRng; use storage_proofs::fr32::bytes_into_fr; diff --git a/filecoin-proofs/src/api/seal.rs b/filecoin-proofs/src/api/seal.rs index 1a4a46969..de3197b06 100644 --- a/filecoin-proofs/src/api/seal.rs +++ b/filecoin-proofs/src/api/seal.rs @@ -3,11 +3,11 @@ use std::io::prelude::*; use std::path::{Path, PathBuf}; use anyhow::{ensure, Context, Result}; +use bellperson::bls::Fr; use bincode::{deserialize, serialize}; use log::{info, trace}; use memmap::MmapOptions; use merkletree::store::{DiskStore, Store, StoreConfig}; -use paired::bls12_381::Fr; use storage_proofs::cache_key::CacheKey; use storage_proofs::compound_proof::{self, CompoundProof}; use storage_proofs::drgraph::Graph; diff --git a/filecoin-proofs/src/api/util.rs b/filecoin-proofs/src/api/util.rs index e63914227..e310d3de4 100644 --- a/filecoin-proofs/src/api/util.rs +++ b/filecoin-proofs/src/api/util.rs @@ -1,6 +1,6 @@ use anyhow::{Context, Result}; +use bellperson::bls::Fr; use merkletree::merkle::{get_merkle_tree_leafs, get_merkle_tree_len}; -use paired::bls12_381::Fr; use storage_proofs::fr32::{bytes_into_fr, fr_into_bytes}; use storage_proofs::hasher::{Domain, Hasher}; use storage_proofs::merkle::{get_base_tree_count, MerkleTreeTrait}; diff --git a/filecoin-proofs/src/bin/phase2.rs b/filecoin-proofs/src/bin/phase2.rs index af3353cb2..5055c6cf3 100644 --- a/filecoin-proofs/src/bin/phase2.rs +++ b/filecoin-proofs/src/bin/phase2.rs @@ -9,6 +9,7 @@ use std::sync::mpsc::{channel, TryRecvError}; use std::thread::{self, JoinHandle}; use std::time::{Duration, Instant}; +use bellperson::bls::{Bls12, G1Affine, G1Uncompressed, G2Affine, G2Uncompressed}; use bellperson::groth16; use byteorder::{BigEndian, ReadBytesExt}; use clap::{App, AppSettings, Arg, ArgGroup, SubCommand}; @@ -22,7 +23,6 @@ use filecoin_proofs::types::{ use filecoin_proofs::with_shape; use groupy::{CurveAffine, EncodedPoint}; use log::{error, info, warn}; -use paired::bls12_381::{Bls12, G1Affine, G1Uncompressed, G2Affine, G2Uncompressed}; use phase2::small::{read_small_params_from_large_file, MPCSmall, Streamer}; use phase2::MPCParameters; use rand::rngs::OsRng; diff --git a/filecoin-proofs/src/caches.rs b/filecoin-proofs/src/caches.rs index e2698f6e8..fb76c0997 100644 --- a/filecoin-proofs/src/caches.rs +++ b/filecoin-proofs/src/caches.rs @@ -3,10 +3,10 @@ use std::sync::Arc; use std::sync::Mutex; use anyhow::Result; +use bellperson::bls::Bls12; use bellperson::groth16; use lazy_static::lazy_static; use log::info; -use paired::bls12_381::Bls12; use storage_proofs::compound_proof::CompoundProof; use storage_proofs::porep::stacked::{StackedCompound, StackedDrg}; use storage_proofs::post::fallback; diff --git a/filecoin-proofs/src/pieces.rs b/filecoin-proofs/src/pieces.rs index 5da6d03f9..a9bcb9c34 100644 --- a/filecoin-proofs/src/pieces.rs +++ b/filecoin-proofs/src/pieces.rs @@ -357,7 +357,7 @@ mod tests { use crate::constants::{DRG_DEGREE, EXP_DEGREE}; use crate::types::DataTree; - use paired::bls12_381::Fr; + use bellperson::bls::Fr; use rand::{Rng, RngCore, SeedableRng}; use rand_xorshift::XorShiftRng; use storage_proofs::drgraph::Graph; diff --git a/filecoin-proofs/tests/api.rs b/filecoin-proofs/tests/api.rs index e45adfb84..f317089f3 100644 --- a/filecoin-proofs/tests/api.rs +++ b/filecoin-proofs/tests/api.rs @@ -6,7 +6,7 @@ use std::sync::Once; use anyhow::Result; use ff::Field; -use paired::bls12_381::Fr; +use bellperson::bls::Fr; use rand::{Rng, SeedableRng}; use rand_xorshift::XorShiftRng; use storage_proofs::hasher::Hasher; diff --git a/storage-proofs/core/Cargo.toml b/storage-proofs/core/Cargo.toml index 865a390c8..b90e3fd0f 100644 --- a/storage-proofs/core/Cargo.toml +++ b/storage-proofs/core/Cargo.toml @@ -60,8 +60,8 @@ big-sector-sizes-bench = [] gpu = ["bellperson/gpu"] measurements = ["cpu-time", "gperftools"] profile = ["measurements"] -pairing = ["bellperson/pairing", "fil-sapling-crypto/pairing", "neptune/pairing", "bellperson/pairing-serde"] -blst = ["bellperson/blst", "fil-sapling-crypto/blst", "neptune/blst", "bellperson/blst-serde"] +pairing = ["bellperson/pairing", "neptune/pairing", "bellperson/pairing-serde"] +blst = ["bellperson/blst", "neptune/blst", "bellperson/blst-serde"] [[bench]] name = "sha256" diff --git a/storage-proofs/porep/Cargo.toml b/storage-proofs/porep/Cargo.toml index 23a7a034a..10db3a53d 100644 --- a/storage-proofs/porep/Cargo.toml +++ b/storage-proofs/porep/Cargo.toml @@ -24,7 +24,6 @@ serde = { version = "1.0", features = ["derive"]} serde_json = "1.0" ff = { version = "0.2.3", package = "fff" } bellperson = { git = "https://github.com/filecoin-project/bellman", branch = "blstrs", default-features = false } -paired = { version = "0.20.0", features = ["serde"] } log = "0.4.7" pretty_assertions = "0.6.1" generic-array = "0.13.2" @@ -48,8 +47,8 @@ pretty_env_logger = "0.4.0" [features] default = ["pairing"] -pairing = ["storage-proofs-core/pairing", "bellperson/pairing", "fil-sapling-crypto/pairing"] -blst = ["storage-proofs-core/blst", "bellperson/blst", "fil-sapling-crypto/blst"] +pairing = ["storage-proofs-core/pairing", "bellperson/pairing"] +blst = ["storage-proofs-core/blst", "bellperson/blst"] [[bench]] name = "encode" diff --git a/storage-proofs/porep/benches/encode.rs b/storage-proofs/porep/benches/encode.rs index dde844a5d..40c723805 100644 --- a/storage-proofs/porep/benches/encode.rs +++ b/storage-proofs/porep/benches/encode.rs @@ -1,6 +1,6 @@ +use bellperson::bls::Fr; use criterion::{black_box, criterion_group, criterion_main, Criterion, Throughput}; use ff::Field; -use paired::bls12_381::Fr; use rand::thread_rng; use storage_proofs_core::fr32::fr_into_bytes; use storage_proofs_core::hasher::sha256::Sha256Hasher; diff --git a/storage-proofs/porep/src/drg/circuit.rs b/storage-proofs/porep/src/drg/circuit.rs index bbc19dab3..a77fe9578 100644 --- a/storage-proofs/porep/src/drg/circuit.rs +++ b/storage-proofs/porep/src/drg/circuit.rs @@ -1,5 +1,6 @@ use std::marker::PhantomData; +use bellperson::bls::{Bls12, Engine, Fr}; use bellperson::gadgets::{ boolean::Boolean, sha256::sha256 as sha256_circuit, @@ -7,8 +8,6 @@ use bellperson::gadgets::{ }; use bellperson::{Circuit, ConstraintSystem, SynthesisError}; use ff::PrimeField; -use paired::bls12_381::{Bls12, Fr}; -use paired::Engine; use storage_proofs_core::{ compound_proof::CircuitComponent, error::Result, gadgets::constraint, gadgets::encode, diff --git a/storage-proofs/porep/src/drg/compound.rs b/storage-proofs/porep/src/drg/compound.rs index e9cf4ff89..1eead8b19 100644 --- a/storage-proofs/porep/src/drg/compound.rs +++ b/storage-proofs/porep/src/drg/compound.rs @@ -1,9 +1,9 @@ use std::marker::PhantomData; use anyhow::{ensure, Context}; +use bellperson::bls::{Bls12, Fr}; use bellperson::Circuit; use generic_array::typenum; -use paired::bls12_381::{Bls12, Fr}; use storage_proofs_core::{ compound_proof::{CircuitComponent, CompoundProof}, diff --git a/storage-proofs/porep/src/drg/vanilla.rs b/storage-proofs/porep/src/drg/vanilla.rs index 4d9f474d6..f89515974 100644 --- a/storage-proofs/porep/src/drg/vanilla.rs +++ b/storage-proofs/porep/src/drg/vanilla.rs @@ -607,8 +607,8 @@ pub fn replica_id(prover_id: [u8; 32], sector_id: [u8; 32]) -> H::Dom mod tests { use super::*; + use bellperson::bls::Fr; use ff::Field; - use paired::bls12_381::Fr; use rand::SeedableRng; use rand_xorshift::XorShiftRng; use storage_proofs_core::{ diff --git a/storage-proofs/porep/src/encode.rs b/storage-proofs/porep/src/encode.rs index ca3733e28..081983041 100644 --- a/storage-proofs/porep/src/encode.rs +++ b/storage-proofs/porep/src/encode.rs @@ -1,5 +1,5 @@ +use bellperson::bls::Fr; use ff::Field; -use paired::bls12_381::Fr; use storage_proofs_core::hasher::Domain; pub fn encode(key: T, value: T) -> T { diff --git a/storage-proofs/porep/src/stacked/circuit/column.rs b/storage-proofs/porep/src/stacked/circuit/column.rs index 6b5dabe0a..417bab73f 100644 --- a/storage-proofs/porep/src/stacked/circuit/column.rs +++ b/storage-proofs/porep/src/stacked/circuit/column.rs @@ -1,6 +1,6 @@ +use bellperson::bls::{Bls12, Fr}; use bellperson::gadgets::num; use bellperson::{ConstraintSystem, SynthesisError}; -use paired::bls12_381::{Bls12, Fr}; use storage_proofs_core::{hasher::Hasher, merkle::MerkleTreeTrait}; use super::hash::hash_single_column; diff --git a/storage-proofs/porep/src/stacked/circuit/column_proof.rs b/storage-proofs/porep/src/stacked/circuit/column_proof.rs index dc6c255df..258cef89e 100644 --- a/storage-proofs/porep/src/stacked/circuit/column_proof.rs +++ b/storage-proofs/porep/src/stacked/circuit/column_proof.rs @@ -1,5 +1,5 @@ +use bellperson::bls::Bls12; use bellperson::{ConstraintSystem, SynthesisError}; -use paired::bls12_381::Bls12; use storage_proofs_core::{ drgraph::Graph, gadgets::por::AuthPath, diff --git a/storage-proofs/porep/src/stacked/circuit/create_label.rs b/storage-proofs/porep/src/stacked/circuit/create_label.rs index e56206421..4ad0adaaf 100644 --- a/storage-proofs/porep/src/stacked/circuit/create_label.rs +++ b/storage-proofs/porep/src/stacked/circuit/create_label.rs @@ -68,10 +68,10 @@ where mod tests { use super::*; + use bellperson::bls::{Bls12, Fr}; use bellperson::gadgets::boolean::Boolean; use bellperson::util_cs::test_cs::TestConstraintSystem; use ff::Field; - use paired::bls12_381::{Bls12, Fr}; use rand::SeedableRng; use rand_xorshift::XorShiftRng; use storage_proofs_core::{ diff --git a/storage-proofs/porep/src/stacked/circuit/hash.rs b/storage-proofs/porep/src/stacked/circuit/hash.rs index cd0069333..20e4ff626 100644 --- a/storage-proofs/porep/src/stacked/circuit/hash.rs +++ b/storage-proofs/porep/src/stacked/circuit/hash.rs @@ -1,8 +1,8 @@ +use bellperson::bls::Bls12; use bellperson::gadgets::num; use bellperson::{ConstraintSystem, SynthesisError}; use generic_array::typenum; use neptune::circuit::poseidon_hash; -use paired::bls12_381::Bls12; /// Hash a list of bits. pub fn hash_single_column( @@ -31,10 +31,10 @@ where mod tests { use super::*; + use bellperson::bls::{Bls12, Fr}; use bellperson::util_cs::test_cs::TestConstraintSystem; use bellperson::ConstraintSystem; use ff::Field; - use paired::bls12_381::{Bls12, Fr}; use rand::SeedableRng; use rand_xorshift::XorShiftRng; use storage_proofs_core::hasher::{HashFunction, Hasher, PoseidonHasher}; diff --git a/storage-proofs/porep/src/stacked/circuit/params.rs b/storage-proofs/porep/src/stacked/circuit/params.rs index bd5f5de65..985bad3d1 100644 --- a/storage-proofs/porep/src/stacked/circuit/params.rs +++ b/storage-proofs/porep/src/stacked/circuit/params.rs @@ -1,9 +1,9 @@ use std::marker::PhantomData; +use bellperson::bls::{Bls12, Fr}; use bellperson::gadgets::{boolean::Boolean, num, uint32}; use bellperson::{ConstraintSystem, SynthesisError}; use generic_array::typenum::{U0, U2}; -use paired::bls12_381::{Bls12, Fr}; use storage_proofs_core::{ drgraph::Graph, gadgets::por::{AuthPath, PoRCircuit}, diff --git a/storage-proofs/porep/src/stacked/circuit/proof.rs b/storage-proofs/porep/src/stacked/circuit/proof.rs index aed1549d8..d9fbe4d5e 100644 --- a/storage-proofs/porep/src/stacked/circuit/proof.rs +++ b/storage-proofs/porep/src/stacked/circuit/proof.rs @@ -1,9 +1,9 @@ use std::marker::PhantomData; use anyhow::ensure; +use bellperson::bls::{Bls12, Fr}; use bellperson::gadgets::num; use bellperson::{Circuit, ConstraintSystem, SynthesisError}; -use paired::bls12_381::{Bls12, Fr}; use storage_proofs_core::{ compound_proof::{CircuitComponent, CompoundProof}, drgraph::Graph, diff --git a/storage-proofs/porep/src/stacked/vanilla/column.rs b/storage-proofs/porep/src/stacked/vanilla/column.rs index efdb1c545..73fb50b87 100644 --- a/storage-proofs/porep/src/stacked/vanilla/column.rs +++ b/storage-proofs/porep/src/stacked/vanilla/column.rs @@ -1,6 +1,6 @@ use std::marker::PhantomData; -use paired::bls12_381::Fr; +use bellperson::bls::Fr; use serde::{Deserialize, Serialize}; use storage_proofs_core::{ error::Result, diff --git a/storage-proofs/porep/src/stacked/vanilla/column_proof.rs b/storage-proofs/porep/src/stacked/vanilla/column_proof.rs index 17632a0b3..137da4d30 100644 --- a/storage-proofs/porep/src/stacked/vanilla/column_proof.rs +++ b/storage-proofs/porep/src/stacked/vanilla/column_proof.rs @@ -1,5 +1,5 @@ +use bellperson::bls::Fr; use log::trace; -use paired::bls12_381::Fr; use serde::{Deserialize, Serialize}; use storage_proofs_core::{error::Result, hasher::Hasher, merkle::MerkleProofTrait}; diff --git a/storage-proofs/porep/src/stacked/vanilla/encoding_proof.rs b/storage-proofs/porep/src/stacked/vanilla/encoding_proof.rs index fe48af650..e976a2b0b 100644 --- a/storage-proofs/porep/src/stacked/vanilla/encoding_proof.rs +++ b/storage-proofs/porep/src/stacked/vanilla/encoding_proof.rs @@ -1,7 +1,7 @@ use log::trace; use std::marker::PhantomData; -use paired::bls12_381::Fr; +use bellperson::bls::Fr; use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; use storage_proofs_core::{fr32::bytes_into_fr_repr_safe, hasher::Hasher}; diff --git a/storage-proofs/porep/src/stacked/vanilla/hash.rs b/storage-proofs/porep/src/stacked/vanilla/hash.rs index 37c0c4d6e..98d364cd7 100644 --- a/storage-proofs/porep/src/stacked/vanilla/hash.rs +++ b/storage-proofs/porep/src/stacked/vanilla/hash.rs @@ -1,5 +1,5 @@ +use bellperson::bls::Fr; use neptune::poseidon::Poseidon; -use paired::bls12_381::Fr; use storage_proofs_core::hasher::types::{POSEIDON_CONSTANTS_11, POSEIDON_CONSTANTS_2}; /// Hash all elements in the given column. diff --git a/storage-proofs/porep/src/stacked/vanilla/proof.rs b/storage-proofs/porep/src/stacked/vanilla/proof.rs index 618cbb054..1829380e7 100644 --- a/storage-proofs/porep/src/stacked/vanilla/proof.rs +++ b/storage-proofs/porep/src/stacked/vanilla/proof.rs @@ -5,6 +5,7 @@ use std::path::{Path, PathBuf}; use std::sync::{mpsc, Arc, RwLock}; use anyhow::Context; +use bellperson::bls::Fr; use bincode::deserialize; use generic_array::typenum::{self, Unsigned}; use log::*; @@ -13,7 +14,6 @@ use merkletree::merkle::{ is_merkle_tree_size_valid, }; use merkletree::store::{DiskStore, StoreConfig}; -use paired::bls12_381::Fr; use rayon::prelude::*; use storage_proofs_core::{ cache_key::CacheKey, @@ -1339,8 +1339,8 @@ impl<'a, Tree: 'static + MerkleTreeTrait, G: 'static + Hasher> StackedDrg<'a, Tr mod tests { use super::*; + use bellperson::bls::{Fr, FrRepr}; use ff::{Field, PrimeField}; - use paired::bls12_381::{Fr, FrRepr}; use rand::{Rng, SeedableRng}; use rand_xorshift::XorShiftRng; use storage_proofs_core::hasher::poseidon::PoseidonHasher; diff --git a/storage-proofs/post/Cargo.toml b/storage-proofs/post/Cargo.toml index a12c55719..b6d0fa920 100644 --- a/storage-proofs/post/Cargo.toml +++ b/storage-proofs/post/Cargo.toml @@ -21,7 +21,6 @@ blake2b_simd = "0.5" blake2s_simd = "0.5" ff = { version = "0.2.3", package = "fff" } bellperson = { git = "https://github.com/filecoin-project/bellman", branch = "blstrs", default-features = false } -paired = { version = "0.20.0", features = ["serde"] } log = "0.4.7" hex = "0.4.0" generic-array = "0.13.2" @@ -36,5 +35,5 @@ rand_xorshift = "0.2.0" [features] default = ["pairing"] -pairing = ["storage-proofs-core/pairing", "bellperson/pairing", "fil-sapling-crypto/pairing"] -blst = ["storage-proofs-core/blst", "bellperson/blst", "fil-sapling-crypto/blst"] \ No newline at end of file +pairing = ["storage-proofs-core/pairing", "bellperson/pairing"] +blst = ["storage-proofs-core/blst", "bellperson/blst"] \ No newline at end of file diff --git a/storage-proofs/post/src/election/circuit.rs b/storage-proofs/post/src/election/circuit.rs index ead924fa5..7a8dcee71 100644 --- a/storage-proofs/post/src/election/circuit.rs +++ b/storage-proofs/post/src/election/circuit.rs @@ -1,10 +1,10 @@ use std::marker::PhantomData; +use bellperson::bls::{Bls12, Fr}; use bellperson::gadgets::num; use bellperson::{Circuit, ConstraintSystem, SynthesisError}; use ff::Field; use generic_array::typenum; -use paired::bls12_381::{Bls12, Fr}; use typenum::marker_traits::Unsigned; use storage_proofs_core::{ @@ -178,9 +178,9 @@ mod tests { use std::collections::BTreeMap; + use bellperson::bls::{Bls12, Fr}; use bellperson::util_cs::test_cs::TestConstraintSystem; use ff::Field; - use paired::bls12_381::{Bls12, Fr}; use rand::SeedableRng; use rand_xorshift::XorShiftRng; use storage_proofs_core::{ diff --git a/storage-proofs/post/src/election/compound.rs b/storage-proofs/post/src/election/compound.rs index 31add334c..9171b3b43 100644 --- a/storage-proofs/post/src/election/compound.rs +++ b/storage-proofs/post/src/election/compound.rs @@ -1,8 +1,8 @@ use std::marker::PhantomData; +use bellperson::bls::{Bls12, Fr}; use bellperson::Circuit; use generic_array::typenum; -use paired::bls12_381::{Bls12, Fr}; use typenum::marker_traits::Unsigned; use storage_proofs_core::{ diff --git a/storage-proofs/post/src/election/vanilla.rs b/storage-proofs/post/src/election/vanilla.rs index 0a2198651..f75237d38 100644 --- a/storage-proofs/post/src/election/vanilla.rs +++ b/storage-proofs/post/src/election/vanilla.rs @@ -3,10 +3,10 @@ use std::fmt; use std::marker::PhantomData; use anyhow::{bail, ensure, Context}; +use bellperson::bls::Fr; use byteorder::{ByteOrder, LittleEndian}; use generic_array::typenum; use log::trace; -use paired::bls12_381::Fr; use rayon::prelude::*; use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; diff --git a/storage-proofs/post/src/fallback/circuit.rs b/storage-proofs/post/src/fallback/circuit.rs index 6ffd8932d..5068096ac 100644 --- a/storage-proofs/post/src/fallback/circuit.rs +++ b/storage-proofs/post/src/fallback/circuit.rs @@ -1,7 +1,7 @@ +use bellperson::bls::{Bls12, Fr}; use bellperson::gadgets::num; use bellperson::{Circuit, ConstraintSystem, SynthesisError}; use ff::Field; -use paired::bls12_381::{Bls12, Fr}; use rayon::prelude::*; use storage_proofs_core::{ @@ -218,7 +218,6 @@ mod tests { use bellperson::util_cs::test_cs::TestConstraintSystem; use ff::Field; use generic_array::typenum::{U0, U2, U4, U8}; - use paired::bls12_381::{Bls12, Fr}; use rand::SeedableRng; use rand_xorshift::XorShiftRng; use storage_proofs_core::{ diff --git a/storage-proofs/post/src/fallback/compound.rs b/storage-proofs/post/src/fallback/compound.rs index b74bd15a5..702318b79 100644 --- a/storage-proofs/post/src/fallback/compound.rs +++ b/storage-proofs/post/src/fallback/compound.rs @@ -1,8 +1,8 @@ use std::marker::PhantomData; use anyhow::{anyhow, ensure}; +use bellperson::bls::{Bls12, Fr}; use bellperson::Circuit; -use paired::bls12_381::{Bls12, Fr}; use storage_proofs_core::{ compound_proof::{CircuitComponent, CompoundProof}, diff --git a/storage-proofs/post/src/fallback/vanilla.rs b/storage-proofs/post/src/fallback/vanilla.rs index 9dcee21f0..e428fcce4 100644 --- a/storage-proofs/post/src/fallback/vanilla.rs +++ b/storage-proofs/post/src/fallback/vanilla.rs @@ -2,10 +2,10 @@ use std::collections::BTreeSet; use std::marker::PhantomData; use anyhow::ensure; +use bellperson::bls::Fr; use byteorder::{ByteOrder, LittleEndian}; use generic_array::typenum::Unsigned; use log::{error, trace}; -use paired::bls12_381::Fr; use rayon::prelude::*; use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; diff --git a/storage-proofs/post/src/rational/circuit.rs b/storage-proofs/post/src/rational/circuit.rs index adadc356f..d2b25df4e 100644 --- a/storage-proofs/post/src/rational/circuit.rs +++ b/storage-proofs/post/src/rational/circuit.rs @@ -1,8 +1,8 @@ use std::marker::PhantomData; +use bellperson::bls::{Bls12, Fr}; use bellperson::gadgets::num; use bellperson::{Circuit, ConstraintSystem, SynthesisError}; -use paired::bls12_381::{Bls12, Fr}; use storage_proofs_core::{ compound_proof::CircuitComponent, @@ -111,8 +111,8 @@ mod tests { use std::collections::BTreeMap; + use bellperson::bls::{Bls12, Fr}; use ff::Field; - use paired::bls12_381::{Bls12, Fr}; use rand::{Rng, SeedableRng}; use rand_xorshift::XorShiftRng; diff --git a/storage-proofs/post/src/rational/compound.rs b/storage-proofs/post/src/rational/compound.rs index 891566052..e89f4ce8f 100644 --- a/storage-proofs/post/src/rational/compound.rs +++ b/storage-proofs/post/src/rational/compound.rs @@ -1,9 +1,9 @@ use std::marker::PhantomData; use anyhow::ensure; +use bellperson::bls::{Bls12, Fr}; use bellperson::{Circuit, ConstraintSystem, SynthesisError}; use generic_array::typenum; -use paired::bls12_381::{Bls12, Fr}; use storage_proofs_core::{ compound_proof::{CircuitComponent, CompoundProof}, From 8af8d95dfaa8bcab7bd8e0a1308b15042ce7cb1f Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Fri, 25 Sep 2020 15:05:13 +0200 Subject: [PATCH 07/20] feature fixes --- .circleci/config.yml | 54 +++++++++++++++++++++++++++++++-- fil-proofs-tooling/Cargo.toml | 4 +-- filecoin-proofs/Cargo.toml | 2 +- storage-proofs/Cargo.toml | 8 ++--- storage-proofs/porep/Cargo.toml | 9 +++--- storage-proofs/post/Cargo.toml | 10 +++--- 6 files changed, 70 insertions(+), 17 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 260aa9143..6c4709ce1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -29,6 +29,7 @@ jobs: - cargo-v28-{{ checksum "rust-toolchain" }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}-{{ arch }} - run: rustup install $(cat rust-toolchain) - run: rustup default $(cat rust-toolchain) + - run: rustup install nightly - run: rustup component add rustfmt-preview - run: rustup component add clippy - run: cargo update @@ -171,16 +172,60 @@ jobs: - cargo-v28-{{ checksum "rust-toolchain" }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}-{{ arch }} - restore_parameter_cache - run: - name: Test with use_multicore_sdr enabled + name: Test with use_multicore_sdr pairing enabled command: | ulimit -n 20000 ulimit -u 20000 ulimit -n 20000 - cargo +$(cat rust-toolchain) test --verbose --release -- --ignored lifecycle + cargo +nightly -Zpackage-features test --all --verbose --release --test api -- --ignored lifecycle environment: RUST_TEST_THREADS: 1 FIL_PROOFS_USE_MULTICORE_SDR: true + - run: + name: Test with use_multicore_sdr and blst enabled + command: | + ulimit -n 20000 + ulimit -u 20000 + ulimit -n 20000 + cargo +nightly -Zpackage-features test --all --no-default-features --features gpu,blst --verbose --release --test api -- --ignored lifecycle + environment: + RUST_TEST_THREADS: 1 + FIL_PROOFS_USE_MULTICORE_SDR: true + + test_blst: + docker: + - image: filecoin/rust:latest + working_directory: /mnt/crate + resource_class: 2xlarge+ + steps: + - configure_environment_variables + - checkout + - attach_workspace: + at: "." + - restore_cache: + keys: + - cargo-v28-{{ checksum "rust-toolchain" }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}-{{ arch }} + - restore_parameter_cache + - run: + name: Test ignored with blst enabled + command: | + ulimit -n 20000 + ulimit -u 20000 + ulimit -n 20000 + cargo +nightly -Zpackage-features test --all --no-default-features --features gpu,blst --verbose --release --test api -- --ignored + environment: + RUST_TEST_THREADS: 1 + + - run: + name: Test with blst enabled + command: | + ulimit -n 20000 + ulimit -u 20000 + ulimit -n 20000 + cargo +nightly -Zpackage-features test --all --no-default-features --features gpu,blst --verbose + + bench: docker: - image: filecoin/rust:latest @@ -419,10 +464,15 @@ workflows: requires: - cargo_fetch - ensure_groth_parameters_and_keys_linux + - test_multicore_sdr: requires: - cargo_fetch - ensure_groth_parameters_and_keys_linux + - test_blst: + requires: + - cargo_fetch + - ensure_groth_parameters_and_keys_linux - test: requires: - cargo_fetch diff --git a/fil-proofs-tooling/Cargo.toml b/fil-proofs-tooling/Cargo.toml index 3d823c6fd..6b2f45e00 100644 --- a/fil-proofs-tooling/Cargo.toml +++ b/fil-proofs-tooling/Cargo.toml @@ -10,6 +10,8 @@ repository = "https://github.com/filecoin-project/rust-fil-proofs" readme = "README.md" [dependencies] +storage-proofs = { path = "../storage-proofs", default-features = false } +filecoin-proofs = { path = "../filecoin-proofs", default-features = false } clap = "2" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" @@ -22,8 +24,6 @@ chrono = { version = "0.4.7", features = ["serde"] } memmap = "0.7.0" bellperson = { git = "https://github.com/filecoin-project/bellman", branch = "blstrs", default-features = false } rand = "0.7" -storage-proofs = { path = "../storage-proofs"} -filecoin-proofs = { path = "../filecoin-proofs"} tempfile = "3.0.8" cpu-time = "1.0.0" git2 = "0.13.6" diff --git a/filecoin-proofs/Cargo.toml b/filecoin-proofs/Cargo.toml index 89972edc7..c32e1d165 100644 --- a/filecoin-proofs/Cargo.toml +++ b/filecoin-proofs/Cargo.toml @@ -9,7 +9,7 @@ repository = "https://github.com/filecoin-project/rust-fil-proofs" readme = "README.md" [dependencies] -storage-proofs = { version = "^5.0.0", path = "../storage-proofs" } +storage-proofs = { version = "^5.0.0", path = "../storage-proofs", default-features = false } bitvec = "0.17" chrono = "0.4" rand = "0.7" diff --git a/storage-proofs/Cargo.toml b/storage-proofs/Cargo.toml index 8a666d5e0..cbcc3995c 100644 --- a/storage-proofs/Cargo.toml +++ b/storage-proofs/Cargo.toml @@ -9,15 +9,15 @@ repository = "https://github.com/filecoin-project/rust-fil-proofs" readme = "README.md" [dependencies] -storage-proofs-core = { path = "./core", version = "^5.0.0"} -storage-proofs-post = { path = "./post", version = "^5.0.0"} -storage-proofs-porep = { path = "./porep", version = "^5.0.0"} +storage-proofs-core = { path = "./core", version = "^5.0.0", default-features = false } +storage-proofs-post = { path = "./post", version = "^5.0.0", default-features = false } +storage-proofs-porep = { path = "./porep", version = "^5.0.0", default-features = false } [features] default = ["gpu", "pairing"] simd = ["storage-proofs-core/simd"] asm = ["storage-proofs-core/asm"] -gpu = ["storage-proofs-core/gpu"] +gpu = ["storage-proofs-core/gpu", "storage-proofs-porep/gpu", "storage-proofs-post/gpu"] measurements = ["storage-proofs-core/measurements"] profile = ["measurements"] pairing = ["storage-proofs-core/pairing", "storage-proofs-post/pairing", "storage-proofs-porep/pairing"] diff --git a/storage-proofs/porep/Cargo.toml b/storage-proofs/porep/Cargo.toml index 10db3a53d..639eec527 100644 --- a/storage-proofs/porep/Cargo.toml +++ b/storage-proofs/porep/Cargo.toml @@ -11,7 +11,7 @@ readme = "README.md" [dependencies] crossbeam = "0.7.3" digest = "0.9" -storage-proofs-core = { path = "../core", version = "^5.0.0"} +storage-proofs-core = { path = "../core", version = "^5.0.0", default-features = false} sha2raw = { path = "../../sha2raw", version = "^2.0.0"} rand = "0.7" merkletree = "0.21.0" @@ -46,9 +46,10 @@ glob = "0.3.0" pretty_env_logger = "0.4.0" [features] -default = ["pairing"] -pairing = ["storage-proofs-core/pairing", "bellperson/pairing"] -blst = ["storage-proofs-core/blst", "bellperson/blst"] +default = ["pairing", "gpu"] +gpu = ["storage-proofs-core/gpu"] +pairing = ["storage-proofs-core/pairing", "bellperson/pairing", "neptune/pairing"] +blst = ["storage-proofs-core/blst", "bellperson/blst", "neptune/blst"] [[bench]] name = "encode" diff --git a/storage-proofs/post/Cargo.toml b/storage-proofs/post/Cargo.toml index b6d0fa920..3bcb04117 100644 --- a/storage-proofs/post/Cargo.toml +++ b/storage-proofs/post/Cargo.toml @@ -9,7 +9,7 @@ repository = "https://github.com/filecoin-project/rust-fil-proofs" readme = "README.md" [dependencies] -storage-proofs-core = { path = "../core", version = "^5.0.0"} +storage-proofs-core = { path = "../core", version = "^5.0.0", default-features = false} rand = "0.7" merkletree = "0.21.0" byteorder = "1" @@ -34,6 +34,8 @@ pretty_assertions = "0.6.1" rand_xorshift = "0.2.0" [features] -default = ["pairing"] -pairing = ["storage-proofs-core/pairing", "bellperson/pairing"] -blst = ["storage-proofs-core/blst", "bellperson/blst"] \ No newline at end of file +default = ["pairing", "gpu"] +gpu = ["storage-proofs-core/gpu"] +pairing = ["storage-proofs-core/pairing", "bellperson/pairing", "neptune/pairing"] +blst = ["storage-proofs-core/blst", "bellperson/blst", "neptune/blst"] + From 577ed85abf51f1435501064eaa636eb43a5c9bc2 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Fri, 25 Sep 2020 15:36:12 +0200 Subject: [PATCH 08/20] cache prepared verifying keys --- filecoin-proofs/src/api/seal.rs | 2 +- filecoin-proofs/src/caches.rs | 37 ++++++++++++++--------- storage-proofs/core/src/compound_proof.rs | 8 ++--- storage-proofs/core/src/multi_proof.rs | 8 ++--- 4 files changed, 31 insertions(+), 24 deletions(-) diff --git a/filecoin-proofs/src/api/seal.rs b/filecoin-proofs/src/api/seal.rs index de3197b06..fbd56c04b 100644 --- a/filecoin-proofs/src/api/seal.rs +++ b/filecoin-proofs/src/api/seal.rs @@ -505,7 +505,7 @@ pub fn seal_commit_phase2( )?; info!("snark_proof:finish"); - let proof = MultiProof::new(groth_proofs, &groth_params.vk); + let proof = MultiProof::new(groth_proofs, &groth_params.pvk); let mut buf = Vec::with_capacity( SINGLE_PARTITION_PROOF_LEN * usize::from(PoRepProofPartitions::from(porep_config)), diff --git a/filecoin-proofs/src/caches.rs b/filecoin-proofs/src/caches.rs index fb76c0997..1ad4580c2 100644 --- a/filecoin-proofs/src/caches.rs +++ b/filecoin-proofs/src/caches.rs @@ -16,11 +16,11 @@ use crate::parameters::{public_params, window_post_public_params, winning_post_p use crate::types::*; type Bls12GrothParams = groth16::MappedParameters; -pub type Bls12VerifyingKey = groth16::VerifyingKey; +pub type Bls12PreparedVerifyingKey = groth16::PreparedVerifyingKey; type Cache = HashMap>; type GrothMemCache = Cache; -type VerifyingKeyMemCache = Cache; +type VerifyingKeyMemCache = Cache; lazy_static! { static ref GROTH_PARAM_MEMORY_CACHE: Mutex = Default::default(); @@ -67,9 +67,12 @@ where } #[inline] -pub fn lookup_verifying_key(identifier: String, generator: F) -> Result> +pub fn lookup_verifying_key( + identifier: String, + generator: F, +) -> Result> where - F: FnOnce() -> Result, + F: FnOnce() -> Result, { let vk_identifier = format!("{}-verifying-key", &identifier); cache_lookup(&*VERIFYING_KEY_MEMORY_CACHE, vk_identifier, generator) @@ -148,7 +151,7 @@ pub fn get_post_params( pub fn get_stacked_verifying_key( porep_config: PoRepConfig, -) -> Result> { +) -> Result> { let public_params = public_params( PaddedBytesAmount::from(porep_config), usize::from(PoRepProofPartitions::from(porep_config)), @@ -156,11 +159,11 @@ pub fn get_stacked_verifying_key( )?; let vk_generator = || { - as CompoundProof< + let vk = as CompoundProof< StackedDrg, _, - >>::verifying_key::(None, &public_params) - .map_err(Into::into) + >>::verifying_key::(None, &public_params)?; + Ok(bellperson::groth16::prepare_verifying_key(&vk)) }; Ok(lookup_verifying_key( @@ -174,17 +177,19 @@ pub fn get_stacked_verifying_key( pub fn get_post_verifying_key( post_config: &PoStConfig, -) -> Result> { +) -> Result> { match post_config.typ { PoStType::Winning => { let post_public_params = winning_post_public_params::(post_config)?; let vk_generator = || { - as CompoundProof< + let vk = as CompoundProof< fallback::FallbackPoSt, fallback::FallbackPoStCircuit, - >>::verifying_key::(None, &post_public_params) - .map_err(Into::into) + >>::verifying_key::( + None, &post_public_params + )?; + Ok(bellperson::groth16::prepare_verifying_key(&vk)) }; Ok(lookup_verifying_key( @@ -199,11 +204,13 @@ pub fn get_post_verifying_key( let post_public_params = window_post_public_params::(post_config)?; let vk_generator = || { - as CompoundProof< + let vk = as CompoundProof< fallback::FallbackPoSt, fallback::FallbackPoStCircuit, - >>::verifying_key::(None, &post_public_params) - .map_err(Into::into) + >>::verifying_key::( + None, &post_public_params + )?; + Ok(bellperson::groth16::prepare_verifying_key(&vk)) }; Ok(lookup_verifying_key( diff --git a/storage-proofs/core/src/compound_proof.rs b/storage-proofs/core/src/compound_proof.rs index fc3766b8a..65aae3fbb 100644 --- a/storage-proofs/core/src/compound_proof.rs +++ b/storage-proofs/core/src/compound_proof.rs @@ -102,7 +102,7 @@ where )?; info!("snark_proof:finish"); - Ok(MultiProof::new(groth_proofs, &groth_params.vk)) + Ok(MultiProof::new(groth_proofs, &groth_params.pvk)) } fn prove_with_vanilla<'b>( @@ -126,7 +126,7 @@ where )?; info!("snark_proof:finish"); - Ok(MultiProof::new(groth_proofs, &groth_params.vk)) + Ok(MultiProof::new(groth_proofs, &groth_params.pvk)) } // verify is equivalent to ProofScheme::verify. @@ -142,7 +142,7 @@ where ); let vanilla_public_params = &public_params.vanilla_params; - let pvk = groth16::prepare_batch_verifying_key(&multi_proof.verifying_key); + let pvk = &multi_proof.verifying_key; if !::satisfies_requirements( &public_params.vanilla_params, @@ -243,7 +243,7 @@ where let vanilla_public_params = &public_params.vanilla_params; // just use the first one, the must be equal any way - let pvk = groth16::prepare_batch_verifying_key(&multi_proofs[0].verifying_key); + let pvk = &multi_proofs[0].verifying_key; for multi_proof in multi_proofs.iter() { if !::satisfies_requirements( diff --git a/storage-proofs/core/src/multi_proof.rs b/storage-proofs/core/src/multi_proof.rs index 1711b88bf..3d2075e07 100644 --- a/storage-proofs/core/src/multi_proof.rs +++ b/storage-proofs/core/src/multi_proof.rs @@ -8,7 +8,7 @@ use std::io::{self, Read, Write}; pub struct MultiProof<'a> { pub circuit_proofs: Vec>, - pub verifying_key: &'a groth16::VerifyingKey, + pub verifying_key: &'a groth16::PreparedVerifyingKey, } const GROTH_PROOF_SIZE: usize = 192; @@ -16,7 +16,7 @@ const GROTH_PROOF_SIZE: usize = 192; impl<'a> MultiProof<'a> { pub fn new( groth_proofs: Vec>, - verifying_key: &'a groth16::VerifyingKey, + verifying_key: &'a groth16::PreparedVerifyingKey, ) -> Self { MultiProof { circuit_proofs: groth_proofs, @@ -27,7 +27,7 @@ impl<'a> MultiProof<'a> { pub fn new_from_reader( partitions: Option, mut reader: R, - verifying_key: &'a groth16::VerifyingKey, + verifying_key: &'a groth16::PreparedVerifyingKey, ) -> Result { let num_proofs = partitions.unwrap_or(1); @@ -41,7 +41,7 @@ impl<'a> MultiProof<'a> { pub fn new_from_bytes( partitions: Option, proof_bytes: &[u8], - verifying_key: &'a groth16::VerifyingKey, + verifying_key: &'a groth16::PreparedVerifyingKey, ) -> Result { let num_proofs = partitions.unwrap_or(1); From c671054c9f24bc0fd216b3783877776b2c998190 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Mon, 5 Oct 2020 13:32:03 +0200 Subject: [PATCH 09/20] use proofs::read_many --- storage-proofs/core/src/multi_proof.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/storage-proofs/core/src/multi_proof.rs b/storage-proofs/core/src/multi_proof.rs index 3d2075e07..86d741561 100644 --- a/storage-proofs/core/src/multi_proof.rs +++ b/storage-proofs/core/src/multi_proof.rs @@ -45,11 +45,7 @@ impl<'a> MultiProof<'a> { ) -> Result { let num_proofs = partitions.unwrap_or(1); - let proofs = proof_bytes - .par_chunks(GROTH_PROOF_SIZE) - .take(num_proofs) - .map(groth16::Proof::read) - .collect::>>()?; + let proofs = groth16::Proof::read_many(proof_bytes, num_proofs)?; ensure!( num_proofs == proofs.len(), From 15abd9b6fb7e244562074d8ae1e70b4b7f3719f8 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Mon, 5 Oct 2020 13:49:02 +0200 Subject: [PATCH 10/20] avoid one allocation --- storage-proofs/core/src/compound_proof.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/storage-proofs/core/src/compound_proof.rs b/storage-proofs/core/src/compound_proof.rs index 65aae3fbb..13689555b 100644 --- a/storage-proofs/core/src/compound_proof.rs +++ b/storage-proofs/core/src/compound_proof.rs @@ -156,9 +156,13 @@ where .into_par_iter() .map(|k| Self::generate_public_inputs(public_inputs, vanilla_public_params, Some(k))) .collect::>()?; - let proofs: Vec<_> = multi_proof.circuit_proofs.iter().collect(); - let res = groth16::verify_proofs_batch(&pvk, &mut rand::rngs::OsRng, &proofs, &inputs)?; + let res = groth16::verify_proofs_batch( + &pvk, + &mut rand::rngs::OsRng, + &multi_proof.circuit_proofs, + &inputs, + )?; Ok(res) } From b8d82fba8ffa7ea3c35cf06166c50c4638ce7e26 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Mon, 5 Oct 2020 14:00:48 +0200 Subject: [PATCH 11/20] fixup --- storage-proofs/core/src/compound_proof.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/storage-proofs/core/src/compound_proof.rs b/storage-proofs/core/src/compound_proof.rs index 13689555b..679e4941a 100644 --- a/storage-proofs/core/src/compound_proof.rs +++ b/storage-proofs/core/src/compound_proof.rs @@ -157,12 +157,8 @@ where .map(|k| Self::generate_public_inputs(public_inputs, vanilla_public_params, Some(k))) .collect::>()?; - let res = groth16::verify_proofs_batch( - &pvk, - &mut rand::rngs::OsRng, - &multi_proof.circuit_proofs, - &inputs, - )?; + let proofs: Vec<_> = multi_proof.circuit_proofs.iter().collect(); + let res = groth16::verify_proofs_batch(&pvk, &mut rand::rngs::OsRng, &proofs, &inputs)?; Ok(res) } From d393c102f8ff453655a6b123d9bd50c00f214d18 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Mon, 5 Oct 2020 16:01:17 +0200 Subject: [PATCH 12/20] remove fil-blst dependency --- filecoin-proofs/src/api/post.rs | 35 +------------ filecoin-proofs/src/api/seal.rs | 23 +-------- rust-fil-proofs.config.toml.sample | 3 -- storage-proofs/core/Cargo.toml | 1 - storage-proofs/core/src/compound_proof.rs | 63 ----------------------- storage-proofs/core/src/multi_proof.rs | 3 +- storage-proofs/core/src/settings.rs | 2 - 7 files changed, 4 insertions(+), 126 deletions(-) diff --git a/filecoin-proofs/src/api/post.rs b/filecoin-proofs/src/api/post.rs index 258120c4b..6afc3c7b5 100644 --- a/filecoin-proofs/src/api/post.rs +++ b/filecoin-proofs/src/api/post.rs @@ -19,7 +19,6 @@ use storage_proofs::post::fallback; use storage_proofs::post::fallback::SectorProof; use storage_proofs::proof::ProofScheme; use storage_proofs::sector::*; -use storage_proofs::settings; use storage_proofs::util::default_rows_to_discard; use crate::api::util::{as_safe_commitment, get_base_tree_leafs, get_base_tree_size}; @@ -624,22 +623,7 @@ pub fn verify_winning_post( k: None, }; - let use_fil_blst = settings::SETTINGS.use_fil_blst; - - let is_valid = if use_fil_blst { - info!("verify_winning_post: use_fil_blst=true"); - let verifying_key_path = post_config.get_cache_verifying_key_path::()?; - fallback::FallbackPoStCompound::verify_blst( - &pub_params, - &pub_inputs, - &proof, - proof.len() / 192, - &fallback::ChallengeRequirements { - minimum_challenge_count: post_config.challenge_count * post_config.sector_count, - }, - &verifying_key_path, - )? - } else { + let is_valid = { let verifying_key = get_post_verifying_key::(&post_config)?; let single_proof = MultiProof::new_from_reader(None, &proof[..], &verifying_key)?; @@ -997,22 +981,7 @@ pub fn verify_window_post( k: None, }; - let use_fil_blst = settings::SETTINGS.use_fil_blst; - - let is_valid = if use_fil_blst { - info!("verify_window_post: use_fil_blst=true"); - let verifying_key_path = post_config.get_cache_verifying_key_path::()?; - fallback::FallbackPoStCompound::verify_blst( - &pub_params, - &pub_inputs, - &proof, - proof.len() / 192, - &fallback::ChallengeRequirements { - minimum_challenge_count: post_config.challenge_count * post_config.sector_count, - }, - &verifying_key_path, - )? - } else { + let is_valid = { let verifying_key = get_post_verifying_key::(&post_config)?; let multi_proof = MultiProof::new_from_reader(partitions, &proof[..], &verifying_key)?; diff --git a/filecoin-proofs/src/api/seal.rs b/filecoin-proofs/src/api/seal.rs index fbd56c04b..8dab0b715 100644 --- a/filecoin-proofs/src/api/seal.rs +++ b/filecoin-proofs/src/api/seal.rs @@ -21,7 +21,6 @@ use storage_proofs::porep::stacked::{ }; use storage_proofs::proof::ProofScheme; use storage_proofs::sector::SectorId; -use storage_proofs::settings; use storage_proofs::util::default_rows_to_discard; use crate::api::util::{ @@ -609,27 +608,7 @@ pub fn verify_seal( k: None, }; - let use_fil_blst = settings::SETTINGS.use_fil_blst; - - let result = if use_fil_blst { - info!("verify_seal: use_fil_blst=true"); - let verifying_key_path = porep_config.get_cache_verifying_key_path::()?; - - StackedCompound::verify_blst( - &compound_public_params, - &public_inputs, - &proof_vec, - proof_vec.len() / 192, - &ChallengeRequirements { - minimum_challenges: *POREP_MINIMUM_CHALLENGES - .read() - .expect("POREP_MINIMUM_CHALLENGES poisoned") - .get(&u64::from(SectorSize::from(porep_config))) - .expect("unknown sector size") as usize, - }, - &verifying_key_path, - ) - } else { + let result = { let sector_bytes = PaddedBytesAmount::from(porep_config); let verifying_key = get_stacked_verifying_key::(porep_config)?; diff --git a/rust-fil-proofs.config.toml.sample b/rust-fil-proofs.config.toml.sample index cb68e9700..f2106e8dd 100644 --- a/rust-fil-proofs.config.toml.sample +++ b/rust-fil-proofs.config.toml.sample @@ -31,8 +31,5 @@ rows_to_discard = 2 # This value is defaulted to the number of cores available on your system. #window_post_synthesis_num_cpus = 8 -# This enables accelerate snark verification -use_fil_blst = false - # This enables multicore SDR replication use_multicore_sdr = false diff --git a/storage-proofs/core/Cargo.toml b/storage-proofs/core/Cargo.toml index b90e3fd0f..e7c0a5964 100644 --- a/storage-proofs/core/Cargo.toml +++ b/storage-proofs/core/Cargo.toml @@ -42,7 +42,6 @@ neptune = { git = "https://github.com/filecoin-project/neptune", branch = "blst" cpu-time = { version = "1.0", optional = true } gperftools = { version = "0.2", optional = true } num_cpus = "1.10.1" -fil-blst = { git = "https://github.com/filecoin-project/fil-blst", branch = "rustify" } [dev-dependencies] proptest = "0.10" diff --git a/storage-proofs/core/src/compound_proof.rs b/storage-proofs/core/src/compound_proof.rs index 679e4941a..a495fded7 100644 --- a/storage-proofs/core/src/compound_proof.rs +++ b/storage-proofs/core/src/compound_proof.rs @@ -1,9 +1,6 @@ -use std::path::Path; - use anyhow::{ensure, Context}; use bellperson::bls::{Bls12, Fr}; use bellperson::{groth16, Circuit}; -use fil_blst::{blst::blst_scalar, blst_fr_from_fr, scalar_from_u64, verify_batch_proof}; use log::info; use rand::{rngs::OsRng, RngCore}; use rayon::prelude::*; @@ -162,66 +159,6 @@ where Ok(res) } - // verify_blst is equivalent to ProofScheme::verify. - fn verify_blst( - public_params: &PublicParams<'a, S>, - public_inputs: &S::PublicInputs, - proof_vec: &[u8], - num_proofs: usize, - requirements: &S::Requirements, - vk_path: &Path, - ) -> Result { - ensure!( - num_proofs == Self::partition_count(public_params), - "Inconsistent inputs" - ); - - let vanilla_public_params = &public_params.vanilla_params; - - if !::satisfies_requirements( - &public_params.vanilla_params, - requirements, - num_proofs, - ) { - return Ok(false); - } - - let inputs: Vec<_> = (0..num_proofs) - .into_par_iter() - .map(|k| Self::generate_public_inputs(public_inputs, vanilla_public_params, Some(k))) - .collect::>()?; - - let blst_inputs: Vec<_> = todo!(); /*inputs - .iter() - .flat_map(|pis| pis.iter().map(|pi| blst_fr_from_fr(*pi))) - .collect();*/ - - // choose random coefficients for combining the proofs - let mut r: Vec = Vec::with_capacity(num_proofs); - let mut rng = rand::rngs::OsRng; - for _ in 0..num_proofs { - use rand::Rng; - let t: u128 = rng.gen(); - - let mut limbs: [u64; 4] = [0, 0, 0, 0]; - limbs[1] = (t >> 64) as u64; - limbs[0] = (t & (-1i64 as u128) >> 64) as u64; - - r.push(scalar_from_u64(&limbs)); - } - - let res = verify_batch_proof( - proof_vec, - num_proofs, - &blst_inputs[..], - inputs[0].len(), - &r[..], - 128, - vk_path, - ); - Ok(res) - } - /// Efficiently verify multiple proofs. fn batch_verify<'b>( public_params: &PublicParams<'a, S>, diff --git a/storage-proofs/core/src/multi_proof.rs b/storage-proofs/core/src/multi_proof.rs index 86d741561..350e59531 100644 --- a/storage-proofs/core/src/multi_proof.rs +++ b/storage-proofs/core/src/multi_proof.rs @@ -3,8 +3,7 @@ use bellperson::groth16; use crate::error::Result; use anyhow::{ensure, Context}; use bellperson::bls::Bls12; -use rayon::prelude::*; -use std::io::{self, Read, Write}; +use std::io::{Read, Write}; pub struct MultiProof<'a> { pub circuit_proofs: Vec>, diff --git a/storage-proofs/core/src/settings.rs b/storage-proofs/core/src/settings.rs index 39e7bb5a5..eb0786243 100644 --- a/storage-proofs/core/src/settings.rs +++ b/storage-proofs/core/src/settings.rs @@ -26,7 +26,6 @@ pub struct Settings { pub window_post_synthesis_num_cpus: u32, pub parameter_cache: String, pub parent_cache: String, - pub use_fil_blst: bool, pub use_multicore_sdr: bool, pub multicore_sdr_producers: usize, pub multicore_sdr_producer_stride: u64, @@ -51,7 +50,6 @@ impl Default for Settings { // The name is retained for backwards compatibility. parameter_cache: "/var/tmp/filecoin-proof-parameters/".to_string(), parent_cache: cache("filecoin-parents"), - use_fil_blst: false, use_multicore_sdr: false, multicore_sdr_producers: 3, multicore_sdr_producer_stride: 128, From 13dee64793278923bb36efd7616e7e6677e02fd7 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Mon, 5 Oct 2020 18:44:12 +0200 Subject: [PATCH 13/20] ci fixes --- .circleci/config.yml | 30 ------------------- .../src/stacked/vanilla/create_label/multi.rs | 2 +- 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6c4709ce1..4271950dc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -128,32 +128,6 @@ jobs: RUST_TEST_THREADS: 1 no_output_timeout: 30m - # Running with `use_fil_blst=true` should be integrated directly into the test code. For now we - # just re-run the tests that exercise the fil-blst code path with that setting set. - test_fil_blst: - docker: - - image: filecoin/rust:latest - working_directory: /mnt/crate - resource_class: 2xlarge+ - steps: - - configure_environment_variables - - checkout - - attach_workspace: - at: "." - - restore_cache: - keys: - - cargo-v28-{{ checksum "rust-toolchain" }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}-{{ arch }} - - restore_parameter_cache - - run: - name: Test with fil-blst enabled - command: | - ulimit -n 20000 - ulimit -u 20000 - ulimit -n 20000 - cargo +$(cat rust-toolchain) test --verbose --release --test api -- --ignored - environment: - RUST_TEST_THREADS: 1 - FIL_PROOFS_USE_FIL_BLST: true # Running with `use_multicore_sdr=true` should be integrated directly into the test code. For now we # just re-run the lifecycle tests to exercise the use_multicore_sdr code path with that setting set. @@ -460,10 +434,6 @@ workflows: requires: - cargo_fetch - ensure_groth_parameters_and_keys_linux - - test_fil_blst: - requires: - - cargo_fetch - - ensure_groth_parameters_and_keys_linux - test_multicore_sdr: requires: diff --git a/storage-proofs/porep/src/stacked/vanilla/create_label/multi.rs b/storage-proofs/porep/src/stacked/vanilla/create_label/multi.rs index 17fa51ec5..36c1d8feb 100644 --- a/storage-proofs/porep/src/stacked/vanilla/create_label/multi.rs +++ b/storage-proofs/porep/src/stacked/vanilla/create_label/multi.rs @@ -619,9 +619,9 @@ pub fn create_labels_for_decoding Date: Wed, 7 Oct 2020 22:11:35 +0200 Subject: [PATCH 14/20] fmt --- fil-proofs-tooling/src/bin/benchy/hash_fns.rs | 2 +- fil-proofs-tooling/src/bin/benchy/prodbench.rs | 2 +- fil-proofs-tooling/src/bin/check_parameters/main.rs | 2 +- filecoin-proofs/tests/api.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fil-proofs-tooling/src/bin/benchy/hash_fns.rs b/fil-proofs-tooling/src/bin/benchy/hash_fns.rs index 5fd21219f..545d18aa7 100644 --- a/fil-proofs-tooling/src/bin/benchy/hash_fns.rs +++ b/fil-proofs-tooling/src/bin/benchy/hash_fns.rs @@ -1,8 +1,8 @@ +use bellperson::bls::Bls12; use bellperson::gadgets::boolean::Boolean; use bellperson::util_cs::test_cs::TestConstraintSystem; use bellperson::ConstraintSystem; use fil_proofs_tooling::metadata::Metadata; -use bellperson::bls::Bls12; use rand::RngCore; use serde::Serialize; use storage_proofs::util::{bits_to_bytes, bytes_into_boolean_vec, bytes_into_boolean_vec_be}; diff --git a/fil-proofs-tooling/src/bin/benchy/prodbench.rs b/fil-proofs-tooling/src/bin/benchy/prodbench.rs index 542b643ab..095d85d50 100644 --- a/fil-proofs-tooling/src/bin/benchy/prodbench.rs +++ b/fil-proofs-tooling/src/bin/benchy/prodbench.rs @@ -1,3 +1,4 @@ +use bellperson::bls::Bls12; use bellperson::util_cs::bench_cs::BenchCS; use bellperson::Circuit; use fil_proofs_tooling::shared::{create_replicas, PROVER_ID, RANDOMNESS, TICKET_BYTES}; @@ -11,7 +12,6 @@ use filecoin_proofs::{ validate_cache_for_commit, PoRepConfig, }; use log::info; -use bellperson::bls::Bls12; use rand::SeedableRng; use rand_xorshift::XorShiftRng; use serde::{Deserialize, Serialize}; diff --git a/fil-proofs-tooling/src/bin/check_parameters/main.rs b/fil-proofs-tooling/src/bin/check_parameters/main.rs index 1c40bf4eb..d6ae7e5f1 100644 --- a/fil-proofs-tooling/src/bin/check_parameters/main.rs +++ b/fil-proofs-tooling/src/bin/check_parameters/main.rs @@ -1,9 +1,9 @@ use std::path::PathBuf; use anyhow::Result; +use bellperson::bls::Bls12; use bellperson::groth16::MappedParameters; use clap::{value_t, App, Arg, SubCommand}; -use bellperson::bls::Bls12; use storage_proofs::parameter_cache::read_cached_params; diff --git a/filecoin-proofs/tests/api.rs b/filecoin-proofs/tests/api.rs index f317089f3..2d0aa9f04 100644 --- a/filecoin-proofs/tests/api.rs +++ b/filecoin-proofs/tests/api.rs @@ -5,8 +5,8 @@ use std::path::{Path, PathBuf}; use std::sync::Once; use anyhow::Result; -use ff::Field; use bellperson::bls::Fr; +use ff::Field; use rand::{Rng, SeedableRng}; use rand_xorshift::XorShiftRng; use storage_proofs::hasher::Hasher; From a4df50fb97e5e9e54bb199186325d93606966cd0 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Wed, 7 Oct 2020 22:47:55 +0200 Subject: [PATCH 15/20] avoid duplicate hashing in challenge generation for fallback post --- storage-proofs/post/src/fallback/vanilla.rs | 103 +++++++++++++------- 1 file changed, 68 insertions(+), 35 deletions(-) diff --git a/storage-proofs/post/src/fallback/vanilla.rs b/storage-proofs/post/src/fallback/vanilla.rs index e428fcce4..473be1dd6 100644 --- a/storage-proofs/post/src/fallback/vanilla.rs +++ b/storage-proofs/post/src/fallback/vanilla.rs @@ -205,11 +205,14 @@ pub fn generate_leaf_challenges( ) -> Vec { let mut challenges = Vec::with_capacity(challenge_count); + let mut hasher = Sha256::new(); + hasher.update(AsRef::<[u8]>::as_ref(&randomness)); + hasher.update(§or_id.to_le_bytes()[..]); + for leaf_challenge_index in 0..challenge_count { - let challenge = generate_leaf_challenge( + let challenge = generate_leaf_challenge_inner::( + hasher.clone(), pub_params, - randomness, - sector_id, leaf_challenge_index as u64, ); challenges.push(challenge) @@ -228,6 +231,15 @@ pub fn generate_leaf_challenge( let mut hasher = Sha256::new(); hasher.update(AsRef::<[u8]>::as_ref(&randomness)); hasher.update(§or_id.to_le_bytes()[..]); + + generate_leaf_challenge_inner::(hasher, pub_params, leaf_challenge_index) +} + +fn generate_leaf_challenge_inner( + mut hasher: Sha256, + pub_params: &PublicParams, + leaf_challenge_index: u64, +) -> u64 { hasher.update(&leaf_challenge_index.to_le_bytes()[..]); let hash = hasher.finalize(); @@ -383,6 +395,11 @@ impl<'a, Tree: 'a + MerkleTreeTrait> ProofScheme<'a> for FallbackPoSt<'a, Tree> Tree::Arity::to_usize(), ); + // avoid rehashing fixed inputs + let mut challenge_hasher = Sha256::new(); + challenge_hasher.update(AsRef::<[u8]>::as_ref(&pub_inputs.randomness)); + challenge_hasher.update(&u64::from(sector_id).to_le_bytes()[..]); + let mut inclusion_proofs = Vec::new(); for proof_or_fault in (0..pub_params.challenge_count) .into_par_iter() @@ -390,12 +407,12 @@ impl<'a, Tree: 'a + MerkleTreeTrait> ProofScheme<'a> for FallbackPoSt<'a, Tree> let challenge_index = ((j * num_sectors_per_chunk + i) * pub_params.challenge_count + n) as u64; - let challenged_leaf_start = generate_leaf_challenge( - pub_params, - pub_inputs.randomness, - sector_id.into(), - challenge_index, - ); + let challenged_leaf_start = + generate_leaf_challenge_inner::<::Domain>( + challenge_hasher.clone(), + pub_params, + challenge_index, + ); let proof = tree.gen_cached_proof( challenged_leaf_start as usize, @@ -522,35 +539,51 @@ impl<'a, Tree: 'a + MerkleTreeTrait> ProofScheme<'a> for FallbackPoSt<'a, Tree> inclusion_proofs.len() ); - for (n, inclusion_proof) in inclusion_proofs.iter().enumerate() { - let challenge_index = - ((j * num_sectors_per_chunk + i) * pub_params.challenge_count + n) as u64; - let challenged_leaf_start = generate_leaf_challenge( - pub_params, - pub_inputs.randomness, - sector_id.into(), - challenge_index, - ); - - // validate all comm_r_lasts match - if inclusion_proof.root() != comm_r_last { - error!("inclusion proof root != comm_r_last: {:?}", sector_id); - return Ok(false); - } + // avoid rehashing fixed inputs + let mut challenge_hasher = Sha256::new(); + challenge_hasher.update(AsRef::<[u8]>::as_ref(&pub_inputs.randomness)); + challenge_hasher.update(&u64::from(sector_id).to_le_bytes()[..]); - // validate the path length - let expected_path_length = - inclusion_proof.expected_len(pub_params.sector_size as usize / NODE_SIZE); + let is_valid_list = inclusion_proofs + .par_iter() + .enumerate() + .map(|(n, inclusion_proof)| -> Result { + let challenge_index = ((j * num_sectors_per_chunk + i) + * pub_params.challenge_count + + n) as u64; + let challenged_leaf_start = + generate_leaf_challenge_inner::<::Domain>( + challenge_hasher.clone(), + pub_params, + challenge_index, + ); + + // validate all comm_r_lasts match + if inclusion_proof.root() != comm_r_last { + error!("inclusion proof root != comm_r_last: {:?}", sector_id); + return Ok(false); + } - if expected_path_length != inclusion_proof.path().len() { - error!("wrong path length: {:?}", sector_id); - return Ok(false); - } + // validate the path length + let expected_path_length = inclusion_proof + .expected_len(pub_params.sector_size as usize / NODE_SIZE); - if !inclusion_proof.validate(challenged_leaf_start as usize) { - error!("invalid inclusion proof: {:?}", sector_id); - return Ok(false); - } + if expected_path_length != inclusion_proof.path().len() { + error!("wrong path length: {:?}", sector_id); + return Ok(false); + } + + if !inclusion_proof.validate(challenged_leaf_start as usize) { + error!("invalid inclusion proof: {:?}", sector_id); + return Ok(false); + } + Ok(true) + }) + .collect::>>()?; + + let is_valid = is_valid_list.into_iter().all(|v| v); + if !is_valid { + return Ok(false); } } } From bb1b7911e1ade6c3657b7335f0ecbcc77f250a84 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Tue, 27 Oct 2020 18:17:55 +0100 Subject: [PATCH 16/20] update dependencies --- fil-proofs-tooling/Cargo.toml | 8 ++++---- filecoin-proofs/Cargo.toml | 8 ++++---- filecoin-proofs/src/bin/circuitinfo.rs | 3 +-- sha2raw/Cargo.toml | 5 +++-- sha2raw/src/sha256.rs | 4 ++-- sha2raw/src/sha256_utils.rs | 2 +- storage-proofs/core/Cargo.toml | 8 ++++---- storage-proofs/core/src/gadgets/xor.rs | 3 +-- storage-proofs/porep/Cargo.toml | 8 ++++---- storage-proofs/porep/src/stacked/circuit/create_label.rs | 3 +-- storage-proofs/post/Cargo.toml | 6 +++--- 11 files changed, 28 insertions(+), 30 deletions(-) diff --git a/fil-proofs-tooling/Cargo.toml b/fil-proofs-tooling/Cargo.toml index 6b2f45e00..77a898197 100644 --- a/fil-proofs-tooling/Cargo.toml +++ b/fil-proofs-tooling/Cargo.toml @@ -22,7 +22,7 @@ regex = "1.3.7" commandspec = "0.12.2" chrono = { version = "0.4.7", features = ["serde"] } memmap = "0.7.0" -bellperson = { git = "https://github.com/filecoin-project/bellman", branch = "blstrs", default-features = false } +bellperson = { git = "https://github.com/filecoin-project/bellperson", branch = "blstrs", default-features = false } rand = "0.7" tempfile = "3.0.8" cpu-time = "1.0.0" @@ -40,9 +40,9 @@ ff = { version = "0.2.3", package = "fff" } rand_xorshift = "0.2.0" bytefmt = "0.1.7" rayon = "1.3.0" -flexi_logger = "0.14.7" +flexi_logger = "0.16.1" typenum = "1.11.2" -generic-array = "0.13.2" +generic-array = "0.14.4" byte-unit = "4.0.9" [features] @@ -54,4 +54,4 @@ pairing = ["storage-proofs/pairing", "filecoin-proofs/pairing", "bellperson/pair blst = ["storage-proofs/blst", "filecoin-proofs/blst", "bellperson/blst"] [target.'cfg(target_arch = "x86_64")'.dependencies] -raw-cpuid = "7.0.3" +raw-cpuid = "8.1.2" diff --git a/filecoin-proofs/Cargo.toml b/filecoin-proofs/Cargo.toml index c32e1d165..fb0e4af97 100644 --- a/filecoin-proofs/Cargo.toml +++ b/filecoin-proofs/Cargo.toml @@ -23,7 +23,7 @@ serde_json = "1.0" regex = "1.3.7" ff = { version = "0.2.3", package = "fff" } blake2b_simd = "0.5" -bellperson = { git = "https://github.com/filecoin-project/bellman", branch = "blstrs", default-features = false } +bellperson = { git = "https://github.com/filecoin-project/bellperson", branch = "blstrs", default-features = false } clap = "2" log = "0.4.7" fil_logger = "0.1" @@ -44,11 +44,11 @@ gperftools = { version = "0.2", optional = true } phase2 = { git = "https://github.com/filecoin-project/phase2", branch = "blst", package = "phase21", default-features = false } simplelog = "0.8.0" rand_chacha = "0.2.1" -dialoguer = "0.6.2" -generic-array = "0.13.2" +dialoguer = "0.7.1" +generic-array = "0.14.4" structopt = "0.3.12" humansize = "1.1.0" -indicatif = "0.14.0" +indicatif = "0.15.0" groupy = "0.3.0" [dependencies.reqwest] diff --git a/filecoin-proofs/src/bin/circuitinfo.rs b/filecoin-proofs/src/bin/circuitinfo.rs index 7914eac26..40fcf461f 100644 --- a/filecoin-proofs/src/bin/circuitinfo.rs +++ b/filecoin-proofs/src/bin/circuitinfo.rs @@ -4,7 +4,7 @@ use log::{info, warn}; use structopt::StructOpt; use bellperson::util_cs::bench_cs::BenchCS; -use bellperson::Circuit; +use bellperson::{bls::Bls12, Circuit}; use filecoin_proofs::constants::*; use filecoin_proofs::parameters::{ public_params, window_post_public_params, winning_post_public_params, @@ -12,7 +12,6 @@ use filecoin_proofs::parameters::{ use filecoin_proofs::types::*; use filecoin_proofs::with_shape; use filecoin_proofs::PoStType; -use paired::bls12_381::Bls12; use storage_proofs::compound_proof::CompoundProof; use storage_proofs::porep::stacked::{StackedCompound, StackedDrg}; use storage_proofs::post::fallback::{FallbackPoSt, FallbackPoStCircuit, FallbackPoStCompound}; diff --git a/sha2raw/Cargo.toml b/sha2raw/Cargo.toml index 69d21b1ac..caba9ad1b 100644 --- a/sha2raw/Cargo.toml +++ b/sha2raw/Cargo.toml @@ -12,10 +12,11 @@ edition = "2018" [dependencies] digest = "0.9" -block-buffer = "0.7" +block-buffer = "0.9" fake-simd = "0.1" -opaque-debug = "0.2" +opaque-debug = "0.3" sha2-asm = { version = "0.5", optional = true } +byteorder = "1.3.4" [dependencies.lazy_static] version = "1.4.0" diff --git a/sha2raw/src/sha256.rs b/sha2raw/src/sha256.rs index 9130fdea8..b792bcb33 100644 --- a/sha2raw/src/sha256.rs +++ b/sha2raw/src/sha256.rs @@ -1,4 +1,4 @@ -use block_buffer::byteorder::{ByteOrder, BE}; +use byteorder::{ByteOrder, BE}; use crate::consts::H256; use crate::platform::Implementation; @@ -79,7 +79,7 @@ impl Sha256 { } } -opaque_debug::impl_opaque_debug!(Sha256); +opaque_debug::implement!(Sha256); #[cfg(test)] mod tests { diff --git a/sha2raw/src/sha256_utils.rs b/sha2raw/src/sha256_utils.rs index 0e6d8a743..5f55cd783 100644 --- a/sha2raw/src/sha256_utils.rs +++ b/sha2raw/src/sha256_utils.rs @@ -283,7 +283,7 @@ fn sha256_digest_block_u32(state: &mut [u32; 8], block: &[u32; 16]) { #[inline] pub fn compress256(state: &mut [u32; 8], blocks: &[&[u8]]) { use crate::consts::BLOCK_LEN; - use block_buffer::byteorder::{ByteOrder, BE}; + use byteorder::{ByteOrder, BE}; let mut block_u32 = [0u32; BLOCK_LEN]; diff --git a/storage-proofs/core/Cargo.toml b/storage-proofs/core/Cargo.toml index e7c0a5964..8cb31a0e8 100644 --- a/storage-proofs/core/Cargo.toml +++ b/storage-proofs/core/Cargo.toml @@ -19,8 +19,8 @@ config = { version = "0.10.1", default-features = false, features = ["toml"] } itertools = "0.9" lazy_static = "1.2" memmap = "0.7" -aes = "0.3" -block-modes = "0.3" +aes = "0.6" +block-modes = "0.7" sha2 = "0.9.1" tempfile = "3" fs2 = "0.4" @@ -30,12 +30,12 @@ blake2b_simd = "0.5" blake2s_simd = "0.5" toml = "0.5" ff = { version = "0.2.3", package = "fff" } -bellperson = { git = "https://github.com/filecoin-project/bellman", branch = "blstrs", default-features = false } +bellperson = { git = "https://github.com/filecoin-project/bellperson", branch = "blstrs", default-features = false } serde_json = "1.0" log = "0.4.7" rand_chacha = "0.2.1" hex = "0.4.0" -generic-array = "0.13.2" +generic-array = "0.14.4" anyhow = "1.0.23" thiserror = "1.0.6" neptune = { git = "https://github.com/filecoin-project/neptune", branch = "blst", default-features = false, features = ["gpu"] } diff --git a/storage-proofs/core/src/gadgets/xor.rs b/storage-proofs/core/src/gadgets/xor.rs index 513549551..157cc9a01 100644 --- a/storage-proofs/core/src/gadgets/xor.rs +++ b/storage-proofs/core/src/gadgets/xor.rs @@ -1,6 +1,5 @@ use bellperson::gadgets::boolean::Boolean; -use bellperson::{ConstraintSystem, SynthesisError}; -use paired::Engine; +use bellperson::{bls::Engine, ConstraintSystem, SynthesisError}; pub fn xor( cs: &mut CS, diff --git a/storage-proofs/porep/Cargo.toml b/storage-proofs/porep/Cargo.toml index 639eec527..be839f29b 100644 --- a/storage-proofs/porep/Cargo.toml +++ b/storage-proofs/porep/Cargo.toml @@ -9,7 +9,7 @@ repository = "https://github.com/filecoin-project/rust-fil-proofs" readme = "README.md" [dependencies] -crossbeam = "0.7.3" +crossbeam = "0.8" digest = "0.9" storage-proofs-core = { path = "../core", version = "^5.0.0", default-features = false} sha2raw = { path = "../../sha2raw", version = "^2.0.0"} @@ -23,10 +23,10 @@ rayon = "1.0.0" serde = { version = "1.0", features = ["derive"]} serde_json = "1.0" ff = { version = "0.2.3", package = "fff" } -bellperson = { git = "https://github.com/filecoin-project/bellman", branch = "blstrs", default-features = false } +bellperson = { git = "https://github.com/filecoin-project/bellperson", branch = "blstrs", default-features = false } log = "0.4.7" pretty_assertions = "0.6.1" -generic-array = "0.13.2" +generic-array = "0.14.4" anyhow = "1.0.23" neptune = { git = "https://github.com/filecoin-project/neptune", branch = "blst", default-features = false, features = ["gpu"] } num_cpus = "1.10.1" @@ -34,7 +34,7 @@ hex = "0.4.2" bincode = "1.1.2" byteorder = "1.3.4" lazy_static = "1.2" -byte-slice-cast = "0.3.5" +byte-slice-cast = "1.0.0" hwloc = "0.3.0" libc = "0.2" diff --git a/storage-proofs/porep/src/stacked/circuit/create_label.rs b/storage-proofs/porep/src/stacked/circuit/create_label.rs index 4ad0adaaf..850dfacc4 100644 --- a/storage-proofs/porep/src/stacked/circuit/create_label.rs +++ b/storage-proofs/porep/src/stacked/circuit/create_label.rs @@ -1,7 +1,6 @@ use bellperson::gadgets::{boolean::Boolean, num, sha256::sha256 as sha256_circuit, uint32}; -use bellperson::{ConstraintSystem, SynthesisError}; +use bellperson::{bls::Engine, ConstraintSystem, SynthesisError}; use ff::PrimeField; -use paired::Engine; use storage_proofs_core::{gadgets::multipack, gadgets::uint64, util::reverse_bit_numbering}; use crate::stacked::vanilla::TOTAL_PARENTS; diff --git a/storage-proofs/post/Cargo.toml b/storage-proofs/post/Cargo.toml index 3bcb04117..400b7dacd 100644 --- a/storage-proofs/post/Cargo.toml +++ b/storage-proofs/post/Cargo.toml @@ -13,17 +13,17 @@ storage-proofs-core = { path = "../core", version = "^5.0.0", default-features = rand = "0.7" merkletree = "0.21.0" byteorder = "1" -crossbeam = "0.7.3" +crossbeam = "0.8" sha2 = "0.9.1" rayon = "1.0.0" serde = { version = "1.0", features = ["derive"]} blake2b_simd = "0.5" blake2s_simd = "0.5" ff = { version = "0.2.3", package = "fff" } -bellperson = { git = "https://github.com/filecoin-project/bellman", branch = "blstrs", default-features = false } +bellperson = { git = "https://github.com/filecoin-project/bellperson", branch = "blstrs", default-features = false } log = "0.4.7" hex = "0.4.0" -generic-array = "0.13.2" +generic-array = "0.14.4" anyhow = "1.0.23" neptune = { git = "https://github.com/filecoin-project/neptune", branch = "blst", default-features = false, features = ["gpu"] } num_cpus = "1.10.1" From eaf4f609de0e624b078ca7b3762d3a35c38bba6f Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Wed, 28 Oct 2020 00:26:10 +0100 Subject: [PATCH 17/20] switch to blstrs#9 --- fil-proofs-tooling/Cargo.toml | 2 +- filecoin-proofs/Cargo.toml | 4 ++-- storage-proofs/core/Cargo.toml | 4 ++-- storage-proofs/porep/Cargo.toml | 4 ++-- storage-proofs/post/Cargo.toml | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fil-proofs-tooling/Cargo.toml b/fil-proofs-tooling/Cargo.toml index 77a898197..142e5f4a1 100644 --- a/fil-proofs-tooling/Cargo.toml +++ b/fil-proofs-tooling/Cargo.toml @@ -22,7 +22,7 @@ regex = "1.3.7" commandspec = "0.12.2" chrono = { version = "0.4.7", features = ["serde"] } memmap = "0.7.0" -bellperson = { git = "https://github.com/filecoin-project/bellperson", branch = "blstrs", default-features = false } +bellperson = { git = "https://github.com/filecoin-project/bellperson", branch = "blstrs-9", default-features = false } rand = "0.7" tempfile = "3.0.8" cpu-time = "1.0.0" diff --git a/filecoin-proofs/Cargo.toml b/filecoin-proofs/Cargo.toml index fb0e4af97..54679093e 100644 --- a/filecoin-proofs/Cargo.toml +++ b/filecoin-proofs/Cargo.toml @@ -23,7 +23,7 @@ serde_json = "1.0" regex = "1.3.7" ff = { version = "0.2.3", package = "fff" } blake2b_simd = "0.5" -bellperson = { git = "https://github.com/filecoin-project/bellperson", branch = "blstrs", default-features = false } +bellperson = { git = "https://github.com/filecoin-project/bellperson", branch = "blstrs-9", default-features = false } clap = "2" log = "0.4.7" fil_logger = "0.1" @@ -41,7 +41,7 @@ sha2 = "0.9.1" typenum = "1.11.2" bitintr = "0.3.0" gperftools = { version = "0.2", optional = true } -phase2 = { git = "https://github.com/filecoin-project/phase2", branch = "blst", package = "phase21", default-features = false } +phase2 = { git = "https://github.com/filecoin-project/phase2", branch = "blstrs-9", package = "phase21", default-features = false } simplelog = "0.8.0" rand_chacha = "0.2.1" dialoguer = "0.7.1" diff --git a/storage-proofs/core/Cargo.toml b/storage-proofs/core/Cargo.toml index 8cb31a0e8..03981df78 100644 --- a/storage-proofs/core/Cargo.toml +++ b/storage-proofs/core/Cargo.toml @@ -30,7 +30,7 @@ blake2b_simd = "0.5" blake2s_simd = "0.5" toml = "0.5" ff = { version = "0.2.3", package = "fff" } -bellperson = { git = "https://github.com/filecoin-project/bellperson", branch = "blstrs", default-features = false } +bellperson = { git = "https://github.com/filecoin-project/bellperson", branch = "blstrs-9", default-features = false } serde_json = "1.0" log = "0.4.7" rand_chacha = "0.2.1" @@ -38,7 +38,7 @@ hex = "0.4.0" generic-array = "0.14.4" anyhow = "1.0.23" thiserror = "1.0.6" -neptune = { git = "https://github.com/filecoin-project/neptune", branch = "blst", default-features = false, features = ["gpu"] } +neptune = { git = "https://github.com/filecoin-project/neptune", branch = "blstrs-9", default-features = false, features = ["gpu"] } cpu-time = { version = "1.0", optional = true } gperftools = { version = "0.2", optional = true } num_cpus = "1.10.1" diff --git a/storage-proofs/porep/Cargo.toml b/storage-proofs/porep/Cargo.toml index be839f29b..c253f18c7 100644 --- a/storage-proofs/porep/Cargo.toml +++ b/storage-proofs/porep/Cargo.toml @@ -23,12 +23,12 @@ rayon = "1.0.0" serde = { version = "1.0", features = ["derive"]} serde_json = "1.0" ff = { version = "0.2.3", package = "fff" } -bellperson = { git = "https://github.com/filecoin-project/bellperson", branch = "blstrs", default-features = false } +bellperson = { git = "https://github.com/filecoin-project/bellperson", branch = "blstrs-9", default-features = false } log = "0.4.7" pretty_assertions = "0.6.1" generic-array = "0.14.4" anyhow = "1.0.23" -neptune = { git = "https://github.com/filecoin-project/neptune", branch = "blst", default-features = false, features = ["gpu"] } +neptune = { git = "https://github.com/filecoin-project/neptune", branch = "blstrs-9", default-features = false, features = ["gpu"] } num_cpus = "1.10.1" hex = "0.4.2" bincode = "1.1.2" diff --git a/storage-proofs/post/Cargo.toml b/storage-proofs/post/Cargo.toml index 400b7dacd..732fa6cb1 100644 --- a/storage-proofs/post/Cargo.toml +++ b/storage-proofs/post/Cargo.toml @@ -20,12 +20,12 @@ serde = { version = "1.0", features = ["derive"]} blake2b_simd = "0.5" blake2s_simd = "0.5" ff = { version = "0.2.3", package = "fff" } -bellperson = { git = "https://github.com/filecoin-project/bellperson", branch = "blstrs", default-features = false } +bellperson = { git = "https://github.com/filecoin-project/bellperson", branch = "blstrs-9", default-features = false } log = "0.4.7" hex = "0.4.0" generic-array = "0.14.4" anyhow = "1.0.23" -neptune = { git = "https://github.com/filecoin-project/neptune", branch = "blst", default-features = false, features = ["gpu"] } +neptune = { git = "https://github.com/filecoin-project/neptune", branch = "blstrs-9", default-features = false, features = ["gpu"] } num_cpus = "1.10.1" [dev-dependencies] From 5ae5c4704248f2cf3df81a1bf5b6576fd51c5240 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Wed, 28 Oct 2020 21:27:24 +0100 Subject: [PATCH 18/20] fix nightly compile for fil-proofs-tooling --- fil-proofs-tooling/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fil-proofs-tooling/Cargo.toml b/fil-proofs-tooling/Cargo.toml index 142e5f4a1..7d809aae2 100644 --- a/fil-proofs-tooling/Cargo.toml +++ b/fil-proofs-tooling/Cargo.toml @@ -27,12 +27,12 @@ rand = "0.7" tempfile = "3.0.8" cpu-time = "1.0.0" git2 = "0.13.6" -heim = { version = "0.1.0-beta.1", features = ["host", "memory", "cpu"] } +heim = { git = "https://github.com/heim-rs/heim", rev = "e22e235", features = ["host", "memory", "cpu"] } async-std = "1.6" blake2s_simd = "0.5.6" fil_logger = "0.1" log = "0.4.8" -uom = "0.28" +uom = "0.30" merkletree = "0.21.0" bincode = "1.1.2" anyhow = "1.0.23" From 2e9ff71ad49bb2317ddb7652d8bc004faba0f94a Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Thu, 29 Oct 2020 13:07:50 +0100 Subject: [PATCH 19/20] update to released versions of phase21 and bellperson --- fil-proofs-tooling/Cargo.toml | 2 +- filecoin-proofs/Cargo.toml | 4 ++-- storage-proofs/core/Cargo.toml | 2 +- storage-proofs/porep/Cargo.toml | 2 +- storage-proofs/post/Cargo.toml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fil-proofs-tooling/Cargo.toml b/fil-proofs-tooling/Cargo.toml index 7d809aae2..a56d1f537 100644 --- a/fil-proofs-tooling/Cargo.toml +++ b/fil-proofs-tooling/Cargo.toml @@ -22,7 +22,7 @@ regex = "1.3.7" commandspec = "0.12.2" chrono = { version = "0.4.7", features = ["serde"] } memmap = "0.7.0" -bellperson = { git = "https://github.com/filecoin-project/bellperson", branch = "blstrs-9", default-features = false } +bellperson = { version = "0.11", default-features = false } rand = "0.7" tempfile = "3.0.8" cpu-time = "1.0.0" diff --git a/filecoin-proofs/Cargo.toml b/filecoin-proofs/Cargo.toml index 54679093e..dddaf634d 100644 --- a/filecoin-proofs/Cargo.toml +++ b/filecoin-proofs/Cargo.toml @@ -23,7 +23,7 @@ serde_json = "1.0" regex = "1.3.7" ff = { version = "0.2.3", package = "fff" } blake2b_simd = "0.5" -bellperson = { git = "https://github.com/filecoin-project/bellperson", branch = "blstrs-9", default-features = false } +bellperson = { version = "0.11", default-features = false } clap = "2" log = "0.4.7" fil_logger = "0.1" @@ -41,7 +41,7 @@ sha2 = "0.9.1" typenum = "1.11.2" bitintr = "0.3.0" gperftools = { version = "0.2", optional = true } -phase2 = { git = "https://github.com/filecoin-project/phase2", branch = "blstrs-9", package = "phase21", default-features = false } +phase2 = { version = "0.10", package = "phase21", default-features = false } simplelog = "0.8.0" rand_chacha = "0.2.1" dialoguer = "0.7.1" diff --git a/storage-proofs/core/Cargo.toml b/storage-proofs/core/Cargo.toml index 03981df78..737c40be2 100644 --- a/storage-proofs/core/Cargo.toml +++ b/storage-proofs/core/Cargo.toml @@ -30,7 +30,7 @@ blake2b_simd = "0.5" blake2s_simd = "0.5" toml = "0.5" ff = { version = "0.2.3", package = "fff" } -bellperson = { git = "https://github.com/filecoin-project/bellperson", branch = "blstrs-9", default-features = false } +bellperson = { version = "0.11", default-features = false } serde_json = "1.0" log = "0.4.7" rand_chacha = "0.2.1" diff --git a/storage-proofs/porep/Cargo.toml b/storage-proofs/porep/Cargo.toml index c253f18c7..b26d07890 100644 --- a/storage-proofs/porep/Cargo.toml +++ b/storage-proofs/porep/Cargo.toml @@ -23,7 +23,7 @@ rayon = "1.0.0" serde = { version = "1.0", features = ["derive"]} serde_json = "1.0" ff = { version = "0.2.3", package = "fff" } -bellperson = { git = "https://github.com/filecoin-project/bellperson", branch = "blstrs-9", default-features = false } +bellperson = { version = "0.11", default-features = false } log = "0.4.7" pretty_assertions = "0.6.1" generic-array = "0.14.4" diff --git a/storage-proofs/post/Cargo.toml b/storage-proofs/post/Cargo.toml index 732fa6cb1..4fe8ae3d1 100644 --- a/storage-proofs/post/Cargo.toml +++ b/storage-proofs/post/Cargo.toml @@ -20,7 +20,7 @@ serde = { version = "1.0", features = ["derive"]} blake2b_simd = "0.5" blake2s_simd = "0.5" ff = { version = "0.2.3", package = "fff" } -bellperson = { git = "https://github.com/filecoin-project/bellperson", branch = "blstrs-9", default-features = false } +bellperson = { version = "0.11", default-features = false } log = "0.4.7" hex = "0.4.0" generic-array = "0.14.4" From 63657b0d4fc8d88a27f79197c5cddc312becda62 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Thu, 29 Oct 2020 17:36:34 +0100 Subject: [PATCH 20/20] update to released neptune --- storage-proofs/core/Cargo.toml | 2 +- storage-proofs/porep/Cargo.toml | 2 +- storage-proofs/post/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/storage-proofs/core/Cargo.toml b/storage-proofs/core/Cargo.toml index 737c40be2..a2d0a9eda 100644 --- a/storage-proofs/core/Cargo.toml +++ b/storage-proofs/core/Cargo.toml @@ -38,7 +38,7 @@ hex = "0.4.0" generic-array = "0.14.4" anyhow = "1.0.23" thiserror = "1.0.6" -neptune = { git = "https://github.com/filecoin-project/neptune", branch = "blstrs-9", default-features = false, features = ["gpu"] } +neptune = { version = "2.1.0", default-features = false, features = ["gpu"] } cpu-time = { version = "1.0", optional = true } gperftools = { version = "0.2", optional = true } num_cpus = "1.10.1" diff --git a/storage-proofs/porep/Cargo.toml b/storage-proofs/porep/Cargo.toml index b26d07890..d66a6a289 100644 --- a/storage-proofs/porep/Cargo.toml +++ b/storage-proofs/porep/Cargo.toml @@ -28,7 +28,7 @@ log = "0.4.7" pretty_assertions = "0.6.1" generic-array = "0.14.4" anyhow = "1.0.23" -neptune = { git = "https://github.com/filecoin-project/neptune", branch = "blstrs-9", default-features = false, features = ["gpu"] } +neptune = { version = "2.1.0", default-features = false, features = ["gpu"] } num_cpus = "1.10.1" hex = "0.4.2" bincode = "1.1.2" diff --git a/storage-proofs/post/Cargo.toml b/storage-proofs/post/Cargo.toml index 4fe8ae3d1..bc35dc9f7 100644 --- a/storage-proofs/post/Cargo.toml +++ b/storage-proofs/post/Cargo.toml @@ -25,7 +25,7 @@ log = "0.4.7" hex = "0.4.0" generic-array = "0.14.4" anyhow = "1.0.23" -neptune = { git = "https://github.com/filecoin-project/neptune", branch = "blstrs-9", default-features = false, features = ["gpu"] } +neptune = { version = "2.1.0", default-features = false, features = ["gpu"] } num_cpus = "1.10.1" [dev-dependencies]