Is there any crates that support generate prime and pow method for bigint?

Hello, I am new to Rust and want to use Rust to write some kind of a digital signature scheme.

Now first I want to generate a prime big int number like the crates provide num-primes

pub struct Generator;
let prime = Generator::new_prime(512);

But seems like the BigUint type this crate provides only has modpow method, (a ^ b) mod c.
My algorithm needs only pow method a ^ b,
for example in golang, you can just set the last to nil.

e := new(big.Int).Exp(big.NewInt(2), big.NewInt(100), nil)

In rust, this crate num-bigint provides both pow and modpow method.

But seem like their biguint type are incompatible, is any way to handle this?? Or there is any other crates I can use?

Thanks in advance!

let c = Generator::new_prime(506); // use num-primes crate
        let d = c.clone().to_bytes_be();
        let f = BigUint::from_bytes_be(&d); // use num-bigint crate

maybe it will work? Not sure if there will cause any problem :rofl:

It looks to just be a re-export of num_bigint::BigUint, so it should work (check crate versions I guess).

That said, given this statement, you may want a different crate anyway.

Please note there is a critical bug in this program that I cannot seem to fix where it marks some prime numbers as not prime. It is in the miller-rabin implementation and I cannot seem to fix it. If anyone is up to it, feel free to look through the issues tab for information about the bug and submit a PR if you find a fix.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.