naeural-client 2.3.3__py3-none-any.whl → 2.3.5__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.
naeural_client/_ver.py CHANGED
@@ -1,4 +1,4 @@
1
- __VER__ = "2.3.3"
1
+ __VER__ = "2.3.5"
2
2
 
3
3
  if __name__ == "__main__":
4
4
  with open("pyproject.toml", "rt") as fd:
naeural_client/bc/base.py CHANGED
@@ -14,12 +14,24 @@ from cryptography.hazmat.primitives import serialization
14
14
 
15
15
  from ..utils.config import get_user_folder
16
16
 
17
-
18
- class BCct:
17
+ class BCctbase:
19
18
  SIGN = 'EE_SIGN'
20
19
  SENDER = 'EE_SENDER'
21
20
  HASH = 'EE_HASH'
22
21
 
22
+ ETH_SIGN = 'EE_ETH_SIGN'
23
+ ETH_SENDER= 'EE_ETH_SENDER'
24
+
25
+ # TODO: generate automaticall the NON_DATA_FIELDS
26
+
27
+
28
+ class BCct:
29
+ SIGN = BCctbase.SIGN
30
+ SENDER = BCctbase.SENDER
31
+ HASH = BCctbase.HASH
32
+ ETH_SIGN = BCctbase.ETH_SIGN
33
+ ETH_SENDER = BCctbase.ETH_SENDER
34
+
23
35
  ADDR_PREFIX_OLD = "aixp_"
24
36
  ADDR_PREFIX = "0xai_"
25
37
 
@@ -56,7 +68,7 @@ class VerifyMessage(_DotDict):
56
68
  self.sender = None
57
69
 
58
70
 
59
- NON_DATA_FIELDS = [BCct.HASH, BCct.SIGN, BCct.SENDER]
71
+ NON_DATA_FIELDS = [val for key, val in BCctbase.__dict__.items() if key[0] != '_']
60
72
 
61
73
  def replace_nan_inf(data, inplace=False):
62
74
  assert isinstance(data, (dict, list)), "Only dictionaries and lists are supported"
@@ -534,6 +546,25 @@ class BaseBlockEngine:
534
546
  address = address[len(BCct.ADDR_PREFIX_OLD):]
535
547
  return address
536
548
 
549
+ def _add_prefix(self, address):
550
+ """
551
+ Adds the prefix to the address
552
+
553
+ Parameters
554
+ ----------
555
+ address : str
556
+ the text address.
557
+
558
+ Returns
559
+ -------
560
+ address : str
561
+ the address with the prefix.
562
+ """
563
+ address = self._remove_prefix(address)
564
+ address = BCct.ADDR_PREFIX + address
565
+ return address
566
+
567
+
537
568
  def _pk_to_address(self, public_key):
538
569
  """
539
570
  Given a pk object will return the simple text address.
@@ -889,7 +920,7 @@ class BaseBlockEngine:
889
920
  return result
890
921
 
891
922
 
892
- def sign(self, dct_data: dict, add_data=True, use_digest=True, replace_nan=True) -> str:
923
+ def sign(self, dct_data: dict, add_data=True, use_digest=True, replace_nan=True, eth_sign=False) -> str:
893
924
  """
894
925
  Generates the signature for a dict object.
895
926
  Does not add the signature to the dict object
@@ -908,6 +939,9 @@ class BaseBlockEngine:
908
939
 
909
940
  replace_nan: bool, optional
910
941
  will replace `np.nan` and `np.inf` with `None` before signing.
942
+
943
+ eth_sign: bool, optional
944
+ will also sign the data with the Ethereum account. Default `False`
911
945
 
912
946
  Returns
913
947
  -------
@@ -926,6 +960,7 @@ class BaseBlockEngine:
926
960
  return_all=True,
927
961
  replace_nan=replace_nan,
928
962
  )
963
+ text_data = bdata.decode()
929
964
  if use_digest:
930
965
  bdata = bin_hexdigest # to-sign data is the hash
931
966
  # finally sign either full or just hash
@@ -934,6 +969,15 @@ class BaseBlockEngine:
934
969
  # not populate dict
935
970
  dct_data[BCct.SIGN] = result
936
971
  dct_data[BCct.SENDER] = self.address
972
+ dct_data[BCct.ETH_SENDER] = self.eth_address
973
+ ### add eth signature
974
+ dct_data[BCct.ETH_SIGN] = "0xBEEF"
975
+ if eth_sign:
976
+ eth_sign_info = self.eth_sign_text(text_data, signature_only=False)
977
+ # can be replaced with dct_data[BCct.ETH_SIGN] = self.eth_sign_text(bdata.decode(), signature_only=True)
978
+ eth_sign = eth_sign_info.get('signature')
979
+ dct_data[BCct.ETH_SIGN] = eth_sign
980
+ ### end eth signature
937
981
  if use_digest:
938
982
  dct_data[BCct.HASH] = hexdigest
939
983
  return result
naeural_client/bc/ec.py CHANGED
@@ -494,6 +494,32 @@ class BaseBCEllipticCurveEngine(BaseBlockEngine):
494
494
  "sender" : self.eth_address,
495
495
  }
496
496
 
497
+ def eth_sign_text(self, message, signature_only=True):
498
+ """
499
+ Signs a text message using the private key.
500
+
501
+ Parameters
502
+ ----------
503
+ message : str
504
+ The message to sign.
505
+
506
+ signature_only : bool, optional
507
+ Whether to return only the signature. The default is True
508
+
509
+ Returns
510
+ -------
511
+ str
512
+ The signature of the message.
513
+ """
514
+ types = ["string"]
515
+ values = [message]
516
+ result = self.eth_sign_message(types, values)
517
+ if signature_only:
518
+ return result["signature"]
519
+ return result
520
+
521
+
522
+
497
523
  def eth_sign_node_epochs(self, node, epochs, epochs_vals, signature_only=True):
