How to use the blspy.Signature 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 Chia-Network / chia-blockchain / src / util / streamable.py View on Github external
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,
    and adds parse, from bytes, stream, and __bytes__ methods.
github Chia-Network / chia-blockchain / src / types / body.py View on Github external
from blspy import PrependSignature, Signature

from src.types.coinbase import CoinbaseInfo
from src.types.fees_target import FeesTarget
from src.types.sized_bytes import bytes32
from src.util.ints import uint64
from src.util.streamable import Streamable, streamable


@dataclass(frozen=True)
@streamable
class Body(Streamable):
    coinbase: CoinbaseInfo
    coinbase_signature: PrependSignature
    fees_target_info: FeesTarget
    aggregated_signature: Optional[Signature]
    solutions_generator: bytes32  # TODO: use actual transactions
    cost: uint64