How to use the blspy.PrivateKey.PRIVATE_KEY_SIZE function in blspy

To help you get started, we’ve selected a few blspy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ethereum / trinity / eth2 / _utils / bls / backends / chia / api.py View on Github external
def _privkey_from_int(privkey: int) -> PrivateKey:
    privkey_bytes = privkey.to_bytes(PrivateKey.PRIVATE_KEY_SIZE, "big")
    try:
        return PrivateKey.from_bytes(privkey_bytes)
    except RuntimeError as error:
        raise ValueError(f"Bad private key: {privkey}, {error}")
github Chia-Network / chia-blockchain / src / util / streamable.py View on Github external
import io
import dataclasses
import pprint
from typing import Type, BinaryIO, get_type_hints, Any, List
from hashlib import sha256
from blspy import (PrivateKey, PublicKey, InsecureSignature, Signature, PrependSignature,
                   ExtendedPrivateKey, ExtendedPublicKey, ChainCode)
from src.util.type_checking import strictdataclass, is_type_List, is_type_SpecificOptional
from src.types.sized_bytes import bytes32
from src.util.ints import uint32

pp = pprint.PrettyPrinter(indent=1, width=120, compact=True)

# TODO: Remove hack, this allows streaming these objects from binary
size_hints = {
    "PrivateKey": PrivateKey.PRIVATE_KEY_SIZE,
    "PublicKey": PublicKey.PUBLIC_KEY_SIZE,
    "Signature": Signature.SIGNATURE_SIZE,
    "InsecureSignature": InsecureSignature.SIGNATURE_SIZE,
    "PrependSignature": PrependSignature.SIGNATURE_SIZE,
    "ExtendedPublicKey": ExtendedPublicKey.EXTENDED_PUBLIC_KEY_SIZE,
    "ExtendedPrivateKey": ExtendedPrivateKey.EXTENDED_PRIVATE_KEY_SIZE,
    "ChainCode": ChainCode.CHAIN_CODE_KEY_SIZE
}
unhashable_types = [PrivateKey, PublicKey, Signature, PrependSignature, InsecureSignature,
                    ExtendedPublicKey, ExtendedPrivateKey, ChainCode]


def streamable(cls: Any):
    """
    This is a decorator for class definitions. It applies the strictdataclass decorator,
    which checks all types at construction. It also defines a simple serialization format,