def __init__(self, public_key_bytes: bytes, backend: 'Union[BaseECCBackend, Type[BaseECCBackend], str, None]' = None, ) -> None: validate_uncompressed_public_key_bytes(public_key_bytes) self._raw_key = public_key_bytes super().__init__(backend=backend)
def compress_public_key_bytes( self, uncompressed_public_key_bytes: bytes) -> bytes: validate_uncompressed_public_key_bytes(uncompressed_public_key_bytes) point = ( big_endian_to_int(uncompressed_public_key_bytes[:32]), big_endian_to_int(uncompressed_public_key_bytes[32:]), ) public_key = self.keys.PublicKey.from_point(*point) return public_key.format(compressed=True)