Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Prime number tools for crypto-bigint
This library implements prime number generation and primality checking for crypto-bigint integers.
At a high level, provides two primality tests that can be used by themselves or to generate random primes:
- The BPSW'21 test which improves on the commonly used BPSW'80, based on Baillie et al "Strengthening the Baillie-PSW primality test", Math. Comp. 90 1931-1955 (2021), DOI: 10.1090/mcom/3616;
- The test prescribed by the FIPS-186.5 standard, along with a function to calculate the required number of Miller-Rabin test iterations depending on the prime size and the bound on the probability of a false positive.
The generated primes can have additional constraints imposed on them, like having certain bits set, or requiring the primes to be safe.
Advanced users can use the primality test components from the hazmat module to build a custom prime finding solution that best fit their needs:
- Sieving iterator;
- Miller-Rabin test;
- Lucas test with a choice of base and a specific variation.
The library is no-std compatible and contains no unsafe code.
Example
Find a 196 bit prime returned in a 256-bit long crypto_bigint::U256:
use U256;
use ;
use ;
let prime = ;
assert!;
Find a 64 bit safe prime returned in a crypto_bigint::U1024:
use U1024;
use ;
use ;
let prime = ;
assert!;
random_prime() returns primes with MSB set.
If a different behavior is desired, it can be done by manually creating a sieve:
use ;
use U256;
use ;
let flavor = Any;
let factory = new.unwrap;
let prime = sieve_and_find.unwrap.unwrap;
assert!;
Features
The following features are available:
multicore: Enables additional parallel prime finding functions. Disabled by default.