naeural-client 2.5.14__py3-none-any.whl → 2.5.15__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 +1 -1
- naeural_client/bc/base.py +43 -21
- {naeural_client-2.5.14.dist-info → naeural_client-2.5.15.dist-info}/METADATA +1 -1
- {naeural_client-2.5.14.dist-info → naeural_client-2.5.15.dist-info}/RECORD +7 -7
- {naeural_client-2.5.14.dist-info → naeural_client-2.5.15.dist-info}/WHEEL +0 -0
- {naeural_client-2.5.14.dist-info → naeural_client-2.5.15.dist-info}/entry_points.txt +0 -0
- {naeural_client-2.5.14.dist-info → naeural_client-2.5.15.dist-info}/licenses/LICENSE +0 -0
naeural_client/_ver.py
CHANGED
naeural_client/bc/base.py
CHANGED
@@ -21,9 +21,7 @@ class BCctbase:
|
|
21
21
|
|
22
22
|
ETH_SIGN = 'EE_ETH_SIGN'
|
23
23
|
ETH_SENDER= 'EE_ETH_SENDER'
|
24
|
-
|
25
|
-
# TODO: generate automaticall the NON_DATA_FIELDS
|
26
|
-
|
24
|
+
|
27
25
|
|
28
26
|
class BCct:
|
29
27
|
SIGN = BCctbase.SIGN
|
@@ -52,7 +50,7 @@ class BCct:
|
|
52
50
|
AUTHORISED_ADDRS = 'authorized_addrs'
|
53
51
|
|
54
52
|
DEFAULT_INFO = '0xai handshake data'
|
55
|
-
|
53
|
+
|
56
54
|
|
57
55
|
|
58
56
|
class _DotDict(dict):
|
@@ -68,7 +66,12 @@ class VerifyMessage(_DotDict):
|
|
68
66
|
self.sender = None
|
69
67
|
|
70
68
|
|
71
|
-
|
69
|
+
ALL_NON_DATA_FIELDS = [val for key, val in BCctbase.__dict__.items() if key[0] != '_']
|
70
|
+
|
71
|
+
NO_ETH_NON_DATA_FIELDS = [
|
72
|
+
val for key, val in BCctbase.__dict__.items()
|
73
|
+
if key[0] != '_' and not key.startswith('ETH_')
|
74
|
+
]
|
72
75
|
|
73
76
|
def replace_nan_inf(data, inplace=False):
|
74
77
|
assert isinstance(data, (dict, list)), "Only dictionaries and lists are supported"
|
@@ -295,7 +298,8 @@ class BaseBlockEngine:
|
|
295
298
|
config,
|
296
299
|
ensure_ascii_payloads=False,
|
297
300
|
verbosity=1,
|
298
|
-
user_config=False
|
301
|
+
user_config=False,
|
302
|
+
eth_enabled=True,
|
299
303
|
):
|
300
304
|
with cls._lock:
|
301
305
|
if name not in cls.__instances:
|
@@ -305,6 +309,7 @@ class BaseBlockEngine:
|
|
305
309
|
ensure_ascii_payloads=ensure_ascii_payloads,
|
306
310
|
verbosity=verbosity,
|
307
311
|
user_config=user_config,
|
312
|
+
eth_enabled=eth_enabled,
|
308
313
|
)
|
309
314
|
cls.__instances[name] = instance
|
310
315
|
else:
|
@@ -319,6 +324,7 @@ class BaseBlockEngine:
|
|
319
324
|
ensure_ascii_payloads=False,
|
320
325
|
verbosity=1,
|
321
326
|
user_config=False,
|
327
|
+
eth_enabled=True,
|
322
328
|
):
|
323
329
|
|
324
330
|
self.__name = name
|
@@ -332,6 +338,8 @@ class BaseBlockEngine:
|
|
332
338
|
self.__config = config
|
333
339
|
self.__ensure_ascii_payloads = ensure_ascii_payloads
|
334
340
|
|
341
|
+
self.__eth_enabled = eth_enabled
|
342
|
+
|
335
343
|
if user_config:
|
336
344
|
user_folder = get_user_folder()
|
337
345
|
pem_fn = str(user_folder / '_naeural.pem')
|
@@ -356,6 +364,11 @@ class BaseBlockEngine:
|
|
356
364
|
**kwargs
|
357
365
|
)
|
358
366
|
|
367
|
+
|
368
|
+
@property
|
369
|
+
def eth_enabled(self):
|
370
|
+
return self.__eth_enabled
|
371
|
+
|
359
372
|
@property
|
360
373
|
def name(self):
|
361
374
|
return self.__name
|
@@ -376,8 +389,7 @@ class BaseBlockEngine:
|
|
376
389
|
from_file=True,
|
377
390
|
password=self.__password,
|
378
391
|
)
|
379
|
-
self.P(" Loaded sk from {}".format(full_path), verbosity=1)
|
380
|
-
os.environ[BCct.K_USER_CONFIG_PEM_FILE] = self.__pem_file
|
392
|
+
self.P(" Loaded sk from {}".format(full_path), verbosity=1)
|
381
393
|
except:
|
382
394
|
self.P(" Failed to load sk from {}".format(full_path), color='r', verbosity=1)
|
383
395
|
|
@@ -389,6 +401,9 @@ class BaseBlockEngine:
|
|
389
401
|
password=self.__password,
|
390
402
|
fn=self.__pem_file,
|
391
403
|
)
|
404
|
+
|
405
|
+
os.environ[BCct.K_USER_CONFIG_PEM_FILE] = self.__pem_file
|
406
|
+
|
392
407
|
self.__public_key = self._get_pk(private_key=self.__private_key)
|
393
408
|
self.__address = self._pk_to_address(self.__public_key)
|
394
409
|
### Ethereum
|
@@ -947,7 +962,11 @@ class BaseBlockEngine:
|
|
947
962
|
The dict will be modified inplace to replace NaN and Inf with None.
|
948
963
|
"""
|
949
964
|
assert isinstance(dct_data, dict), "Cannot compute hash on non-dict data"
|
950
|
-
|
965
|
+
if self.eth_enabled:
|
966
|
+
dct_only_data = {k:dct_data[k] for k in dct_data if k not in ALL_NON_DATA_FIELDS}
|
967
|
+
else:
|
968
|
+
dct_only_data = {k:dct_data[k] for k in dct_data if k not in NO_ETH_NON_DATA_FIELDS}
|
969
|
+
#endif
|
951
970
|
str_data = self._dict_to_json(
|
952
971
|
dct_only_data,
|
953
972
|
replace_nan=replace_nan,
|
@@ -1032,18 +1051,20 @@ class BaseBlockEngine:
|
|
1032
1051
|
# finally sign either full or just hash
|
1033
1052
|
result = self._sign(data=bdata, private_key=self.__private_key, text=True)
|
1034
1053
|
if add_data:
|
1035
|
-
#
|
1054
|
+
# now populate dict
|
1036
1055
|
dct_data[BCct.SIGN] = result
|
1037
1056
|
dct_data[BCct.SENDER] = self.address
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1057
|
+
|
1058
|
+
if self.__eth_enabled:
|
1059
|
+
dct_data[BCct.ETH_SENDER] = self.eth_address
|
1060
|
+
### add eth signature
|
1061
|
+
dct_data[BCct.ETH_SIGN] = "0xBEEF"
|
1062
|
+
if eth_sign:
|
1063
|
+
eth_sign_info = self.eth_sign_text(text_data, signature_only=False)
|
1064
|
+
# can be replaced with dct_data[BCct.ETH_SIGN] = self.eth_sign_text(bdata.decode(), signature_only=True)
|
1065
|
+
eth_sign = eth_sign_info.get('signature')
|
1066
|
+
dct_data[BCct.ETH_SIGN] = eth_sign
|
1067
|
+
### end eth signature
|
1047
1068
|
if use_digest:
|
1048
1069
|
dct_data[BCct.HASH] = hexdigest
|
1049
1070
|
return result
|
@@ -1059,7 +1080,7 @@ class BaseBlockEngine:
|
|
1059
1080
|
verify_allowed=False,
|
1060
1081
|
replace_nan=True,
|
1061
1082
|
log_hash_sign_fails=True,
|
1062
|
-
)
|
1083
|
+
):
|
1063
1084
|
"""
|
1064
1085
|
Verifies the signature validity of a given text message
|
1065
1086
|
|
@@ -1090,7 +1111,8 @@ class BaseBlockEngine:
|
|
1090
1111
|
Returns
|
1091
1112
|
-------
|
1092
1113
|
bool / VerifyMessage
|
1093
|
-
returns `True` if signature verifies else `False`.
|
1114
|
+
returns `True` if signature verifies else `False`.
|
1115
|
+
returns `VerifyMessage` structure if return_full_info (default `True`)
|
1094
1116
|
|
1095
1117
|
"""
|
1096
1118
|
result = False
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: naeural_client
|
3
|
-
Version: 2.5.
|
3
|
+
Version: 2.5.15
|
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=GP8WSrn87sjTPO-QRNL2PG8JK5Mixbiea_HrtbG8RAQ,592
|
2
|
-
naeural_client/_ver.py,sha256=
|
2
|
+
naeural_client/_ver.py,sha256=faJGaZrSmtt1EqoiJ0ZLjHFxC6EqyGieKCP_GSS8tPc,331
|
3
3
|
naeural_client/base_decentra_object.py,sha256=C4iwZTkhKNBS4VHlJs5DfElRYLo4Q9l1V1DNVSk1fyQ,4412
|
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
|
@@ -14,7 +14,7 @@ naeural_client/base/webapp_pipeline.py,sha256=QmPLVmhP0CPdi0YuvbZEH4APYz2Amtw3gy
|
|
14
14
|
naeural_client/base/payload/__init__.py,sha256=y8fBI8tG2ObNfaXFWjyWZXwu878FRYj_I8GIbHT4GKE,29
|
15
15
|
naeural_client/base/payload/payload.py,sha256=x-au7l67Z_vfn_4R2C_pjZCaFuUVXHngJiGOfIAYVdE,2690
|
16
16
|
naeural_client/bc/__init__.py,sha256=FQj23D1PrY06NUOARiKQi4cdj0-VxnoYgYDEht8lpr8,158
|
17
|
-
naeural_client/bc/base.py,sha256=
|
17
|
+
naeural_client/bc/base.py,sha256=ki0Q1a9Ssy0EXi2TobbUK6-JCTQ0qovPxoQD0QSgGKY,32712
|
18
18
|
naeural_client/bc/chain.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
19
19
|
naeural_client/bc/ec.py,sha256=mWjodWCRgC3omVXOA9jtNdtPVNn2kMKV3Dcjt9oFUCQ,22974
|
20
20
|
naeural_client/certs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -81,8 +81,8 @@ naeural_client/utils/__init__.py,sha256=mAnke3-MeRzz3nhQvhuHqLnpaaCSmDxicd7Ck9uw
|
|
81
81
|
naeural_client/utils/comm_utils.py,sha256=4cS9llRr_pK_3rNgDcRMCQwYPO0kcNU7AdWy_LtMyCY,1072
|
82
82
|
naeural_client/utils/config.py,sha256=aUVyi5rZjvnbUwM5mmj0E2IHvURdrlHSgleqZvJBNuU,5202
|
83
83
|
naeural_client/utils/dotenv.py,sha256=_AgSo35n7EnQv5yDyu7C7i0kHragLJoCGydHjvOkrYY,2008
|
84
|
-
naeural_client-2.5.
|
85
|
-
naeural_client-2.5.
|
86
|
-
naeural_client-2.5.
|
87
|
-
naeural_client-2.5.
|
88
|
-
naeural_client-2.5.
|
84
|
+
naeural_client-2.5.15.dist-info/METADATA,sha256=yKJZGG5cvOHV1ZUTMIY2zBGlQJO-bfAoWcG7LI7upz8,14494
|
85
|
+
naeural_client-2.5.15.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
86
|
+
naeural_client-2.5.15.dist-info/entry_points.txt,sha256=PNdyotDaQBAslZREx5luVyj0kqpQnwNACwkFNTPIHU4,55
|
87
|
+
naeural_client-2.5.15.dist-info/licenses/LICENSE,sha256=cvOsJVslde4oIaTCadabXnPqZmzcBO2f2zwXZRmJEbE,11311
|
88
|
+
naeural_client-2.5.15.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|