Functions
createKeyPairFromPrivateKeyBytes
createKeyPairFromPrivateKeyBytes(
bytes
,extractable?
):Promise
<CryptoKeyPair
>
Given a private key represented as a 32-byte Uint8Array
, creates an Ed25519 public/private key
pair for use with other methods in this package that accept CryptoKey
objects.
Parameters
Parameter | Type | Description |
---|---|---|
bytes | ReadonlyUint8Array | 32 bytes that represent the private key |
extractable? | boolean | Setting this to true makes it possible to extract the bytes of the private key using the crypto.subtle.exportKey() API. Defaults to false . |
Returns
Promise
<CryptoKeyPair
>
Example
This can be useful when you have a private key but not the corresponding public key or when you need to derive key pairs from seeds. For instance, the following code snippet derives a key pair from the hash of a message.