I want to call function with four parameters. I know how to create two of them, but the last two is the r and s components of ECDSA signature of (param_1, param_2). I tried this (and a lot of combinations), but the result is wrong:
msg = '%d%d' % (param_1, param_2)
message_hash = defunct_hash_message(text=msg)
signed_message = w3.eth.account.signHash(message_hash, private_key=wallet_private_key)
w3.toHex(signed_message['r'])[2:])
w3.toHex(signed_message['s'])[2:])
Next
From code of contract:
r, s - components of ECDSA signature of (commitLastBlock, commit). v is guaranteed to always equal 27.
Made convertaion this way:
signatureHash = w3.soliditySha3(['uint40', 'uint256'], [commitLastBlock, commit])
I checked it and it's valid. But when I sign the result, the r and s values are wrong anyway. I do it whis way:
signed_message = w3.eth.account.signHash(signatureHash, private_key)
type
of the parameters. – Jaime Apr 20 '19 at 12:54