ecpair

A library for managing SECP256k1 keypairs written in TypeScript with transpiled JavaScript committed to git.
This BitGo fork improves compatibility with fork coins, and alternative SECP256K1 implementations.
Example
TypeScript
import { Signer, SignerAsync, ECPairInterface, ECPairFactory, ECPairAPI, TinySecp256k1Interface } from 'ecpair';
import * as crypto from 'crypto';
const tinysecp: TinySecp256k1Interface = require('tiny-secp256k1');
const ECPair: ECPairAPI = ECPairFactory(tinysecp);
const keyPair1: ECPairInterface = ECPair.fromWIF('KynD8ZKdViVo5W82oyxvE18BbG6nZPVQ8Td8hYbwU94RmyUALUik');
const keyPair2 = ECPair.fromPrivateKey(crypto.randomBytes(32));
const keyPair3 = ECPair.makeRandom();
const customRandomBufferFunc = (size: number): Buffer => crypto.randomBytes(size);
const keyPair4 = ECPair.makeRandom({ rng: customRandomBufferFunc });
const keyPair5 = ECPair.fromPublicKey(keyPair1.publicKey);
const network = {};
ECPair.makeRandom({ network });
ECPair.fromPrivateKey(crypto.randomBytes(32), { network });
ECPair.fromPublicKey(keyPair1.publicKey, { network });
ECPair.fromWIF('wif key...', network);
const network2 = {};
const network3 = {};
ECPair.fromWIF('wif key...', [network, network2, network3]);
LICENSE MIT
Written and tested by bitcoinjs-lib contributors since 2014.