-
Notifications
You must be signed in to change notification settings - Fork 503
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
Consistency regarding from_bytes
APIs
#491
Comments
Note that right now |
Related is #490: should we add an |
pub fn from_bytes_mod_order(bytes: [u8; 32]) -> Scalar then pub fn from_canonical_bytes(bytes: [u8; 32]) -> CtOption<Scalar> and pub const fn from_bits(bytes: [u8; 32]) -> Scalar I think it might be confusing using |
For That would provide a nice convenience wrapper for cases where |
Well, now I see why Sidebar: I'm a bit confused why |
Whoops, didn't mean to close that quite yet. I guess one advantage of the Opened #493 regarding |
I can make existing |
How do we get progress on this, to finally release 4.0.0? |
As noted above, upon further review the inherent methods seem to have good reasons for being the way they are. So the main thing would be to survey places where |
Since |
Yeah, only thing to worry about is overlapping impls causing inference failure when you go from 1 -> 2 or more, but that isn't technically a breaking change. That said, I can close this to unblock a release. |
There are several APIs for converting various types from bytes which generally take the form:
There's one exception to this:
...which makes a copy of the byte array. It should probably be changed to borrow the array, especially as
from_bytes_mod_order_wide
takes a&[u8; 64]
.Another question is how
From
/TryFrom
impls should be defined for these types:From<[u8; N]>
impl?TryFrom<[u8; N]>
impl?TryFrom<&[u8]>
? (always fallible since the slice might be the wrong size)An important consideration here is if multiple overlapping impls of the same trait are allowed. If we try to add that after a major release, it breaks inference, which I think is generally allowed under Rust SemVer, but can break downstream code and is generally annoying to deal with.
Edit:
CompressedEdwardsY
andCompressedRistretto
both have afrom_slice
method that panics of the slice is the wrong length. We should perhaps consider returning aResult
instead.The text was updated successfully, but these errors were encountered: