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

Remove field traits from behind std feature flag #26

Merged
merged 5 commits into from
Dec 25, 2021
Merged

Conversation

str4d
Copy link
Contributor

@str4d str4d commented Dec 22, 2021

Closes #25.

This enables the crate to be compiled without the tables, instead using
a simple fallback for `SqrtRatio::sqrt_ratio`.
Now that we have a default implementation of `SqrtRatio::sqrt_ratio`, we
can use it and `FieldExt` in no-std environments.

We introduce an `alloc` feature flag to form a common feature dependency
between `std` and `sqrt-table`. It is currently unused directly, but
will be used after `CurveAffine` is refactored to remove the `std`
dependency.

Closes #25.
@str4d str4d added this to the Core Sprint 2021-50 milestone Dec 22, 2021
@str4d str4d mentioned this pull request Dec 22, 2021
@codecov-commenter
Copy link

codecov-commenter commented Dec 22, 2021

Codecov Report

Merging #26 (c109603) into main (c052756) will decrease coverage by 0.75%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #26      +/-   ##
==========================================
- Coverage   67.04%   66.29%   -0.76%     
==========================================
  Files          10       11       +1     
  Lines        1408     1424      +16     
==========================================
  Hits          944      944              
- Misses        464      480      +16     
Impacted Files Coverage Δ
src/arithmetic/curves.rs 0.00% <ø> (ø)
src/arithmetic/fields.rs 64.88% <0.00%> (-22.75%) ⬇️
src/curves.rs 37.95% <ø> (ø)
src/fields/fp.rs 81.68% <ø> (+5.94%) ⬆️
src/fields/fq.rs 81.10% <ø> (+5.90%) ⬆️
src/lib.rs 100.00% <ø> (ø)
src/hashtocurve.rs 71.64% <0.00%> (-28.36%) ⬇️
benches/point.rs 0.00% <0.00%> (ø)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c052756...c109603. Read the comment docs.

This removes a dependency on the `getrandom` crate in no-std mode, which
doesn't work on some no-std targets that `getrandom` doesn't support.
@@ -21,6 +21,7 @@ and this project adheres to Rust's notion of
- `FieldExt::from_u64` (use `From<u64> for ff::PrimeField` instead).
- `FieldExt::{from_bytes, read, to_bytes, write}`
(use `ff::PrimeField::{from_repr, to_repr}` instead).
- `FieldExt::rand` (use `ff::Field::random` instead).

Copy link
Contributor

@daira daira Dec 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document the changes to std gating (also taking into account #28), and that the sqrt-table feature controls whether the table-based sqrt implementation is used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've not released a crate version with the std feature flag, so to crate users they'll see the addition of no-std support. Agreed on documenting the new flags, but I'll do that in a separate PR once everything is stable.

Copy link
Contributor

@daira daira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

src/arithmetic/fields.rs Outdated Show resolved Hide resolved
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
@str4d str4d merged commit 93c6a18 into main Dec 25, 2021
@str4d str4d deleted the no-std-field-traits branch December 25, 2021 12:34
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.

Add alloc feature flag
3 participants