importPublicKey(publicKey: string,options?: ImportPublicKeyOptions): Promise<CryptoKey>
Imports an x25519 public key as a CryptoKey.
This function imports raw 32-byte x25519 public keys using the "raw" format supported by the Web Crypto API.
Import public key from base64 string
Import public key from base64 string
import { assertEquals } from "@std/assert"; import { importPublicKey, wgGenKey, wgPubKey } from "@hertzg/wg-keys"; const privateKeyBase64 = wgGenKey(); const publicKeyBase64 = await wgPubKey(privateKeyBase64); const cryptoKey = await importPublicKey(publicKeyBase64); assertEquals(cryptoKey.type, "public");
optional
options: ImportPublicKeyOptions
Configuration options for key import
Promise<CryptoKey>
A promise resolving to the imported CryptoKey
importPublicKey(publicKey: Uint8Array,options?: ImportPublicKeyOptions): Promise<CryptoKey>
Imports an x25519 public key as a CryptoKey.
This function imports raw 32-byte x25519 public keys using the "raw" format supported by the Web Crypto API.
Import public key from Uint8Array
Import public key from Uint8Array
import { assertEquals } from "@std/assert"; import { importPublicKey, publicBytesFromPrivateBytes, randomPrivateKeyBytes } from "@hertzg/wg-keys"; const privateKeyBytes = randomPrivateKeyBytes(); const publicKeyBytes = await publicBytesFromPrivateBytes(privateKeyBytes); const cryptoKey = await importPublicKey(publicKeyBytes); assertEquals(cryptoKey.type, "public");
publicKey: Uint8Array
The 32-byte public key as Uint8Array
optional
options: ImportPublicKeyOptions
Configuration options for key import
Promise<CryptoKey>
A promise resolving to the imported CryptoKey