tronprotocol / tronweb

Javascript API Library for interacting with the TRON Network
MIT License
423 stars 271 forks source link

Incorect signature #420

Closed JumboJet5 closed 11 months ago

JumboJet5 commented 1 year ago

Hi

I have a issue with signMessageV2 on iOS version - 17.0 tronLink app version - v4.13.8

When I try to sign message, I got wrong signature

Example:

on app

    tronWeb: 5.1.0-m-1.7
    message: Message
    method: signMessageV2
    sign: 0x57df6449d0d8eca7a87101022a37dccffd226f4d4588ffc33aae6ff9494a857457df6449d0d8eca7a87101022a37dccffd226f4d4588ffc33aae6ff9494a85741b

on web

    tronWeb: 5.1.1
    message: Message
    method: signMessageV2
    sign: 0x57df6449d0d8eca7a87101022a37dccffd226f4d4588ffc33aae6ff9494a85745c54789f6b985b55f61039698fb0c8a083c56195b95e76a7ef99df30e527e2851b

both signed by TTYtkC5FmWm8VMan7xvhkwLVApE9MubY8S wallet

JumboJet5 commented 1 year ago

same with sign method

start940315 commented 1 year ago

As I've tested, the function has no problem. Maybe you used different private key? You can use tronweb.trx.verifyMessageV2 to get the signer address. Obviously, they are different address.

JumboJet5 commented 1 year ago

I'm pretty sure that address was same

Problem relative only for iPhone app

for example:

iPhone app

    tronWeb: 5.3.0-m-1.9-m-1.9
    account: TTYtkC5FmWm8VMan7xvhkwLVApE9MubY8S
    message: Message
    method: signMessageV2
    sign: 0x57df6449d0d8eca7a87101022a37dccffd226f4d4588ffc33aae6ff9494a857457df6449d0d8eca7a87101022a37dccffd226f4d4588ffc33aae6ff9494a85741b
    verifyMessageV2: TZDW9R8TZFXPEtck6EH62ttvsaPcysUDxr
    tronWeb: 5.3.0-m-1.9-m-1.9
    account: TBHUWr3na3atEghVNZ1BmhK7fe5Fss3icX
    message: Message
    method: signMessageV2
    sign: 0x460bc25fafc75c3dbda3bf2ace6f5c0281e35e0e7ded5c1b0f7996177b79197d460bc25fafc75c3dbda3bf2ace6f5c0281e35e0e7ded5c1b0f7996177b79197d1b
    verifyMessageV2: TTToYmpek6f5uKmD2dUhpu5ntGjBBd7cBP

Android app

    tronWeb: 5.3.0-m-1.9-m-1.9
    account: TTYtkC5FmWm8VMan7xvhkwLVApE9MubY8S
    message: Message
    method: signMessageV2
    sign: 0x57df6449d0d8eca7a87101022a37dccffd226f4d4588ffc33aae6ff9494a85745c54789f6b985b55f61039698fb0c8a083c56195b95e76a7ef99df30e527e2851b
    verifyMessageV2: TTYtkC5FmWm8VMan7xvhkwLVApE9MubY8S
    tronWeb: 5.3.0-m-1.9-m-1.9
    account: TGXbmCc6fBn5WXPVgC9wgN1TPf2HvkMoRC
    message: Message
    method: signMessageV2
    sign: 0xfd97c550d971e96007b37ff4abac981099b7e0a7144dd16f1480ccc2359be81e1d199828dc4d4327f0588de788815f318ce67d375f357ff25982f72bf1efeaab1c
    verifyMessageV2: TGXbmCc6fBn5WXPVgC9wgN1TPf2HvkMoRC

Component

const TestSign = (): JSX.Element => {
  const account = (tronWeb as any)?.defaultAddress?.base58

  const [sign, setSign] = useState('')
  const message = 'Message'
  const signMessage = async () => {
    if (!tronWeb) {
      return setSign('')
    }
    return setSign(await (tronWeb as any).trx.signMessageV2(message))
  }
  const version = (tronWeb as any)?.version
  const copyInfo = async () =>
    copy(`
    tronWeb: ${version}
    account: ${account}
    message: ${message}
    method: signMessageV2
    sign: ${sign}
    verifyMessageV2: ${await (tronWeb as any)?.trx?.verifyMessageV2(message, sign)}
    `)

  return (
    <div>
      <div>
        <button onClick={signMessage} style={{ color: 'black' }}>
          sign
        </button>
      </div>
      <div>{version}</div>
      <div>{message}</div>
      <div>{sign}</div>
      <div>
        <button onClick={copyInfo} style={{ color: 'black' }}>
          copy
        </button>
      </div>
    </div>
  )
}
JumboJet5 commented 1 year ago

U can share me commit or branch with the actual iPhone build and I will try to help reproduce and debug this bug, bcs in iPhone app devTools really poor for understanding what happens

mariabeyrak commented 11 months ago

Same issue for me. iOS 17 @start940315

start940315 commented 11 months ago

We have locate the bug and will fix it in the next version. For more information please join tronlink developers telegram group