symbol-sdk-python 3.2.0__tar.gz → 3.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/PKG-INFO +1 -1
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/pyproject.toml +1 -1
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/facade/NemFacade.py +40 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/facade/SymbolFacade.py +44 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/nem/MessageEncoder.py +6 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/nem/TransactionFactory.py +5 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/ripemd160.py +1 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/symbol/MessageEncoder.py +6 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/symbol/Metadata.py +14 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/symbol/Network.py +22 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/symbol/TransactionFactory.py +10 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/README.md +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/AccountDescriptorRepository.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/ArrayHelpers.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/BaseValue.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/Bip32.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/BlockchainSettings.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/BufferReader.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/BufferWriter.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/ByteArray.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/Cipher.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/CodeWordsEncoder.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/CryptoTypes.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/DiceMnemonicGenerator.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/Network.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/NetworkTimestamp.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/NodeDescriptorRepository.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/Ordered.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/PrivateKeyStorage.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/QrSignatureStorage.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/QrStorage.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/RuleBasedTransactionFactory.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/SharedKey.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/TransactionDescriptorProcessor.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/Transforms.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/__init__.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/external/__init__.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/external/ed25519.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/facade/BatchOperations.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/facade/__init__.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/impl/CipherHelpers.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/impl/__init__.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/nc/__init__.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/nem/KeyPair.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/nem/Network.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/nem/SharedKey.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/nem/__init__.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/sc/__init__.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/symbol/IdGenerator.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/symbol/KeyPair.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/symbol/Merkle.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/symbol/SharedKey.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/symbol/VotingKeysGenerator.py +0 -0
- {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/symbol/__init__.py +0 -0
|
@@ -4,11 +4,43 @@ import sha3
|
|
|
4
4
|
|
|
5
5
|
from ..CryptoTypes import Hash256, PrivateKey, PublicKey
|
|
6
6
|
from ..nem.KeyPair import KeyPair, Verifier
|
|
7
|
+
from ..nem.MessageEncoder import MessageEncoder
|
|
7
8
|
from ..nem.Network import Address, Network
|
|
8
9
|
from ..nem.SharedKey import SharedKey
|
|
9
10
|
from ..nem.TransactionFactory import TransactionFactory
|
|
10
11
|
from ..Network import NetworkLocator
|
|
11
12
|
|
|
13
|
+
# region NemPublicAccount / NemAccount
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class NemPublicAccount:
|
|
17
|
+
"""NEM public account."""
|
|
18
|
+
|
|
19
|
+
def __init__(self, facade, public_key):
|
|
20
|
+
"""Creates a NEM public account."""
|
|
21
|
+
self._facade = facade
|
|
22
|
+
self.public_key = public_key
|
|
23
|
+
self.address = self._facade.network.public_key_to_address(self.public_key)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class NemAccount(NemPublicAccount):
|
|
27
|
+
"""NEM account."""
|
|
28
|
+
|
|
29
|
+
def __init__(self, facade, key_pair):
|
|
30
|
+
"""Creates a NEM account."""
|
|
31
|
+
super().__init__(facade, key_pair.public_key)
|
|
32
|
+
self.key_pair = key_pair
|
|
33
|
+
|
|
34
|
+
def message_encoder(self):
|
|
35
|
+
"""Creates a message encoder that can be used for encrypting and encoding messages between two parties."""
|
|
36
|
+
return MessageEncoder(self.key_pair)
|
|
37
|
+
|
|
38
|
+
def sign_transaction(self, transaction):
|
|
39
|
+
"""Signs a NEM transaction."""
|
|
40
|
+
return self._facade.sign_transaction(self.key_pair, transaction)
|
|
41
|
+
|
|
42
|
+
# endregion
|
|
43
|
+
|
|
12
44
|
|
|
13
45
|
class NemFacade:
|
|
14
46
|
"""Facade used to interact with NEM blockchain."""
|
|
@@ -46,6 +78,14 @@ class NemFacade:
|
|
|
46
78
|
"""Creates a network timestamp representing the current time."""
|
|
47
79
|
return self.network.from_datetime(datetime.now(timezone.utc))
|
|
48
80
|
|
|
81
|
+
def create_public_account(self, public_key):
|
|
82
|
+
"""Creates a NEM public account from a public key."""
|
|
83
|
+
return NemPublicAccount(self, public_key)
|
|
84
|
+
|
|
85
|
+
def create_account(self, private_key):
|
|
86
|
+
"""Creates a NEM account from a private key."""
|
|
87
|
+
return NemAccount(self, KeyPair(private_key))
|
|
88
|
+
|
|
49
89
|
@staticmethod
|
|
50
90
|
def hash_transaction(transaction):
|
|
51
91
|
"""Hashes a NEM transaction."""
|
|
@@ -6,6 +6,7 @@ from ..CryptoTypes import Hash256, PublicKey, Signature
|
|
|
6
6
|
from ..Network import NetworkLocator
|
|
7
7
|
from ..symbol.KeyPair import KeyPair, Verifier
|
|
8
8
|
from ..symbol.Merkle import MerkleHashBuilder
|
|
9
|
+
from ..symbol.MessageEncoder import MessageEncoder
|
|
9
10
|
from ..symbol.Network import Address, Network
|
|
10
11
|
from ..symbol.SharedKey import SharedKey
|
|
11
12
|
from ..symbol.TransactionFactory import TransactionFactory
|
|
@@ -26,6 +27,41 @@ AGGREGATE_HASHED_SIZE = sum(field[1] for field in [
|
|
|
26
27
|
])
|
|
27
28
|
|
|
28
29
|
|
|
30
|
+
# region SymbolPublicAccount / SymbolAccount
|
|
31
|
+
|
|
32
|
+
class SymbolPublicAccount:
|
|
33
|
+
"""Symbol public account."""
|
|
34
|
+
|
|
35
|
+
def __init__(self, facade, public_key):
|
|
36
|
+
"""Creates a Symbol public account."""
|
|
37
|
+
self._facade = facade
|
|
38
|
+
self.public_key = public_key
|
|
39
|
+
self.address = self._facade.network.public_key_to_address(self.public_key)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class SymbolAccount(SymbolPublicAccount):
|
|
43
|
+
"""Symbol account."""
|
|
44
|
+
|
|
45
|
+
def __init__(self, facade, key_pair):
|
|
46
|
+
"""Creates a Symbol account."""
|
|
47
|
+
super().__init__(facade, key_pair.public_key)
|
|
48
|
+
self.key_pair = key_pair
|
|
49
|
+
|
|
50
|
+
def message_encoder(self):
|
|
51
|
+
"""Creates a message encoder that can be used for encrypting and encoding messages between two parties."""
|
|
52
|
+
return MessageEncoder(self.key_pair)
|
|
53
|
+
|
|
54
|
+
def sign_transaction(self, transaction):
|
|
55
|
+
"""Signs a Symbol transaction."""
|
|
56
|
+
return self._facade.sign_transaction(self.key_pair, transaction)
|
|
57
|
+
|
|
58
|
+
def cosign_transaction(self, transaction, detached=False):
|
|
59
|
+
"""Cosigns a Symbol transaction."""
|
|
60
|
+
return self._facade.cosign_transaction(self.key_pair, transaction, detached)
|
|
61
|
+
|
|
62
|
+
# endregion
|
|
63
|
+
|
|
64
|
+
|
|
29
65
|
class SymbolFacade:
|
|
30
66
|
"""Facade used to interact with Symbol blockchain."""
|
|
31
67
|
|
|
@@ -63,6 +99,14 @@ class SymbolFacade:
|
|
|
63
99
|
"""Creates a network timestamp representing the current time."""
|
|
64
100
|
return self.network.from_datetime(datetime.now(timezone.utc))
|
|
65
101
|
|
|
102
|
+
def create_public_account(self, public_key):
|
|
103
|
+
"""Creates a Symbol public account from a public key."""
|
|
104
|
+
return SymbolPublicAccount(self, public_key)
|
|
105
|
+
|
|
106
|
+
def create_account(self, private_key):
|
|
107
|
+
"""Creates a Symbol account from a private key."""
|
|
108
|
+
return SymbolAccount(self, KeyPair(private_key))
|
|
109
|
+
|
|
66
110
|
def hash_transaction(self, transaction):
|
|
67
111
|
"""Hashes a Symbol transaction."""
|
|
68
112
|
hasher = hashlib.sha3_256()
|
|
@@ -17,6 +17,12 @@ class MessageEncoder:
|
|
|
17
17
|
|
|
18
18
|
self.key_pair = key_pair
|
|
19
19
|
|
|
20
|
+
@property
|
|
21
|
+
def public_key(self):
|
|
22
|
+
"""Public key used for message encoding."""
|
|
23
|
+
|
|
24
|
+
return self.key_pair.public_key
|
|
25
|
+
|
|
20
26
|
def try_decode(self, recipient_public_key, encoded_message: Message):
|
|
21
27
|
"""Tries to decode encoded message, returns tuple:
|
|
22
28
|
* True, message - if message has been decoded and decrypted
|
|
@@ -39,6 +39,11 @@ class TransactionFactory:
|
|
|
39
39
|
|
|
40
40
|
return transaction
|
|
41
41
|
|
|
42
|
+
@staticmethod
|
|
43
|
+
def deserialize(payload):
|
|
44
|
+
"""Deserializes a transaction from a binary payload."""
|
|
45
|
+
return nc.TransactionFactory.deserialize(payload)
|
|
46
|
+
|
|
42
47
|
@staticmethod
|
|
43
48
|
def to_non_verifiable_transaction(transaction):
|
|
44
49
|
"""Converts a transaction to a non-verifiable transaction."""
|
|
@@ -20,6 +20,12 @@ class MessageEncoder:
|
|
|
20
20
|
|
|
21
21
|
self.key_pair = key_pair
|
|
22
22
|
|
|
23
|
+
@property
|
|
24
|
+
def public_key(self):
|
|
25
|
+
"""Public key used for message encoding."""
|
|
26
|
+
|
|
27
|
+
return self.key_pair.public_key
|
|
28
|
+
|
|
23
29
|
def try_decode(self, recipient_public_key, encoded_message):
|
|
24
30
|
"""Tries to decode encoded message, returns tuple:
|
|
25
31
|
* True, message - if message has been decoded and decrypted
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
import hashlib
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def metadata_generate_key(seed):
|
|
5
|
+
"""Generates a metadata key from a string."""
|
|
6
|
+
|
|
7
|
+
hash_result = hashlib.sha3_256(seed.encode('utf8')).digest()
|
|
8
|
+
|
|
9
|
+
key_bytes = bytearray(hash_result[:8])
|
|
10
|
+
key_bytes[7] |= 0x80 # set high bit to match SDK V2 implementation
|
|
11
|
+
|
|
12
|
+
return int.from_bytes(key_bytes, 'little')
|
|
13
|
+
|
|
14
|
+
|
|
1
15
|
def metadata_update_value(old_value, new_value):
|
|
2
16
|
"""Creates a metadata payload for updating old value to new value."""
|
|
3
17
|
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import base64
|
|
2
2
|
import datetime
|
|
3
3
|
import hashlib
|
|
4
|
+
from binascii import unhexlify
|
|
4
5
|
|
|
5
6
|
from ..ByteArray import ByteArray
|
|
6
7
|
from ..CryptoTypes import Hash256
|
|
7
8
|
from ..Network import Network as BasicNetwork
|
|
8
9
|
from ..NetworkTimestamp import NetworkTimestamp as BasicNetworkTimestamp
|
|
9
10
|
from ..NetworkTimestamp import NetworkTimestampDatetimeConverter
|
|
11
|
+
from ..sc import NamespaceId
|
|
10
12
|
|
|
11
13
|
|
|
12
14
|
class NetworkTimestamp(BasicNetworkTimestamp):
|
|
@@ -36,12 +38,32 @@ class Address(ByteArray):
|
|
|
36
38
|
|
|
37
39
|
super().__init__(self.SIZE, raw_bytes, Address)
|
|
38
40
|
|
|
41
|
+
def to_namespace_id(self):
|
|
42
|
+
"""Attempts to convert this address into a namespace id."""
|
|
43
|
+
|
|
44
|
+
if not self.bytes[0] & 0x01:
|
|
45
|
+
return None
|
|
46
|
+
|
|
47
|
+
return NamespaceId(int.from_bytes(self.bytes[1:9], 'little'))
|
|
48
|
+
|
|
39
49
|
def __str__(self):
|
|
40
50
|
return base64.b32encode(self.bytes + bytes(0)).decode('utf8')[0:-1]
|
|
41
51
|
|
|
42
52
|
def __repr__(self):
|
|
43
53
|
return f'Address(\'{str(self)}\')'
|
|
44
54
|
|
|
55
|
+
@staticmethod
|
|
56
|
+
def from_decoded_address_hex_string(hex_string):
|
|
57
|
+
"""Creates an address from a decoded address hex string (typically from REST)."""
|
|
58
|
+
|
|
59
|
+
return Address(unhexlify(hex_string))
|
|
60
|
+
|
|
61
|
+
@staticmethod
|
|
62
|
+
def from_namespace_id(namespace_id, network_identifier):
|
|
63
|
+
"""Creates an address from a namespace id."""
|
|
64
|
+
|
|
65
|
+
return Address(bytes([network_identifier + 1]) + namespace_id.value.to_bytes(8, 'little') + bytes([0] * (Address.SIZE - 9)))
|
|
66
|
+
|
|
45
67
|
|
|
46
68
|
class Network(BasicNetwork):
|
|
47
69
|
"""Represents a Symbol network."""
|
{symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/symbol/TransactionFactory.py
RENAMED
|
@@ -55,6 +55,16 @@ class TransactionFactory:
|
|
|
55
55
|
"""
|
|
56
56
|
return self._create_and_extend(transaction_descriptor, autosort, sc.EmbeddedTransactionFactory)
|
|
57
57
|
|
|
58
|
+
@staticmethod
|
|
59
|
+
def deserialize(payload):
|
|
60
|
+
"""Deserializes a transaction from a binary payload."""
|
|
61
|
+
return sc.TransactionFactory.deserialize(payload)
|
|
62
|
+
|
|
63
|
+
@staticmethod
|
|
64
|
+
def deserialize_embedded(payload):
|
|
65
|
+
"""Deserializes an embedded transaction from a binary payload."""
|
|
66
|
+
return sc.EmbeddedTransactionFactory.deserialize(payload)
|
|
67
|
+
|
|
58
68
|
@staticmethod
|
|
59
69
|
def attach_signature(transaction, signature):
|
|
60
70
|
"""Attaches a signature to a transaction."""
|
|
File without changes
|
{symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/AccountDescriptorRepository.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/RuleBasedTransactionFactory.py
RENAMED
|
File without changes
|
|
File without changes
|
{symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/TransactionDescriptorProcessor.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.2}/symbolchain/symbol/VotingKeysGenerator.py
RENAMED
|
File without changes
|
|
File without changes
|