def raw_bytes_from_point(point: Point, only_y_coord=False) -> bytes: uncompressed_point_bytes = point.to_bytes(is_compressed=False) if only_y_coord: y_coord_start = (1 + Point.expected_bytes_length(is_compressed=False)) // 2 return uncompressed_point_bytes[y_coord_start:] else: return uncompressed_point_bytes[1:]
def kdf(ecpoint: Point, key_length: int) -> bytes: data = ecpoint.to_bytes(is_compressed=True) return HKDF(algorithm=hashes.BLAKE2b(64), length=key_length, salt=None, info=None, backend=default_backend()).derive(data)
def kdf( ecpoint: Point, key_length: int, salt: Optional[bytes] = None, info: Optional[bytes] = None, ) -> bytes: data = ecpoint.to_bytes(is_compressed=True) hkdf = HKDF(algorithm=hashes.BLAKE2b(64), length=key_length, salt=salt, info=info, backend=default_backend()) return hkdf.derive(data)
def kdf( ecpoint: Point, key_length: int, salt: Optional[bytes] = None, info: Optional[bytes] = None, ) -> bytes: data = ecpoint.to_bytes(is_compressed=True) salt = salt or b'' info = info or b'' return Hkdf( salt, data, hash=blake2b, ).expand(info=info, length=key_length)