-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to verify TronLink/TronWeb.js signed message in tron-api #77
Comments
plugin hasn't been updated for a long time, let's check |
Currently, this code does solve the issue for verifying TronWeb generated signature from eth_hash.auto import keccak as keccak_256
# message length is 32 chars and message is a hex string without 0x prefix
# eg message = "557e3517549cf8ed47d8b205654ea2a7"
message_hash = keccak_256(header.encode('utf-8') + bytes.fromhex(message)) |
thanks, let's check this signature feature |
message = tron.trx.sign(tron.toHex(text="test"))
print(
tron.trx.verify_message(tron.toHex(text="test"), message)
) |
How to convert tronweb.trx.sign(hexMessage) to UTF format in tronlink wallet |
Here is the document code: var str = "helloworld"; // verify the signature so , Java verifyMsg: it is same as tron.trx.sign |
Do I understand correctly, this library is not suitable for me to verify the signature if the signature is done on the frontend via tronweb? |
where does |
For those who will come here. TronLink expects a fixed message length of 32. To comply with compatibility, you can use something like this: from tronapi.common.account import Account, Address
from tronapi.trx import TRX_MESSAGE_HEADER
from trx_utils import to_text, to_hex
from tronapi import Tron
TronClient = Tron()
message_hash = TronClient.keccak(text=TRX_MESSAGE_HEADER + '32' + to_text(hexstr=body.nonce))
recovered = Account.recover_hash(to_hex(message_hash), body.sign)
print(address == Address.from_hex('41' + recovered[2:]).decode()) |
Unfortunately, The HDD where this testing code was stored has failed. But I guess it should be Tron or Ethereum header |
Javascript Code for Signing Message:
Python Code for Verifying Signed Message
I am getting this error
ValueError: Signature does not match
The text was updated successfully, but these errors were encountered: