Esempio n. 1
0
 def test_sign_without_secret_raise(self):
     data = b"Hello, Kuknos!"
     can_not_sign_kp = Keypair.from_public_key(
         "GAXDYNIBA5E4DXR5TJN522RRYESFQ5UNUXHIPTFGVLLD5O5K552DF5ZH"
     )
     with pytest.raises(MissingEd25519SecretSeedError):
         can_not_sign_kp.sign(data)
Esempio n. 2
0
 def test_can_sign(self):
     can_sign_kp = Keypair.from_secret(
         "SD7X7LEHBNMUIKQGKPARG5TDJNBHKC346OUARHGZL5ITC6IJPXHILY36"
     )
     can_not_sign_kp = Keypair.from_public_key(
         "GAXDYNIBA5E4DXR5TJN522RRYESFQ5UNUXHIPTFGVLLD5O5K552DF5ZH"
     )
     assert can_sign_kp.can_sign() is True
     assert can_not_sign_kp.can_sign() is False
Esempio n. 3
0
 def test_create_from_public_key(self):
     public_key = "GAXDYNIBA5E4DXR5TJN522RRYESFQ5UNUXHIPTFGVLLD5O5K552DF5ZH"
     kp = Keypair.from_public_key(public_key)
     assert isinstance(kp, Keypair)
     assert (
         kp.public_key == "GAXDYNIBA5E4DXR5TJN522RRYESFQ5UNUXHIPTFGVLLD5O5K552DF5ZH"
     )
     assert (
         kp.raw_public_key().hex()
         == "2e3c35010749c1de3d9a5bdd6a31c12458768da5ce87cca6aad63ebbaaef7432"
     )
Esempio n. 4
0
 def test_from_xdr_object_alphanum12(self):
     code = "Banana"
     issuer = "GCNY5OXYSY4FKHOPT2SPOQZAOEIGXB5LBYW3HVU3OWSTQITS65M5RCNY"
     type = "credit_alphanum12"
     asset_code = kuknos_xdr.AssetCode12(
         bytearray(code, "ascii") + b"\x00" * (12 - len(code)))
     asset = kuknos_xdr.AssetAlphaNum12(
         asset_code=asset_code,
         issuer=Keypair.from_public_key(issuer).xdr_account_id(),
     )
     xdr = kuknos_xdr.Asset(
         type=kuknos_xdr.AssetType.ASSET_TYPE_CREDIT_ALPHANUM12,
         alpha_num12=asset)
     asset = Asset.from_xdr_object(xdr)
     assert asset.code == code
     assert asset.issuer == issuer
     assert asset.type == type
Esempio n. 5
0
from kuknos_sdk.keypair import Keypair

# create a random keypair
print("create a random keypair")
kp = Keypair.random()
print("Secret: {}".format(kp.secret))
print("Public Key: {}".format(kp.public_key))
print("")

# create a keypair from secret
print("create a keypair from secret")
secret = "SBRR6ZPBHHTDXYSFRZR2QZCGDZURNE5ON4M4F3HQA42G3Z62SFCR7EEJ"
kp = Keypair.from_secret(secret)
print("Secret: {}".format(kp.secret))
print("Public Key: {}".format(kp.public_key))
print("")

# create a keypair from public key
print("create a keypair from public key")
public_key = "GDCZ6JDZMWYORTIHEO2E4ZXKBQ2TLXNRQJPJH5RCFN7Q7I24G4RGLXP6"
kp = Keypair.from_public_key(public_key)
print("Public Key: {}".format(kp.public_key))
Esempio n. 6
0
 def test_create_from_invalid_public_key_raise(self, invalid_public_key):
     with pytest.raises(
         Ed25519PublicKeyInvalidError,
         match="Invalid Ed25519 Public Key: {}".format(invalid_public_key),
     ):
         Keypair.from_public_key(invalid_public_key)
Esempio n. 7
0
 def test_signature_hint(self, public_key, hint):
     assert Keypair.from_public_key(public_key).signature_hint() == hint
Esempio n. 8
0
 def test_read_secret_without_secret_raise(self):
     kp = Keypair.from_public_key(
         "GAXDYNIBA5E4DXR5TJN522RRYESFQ5UNUXHIPTFGVLLD5O5K552DF5ZH"
     )
     with pytest.raises(MissingEd25519SecretSeedError):
         secret = kp.secret