Skip to content

BitcoinMessageSigner.signMessage doesn't work at all. #4581

@combab0

Description

@combab0

Describe the bug
BitcoinMessageSigner.signMessage crash.

To Reproduce
Steps to reproduce the behavior:

import { initWasm } from '@trustwallet/wallet-core'

const core = await initWasm()
const {
  CoinType,
  HDWallet,
  BitcoinMessageSigner,
  EthereumMessageSigner,
  TronMessageSigner
} = core
const wallet = HDWallet.create(256, '')
const ethkey = wallet.getKeyForCoin(CoinType.ethereum)
const ethpubkey = ethkey.getPublicKey(CoinType.ethereum)
const ethaddr = wallet.getAddressForCoin(CoinType.ethereum)
const ethsig = EthereumMessageSigner.signMessage(ethkey, ethaddr)
const ethcheck = EthereumMessageSigner.verifyMessage(ethpubkey, ethaddr, ethsig)
console.log(ethaddr, ethsig, ethcheck)

const tronkey = wallet.getKeyForCoin(CoinType.tron)
const tronpubkey = tronkey.getPublicKey(CoinType.tron)
const tronaddr = wallet.getAddressForCoin(CoinType.tron)
const tronsig = TronMessageSigner.signMessage(tronkey, tronaddr)
const troncheck = TronMessageSigner.verifyMessage(tronpubkey, tronaddr, tronsig)
console.log(tronaddr, tronsig, troncheck)

/*
export class BitcoinMessageSigner {
    static signMessage(privateKey: PrivateKey, address: string, message: string): string;
    static verifyMessage(address: string, message: string, signature: string): boolean;
}
*/
try {
  const bitkey = wallet.getKeyForCoin(CoinType.bitcoin)
  const bitaddr = wallet.getAddressForCoin(CoinType.bitcoin)
  const bitsig = BitcoinMessageSigner.signMessage(bitkey, bitaddr, 'test')
  const bitcheck = BitcoinMessageSigner.verifyMessage(bitaddr, 'test', bitsig)
  console.log(bitaddr, bitsig, bitcheck)
} catch (e) {
  console.log(e)
}

/*
result:
0xBBb8319FbC518aBe2DACbb1cC59C9f2400e7b97B 25dbacbfc00dbafd114636f2e6f6ce51965db3b6f0f8d4934dfdfd1db3e2ad8770d0f97605c29405cb91bc66b4b70e65b96b0f12f015df74bc6e795b054b46981c true
TLqxFAZmES4x1FnEcpNWmJod9AvR4MAb6P c6dc08fce4c335bde8a115291c48a4146cfaf4f497b0bc5c3a43a2b8478ea43053559a604f098eb9b4ee867ba7b6cfa11069db730bff215c7d11a37f13abfd211b true
2355360 - Exception catching is disabled, this exception cannot be caught. Compile with -sNO_DISABLE_EXCEPTION_CATCHING or -sEXCEPTION_CATCHING_ALLOWED=[..] to catch.
*/

Expected behavior
signMessage should work like a eth, tron..

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions