You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Result is always ValueError: Signature does not match.
I've inspected tronapi.trx.Trx.sign and tronapi.trx.Trx.verify_message and found that they have different code for header definition:
tronapi.trx.Trx.sign
# Determine which header to attach to the message# before encrypting or decryptingheader=TRX_MESSAGE_HEADERifuse_tronelseETH_MESSAGE_HEADERheader+=str(len(transaction))
message_hash=self.tron.keccak(text=header+transaction)
tronapi.trx.Trx.verify_message
# Determine which header to attach to the message# before encrypting or decryptingheader=TRX_MESSAGE_HEADERifuse_tronelseETH_MESSAGE_HEADERmessage_hash=self.tron.keccak(text=header+message)
Adding header += str(len(message)) string into tronapi.trx.Trx.verify_message fixes the problem.
The text was updated successfully, but these errors were encountered:
@Anon731 Can you please provide a complete working code sample with the added header? I'm trying to use your suggestion but not having much luck.
Edit: I ended up using the NodeJS API to correctly match the signature generated with the clientside tronweb API. The python API really shouldn't be doing this differently.
Code example
Result is always
ValueError: Signature does not match
.I've inspected
tronapi.trx.Trx.sign
andtronapi.trx.Trx.verify_message
and found that they have different code for header definition:tronapi.trx.Trx.sign
tronapi.trx.Trx.verify_message
Adding
header += str(len(message))
string intotronapi.trx.Trx.verify_message
fixes the problem.The text was updated successfully, but these errors were encountered: