Example #1
0
 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:]
Example #2
0
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)
Example #3
0
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)
Example #4
0
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)