Skip to content

Provide a way to derive a public key from a private key? #406

@twiss

Description

@twiss

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:

const privateKey = await crypto.subtle.importKey('raw-private', privateKeyMaterial, 'Ed25519', false, ['sign']);
const publicKeyMaterial = await crypto.subtle.exportKey('raw-public', privateKey);

(which would be more convenient if what you want is the public key material, but less convenient if you want a public key object).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions