-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use crypto-bigint
instead of num-bigint
#6
Conversation
This contains some stuff related to the schnorr implementation, which I think should be a separate PR, but IMO it would be nice to get the crypto-bigint changes into main right away :) |
/// `M = MAX+1-c` where `c` is small enough to fit in a single [`Limb`], | ||
/// see the documentation for crypto_bigint::mul_mod_special. | ||
pub fn mul_mod(lhs: &Nat, rhs: &Nat) -> Nat { | ||
let c = 18446744073709428953; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this magic number? Probably needs a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a comment above the function, but it is arguably not directly at the thing it's commenting on - c
is MAX+1-M
, i.e. the difference between the modulus and the biggest integer representable by Nat
(which is currently U64
, so MAX
is 2^64-1 and thus c
is 2^64-M).
See the documentation for mul_mod_special
for more details :)
Crypto-bigint will allow us to use https://docs.rs/crypto-primes/latest/crypto_primes/ for implementing the group operations needed for schnorr as well as elliptic curve library https://docs.rs/elliptic-curve/latest/elliptic_curve/ for ecdsa