symbol-sdk-python 3.2.0__tar.gz → 3.2.3__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.
Files changed (54) hide show
  1. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/PKG-INFO +6 -6
  2. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/pyproject.toml +5 -5
  3. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/BaseValue.py +4 -0
  4. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/ByteArray.py +4 -0
  5. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/Network.py +1 -1
  6. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/facade/NemFacade.py +49 -7
  7. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/facade/SymbolFacade.py +64 -10
  8. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/nc/__init__.py +463 -24
  9. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/nem/MessageEncoder.py +6 -0
  10. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/nem/TransactionFactory.py +5 -0
  11. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/ripemd160.py +1 -0
  12. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/sc/__init__.py +660 -4
  13. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/symbol/MessageEncoder.py +6 -0
  14. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/symbol/Metadata.py +14 -0
  15. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/symbol/Network.py +22 -0
  16. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/symbol/TransactionFactory.py +10 -0
  17. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/README.md +0 -0
  18. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/AccountDescriptorRepository.py +0 -0
  19. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/ArrayHelpers.py +0 -0
  20. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/Bip32.py +0 -0
  21. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/BlockchainSettings.py +0 -0
  22. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/BufferReader.py +0 -0
  23. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/BufferWriter.py +0 -0
  24. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/Cipher.py +0 -0
  25. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/CodeWordsEncoder.py +0 -0
  26. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/CryptoTypes.py +0 -0
  27. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/DiceMnemonicGenerator.py +0 -0
  28. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/NetworkTimestamp.py +0 -0
  29. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/NodeDescriptorRepository.py +0 -0
  30. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/Ordered.py +0 -0
  31. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/PrivateKeyStorage.py +0 -0
  32. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/QrSignatureStorage.py +0 -0
  33. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/QrStorage.py +0 -0
  34. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/RuleBasedTransactionFactory.py +0 -0
  35. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/SharedKey.py +0 -0
  36. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/TransactionDescriptorProcessor.py +0 -0
  37. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/Transforms.py +0 -0
  38. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/__init__.py +0 -0
  39. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/external/__init__.py +0 -0
  40. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/external/ed25519.py +0 -0
  41. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/facade/BatchOperations.py +0 -0
  42. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/facade/__init__.py +0 -0
  43. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/impl/CipherHelpers.py +0 -0
  44. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/impl/__init__.py +0 -0
  45. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/nem/KeyPair.py +0 -0
  46. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/nem/Network.py +0 -0
  47. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/nem/SharedKey.py +0 -0
  48. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/nem/__init__.py +0 -0
  49. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/symbol/IdGenerator.py +0 -0
  50. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/symbol/KeyPair.py +0 -0
  51. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/symbol/Merkle.py +0 -0
  52. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/symbol/SharedKey.py +0 -0
  53. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/symbol/VotingKeysGenerator.py +0 -0
  54. {symbol_sdk_python-3.2.0 → symbol_sdk_python-3.2.3}/symbolchain/symbol/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: symbol-sdk-python
3
- Version: 3.2.0
3
+ Version: 3.2.3
4
4
  Summary: Symbol SDK
5
5
  Home-page: https://github.com/symbol/symbol/tree/main/sdk/python
6
6
  License: MIT
@@ -9,19 +9,19 @@ Author: Symbol Contributors
9
9
  Author-email: contributors@symbol.dev
10
10
  Maintainer: Symbol Contributors
11
11
  Maintainer-email: contributors@symbol.dev
12
- Requires-Python: >=3.9,<4.0
12
+ Requires-Python: >=3.9.2,<4.0.0
13
13
  Classifier: License :: OSI Approved :: MIT License
14
14
  Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.9
16
15
  Classifier: Programming Language :: Python :: 3.10
17
16
  Classifier: Programming Language :: Python :: 3.11
18
- Requires-Dist: cryptography (>=42.0.2,<42.1.0)
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Requires-Dist: cryptography (>=44.0.0,<44.1.0)
19
19
  Requires-Dist: mnemonic (>=0.20,<1.0)
20
- Requires-Dist: pillow (>=10.3.0,<10.4.0)
20
+ Requires-Dist: pillow (>=11.0.0,<11.1.0)
21
21
  Requires-Dist: pynacl (>=1.5.0,<1.6.0)
