I am signing a message using TronLink/TronWeb.js but unable to verify it in Python
Python Library I am using https://github.com/iexbase/tron-api-python/
Javascript Code for Signing Message:
const original_message = "557e3517549cf8ed47d8b205654ea2a7"
const signedtxn = await tronWeb.trx.sign(original_message);
// result 0x862e16c28684bed7162e9a1dd34962882d887610de6c775054ffbad989baec65707b2ba898366c02e9f20730bc2daf54bb7e6d33d77c64f8930f8c9365f5993a1b
Python Code for Verifying Signed Message
from tronapi import Tron
from hexbytes import HexBytes
tron = Tron()
class signed_message:
# signedtxn variable in javascript
signature = HexBytes('0x862e16c28684bed7162e9a1dd34962882d887610de6c775054ffbad989baec65707b2ba898366c02e9f20730bc2daf54bb7e6d33d77c64f8930f8c9365f5993a1b')
original_message = "557e3517549cf8ed47d8b205654ea2a7"
address = "<!-- Tron Base58 Address in TronLink/TronWeb -->"
tron.trx.verify_message(original_message, signed_message, address=address)
I am getting this error in python
ValueError: Signature does not match
I can verify the message in TronWeb.js but can't in Python
You can use tronpy (yes, I am the author of tronpy.)
PublicKey.verify_msg
the last byte of your signature should be
0x01
or0x00
, which is different from ETH.