Appearance
@pqc-sdk/core / decrypt
Function: decrypt()
decrypt(
ciphertext,secretKey):Promise<Uint8Array<ArrayBufferLike>>
Decrypts a ciphertext produced by encrypt. If the ciphertext was tampered with or the key does not match, it throws PqcError with code DECRYPTION_FAILED — it never returns corrupted data.
Parameters
ciphertext
Uint8Array
secretKey
SecretKey<"ml-kem-768">
Returns
Promise<Uint8Array<ArrayBufferLike>>
Example
ts
import { pqc } from '@pqc-sdk/core';
const plaintext = await pqc.decrypt(ciphertext, pair.secretKey);
new TextDecoder().decode(plaintext);