@nats-io/nats-core
    Preparing search index...

    Interface KeyPair

    interface KeyPair {
        clear(): void;
        getPrivateKey(): Uint8Array;
        getPublicKey(): string;
        getSeed(): Uint8Array;
        open(message: Uint8Array, sender: string): Uint8Array<ArrayBufferLike>;
        seal(input: Uint8Array, recipient: string, nonce?: Uint8Array): Uint8Array;
        sign(input: Uint8Array): Uint8Array;
        verify(input: Uint8Array, sig: Uint8Array): boolean;
    }
    Index

    Methods

    • Clears the secret stored in the keypair. After clearing a keypair cannot be used or recovered.

      Returns void

    • Returns the private key associated with the KeyPair

      Returns Uint8Array

      Uint8Array

      NKeysError

    • Returns the public key associated with the KeyPair

      Returns string

      NKeysError

    • Returns the PrivateKey's seed.

      Returns Uint8Array

      Uint8Array

      NKeysError

    • Opens (decrypts) and processes a given message from a specified sender. Note that only curve keys can open a payload.

      Parameters

      • message: Uint8Array

        The message to be opened and processed.

      • sender: string

        The sender of the message.

      Returns Uint8Array<ArrayBufferLike>

      Returns the processed message as a Uint8Array if successful, or null if the operation fails.

      if not a curve key

    • Seals (encrypts) the provided input data with the recipient's public key and an optional nonce. Note that only curve keys can seal a payload.

      Parameters

      • input: Uint8Array

        The data to be encrypted.

      • recipient: string

        The recipient's identifier or public key.

      • Optionalnonce: Uint8Array

        An optional nonce to use in the encryption process.

      Returns Uint8Array

      The encrypted data.

      if not a curve key

    • Returns the digital signature of signing the input with the the KeyPair's private key. Note that only non-curve keys can sign.

      Parameters

      • input: Uint8Array

      Returns Uint8Array

      Uint8Array

      NKeysError if a curve key

    • Returns true if the signature can be verified with the KeyPair Note that only non-curve keys can verify.

      Parameters

      • input: Uint8Array
      • sig: Uint8Array

      Returns boolean

      NKeysError if a curve key