Skip to content

Function: sealStream() ​

sealStream(publicKey, source, options?): AsyncGenerator<Uint8Array<ArrayBufferLike>>

Defined in: stream.ts:355

Encrypts a stream of byte chunks (any sizes) to publicKey. Yields the encrypted stream as an async sequence of byte pieces: the prelude (magic, header), then one frame per chunk. Concatenate the pieces to store or send them. Input of any length, including none, is accepted.

Input is re-cut into chunks of chunkSize bytes. A full chunk is sealed only once more data has arrived behind it, so the final chunk, which holds the remaining 0 to chunkSize bytes, is always sealed as the last one. The sealer is freed when the generator finishes or is closed.

Parameters ​

publicKey ​

PublicKey

The recipient's hybrid KEM key or ML-KEM-1024 key.

source ​

ByteSource

The plaintext, as an async or sync iterable of byte arrays.

options? ​

SealStreamOptions = {}

aad and chunkSize (see SealStreamOptions).

Returns ​

AsyncGenerator<Uint8Array<ArrayBufferLike>>

An async generator of the encrypted pieces.

Throws ​

for a key that is not a hybrid KEM key or ML-KEM-1024.

Throws ​

for a chunkSize that is not an integer from 1,024 to 16,777,216, or a piece of source that is not bytes.

Apache-2.0.