sidan-gin 0.1.0__py3-none-any.whl → 0.1.1__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 sidan-gin might be problematic. Click here for more details.

sidan_gin/__init__.py CHANGED
@@ -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)
@@ -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,4 +1,6 @@
1
- sidan_gin/__init__.py,sha256=w38yqTv24z2PXNpyyMy-fC5isk_bkxG7YC6KHTpjjc8,37
1
+ sidan_gin/__init__.py,sha256=qlODpgSpLJISU-uti5fMG_FokqIqcRx_nNL5kS0jF2I,60
2
+ sidan_gin/signing/__init__.py,sha256=_ylJyQIxP_-knJYHUxgDVYWSWG3MMhd_xiI9CH0sFmA,38
3
+ sidan_gin/signing/wallet.py,sha256=ijZ2ICI91E8MPc73ueytqV5s-6bbj3O3hJs8RBnuljw,1442
2
4
  sidan_gin/types/__init__.py,sha256=r5Z6Bto1lE22yhNO9UThri6xoSUnoKk1Gb9A8aHMI24,241
3
5
  sidan_gin/types/account_info.py,sha256=Q5TIXE6Ofj3DlSlMdeL2jhrSQYaJHIqhEzW_oMe_5OU,193
4
6
  sidan_gin/types/asset.py,sha256=9LXNaCIJ0lyA0sGJOnusb_hDRf_ODZK4b3onUZmMPfI,2088
@@ -9,7 +11,7 @@ sidan_gin/types/protocol.py,sha256=MxC2TLtQVrQao6csvPx459JwIpM98XNwBYK05d-JRA8,5
9
11
  sidan_gin/types/transaction_info.py,sha256=c7rh7I38uTksnyDgAZKPdLlw0zVeQHfIVWrcWw-IwrA,220
10
12
  sidan_gin/types/utxo.py,sha256=HvnAJXxyLm0KUBnrqprMm8Pc8H2ebxGW339pFLKo7K4,452
11
13
  sidan_gin/types/value.py,sha256=cGFqxk15FrG2zy6PB5zMRq1vOBYfBQbMWbuqiCTEgRg,3345
12
- sidan_gin-0.1.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
13
- sidan_gin-0.1.0.dist-info/METADATA,sha256=nS976pOzqOo4mAxYzreb4HZZTr3UhmZPfTR5mXvMHAo,935
14
- sidan_gin-0.1.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
15
- sidan_gin-0.1.0.dist-info/RECORD,,
14
+ sidan_gin-0.1.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
15
+ sidan_gin-0.1.1.dist-info/METADATA,sha256=VoXv0GDlBqKLjozzL0kU02arvraVY78SdX0esFg5Mlc,1036
16
+ sidan_gin-0.1.1.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
17
+ sidan_gin-0.1.1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.1
2
+ Generator: poetry-core 2.0.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any