@blockchaincommons/components - v1.0.0-beta.4
    Preparing search index...

    Class ECPrivateKey

    EC private key for ECDSA and Schnorr signatures (secp256k1, 32 bytes)

    An ECPrivateKey is a 32-byte secret value that can be used to:

    • Generate its corresponding public key
    • Sign messages using the ECDSA signature scheme
    • Sign messages using the Schnorr signature scheme (BIP-340)

    These keys use the secp256k1 curve, which is the same curve used in Bitcoin and other cryptocurrencies.

    CBOR Serialization

    ECPrivateKey is serialized to CBOR with tags 40306 (or legacy 306).

    The format is a map:

    #6.40306({
    2: true, // indicates private key
    3: h'<32-byte-private-key>' // key data
    })

    Implements

    Index
    KEY_SIZE: number = ecdsa.PRIVATE_KEY_SIZE

    The byte length of a ECPrivateKey.

    • Derive an ECPrivateKey from the given key material.

      Parameters

      • keyMaterial: Uint8Array

        The key material to derive from

      Returns ECPrivateKey

      A new ECPrivateKey derived from the key material

    • Sign a message using ECDSA.

      Parameters

      • message: Uint8Array

        The message to sign

      Returns Uint8Array

      A 64-byte signature

    • Sign a message using Schnorr signature (BIP-340).

      Parameters

      • message: Uint8Array

        The message to sign

      Returns Uint8Array

      A 64-byte signature

    • Sign a message using Schnorr signature with custom RNG.

      Parameters

      • message: Uint8Array

        The message to sign

      • rng: RandomNumberGenerator

        Random number generator for auxiliary randomness

      Returns Uint8Array

      A 64-byte signature

    • The first four bytes of reference() in hex, the reference's ref_hex_short.

      Returns string

    • The CBOR tags of this type; the first one is used to encode. As the reference, this type is only encoded: it has no fromCbor.

      Returns Tag[]

    • Returns the untagged CBOR encoding.

      Format: { 2: true, 3: h'<32-byte-key>' }

      Returns Cbor