coinex-api 0.0.89__py3-none-any.whl → 0.0.110__py3-none-any.whl

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.

Potentially problematic release.


This version of coinex-api might be problematic. Click here for more details.

Files changed (197) hide show
  1. coinex/ccxt/__init__.py +1 -1
  2. coinex/ccxt/async_support/__init__.py +1 -1
  3. coinex/ccxt/async_support/base/exchange.py +139 -10
  4. coinex/ccxt/async_support/base/throttler.py +1 -1
  5. coinex/ccxt/async_support/base/ws/cache.py +1 -0
  6. coinex/ccxt/async_support/base/ws/client.py +26 -4
  7. coinex/ccxt/async_support/coinex.py +2 -2
  8. coinex/ccxt/base/exchange.py +587 -91
  9. coinex/ccxt/base/types.py +11 -2
  10. coinex/ccxt/coinex.py +2 -2
  11. coinex/ccxt/pro/__init__.py +1 -1
  12. coinex/ccxt/pro/coinex.py +10 -7
  13. coinex/ccxt/static_dependencies/bip/__init__.py +6 -0
  14. coinex/ccxt/static_dependencies/bip/addr/P2PKH_addr.py +205 -0
  15. coinex/ccxt/static_dependencies/bip/addr/__init__.py +5 -0
  16. coinex/ccxt/static_dependencies/bip/addr/addr_dec_utils.py +125 -0
  17. coinex/ccxt/static_dependencies/bip/addr/addr_key_validator.py +162 -0
  18. coinex/ccxt/static_dependencies/bip/addr/iaddr_decoder.py +48 -0
  19. coinex/ccxt/static_dependencies/bip/addr/iaddr_encoder.py +50 -0
  20. coinex/ccxt/static_dependencies/bip/base58/__init__.py +3 -0
  21. coinex/ccxt/static_dependencies/bip/base58/base58.py +207 -0
  22. coinex/ccxt/static_dependencies/bip/base58/base58_ex.py +25 -0
  23. coinex/ccxt/static_dependencies/bip/base58/base58_xmr.py +155 -0
  24. coinex/ccxt/static_dependencies/bip/bech32/__init__.py +4 -0
  25. coinex/ccxt/static_dependencies/bip/bech32/bch_bech32.py +220 -0
  26. coinex/ccxt/static_dependencies/bip/bech32/bech32.py +235 -0
  27. coinex/ccxt/static_dependencies/bip/bech32/bech32_base.py +246 -0
  28. coinex/ccxt/static_dependencies/bip/bech32/bech32_ex.py +25 -0
  29. coinex/ccxt/static_dependencies/bip/bech32/segwit_bech32.py +173 -0
  30. coinex/ccxt/static_dependencies/bip/bip32/__init__.py +14 -0
  31. coinex/ccxt/static_dependencies/bip/bip32/base/__init__.py +3 -0
  32. coinex/ccxt/static_dependencies/bip/bip32/base/bip32_base.py +581 -0
  33. coinex/ccxt/static_dependencies/bip/bip32/base/ibip32_key_derivator.py +83 -0
  34. coinex/ccxt/static_dependencies/bip/bip32/base/ibip32_mst_key_generator.py +47 -0
  35. coinex/ccxt/static_dependencies/bip/bip32/bip32_const.py +35 -0
  36. coinex/ccxt/static_dependencies/bip/bip32/bip32_ex.py +29 -0
  37. coinex/ccxt/static_dependencies/bip/bip32/bip32_key_data.py +500 -0
  38. coinex/ccxt/static_dependencies/bip/bip32/bip32_key_net_ver.py +83 -0
  39. coinex/ccxt/static_dependencies/bip/bip32/bip32_key_ser.py +294 -0
  40. coinex/ccxt/static_dependencies/bip/bip32/bip32_keys.py +457 -0
  41. coinex/ccxt/static_dependencies/bip/bip32/bip32_path.py +247 -0
  42. coinex/ccxt/static_dependencies/bip/bip32/bip32_utils.py +72 -0
  43. coinex/ccxt/static_dependencies/bip/bip32/kholaw/__init__.py +4 -0
  44. coinex/ccxt/static_dependencies/bip/bip32/kholaw/bip32_kholaw_ed25519.py +82 -0
  45. coinex/ccxt/static_dependencies/bip/bip32/kholaw/bip32_kholaw_ed25519_key_derivator.py +118 -0
  46. coinex/ccxt/static_dependencies/bip/bip32/kholaw/bip32_kholaw_key_derivator_base.py +204 -0
  47. coinex/ccxt/static_dependencies/bip/bip32/kholaw/bip32_kholaw_mst_key_generator.py +119 -0
  48. coinex/ccxt/static_dependencies/bip/bip32/slip10/__init__.py +1 -0
  49. coinex/ccxt/static_dependencies/bip/bip32/slip10/bip32_slip10_key_derivator.py +200 -0
  50. coinex/ccxt/static_dependencies/bip/bip32/slip10/bip32_slip10_mst_key_generator.py +168 -0
  51. coinex/ccxt/static_dependencies/bip/bip32/slip10/bip32_slip10_secp256k1.py +82 -0
  52. coinex/ccxt/static_dependencies/bip/bip44/__init__.py +1 -0
  53. coinex/ccxt/static_dependencies/bip/bip44/bip44.py +265 -0
  54. coinex/ccxt/static_dependencies/bip/bip44_base/__init__.py +3 -0
  55. coinex/ccxt/static_dependencies/bip/bip44_base/bip44_base.py +624 -0
  56. coinex/ccxt/static_dependencies/bip/bip44_base/bip44_base_ex.py +25 -0
  57. coinex/ccxt/static_dependencies/bip/bip44_base/bip44_keys.py +225 -0
  58. coinex/ccxt/static_dependencies/bip/coin_conf/__init__.py +2 -0
  59. coinex/ccxt/static_dependencies/bip/coin_conf/coin_conf.py +68 -0
  60. coinex/ccxt/static_dependencies/bip/coin_conf/coins_conf.py +890 -0
  61. coinex/ccxt/static_dependencies/bip/conf/__init__.py +0 -0
  62. coinex/ccxt/static_dependencies/bip/conf/bip44/__init__.py +3 -0
  63. coinex/ccxt/static_dependencies/bip/conf/bip44/bip44_coins.py +126 -0
  64. coinex/ccxt/static_dependencies/bip/conf/bip44/bip44_conf.py +1360 -0
  65. coinex/ccxt/static_dependencies/bip/conf/bip44/bip44_conf_getter.py +153 -0
  66. coinex/ccxt/static_dependencies/bip/conf/bip49/__init__.py +3 -0
  67. coinex/ccxt/static_dependencies/bip/conf/bip49/bip49_coins.py +53 -0
  68. coinex/ccxt/static_dependencies/bip/conf/bip49/bip49_conf.py +366 -0
  69. coinex/ccxt/static_dependencies/bip/conf/bip49/bip49_conf_getter.py +80 -0
  70. coinex/ccxt/static_dependencies/bip/conf/bip84/__init__.py +3 -0
  71. coinex/ccxt/static_dependencies/bip/conf/bip84/bip84_coins.py +39 -0
  72. coinex/ccxt/static_dependencies/bip/conf/bip84/bip84_conf.py +113 -0
  73. coinex/ccxt/static_dependencies/bip/conf/bip84/bip84_conf_getter.py +66 -0
  74. coinex/ccxt/static_dependencies/bip/conf/bip86/__init__.py +3 -0
  75. coinex/ccxt/static_dependencies/bip/conf/bip86/bip86_coins.py +37 -0
  76. coinex/ccxt/static_dependencies/bip/conf/bip86/bip86_conf.py +83 -0
  77. coinex/ccxt/static_dependencies/bip/conf/bip86/bip86_conf_getter.py +64 -0
  78. coinex/ccxt/static_dependencies/bip/conf/common/__init__.py +8 -0
  79. coinex/ccxt/static_dependencies/bip/conf/common/atom_addr.py +104 -0
  80. coinex/ccxt/static_dependencies/bip/conf/common/bip_bitcoin_cash_conf.py +106 -0
  81. coinex/ccxt/static_dependencies/bip/conf/common/bip_coin_conf.py +217 -0
  82. coinex/ccxt/static_dependencies/bip/conf/common/bip_coins.py +28 -0
  83. coinex/ccxt/static_dependencies/bip/conf/common/bip_conf_const.py +30 -0
  84. coinex/ccxt/static_dependencies/bip/conf/common/bip_litecoin_conf.py +121 -0
  85. coinex/ccxt/static_dependencies/bip/ecc/__init__.py +42 -0
  86. coinex/ccxt/static_dependencies/bip/ecc/common/__init__.py +0 -0
  87. coinex/ccxt/static_dependencies/bip/ecc/common/dummy_point.py +219 -0
  88. coinex/ccxt/static_dependencies/bip/ecc/common/ikeys.py +263 -0
  89. coinex/ccxt/static_dependencies/bip/ecc/common/ipoint.py +190 -0
  90. coinex/ccxt/static_dependencies/bip/ecc/conf.py +28 -0
  91. coinex/ccxt/static_dependencies/bip/ecc/curve/__init__.py +0 -0
  92. coinex/ccxt/static_dependencies/bip/ecc/curve/elliptic_curve.py +121 -0
  93. coinex/ccxt/static_dependencies/bip/ecc/curve/elliptic_curve_getter.py +74 -0
  94. coinex/ccxt/static_dependencies/bip/ecc/curve/elliptic_curve_types.py +37 -0
  95. coinex/ccxt/static_dependencies/bip/ecc/ecdsa/__init__.py +0 -0
  96. coinex/ccxt/static_dependencies/bip/ecc/ecdsa/ecdsa_keys.py +36 -0
  97. coinex/ccxt/static_dependencies/bip/ecc/secp256k1/__init__.py +0 -0
  98. coinex/ccxt/static_dependencies/bip/ecc/secp256k1/secp256k1.py +36 -0
  99. coinex/ccxt/static_dependencies/bip/ecc/secp256k1/secp256k1_const.py +59 -0
  100. coinex/ccxt/static_dependencies/bip/ecc/secp256k1/secp256k1_keys_ecdsa.py +248 -0
  101. coinex/ccxt/static_dependencies/bip/ecc/secp256k1/secp256k1_point_ecdsa.py +234 -0
  102. coinex/ccxt/static_dependencies/bip/slip/__init__.py +0 -0
  103. coinex/ccxt/static_dependencies/bip/slip/slip173/__init__.py +1 -0
  104. coinex/ccxt/static_dependencies/bip/slip/slip173/slip173.py +60 -0
  105. coinex/ccxt/static_dependencies/bip/slip/slip32/__init__.py +4 -0
  106. coinex/ccxt/static_dependencies/bip/slip/slip32/slip32.py +322 -0
  107. coinex/ccxt/static_dependencies/bip/slip/slip32/slip32_key_net_ver.py +62 -0
  108. coinex/ccxt/static_dependencies/bip/slip/slip44/__init__.py +1 -0
  109. coinex/ccxt/static_dependencies/bip/slip/slip44/slip44.py +81 -0
  110. coinex/ccxt/static_dependencies/bip/utils/__init__.py +0 -0
  111. coinex/ccxt/static_dependencies/bip/utils/conf/__init__.py +1 -0
  112. coinex/ccxt/static_dependencies/bip/utils/conf/coin_names.py +59 -0
  113. coinex/ccxt/static_dependencies/bip/utils/crypto/__init__.py +10 -0
  114. coinex/ccxt/static_dependencies/bip/utils/crypto/aes_ecb.py +152 -0
  115. coinex/ccxt/static_dependencies/bip/utils/crypto/blake2.py +191 -0
  116. coinex/ccxt/static_dependencies/bip/utils/crypto/chacha20_poly1305.py +101 -0
  117. coinex/ccxt/static_dependencies/bip/utils/crypto/hash160.py +57 -0
  118. coinex/ccxt/static_dependencies/bip/utils/crypto/hmac.py +118 -0
  119. coinex/ccxt/static_dependencies/bip/utils/crypto/pbkdf2.py +66 -0
  120. coinex/ccxt/static_dependencies/bip/utils/crypto/ripemd.py +58 -0
  121. coinex/ccxt/static_dependencies/bip/utils/crypto/scrypt.py +66 -0
  122. coinex/ccxt/static_dependencies/bip/utils/crypto/sha2.py +182 -0
  123. coinex/ccxt/static_dependencies/bip/utils/crypto/sha3.py +99 -0
  124. coinex/ccxt/static_dependencies/bip/utils/misc/__init__.py +7 -0
  125. coinex/ccxt/static_dependencies/bip/utils/misc/algo.py +108 -0
  126. coinex/ccxt/static_dependencies/bip/utils/misc/base32.py +151 -0
  127. coinex/ccxt/static_dependencies/bip/utils/misc/bit.py +115 -0
  128. coinex/ccxt/static_dependencies/bip/utils/misc/bytes.py +200 -0
  129. coinex/ccxt/static_dependencies/bip/utils/misc/data_bytes.py +181 -0
  130. coinex/ccxt/static_dependencies/bip/utils/misc/integer.py +97 -0
  131. coinex/ccxt/static_dependencies/bip/utils/misc/string.py +54 -0
  132. coinex/ccxt/static_dependencies/bip/utils/typing/__init__.py +1 -0
  133. coinex/ccxt/static_dependencies/bip/utils/typing/literal.py +27 -0
  134. coinex/ccxt/static_dependencies/bip/wif/__init__.py +1 -0
  135. coinex/ccxt/static_dependencies/bip/wif/wif.py +144 -0
  136. coinex/ccxt/static_dependencies/dydx_v4_client/amino/amino_pb2.py +31 -0
  137. coinex/ccxt/static_dependencies/dydx_v4_client/cosmos/base/v1beta1/coin_pb2.py +47 -0
  138. coinex/ccxt/static_dependencies/dydx_v4_client/cosmos/crypto/multisig/keys_pb2.py +33 -0
  139. coinex/ccxt/static_dependencies/dydx_v4_client/cosmos/crypto/multisig/v1beta1/multisig_pb2.py +33 -0
  140. coinex/ccxt/static_dependencies/dydx_v4_client/cosmos/crypto/secp256k1/keys_pb2.py +34 -0
  141. coinex/ccxt/static_dependencies/dydx_v4_client/cosmos/msg/v1/msg_pb2.py +27 -0
  142. coinex/ccxt/static_dependencies/dydx_v4_client/cosmos/tx/signing/v1beta1/signing_pb2.py +38 -0
  143. coinex/ccxt/static_dependencies/dydx_v4_client/cosmos/tx/v1beta1/tx_pb2.py +75 -0
  144. coinex/ccxt/static_dependencies/dydx_v4_client/cosmos_proto/cosmos_pb2.py +36 -0
  145. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/accountplus/accountplus_pb2.py +31 -0
  146. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/accountplus/genesis_pb2.py +40 -0
  147. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/accountplus/models_pb2.py +26 -0
  148. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/accountplus/params_pb2.py +29 -0
  149. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/accountplus/query_pb2.py +57 -0
  150. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/accountplus/tx_pb2.py +51 -0
  151. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/block_rate_limit_config_pb2.py +37 -0
  152. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/clob_pair_pb2.py +41 -0
  153. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/equity_tier_limit_config_pb2.py +35 -0
  154. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/finalize_block_pb2.py +27 -0
  155. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/liquidations_config_pb2.py +39 -0
  156. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/liquidations_pb2.py +38 -0
  157. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/matches_pb2.py +55 -0
  158. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/mev_pb2.py +49 -0
  159. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/operation_pb2.py +32 -0
  160. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/order_pb2.py +86 -0
  161. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/order_removals_pb2.py +32 -0
  162. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/process_proposer_matches_events_pb2.py +42 -0
  163. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/query_pb2.py +124 -0
  164. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/streaming_pb2.py +29 -0
  165. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/tx_pb2.py +117 -0
  166. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/sending/genesis_pb2.py +26 -0
  167. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/sending/query_pb2.py +26 -0
  168. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/sending/transfer_pb2.py +61 -0
  169. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/sending/tx_pb2.py +37 -0
  170. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/subaccounts/asset_position_pb2.py +29 -0
  171. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/subaccounts/genesis_pb2.py +30 -0
  172. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/subaccounts/perpetual_position_pb2.py +33 -0
  173. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/subaccounts/query_pb2.py +63 -0
  174. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/subaccounts/streaming_pb2.py +31 -0
  175. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/subaccounts/subaccount_pb2.py +33 -0
  176. coinex/ccxt/static_dependencies/dydx_v4_client/gogoproto/gogo_pb2.py +102 -0
  177. coinex/ccxt/static_dependencies/dydx_v4_client/registry.py +38 -0
  178. coinex/ccxt/static_dependencies/ecdsa/ellipticcurve.py +842 -0
  179. coinex/ccxt/static_dependencies/ecdsa/keys.py +15 -4
  180. coinex/ccxt/static_dependencies/mnemonic/__init__.py +4 -0
  181. coinex/ccxt/static_dependencies/mnemonic/mnemonic.py +282 -0
  182. coinex/ccxt/static_dependencies/mnemonic/py.typed +1 -0
  183. coinex/ccxt/static_dependencies/mnemonic/wordlist/chinese_simplified.txt +2048 -0
  184. coinex/ccxt/static_dependencies/mnemonic/wordlist/chinese_traditional.txt +2048 -0
  185. coinex/ccxt/static_dependencies/mnemonic/wordlist/czech.txt +2048 -0
  186. coinex/ccxt/static_dependencies/mnemonic/wordlist/english.txt +2048 -0
  187. coinex/ccxt/static_dependencies/mnemonic/wordlist/french.txt +2048 -0
  188. coinex/ccxt/static_dependencies/mnemonic/wordlist/italian.txt +2048 -0
  189. coinex/ccxt/static_dependencies/mnemonic/wordlist/japanese.txt +2048 -0
  190. coinex/ccxt/static_dependencies/mnemonic/wordlist/korean.txt +2048 -0
  191. coinex/ccxt/static_dependencies/mnemonic/wordlist/portuguese.txt +2048 -0
  192. coinex/ccxt/static_dependencies/mnemonic/wordlist/russian.txt +2048 -0
  193. coinex/ccxt/static_dependencies/mnemonic/wordlist/spanish.txt +2048 -0
  194. coinex/ccxt/static_dependencies/mnemonic/wordlist/turkish.txt +2048 -0
  195. {coinex_api-0.0.89.dist-info → coinex_api-0.0.110.dist-info}/METADATA +3 -3
  196. {coinex_api-0.0.89.dist-info → coinex_api-0.0.110.dist-info}/RECORD +197 -17
  197. {coinex_api-0.0.89.dist-info → coinex_api-0.0.110.dist-info}/WHEEL +1 -1
