-
Notifications
You must be signed in to change notification settings - Fork 24
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
feat: Big integer abstraction for Name accumulators & rug
-based BigInt backend
#373
Conversation
Very nice perf improvement! About:
The doc at https://docs.rs/gmp-mpfr-sys/1.6.1/gmp_mpfr_sys/index.html#experimental-optional-features says that it builds gmp. I guess it's statically linked so there is no runtime dependency to install. |
Oh that's cool. One thing to figure out I guess would be licensing. GMP is LGPLv3 and GPLv2 dual-licensed. |
So after some additional research & talking to people it seems like LGPL is designed to allow projects that use something that's LGPL to be licensed differently. Looking at rug reverse dependencies: https://crates.io/crates/rug/reverse_dependencies there's lots of projects that are licensed as MIT/Apache 2.0 with rug in their direct dependencies. Unlike all of these other crates, I think I'll add a note in the nameaccumulator README that by enabling the "rug" feature, you'll be depending on rug, just as an FYI. |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #373 +/- ##
==========================================
+ Coverage 54.57% 54.85% +0.27%
==========================================
Files 56 57 +1
Lines 3879 3936 +57
Branches 933 947 +14
==========================================
+ Hits 2117 2159 +42
- Misses 1162 1168 +6
- Partials 600 609 +9
|
rug
-based BigInt backendrug
-based BigInt backend
This also implements wnfs-wg/spec#76 since that simplifies the Now it's all big-endian within |
This introduces the
Big
trait in thewnfs-nameaccumulator
crate which abstracts the type & functions needed from the bigint library to support name accumulators.This allows us to experiment with different backends.
I've implemented a
rug
based backend and tested it against thenum-bigint-dig
backend, it improves name accumulator performance by roughly 2x:Benchmark output
The downside of the
rug
backend is that you need to have thegmp
libraries installed locally.Currently WIP because:
Big
trait. There's some weirdness to it. Function names and stuff.Consider splitting theNot now.Big::Num
type intoBig::U2048
andBig::U256
, orBig::GroupElem
andBig::Exponent
, or whatever is needed to support acrypto-bigint
backend.Decide whether backends must use e.g. the same pseudo-random prime derivation algorithms.No, it just needs to be pseudorandom.rug
feature.