sidan-gin 0.1.0__tar.gz → 0.1.1__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.

Potentially problematic release.


This version of sidan-gin might be problematic. Click here for more details.

@@ -1,13 +1,12 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: sidan-gin
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: A python library for Cardano development, compatible with Mesh and Whisky types.
5
- Home-page: https://github.com/sidan-lab/gin
6
5
  License: Apache-2.0
7
6
  Keywords: cardano
8
7
  Author: HinsonSIDAN
9
8
  Author-email: wongkahinhinson@gmail.com
10
- Requires-Python: >3.11
9
+ Requires-Python: >3.11,<4.0.0
11
10
  Classifier: Intended Audience :: Developers
12
11
  Classifier: License :: OSI Approved :: Apache Software License
13
12
  Classifier: Natural Language :: English
@@ -15,8 +14,11 @@ Classifier: Programming Language :: Python :: 3
15
14
  Classifier: Programming Language :: Python :: 3.12
16
15
  Classifier: Programming Language :: Python :: 3.13
17
16
  Classifier: Programming Language :: Python :: 3.11
17
+ Requires-Dist: cbor2 (>=5.6.5,<6.0.0)
18
+ Requires-Dist: pycardano (>=0.12.3,<0.13.0)
18
19
  Requires-Dist: requests (>=2.25,<3.0)
19
20
  Project-URL: Documentation, https://github.com/sidan-lab/gin
21
+ Project-URL: Homepage, https://github.com/sidan-lab/gin
20
22
  Description-Content-Type: text/markdown
21
23
 
22
24
  # gin
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "sidan-gin"
3
- version = "0.1.0"
3
+ version = "0.1.1"
4
4
  classifiers = [
5
5
  "Intended Audience :: Developers",
6
6
  "License :: OSI Approved :: Apache Software License",
@@ -17,8 +17,10 @@ authors = ["HinsonSIDAN <wongkahinhinson@gmail.com>"]
17
17
  license = "Apache-2.0"
18
18
 
19
19
  [tool.poetry.dependencies]
20
- python = ">3.11"
20
+ python = ">3.11,<4.0.0"
21
21
  requests = "^2.25"
22
+ cbor2 = "^5.6.5"
23
+ pycardano = "^0.12.3"
22
24
 
23
25
  [tool.poetry.dev-dependencies]
24
26
  pytest = "^8.2.0"
@@ -38,5 +40,3 @@ build-backend = "poetry.core.masonry.api"
38
40
  [tool.pytest.ini_options]
39
41
  testpaths = ["tests"]
40
42
  pythonpath = ["src"]
41
-
42
-
@@ -1,3 +1,4 @@
1
1
  # flake8: noqa
2
2
 
3
+ from .signing import *
3
4
  from .types import *
@@ -0,0 +1,3 @@
1
+ # flake8: noqa
2
+
3
+ from .wallet import *
@@ -0,0 +1,40 @@
1
+ # flake8: noqa: E501
2
+
3
+ from cbor2 import dumps, loads
4
+ from nacl.encoding import RawEncoder
5
+ from nacl.hash import blake2b
6
+ from pycardano import crypto, key
7
+
8
+
9
+ class HDWallet:
10
+ def __init__(self, mnemonic):
11
+ self.mnemonic = mnemonic
12
+ self.hd_wallet = crypto.HDWallet.from_mnemonic(self.mnemonic).derive_from_path(
13
+ "m/1852'/1815'/0'/0/0"
14
+ )
15
+ self.signing_key = key.ExtendedSigningKey.from_hdwallet(self.hd_wallet)
16
+ self.verification_key = self.signing_key.to_verification_key()
17
+
18
+ def sign_tx(self, tx_hex):
19
+ raw_decoded_cbor = loads(bytes.fromhex(tx_hex))
20
+ raw_tx_body = raw_decoded_cbor[0]
21
+ signature = self.sign(blake2b(dumps(raw_tx_body), 32, encoder=RawEncoder))
22
+ raw_witness_set = raw_decoded_cbor[1]
23
+ if 0 in raw_witness_set:
24
+ raw_vkeys = raw_witness_set[0]
25
+ raw_vkeys.append(
26
+ [self.verification_key.to_non_extended().to_cbor()[2::], signature]
27
+ )
28
+ raw_witness_set[0] = raw_vkeys
29
+ else:
30
+ raw_witness_set[0] = [
31
+ [self.verification_key.to_non_extended().to_cbor()[2::], signature]
32
+ ]
33
+ raw_decoded_cbor[1] = raw_witness_set
34
+ return dumps(raw_decoded_cbor).hex()
35
+
36
+ def sign_message_hex(self, message_hex):
37
+ return self.sign(bytes.fromhex(message_hex))
38
+
39
+ def sign(self, message):
40
+ return self.signing_key.sign(message)
File without changes
File without changes