Created
June 12, 2022 09:39
-
-
Save madhavanmalolan/75c06979dc28cb57d4283ff7a788b4e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib | |
from web3 import Web3 | |
def bytes_to_u64_4(hex): | |
# to u64[4] | |
return [str(int(hex[i:i+16], 16)) for i in range(0,64, 16)] | |
def zokrates_sha3(hex): | |
hash = Web3.sha3(hexstr=hex).hex()[:64] | |
return bytes_to_u64_4(hash) | |
if __name__ == "__main__": | |
raw_msg = "test" | |
msg = hashlib.sha512(raw_msg.encode("utf-8")).digest() | |
M0 = msg.hex()[:64] | |
b0 = bytes_to_u64_4(M0) | |
args = " ".join(b0) | |
hash_am = zokrates_sha3(M0) | |
args += " "+ " ".join(hash_am) | |
print(args) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment