@btc-vision/ecpair - v4.0.2
    Preparing search index...

    Class ECPairSigner

    Concrete secp256k1 key-pair signer backed by a CryptoBackend.

    Instances are created exclusively through the static factory methods (ECPairSigner.fromPrivateKey, ECPairSigner.fromPublicKey, ECPairSigner.fromWIF, ECPairSigner.makeRandom).

    import { ECPairSigner, createNobleBackend } from 'ecpair';

    const backend = createNobleBackend();
    const signer = ECPairSigner.makeRandom(backend, bitcoin);
    const sig = signer.sign(messageHash);

    Implements

    Index

    Accessors

    Methods

    • Imports a signer from a WIF-encoded private key string.

      Parameters

      • backend: CryptoBackend

        Cryptographic backend to use.

      • wifString: string

        Base58Check WIF string.

      • network: Network | readonly Network[]

        One or more candidate networks whose WIF version byte is matched.

      Returns ECPairSigner

      If no network matches the decoded version byte.

    • Produces a compact ECDSA signature.

      When lowR is true, grinds the nonce until the R value's first byte is <= 0x7f, producing a smaller DER encoding.

      Parameters

      • hash: MessageHash

        32-byte message digest.

      • OptionallowR: boolean

        Enable low-R grinding. Defaults to false.

      Returns Signature

      If this is a public-key-only signer.

    • Exports the private key as a WIF string using this signer's network.

      Returns string

      If this is a public-key-only signer.

    • Derives a new signer by applying a Taproot-style scalar tweak.

      When a private key is available the tweak is applied to the scalar (negating first if the public key has odd Y). Otherwise, only the public key is tweaked via x-only point addition.

      Parameters

      Returns ECPairSigner

      If the tweaked key is invalid (e.g. lands on the point at infinity).