def fromSignedJSON( json: Dict[str, Any] ) -> Any: return SignedVerificationPacket( bytes.fromhex(json["hash"]), json["holders"], Signature(bytes.fromhex(json["signature"])) )
def __init__( self, txHash: bytes, holders: List[int] = [], signature: Signature = Signature() ) -> None: VerificationPacket.__init__(self, txHash, holders) self.signature: Signature = signature
def __init__( self, difficulty: bytes, nonce: int = 0, holder: int = 0, signature: Signature = Signature() ) -> None: DataDifficulty.__init__(self, difficulty, nonce, holder) self.signature: Signature = signature
def fromSignedJSON( json: Dict[str, Any] ) -> Any: return SignedDataDifficulty( bytes.fromhex(json["difficulty"]), json["nonce"], json["holder"], Signature(bytes.fromhex(json["signature"])) )
def __init__( self, packets: List[VerificationPacket] = [], elements: List[Element] = [], aggregate: Signature = Signature()) -> None: self.packets: List[VerificationPacket] = list(packets) self.packets.sort(key=lambda packet: packet.hash, reverse=True) self.elements: List[Element] = list(elements) self.aggregate: Signature = aggregate
def __init__( self, inputs: List[Tuple[bytes, int]], output: bytes, signature: bytes = Signature().serialize()) -> None: self.inputs: List[Tuple[bytes, int]] = inputs self.output: bytes = output self.amount: int = 0 self.signature: bytes = signature self.hash = blake2b(b'\1' + self.signature, digest_size=32).digest()
def fromSignedJSON( json: Dict[str, Any] ) -> Any: holders: List[bytes] = [] for holder in json["holders"]: holders.append(bytes.fromhex(holder)) return SignedMeritRemovalVerificationPacket( SignedVerificationPacket(bytes.fromhex(json["hash"])), holders, Signature(bytes.fromhex(json["signature"])) )
def __init__( self, packets: List[VerificationPacket] = [], elements: List[Element] = [], aggregate: Signature = Signature()) -> None: self.packets: List[VerificationPacket] = list(packets) self.packets.sort(key=lambda packet: packet.hash, reverse=True) packetsMerkle: List[bytes] = [] for packet in packets: packetsMerkle.append( blake2b(packet.prefix + packet.serialize(), digest_size=32).digest()) self.packetsContents: bytes = merkle(packetsMerkle) self.elements: List[Element] = list(elements) self.aggregate: Signature = aggregate
def fromJSON(keys: Dict[bytes, int], json: Dict[str, Any]) -> Any: packets: List[VerificationPacket] = [] elements: List[Element] = [] for packet in json["transactions"]: packets.append( VerificationPacket(bytes.fromhex(packet["hash"]), packet["holders"])) for element in json["elements"]: if element["descendant"] == "SendDifficulty": elements.append(SendDifficulty.fromJSON(element)) elif element["descendant"] == "DataDifficulty": elements.append(DataDifficulty.fromJSON(element)) elif element["descendant"] == "MeritRemoval": elements.append(MeritRemoval.fromJSON(keys, element)) return BlockBody(packets, elements, Signature(bytes.fromhex(json["aggregate"])))
def __init__(self, txHash: bytes, holder: int = 0, signature: Signature = Signature()) -> None: Verification.__init__(self, txHash, holder) self.signature: Signature = signature