22
22
  Requires-Dist: pyyaml (>=6.0.1,<6.1.0)
23
23
  Requires-Dist: pyzbar (>=0.1.9,<0.2.0)
24
- Requires-Dist: qrcode (>=7.4.2,<7.5.0)
24
+ Requires-Dist: qrcode (>=8.0,<9.0)
25
25
  Requires-Dist: ripemd-hash (>=1.0.1,<1.1.0)
26
26
  Requires-Dist: safe-pysha3 (>=1.0.4,<1.1.0)
27
27
  Project-URL: Repository, https://github.com/symbol/symbol/tree/main/sdk/python
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = 'symbol-sdk-python'
3
- version = '3.2.0'
3
+ version = '3.2.3'
4
4
  description = 'Symbol SDK'
5
5
  authors = ['Symbol Contributors <contributors@symbol.dev>']
6
6
  maintainers = ['Symbol Contributors <contributors@symbol.dev>']
@@ -17,13 +17,13 @@ keywords = ['symbol', 'sdk', 'Symbol SDK']
17
17
  classifiers = ['Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11']
18
18
 
19
19
  [tool.poetry.dependencies]
20
- python = "^3.9"
21
- cryptography = ">=42.0.2,<42.1.0"
20
+ python = "^3.9.2"
21
+ cryptography = ">=44.0.0,<44.1.0"
22
22
  mnemonic = ">=0.20,<1.0"
23
- pillow = ">=10.3.0,<10.4.0"
23
+ pillow = ">=11.0.0,<11.1.0"
24
24
  pynacl = ">=1.5.0,<1.6.0"
25
25
  pyyaml = ">=6.0.1,<6.1.0"
26
26
  pyzbar = ">=0.1.9,<0.2.0"
27
- qrcode = ">=7.4.2,<7.5.0"
27
+ qrcode = ">=8.0,<9.0"
28
28
  ripemd-hash = ">=1.0.1,<1.1.0"
29
29
  safe-pysha3 = ">=1.0.4,<1.1.0"
@@ -49,3 +49,7 @@ class BaseValue(Ordered):
49
49
  unsigned_value = self.value + upper_bound_plus_one
50
50
 
51
51
  return f'0x{unsigned_value:0{self.size * 2}X}'
52
+
53
+ def to_json(self):
54
+ """Returns representation of this object that can be stored in JSON."""
55
+ return str(self.value) if 8 <= self.size else self.value
@@ -37,3 +37,7 @@ class ByteArray(Ordered):
37
37
 
38
38
  def __str__(self):
39
39
  return hexlify(self.bytes).decode('utf8').upper()
40
+
41
+ def to_json(self):
42
+ """Returns representation of this object that can be stored in JSON."""
43
+ return str(self)
@@ -9,7 +9,7 @@ class Network:
9
9
  """Represents a network."""
10
10
 
11
11
  def __init__(self, name, identifier, datetime_converter, address_class, network_timestamp_class):
12
- # pylint: disable=too-many-arguments
12
+ # pylint: disable=too-many-arguments,too-many-positional-arguments
13
13
 
14
14
  """Creates a new network with the specified properties."""
15
15
  self.name = name
