def test_TestTransactionSignInputs(): handle = utils.makeEmptyTransaction() # Panics if txns already signed sig = skycoin.cipher_Sig() assert skycoin.SKY_coin_Transaction_PushSignature(handle, sig) == skycoin.SKY_OK secKeys = [] secKeys.append(skycoin.cipher_SecKey()) # Panics if not enough keys handle = utils.makeEmptyTransaction() ux, s = utils.makeUxOutWithSecret() h = skycoin.cipher_SHA256() assert skycoin.SKY_coin_UxOut_Hash(ux, h) == skycoin.SKY_OK err, _ = skycoin.SKY_coin_Transaction_PushInput(handle, h) assert err == skycoin.SKY_OK ux2, s2 = utils.makeUxOutWithSecret() assert skycoin.SKY_coin_UxOut_Hash(ux2, h) == skycoin.SKY_OK err, _ = skycoin.SKY_coin_Transaction_PushInput(handle, h) assert err == skycoin.SKY_OK assert skycoin.SKY_coin_Transaction_PushOutput( handle, utils.makeAddress(), 40, 80) == skycoin.SKY_OK err, count = skycoin.SKY_coin_Transaction_GetSignaturesCount(handle) assert err == skycoin.SKY_OK assert count == 0 # Valid signing assert skycoin.SKY_coin_Transaction_HashInner(handle, h) == skycoin.SKY_OK secKeys = [] secKeys.append(s) secKeys.append(s2) assert skycoin.SKY_coin_Transaction_SignInputs( handle, secKeys) == skycoin.SKY_OK err, count = skycoin.SKY_coin_Transaction_GetSignaturesCount(handle) assert err == skycoin.SKY_OK assert count == 2 h2 = skycoin.cipher_SHA256() assert skycoin.SKY_coin_Transaction_HashInner( handle, h2) == skycoin.SKY_OK assert h == h2 p = skycoin.cipher_PubKey() assert skycoin.SKY_cipher_PubKeyFromSecKey(s, p) == skycoin.SKY_OK a = skycoin.cipher__Address() a2 = skycoin.cipher__Address() assert skycoin.SKY_cipher_AddressFromPubKey(p, a) == skycoin.SKY_OK assert skycoin.SKY_cipher_PubKeyFromSecKey(s2, p) == skycoin.SKY_OK assert skycoin.SKY_cipher_AddressFromPubKey(p, a2) == skycoin.SKY_OK sha1 = skycoin.cipher_SHA256() sha2 = skycoin.cipher_SHA256() txin0 = skycoin.cipher_SHA256() txin1 = skycoin.cipher_SHA256() assert skycoin.SKY_coin_Transaction_GetInputAt( handle, 0, txin0) == skycoin.SKY_OK assert skycoin.SKY_coin_Transaction_GetInputAt( handle, 1, txin1) == skycoin.SKY_OK assert skycoin.SKY_cipher_AddSHA256(h, txin0, sha1) == skycoin.SKY_OK assert skycoin.SKY_cipher_AddSHA256(h, txin1, sha2) == skycoin.SKY_OK txsig0 = skycoin.cipher_Sig() txsig1 = skycoin.cipher_Sig() assert skycoin.SKY_coin_Transaction_GetSignatureAt( handle, 0, txsig0) == skycoin.SKY_OK assert skycoin.SKY_coin_Transaction_GetSignatureAt( handle, 1, txsig1) == skycoin.SKY_OK
def test_TestAddressFromBytes(): public_key = skycoin.cipher_PubKey() secret_key = skycoin.cipher_SecKey() skycoin.SKY_cipher_GenerateKeyPair(public_key, secret_key) address = skycoin.cipher__Address() skycoin.SKY_cipher_AddressFromPubKey(public_key, address) address_2 = skycoin.cipher__Address() _, byte = skycoin.SKY_cipher_Address_Bytes(address) err = skycoin.SKY_cipher_AddressFromBytes(byte, address_2) assert err == skycoin.SKY_OK assert address == address_2 # Invalid number of bytes __ = skycoin.cipher__Address() err = skycoin.SKY_cipher_AddressFromBytes(byte[:len(byte) - 2], __) assert err == skycoin.SKY_ErrAddressInvalidLength # Invalid checksum byte_array = bytearray(byte) byte_array[-1] = 1 byte_new = bytes(byte_array) err = skycoin.SKY_cipher_AddressFromBytes(byte_new, __) assert err == skycoin.SKY_ErrAddressInvalidChecksum address.Version = 2 _, b = skycoin.SKY_cipher_Address_Bytes(address) err = skycoin.SKY_cipher_AddressFromBytes(b, __) assert err == skycoin.SKY_ErrAddressInvalidVersion
def makeKeysAndAddress(): ppubkey = skycoin.cipher_PubKey() pseckey = skycoin.cipher_SecKey() err = skycoin.SKY_cipher_GenerateKeyPair(ppubkey, pseckey) assert err == skycoin.SKY_OK paddress = skycoin.cipher__Address() err = skycoin.SKY_cipher_AddressFromPubKey(ppubkey, paddress) assert err == skycoin.SKY_OK return err, ppubkey, pseckey, paddress
def test_TestAddressNull(): address = skycoin.cipher__Address() _error, isNull = skycoin.SKY_cipher_Address_Null(address) assert _error == skycoin.SKY_OK assert isNull == 1 public_key = skycoin.cipher_PubKey() secret_key = skycoin.cipher_SecKey() skycoin.SKY_cipher_GenerateKeyPair(public_key, secret_key) skycoin.SKY_cipher_AddressFromPubKey(public_key, address) assert address is not None
def test_TestSignHash(): public_key = skycoin.cipher_PubKey() secret_key = skycoin.cipher_SecKey() addres = skycoin.cipher__Address() sha_sum = skycoin.cipher_SHA256() sig_1 = skycoin.cipher_Sig() sig_2 = skycoin.cipher_Sig() skycoin.SKY_cipher_GenerateKeyPair(public_key, secret_key) skycoin.SKY_cipher_AddressFromPubKey(public_key, addres) _, data = skycoin.SKY_cipher_RandByte(256) skycoin.SKY_cipher_SumSHA256(data, sha_sum) skycoin.SKY_cipher_SignHash(sha_sum, secret_key, sig_1) assert sig_1 != sig_2
def test_TestPubKeyToAddress(): public_key = skycoin.cipher_PubKey() secret_key = skycoin.cipher_SecKey() skycoin.SKY_cipher_GenerateKeyPair(public_key, secret_key) addres = skycoin.cipher__Address() skycoin.SKY_cipher_AddressFromPubKey(public_key, addres) # func (self Address) Verify(key PubKey) error assert skycoin.SKY_cipher_Address_Verify(addres, public_key) == skycoin.SKY_OK # func DecodeBase58Address(addr string) (Address, error) _, addres_str = skycoin.SKY_cipher_Address_String(addres) assert skycoin.SKY_cipher_DecodeBase58Address(addres_str, addres) == skycoin.SKY_OK
def test_TestAddressRoundtrip(): public_key = skycoin.cipher_PubKey() secret_key = skycoin.cipher_SecKey() skycoin.SKY_cipher_GenerateKeyPair(public_key, secret_key) address = skycoin.cipher__Address() address_2 = skycoin.cipher__Address() skycoin.SKY_cipher_AddressFromPubKey(public_key, address) _, byte = skycoin.skycoin.SKY_cipher_Address_Bytes(address) err = skycoin.skycoin.SKY_cipher_AddressFromBytes(byte, address_2) assert err == skycoin.SKY_OK assert address == address_2 _, addres_str = skycoin.SKY_cipher_Address_String(address) _, addres_2_str = skycoin.SKY_cipher_Address_String(address_2) assert addres_2_str == addres_str
def test_TestAddressBulk(): for _ in range(1024): public_key = skycoin.cipher_PubKey() secret_key = skycoin.cipher_SecKey() addres_1 = skycoin.cipher__Address() address_2 = skycoin.cipher__Address() _, data = skycoin.SKY_cipher_RandByte(32) skycoin.SKY_cipher_GenerateDeterministicKeyPair( data, public_key, secret_key) skycoin.SKY_cipher_AddressFromPubKey(public_key, addres_1) err = skycoin.SKY_cipher_Address_Verify(addres_1, public_key) assert err == skycoin.SKY_OK _, addres_str = skycoin.SKY_cipher_Address_String(addres_1) err = skycoin.SKY_cipher_DecodeBase58Address(addres_str, address_2) assert err == skycoin.SKY_OK assert addres_1 == address_2
def makeUxBodyWithSecret(): p = skycoin.cipher_PubKey() s = skycoin.cipher_SecKey() assert skycoin.SKY_cipher_GenerateKeyPair(p, s) == skycoin.SKY_OK uxb = skycoin.coin__UxBody() err, b = skycoin.SKY_cipher_RandByte(128) assert err == skycoin.SKY_OK h = skycoin.cipher_SHA256() assert skycoin.SKY_cipher_SumSHA256(b, h) == skycoin.SKY_OK assert h.assignTo(uxb.SrcTransaction) == None a = skycoin.cipher__Address() assert skycoin.SKY_cipher_AddressFromPubKey(p, a) == skycoin.SKY_OK uxb.Address = a uxb.Coins = int(1e6) uxb.Hours = int(100) return uxb, s
def test_TestAddressString(): public_key = skycoin.cipher_PubKey() secret_key = skycoin.cipher_SecKey() skycoin.SKY_cipher_GenerateKeyPair(public_key, secret_key) address = skycoin.cipher__Address() skycoin.SKY_cipher_AddressFromPubKey(public_key, address) _, addres_str = skycoin.SKY_cipher_Address_String(address) address_2 = skycoin.cipher__Address() err = skycoin.SKY_cipher_DecodeBase58Address(addres_str, address_2) assert err == skycoin.SKY_OK assert address == address_2 _, addres_2_str = skycoin.SKY_cipher_Address_String(address_2) addres_3 = skycoin.cipher__Address() err = skycoin.SKY_cipher_DecodeBase58Address(addres_2_str, addres_3) assert err == skycoin.SKY_OK assert address_2 == addres_3
def test_GenerateKeyPairs(): error, data = skycoin.SKY_cipher_RandByte(32) assert error == 0 pubkey = skycoin.cipher_PubKey() seckey = skycoin.cipher_SecKey() error = skycoin.SKY_cipher_GenerateDeterministicKeyPair(data, pubkey, seckey) assert error == 0 address = skycoin.cipher__Address() error = skycoin.SKY_cipher_AddressFromPubKey(pubkey, address) assert error == 0 error = skycoin.SKY_cipher_Address_Verify(address, pubkey) assert error == 0 error, address_string = skycoin.SKY_cipher_Address_String( address ) assert error == 0 address2 = skycoin.cipher__Address() error = skycoin.SKY_cipher_DecodeBase58Address( address_string, address2 ) assert error == 0 assert address.isEqual(address2)
def test_TestAddressVerify(): public_key = skycoin.cipher_PubKey() secret_key = skycoin.cipher_SecKey() skycoin.SKY_cipher_GenerateKeyPair(public_key, secret_key) address = skycoin.cipher__Address() skycoin.SKY_cipher_AddressFromPubKey(public_key, address) # Valid pubkey+address err = skycoin.SKY_cipher_Address_Verify(address, public_key) assert err == skycoin.SKY_OK # Invalid pubkey public_key_temp = skycoin.cipher_PubKey() err = skycoin.SKY_cipher_Address_Verify(address, public_key_temp) assert err == skycoin.SKY_ErrAddressInvalidPubKey skycoin.SKY_cipher_GenerateKeyPair(public_key_temp, secret_key) err = skycoin.SKY_cipher_Address_Verify(address, public_key_temp) assert err == skycoin.SKY_ErrAddressInvalidPubKey # Bad version address.Version = 0x01 err = skycoin.SKY_cipher_Address_Verify(address, public_key) assert err == skycoin.SKY_ErrAddressInvalidVersion
def test_TestDecodeBase58Address(): public_key = skycoin.cipher_PubKey() secret_key = skycoin.cipher_SecKey() skycoin.SKY_cipher_GenerateKeyPair(public_key, secret_key) address = skycoin.cipher__Address() skycoin.SKY_cipher_AddressFromPubKey(public_key, address) err = skycoin.SKY_cipher_Address_Verify(address, public_key) assert err == skycoin.SKY_OK address_2 = skycoin.cipher__Address() err = skycoin.SKY_cipher_DecodeBase58Address(b'""', address_2) assert err == skycoin.SKY_ERROR err = skycoin.SKY_cipher_DecodeBase58Address(b'"cascs"', address_2) assert err == skycoin.SKY_ERROR _, byte = skycoin.SKY_cipher_Address_Bytes(address) _, h = skycoin.SKY_base58_Hex2Base58(byte[:int(len(byte) / 2)]) err = skycoin.SKY_cipher_DecodeBase58Address(h, address_2) assert err == skycoin.SKY_ErrAddressInvalidLength _, h = skycoin.SKY_base58_Hex2Base58(byte) err = skycoin.SKY_cipher_DecodeBase58Address(h, address_2) assert err == skycoin.SKY_OK assert address == address_2 _, addres_str = skycoin.SKY_cipher_Address_String(address) err = skycoin.SKY_cipher_DecodeBase58Address(addres_str, address_2) assert err == skycoin.SKY_OK assert address == address_2 # preceding whitespace is invalid addres_2_str = b'" " + a_str' err = skycoin.SKY_cipher_DecodeBase58Address(addres_2_str, address_2) assert err == skycoin.SKY_ERROR # preceding zeroes are invalid addres_2_str = b'"000" + a_str' err = skycoin.SKY_cipher_DecodeBase58Address(addres_2_str, address_2) assert err == skycoin.SKY_ERROR # trailing whitespace is invalid addres_2_str = b'a_str + " "' err = skycoin.SKY_cipher_DecodeBase58Address(addres_2_str, address_2) assert err == skycoin.SKY_ERROR # trailing zeroes are invalid addres_2_str = b'a_str + "000"' err = skycoin.SKY_cipher_DecodeBase58Address(addres_2_str, address_2) assert err == skycoin.SKY_ERROR
def test_TestUxOutCoinHours(): p = skycoin.cipher_PubKey() s = skycoin.cipher_SecKey() skycoin.SKY_cipher_GenerateKeyPair(p, s) uxb = skycoin.coin__UxBody() _, b = skycoin.SKY_cipher_RandByte(128) h = skycoin.cipher_SHA256() assert skycoin.SKY_cipher_SumSHA256(b, h) == skycoin.SKY_OK uxb.SetSrcTransaction(h.toStr()) a = skycoin.cipher__Address() skycoin.SKY_cipher_AddressFromPubKey(p, a) uxb.Address = a uxb.Coins = int(1e6) uxb.Hours = int(100) uxo = skycoin.coin__UxOut() uxh = skycoin.coin__UxHead() uxh.Time = 100 uxh.BkSeq = 2 uxo.Head = uxh uxo.Body = uxb # Less than an hour passed now = uxh.Time + 100 err, hours = skycoin.SKY_coin_UxOut_CoinHours(uxo, now) assert hours == uxh.Time assert err == skycoin.SKY_OK # 1 hours passed now = uxh.Time + 3600 err, hours = skycoin.SKY_coin_UxOut_CoinHours(uxo, now) assert hours == uxh.Time + uxb.Coins / 1000000 assert err == skycoin.SKY_OK # 6 hours passed now = uxh.Time + 3600 * 6 err, hours = skycoin.SKY_coin_UxOut_CoinHours(uxo, now) assert hours == uxh.Time + (uxb.Coins / 1000000) * 6 assert err == skycoin.SKY_OK # Time is backwards (treated as no hours passed) now = uxh.Time // 2 err, hours = skycoin.SKY_coin_UxOut_CoinHours(uxo, now) assert hours == uxh.Time assert err == skycoin.SKY_OK # 1 hour has passed, output has 1.5 coins, should gain 1 coinhour uxb.Coins = 1500000 now = uxh.Time + 3600 err, hours = skycoin.SKY_coin_UxOut_CoinHours(uxo, now) assert hours == uxb.Hours + 1 assert err == skycoin.SKY_OK # 2 hours have passed, output has 1.5 coins, should gain 3 coin hours uxb.Coins = 1500000 uxo.Body = uxb now = uxh.Time + 3600 * 2 err, hours = skycoin.SKY_coin_UxOut_CoinHours(uxo, now) assert hours == uxb.Hours + 3 assert err == skycoin.SKY_OK # 1 second has passed, output has 3600 coins, should gain 1 coin hour uxb.Coins = 3600000000 uxo.Body = uxb now = uxh.Time + 1 err, hours = skycoin.SKY_coin_UxOut_CoinHours(uxo, now) assert hours == uxb.Hours + 1 assert err == skycoin.SKY_OK # 1000000 hours minus 1 second have passed, output has 1 droplet, should gain 0 coin hour uxb.Coins = 1 uxo.Body = uxb now = uxh.Time + 1000000 * 3600 - 1 err, hours = skycoin.SKY_coin_UxOut_CoinHours(uxo, now) assert hours == uxb.Hours assert err == skycoin.SKY_OK # 1000000 hours have passed, output has 1 droplet, should gain 1 coin hour uxb.Coins = 1 uxo.Body = uxb now = uxh.Time + 1000000 * 3600 err, hours = skycoin.SKY_coin_UxOut_CoinHours(uxo, now) assert hours == uxb.Hours + 1 assert err == skycoin.SKY_OK # No hours passed, using initial coin hours uxb.Coins = 1000000000 uxb.Hours = 1000 * 1000 uxo.Body = uxb now = uxh.Time err, hours = skycoin.SKY_coin_UxOut_CoinHours(uxo, now) assert hours == uxb.Hours assert err == skycoin.SKY_OK # One hour passed, using initial coin hours now = uxh.Time + 3600 err, hours = skycoin.SKY_coin_UxOut_CoinHours(uxo, now) assert hours == uxb.Hours + 1000000000 / 1000000 assert err == skycoin.SKY_OK # No hours passed and no hours to begin with0 uxb.Hours = 0 uxo.Body = uxb now = uxh.Time err, hours = skycoin.SKY_coin_UxOut_CoinHours(uxo, now) assert hours == 0 assert err == skycoin.SKY_OK # Centuries have passed, time-based calculation overflows uint64 # when calculating the whole coin seconds uxb.Coins = 2000000 uxo.Body = uxb now = 0xFFFFFFFFFFFFFFFF err, hours = skycoin.SKY_coin_UxOut_CoinHours(uxo, now) assert err == skycoin.SKY_ERROR # Centuries have passed, time-based calculation overflows uint64 # when calculating the droplet seconds uxb.Coins = 1500000 uxo.Body = uxb now = 0xFFFFFFFFFFFFFFFF err, hours = skycoin.SKY_coin_UxOut_CoinHours(uxo, now) assert err == skycoin.SKY_ERROR # Output would overflow if given more hours, has reached its limit uxb.Coins = 3600000000 uxo.Body = uxb now = 0xFFFFFFFFFFFFFFFF err, hours = skycoin.SKY_coin_UxOut_CoinHours(uxo, now) assert err == skycoin.SKY_ERROR
def test_TestUxOutSnapshotHash(): p = skycoin.cipher_PubKey() s = skycoin.cipher_SecKey() skycoin.SKY_cipher_GenerateKeyPair(p, s) uxb = skycoin.coin__UxBody() _, b = skycoin.SKY_cipher_RandByte(128) h = skycoin.cipher_SHA256() assert skycoin.SKY_cipher_SumSHA256(b, h) == skycoin.SKY_OK uxb.SetSrcTransaction(h.toStr()) a = skycoin.cipher__Address() skycoin.SKY_cipher_AddressFromPubKey(p, a) uxb.Address = a uxb.Coins = int(1e6) uxb.Hours = int(100) uxo = skycoin.coin__UxOut() uxh = skycoin.coin__UxHead() uxh.Time = 100 uxh.BkSeq = 2 uxo.Head = uxh uxo.Body = uxb hn = skycoin.cipher_SHA256() assert skycoin.SKY_coin_UxOut_SnapshotHash(uxo, hn) == skycoin.SKY_OK # snapshot hash should be dependent on every field in body and head # Head Time uxo_2 = uxo uxh.Time = 20 uxo_2.Head = uxh hn_2 = skycoin.cipher_SHA256() assert skycoin.SKY_coin_UxOut_SnapshotHash(uxo_2, hn_2) == skycoin.SKY_OK assert hn != hn_2 # Head BkSeq uxo_2 = uxo uxh.BkSeq = 4 uxo_2.Head = uxh hn_2 = skycoin.cipher_SHA256() assert skycoin.SKY_coin_UxOut_SnapshotHash(uxo_2, hn_2) == skycoin.SKY_OK assert hn != hn_2 # Body SetSrcTransaction uxo_2 = uxo uxb = skycoin.coin__UxBody() _, b = skycoin.SKY_cipher_RandByte(128) h = skycoin.cipher_SHA256() assert skycoin.SKY_cipher_SumSHA256(b, h) == skycoin.SKY_OK uxb.SetSrcTransaction(h.toStr()) uxo_2.Body = uxb hn_2 = skycoin.cipher_SHA256() assert skycoin.SKY_coin_UxOut_SnapshotHash(uxo_2, hn_2) == skycoin.SKY_OK assert hn != hn_2 # Body Address p_2 = skycoin.cipher_PubKey() s_2 = skycoin.cipher_SecKey() skycoin.SKY_cipher_GenerateKeyPair(p_2, s_2) a_2 = skycoin.cipher__Address() skycoin.SKY_cipher_AddressFromPubKey(p_2, a_2) uxo_2 = uxo uxb = skycoin.coin__UxBody() uxb.Address = a_2 uxo_2.Body = uxb hn_2 = skycoin.cipher_SHA256() assert skycoin.SKY_coin_UxOut_SnapshotHash(uxo_2, hn_2) == skycoin.SKY_OK assert hn != hn_2 # Body Coins uxo_2 = uxo uxb = skycoin.coin__UxBody() uxb.Coins = int(2) uxo_2.Body = uxb hn_2 = skycoin.cipher_SHA256() assert skycoin.SKY_coin_UxOut_SnapshotHash(uxo_2, hn_2) == skycoin.SKY_OK assert hn != hn_2 # Body Hours uxo_2 = uxo uxb = skycoin.coin__UxBody() uxb.Hours = int(2) uxo_2.Body = uxb hn_2 = skycoin.cipher_SHA256() assert skycoin.SKY_coin_UxOut_SnapshotHash(uxo_2, hn_2) == skycoin.SKY_OK assert hn != hn_2
def makeAddress(): p, s = makecipher_PubKeyAndcipher_SecKey() a = skycoin.cipher__Address() assert skycoin.SKY_cipher_AddressFromPubKey(p, a) == skycoin.SKY_OK return a
def ValidateSeedData(SeedTestData=None, InputTestData=None): err, keys = skycoin.SKY_cipher_GenerateDeterministicKeyPairs( SeedTestData.Seed, len(SeedTestData.Keys)) assert err == skycoin.SKY_OK if len(SeedTestData.Keys) != len(keys): return skycoin.SKY_ERROR for i, s in enumerate(keys): secret_Key_null = skycoin.cipher_SecKey() if s == secret_Key_null: return skycoin.SKY_ErrInvalidSecKey if (SeedTestData.Keys[i].Secret).decode() != binascii.hexlify( bytearray(s.toStr())).decode('ascii'): assert err == skycoin.SKY_ERROR p = skycoin.cipher_PubKey() p_null = skycoin.cipher_PubKey() err = skycoin.SKY_cipher_PubKeyFromSecKey(s, p) if p == p_null: return skycoin.SKY_ErrInvalidPubKey if (SeedTestData.Keys[i].Public).decode() != binascii.hexlify( bytearray(p.toStr())).decode('ascii'): return skycoin.SKY_ErrInvalidPubKey addr1 = skycoin.cipher__Address() addr_null = skycoin.cipher__Address() err = skycoin.SKY_cipher_AddressFromPubKey(p, addr1) assert err == skycoin.SKY_OK if addr1 == addr_null: return skycoin.SKY_ErrAddressInvalidPubKey if not (SeedTestData.Keys[i].Address == addr1): return skycoin.SKY_ErrAddressInvalidChecksum addr2 = skycoin.cipher__Address() err = skycoin.SKY_cipher_AddressFromSecKey(s, addr2) assert err == skycoin.SKY_OK if not (addr1 == addr2): return skycoin.SKY_ErrAddressInvalidChecksum if InputTestData == None and SeedTestData.Keys[i].Signatures != 0: return skycoin.SKY_ERROR if InputTestData != None: if len(SeedTestData.Keys[i].Signatures) != len(InputTestData): return skycoin.SKY_ERROR for j in range(len(InputTestData)): sig = SeedTestData.Keys[i].Signatures[j] sig_null = skycoin.cipher_Sig() if sig == sig_null: return skycoin.SKY_ERROR err = skycoin.SKY_cipher_VerifySignedHash( sig, InputTestData[j]) if err != skycoin.SKY_OK: return skycoin.SKY_ERROR p2 = skycoin.cipher_PubKey() err = skycoin.SKY_cipher_PubKeyFromSig(sig, InputTestData[j], p2) if err != skycoin.SKY_OK: return skycoin.SKY_ERROR if not (p == p2): return 1 return skycoin.SKY_ERROR sig2 = skycoin.cipher_Sig() skycoin.SKY_cipher_SignHash(InputTestData[j], s, sig2) if sig2 == sig_null: return skycoin.SKY_ERROR return skycoin.SKY_OK