-
Notifications
You must be signed in to change notification settings - Fork 11.4k
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
[fastx types] 32 byte authenticator #94
[fastx types] 32 byte authenticator #94
Conversation
5bdfc5f
to
ac4ef4a
Compare
Consider making (the branch of) #88 the target branch? |
@sblackshear 🤦 it's not you: that's impossible. This would be one case where only opening a (feature) branch on the main repo would work. |
ac4ef4a
to
a46ec62
Compare
fn try_from(bytes: &[u8]) -> Result<Self, FastPayError> { | ||
let arr: [u8; dalek::PUBLIC_KEY_LENGTH] = bytes | ||
.try_into() | ||
.map_err(|_| FastPayError::InvalidAuthenticator)?; |
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 single error case of this TryFrom
is just an invalid length error. There is a host of other problems completely ignored by the current implementation:
- there are sequences of 32 bytes that will structurally not ever be usable as an Ed25519 Public Key in any way,
- there are sequences of 32 bytes that will 100% be usable as an Ed25519 Public Key, but that demonstrably and unambiguously aim at tricking anybody who does so.
The above takes exactly none of that into account. Further, several of those checks will not be performed by check_internal
's dalek::PublicKey::from_bytes
(and the library has a nice warning to say so).
I admit it's probably a completely orthogonal point to this PR, and worth tackling in a different issue (probably extracted from this comment), but I'd appreciate a spectacular comment on PublicKeyBytes
making this clear. Here is an example of my personal minimum bar for the word "spectacular".
@sblackshear I'm happy to write a BCS-compatible serialization for |
Thanks for flagging the issue above + this offer! I'm not sure we need this for now because of the forthcoming decoupling of FastPay addresses and authenticators:
|
3e217bf
to
da03bde
Compare
Previously, we assumed that Move `address`es (16 bytes)/`Authenticator`s and FastX addresses/authenticators (currently 32 bytes) had to coincide + used unsafe hacks to convert between them. This PR separates the two, allowing Move `Authenticator`s to be 32 bytes + eliminating all the hacks.
da03bde
to
5e0d1f7
Compare
This is based on #88 and thus may be hard to review until that PR lands...
Previously, we assumed that Move
address
es (16 bytes)/Authenticator
s and FastX addresses/authenticators (currently 32 bytes) had to coincide + used unsafe hacks to convert between them. This PR separates the two, allowing MoveAuthenticator
s to be 32 bytes + eliminating all the hacks.