498
524
  """
499
525
  Signs the node availability
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: naeural_client
3
- Version: 2.3.3
3
+ Version: 2.3.5
4
4
  Summary: `naeural_client` is the Python SDK required for client app development for the Naeural Edge Protocol Edge Protocol framework
5
5
  Project-URL: Homepage, https://github.com/NaeuralEdgeProtocol/naeural_client
6
6
  Project-URL: Bug Tracker, https://github.com/NaeuralEdgeProtocol/naeural_client/issues
@@ -1,5 +1,5 @@
1
1
  naeural_client/__init__.py,sha256=UKEDGS0wFYyxwmhEAKJGecO2vYbIfRYUP4SQgnK10IE,578
2
- naeural_client/_ver.py,sha256=GQ_36ciIRKCRNG8bJxPw3rbxI1SLK92UEEFnv7b2rwg,330
2
+ naeural_client/_ver.py,sha256=EWnqul34PhmTnOrLt56k1VLDiMRHZEMFzpZfYfZWZAc,330
3
3
  naeural_client/base_decentra_object.py,sha256=wXjl65gWxxkhV6Tq48wFfNGITvdYdkKPT-wLurGB5vc,4287
4
4
  naeural_client/plugins_manager_mixin.py,sha256=X1JdGLDz0gN1rPnTN_5mJXR8JmqoBFQISJXmPR9yvCo,11106
5
5
  naeural_client/base/__init__.py,sha256=hACh83_cIv7-PwYMM3bQm2IBmNqiHw-3PAfDfAEKz9A,259
@@ -13,9 +13,9 @@ naeural_client/base/transaction.py,sha256=bfs6td5M0fINgPQNxhrl_AUjb1YiilLDQ-Cd_o
13
13
  naeural_client/base/payload/__init__.py,sha256=y8fBI8tG2ObNfaXFWjyWZXwu878FRYj_I8GIbHT4GKE,29
14
14
  naeural_client/base/payload/payload.py,sha256=v50D7mBBD2WwWzvpbRGMSr-X6vv5ie21IY1aDxTqe1c,2275
15
15
  naeural_client/bc/__init__.py,sha256=FQj23D1PrY06NUOARiKQi4cdj0-VxnoYgYDEht8lpr8,158
16
- naeural_client/bc/base.py,sha256=GI9CbI2RVgIBXpOoRjrhXt45tONlBDMrybX_BcL3_Os,29513
16
+ naeural_client/bc/base.py,sha256=ckUjK8f8pk5t70-hnDMPoqRwcQXlPFERNgCli2MKSKQ,30790
17
17
  naeural_client/bc/chain.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
- naeural_client/bc/ec.py,sha256=raIGI7BpSH8xU_Bg7RpKv9KEW3F6PuAdL5miZfvw7iI,14027
18
+ naeural_client/bc/ec.py,sha256=9yhMq3HEICQRLD9MO3YYlWrSIA9Dled4GAh4DVNs3h0,14593
19
19
  naeural_client/certs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  naeural_client/certs/r9092118.ala.eu-central-1.emqxsl.com.crt,sha256=y-6io0tseyx9-a4Pmde1z1gPULtJNSYUpG_YFkYaMKU,1337
21
21
  naeural_client/cli/README.md,sha256=WPdI_EjzAbUW1aPyj1sSR8rLydcJKZtoiaEtklQrjHo,74
@@ -80,8 +80,8 @@ naeural_client/utils/__init__.py,sha256=mAnke3-MeRzz3nhQvhuHqLnpaaCSmDxicd7Ck9uw
80
80
  naeural_client/utils/comm_utils.py,sha256=4cS9llRr_pK_3rNgDcRMCQwYPO0kcNU7AdWy_LtMyCY,1072
81
81
  naeural_client/utils/config.py,sha256=t_VzyBnRHJa-Kt71HUu9gXxeDOri1Aqf_-gjO04gAYs,3681
82
82
  naeural_client/utils/dotenv.py,sha256=_AgSo35n7EnQv5yDyu7C7i0kHragLJoCGydHjvOkrYY,2008
83
- naeural_client-2.3.3.dist-info/METADATA,sha256=K-DHydXlyDgYHKBW_lYVnGV3ZG0xqoePu216HbcdsPY,14449
84
- naeural_client-2.3.3.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
85
- naeural_client-2.3.3.dist-info/entry_points.txt,sha256=PNdyotDaQBAslZREx5luVyj0kqpQnwNACwkFNTPIHU4,55
86
- naeural_client-2.3.3.dist-info/licenses/LICENSE,sha256=cvOsJVslde4oIaTCadabXnPqZmzcBO2f2zwXZRmJEbE,11311
87
- naeural_client-2.3.3.dist-info/RECORD,,
83
+ naeural_client-2.3.5.dist-info/METADATA,sha256=l_voa5q2PaSwS1ZqkDu_w2ncdFah_jSWomW1kEY_8Z8,14449
84
+ naeural_client-2.3.5.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
85
+ naeural_client-2.3.5.dist-info/entry_points.txt,sha256=PNdyotDaQBAslZREx5luVyj0kqpQnwNACwkFNTPIHU4,55
86
+ naeural_client-2.3.5.dist-info/licenses/LICENSE,sha256=cvOsJVslde4oIaTCadabXnPqZmzcBO2f2zwXZRmJEbE,11311
87
+ naeural_client-2.3.5.dist-info/RECORD,,