alphazero / Blake2b

Java implementation of the BLAKE2b cryptographic hash function
Other
79 stars 22 forks source link

BLAKE2b-256 #4

Closed xianaofei closed 6 years ago

xianaofei commented 6 years ago

hashPrevouts: BLAKE2b-256('ZcashPrevoutHash','') = d53a633bbecf82fe9e9484d8a0e727c73bb9e68c96e72dec30144f6a84afa136 How to write this project, thank you

xianaofei commented 6 years ago

python h = hashlib.blake2b(person=b'ZcashOutputsHash', digest_size=32) h.update(binascii.unhexlify(b'8f739811893e0000095200ac6551ac636565b1a45a0805750200025151')) print(h.hexdigest())

ec55f4afc6cebfe1c35bdcded7519ff6efb381ab1d5a8dd0060c13b2a512932b

java Blake2b mac = Blake2b.Mac.newInstance("ZcashPrevoutHash".getBytes(), 32); mac.update("".getBytes()); tmp = mac.digest(); System.out.println("end..." + toHexString(tmp)); out 8cfa9d64e689eb8447f1080d81f4ca37be863e780f6875b69b1a51df589c2201 ec55f4afc6cebfe1c35bdcded7519ff6efb381ab1d5a8dd0060c13b2a512932b != 8cfa9d64e689eb8447f1080d81f4ca37be863e780f6875b69b1a51df589c2201

mac.update("".getBytes()); Is there a problem here and how to use it? Thank you.

alphazero commented 6 years ago

@xianaofei, Your Python code hashes a different message than your Java code. You are also passing different keys to initialize the MAC. The python library you are using is also not identified. The MAC tests are conformant to the C reference implementation.

Closing issue.