-
Notifications
You must be signed in to change notification settings - Fork 242
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 ff traits for bls12_381 and jubjub crates #227
Conversation
Codecov Report
@@ Coverage Diff @@
## master #227 +/- ##
===========================================
- Coverage 65.43% 35.09% -30.35%
===========================================
Files 105 94 -11
Lines 14936 11325 -3611
===========================================
- Hits 9774 3974 -5800
- Misses 5162 7351 +2189
Continue to review full report at Codecov.
|
I've addressed most comments in #228. Once that PR has been reviewed and merged, I'll rebase this PR to remove the now-unnecessary parts, and implement |
Rebased on master after merging #228. |
The first commit in this PR is also in #230; I'll rebase whichever PR is not merged first. |
Rebased on master now that #230 has been merged. |
Rebased the PR; it now only implements the |
@@ -70,6 +78,22 @@ const MODULUS: Scalar = Scalar([ | |||
0x73ed_a753_299d_7d48, | |||
]); | |||
|
|||
const MODULUS_BYTES: [u8; 32] = [ |
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.
Say what byte order this is in (maybe include it in the name).
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.
Also consider renaming Scalar::from_bytes
to from_le_bytes
.
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.
Note that this value is only used later in the PrimeField
impl, where the constant is defined to be little endian by the implementation, so this property is documented and accounted for.
@@ -162,7 +162,7 @@ impl Fp { | |||
self.ct_eq(&Fp::zero()) | |||
} | |||
|
|||
/// Attempts to convert a little-endian byte representation of | |||
/// Attempts to convert a big-endian byte representation of | |||
/// a scalar into an `Fp`, failing if the input is not canonical. | |||
pub fn from_bytes(bytes: &[u8; 48]) -> CtOption<Fp> { |
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.
Consider naming this from_be_bytes
.
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.
I'd personally rather not; it implies a little-endian scalar encoding would also be correct and supported (rather than big-endian being canonical for Fp
), and that way lies madness.
@@ -70,6 +78,33 @@ pub const MODULUS: Fr = Fr([ | |||
0x0e7d_b4ea_6533_afa9, | |||
]); | |||
|
|||
const MODULUS_BYTES: [u8; 32] = [ |
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.
Say what byte order this is in (maybe include it in the name).
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.
Also consider renaming Fr::from_bytes
to from_le_bytes
.
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.
See the other comment; the same holds here.
Closes #160 and #166.