@@ -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."""
@@ -53,16 +93,18 @@ class NemFacade:
53
93
  return Hash256(sha3.keccak_256(non_verifiable_transaction.serialize()).digest())
54
94
 
55
95
  @staticmethod
56
- def sign_transaction(key_pair, transaction):
57
- """Signs a NEM transaction."""
96
+ def extract_signing_payload(transaction):
97
+ """Gets the payload to sign given a NEM transaction."""
58
98
  non_verifiable_transaction = TransactionFactory.to_non_verifiable_transaction(transaction)
59
- return key_pair.sign(non_verifiable_transaction.serialize())
99
+ return non_verifiable_transaction.serialize()
60
100
 
61
- @staticmethod
62
- def verify_transaction(transaction, signature):
101
+ def sign_transaction(self, key_pair, transaction):
102
+ """Signs a NEM transaction."""
103
+ return key_pair.sign(self.extract_signing_payload(transaction))
104
+
105
+ def verify_transaction(self, transaction, signature):
63
106
  """Verifies a NEM transaction."""
64
- non_verifiable_transaction = TransactionFactory.to_non_verifiable_transaction(transaction)
65
- return Verifier(transaction.signer_public_key).verify(non_verifiable_transaction.serialize(), signature)
107
+ return Verifier(transaction.signer_public_key).verify(self.extract_signing_payload(transaction), signature)
66
108
 
67
109
  def bip32_path(self, account_id):
68
110
  """Creates a network compatible BIP32 path for the specified account."""
@@ -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,45 @@ 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
+ def cosign_transaction_hash(self, transaction_hash, detached=False):
63
+ """Cosigns a Symbol transaction hash."""
64
+ return self._facade.cosign_transaction_hash(self.key_pair, transaction_hash, detached)
65
+
66
+ # endregion
67
+
68
+
29
69
  class SymbolFacade:
30
70
  """Facade used to interact with Symbol blockchain."""
31
71
 
@@ -63,6 +103,14 @@ class SymbolFacade:
63
103
  """Creates a network timestamp representing the current time."""
64
104
  return self.network.from_datetime(datetime.now(timezone.utc))
65
105
 
106
+ def create_public_account(self, public_key):
107
+ """Creates a Symbol public account from a public key."""
108
+ return SymbolPublicAccount(self, public_key)
109
+
110
+ def create_account(self, private_key):
111
+ """Creates a Symbol account from a private key."""
112
+ return SymbolAccount(self, KeyPair(private_key))
113
+
66
114
  def hash_transaction(self, transaction):
67
115
  """Hashes a Symbol transaction."""
68
116
  hasher = hashlib.sha3_256()
@@ -72,22 +120,23 @@ class SymbolFacade:
72
120
  hasher.update(self._transaction_data_buffer(transaction.serialize()))
73
121
  return Hash256(hasher.digest())
74
122
 
75
- def sign_transaction(self, key_pair, transaction):
76
- """Signs a Symbol transaction."""
123
+ def extract_signing_payload(self, transaction):
124
+ """Gets the payload to sign given a Symbol transaction."""
77
125
  sign_buffer = self.network.generation_hash_seed.bytes
78
126
  sign_buffer += self._transaction_data_buffer(transaction.serialize())
79
- return key_pair.sign(sign_buffer)
127
+ return sign_buffer
128
+
129
+ def sign_transaction(self, key_pair, transaction):
130
+ """Signs a Symbol transaction."""
131
+ return key_pair.sign(self.extract_signing_payload(transaction))
80
132
 
81
133
  def verify_transaction(self, transaction, signature):
82
134
  """Verifies a Symbol transaction."""
83
- verify_buffer = self.network.generation_hash_seed.bytes
84
- verify_buffer += self._transaction_data_buffer(transaction.serialize())
85
- return Verifier(transaction.signer_public_key).verify(verify_buffer, signature)
86
-
87
- def cosign_transaction(self, key_pair, transaction, detached=False):
88
- """Cosigns a Symbol transaction."""
89
- transaction_hash = self.hash_transaction(transaction)
135
+ return Verifier(transaction.signer_public_key).verify(self.extract_signing_payload(transaction), signature)
90
136
 
137
+ @staticmethod
138
+ def cosign_transaction_hash(key_pair, transaction_hash, detached=False):
139
+ """Cosigns a Symbol transaction hash."""
91
140
  cosignature = sc.DetachedCosignature() if detached else sc.Cosignature()
92
141
  if detached:
93
142
  cosignature.parent_hash = sc.Hash256(transaction_hash.bytes)
@@ -97,6 +146,11 @@ class SymbolFacade:
97
146
  cosignature.signature = sc.Signature(key_pair.sign(transaction_hash.bytes).bytes)
98
147
  return cosignature
99
148
 
149
+ def cosign_transaction(self, key_pair, transaction, detached=False):
150
+ """Cosigns a Symbol transaction."""
151
+ transaction_hash = self.hash_transaction(transaction)
152
+ return self.cosign_transaction_hash(key_pair, transaction_hash, detached)
153
+
100
154
  @staticmethod
101
155
  def hash_embedded_transactions(embedded_transactions):
102
156
  """Hashes embedded transactions of an aggregate."""