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

Implement group and pairing traits for bls12_381 and jubjub crates #245

Merged
merged 5 commits into from
Aug 19, 2020

Conversation

str4d
Copy link
Contributor

@str4d str4d commented Jun 25, 2020

Closes #163. Closes #167. Closes #169.

@str4d str4d requested a review from ebfull June 25, 2020 03:52
@str4d str4d added this to the Core Sprint 2020-25 milestone Jun 25, 2020
@str4d str4d force-pushed the impl-group-pairing-traits branch from dc2acd8 to 2e062a7 Compare June 25, 2020 03:53
jubjub/src/lib.rs Outdated Show resolved Hide resolved
bls12_381/src/g1.rs Outdated Show resolved Hide resolved
bls12_381/src/g2.rs Outdated Show resolved Hide resolved
jubjub/src/lib.rs Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jun 25, 2020

Codecov Report

Merging #245 into master will decrease coverage by 1.69%.
The diff coverage is 1.62%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #245      +/-   ##
==========================================
- Coverage   66.73%   65.03%   -1.70%     
==========================================
  Files         117      117              
  Lines       16192    16623     +431     
==========================================
+ Hits        10805    10811       +6     
- Misses       5387     5812     +425     
Impacted Files Coverage Δ
bls12_381/src/fp.rs 44.19% <0.00%> (-2.66%) ⬇️
bls12_381/src/fp12.rs 44.64% <0.00%> (-1.23%) ⬇️
bls12_381/src/fp2.rs 55.55% <0.00%> (-1.12%) ⬇️
bls12_381/src/fp6.rs 52.73% <0.00%> (-1.49%) ⬇️
bls12_381/src/g1.rs 65.15% <0.00%> (-9.94%) ⬇️
bls12_381/src/g2.rs 58.04% <0.00%> (-8.09%) ⬇️
group/src/lib.rs 50.00% <ø> (ø)
jubjub/src/lib.rs 41.95% <2.45%> (-14.26%) ⬇️
bls12_381/src/pairings.rs 55.01% <3.30%> (-21.73%) ⬇️
zcash_primitives/src/serialize.rs 64.28% <0.00%> (-1.03%) ⬇️
... and 2 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 964532e...3200ffc. Read the comment docs.

@ebfull ebfull mentioned this pull request Jun 26, 2020
18 tasks
@str4d str4d force-pushed the impl-group-pairing-traits branch 2 times, most recently from 79d95bf to 1c4faf9 Compare July 2, 2020 02:32
@nuttycom nuttycom self-requested a review July 20, 2020 21:56
Copy link
Contributor

@nuttycom nuttycom left a comment

Choose a reason for hiding this comment

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

Non-blocking style comments/questions; I don't know how to verify the correctness of the actual group operations, but they look like what I'd expect.

bls12_381/src/fp.rs Outdated Show resolved Hide resolved
}
}

impl Sum for G2Subgroup {
Copy link
Contributor

Choose a reason for hiding this comment

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

Having seen this implementation duplicated a few times now, could it just be done via a blanket trait with constraints on Add and Identity? Or, is there a Monoid trait that combines the two? In Haskell we have this in the standard library:

Prelude> :t Data.Foldable.fold
Data.Foldable.fold :: (Foldable t, Monoid m) => t m -> m

bls12_381/src/g1.rs Outdated Show resolved Hide resolved
bls12_381/src/g1.rs Outdated Show resolved Hide resolved
bls12_381/src/g2.rs Show resolved Hide resolved
}
}

impl<'r> Sum<&'r ExtendedPoint> for ExtendedPoint {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we can't use a blanket trait for these, we should at least make a macro for them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's already a set of common macros that are planned to be extracted out; we can do this at the same time.

jubjub/src/lib.rs Show resolved Hide resolved
bls12_381/src/g1.rs Outdated Show resolved Hide resolved
bls12_381/src/g1.rs Outdated Show resolved Hide resolved
bls12_381/src/g2.rs Show resolved Hide resolved
bls12_381/src/g2.rs Outdated Show resolved Hide resolved
bls12_381/src/g1.rs Outdated Show resolved Hide resolved
bls12_381/src/pairings.rs Outdated Show resolved Hide resolved
jubjub/src/lib.rs Show resolved Hide resolved
@str4d str4d mentioned this pull request Aug 12, 2020
@str4d str4d force-pushed the impl-group-pairing-traits branch from 1c4faf9 to f39f8d1 Compare August 12, 2020 23:11
@str4d
Copy link
Contributor Author

str4d commented Aug 12, 2020

Okay, I think that (aside from specifying the full-group generators for G1 and G2) this is ready for review. Best reviewed by-commit.

@str4d str4d force-pushed the impl-group-pairing-traits branch from f39f8d1 to b1e6f8a Compare August 13, 2020 18:42
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.

Need to check a few things, otherwise utACK.

bls12_381/src/fp.rs Outdated Show resolved Hide resolved
bls12_381/src/g1.rs Show resolved Hide resolved
bls12_381/src/g1.rs Show resolved Hide resolved
bls12_381/src/g1.rs Show resolved Hide resolved
bls12_381/src/g1.rs Show resolved Hide resolved
jubjub/src/lib.rs Show resolved Hide resolved
0x0000_0000_0000_0000,
0x0000_0000_0000_0000,
0x0000_0000_0000_0000,
]),
Copy link
Contributor

Choose a reason for hiding this comment

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

@daira should check that this is the canonical point as defined that generates the whole group.

Copy link
Contributor

Choose a reason for hiding this comment

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

I reviewed find_curve_generator() and it looks correct to me. This doesn't check that the point arithmetic or Montgomery conversion is done correctly, but it's enough to satisfy me.

bls12_381/src/pairings.rs Show resolved Hide resolved
bls12_381/src/pairings.rs Outdated Show resolved Hide resolved
@str4d str4d force-pushed the impl-group-pairing-traits branch from b1e6f8a to 3a72f08 Compare August 17, 2020 22:41
@str4d
Copy link
Contributor Author

str4d commented Aug 17, 2020

Force-pushed to address some of @daira's comments. Per my responses above, I think they are all addressed now.

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

@str4d str4d merged commit 544d593 into zcash:master Aug 19, 2020
@str4d str4d deleted the impl-group-pairing-traits branch August 19, 2020 22:07
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.

impl pairing::* for bls12_381 impl group::* for bls12_381 impl group::* for jubjub
5 participants