def compress_public_key(uncompressed_public_key_bytes: bytes) -> bytes: x, y = decode_public_key(uncompressed_public_key_bytes) if y % 2 == 0: prefix = b"\x02" else: prefix = b"\x03" return prefix + pad32(int_to_big_endian(x))
def to_bytes(self): return b''.join( pad32(int_to_big_endian(value)) for value in self.rs )
def encode_raw_public_key(raw_public_key: Tuple[int, int]) -> bytes: left, right = raw_public_key return b''.join(( pad32(int_to_big_endian(left)), pad32(int_to_big_endian(right)), ))
def to_bytes(self) -> bytes: vb = int_to_byte(self.v) rb = pad32(int_to_big_endian(self.r)) sb = pad32(int_to_big_endian(self.s)) return b''.join((rb, sb, vb))