Skip to content

Class: SecretBytes ​

Defined in: keys.ts:413

32 bytes of secret material in WASM memory: a KEM shared secret or an Argon2id master key. Also exported as SharedSecret.

Accessors ​

length ​

Get Signature ​

get length(): number

Defined in: keys.ts:435

Number of secret bytes held.

Throws ​

if the object has been freed.

Returns ​

number

Methods ​

[dispose]() ​

[dispose](): void

Defined in: keys.ts:475

Supports using secret = ...; calls SecretBytes.free.

Returns ​

void


deriveKey() ​

deriveKey(length, info): Uint8Array

Defined in: keys.ts:450

HKDF-SHA256 with no salt (identical to quantum-safe-py SharedSecret.derive_key).

Parameters ​

length ​

number

Output length in bytes, at most 8160.

info ​

Uint8Array

Domain-separation string, e.g. utf8('myapp-encryption-v1').

Returns ​

Uint8Array

length derived bytes (a copy in the JavaScript heap; wipe it when sensitive).

Throws ​

if length exceeds 8160.

Throws ​

if length is not a non-negative integer, info is not bytes, or the object has been freed.

Example ​

ts
const key = secret.deriveKey(32, utf8('myapp-encryption-v1'));

exportBytes() ​

exportBytes(): Uint8Array

Defined in: keys.ts:460

Copies the secret out of WASM memory. Wipe the copy after use.

Returns ​

Uint8Array

Throws ​

if the object has been freed.


free() ​

free(): void

Defined in: keys.ts:471

Wipes and releases the secret in WASM memory. The object is unusable afterwards. Calling it again does nothing.

Returns ​

void


toJSON() ​

toJSON(): object

Defined in: keys.ts:483

Never reveals the secret: returns a redaction marker.

Returns ​

object

redacted ​

redacted: true

type ​

type: "SecretBytes"


toString() ​

toString(): string

Defined in: keys.ts:479

Never reveals the secret.

Returns ​

string


from() ​

static from(data): SecretBytes

Defined in: keys.ts:427

Moves a copy of data into WASM memory. Wipe your own copy afterwards.

Parameters ​

data ​

Uint8Array

The secret bytes; must not be empty.

Returns ​

SecretBytes

A new SecretBytes.

Throws ​

if data is empty or not bytes.

Apache-2.0.