示例#1
0
def test_IKM_to_lamport_SK(test_vector) -> None:
    test_vector_lamport_0 = [
        bytes.fromhex(x) for x in test_vector['lamport_0']
    ]
    test_vector_lamport_1 = [
        bytes.fromhex(x) for x in test_vector['lamport_1']
    ]
    salt = test_vector['child_index'].to_bytes(4, 'big')
    IKM = test_vector['master_SK'].to_bytes(32, 'big')
    lamport_0 = _IKM_to_lamport_SK(IKM=IKM, salt=salt)
    not_IKM = _flip_bits_256(test_vector['master_SK']).to_bytes(32, 'big')
    lamport_1 = _IKM_to_lamport_SK(IKM=not_IKM, salt=salt)
    assert test_vector_lamport_0 == lamport_0
    assert test_vector_lamport_1 == lamport_1
示例#2
0
def test_flip_bits_256(test_vector) -> None:
    test_vector_int = int(test_vector['seed'][:64],
                          16)  # 64 comes from string chars containing .5 bytes
    assert test_vector_int & _flip_bits_256(test_vector_int) == 0