Options
All
  • Public
  • Public/Protected
  • All
Menu

Class KeyPair

Hierarchy

  • KeyPair

Index

Constructors

constructor

  • new KeyPair(publicKey: Uint8Array, privateKey: Uint8Array): KeyPair

Properties

Readonly privateKey

privateKey: Uint8Array

Readonly publicKey

publicKey: Uint8Array

Readonly publicKeyAPI

publicKeyAPI: string

Readonly publicKeyChecksum

publicKeyChecksum: string

Methods

exportToFile

  • exportToFile(filename: string, password: string): Promise<unknown>
  • Same as exportToText this writes the exported text to a file.

    Parameters

    • filename: string
    • password: string

      Password to encrypt the private key.

    Returns Promise<unknown>

exportToString

  • exportToString(password: string): string
  • Export the keypair to a encrypt base64 fromatted text string. The private key is encrypted using the provided password.

    Parameters

    • password: string

      Password to encrypt the private key.

    Returns string

    The encrpted private key as a encrypted base64 formatted string.

sign

  • sign(text: string): Promise<string>
  • Sign a hash message. This is called by the convex API class to sign a hash returned from the prepare api. This signed message cryptographically proves that the keypair owner has access to the private key.

    The API calls this with a hex string, that is converted to bytes, and then sigend. The resultant signed data is sent back as a hex string.

    Parameters

    • text: string

      Text hex string to sign

    Returns Promise<string>

    A hex string signed with a prefix of '0x'

Static create

Static createFromPrivateKey

  • createFromPrivateKey(privateKey: Uint8Array): Promise<KeyPair>

Static importFromFile

  • importFromFile(filename: string, password: string): Promise<KeyPair>
  • Imports a private key file. The key file is in the format as a encrpted base64 text. The private key is encrypted.

    Parameters

    • filename: string

      Filename containing the encrypted private key.

    • password: string

      Password to decrypt the private key.

    Returns Promise<KeyPair>

    An KeyPair object with the private and public keys.

Static importFromString

  • importFromString(text: string, password: string): Promise<KeyPair>
  • Imports a keypair from a encrypted base64 text string. You need to pass the correct password, to decrypt the private key stored in the text string.

    Parameters

    • text: string

      Encrpted base64 fromated text with the private key encrypted.

    • password: string

      Password to decrypt the private key.

    Returns Promise<KeyPair>

    an KeyPair object with the private and public key pairs.

Generated using TypeDoc