@did-btc1/keypair
    Preparing search index...

    Class SecretKey

    Encapsulates a secp256k1 secret key Provides get methods for different formats (raw, secret, point). Provides helpers methods for comparison, serialization and publicKey generation. SecretKey

    Implements

    Index

    Constructors

    • Instantiates an instance of SecretKey.

      Parameters

      • entropy: Entropy

        bytes (Uint8Array) or secret (bigint)

      Returns SecretKey

      If entropy is not provided, not a valid 32-byte secret key or not a valid bigint seed

    Accessors

    • get bytes(): Uint8Array

      Get the secret key entropy as a byte array.

      Returns Uint8Array

      The secret key bytes as a Uint8Array

    • get hex(): Hex

      Returns the raw secret key as a hex string.

      Returns Hex

      The secret key as a hex string

    • get multibase(): string

      Encode the secret key bytes as a secretKeyMultibase string.

      Returns string

      The secret key in base58btc multibase format

    • get seed(): bigint

      Get the secret key entropy as a bigint.

      Returns bigint

      The secret key as a bigint

    Methods

    • Encodes the secret key bytes to BIP340 multibase format.

      Returns string

      The secret key in BIP340 multibase format.

    • Checks if this secret key is equal to another.

      Parameters

      Returns boolean

      True if the private keys are equal, false otherwise

    • Checks if the secret key is valid.

      Returns boolean

      True if the secret key is valid, false otherwise

    • Checks if the public key is a valid secp256k1 point.

      Parameters

      Returns boolean

      True if the public key is valid, false otherwise

    • Converts the secret key to a JSON object.

      Returns SecretKeyObject

      The secret key as a JSON object

    • Decodes the multibase string to the 34-byte secret key (2 byte prefix + 32 byte key).

      Parameters

      • multibase: string

        The multibase string to decode

      Returns Bytes

      The decoded secret key.

    • Creates a SecretKey object from a JSON object.

      Parameters

      • json: SecretKeyObject

        The JSON object containing the secret key bytes

      Returns SecretKey

      A new SecretKey object

    • Creates a new SecretKey object from a bigint secret.

      Parameters

      • secret: bigint

        The secret bigint

      Returns SecretKey

      A new SecretKey object

    • Generates a public key from the given secret key bytes.

      Parameters

      • bytes: Bytes

        The secret key bytes

      Returns Bytes

      The computed public key bytes

    • Generates random secret key bytes.

      Returns Bytes

      Uint8Array of 32 random bytes.

    • Convert a secret key bytes to a bigint secret.

      Parameters

      • secret: bigint

        The secret key secret.

      Returns Bytes

      The secret key secret as secret key bytes.

    • Converts a SecretKey or KeyBytes to a Pair.

      Parameters

      • bytes: Bytes

      Returns SchnorrKeyPair

      The SchnorrKeyPair object containing the public and private keys

      If the secret key is not valid

    • Convert a bigint secret to secret key bytes.

      Parameters

      • bytes: Bytes

        The secret key bytes

      Returns bigint

      The secret key bytes as a bigint secret