Helper class that makes securing secrets easier by hiding them in closures as additional protection against accidental exposure via debugging, etc. Note, when done with this secret, call zero() to clear the memory, but be warned that this is JavaScript, and that is no guarantee against exposure.

Constructors

Properties

Methods

Constructors

  • Creates an instance of PrivSecretBuf.

    Parameters

    • secret: Uint8Array

      the secret as a Uint8Array.

    Returns PrivSecretBuf

    Throws

    Will throw an error if the secret is not a Uint8Array or is zeroed.

Properties

cfg: {
    didZero: boolean;
}

Type declaration

  • didZero: boolean
secret: Uint8Array

Methods

  • Derives a new secret from the current secret.

    Parameters

    • subkeyId: number

      the subkey ID to use for derivation.

    Returns PrivSecretBuf

    a new instance of PrivSecretBuf with the derived secret.

    Throws

    Will throw an error if the secret has already been zeroed or is not of length 32.

  • Derives a signing public key from the secret.

    Returns Uint8Array

    the derived public key as a Uint8Array.

    Throws

    Will throw an error if the secret has already been zeroed or is not of length 32.

  • Gets the secret.

    Returns Uint8Array

    the secret as a Uint8Array.

    Throws

    Will throw an error if the secret has already been zeroed.

  • Signs a message with the secret.

    Parameters

    • message: string | Uint8Array

      the message to sign, either as a Uint8Array or a string.

    Returns Uint8Array

    the signature as a Uint8Array.

    Throws

    Will throw an error if the secret has already been zeroed or is not of length 32.

  • Zeroes the secret.

    Returns void