def _header_digest(header: c.Container, header_type: c.Construct, hash_function: Callable = blake2s) -> bytes: stripped_header = header.copy() stripped_header.sigmask = 0 stripped_header.signature = b"\0" * 64 stripped_header.v1_key_indexes = [0, 0, 0] stripped_header.v1_signatures = [b"\0" * 64] * 3 header_bytes = header_type.build(stripped_header) return hash_function(header_bytes).digest()
def _header_digest( header: c.Container, header_type: c.Construct, hash_function: Callable = pyblake2.blake2s, ) -> bytes: stripped_header = header.copy() stripped_header.sigmask = 0 stripped_header.signature = b"\0" * 64 stripped_header.v1_key_indexes = [0, 0, 0] stripped_header.v1_signatures = [b"\0" * 64] * 3 header_bytes = header_type.build(stripped_header) return hash_function(header_bytes).digest()
def _header_digest(header: c.Container, header_type: c.Construct) -> bytes: stripped_header = header.copy() stripped_header.sigmask = 0 stripped_header.signature = b"\0" * 64 header_bytes = header_type.build(stripped_header) return pyblake2.blake2s(header_bytes).digest()
def test_serde(obj_type: Construct, obj_input: Any, expected: Any) -> None: """Tests that inputs are serialized and deserialized as expected.""" serialized = obj_type.build(obj_input) assert list(serialized) == expected deserialized = obj_type.parse(serialized) assert deserialized == obj_input