Version Information
- vyper Version (output of
vyper --version): 0.3.6+commit.4a2124d0
- OS: osx
- Python Version (output of
python --version): Python 3.9.13
Folded hashes are computed on utf8 encoded strings, runtime hashes are computed on latin1 encoded strings
# @version 0.3.6
@external
@view
def compile_hash() -> bytes32:
return keccak256('è')
@external
@view
def runtime_hash() -> bytes32:
str:String[1] = 'è'
return keccak256(str)
Here runtime_hash() and compile_hash() should return the same bytes32 value, but they are different. one is the hash of 0xe8 (ord('è')), the other is the hash of 0xc3a8 ('è'.encode())
How can it be fixed?
Encode strings in Keccak256 folding the same way as they are represented at runtime
Version Information
vyper --version): 0.3.6+commit.4a2124d0python --version): Python 3.9.13Folded hashes are computed on
utf8encoded strings, runtime hashes are computed on latin1 encoded stringsHere
runtime_hash()andcompile_hash()should return the same bytes32 value, but they are different. one is the hash of0xe8(ord('è')), the other is the hash of0xc3a8('è'.encode())How can it be fixed?
Encode strings in Keccak256 folding the same way as they are represented at runtime