@@ -0,0 +1,37 @@
1
+ # Copyright (c) 2021 Emanuele Bellocchia
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ """Module for elliptic curves enum."""
22
+
23
+ # Imports
24
+ from enum import Enum, auto, unique
25
+
26
+
27
+ @unique
28
+ class EllipticCurveTypes(Enum):
29
+ """Enumerative for elliptic curve types."""
30
+
31
+ ED25519 = auto()
32
+ ED25519_BLAKE2B = auto()
33
+ ED25519_KHOLAW = auto()
34
+ ED25519_MONERO = auto()
35
+ NIST256P1 = auto()
36
+ SECP256K1 = auto()
37
+ SR25519 = auto()
@@ -0,0 +1,36 @@
1
+ # Copyright (c) 2021 Emanuele Bellocchia
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ """Module with some ECDSA keys constants."""
22
+
23
+
24
+ class EcdsaKeysConst:
25
+ """Class container for ECDSA keys constants."""
26
+
27
+ # Point coordinate length in bytes
28
+ POINT_COORD_BYTE_LEN: int = 32
29
+ # Private key length in bytes
30
+ PRIV_KEY_BYTE_LEN: int = 32
31
+ # Uncompressed public key prefix
32
+ PUB_KEY_UNCOMPRESSED_PREFIX: bytes = b"\x04"
33
+ # Compressed public key length in bytes
34
+ PUB_KEY_COMPRESSED_BYTE_LEN: int = 33
35
+ # Uncompressed public key length in bytes
36
+ PUB_KEY_UNCOMPRESSED_BYTE_LEN: int = 65
@@ -0,0 +1,36 @@
1
+ # Copyright (c) 2021 Emanuele Bellocchia
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ """Module with secp256k1 curve."""
22
+
23
+ # Imports
24
+ from ..curve.elliptic_curve import EllipticCurve
25
+ from .secp256k1_const import (
26
+ Secp256k1Const, Secp256k1Point, Secp256k1PrivateKey, Secp256k1PublicKey
27
+ )
28
+
29
+
30
+ # Secp256k1 curve definition
31
+ Secp256k1: EllipticCurve = EllipticCurve(Secp256k1Const.NAME,
32
+ Secp256k1Const.CURVE_ORDER,
33
+ Secp256k1Const.GENERATOR,
34
+ Secp256k1Point,
35
+ Secp256k1PublicKey,
36
+ Secp256k1PrivateKey)
@@ -0,0 +1,59 @@
1
+ # Copyright (c) 2021 Emanuele Bellocchia
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ """Module with secp256k1 constants."""
22
+
23
+ # Imports
24
+ from typing import Type
25
+
26
+ from ..common.ikeys import IPrivateKey, IPublicKey
27
+ from ..common.ipoint import IPoint
28
+
29
+
30
+ # Variables
31
+ Secp256k1Point: Type[IPoint]
32
+ Secp256k1PublicKey: Type[IPublicKey]
33
+ Secp256k1PrivateKey: Type[IPrivateKey]
34
+ _CURVE_ORDER: int
35
+ _GENERATOR: IPoint
36
+
37
+ from ....ecdsa.ecdsa import generator_secp256k1
38
+
39
+ from ..secp256k1.secp256k1_keys_ecdsa import (
40
+ Secp256k1PointEcdsa, Secp256k1PrivateKeyEcdsa, Secp256k1PublicKeyEcdsa
41
+ )
42
+
43
+ Secp256k1Point = Secp256k1PointEcdsa
44
+ Secp256k1PublicKey = Secp256k1PublicKeyEcdsa
45
+ Secp256k1PrivateKey = Secp256k1PrivateKeyEcdsa
46
+
47
+ _CURVE_ORDER = generator_secp256k1.order()
48
+ _GENERATOR = Secp256k1Point(generator_secp256k1)
49
+
50
+
51
+ class Secp256k1Const:
52
+ """Class container for Secp256k1 constants."""
53
+
54
+ # Curve name
55
+ NAME: str = "Secp256k1"
56
+ # Curve order
57
+ CURVE_ORDER: int = _CURVE_ORDER
58
+ # Curve generator point
59
+ GENERATOR: IPoint = _GENERATOR
@@ -0,0 +1,248 @@
1
+ # Copyright (c) 2021 Emanuele Bellocchia
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ """Module for secp256k1 keys based on ecdsa library."""
22
+
23
+ # Imports
24
+ from typing import Any
25
+
26
+ from ....ecdsa import curves, ellipticcurve, keys
27
+ from ....ecdsa.ecdsa import curve_secp256k1
28
+
29
+ from ..common.ikeys import IPrivateKey, IPublicKey
30
+ from ..common.ipoint import IPoint
31
+ from ..curve.elliptic_curve_types import EllipticCurveTypes
32
+ from ..ecdsa.ecdsa_keys import EcdsaKeysConst
33
+ from .secp256k1_point_ecdsa import Secp256k1PointEcdsa
34
+ from ...utils.misc import DataBytes
35
+
36
+
37
+ class Secp256k1PublicKeyEcdsa(IPublicKey):
38
+ """Secp256k1 public key class."""
39
+
40
+ m_ver_key: keys.VerifyingKey
41
+
42
+ @classmethod
43
+ def FromBytes(cls,
44
+ key_bytes: bytes) -> IPublicKey:
45
+ """
46
+ Construct class from key bytes.
47
+
48
+ Args:
49
+ key_bytes (bytes): Key bytes
50
+
51
+ Returns:
52
+ IPublicKey: IPublicKey object
53
+
54
+ Raises:
55
+ ValueError: If key bytes are not valid
56
+ """
57
+ try:
58
+ return cls(keys.VerifyingKey.from_string(key_bytes,
59
+ curve=curves.SECP256k1))
60
+ except keys.MalformedPointError as ex:
61
+ raise ValueError("Invalid public key bytes") from ex
62
+
63
+ @classmethod
64
+ def FromPoint(cls,
65
+ key_point: IPoint) -> IPublicKey:
66
+ """
67
+ Construct class from key point.
68
+
69
+ Args:
70
+ key_point (IPoint object): Key point
71
+
72
+ Returns:
73
+ IPublicKey: IPublicKey object
74
+
75
+ Raises:
76
+ ValueError: If key point is not valid
77
+ """
78
+ try:
79
+ return cls(
80
+ keys.VerifyingKey.from_public_point(
81
+ ellipticcurve.Point(curve_secp256k1,
82
+ key_point.X(),
83
+ key_point.Y()),
84
+ curve=curves.SECP256k1
85
+ )
86
+ )
87
+ except keys.MalformedPointError as ex:
88
+ raise ValueError("Invalid public key point") from ex
89
+
90
+ def __init__(self,
91
+ key_obj: keys.VerifyingKey) -> None:
92
+ """
93
+ Construct class from key object.
94
+
95
+ Args:
96
+ key_obj (keys.VerifyingKey): Key object
97
+ """
98
+ self.m_ver_key = key_obj
99
+
100
+ @staticmethod
101
+ def CurveType() -> EllipticCurveTypes:
102
+ """
103
+ Get the elliptic curve type.
104
+
105
+ Returns:
106
+ EllipticCurveTypes: Elliptic curve type
107
+ """
108
+ return EllipticCurveTypes.SECP256K1
109
+
110
+ @staticmethod
111
+ def CompressedLength() -> int:
112
+ """
113
+ Get the compressed key length.
114
+
115
+ Returns:
116
+ int: Compressed key length
117
+ """
118
+ return EcdsaKeysConst.PUB_KEY_COMPRESSED_BYTE_LEN
119
+
120
+ @staticmethod
121
+ def UncompressedLength() -> int:
122
+ """
123
+ Get the uncompressed key length.
124
+
125
+ Returns:
126
+ int: Uncompressed key length
127
+ """
128
+ return EcdsaKeysConst.PUB_KEY_UNCOMPRESSED_BYTE_LEN
129
+
130
+ def UnderlyingObject(self) -> Any:
131
+ """
132
+ Get the underlying object.
133
+
134
+ Returns:
135
+ Any: Underlying object
136
+ """
137
+ return self.m_ver_key
138
+
139
+ def RawCompressed(self) -> DataBytes:
140
+ """
141
+ Return raw compressed public key.
142
+
143
+ Returns:
144
+ DataBytes object: DataBytes object
145
+ """
146
+ return DataBytes(self.m_ver_key.to_string('compressed'))
147
+
148
+ def RawUncompressed(self) -> DataBytes:
149
+ """
150
+ Return raw uncompressed public key.
151
+
152
+ Returns:
153
+ DataBytes object: DataBytes object
154
+ """
155
+ return DataBytes(self.m_ver_key.to_string())
156
+
157
+ def Point(self) -> IPoint:
158
+ """
159
+ Get public key point.
160
+
161
+ Returns:
162
+ IPoint object: IPoint object
163
+ """
164
+ return Secp256k1PointEcdsa(self.m_ver_key.pubkey.point)
165
+
166
+
167
+ class Secp256k1PrivateKeyEcdsa(IPrivateKey):
168
+ """Secp256k1 private key class."""
169
+
170
+ m_sign_key = keys.SigningKey
171
+
172
+ @classmethod
173
+ def FromBytes(cls,
174
+ key_bytes: bytes) -> IPrivateKey:
175
+ """
176
+ Construct class from key bytes.
177
+
178
+ Args:
179
+ key_bytes (bytes): Key bytes
180
+
181
+ Returns:
182
+ IPrivateKey: IPrivateKey object
183
+
184
+ Raises:
185
+ ValueError: If key bytes are not valid
186
+ """
187
+ try:
188
+ return cls(keys.SigningKey.from_string(key_bytes,
189
+ curve=curves.SECP256k1))
190
+ except keys.MalformedPointError as ex:
191
+ raise ValueError("Invalid private key bytes") from ex
192
+
193
+ def __init__(self,
194
+ key_obj: keys.SigningKey) -> None:
195
+ """
196
+ Construct class from key object.
197
+
198
+ Args:
199
+ key_obj (ecdsa.SigningKey): Key object
200
+ """
201
+ self.m_sign_key = key_obj
202
+
203
+ @staticmethod
204
+ def CurveType() -> EllipticCurveTypes:
205
+ """
206
+ Get the elliptic curve type.
207
+
208
+ Returns:
209
+ EllipticCurveTypes: Elliptic curve type
210
+ """
211
+ return EllipticCurveTypes.SECP256K1
212
+
213
+ @staticmethod
214
+ def Length() -> int:
215
+ """
216
+ Get the key length.
217
+
218
+ Returns:
219
+ int: Key length
220
+ """
221
+ return EcdsaKeysConst.PRIV_KEY_BYTE_LEN
222
+
223
+ def UnderlyingObject(self) -> Any:
224
+ """
225
+ Get the underlying object.
226
+
227
+ Returns:
228
+ Any: Underlying object
229
+ """
230
+ return self.m_sign_key
231
+
232
+ def Raw(self) -> DataBytes:
233
+ """
234
+ Return raw private key.
235
+
236
+ Returns:
237
+ DataBytes object: DataBytes object
238
+ """
239
+ return DataBytes(self.m_sign_key.to_string())
240
+
241
+ def PublicKey(self) -> IPublicKey:
242
+ """
243
+ Get the public key correspondent to the private one.
244
+
245
+ Returns:
246
+ IPublicKey object: IPublicKey object
247
+ """
248
+ return Secp256k1PublicKeyEcdsa(self.m_sign_key.get_verifying_key())
@@ -0,0 +1,234 @@
1
+ # Copyright (c) 2021 Emanuele Bellocchia
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ """Module for secp256k1 point based on ecdsa library."""
22
+
23
+ # Imports
24
+ from typing import Any
25
+
26
+ from ....ecdsa import ellipticcurve, keys
27
+ from ....ecdsa.ecdsa import curve_secp256k1
28
+
29
+ from ..common.ipoint import IPoint
30
+ from ..curve.elliptic_curve_types import EllipticCurveTypes
31
+ from ..ecdsa.ecdsa_keys import EcdsaKeysConst
32
+ from ...utils.misc import BytesUtils, DataBytes, IntegerUtils
33
+
34
+
35
+ class Secp256k1PointEcdsa(IPoint):
36
+ """Secp256k1 point class."""
37
+
38
+ m_point: ellipticcurve.PointJacobi
39
+
40
+ @classmethod
41
+ def FromBytes(cls,
42
+ point_bytes: bytes) -> IPoint:
43
+ """
44
+ Construct class from point bytes.
45
+
46
+ Args:
47
+ point_bytes (bytes): Point bytes
48
+
49
+ Returns:
50
+ IPoint: IPoint object
51
+ """
52
+ try:
53
+ return cls(ellipticcurve.PointJacobi.from_bytes(curve_secp256k1,
54
+ point_bytes))
55
+ except keys.MalformedPointError as ex:
56
+ raise ValueError("Invalid point key bytes") from ex
57
+ # ECDSA < 0.17 doesn't have from_bytes method for PointJacobi
58
+ except AttributeError:
59
+ return cls.FromCoordinates(
60
+ BytesUtils.ToInteger(point_bytes[:EcdsaKeysConst.POINT_COORD_BYTE_LEN]),
61
+ BytesUtils.ToInteger(point_bytes[EcdsaKeysConst.POINT_COORD_BYTE_LEN:])
62
+ )
63
+
64
+ @classmethod
65
+ def FromCoordinates(cls,
66
+ x: int,
67
+ y: int) -> IPoint:
68
+ """
69
+ Construct class from point coordinates.
70
+
71
+ Args:
72
+ x (int): X coordinate of the point
73
+ y (int): Y coordinate of the point
74
+
75
+ Returns:
76
+ IPoint: IPoint object
77
+ """
78
+ return cls(
79
+ ellipticcurve.PointJacobi.from_affine(
80
+ ellipticcurve.Point(curve_secp256k1, x, y)
81
+ )
82
+ )
83
+
84
+ def __init__(self,
85
+ point_obj: ellipticcurve.PointJacobi) -> None:
86
+ """
87
+ Construct class from point object.
88
+
89
+ Args:
90
+ point_obj (ellipticcurve.PointJacobi): Point object
91
+ """
92
+ self.m_point = point_obj
93
+
94
+ @staticmethod
95
+ def CurveType() -> EllipticCurveTypes:
96
+ """
97
+ Get the elliptic curve type.
98
+
99
+ Returns:
100
+ EllipticCurveTypes: Elliptic curve type
101
+ """
102
+ return EllipticCurveTypes.SECP256K1
103
+
104
+ @staticmethod
105
+ def CoordinateLength() -> int:
106
+ """
107
+ Get the coordinate length.
108
+
109
+ Returns:
110
+ int: Coordinate key length
111
+ """
112
+ return EcdsaKeysConst.POINT_COORD_BYTE_LEN
113
+
114
+ def UnderlyingObject(self) -> Any:
115
+ """
116
+ Get the underlying object.
117
+
118
+ Returns:
119
+ Any: Underlying object
120
+ """
121
+ return self.m_point
122
+
123
+ def X(self) -> int:
124
+ """
125
+ Get point X coordinate.
126
+
127
+ Returns:
128
+ int: Point X coordinate
129
+ """
130
+ return self.m_point.x()
131
+
132
+ def Y(self) -> int:
133
+ """
134
+ Get point Y coordinate.
135
+
136
+ Returns:
137
+ int: Point Y coordinate
138
+ """
139
+ return self.m_point.y()
140
+
141
+ def Raw(self) -> DataBytes:
142
+ """
143
+ Return the point raw bytes.
144
+
145
+ Returns:
146
+ DataBytes object: DataBytes object
147
+ """
148
+ return self.RawDecoded()
149
+
150
+ def RawEncoded(self) -> DataBytes:
151
+ """
152
+ Return the encoded point raw bytes.
153
+
154
+ Returns:
155
+ DataBytes object: DataBytes object
156
+ """
157
+ try:
158
+ return DataBytes(self.m_point.to_bytes("compressed"))
159
+ # ECDSA < 0.17 doesn't have to_bytes method for PointJacobi
160
+ except AttributeError:
161
+ x_bytes = IntegerUtils.ToBytes(self.m_point.x(), EcdsaKeysConst.POINT_COORD_BYTE_LEN)
162
+ if self.m_point.y() & 1:
163
+ enc_bytes = b"\x03" + x_bytes
164
+ else:
165
+ enc_bytes = b"\x02" + x_bytes
166
+ return DataBytes(enc_bytes)
167
+
168
+ def RawDecoded(self) -> DataBytes:
169
+ """
170
+ Return the decoded point raw bytes.
171
+
172
+ Returns:
173
+ DataBytes object: DataBytes object
174
+ """
175
+ try:
176
+ return DataBytes(self.m_point.to_bytes())
177
+ # ECDSA < 0.17 doesn't have to_bytes method for PointJacobi
178
+ except AttributeError:
179
+ x_bytes = IntegerUtils.ToBytes(self.m_point.x(), EcdsaKeysConst.POINT_COORD_BYTE_LEN)
180
+ y_bytes = IntegerUtils.ToBytes(self.m_point.y(), EcdsaKeysConst.POINT_COORD_BYTE_LEN)
181
+
182
+ return DataBytes(x_bytes + y_bytes)
183
+
184
+ def __add__(self,
185
+ point: IPoint) -> IPoint:
186
+ """
187
+ Add point to another point.
188
+
189
+ Args:
190
+ point (IPoint object): IPoint object
191
+
192
+ Returns:
193
+ IPoint object: IPoint object
194
+ """
195
+ return self.__class__(self.m_point + point.UnderlyingObject())
196
+
197
+ def __radd__(self,
198
+ point: IPoint) -> IPoint:
199
+ """
200
+ Add point to another point.
201
+
202
+ Args:
203
+ point (IPoint object): IPoint object
204
+
205
+ Returns:
206
+ IPoint object: IPoint object
207
+ """
208
+ return self + point
209
+
210
+ def __mul__(self,
211
+ scalar: int) -> IPoint:
212
+ """
213
+ Multiply point by a scalar.
214
+
215
+ Args:
216
+ scalar (int): scalar
217
+
218
+ Returns:
219
+ IPoint object: IPoint object
220
+ """
221
+ return self.__class__(self.m_point * scalar)
222
+
223
+ def __rmul__(self,
224
+ scalar: int) -> IPoint:
225
+ """
226
+ Multiply point by a scalar.
227
+
228
+ Args:
229
+ scalar (int): scalar
230
+
231
+ Returns:
232
+ IPoint object: IPoint object
233
+ """
234
+ return self * scalar
File without changes
@@ -0,0 +1 @@
1
+ from .slip173 import Slip173