Closed smartDev22 closed 5 years ago
message = tron.toHex(text='hello')
signed = tron.trx.sign(message)
# verify
tron.trx.verify_message(message, signed)
https://github.com/iexbase/tron-api-python/blob/master/tronapi/trx.py#L656
Using your code I get an error:
Traceback (most recent call last): File "<input>", line 1, in <module> File "/*****/python3.6/site-packages/tronapi/trx.py", line 541, in sign message_hash = self.tron.sha3( AttributeError: 'Tron' object has no attribute 'sha3'
here is the complete code that i use:
from tronapi import Tron
full_node = 'https://api.shasta.trongrid.io'
solidity_node = 'https://api.shasta.trongrid.io'
event_server = 'https://api.shasta.trongrid.io'
tron = Tron(full_node=full_node,
solidity_node=solidity_node,
event_server=event_server)
message = tron.toHex ( text = ' hello ' )
signed = tron.trx.sign(message)
Confirmation of the message signature always fails in my case. Used following code:
Always getting ValueError: Signature does not match
.
Always getting ValueError: Signature does not match.
I guess there's a bug either in trx.sign
either in trx.verify_message
method.
trx.verify_message
have following code for header:
...
# Determine which header to attach to the message
# before encrypting or decrypting
header = TRX_MESSAGE_HEADER if use_tron else ETH_MESSAGE_HEADER
message_hash = self.tron.keccak(text=header+message)
...
When trx.sign
one line more header += str(len(transaction))
:
...
# Determine which header to attach to the message
# before encrypting or decrypting
header = TRX_MESSAGE_HEADER if use_tron else ETH_MESSAGE_HEADER
header += str(len(transaction))
message_hash = self.tron.keccak(text=header+transaction)
...
Adding header += str(len(message))
string into verify_message
fixes the problem.
Created separate issue for this - https://github.com/iexbase/tron-api-python/issues/49.
Good afternoon, show me please an example of verification of the message signed tronlink. After signing I get a string of this type:
пытаюсь делать так:
tron.trx.verify_message(message=tron.toHex('123'), signed_message='0x267363b76ac81738e22272c01e212483402f43474f8ac175420d563703470ce74486c6188f9da9ef27bad17ed7ef63797d11337be8b147fe1093de62cca66a7f1c', address='TAQByCrjDDWrMWdDJqTFs5sPnvGb85q1cy')
but in response I get an error