-
Notifications
You must be signed in to change notification settings - Fork 925
Add getPublicKeyFromPrivateKey
helper
#3049
Conversation
🦋 Changeset detectedLatest commit: 0a4c8ae The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @lorisleiva and the rest of your teammates on Graphite |
getPublicKeyFromPrivateKey
helper
806a29c
to
7153986
Compare
7153986
to
981ad42
Compare
beforeEach(async () => { | ||
privateKey = await createPrivateKeyFromBytes(MOCK_PRIVATE_KEY_BYTES, false); | ||
}); | ||
it('cannot get the associated public key', async () => { |
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.
Is it possible for us to check if it's extractable? I'm wondering if we should add a Solana error for this case because I'm skeptical that subtle crypto will give a nice error message
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.
Good shout! I've added a new SOLANA_ERROR__SUBTLE_CRYPTO__CANNOT_EXPORT_NON_EXTRACTABLE_KEY
error code.
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.
Wow! I didn't think this was possible! Amazing.
This can't go in without this PR also including an update to the polyfill. The only reason the tests pass here is that the tests run in a haz-ed25519 environment. This will puke in a browser that doesn't.
To be clear, you need to add a polyfill that implements at least jwk
export for private keys and import for public keys. Hint: the x
and d
coordinates are base64URL encoded.
Thanks @steveluscher, I'll apply your suggestions and prepend PRs to the stack for the polyfill. |
981ad42
to
06734a1
Compare
f4af5f1
to
b4a8fbf
Compare
5a9de85
to
526072b
Compare
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.
b4a8fbf
to
4f3be6a
Compare
526072b
to
99f14b3
Compare
Merge activity
|
99f14b3
to
0a4c8ae
Compare
Because there has been no activity on this PR for 14 days since it was merged, it has been automatically locked. Please open a new issue if it requires a follow up. |
This PR adds a
getPublicKeyFromPrivateKey
helper method that can be used to retrieve theCryptoKey
public key from an extractableCryptoKey
private key.