Last active
April 6, 2020 17:22
-
-
Save mratsim/f8a6084e68b40fb126b2c766db0ea33e to your computer and use it in GitHub Desktop.
This file contains hidden or 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 ../beacon_chain/spec/digest # from NBC build directory | |
import stew/endians2 | |
func fakeHash*(index: SomeInteger): Eth2Digest = | |
## Create fake hashes | |
## Those are just the value serialized in big-endian | |
## We add 16x16 to avoid having a zero hash are those are special cased | |
## We store them in the first 8 bytes | |
## as those are the one used in hash tables Table[Eth2Digest, T] | |
result.data[0 ..< 8] = (16*16+index).uint64.toBytesBE() | |
var f1 = fakeHash(1) | |
var f9 = fakeHash(9) | |
echo f1 | |
echo f9 | |
import nimcrypto/hash # comment out and it's correct | |
let test = f1 == f9 | |
echo test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment