-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feature/compressed try from #1
Feature/compressed try from #1
Conversation
This reduces copy-pasta in downstream users to check the length of the slice beforehand.
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.
The commit history of this branch is severely convoluted.. it'd be nicer if it were one or two simple commits which neatly correspond to the subject of the PR.
src/scalar.rs
Outdated
impl From<[u8; 32]> for Scalar { | ||
fn from(bytes: [u8; 32]) -> Self { | ||
Scalar{ 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.
This would allow users to construct noncanonical Scalar
s, both in that the most significant bit could be set, which is explicitly disallowed, and in that they could be unreduced modulo the basepoint order.
src/scalar.rs
Outdated
let mut s_bytes = [0x00u8; 32]; | ||
s_bytes.copy_from_slice(bytes); | ||
|
||
Ok(Scalar::from_bits(s_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 feel very nervous calling from_bits()
under the hood here, it should only be called when explicitly needed, for protocols that rely on it such as x25519 diffie-hellman, because it allows unreduced Scalar
s to be constructed.
a7f2c6c
to
9ae2e3b
Compare
…t, CompressedEdwardsY and Scalar
452b935
to
ccb97b6
Compare
Kind of targeting for different purposes, since there was the change from the default lib |
TryFrom<&[u8]>
to ScalarFrom<[u8; 32]>
to types that reflects this structure