entropyxyz/crypto-primes

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

ok-john opened this issue · 2 comments

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.

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

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