Пример #1
0
def test_TestGenerateDeterministicKeyPair():
    # deterministic key pairs are useless as is because we can't
    # generate pair n+1, only pair 0
    public_key = skycoin.cipher_PubKey()
    secret_key = skycoin.cipher_SecKey()
    _, seed = skycoin.SKY_cipher_RandByte(32)
    skycoin.SKY_cipher_GenerateDeterministicKeyPair(seed, public_key,
                                                    secret_key)
    assert skycoin.SKY_cipher_PubKey_Verify(public_key) == skycoin.SKY_OK
    assert skycoin.SKY_cipher_SecKey_Verify(secret_key) == skycoin.SKY_OK
    skycoin.SKY_cipher_GenerateDeterministicKeyPair(seed, public_key,
                                                    secret_key)
    assert skycoin.SKY_cipher_PubKey_Verify(public_key) == skycoin.SKY_OK
    assert skycoin.SKY_cipher_SecKey_Verify(secret_key) == skycoin.SKY_OK
Пример #2
0
def test_TestSecKeyVerify():
    # Empty secret key should not be valid
    secret_key = skycoin.cipher_SecKey()
    public_key = skycoin.cipher_PubKey()
    assert skycoin.SKY_cipher_SecKey_Verify(secret_key) is not None
    # Generated sec key should be valid
    skycoin.SKY_cipher_GenerateKeyPair(public_key, secret_key)
    assert skycoin.SKY_cipher_PubKey_Verify(public_key) == skycoin.SKY_OK
Пример #3
0
def test_TestPubKeyVerify():
    # Random bytes should not be valid, most of the time
    failed = False
    for _ in range(10):
        public_key = skycoin.cipher_PubKey()
        _, data = skycoin.SKY_cipher_RandByte(33)
        skycoin.SKY_cipher_NewPubKey(data, public_key)
        if skycoin.SKY_cipher_PubKey_Verify(public_key) is not None:
            failed = True
            break
    assert failed is True
Пример #4
0
def test_TestPubKeyVerifyDefault2():
    for _ in range(1024):
        public_key = skycoin.cipher_PubKey()
        secret_key = skycoin.cipher_SecKey()
        skycoin.SKY_cipher_GenerateKeyPair(public_key, secret_key)
        assert skycoin.SKY_cipher_PubKey_Verify(public_key) == skycoin.SKY_OK
Пример #5
0
def test_TestPubKeyVerifyDefault1():
    #  Generated pub key should be valid
    public_key = skycoin.cipher_PubKey()
    secret_key = skycoin.cipher_SecKey()
    skycoin.SKY_cipher_GenerateKeyPair(public_key, secret_key)
    assert skycoin.SKY_cipher_PubKey_Verify(public_key) == skycoin.SKY_OK
Пример #6
0
def test_TestPubKeyVerifyNil():
    # Empty public key should not be valid
    public_key = skycoin.cipher_PubKey()
    assert skycoin.SKY_cipher_PubKey_Verify(
        public_key) == skycoin.SKY_ErrInvalidPubKey
Пример #7
0
def test_TestGenerateKeyPair():
    public_key = skycoin.cipher_PubKey()
    secret_key = skycoin.cipher_SecKey()
    skycoin.SKY_cipher_GenerateKeyPair(public_key, secret_key)
    assert skycoin.SKY_cipher_PubKey_Verify(public_key) == skycoin.SKY_OK
    assert skycoin.SKY_cipher_SecKey_Verify(secret_key) == skycoin.SKY_OK