bit-sig-verifier-in-eth
TypeScript icon, indicating that this package has built-in type declarations

0.0.15 • Public • Published

Verifying native bit message signature in evm.

notes

Both the ethereum and the bitcoin are base the spec256k1 curve, that means the signature signed by bitcoin wallet can be verified in smart contracts. The format of address and signature are different in bitcoin and ethereum, but they have same private key and publick key. You can convert them by this peoject.

test

yarn
yarn hardhat test

install

yarn add --dev bit-sig-verifier-in-eth

usage

import { convertToEthSignature, compressedPublicKeyToAddress, verifyBitSignatureWithEthAddress } from 'bit-sig-verifier-in-eth'

async function () {
    //generate random signer
    const ethwallet = ethers.Wallet.createRandom()
    const bitkey = new PrivateKey(ethwallet.privateKey.substring(2))
        
    const address = compressedPublicKeyToAddress(bitkey.toPublicKey().toBuffer().toString('hex'))
    expect(address).to.equal(await ethwallet.getAddress())
}

Readme

Keywords

none

Package Sidebar

Install

npm i bit-sig-verifier-in-eth

Weekly Downloads

1

Version

0.0.15

License

MIT

Unpacked Size

517 kB

Total Files

16

Last publish

Collaborators

  • evanmusk