You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Provide a way to derive a public key from a private key? #406
In WICG/webcrypto-secure-curves#26, it was requested to provide a method to derive a public key from a private key for Ed25519, but this may be useful to provide a generic method for.
There is a workaround by exporting the private key as JWK, which typically also contains the public key material. However, this requires to then manually take the public key properties from the JWK (and which ones those are depends on the algorithm).
Perhaps it would be simpler to provide an explicit method for this; e.g. crypto.subtle.getPublicKey(privateKey)?
Alternatively, we could allow exporting public keys from private key objects, such that (in combination with #393) the following would be possible:
I think providing an explicit method (getPublicKey) would improve the code readability. In order to use the importKey/exportKey trick you still need a bit of knowledge about how the keys are stored.
I think a getPublicKey method would be nice. Its argument is a private CryptoKey, its extractable slot is irrelevant, key_ops array as a second argument, and it resolves a public extractable CryptoKey with the same algorithm.
Activity
Frosne commentedon Jul 7, 2025
I think providing an explicit method (
getPublicKey) would improve the code readability. In order to use the importKey/exportKey trick you still need a bit of knowledge about how the keys are stored.panva commentedon Jul 7, 2025
I think a getPublicKey method would be nice. Its argument is a private CryptoKey, its extractable slot is irrelevant, key_ops array as a second argument, and it resolves a public extractable CryptoKey with the same algorithm.