diff --git a/rust/Cargo.lock b/rust/Cargo.lock index d606e0de..38d26589 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -149,7 +149,7 @@ dependencies = [ "log", "memmap", "num_cpus", - "paired 0.21.0", + "paired", "rand 0.7.3", "rand_core 0.5.1", "rayon", @@ -271,17 +271,16 @@ checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" [[package]] name = "bls-signatures" -version = "0.6.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "863020d4fead1c6090d754cf542cd723c124859543f595c65e8c6f11377a4223" +checksum = "c304bf630458ef603e5a98c430562aa40ea50f1acedb8ecf2366fe3f73919d71" dependencies = [ + "blst", + "blstrs", "fff", "groupy", - "hkdf 0.8.0", - "paired 0.20.1", "rand_core 0.5.1", "rayon", - "sha2ni", "thiserror", ] @@ -298,9 +297,9 @@ dependencies = [ [[package]] name = "blstrs" -version = "0.1.0" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a4284735e22f7104c7983d95ad876aa1447c7be815080190ff32ba169c9fca0" +checksum = "0b109d2bfceb784992223b60cd6f631081a99d7f84c195b4a26611343dee7bef" dependencies = [ "blst", "fff", @@ -640,16 +639,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "crypto-mac" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" -dependencies = [ - "generic-array 0.12.3", - "subtle 1.0.0", -] - [[package]] name = "crypto-mac" version = "0.10.0" @@ -657,7 +646,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4857fd85a0c34b3c3297875b747c1e02e06b6a0ea32dd892d8192b9ce0813ea6" dependencies = [ "generic-array 0.14.4", - "subtle 2.3.0", + "subtle", ] [[package]] @@ -898,7 +887,7 @@ dependencies = [ "num-complex", "num-traits 0.2.14", "ocl-core-vector", - "rustc_version 0.1.7", + "rustc_version", ] [[package]] @@ -919,6 +908,7 @@ dependencies = [ "anyhow", "bellperson", "bls-signatures", + "blstrs", "byteorder 1.3.4", "cbindgen", "drop_struct_macro_derive", @@ -926,6 +916,7 @@ dependencies = [ "ffi-toolkit", "fil_logger", "filecoin-proofs-api", + "groupy", "libc", "log", "rand 0.7.3", @@ -1270,16 +1261,6 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" -[[package]] -name = "hkdf" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fa08a006102488bd9cd5b8013aabe84955cf5ae22e304c2caf655b633aefae3" -dependencies = [ - "digest 0.8.1", - "hmac 0.7.1", -] - [[package]] name = "hkdf" version = "0.10.0" @@ -1287,17 +1268,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51ab2f639c231793c5f6114bdb9bbe50a7dbbfcd7c7c6bd8475dec2d991e964f" dependencies = [ "digest 0.9.0", - "hmac 0.10.1", -] - -[[package]] -name = "hmac" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" -dependencies = [ - "crypto-mac 0.7.0", - "digest 0.8.1", + "hmac", ] [[package]] @@ -1306,7 +1277,7 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" dependencies = [ - "crypto-mac 0.10.0", + "crypto-mac", "digest 0.9.0", ] @@ -1495,9 +1466,6 @@ name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -dependencies = [ - "spin", -] [[package]] name = "lexical-core" @@ -1920,21 +1888,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "paired" -version = "0.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953ae957e986289a03f1407ce9c88f19e8280e8106d5498a364e3e5b60b1b9fc" -dependencies = [ - "blake2b_simd", - "byteorder 1.3.4", - "digest 0.8.1", - "fff", - "groupy", - "hkdf 0.8.0", - "rand_core 0.5.1", -] - [[package]] name = "paired" version = "0.21.0" @@ -1946,7 +1899,7 @@ dependencies = [ "digest 0.9.0", "fff", "groupy", - "hkdf 0.10.0", + "hkdf", "rand_core 0.5.1", "serde", ] @@ -2230,17 +2183,6 @@ dependencies = [ "rand_core 0.5.1", ] -[[package]] -name = "raw-cpuid" -version = "7.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4a349ca83373cfa5d6dbb66fd76e58b2cca08da71a5f6400de0a0a6a9bceeaf" -dependencies = [ - "bitflags 1.2.1", - "cc", - "rustc_version 0.2.3", -] - [[package]] name = "rayon" version = "1.5.0" @@ -2397,16 +2339,7 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084" dependencies = [ - "semver 0.1.20", -] - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver 0.9.0", + "semver", ] [[package]] @@ -2460,21 +2393,6 @@ version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4f410fedcf71af0345d7607d246e7ad15faaadd49d240ee3b24e5dc21a820ac" -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - [[package]] name = "serde" version = "1.0.117" @@ -2552,20 +2470,6 @@ dependencies = [ "cc", ] -[[package]] -name = "sha2ni" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ce234f44a9c36fb84a168d4201b596d800e170aaa966a68857058cbe2d041a3" -dependencies = [ - "block-buffer 0.7.3", - "digest 0.8.1", - "fake-simd", - "lazy_static", - "opaque-debug 0.2.3", - "raw-cpuid", -] - [[package]] name = "sha2raw" version = "2.0.0" @@ -2610,12 +2514,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - [[package]] name = "static_assertions" version = "1.1.0" @@ -2761,12 +2659,6 @@ dependencies = [ "syn 1.0.48", ] -[[package]] -name = "subtle" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" - [[package]] name = "subtle" version = "2.3.0" diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 1a3bd4a8..a4e4560b 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -17,11 +17,13 @@ publish = false crate-type = ["rlib", "staticlib"] [dependencies] -bls-signatures = "0.6.0" +bls-signatures = { version = "0.7.0", default-features = false, features = ["blst"] } +blstrs = { version = "0.1.2" } byteorder = "1.2" drop_struct_macro_derive = "0.4.0" ff = { version = "0.2.1", package = "fff" } ffi-toolkit = "0.4.0" +groupy = "0.3.0" libc = "0.2.58" log = "0.4.7" fil_logger = "0.1.0" @@ -47,4 +49,5 @@ tempfile = "3.0.8" [features] default = ["pairing"] pairing = ["filecoin-proofs-api/pairing", "bellperson/pairing"] -blst = ["filecoin-proofs-api/blst", "bellperson/blst"] \ No newline at end of file +blst = ["filecoin-proofs-api/blst", "bellperson/blst"] + diff --git a/rust/src/bls/api.rs b/rust/src/bls/api.rs index b1f542df..3f4ab2ef 100644 --- a/rust/src/bls/api.rs +++ b/rust/src/bls/api.rs @@ -1,12 +1,12 @@ use std::slice::from_raw_parts; use bls_signatures::{ - aggregate as aggregate_sig, - groupy::{CurveAffine, CurveProjective, EncodedPoint, GroupDecodingError}, - hash as hash_sig, - paired::bls12_381::{G2Affine, G2Compressed}, - verify as verify_sig, PrivateKey, PublicKey, Serialize, Signature, + aggregate as aggregate_sig, hash as hash_sig, verify as verify_sig, + verify_messages as verify_messages_sig, PrivateKey, PublicKey, Serialize, Signature, }; +use blstrs::{G2Affine, G2Compressed}; +use groupy::{CurveAffine, CurveProjective, EncodedPoint, GroupDecodingError}; + use rand::rngs::OsRng; use rand::SeedableRng; use rand_chacha::ChaChaRng; @@ -177,7 +177,7 @@ pub unsafe extern "C" fn fil_verify( verify_sig(&signature, digests.as_slice(), public_keys.as_slice()) as libc::c_int } -/// Verify that a signature is the aggregated signature of the hhashed messages +/// Verify that a signature is the aggregated signature of the hashed messages /// /// # Arguments /// @@ -219,11 +219,6 @@ pub unsafe extern "C" fn fil_hash_verify( return 0; } - let digests: Vec<_> = messages - .into_par_iter() - .map(|message: &[u8]| hash_sig(message)) - .collect::>(); - let public_keys: Vec<_> = try_ffi!( raw_public_keys .par_chunks(PUBLIC_KEY_BYTES) @@ -232,7 +227,7 @@ pub unsafe extern "C" fn fil_hash_verify( 0 ); - verify_sig(&signature, &digests, &public_keys) as libc::c_int + verify_messages_sig(&signature, &messages, &public_keys) as libc::c_int } /// Generate a new private key @@ -427,8 +422,8 @@ mod tests { .inner; assert_eq!( [ - 115, 245, 77, 209, 4, 57, 40, 107, 10, 153, 141, 16, 153, 172, 85, 197, 125, - 163, 35, 217, 108, 241, 64, 235, 231, 220, 131, 1, 77, 253, 176, 19 + 56, 13, 181, 159, 37, 1, 12, 96, 45, 77, 254, 118, 103, 235, 218, 176, 220, + 241, 142, 119, 206, 233, 83, 35, 26, 15, 118, 198, 192, 120, 179, 52 ], private_key, );