examples: add sign message python example

Require Python3 and eth_keys

Signed-off-by: Clément Péron <peron.clem@gmail.com>
This commit is contained in:
Clément Péron
2019-03-25 17:49:57 +01:00
parent a9e1da08b3
commit 51ac58fd37
2 changed files with 100 additions and 5 deletions

View File

@@ -23,14 +23,12 @@ from rlp import Serializable
try:
from Crypto.Hash import keccak
def sha3_256(x): return keccak.new(digest_bits=256, data=x).digest()
def sha3_256(x): return keccak.new(digest_bits=256, data=x.encode()).digest()
except:
import sha3 as _sha3
def sha3_256(x): return _sha3.sha3_256(x).digest()
address = Binary.fixed_length(20, allow_empty=True)
address = Binary.fixed_length(20, allow_empty=True)
def sha3(seed):
return sha3_256(str(seed))
@@ -71,4 +69,4 @@ def unsigned_tx_from_tx(tx):
to=tx.to,
value=tx.value,
data=tx.data,
)
)