Skip to content

Instantly share code, notes, and snippets.

@madhavanmalolan
Created June 12, 2022 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madhavanmalolan/75c06979dc28cb57d4283ff7a788b4e1 to your computer and use it in GitHub Desktop.
Save madhavanmalolan/75c06979dc28cb57d4283ff7a788b4e1 to your computer and use it in GitHub Desktop.
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