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

Feature/compressed try from #1

Conversation

vlopes11
Copy link

  • Added TryFrom<&[u8]> to Scalar
  • Added From<[u8; 32]> to types that reflects this structure

Copy link
Owner

@isislovecruft isislovecruft left a 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
Comment on lines 481 to 487
impl From<[u8; 32]> for Scalar {
fn from(bytes: [u8; 32]) -> Self {
Scalar{ bytes }
}
}

Copy link
Owner

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 Scalars, 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))
Copy link
Owner

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 Scalars to be constructed.

@vlopes11
Copy link
Author

Kind of targeting for different purposes, since there was the change from the default lib From and TryFrom to a different approach. Closing this PR

@vlopes11 vlopes11 closed this Oct 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants