entropyxyz / crypto-primes

Random prime generation and primality testing library based on `crypto-bigint`.
https://docs.rs/crypto-primes
Apache License 2.0
17 stars 4 forks source link

Switch from library panic to return an Error or other invalid return #8

Closed ok-john closed 7 months ago

ok-john commented 1 year ago

Currently jacobi_symbol panics when p is even - perhaps this should return and Error, maybe -1?

/// Returns the Jacobi symbol `(a/p)` given an odd `p`. Panics on even `p`.
pub(crate) fn jacobi_symbol<const L: usize>(a: i32, p_long: &Uint<L>) -> JacobiSymbol {

Idea being that any dependent libraries who import this function can handle errors/panics instead of the underlying library panicing.

fjarri commented 1 year ago

jacobi_symbol() is not currently exported, so these panics are more of a debug asserts (maybe that's what they should be instead).

fjarri commented 7 months ago

jacobi_symbol() takes an Odd-wrapped integer since #38, so this is no longer an issue.