This class provides key pair functionality for Ed25519 curve: generating key pairs, encoding key pairs, signing and verifying.

Hierarchy

Constructors

  • Construct an instance of key pair given a secret key. It's generally assumed that these are encoded in base58.

    Parameters

    • extendedSecretKey: string

    Returns KeyPairEd25519

Properties

extendedSecretKey: string
publicKey: PublicKey
secretKey: string

Methods

  • Signs a message using the key pair's secret key.

    Parameters

    • message: Uint8Array

      The message to be signed.

    Returns Signature

    The signature object containing the signature and the public key.

  • Returns a string representation of the key pair in the format 'ed25519:[extendedSecretKey]'.

    Returns string

    The string representation of the key pair.

  • Verifies the signature of a message using the key pair's public key.

    Parameters

    • message: Uint8Array

      The message to be verified.

    • signature: Uint8Array

      The signature to be verified.

    Returns boolean

    true if the signature is valid, otherwise false.

  • Generate a new random keypair.

    Returns KeyPairEd25519

    Example

    const keyRandom = KeyPair.fromRandom();
    keyRandom.publicKey
    // returns [PUBLIC_KEY]

    keyRandom.secretKey
    // returns [SECRET_KEY]

Generated using TypeDoc