-
Notifications
You must be signed in to change notification settings - Fork 49
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
Support no-std builds #4
Conversation
Codecov Report
@@ Coverage Diff @@
## main #4 +/- ##
==========================================
- Coverage 66.50% 65.53% -0.97%
==========================================
Files 10 10
Lines 1421 1445 +24
==========================================
+ Hits 945 947 +2
- Misses 476 498 +22
Continue to review full report at Codecov.
|
The `FieldExt` trait was originally the only trait implemented in this crate. When we added `ff` support, we reworked `FieldExt` to be an extension trait on top of `ff::PrimeField`, but left the existing impls in `FieldExt`. This resulted in some circular dependencies that prevent us from making `FieldExt` conditional (e.g. for no-std support). This commit removes the cycles like so: - `ff::PrimeField::{from_repr, to_repr}` were implemented as calls to `FieldExt::{from_bytes, to_bytes}`. The field encoding/decoding logic is moved into the `ff::PrimeField` trait impl, and `FieldExt` now calls into `ff::PrimeField`. - `ff::Field::sqrt` was implemented in terms of `FieldExt::sqrt_alt`. Given that the latter is a trivial wrapper around the `SqrtTables` implementation, we duplicate the call to eliminate the cycle. - `ff::Field::random` used `FieldExt::from_bytes_wide`, which wraps either `Fp::from_u512` or `Fq::from_u512`. We now use these internal methods directly.
3397293
to
abcf70a
Compare
We re-introduce the Tonelli-Shank square root algoritm that was removed in zcash/halo2#120, to use in no-std mode (the table-based impl requires allocations, and also uses 29kiB of memory which is a problem for constrained environments that typically need no-std).
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
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.
utACK
It doesn't affect the serialized output.
No description provided.