Skip to content
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

Merged
merged 8 commits into from
Nov 22, 2023
Merged

Use crypto-bigint instead of num-bigint #6

merged 8 commits into from
Nov 22, 2023

Conversation

mzacho
Copy link
Owner

@mzacho mzacho commented Nov 20, 2023

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

src/circuit.rs Outdated Show resolved Hide resolved
@mzacho
Copy link
Owner Author

mzacho commented Nov 20, 2023

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 :)

src/circuit.rs Outdated Show resolved Hide resolved
/// `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;
Copy link
Collaborator

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

Copy link
Owner Author

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 :)

src/shares.rs Outdated Show resolved Hide resolved
@arcuo arcuo merged commit 17e8270 into main Nov 22, 2023
1 check passed
@arcuo arcuo deleted the schnorr branch November 22, 2023 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants