feat: update dependencies

This commit is contained in:
Friedel Ziegelmayer 2019-12-11 00:48:19 +01:00 committed by GitHub
parent f220490a7a
commit 3042607c90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 73 additions and 35 deletions

View File

@ -1,6 +1,6 @@
language: rust
rust:
- 1.31.1
- 1.36.0
- stable
- beta
- nightly

View File

@ -19,7 +19,7 @@ features = ["std", "serde", "rand", "prime"]
[dependencies]
[dependencies.smallvec]
version = "0.6.7"
version = "1.0.0"
default-features = false
[dependencies.num-integer]
@ -36,7 +36,7 @@ default-features = false
[dependencies.rand]
optional = true
version = "0.6"
version = "0.7"
default-features = false
[dependencies.zeroize]
@ -51,7 +51,7 @@ version = "1.0"
default-features = false
[dependencies.libm]
version = "0.1.4"
version = "0.2.1"
[dependencies.lazy_static]
version = "1.2.0"
@ -65,9 +65,10 @@ version = "1.2.7"
default-features = false
[dev-dependencies]
rand_chacha = "0.1"
rand_xorshift = "0.1"
rand_isaac = "0.1"
rand_chacha = "0.2"
rand_xorshift = "0.2"
rand_isaac = "0.2"
rand = { version = "0.7", features = ["small_rng"] }
[dev-dependencies.serde_test]
version = "1.0"
@ -78,7 +79,7 @@ autocfg = "0.1.5"
[features]
default = ["std", "i128", "u64_digit"]
i128 = ["num-integer/i128", "num-traits/i128"]
std = ["num-integer/std", "num-traits/std", "smallvec/std", "rand/std", "serde/std"]
std = ["num-integer/std", "num-traits/std", "smallvec/write", "rand/std", "serde/std"]
u64_digit = []
prime = ["rand"]
nightly = ["rand/nightly"]

View File

