-
Notifications
You must be signed in to change notification settings - Fork 75
crypto: accept ed25519 priv key as a value type #234
Conversation
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.
Looks reasonable to me. The only thing I'd be worried about is that this might break existing code.
I can't see any use of these two functions across the PL stack though.
@vyzo, wdyt?
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.
sounds reasonable, but lets keep compatibility and also accept pointers given by the user.
Ok, will adjust, so that both forms are accepted |
1329e28
to
029a900
Compare
Adjusted for backward compatibility. In |
Why not just accept both in a single function? |
Since underlying type is []byte, the ed25519 key is generally passed as a value, not a pointer. In particular, nowhere in std crypto package it is, nor any common parsing functions returns it this way. The test itself shows the issue: whereas all other keys are passed as they are got from their respective generators, ed25519 needs additional pointer mapping. Also the behaviour is inconsistent, since in function PubKeyToStdKey in the case for Ed25519 a value to underlying []byte is returned, not a pointer.
029a900
to
b557fdf
Compare
Sry for late reply, @Stebalien the changes I propose here in current version do extend KeyPairFromStdKey function to accept value type. I just realised, that I forgot to adjust commit and PR title to communicate the change, which I've just done. As for the |
2022-08-26 triage note: Closing this at this point since it has been 8 months and it hasn't been merged yet. If it is still critical, please go ahead and open a PR in libp2p/go-libp2p since this repo is now archived. |
Since underlying type is []byte, the ed25519 key is generally passed as a value, not a pointer.
In particular, nowhere in std crypto package it is, nor any common parsing functions returns it this way.
The test itself shows the issue: whereas all other keys are passed as they are got from their respective generators,
ed25519 needs additional pointer retrieval. Also the behaviour is inconsistent, since in function PubKeyToStdKey in the case for Ed25519 a value to type with underlying []byte is returned, not a pointer.
This is a breaking change though, so if the lib is considered stable, the previous method should be deprecated and new one created.