diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index cf55d9a28..5f76fb061 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -3,45 +3,60 @@ name: Rust on: [push, pull_request] jobs: + lint: + name: Lint + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - uses: actions-rs/toolchain@v1 + with: + toolchain: 1.37.0 + override: true + + # Ensure all code has been formatted with rustfmt + - run: rustup component add rustfmt + - name: Check formatting + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check --color always + test: name: Test on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, windows-latest] - - steps: - - uses: actions/checkout@v1 - - name: Check formatting - run: cargo fmt --all -- --check - - name: Build - run: cargo build --verbose --release --all - - name: Run tests - run: cargo test --verbose --release --all - - name: Run slow tests - run: cargo test --verbose --release --all -- --ignored - - macOS: - name: Test on macOS-latest - runs-on: macOS-latest + os: [ubuntu-latest, windows-latest, macOS-latest] steps: - - name: Install Rust - run: curl https://sh.rustup.rs -sSf | sh -s -- -y - - name: Install rustfmt - run: $HOME/.cargo/bin/rustup component add rustfmt - - uses: actions/checkout@v1 - - name: Check formatting - run: $HOME/.cargo/bin/cargo fmt --all -- --check - - name: Build - run: $HOME/.cargo/bin/cargo build --verbose --release --all - - name: Run tests - run: $HOME/.cargo/bin/cargo test --verbose --release --all - - name: Run slow tests - run: $HOME/.cargo/bin/cargo test --verbose --release --all -- --ignored + - uses: actions/checkout@v1 + - uses: actions-rs/toolchain@v1 + with: + toolchain: 1.37.0 + override: true + - name: cargo fetch + uses: actions-rs/cargo@v1 + with: + command: fetch + - name: Build tests + uses: actions-rs/cargo@v1 + with: + command: build + args: --verbose --release --all --tests + - name: Run tests + uses: actions-rs/cargo@v1 + with: + command: test + args: --verbose --release --all + - name: Run slow tests + uses: actions-rs/cargo@v1 + with: + command: test + args: --verbose --release --all -- --ignored doc-links: - name: Check intra-doc links + name: Nightly lint runs-on: ubuntu-latest steps: @@ -50,7 +65,22 @@ jobs: with: toolchain: nightly override: true - - uses: actions-rs/cargo@v1 + - name: cargo fetch + uses: actions-rs/cargo@v1 + with: + command: fetch + + # Ensure intra-documentation links all resolve correctly + # Requires #![deny(intra_doc_link_resolution_failure)] in crates. + - name: Check intra-doc links + uses: actions-rs/cargo@v1 with: command: doc - args: --document-private-items + args: --all --document-private-items + + # Build benchmarks to prevent bitrot + - name: Build benchmarks + uses: actions-rs/cargo@v1 + with: + command: build + args: --verbose --all --benches diff --git a/Cargo.lock b/Cargo.lock index 4dd785143..7a33a24e5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -54,19 +54,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "bellman" -version = "0.1.0" +version = "0.2.0" dependencies = [ "bit-vec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "blake2s_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "ff 0.4.0", + "ff 0.5.0", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "group 0.1.0", + "group 0.2.0", "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "pairing 0.14.2", + "pairing 0.15.0", "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -251,16 +251,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "ff" -version = "0.4.0" +version = "0.5.0" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "ff_derive 0.3.0", + "ff_derive 0.4.0", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "ff_derive" -version = "0.3.0" +version = "0.4.0" dependencies = [ "num-bigint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", @@ -316,9 +316,9 @@ dependencies = [ [[package]] name = "group" -version = "0.1.0" +version = "0.2.0" dependencies = [ - "ff 0.4.0", + "ff 0.5.0", "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -357,19 +357,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "librustzcash" -version = "0.1.0" +version = "0.2.0" dependencies = [ - "bellman 0.1.0", + "bellman 0.2.0", "blake2b_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", "blake2s_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "ff 0.4.0", + "ff 0.5.0", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "pairing 0.14.2", + "pairing 0.15.0", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "zcash_primitives 0.0.0", - "zcash_proofs 0.0.0", + "zcash_primitives 0.1.0", + "zcash_proofs 0.1.0", ] [[package]] @@ -435,11 +435,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "pairing" -version = "0.14.2" +version = "0.15.0" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "ff 0.4.0", - "group 0.1.0", + "ff 0.5.0", + "group 0.2.0", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -603,31 +603,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "zcash_client_backend" -version = "0.0.0" +version = "0.1.0" dependencies = [ "bech32 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "pairing 0.14.2", + "pairing 0.15.0", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "zcash_primitives 0.0.0", + "zcash_primitives 0.1.0", ] [[package]] name = "zcash_primitives" -version = "0.0.0" +version = "0.1.0" dependencies = [ "aes 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "blake2b_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", "blake2s_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "crypto_api_chachapoly 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "ff 0.4.0", + "ff 0.5.0", "fpe 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "pairing 0.14.2", + "pairing 0.15.0", "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -636,17 +636,17 @@ dependencies = [ [[package]] name = "zcash_proofs" -version = "0.0.0" +version = "0.1.0" dependencies = [ - "bellman 0.1.0", + "bellman 0.2.0", "blake2b_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "directories 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "ff 0.4.0", - "pairing 0.14.2", + "ff 0.5.0", + "pairing 0.15.0", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "zcash_primitives 0.0.0", + "zcash_primitives 0.1.0", ] [metadata] diff --git a/bellman/Cargo.toml b/bellman/Cargo.toml index 3b2a46fca..4f125b488 100644 --- a/bellman/Cargo.toml +++ b/bellman/Cargo.toml @@ -7,19 +7,19 @@ homepage = "https://github.com/ebfull/bellman" license = "MIT/Apache-2.0" name = "bellman" repository = "https://github.com/ebfull/bellman" -version = "0.1.0" +version = "0.2.0" edition = "2018" [dependencies] bit-vec = "0.4.4" blake2s_simd = "0.5" -ff = { path = "../ff" } +ff = { version = "0.5.0", path = "../ff" } futures = "0.1" futures-cpupool = { version = "0.1", optional = true } -group = { path = "../group" } +group = { version = "0.2.0", path = "../group" } num_cpus = { version = "1", optional = true } crossbeam = { version = "0.7", optional = true } -pairing = { path = "../pairing", optional = true } +pairing = { version = "0.15.0", path = "../pairing", optional = true } rand_core = "0.5" byteorder = "1" @@ -38,3 +38,6 @@ default = ["groth16", "multicore"] name = "mimc" path = "tests/mimc.rs" required-features = ["groth16"] + +[badges] +maintenance = { status = "actively-developed" } diff --git a/ff/Cargo.toml b/ff/Cargo.toml index b83258167..9ac1f1e9a 100644 --- a/ff/Cargo.toml +++ b/ff/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ff" -version = "0.4.0" +version = "0.5.0" authors = ["Sean Bowe "] description = "Library for building and interfacing with finite fields" readme = "README.md" @@ -12,9 +12,12 @@ edition = "2018" [dependencies] byteorder = "1" -ff_derive = { version = "0.3.0", path = "ff_derive", optional = true } +ff_derive = { version = "0.4.0", path = "ff_derive", optional = true } rand_core = "0.5" [features] default = [] derive = ["ff_derive"] + +[badges] +maintenance = { status = "actively-developed" } diff --git a/ff/ff_derive/Cargo.toml b/ff/ff_derive/Cargo.toml index 18ac1bc66..88ba23e2b 100644 --- a/ff/ff_derive/Cargo.toml +++ b/ff/ff_derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ff_derive" -version = "0.3.0" +version = "0.4.0" authors = ["Sean Bowe "] description = "Procedural macro library used to build custom prime field implementations" documentation = "https://docs.rs/ff/" @@ -19,3 +19,6 @@ num-integer = "0.1" proc-macro2 = "1" quote = "1" syn = "1" + +[badges] +maintenance = { status = "passively-maintained" } diff --git a/group/Cargo.toml b/group/Cargo.toml index f27eb3fd1..03c172f9d 100644 --- a/group/Cargo.toml +++ b/group/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "group" -version = "0.1.0" +version = "0.2.0" authors = [ "Sean Bowe ", "Jack Grigg ", @@ -15,6 +15,9 @@ repository = "https://github.com/ebfull/group" edition = "2018" [dependencies] -ff = { path = "../ff" } +ff = { version = "0.5.0", path = "../ff" } rand = "0.7" rand_xorshift = "0.2" + +[badges] +maintenance = { status = "actively-developed" } diff --git a/librustzcash/Cargo.toml b/librustzcash/Cargo.toml index 567bf7c84..432222b00 100644 --- a/librustzcash/Cargo.toml +++ b/librustzcash/Cargo.toml @@ -1,13 +1,17 @@ [package] name = "librustzcash" -version = "0.1.0" +description = "Rust FFI used by the zcashd binary. Not an official API." +version = "0.2.0" authors = [ "Sean Bowe ", "Jack Grigg ", "Jay Graber ", "Simon Liu " ] +homepage = "https://github.com/zcash/librustzcash" +repository = "https://github.com/zcash/librustzcash" readme = "README.md" +license = "MIT OR Apache-2.0" edition = "2018" [lib] @@ -16,14 +20,17 @@ path = "src/rustzcash.rs" crate-type = ["staticlib"] [dependencies] -bellman = { path = "../bellman" } +bellman = { version = "0.2.0", path = "../bellman" } blake2b_simd = "0.5" blake2s_simd = "0.5" -ff = { path = "../ff" } +ff = { version = "0.5.0", path = "../ff" } libc = "0.2" -pairing = { path = "../pairing" } +pairing = { version = "0.15.0", path = "../pairing" } lazy_static = "1" byteorder = "1" rand_core = "0.5.1" -zcash_primitives = { path = "../zcash_primitives" } -zcash_proofs = { path = "../zcash_proofs" } +zcash_primitives = { version = "0.1.0", path = "../zcash_primitives" } +zcash_proofs = { version = "0.1.0", path = "../zcash_proofs" } + +[badges] +maintenance = { status = "deprecated" } diff --git a/pairing/Cargo.toml b/pairing/Cargo.toml index 1801ffd36..1c59855e7 100644 --- a/pairing/Cargo.toml +++ b/pairing/Cargo.toml @@ -2,7 +2,7 @@ name = "pairing" # Remember to change version string in README.md. -version = "0.14.2" +version = "0.15.0" authors = [ "Sean Bowe ", "Jack Grigg ", @@ -18,8 +18,8 @@ edition ="2018" [dependencies] byteorder = "1" -ff = { path = "../ff", features = ["derive"] } -group = { path = "../group" } +ff = { version = "0.5.0", path = "../ff", features = ["derive"] } +group = { version = "0.2.0", path = "../group" } rand_core = "0.5" [dev-dependencies] @@ -29,3 +29,6 @@ rand_xorshift = "0.2" unstable-features = ["expose-arith"] expose-arith = [] default = [] + +[badges] +maintenance = { status = "actively-developed" } diff --git a/pairing/benches/bls12_381/ec.rs b/pairing/benches/bls12_381/ec.rs index d8f6618ca..04bed0d5b 100644 --- a/pairing/benches/bls12_381/ec.rs +++ b/pairing/benches/bls12_381/ec.rs @@ -1,6 +1,8 @@ mod g1 { - use rand::{Rand, SeedableRng, XorShiftRng}; + use rand_core::SeedableRng; + use rand_xorshift::XorShiftRng; + use ff::Field; use group::CurveProjective; use pairing::bls12_381::*; @@ -8,10 +10,13 @@ mod g1 { fn bench_g1_mul_assign(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, + 0xbc, 0xe5, + ]); let v: Vec<(G1, Fr)> = (0..SAMPLES) - .map(|_| (G1::rand(&mut rng), Fr::rand(&mut rng))) + .map(|_| (G1::random(&mut rng), Fr::random(&mut rng))) .collect(); let mut count = 0; @@ -27,10 +32,13 @@ mod g1 { fn bench_g1_add_assign(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, + 0xbc, 0xe5, + ]); let v: Vec<(G1, G1)> = (0..SAMPLES) - .map(|_| (G1::rand(&mut rng), G1::rand(&mut rng))) + .map(|_| (G1::random(&mut rng), G1::random(&mut rng))) .collect(); let mut count = 0; @@ -46,10 +54,13 @@ mod g1 { fn bench_g1_add_assign_mixed(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, + 0xbc, 0xe5, + ]); let v: Vec<(G1, G1Affine)> = (0..SAMPLES) - .map(|_| (G1::rand(&mut rng), G1::rand(&mut rng).into())) + .map(|_| (G1::random(&mut rng), G1::random(&mut rng).into())) .collect(); let mut count = 0; @@ -63,8 +74,10 @@ mod g1 { } mod g2 { - use rand::{Rand, SeedableRng, XorShiftRng}; + use rand_core::SeedableRng; + use rand_xorshift::XorShiftRng; + use ff::Field; use group::CurveProjective; use pairing::bls12_381::*; @@ -72,10 +85,13 @@ mod g2 { fn bench_g2_mul_assign(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, + 0xbc, 0xe5, + ]); let v: Vec<(G2, Fr)> = (0..SAMPLES) - .map(|_| (G2::rand(&mut rng), Fr::rand(&mut rng))) + .map(|_| (G2::random(&mut rng), Fr::random(&mut rng))) .collect(); let mut count = 0; @@ -91,10 +107,13 @@ mod g2 { fn bench_g2_add_assign(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, + 0xbc, 0xe5, + ]); let v: Vec<(G2, G2)> = (0..SAMPLES) - .map(|_| (G2::rand(&mut rng), G2::rand(&mut rng))) + .map(|_| (G2::random(&mut rng), G2::random(&mut rng))) .collect(); let mut count = 0; @@ -110,10 +129,13 @@ mod g2 { fn bench_g2_add_assign_mixed(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, + 0xbc, 0xe5, + ]); let v: Vec<(G2, G2Affine)> = (0..SAMPLES) - .map(|_| (G2::rand(&mut rng), G2::rand(&mut rng).into())) + .map(|_| (G2::random(&mut rng), G2::random(&mut rng).into())) .collect(); let mut count = 0; diff --git a/pairing/benches/bls12_381/fq.rs b/pairing/benches/bls12_381/fq.rs index 053a10cc8..b66332205 100644 --- a/pairing/benches/bls12_381/fq.rs +++ b/pairing/benches/bls12_381/fq.rs @@ -1,4 +1,5 @@ -use rand::{Rand, SeedableRng, XorShiftRng}; +use rand_core::SeedableRng; +use rand_xorshift::XorShiftRng; use ff::{Field, PrimeField, PrimeFieldRepr, SqrtField}; use pairing::bls12_381::*; @@ -7,12 +8,15 @@ use pairing::bls12_381::*; fn bench_fq_repr_add_nocarry(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); let v: Vec<(FqRepr, FqRepr)> = (0..SAMPLES) .map(|_| { - let mut tmp1 = FqRepr::rand(&mut rng); - let mut tmp2 = FqRepr::rand(&mut rng); + let mut tmp1 = Fq::random(&mut rng).into_repr(); + let mut tmp2 = Fq::random(&mut rng).into_repr(); // Shave a few bits off to avoid overflow. for _ in 0..3 { tmp1.div2(); @@ -35,11 +39,14 @@ fn bench_fq_repr_add_nocarry(b: &mut ::test::Bencher) { fn bench_fq_repr_sub_noborrow(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); let v: Vec<(FqRepr, FqRepr)> = (0..SAMPLES) .map(|_| { - let tmp1 = FqRepr::rand(&mut rng); + let tmp1 = Fq::random(&mut rng).into_repr(); let mut tmp2 = tmp1; // Ensure tmp2 is smaller than tmp1. for _ in 0..10 { @@ -62,9 +69,14 @@ fn bench_fq_repr_sub_noborrow(b: &mut ::test::Bencher) { fn bench_fq_repr_num_bits(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); - let v: Vec = (0..SAMPLES).map(|_| FqRepr::rand(&mut rng)).collect(); + let v: Vec = (0..SAMPLES) + .map(|_| Fq::random(&mut rng).into_repr()) + .collect(); let mut count = 0; b.iter(|| { @@ -78,9 +90,14 @@ fn bench_fq_repr_num_bits(b: &mut ::test::Bencher) { fn bench_fq_repr_mul2(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); - let v: Vec = (0..SAMPLES).map(|_| FqRepr::rand(&mut rng)).collect(); + let v: Vec = (0..SAMPLES) + .map(|_| Fq::random(&mut rng).into_repr()) + .collect(); let mut count = 0; b.iter(|| { @@ -95,9 +112,14 @@ fn bench_fq_repr_mul2(b: &mut ::test::Bencher) { fn bench_fq_repr_div2(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); - let v: Vec = (0..SAMPLES).map(|_| FqRepr::rand(&mut rng)).collect(); + let v: Vec = (0..SAMPLES) + .map(|_| Fq::random(&mut rng).into_repr()) + .collect(); let mut count = 0; b.iter(|| { @@ -112,10 +134,13 @@ fn bench_fq_repr_div2(b: &mut ::test::Bencher) { fn bench_fq_add_assign(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); let v: Vec<(Fq, Fq)> = (0..SAMPLES) - .map(|_| (Fq::rand(&mut rng), Fq::rand(&mut rng))) + .map(|_| (Fq::random(&mut rng), Fq::random(&mut rng))) .collect(); let mut count = 0; @@ -131,10 +156,13 @@ fn bench_fq_add_assign(b: &mut ::test::Bencher) { fn bench_fq_sub_assign(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); let v: Vec<(Fq, Fq)> = (0..SAMPLES) - .map(|_| (Fq::rand(&mut rng), Fq::rand(&mut rng))) + .map(|_| (Fq::random(&mut rng), Fq::random(&mut rng))) .collect(); let mut count = 0; @@ -150,10 +178,13 @@ fn bench_fq_sub_assign(b: &mut ::test::Bencher) { fn bench_fq_mul_assign(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); let v: Vec<(Fq, Fq)> = (0..SAMPLES) - .map(|_| (Fq::rand(&mut rng), Fq::rand(&mut rng))) + .map(|_| (Fq::random(&mut rng), Fq::random(&mut rng))) .collect(); let mut count = 0; @@ -169,9 +200,12 @@ fn bench_fq_mul_assign(b: &mut ::test::Bencher) { fn bench_fq_square(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); - let v: Vec = (0..SAMPLES).map(|_| Fq::rand(&mut rng)).collect(); + let v: Vec = (0..SAMPLES).map(|_| Fq::random(&mut rng)).collect(); let mut count = 0; b.iter(|| { @@ -186,9 +220,12 @@ fn bench_fq_square(b: &mut ::test::Bencher) { fn bench_fq_inverse(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); - let v: Vec = (0..SAMPLES).map(|_| Fq::rand(&mut rng)).collect(); + let v: Vec = (0..SAMPLES).map(|_| Fq::random(&mut rng)).collect(); let mut count = 0; b.iter(|| { @@ -201,9 +238,12 @@ fn bench_fq_inverse(b: &mut ::test::Bencher) { fn bench_fq_negate(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); - let v: Vec = (0..SAMPLES).map(|_| Fq::rand(&mut rng)).collect(); + let v: Vec = (0..SAMPLES).map(|_| Fq::random(&mut rng)).collect(); let mut count = 0; b.iter(|| { @@ -218,11 +258,14 @@ fn bench_fq_negate(b: &mut ::test::Bencher) { fn bench_fq_sqrt(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); let v: Vec = (0..SAMPLES) .map(|_| { - let mut tmp = Fq::rand(&mut rng); + let mut tmp = Fq::random(&mut rng); tmp.square(); tmp }) @@ -239,9 +282,12 @@ fn bench_fq_sqrt(b: &mut ::test::Bencher) { fn bench_fq_into_repr(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); - let v: Vec = (0..SAMPLES).map(|_| Fq::rand(&mut rng)).collect(); + let v: Vec = (0..SAMPLES).map(|_| Fq::random(&mut rng)).collect(); let mut count = 0; b.iter(|| { @@ -254,10 +300,13 @@ fn bench_fq_into_repr(b: &mut ::test::Bencher) { fn bench_fq_from_repr(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); let v: Vec = (0..SAMPLES) - .map(|_| Fq::rand(&mut rng).into_repr()) + .map(|_| Fq::random(&mut rng).into_repr()) .collect(); let mut count = 0; diff --git a/pairing/benches/bls12_381/fq12.rs b/pairing/benches/bls12_381/fq12.rs index 84daca2f3..8bf0392db 100644 --- a/pairing/benches/bls12_381/fq12.rs +++ b/pairing/benches/bls12_381/fq12.rs @@ -1,4 +1,5 @@ -use rand::{Rand, SeedableRng, XorShiftRng}; +use rand_core::SeedableRng; +use rand_xorshift::XorShiftRng; use ff::Field; use pairing::bls12_381::*; @@ -7,10 +8,13 @@ use pairing::bls12_381::*; fn bench_fq12_add_assign(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); let v: Vec<(Fq12, Fq12)> = (0..SAMPLES) - .map(|_| (Fq12::rand(&mut rng), Fq12::rand(&mut rng))) + .map(|_| (Fq12::random(&mut rng), Fq12::random(&mut rng))) .collect(); let mut count = 0; @@ -26,10 +30,13 @@ fn bench_fq12_add_assign(b: &mut ::test::Bencher) { fn bench_fq12_sub_assign(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); let v: Vec<(Fq12, Fq12)> = (0..SAMPLES) - .map(|_| (Fq12::rand(&mut rng), Fq12::rand(&mut rng))) + .map(|_| (Fq12::random(&mut rng), Fq12::random(&mut rng))) .collect(); let mut count = 0; @@ -45,10 +52,13 @@ fn bench_fq12_sub_assign(b: &mut ::test::Bencher) { fn bench_fq12_mul_assign(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); let v: Vec<(Fq12, Fq12)> = (0..SAMPLES) - .map(|_| (Fq12::rand(&mut rng), Fq12::rand(&mut rng))) + .map(|_| (Fq12::random(&mut rng), Fq12::random(&mut rng))) .collect(); let mut count = 0; @@ -64,9 +74,12 @@ fn bench_fq12_mul_assign(b: &mut ::test::Bencher) { fn bench_fq12_squaring(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); - let v: Vec = (0..SAMPLES).map(|_| Fq12::rand(&mut rng)).collect(); + let v: Vec = (0..SAMPLES).map(|_| Fq12::random(&mut rng)).collect(); let mut count = 0; b.iter(|| { @@ -81,9 +94,12 @@ fn bench_fq12_squaring(b: &mut ::test::Bencher) { fn bench_fq12_inverse(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); - let v: Vec = (0..SAMPLES).map(|_| Fq12::rand(&mut rng)).collect(); + let v: Vec = (0..SAMPLES).map(|_| Fq12::random(&mut rng)).collect(); let mut count = 0; b.iter(|| { diff --git a/pairing/benches/bls12_381/fq2.rs b/pairing/benches/bls12_381/fq2.rs index 521b6ab98..028c42e53 100644 --- a/pairing/benches/bls12_381/fq2.rs +++ b/pairing/benches/bls12_381/fq2.rs @@ -1,4 +1,5 @@ -use rand::{Rand, SeedableRng, XorShiftRng}; +use rand_core::SeedableRng; +use rand_xorshift::XorShiftRng; use ff::{Field, SqrtField}; use pairing::bls12_381::*; @@ -7,10 +8,13 @@ use pairing::bls12_381::*; fn bench_fq2_add_assign(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); let v: Vec<(Fq2, Fq2)> = (0..SAMPLES) - .map(|_| (Fq2::rand(&mut rng), Fq2::rand(&mut rng))) + .map(|_| (Fq2::random(&mut rng), Fq2::random(&mut rng))) .collect(); let mut count = 0; @@ -26,10 +30,13 @@ fn bench_fq2_add_assign(b: &mut ::test::Bencher) { fn bench_fq2_sub_assign(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); let v: Vec<(Fq2, Fq2)> = (0..SAMPLES) - .map(|_| (Fq2::rand(&mut rng), Fq2::rand(&mut rng))) + .map(|_| (Fq2::random(&mut rng), Fq2::random(&mut rng))) .collect(); let mut count = 0; @@ -45,10 +52,13 @@ fn bench_fq2_sub_assign(b: &mut ::test::Bencher) { fn bench_fq2_mul_assign(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); let v: Vec<(Fq2, Fq2)> = (0..SAMPLES) - .map(|_| (Fq2::rand(&mut rng), Fq2::rand(&mut rng))) + .map(|_| (Fq2::random(&mut rng), Fq2::random(&mut rng))) .collect(); let mut count = 0; @@ -64,9 +74,12 @@ fn bench_fq2_mul_assign(b: &mut ::test::Bencher) { fn bench_fq2_squaring(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); - let v: Vec = (0..SAMPLES).map(|_| Fq2::rand(&mut rng)).collect(); + let v: Vec = (0..SAMPLES).map(|_| Fq2::random(&mut rng)).collect(); let mut count = 0; b.iter(|| { @@ -81,9 +94,12 @@ fn bench_fq2_squaring(b: &mut ::test::Bencher) { fn bench_fq2_inverse(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); - let v: Vec = (0..SAMPLES).map(|_| Fq2::rand(&mut rng)).collect(); + let v: Vec = (0..SAMPLES).map(|_| Fq2::random(&mut rng)).collect(); let mut count = 0; b.iter(|| { @@ -97,9 +113,12 @@ fn bench_fq2_inverse(b: &mut ::test::Bencher) { fn bench_fq2_sqrt(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); - let v: Vec = (0..SAMPLES).map(|_| Fq2::rand(&mut rng)).collect(); + let v: Vec = (0..SAMPLES).map(|_| Fq2::random(&mut rng)).collect(); let mut count = 0; b.iter(|| { diff --git a/pairing/benches/bls12_381/fr.rs b/pairing/benches/bls12_381/fr.rs index 13b0d0e85..9e767d8f3 100644 --- a/pairing/benches/bls12_381/fr.rs +++ b/pairing/benches/bls12_381/fr.rs @@ -1,4 +1,5 @@ -use rand::{Rand, SeedableRng, XorShiftRng}; +use rand_core::SeedableRng; +use rand_xorshift::XorShiftRng; use ff::{Field, PrimeField, PrimeFieldRepr, SqrtField}; use pairing::bls12_381::*; @@ -7,12 +8,15 @@ use pairing::bls12_381::*; fn bench_fr_repr_add_nocarry(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); let v: Vec<(FrRepr, FrRepr)> = (0..SAMPLES) .map(|_| { - let mut tmp1 = FrRepr::rand(&mut rng); - let mut tmp2 = FrRepr::rand(&mut rng); + let mut tmp1 = Fr::random(&mut rng).into_repr(); + let mut tmp2 = Fr::random(&mut rng).into_repr(); // Shave a few bits off to avoid overflow. for _ in 0..3 { tmp1.div2(); @@ -35,11 +39,14 @@ fn bench_fr_repr_add_nocarry(b: &mut ::test::Bencher) { fn bench_fr_repr_sub_noborrow(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); let v: Vec<(FrRepr, FrRepr)> = (0..SAMPLES) .map(|_| { - let tmp1 = FrRepr::rand(&mut rng); + let tmp1 = Fr::random(&mut rng).into_repr(); let mut tmp2 = tmp1; // Ensure tmp2 is smaller than tmp1. for _ in 0..10 { @@ -62,9 +69,14 @@ fn bench_fr_repr_sub_noborrow(b: &mut ::test::Bencher) { fn bench_fr_repr_num_bits(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); - let v: Vec = (0..SAMPLES).map(|_| FrRepr::rand(&mut rng)).collect(); + let v: Vec = (0..SAMPLES) + .map(|_| Fr::random(&mut rng).into_repr()) + .collect(); let mut count = 0; b.iter(|| { @@ -78,9 +90,14 @@ fn bench_fr_repr_num_bits(b: &mut ::test::Bencher) { fn bench_fr_repr_mul2(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); - let v: Vec = (0..SAMPLES).map(|_| FrRepr::rand(&mut rng)).collect(); + let v: Vec = (0..SAMPLES) + .map(|_| Fr::random(&mut rng).into_repr()) + .collect(); let mut count = 0; b.iter(|| { @@ -95,9 +112,14 @@ fn bench_fr_repr_mul2(b: &mut ::test::Bencher) { fn bench_fr_repr_div2(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); - let v: Vec = (0..SAMPLES).map(|_| FrRepr::rand(&mut rng)).collect(); + let v: Vec = (0..SAMPLES) + .map(|_| Fr::random(&mut rng).into_repr()) + .collect(); let mut count = 0; b.iter(|| { @@ -112,10 +134,13 @@ fn bench_fr_repr_div2(b: &mut ::test::Bencher) { fn bench_fr_add_assign(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); let v: Vec<(Fr, Fr)> = (0..SAMPLES) - .map(|_| (Fr::rand(&mut rng), Fr::rand(&mut rng))) + .map(|_| (Fr::random(&mut rng), Fr::random(&mut rng))) .collect(); let mut count = 0; @@ -131,10 +156,13 @@ fn bench_fr_add_assign(b: &mut ::test::Bencher) { fn bench_fr_sub_assign(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); let v: Vec<(Fr, Fr)> = (0..SAMPLES) - .map(|_| (Fr::rand(&mut rng), Fr::rand(&mut rng))) + .map(|_| (Fr::random(&mut rng), Fr::random(&mut rng))) .collect(); let mut count = 0; @@ -150,10 +178,13 @@ fn bench_fr_sub_assign(b: &mut ::test::Bencher) { fn bench_fr_mul_assign(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); let v: Vec<(Fr, Fr)> = (0..SAMPLES) - .map(|_| (Fr::rand(&mut rng), Fr::rand(&mut rng))) + .map(|_| (Fr::random(&mut rng), Fr::random(&mut rng))) .collect(); let mut count = 0; @@ -169,9 +200,12 @@ fn bench_fr_mul_assign(b: &mut ::test::Bencher) { fn bench_fr_square(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); - let v: Vec = (0..SAMPLES).map(|_| Fr::rand(&mut rng)).collect(); + let v: Vec = (0..SAMPLES).map(|_| Fr::random(&mut rng)).collect(); let mut count = 0; b.iter(|| { @@ -186,9 +220,12 @@ fn bench_fr_square(b: &mut ::test::Bencher) { fn bench_fr_inverse(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); - let v: Vec = (0..SAMPLES).map(|_| Fr::rand(&mut rng)).collect(); + let v: Vec = (0..SAMPLES).map(|_| Fr::random(&mut rng)).collect(); let mut count = 0; b.iter(|| { @@ -201,9 +238,12 @@ fn bench_fr_inverse(b: &mut ::test::Bencher) { fn bench_fr_negate(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); - let v: Vec = (0..SAMPLES).map(|_| Fr::rand(&mut rng)).collect(); + let v: Vec = (0..SAMPLES).map(|_| Fr::random(&mut rng)).collect(); let mut count = 0; b.iter(|| { @@ -218,11 +258,14 @@ fn bench_fr_negate(b: &mut ::test::Bencher) { fn bench_fr_sqrt(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); let v: Vec = (0..SAMPLES) .map(|_| { - let mut tmp = Fr::rand(&mut rng); + let mut tmp = Fr::random(&mut rng); tmp.square(); tmp }) @@ -239,9 +282,12 @@ fn bench_fr_sqrt(b: &mut ::test::Bencher) { fn bench_fr_into_repr(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); - let v: Vec = (0..SAMPLES).map(|_| Fr::rand(&mut rng)).collect(); + let v: Vec = (0..SAMPLES).map(|_| Fr::random(&mut rng)).collect(); let mut count = 0; b.iter(|| { @@ -254,10 +300,13 @@ fn bench_fr_into_repr(b: &mut ::test::Bencher) { fn bench_fr_from_repr(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); let v: Vec = (0..SAMPLES) - .map(|_| Fr::rand(&mut rng).into_repr()) + .map(|_| Fr::random(&mut rng).into_repr()) .collect(); let mut count = 0; diff --git a/pairing/benches/bls12_381/mod.rs b/pairing/benches/bls12_381/mod.rs index 96bcdd516..2c23c2a2e 100644 --- a/pairing/benches/bls12_381/mod.rs +++ b/pairing/benches/bls12_381/mod.rs @@ -4,8 +4,10 @@ mod fq12; mod fq2; mod fr; -use rand::{Rand, SeedableRng, XorShiftRng}; +use rand_core::SeedableRng; +use rand_xorshift::XorShiftRng; +use group::CurveProjective; use pairing::bls12_381::*; use pairing::{Engine, PairingCurveAffine}; @@ -13,9 +15,12 @@ use pairing::{Engine, PairingCurveAffine}; fn bench_pairing_g1_preparation(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); - let v: Vec = (0..SAMPLES).map(|_| G1::rand(&mut rng)).collect(); + let v: Vec = (0..SAMPLES).map(|_| G1::random(&mut rng)).collect(); let mut count = 0; b.iter(|| { @@ -29,9 +34,12 @@ fn bench_pairing_g1_preparation(b: &mut ::test::Bencher) { fn bench_pairing_g2_preparation(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); - let v: Vec = (0..SAMPLES).map(|_| G2::rand(&mut rng)).collect(); + let v: Vec = (0..SAMPLES).map(|_| G2::random(&mut rng)).collect(); let mut count = 0; b.iter(|| { @@ -45,13 +53,16 @@ fn bench_pairing_g2_preparation(b: &mut ::test::Bencher) { fn bench_pairing_miller_loop(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); let v: Vec<(G1Prepared, G2Prepared)> = (0..SAMPLES) .map(|_| { ( - G1Affine::from(G1::rand(&mut rng)).prepare(), - G2Affine::from(G2::rand(&mut rng)).prepare(), + G1Affine::from(G1::random(&mut rng)).prepare(), + G2Affine::from(G2::random(&mut rng)).prepare(), ) }) .collect(); @@ -68,13 +79,16 @@ fn bench_pairing_miller_loop(b: &mut ::test::Bencher) { fn bench_pairing_final_exponentiation(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); let v: Vec = (0..SAMPLES) .map(|_| { ( - G1Affine::from(G1::rand(&mut rng)).prepare(), - G2Affine::from(G2::rand(&mut rng)).prepare(), + G1Affine::from(G1::random(&mut rng)).prepare(), + G2Affine::from(G2::random(&mut rng)).prepare(), ) }) .map(|(ref p, ref q)| Bls12::miller_loop(&[(p, q)])) @@ -92,10 +106,13 @@ fn bench_pairing_final_exponentiation(b: &mut ::test::Bencher) { fn bench_pairing_full(b: &mut ::test::Bencher) { const SAMPLES: usize = 1000; - let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); let v: Vec<(G1, G2)> = (0..SAMPLES) - .map(|_| (G1::rand(&mut rng), G2::rand(&mut rng))) + .map(|_| (G1::random(&mut rng), G2::random(&mut rng))) .collect(); let mut count = 0; diff --git a/pairing/benches/pairing_benches.rs b/pairing/benches/pairing_benches.rs index d76e50b27..b083b4250 100644 --- a/pairing/benches/pairing_benches.rs +++ b/pairing/benches/pairing_benches.rs @@ -3,7 +3,8 @@ extern crate ff; extern crate group; extern crate pairing; -extern crate rand; +extern crate rand_core; +extern crate rand_xorshift; extern crate test; mod bls12_381; diff --git a/zcash_client_backend/Cargo.toml b/zcash_client_backend/Cargo.toml index 6199f2b49..7594630a3 100644 --- a/zcash_client_backend/Cargo.toml +++ b/zcash_client_backend/Cargo.toml @@ -1,17 +1,24 @@ [package] name = "zcash_client_backend" -version = "0.0.0" +description = "APIs for creating shielded Zcash light clients" +version = "0.1.0" authors = [ "Jack Grigg ", ] +homepage = "https://github.com/zcash/librustzcash" +repository = "https://github.com/zcash/librustzcash" readme = "README.md" +license = "MIT OR Apache-2.0" edition = "2018" [dependencies] bech32 = "0.7" -pairing = { path = "../pairing" } -zcash_primitives = { path = "../zcash_primitives" } +pairing = { version = "0.15.0", path = "../pairing" } +zcash_primitives = { version = "0.1.0", path = "../zcash_primitives" } [dev-dependencies] rand_core = "0.5" rand_xorshift = "0.2" + +[badges] +maintenance = { status = "actively-developed" } diff --git a/zcash_primitives/Cargo.toml b/zcash_primitives/Cargo.toml index 1b365e35a..c83ecf1ec 100644 --- a/zcash_primitives/Cargo.toml +++ b/zcash_primitives/Cargo.toml @@ -1,10 +1,14 @@ [package] name = "zcash_primitives" -version = "0.0.0" +description = "Rust implementations of the Zcash primitives" +version = "0.1.0" authors = [ "Jack Grigg ", ] +homepage = "https://github.com/zcash/librustzcash" +repository = "https://github.com/zcash/librustzcash" readme = "README.md" +license = "MIT OR Apache-2.0" edition = "2018" [dependencies] @@ -13,12 +17,12 @@ blake2b_simd = "0.5" blake2s_simd = "0.5" byteorder = "1" crypto_api_chachapoly = "0.2.1" -ff = { path = "../ff" } +ff = { version = "0.5.0", path = "../ff" } fpe = "0.2" hex = "0.3" lazy_static = "1" log = "0.4" -pairing = { path = "../pairing" } +pairing = { version = "0.15.0", path = "../pairing" } rand = "0.7" rand_core = "0.5.1" sha2 = "0.8" @@ -26,3 +30,6 @@ sha2 = "0.8" [dev-dependencies] hex-literal = "0.2" rand_xorshift = "0.2" + +[badges] +maintenance = { status = "actively-developed" } diff --git a/zcash_proofs/Cargo.toml b/zcash_proofs/Cargo.toml index 9d0772786..b9de0f76a 100644 --- a/zcash_proofs/Cargo.toml +++ b/zcash_proofs/Cargo.toml @@ -1,21 +1,25 @@ [package] name = "zcash_proofs" -version = "0.0.0" +description = "Zcash zk-SNARK circuits and proving APIs" +version = "0.1.0" authors = [ "Jack Grigg ", ] +homepage = "https://github.com/zcash/librustzcash" +repository = "https://github.com/zcash/librustzcash" readme = "README.md" +license = "MIT OR Apache-2.0" edition = "2018" [dependencies] -bellman = { path = "../bellman" } +bellman = { version = "0.2.0", path = "../bellman" } blake2b_simd = "0.5" byteorder = "1" directories = { version = "1", optional = true } -ff = { path = "../ff" } -pairing = { path = "../pairing" } +ff = { version = "0.5.0", path = "../ff" } +pairing = { version = "0.15.0", path = "../pairing" } rand_core = "0.5.1" -zcash_primitives = { path = "../zcash_primitives" } +zcash_primitives = { version = "0.1.0", path = "../zcash_primitives" } [dev-dependencies] rand_xorshift = "0.2" @@ -23,3 +27,6 @@ rand_xorshift = "0.2" [features] default = ["local-prover"] local-prover = ["directories"] + +[badges] +maintenance = { status = "actively-developed" }