Closed
Description
- Version: 4.8.2
- Python: 3.7.1
- OS: linux
pip freeze
output
ppdirs==1.4.3
APScheduler==3.5.3
attrdict==2.0.0
backcall==0.1.0
borgbackup==1.1.7
Brlapi==0.6.7
btrfsutil==1.0.0
CacheControl==0.12.5
chardet==3.0.4
chrome-gnome-shell==0.0.0
colorama==0.4.1
cycler==0.10.0
cytoolz==0.9.0.1
decorator==4.3.0
distlib==0.2.8
distro==1.3.0
eth-abi==1.2.2
eth-account==0.3.0
eth-hash==0.2.0
eth-keyfile==0.5.1
eth-keys==0.2.0b3
eth-rlp==0.1.2
eth-typing==1.3.0
eth-utils==1.3.0
Glances==3.0.2
hexbytes==0.1.0
html5lib==1.0.1
idna==2.7
ipython==7.1.1
ipython-genutils==0.1.0
jedi==0.13.1
kiwisolver==1.0.1
lensfun==0.3.2
lockfile==0.12.2
louis==3.7.0
lru-dict==1.1.6
matplotlib==3.0.2
meld==3.19.1
msgpack==0.5.6
mutagen==1.41.1
numpy==1.15.4
packaging==18.0
parsimonious==0.8.1
parso==0.3.1
pexpect==4.6.0
pickleshare==0.7.5
progress==1.4
prompt-toolkit==2.0.7
psutil==5.4.8
ptyprocess==0.6.0
pycairo==1.18.0
pycryptodome==3.7.2
Pygments==2.3.0
PyGObject==3.30.4
pyparsing==2.3.0
PyQt5==5.11.3
PyQt5-sip==4.19.13
python-dateutil==2.7.5
pytoml==0.1.20
pytz==2018.7
pyxdg==0.26
requests==2.20.1
retrying==1.3.3
rlp==1.0.3
simplegeneric==0.8.1
six==1.11.0
team==1.0
toolz==0.9.0
traitlets==4.3.2
tzlocal==1.5.1
urllib3==1.24.1
wcwidth==0.1.7
web3==4.8.2
webencodings==0.5.1
websockets==6.0
What was wrong?
I am trying to implement EIP712 signatures in python. In order to do that, I need to follow a very strict hashing mechanism. I've got it working in web3.js and in solidity, but I fail to achieve the same hashes in python.
In order to compute the domain separator I use the following code:
return web3.soliditySha3([
"bytes32",
"bytes32",
"bytes32",
"uint256",
"address",
],[
EIP712DOMAIN_TYPEHASH,
web3.sha3(text=domain.name ),
web3.sha3(text=domain.version),
domain.chainId,
domain.verifyingContract,
])
when checked, all 5 elements are the same as what web3.js produces. However, the result of soliditySha3 is not the same. I noticed that when I change the description of verifyingContract from 'address' to 'bytes32', the resulting hash doesn't change. Is it possible python's soliditySha3 does not abi.encode correctly ?
Just for the record, here is the corresponding javascript code:
return web3.utils.keccak256(web3.eth.abi.encodeParameters([
"bytes32",
"bytes32",
"bytes32",
"uint256",
"address",
],[
EIP712DOMAIN_TYPEHASH,
web3.utils.keccak256(domain.name ),
web3.utils.keccak256(domain.version),
domain.chainId,
domain.verifyingContract,
]));
Metadata
Metadata
Assignees
Labels
No labels