1

The Zokrates tutorial here starts with calculating the SHA256 hash of (the number) 5.

The hex representation of the result is shown at the bottom here:

enter image description here

However, I could not reproduce this on my ubuntu 18.04 command line:

(venv3.6) ~/zokrates_tutorial$ echo 5 | sha256sum
f0b5c2c2211c8d67ed15e75e656c7862d086e9245420892a7de62cd9ec582a06  -

So what's going on here?

1 Answer 1

1

So, I found a convincing verification via this link.

In python there exists a function that turns a hex string into a byte representation like so:

>>> preimage = bytes.fromhex('00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05')

from which then the hex digest can be computed:

>>> hashlib.sha256(preimage).hexdigest()
'c6481e22c5ff4164af680b8cfaa5e8ed3120eeff89c4f307c4a6faaae059ce10'

which is indeed the same a in the tutorial.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.