mirror of
https://github.com/logos-blockchain/logos-blockchain-specs.git
synced 2026-01-29 02:13:08 +00:00
Use blake2b
This commit is contained in:
parent
53d2526dcf
commit
5c830a2d77
@ -1,10 +1,18 @@
|
||||
import itertools
|
||||
from hashlib import blake2b
|
||||
from typing import List, Dict, Tuple, Set, Optional, Self
|
||||
from carnot import Id, Committee
|
||||
from overlay import EntropyOverlay
|
||||
import random
|
||||
|
||||
|
||||
def blake2b_hash(committee: Committee) -> bytes:
|
||||
hasher = blake2b(digest_size=32)
|
||||
for member in committee:
|
||||
hasher.update(member)
|
||||
return hasher.digest()
|
||||
|
||||
|
||||
class CarnotTree:
|
||||
"""
|
||||
This balanced binary tree implementation uses a combination of indexes and keys to easily calculate parenting
|
||||
@ -66,8 +74,8 @@ class CarnotTree:
|
||||
for node in nodes[-remainder:]:
|
||||
next(cycling_committees).add(node)
|
||||
committees = [frozenset(s) for s in committees]
|
||||
# TODO: This hash method should be specific to what we would want to use for the protocol
|
||||
hashes = [hash(s) for s in committees]
|
||||
|
||||
hashes = [blake2b_hash(s) for s in committees]
|
||||
return hashes, dict(enumerate(committees))
|
||||
|
||||
def parent_committee(self, committee_id: Id) -> Optional[Id]:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user