Skip to content

k256: impl ff and group traits#164

Merged
tarcieri merged 4 commits into
masterfrom
k256/group-traits
Sep 5, 2020
Merged

k256: impl ff and group traits#164
tarcieri merged 4 commits into
masterfrom
k256/group-traits

Conversation

@tarcieri

@tarcieri tarcieri commented Sep 4, 2020

Copy link
Copy Markdown
Member
  • Impls ff::{Field, PrimeField} on Scalar
  • Impls group::{Group, Curve} on ProjectivePoint

@tarcieri tarcieri requested review from fjarri, str4d and tuxxy September 4, 2020 18:02
Comment thread k256/Cargo.toml
Comment thread k256/src/arithmetic/scalar.rs Outdated
Comment thread k256/src/arithmetic/projective.rs Outdated
Comment thread k256/src/arithmetic/projective.rs
Comment thread k256/src/arithmetic/projective.rs Outdated
Comment thread k256/src/arithmetic/scalar.rs
Comment thread k256/src/arithmetic/scalar.rs
Comment thread k256/src/arithmetic/scalar.rs
Comment thread k256/src/arithmetic/scalar.rs
Comment thread k256/src/arithmetic/scalar.rs
Comment thread k256/src/arithmetic/scalar.rs
Comment thread k256/src/arithmetic/scalar/scalar_8x32.rs
@tarcieri

tarcieri commented Sep 4, 2020

Copy link
Copy Markdown
Member Author

Lots of clippy complaints about unnecessary borrows now. I'm wondering if we need to add #[inline] on the various owned arithmetic operations to remove those without impacting performance. Edit: applied clippy fixes and posted benchmarks below.

It also seems like there are a lot of inherent methods on Scalar and ProjectivePoint which also have similar or identical methods on the trait. Perhaps we should get rid of the duplicated inherent methods and just use the trait?

@tarcieri

tarcieri commented Sep 4, 2020

Copy link
Copy Markdown
Member Author

Applied clippy's suggested fixes with the new arithmetic impls on owned types. I do really like how it improves the code quality (by removing "eye of sauron"-style borrowed arithmetic).

Ran the existing benchmarks... it looked like mostly improvements except for normalize:

Screen Shot 2020-09-04 at 11 56 37 AM

field element operations/normalize_weak
                        time:   [1.6940 ns 1.7020 ns 1.7113 ns]
                        change: [+4.7960% +5.6804% +6.5209%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 7 outliers among 100 measurements (7.00%)
  1 (1.00%) low mild
  5 (5.00%) high mild
  1 (1.00%) high severe
field element operations/normalize
                        time:   [1.7010 ns 1.7075 ns 1.7142 ns]
                        change: [+1.4923% +3.0551% +4.6100%] (p = 0.00 < 0.05)
                        Performance has regressed.

cc @fjarri

@fjarri

fjarri commented Sep 4, 2020

Copy link
Copy Markdown
Contributor

I wouldn't worry about it. The change is small, and when we're talking about an operation that takes literally 1ns, I doubt that these measurements are very accurate. On my laptop it takes ~4ns, and I don't see any change between this PR and master.

@codecov-commenter

codecov-commenter commented Sep 5, 2020

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 24.50980% with 77 lines in your changes missing coverage. Please review.

Project coverage is 59.43%. Comparing base (d81c5c0) to head (4fe63b0).
Report is 893 commits behind head on master.

Files with missing lines Patch % Lines
k256/src/arithmetic/scalar.rs 12.76% 41 Missing ⚠️
k256/src/arithmetic/projective.rs 18.75% 26 Missing ⚠️
k256/src/arithmetic/scalar/scalar_4x64.rs 0.00% 4 Missing ⚠️
k256/src/arithmetic/scalar/scalar_8x32.rs 0.00% 4 Missing ⚠️
k256/src/arithmetic/affine.rs 0.00% 2 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #164      +/-   ##
==========================================
- Coverage   60.64%   59.43%   -1.22%     
==========================================
  Files          25       25              
  Lines        3601     3688      +87     
==========================================
+ Hits         2184     2192       +8     
- Misses       1417     1496      +79     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- Impls `ff::{Field, PrimeField}` on `Scalar`
- Impls `group::{Group, Curve}` on `ProjectivePoint`
@tarcieri tarcieri changed the title [WIP] k256: impl ff and group traits k256: impl ff and group traits Sep 5, 2020
@tarcieri tarcieri marked this pull request as ready for review September 5, 2020 19:11
@tarcieri tarcieri merged commit ebac050 into master Sep 5, 2020
@tarcieri tarcieri deleted the k256/group-traits branch September 5, 2020 19:20
tarcieri added a commit that referenced this pull request Sep 6, 2020
Corresponding change to #164, but for the `p256` crate.

- Impls `ff::{Field, PrimeField}` on `Scalar`
- Impls `group::{Group, Curve}` on `ProjectivePoint`
tarcieri added a commit that referenced this pull request Sep 6, 2020
Corresponding change to #164, but for the `p256` crate.

- Impls `ff::{Field, PrimeField}` on `Scalar`
- Impls `group::{Group, Curve}` on `ProjectivePoint`
tarcieri added a commit that referenced this pull request Sep 6, 2020
Corresponding change to #164, but for the `p256` crate.

- Impls `ff::{Field, PrimeField}` on `Scalar`
- Impls `group::{Group, Curve}` on `ProjectivePoint`
tarcieri added a commit that referenced this pull request Sep 6, 2020
Corresponding change to #164, but for the `p256` crate.

- Impls `ff::{Field, PrimeField}` on `Scalar`
- Impls `group::{Group, Curve}` on `ProjectivePoint`
@tarcieri tarcieri mentioned this pull request Sep 6, 2020
This was referenced Sep 17, 2020
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.

5 participants