From 2dcbdc2ae99eb58326c02b582556382e73d9e8cb Mon Sep 17 00:00:00 2001 From: mratsim Date: Thu, 6 Dec 2018 15:02:30 +0100 Subject: [PATCH] Update hash function from blake2b to keccak https://github.com/ethereum/eth2.0-specs/pull/227 and https://github.com/ethereum/eth2.0-specs/issues/151 --- test_vectors_generator/tgen_shuffling.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/test_vectors_generator/tgen_shuffling.py b/test_vectors_generator/tgen_shuffling.py index a8f73351e..26fcddcc9 100644 --- a/test_vectors_generator/tgen_shuffling.py +++ b/test_vectors_generator/tgen_shuffling.py @@ -59,10 +59,18 @@ from enum import IntEnum import random Hash32 = NewType('Hash32', bytes) -from hashlib import blake2b +## See https://github.com/ethereum/eth2.0-specs/pull/227 +## and https://github.com/ethereum/eth2.0-specs/issues/151 +## Hashing as been changed from Blake2b-512[:32] to Keccak256 + +# from hashlib import blake2b +# def hash(x): +# return blake2b(x).digest()[:32] + +from eth_utils import keccak def hash(x): - return blake2b(x).digest()[:32] + return keccak(x) class ValidatorStatus(IntEnum): PENDING_ACTIVATION = 0 @@ -278,7 +286,7 @@ if __name__ == '__main__': # Config random.seed(int("0xEF00BEAC", 16)) - num_val = 15 # Number of validators + num_val = 256 # Number of validators seedhash = bytes(random.randint(0, 255) for byte in range(32))