@ -2,13 +2,14 @@
[![crate](https://img.shields.io/crates/v/num-bigint-dig.svg)](https://crates.io/crates/num-bigint-dig)
[![documentation](https://docs.rs/num-bigint-dig/badge.svg)](https://docs.rs/num-bigint-dig)
![minimum rustc 1.31](https://img.shields.io/badge/rustc-1.31+-red.svg)
![minimum rustc 1.36](https://img.shields.io/badge/rustc-1.36+-red.svg)
[![Travis status](https://travis-ci.org/dignifiedquire/num-bigint.svg?branch=master)](https://travis-ci.org/dignifiedquire/num-bigint)
Big integer types for Rust, `BigInt` and `BigUint`.
> **Warning** This is a fork of [`rust-num/num-bigint`](https://github.com/rust-num/num-bigint) with a focus on providing functionality, needed to implement cryptographic operations.
## Usage
Add this to your `Cargo.toml`:
@ -29,7 +30,7 @@ extern crate num_bigint_dig as num_bigint;
The `std` feature is enabled by default and mandatory to compile on older rust
version.
On Rust 1.36 and later, it is possible to use this crate on no_std target. If
It is possible to use this crate on no_std target. If
you wish to compile for a target that does not have an `std` crate, you should
use `num-bigint` with `default-features = false`. All other sub-features should
be compatible with no_std. Note that in this mode, `num-bigint` still relies on
@ -49,7 +50,7 @@ Release notes are available in [RELEASES.md](RELEASES.md).
## Compatibility
The `num-bigint` crate is tested for rustc 1.31 and greater.
The `num-bigint` crate is tested for rustc 1.36 and greater.
## Alternatives
@ -59,7 +60,7 @@ table offers a brief comparison to a few alternatives.
| Crate | License | Min rustc | Implementation |
| :------------------- | :------------- | :-------- | :------------- |
| **`num-bigint-dig`** | MIT/Apache-2.0 | 1.31 | pure rust |
| **`num-bigint-dig`** | MIT/Apache-2.0 | 1.36 | pure rust |
| [`num-bigint`] | MIT/Apache-2.0 | 1.15 | pure rust |
| [`ramp`] | Apache-2.0 | nightly | rust and inline assembly |
| [`rug`] | LGPL-3.0+ | 1.18 | bundles [GMP] via [`gmp-mpfr-sys`] |

View File

@ -12,8 +12,8 @@ name = "bench_main"
num-bigint-dig = { path = "../", features = ["prime", "rand"] }
num-integer = "0.1.39"
num-traits = "0.2.4"
rand = "0.6"
rand_chacha = "0.1"
rand = "0.7"
rand_chacha = "0.2"
[dev-dependencies]
criterion = "0.2"

View File

@ -1,7 +1,7 @@
use criterion::Criterion;
use num_bigint::{BigInt, BigUint, RandBigInt};
use num_traits::{FromPrimitive, Num, One, Pow, Zero};
use rand::{SeedableRng, StdRng};
use rand::{rngs::StdRng, SeedableRng};
use std::mem::replace;
fn get_rng() -> StdRng {

View File

@ -1,6 +1,6 @@
use criterion::Criterion;
use num_bigint::{ExtendedGcd, RandBigInt};
use rand::{SeedableRng, StdRng};
use rand::{rngs::StdRng, SeedableRng};
fn get_rng() -> StdRng {
let mut seed = [0; 32];

View File

@ -45,7 +45,7 @@ fn factorial_div_u32(c: &mut Criterion) {
criterion_group! {
name = benches;
config = { let mut c = Criterion::default(); c.sample_size(5) };
config = { let c = Criterion::default(); c.sample_size(5) };
targets =
factorial_mul_biguint,
factorial_mul_u32,

View File

@ -2,7 +2,7 @@ use criterion::Criterion;
use num_bigint::{BigUint, RandBigInt};
use num_integer::Integer;
use num_traits::Zero;
use rand::{SeedableRng, StdRng};
use rand::{rngs::StdRng, SeedableRng};
fn get_rng() -> StdRng {
let mut seed = [0; 32];

View File

@ -72,7 +72,7 @@ fn bench_gen_prime(c: &mut Criterion) {
criterion_group! {
name = benches;
config = { let mut c = Criterion::default(); c.sample_size(5) };
config = { let c = Criterion::default(); c.sample_size(5) };
targets =
probably_prime_0,
probably_prime_1,

View File

@ -1,7 +1,7 @@
use criterion::Criterion;
use num_bigint::{BigUint, RandBigInt};
use num_traits::Pow;
use rand::{SeedableRng, StdRng};
use rand::{rngs::StdRng, SeedableRng};
// The `big64` cases demonstrate the speed of cases where the value
// can be converted to a `u64` primitive for faster calculation.

View File

@ -1655,9 +1655,9 @@ mod tests {
1305238720762,
];
let mut a1 = &mut [0; 1341];
let mut a2 = &mut [0; 1341];
let mut a3 = &mut [0; 1341];
let a1 = &mut [0; 1341];
let a2 = &mut [0; 1341];
let a3 = &mut [0; 1341];
//print!("{} {}", b.len(), c.len());
long(a1, &b, &c);

View File

@ -15,15 +15,52 @@ use core::{cmp, fmt, mem};
use core::{f32, f64};
use core::{u32, u64, u8};
#[cfg(not(feature = "std"))]
use libm::F64Ext;
#[cfg(feature = "serde")]
use serde;
#[cfg(feature = "zeroize")]
use zeroize::Zeroize;
#[cfg(feature = "std")]
fn sqrt(a: f64) -> f64 {
a.sqrt()
}
#[cfg(not(feature = "std"))]
fn sqrt(a: f64) -> f64 {
libm::sqrt(a)
}
#[cfg(feature = "std")]
fn ln(a: f64) -> f64 {
a.ln()
}
#[cfg(not(feature = "std"))]
fn ln(a: f64) -> f64 {
libm::log(a)
}
#[cfg(feature = "std")]
fn cbrt(a: f64) -> f64 {
a.cbrt()
}
#[cfg(not(feature = "std"))]
fn cbrt(a: f64) -> f64 {
libm::cbrt(a)
}
#[cfg(feature = "std")]
fn exp(a: f64) -> f64 {
a.exp()
}
#[cfg(not(feature = "std"))]
fn exp(a: f64) -> f64 {
libm::exp(a)
}
use integer::{Integer, Roots};
use num_traits::float::FloatCore;
use num_traits::{
@ -1478,7 +1515,7 @@ impl Roots for BigUint {
let guess = if let Some(f) = self.to_f64() {
// We fit in `f64` (lossy), so get a better initial guess from that.
BigUint::from_f64((f.ln() / f64::from(n)).exp()).unwrap()
BigUint::from_f64(exp(ln(f) / f64::from(n))).unwrap()
} else {
// Try to guess by scaling down such that it does fit in `f64`.
// With some (x * 2ⁿᵏ), its nth root ≈ (ⁿ√x * 2ᵏ)
@ -1518,7 +1555,7 @@ impl Roots for BigUint {
let guess = if let Some(f) = self.to_f64() {
// We fit in `f64` (lossy), so get a better initial guess from that.
BigUint::from_f64(f.sqrt()).unwrap()
BigUint::from_f64(sqrt(f)).unwrap()
} else {
// Try to guess by scaling down such that it does fit in `f64`.
// With some (x * 2²ᵏ), its sqrt ≈ (√x * 2ᵏ)
@ -1550,7 +1587,7 @@ impl Roots for BigUint {
let guess = if let Some(f) = self.to_f64() {
// We fit in `f64` (lossy), so get a better initial guess from that.
BigUint::from_f64(f.cbrt()).unwrap()
BigUint::from_f64(cbrt(f)).unwrap()
} else {
// Try to guess by scaling down such that it does fit in `f64`.
// With some (x * 2³ᵏ), its cbrt ≈ (∛x * 2ᵏ)

View File

@ -1134,7 +1134,7 @@ fn test_random_shr() {
use rand::distributions::Standard;
use rand::Rng;
let mut rng = thread_rng();
let rng = thread_rng();
for p in rng.sample_iter::<i64, _>(&Standard).take(1000) {
let big = BigInt::from(p);

View File

@ -20,7 +20,7 @@ mod biguint {
#[cfg(not(feature = "std"))]
fn thread_rng() -> impl Rng {
// Chosen by fair dice roll
rand::StdRng::seed_from_u64(4)
rand::rngs::StdRng::seed_from_u64(4)
}
#[test]

View File

@ -104,7 +104,6 @@ mod biguint {
#[cfg(feature = "rand")]
#[test]
fn test_roots_rand() {
#[cfg(feature = "std")]
fn thread_rng() -> impl rand::Rng {
rand::thread_rng()
@ -117,10 +116,10 @@ mod biguint {
}
use num_bigint::RandBigInt;
use rand::Rng;
use rand::distributions::Uniform;
use rand::Rng;
let mut rng = thread_rng();
let rng = &mut thread_rng();
let bit_range = Uniform::new(0, 2048);
let sample_bits: Vec<_> = rng.sample_iter(&bit_range).take(100).collect();
for bits in sample_bits {

View File

@ -11,7 +11,7 @@ use rand::prelude::*;
fn test_mul_divide_torture_count(count: usize) {
let bits_max = 1 << 12;
let seed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];
let mut rng = SmallRng::from_seed(seed);
let mut rng = rand::rngs::SmallRng::from_seed(seed);
for _ in 0..count {
// Test with numbers of random sizes: