예제 #1
0
파일: chain2.py 프로젝트: gengmoqi/trinity
 def get_block_signature_by_root(self, block_root: Root) -> BLSSignature:
     """
     ``block_root`` is the hash tree root of a beacon block.
     This method provides a way to reconstruct the ``SignedBeaconBlock`` if required.
     """
     key = SchemaV1.block_root_to_signature(block_root)
     try:
         return BLSSignature(self.db[key])
     except KeyError:
         raise BlockNotFound()
예제 #2
0
from eth.constants import (
    ZERO_HASH32, )

from eth2.beacon.typing import (BLSSignature, EpochNumber)

#
# shuffle function
#

# The size of 3 bytes in integer
# sample_range = 2 ** (3 * 8) = 2 ** 24 = 16777216
# sample_range = 16777216

# Entropy is consumed from the seed in 3-byte (24 bit) chunks.
RAND_BYTES = 3
# The highest possible result of the RNG.
RAND_MAX = 2**(RAND_BYTES * 8) - 1

EMPTY_SIGNATURE = BLSSignature(b'\x00' * 96)
GWEI_PER_ETH = 10**9
FAR_FUTURE_EPOCH = EpochNumber(2**64 - 1)

GENESIS_PARENT_ROOT = ZERO_HASH32
예제 #3
0
def aggregate_signatures(signatures: Sequence[BLSSignature]) -> BLSSignature:
    o = Z2
    for s in signatures:
        o = FQP_point_to_FQ2_point(add(o, decompress_G2(s)))
    return BLSSignature(compress_G2(o))
예제 #4
0
def sign(message: bytes, privkey: int, domain: int) -> BLSSignature:
    return BLSSignature(
        compress_G2(multiply(hash_to_G2(message, domain), privkey)))
예제 #5
0
def G2_to_signature(pt: Tuple[int, int]) -> BLSSignature:
    return BLSSignature(pt[0].to_bytes(48, "big") + pt[1].to_bytes(48, "big"))
예제 #6
0
from eth2.beacon.typing import (
    BLSSignature,
    SlotNumber,
)

#
# shuffle function
#

# The size of 3 bytes in integer
# sample_range = 2 ** (3 * 8) = 2 ** 24 = 16777216
# sample_range = 16777216

# Entropy is consumed from the seed in 3-byte (24 bit) chunks.
RAND_BYTES = 3
# The highest possible result of the RNG.
RAND_MAX = 2**(RAND_BYTES * 8) - 1

EMPTY_SIGNATURE = BLSSignature((0, 0))
GWEI_PER_ETH = 10**9
FAR_FUTURE_SLOT = SlotNumber(2**64 - 1)