Class: SealedMessage
Defined in: envelope.ts:37
A sealed (encrypted) message: KEM ciphertext + AES-256-GCM ciphertext + metadata, serialized as CBOR identical to quantum-safe-py's SealedMessage.
Properties
aad
readonlyaad:Uint8Array
Defined in: envelope.ts:49
The caller's additional authenticated data (empty by default).
algorithm
readonlyalgorithm:string
Defined in: envelope.ts:41
KEM algorithm the message was sealed to, e.g. X25519+ML-KEM-768.
ciphertext
readonlyciphertext:Uint8Array
Defined in: envelope.ts:47
AES-256-GCM ciphertext followed by the 16-byte tag.
kemCiphertext
readonlykemCiphertext:Uint8Array
Defined in: envelope.ts:43
The hybrid KEM ciphertext (HybridCipherText.to_bytes()).
nonce
readonlynonce:Uint8Array
Defined in: envelope.ts:45
12-byte AES-GCM nonce.
version
readonlyversion:number
Defined in: envelope.ts:39
Envelope format version: 1 for hybrid KEMs, 2 for pure ML-KEM-1024.
Methods
inspect()
inspect():
SealedInfo
Defined in: envelope.ts:136
Non-secret metadata.
Returns
Version, algorithm and the lengths of the stored fields.
Throws
if the WASM module is not initialised.
toBytes()
toBytes():
Uint8Array
Defined in: envelope.ts:121
CBOR serialization (copy).
Returns
Uint8Array
A fresh copy of the CBOR bytes.
toHex()
toHex():
string
Defined in: envelope.ts:128
Lowercase hex of SealedMessage.toBytes.
Returns
string
The hex string.
toString()
toString():
string
Defined in: envelope.ts:140
Short description with the algorithm and ciphertext length; contains no message data.
Returns
string
fromBytes()
staticfromBytes(data):SealedMessage
Defined in: envelope.ts:76
Parses CBOR bytes (from toBytes() or quantum-safe-py SealedMessage.to_bytes()). The input is copied.
Parameters
data
Uint8Array
CBOR-encoded sealed message.
Returns
SealedMessage
The parsed message.
Throws
if data is not a Uint8Array, ArrayBuffer or typed-array view.
Throws
if data is not a valid sealed message.
fromHex()
staticfromHex(hex):SealedMessage
Defined in: envelope.ts:86
Parses a hex string produced by toHex() / quantum-safe-py to_hex().
Parameters
hex
string
Hex of the CBOR encoding, either case.
Returns
SealedMessage
The parsed message.
Throws
if hex is not valid hex.
Throws
if the decoded bytes are not a valid sealed message.
fromParts()
staticfromParts(parts):SealedMessage
Defined in: envelope.ts:96
Assembles a sealed message from its fields (for example data stored in separate columns).
Parameters
parts
The fields: algorithm, kemCiphertext, nonce and ciphertext are required; aad defaults to empty and version to 1.
aad?
Uint8Array<ArrayBufferLike>
algorithm
string
ciphertext
Uint8Array
kemCiphertext
Uint8Array
nonce
Uint8Array
version?
number
Returns
SealedMessage
The message re-parsed from its CBOR encoding.
Throws
if a byte field is not a Uint8Array, ArrayBuffer or typed-array view.
Throws
if the fields do not form a valid sealed message.