From 468c149820d3083486a5f330af5955fe595ca597 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Mon, 5 Oct 2020 16:01:17 +0200 Subject: [PATCH] remove fil-blst dependency --- filecoin-proofs/src/api/post.rs | 41 +-------------- filecoin-proofs/src/api/seal.rs | 26 +--------- 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(+), 135 deletions(-) diff --git a/filecoin-proofs/src/api/post.rs b/filecoin-proofs/src/api/post.rs index c72574fe4f..6afc3c7b51 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,25 +623,7 @@ pub fn verify_winning_post( k: None, }; - let use_fil_blst = settings::SETTINGS - .lock() - .expect("use_fil_blst settings lock failure") - .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)?; @@ -1000,25 +981,7 @@ pub fn verify_window_post( k: None, }; - let use_fil_blst = settings::SETTINGS - .lock() - .expect("use_fil_blst settings lock failure") - .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 73358b7398..8dab0b7150 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,30 +608,7 @@ pub fn verify_seal( k: None, }; - let use_fil_blst = settings::SETTINGS - .lock() - .expect("use_fil_blst settings lock failure") - .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 be206bd78e..39ed146370 100644 --- a/rust-fil-proofs.config.toml.sample +++ b/rust-fil-proofs.config.toml.sample @@ -34,8 +34,5 @@ rows_to_discard = 2 # Window size for pedersen hashing. pedersen_hash_exp_window_size = 16 -# 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 04ab5382d2..93c1d5f0db 100644 --- a/storage-proofs/core/Cargo.toml +++ b/storage-proofs/core/Cargo.toml @@ -43,7 +43,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 679e4941ac..a495fded7e 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 86d7415611..350e595315 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 48de666f3b..499f986876 100644 --- a/storage-proofs/core/src/settings.rs +++ b/storage-proofs/core/src/settings.rs @@ -29,7 +29,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, } @@ -52,7 +51,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, } }