Appearance
@pqc-sdk/core / decrypt
Function: decrypt()
decrypt(
ciphertext,secretKey):Promise<Uint8Array<ArrayBufferLike>>
Decrypts a ciphertext produced by encrypt, discriminating the envelope on its leading version byte (0x01 = ml-kem-768 v1, 0x02 = x-wing v2; unknown versions fail with INVALID_CIPHERTEXT). 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
Returns
Promise<Uint8Array<ArrayBufferLike>>
Example
ts
import { pqc } from '@pqc-sdk/core';
const plaintext = await pqc.decrypt(ciphertext, pair.secretKey);
new TextDecoder().decode(plaintext);