@ethernity-cloud/sdk-js 1.1.0
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.
- package/LICENSE +661 -0
- package/README.md +185 -0
- package/build.js +22 -0
- package/init.js +301 -0
- package/nodenithy/build/las/Dockerfile +5 -0
- package/nodenithy/build/securelock/Dockerfile.tmpl +65 -0
- package/nodenithy/build/securelock/scripts/binary-fs-build.sh +28 -0
- package/nodenithy/build/securelock/src/.env +3 -0
- package/nodenithy/build/securelock/src/etny_crypto.js +201 -0
- package/nodenithy/build/securelock/src/etny_exec.js +65 -0
- package/nodenithy/build/securelock/src/image_registry_abi.js +808 -0
- package/nodenithy/build/securelock/src/models.js +261 -0
- package/nodenithy/build/securelock/src/package.json +40 -0
- package/nodenithy/build/securelock/src/pox_abi.js +1491 -0
- package/nodenithy/build/securelock/src/securelock.js.tmpl +421 -0
- package/nodenithy/build/securelock/src/swift_stream_service.js +147 -0
- package/nodenithy/build/securelock/src/task_status.js +15 -0
- package/nodenithy/build/securelock/src/wallet.js +29 -0
- package/nodenithy/build/squash/Dockerfile +7 -0
- package/nodenithy/build/trustedzone/Dockerfile.tmpl +57 -0
- package/nodenithy/build/trustedzone/scripts/binary-fs-build.sh +22 -0
- package/nodenithy/build/trustedzone/src/.env +3 -0
- package/nodenithy/build/trustedzone/src/etny_crypto.js +202 -0
- package/nodenithy/build/trustedzone/src/etny_exec.js +54 -0
- package/nodenithy/build/trustedzone/src/image_registry_abi.js +808 -0
- package/nodenithy/build/trustedzone/src/models.js +261 -0
- package/nodenithy/build/trustedzone/src/package.json +40 -0
- package/nodenithy/build/trustedzone/src/pox_abi.js +1491 -0
- package/nodenithy/build/trustedzone/src/swift_stream_service.js +147 -0
- package/nodenithy/build/trustedzone/src/task_status.js +15 -0
- package/nodenithy/build/trustedzone/src/test.js +44 -0
- package/nodenithy/build/trustedzone/src/trustedzone.js.tmpl +508 -0
- package/nodenithy/build/trustedzone/src/wallet.js +28 -0
- package/nodenithy/build/validator/Dockerfile +58 -0
- package/nodenithy/build/validator/package-lock.json +6 -0
- package/nodenithy/build/validator/scripts/binary-fs-build.sh +19 -0
- package/nodenithy/build/validator/src/.env +3 -0
- package/nodenithy/build/validator/src/cert.pem +5 -0
- package/nodenithy/build/validator/src/etny_crypto.js +204 -0
- package/nodenithy/build/validator/src/etny_exec.js +52 -0
- package/nodenithy/build/validator/src/image_registry_abi.js +808 -0
- package/nodenithy/build/validator/src/key.pem +6 -0
- package/nodenithy/build/validator/src/models.js +261 -0
- package/nodenithy/build/validator/src/package-lock.json +2498 -0
- package/nodenithy/build/validator/src/package.json +40 -0
- package/nodenithy/build/validator/src/pox_abi.js +1491 -0
- package/nodenithy/build/validator/src/swift_stream_service.js +147 -0
- package/nodenithy/build/validator/src/task_status.js +15 -0
- package/nodenithy/build/validator/src/test.js +44 -0
- package/nodenithy/build/validator/src/trustedzone.js +613 -0
- package/nodenithy/build/validator/src/validator_abi.js +834 -0
- package/nodenithy/build/validator/src/wallet.js +28 -0
- package/nodenithy/build.js +184 -0
- package/nodenithy/build.mjs +179 -0
- package/nodenithy/build.sh +161 -0
- package/nodenithy/ipfs.js +135 -0
- package/nodenithy/ipfs.mjs +551 -0
- package/nodenithy/public/favicon.ico +0 -0
- package/nodenithy/public/index.html +43 -0
- package/nodenithy/public/logo192.png +0 -0
- package/nodenithy/public/logo512.png +0 -0
- package/nodenithy/public/manifest.json +25 -0
- package/nodenithy/public/robots.txt +3 -0
- package/nodenithy/run/__pycache__/swift_stream_service.cpython-312.pyc +0 -0
- package/nodenithy/run/app/input.txt +4 -0
- package/nodenithy/run/app/payload.js +4 -0
- package/nodenithy/run/docker-compose-final.yml.tmpl +65 -0
- package/nodenithy/run/docker-compose-swift-stream.yml +17 -0
- package/nodenithy/run/docker-compose.yml.tmpl +76 -0
- package/nodenithy/run/etny-securelock-test.yaml.tpl +46 -0
- package/nodenithy/run/etny-trustedzone-test.yaml.tpl +45 -0
- package/nodenithy/run/git.sh +22 -0
- package/nodenithy/run/image_registry.abi +1 -0
- package/nodenithy/run/image_registry.js +372 -0
- package/nodenithy/run/image_registry.py +327 -0
- package/nodenithy/run/image_registry_runner.py +71 -0
- package/nodenithy/run/ipfs.sh +58 -0
- package/nodenithy/run/ipfs_pre.sh +75 -0
- package/nodenithy/run/public_key_service.js +90 -0
- package/nodenithy/run/public_key_service.py +107 -0
- package/nodenithy/run/swift_stream_service.py +212 -0
- package/nodenithy/run/swiftstream.py +37 -0
- package/nodenithy/run/swiftstream1.py +27 -0
- package/nodenithy/run.js +538 -0
- package/nodenithy/run.sh +277 -0
- package/nodenithy/scripts/build-ipfs-upload.sh +23 -0
- package/nodenithy/scripts/build.sh +40 -0
- package/nodenithy/scripts/ipfs-daemon.sh +7 -0
- package/nodenithy/scripts/run.sh +50 -0
- package/nodenithy/src/App.css +57 -0
- package/nodenithy/src/ec_helloworld_example.js +64 -0
- package/nodenithy/src/index.css +13 -0
- package/nodenithy/src/index.js +17 -0
- package/nodenithy/src/preStart.js +45 -0
- package/nodenithy/src/preStart.mjs +57 -0
- package/nodenithy/src/reportWebVitals.js +13 -0
- package/nodenithy/src/serverless/backend.js +5 -0
- package/package.json +48 -0
- package/postinstall.js +34 -0
- package/publish.js +126 -0
- package/pynithy/build/docker-compose.yml +68 -0
- package/pynithy/build/las/Dockerfile +11 -0
- package/pynithy/build/las/src/etny_entrypoint.sh +6 -0
- package/pynithy/build/las/src/las_entrypoint.sh +26 -0
- package/pynithy/build/scripts/binary-fs-build.sh +28 -0
- package/pynithy/build/securelock/Dockerfile.tmpl +78 -0
- package/pynithy/build/securelock/scripts/binary-fs-build.sh +41 -0
- package/pynithy/build/securelock/src/app/.env +5 -0
- package/pynithy/build/securelock/src/app/cert1-ca1-clean.crt +10 -0
- package/pynithy/build/securelock/src/app/cert1-ca1-clean.key +6 -0
- package/pynithy/build/securelock/src/app/enclave_pub_cert.pem +10 -0
- package/pynithy/build/securelock/src/app/input.txt +1 -0
- package/pynithy/build/securelock/src/app/payload.py +25 -0
- package/pynithy/build/securelock/src/app/public-cert-clean.pem +10 -0
- package/pynithy/build/securelock/src/app/result.txt +1 -0
- package/pynithy/build/securelock/src/app/transaction.txt +1 -0
- package/pynithy/build/securelock/src/etny_crypto.py +167 -0
- package/pynithy/build/securelock/src/etny_exec.py +79 -0
- package/pynithy/build/securelock/src/image_registry.abi +1 -0
- package/pynithy/build/securelock/src/key_generation.py +17 -0
- package/pynithy/build/securelock/src/models.py +176 -0
- package/pynithy/build/securelock/src/pox.abi +1489 -0
- package/pynithy/build/securelock/src/securelock.py.tmpl +411 -0
- package/pynithy/build/securelock/src/swift_stream_service.py +186 -0
- package/pynithy/build/trustedzone/Dockerfile.tmpl +56 -0
- package/pynithy/build/trustedzone/scripts/binary-fs-build.sh +32 -0
- package/pynithy/build/trustedzone/src/app/.env +5 -0
- package/pynithy/build/trustedzone/src/app/cert1-ca1-clean.crt +10 -0
- package/pynithy/build/trustedzone/src/app/cert1-ca1-clean.key +6 -0
- package/pynithy/build/trustedzone/src/app/enclave_pub_cert.pem +10 -0
- package/pynithy/build/trustedzone/src/app/input.txt +1 -0
- package/pynithy/build/trustedzone/src/app/payload.py +25 -0
- package/pynithy/build/trustedzone/src/app/public-cert-clean.pem +10 -0
- package/pynithy/build/trustedzone/src/app/result.txt +1 -0
- package/pynithy/build/trustedzone/src/app/securelock.crt +10 -0
- package/pynithy/build/trustedzone/src/app/transaction.txt +1 -0
- package/pynithy/build/trustedzone/src/app/trustedzone.crt +10 -0
- package/pynithy/build/trustedzone/src/etny_crypto.py +188 -0
- package/pynithy/build/trustedzone/src/etny_exec.py +56 -0
- package/pynithy/build/trustedzone/src/formatter.py +42 -0
- package/pynithy/build/trustedzone/src/image_registry.abi +1 -0
- package/pynithy/build/trustedzone/src/key_generation.py +17 -0
- package/pynithy/build/trustedzone/src/models.py +176 -0
- package/pynithy/build/trustedzone/src/pox.abi +1489 -0
- package/pynithy/build/trustedzone/src/swift_stream_service.py +186 -0
- package/pynithy/build/trustedzone/src/trustedzone.py.tmpl +460 -0
- package/pynithy/build.mjs +179 -0
- package/pynithy/docker-compose.yml +0 -0
- package/pynithy/ipfs.mjs +244 -0
- package/pynithy/public/favicon.ico +0 -0
- package/pynithy/public/index.html +43 -0
- package/pynithy/public/logo192.png +0 -0
- package/pynithy/public/logo512.png +0 -0
- package/pynithy/public/manifest.json +25 -0
- package/pynithy/public/robots.txt +3 -0
- package/pynithy/run/certs/cert.pem +31 -0
- package/pynithy/run/certs/challenge.crt +10 -0
- package/pynithy/run/certs/key.pem +52 -0
- package/pynithy/run/docker-compose-final.yml +59 -0
- package/pynithy/run/docker-compose-final.yml.tmpl +59 -0
- package/pynithy/run/docker-compose-swift-stream.yml +27 -0
- package/pynithy/run/docker-compose-swift-stream.yml.tmpl +27 -0
- package/pynithy/run/docker-compose.yml +55 -0
- package/pynithy/run/docker-compose.yml.tmpl +55 -0
- package/pynithy/run/etny-pynity-test.yaml.tpl +46 -0
- package/pynithy/run/etny-securelock-test.yaml.tpl +46 -0
- package/pynithy/run/etny-trustedzone-test.yaml.tpl +46 -0
- package/pynithy/run/git.sh +22 -0
- package/pynithy/run/image_registry.abi +1 -0
- package/pynithy/run/image_registry.js +372 -0
- package/pynithy/run/image_registry.py +139 -0
- package/pynithy/run/image_registry_runner.py +45 -0
- package/pynithy/run/ipfs.sh +89 -0
- package/pynithy/run/public_key_service.js +90 -0
- package/pynithy/run/swiftstream.py +28 -0
- package/pynithy/run.js +538 -0
- package/pynithy/src/App.css +57 -0
- package/pynithy/src/ec_helloworld_example.js +64 -0
- package/pynithy/src/index.css +13 -0
- package/pynithy/src/index.js +17 -0
- package/pynithy/src/preStart.mjs +57 -0
- package/pynithy/src/reportWebVitals.js +13 -0
- package/pynithy/src/serverless/__init__.py +0 -0
- package/pynithy/src/serverless/backend.py +2 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
|
2
|
+
MIIBczCB+qADAgECAgh7c9xYZiMrNDAKBggqhkjOPQQDAzASMRAwDgYDVQQDDAdD
|
|
3
|
+
QV9DRVJUMCAXDTIyMTIxNTEyNTczNVoYDzQwOTYwMTAxMDAwMDAwWjAWMRQwEgYD
|
|
4
|
+
VQQDDAtTRVJWRVJfQ0VSVDB2MBAGByqGSM49AgEGBSuBBAAiA2IABP8MVsw/zCoO
|
|
5
|
+
SH1Hi/jdGfD6w9zWWKs/Z1dm6RBzmeKdJ8g37kGT35mMHiZw4QZEsnaDtTl2dEmM
|
|
6
|
+
0b8vePjERUaiwv4kMQ4r/r54KiM9dmeKViP+qwMrNsO5KNBsOR6t2aMXMBUwEwYD
|
|
7
|
+
VR0lBAwwCgYIKwYBBQUHAwEwCgYIKoZIzj0EAwMDaAAwZQIxAMlYmEz4z6e34Ui/
|
|
8
|
+
l5GNmChI3NUYc5MTL4Zu9X8b/tK82xI2XCv9XWYPHo/gNyA/oAIwDdhKVmDPZjGN
|
|
9
|
+
rU1rl8/+lPT/O1+4mrnyyEB2Vx7Ku1s2MoPf5bS0S/hofEJRmixM
|
|
10
|
+
-----END CERTIFICATE-----
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
-----BEGIN PRIVATE KEY-----
|
|
2
|
+
MIG2AgEAMBAGByqGSM49AgEGBSuBBAAiBIGeMIGbAgEBBDD7xfiPdY+Du8Cn0/yT
|
|
3
|
+
WsYqBPVo7e271N0dZ5Rs9Mur8+M/VyH4g/nDReh3l0mzP4ihZANiAAT/DFbMP8wq
|
|
4
|
+
Dkh9R4v43Rnw+sPc1lirP2dXZukQc5ninSfIN+5Bk9+ZjB4mcOEGRLJ2g7U5dnRJ
|
|
5
|
+
jNG/L3j4xEVGosL+JDEOK/6+eCojPXZnilYj/qsDKzbDuSjQbDkerdk=
|
|
6
|
+
-----END PRIVATE KEY-----
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
|
2
|
+
MIIBczCB+qADAgECAgh7c9xYZiMrNDAKBggqhkjOPQQDAzASMRAwDgYDVQQDDAdD
|
|
3
|
+
QV9DRVJUMCAXDTIyMTIxNTEyNTczNVoYDzQwOTYwMTAxMDAwMDAwWjAWMRQwEgYD
|
|
4
|
+
VQQDDAtTRVJWRVJfQ0VSVDB2MBAGByqGSM49AgEGBSuBBAAiA2IABP8MVsw/zCoO
|
|
5
|
+
SH1Hi/jdGfD6w9zWWKs/Z1dm6RBzmeKdJ8g37kGT35mMHiZw4QZEsnaDtTl2dEmM
|
|
6
|
+
0b8vePjERUaiwv4kMQ4r/r54KiM9dmeKViP+qwMrNsO5KNBsOR6t2aMXMBUwEwYD
|
|
7
|
+
VR0lBAwwCgYIKwYBBQUHAwEwCgYIKoZIzj0EAwMDaAAwZQIxAMlYmEz4z6e34Ui/
|
|
8
|
+
l5GNmChI3NUYc5MTL4Zu9X8b/tK82xI2XCv9XWYPHo/gNyA/oAIwDdhKVmDPZjGN
|
|
9
|
+
rU1rl8/+lPT/O1+4mrnyyEB2Vx7Ku1s2MoPf5bS0S/hofEJRmixM
|
|
10
|
+
-----END CERTIFICATE-----
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
sample input data
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import time
|
|
2
|
+
from decimal import Decimal, getcontext
|
|
3
|
+
|
|
4
|
+
def compute(n):
|
|
5
|
+
getcontext().prec = n
|
|
6
|
+
res = Decimal(0)
|
|
7
|
+
for i in range(n):
|
|
8
|
+
a = Decimal(1)/(16**i)
|
|
9
|
+
b = Decimal(4)/(8*i+1)
|
|
10
|
+
c = Decimal(2)/(8*i+4)
|
|
11
|
+
d = Decimal(1)/(8*i+5)
|
|
12
|
+
e = Decimal(1)/(8*i+6)
|
|
13
|
+
r = a*(b-c-d-e)
|
|
14
|
+
res += r
|
|
15
|
+
return res
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
t1 = time.time()
|
|
19
|
+
res = compute(2000)
|
|
20
|
+
dt = time.time()-t1
|
|
21
|
+
|
|
22
|
+
___etny_result___(str(res))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
|
2
|
+
MIIBczCB+qADAgECAghVH/dYKMPvcjAKBggqhkjOPQQDAzASMRAwDgYDVQQDDAdD
|
|
3
|
+
QV9DRVJUMCAXDTIyMTIyMzE2NTY0NVoYDzQwOTYwMTAxMDAwMDAwWjAWMRQwEgYD
|
|
4
|
+
VQQDDAtTRVJWRVJfQ0VSVDB2MBAGByqGSM49AgEGBSuBBAAiA2IABJswHiJ0gxgS
|
|
5
|
+
Z5UuIWpbgsZGl6K6iEucllY7z64mulQaI2gpBqa2SvRjmXPAzpVeBgyRMxWlj7/c
|
|
6
|
+
vpIpSaaHWxmo1H0IXILtykxS+icwdtsBc/VNdQga/Af4Kvb1g0Cgo6MXMBUwEwYD
|
|
7
|
+
VR0lBAwwCgYIKwYBBQUHAwEwCgYIKoZIzj0EAwMDaAAwZQIxALpMDGNogbZ/fYGP
|
|
8
|
+
nMsr7iAX5ereCqErg6BISUEaIC4kjVHaCbaRQpFFyl4A16cW6AIwSmAY5M8O4nAD
|
|
9
|
+
Ow4YZQBfOv1MySqCQOuLPmMhp84AU7gxQCjRJiWEKQuBlH/aH6Zc
|
|
10
|
+
-----END CERTIFICATE-----
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632788659361533818279682303019520353018529689957736225994138912497217752834791315155748572424541506959508295331168617278558890750983817546374649393192550604009277016711390098488240128583616035637076601047101819429555961989467678374494482553797747268471040475346462080466842590694912933136770289891521047521620569660240580381501935112533824300355876402474964732639141992726042699227967823547816360093417216412199245863150302861829745557067498385054945885869269956909272107975093029553211653449872027559602364806654991198818347977535663698074265425278625518184175746728909777727938000816470600161452491921732172147723501414419735685481613611573525521334757418494684385233239073941433345477624168625189835694855620992192221842725502542568876717904946016534668049886272327917860857843838279679766814541009538837863609506800642251252051173929848960841284886269456042419652850222106611863067442786220391949450471237137869609563643719172874677646575739624138908658326459958133904780275910
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
|
2
|
+
MIIBdDCB+6ADAgECAgkApHn/SJo25GowCgYIKoZIzj0EAwMwEjEQMA4GA1UEAwwH
|
|
3
|
+
Q0FfQ0VSVDAgFw0yMzA2MDMwNzQyNDFaGA80MDk2MDEwMTAwMDAwMFowFjEUMBIG
|
|
4
|
+
A1UEAwwLU0VSVkVSX0NFUlQwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAASexaa+tBw8
|
|
5
|
+
dCu9nH17Tt9K9Xfg3BAlhskg1Evh6pJdXzPb+u8ZtCHeohQEMJXBNOJe4fu28Ksp
|
|
6
|
+
e8N2od2lcqy8kRAm2+g/K0TW97jxN6COkfO2Q2B6s8ZL5obU3CDLA7WjFzAVMBMG
|
|
7
|
+
A1UdJQQMMAoGCCsGAQUFBwMBMAoGCCqGSM49BAMDA2gAMGUCMQDA56m4IopmqtWJ
|
|
8
|
+
xTsl58w6dwME0ntGzTeUd6Cw07HDqeI6wald7NZ59gJ7IexZHC4CMCXqbeI4kMgX
|
|
9
|
+
CYPaqAY3jYDztcRp6No10Qar1iY6eHsns/JUZQBWiMFqCMgpZeuODQ==
|
|
10
|
+
-----END CERTIFICATE-----
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
f9012a80830f4240830f424094549a6e06bb2084100148d50f51cf77a3436c3ae780b8c414e9f38400000000000000000000000000000000000000000000000000000000000015e20000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000005b76313a303a626563353065616630323933623439633761653461393932656137383436336661306539653165376165386332626330653733336435343234383832303764363a726172616a676d7a686c626f736978717a6272793a0000000000824669a0304b2c4abee5a3c945dda995926b0c2fe72fde420468cfbc24eaccd5b8cdab87a0328656248b926043795515c05bc4cf90a1bb3e112818f6116d00a7cfc9bb3215
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
|
2
|
+
MIIBdDCB+6ADAgECAgkAwIvaCpT+w1AwCgYIKoZIzj0EAwMwEjEQMA4GA1UEAwwH
|
|
3
|
+
Q0FfQ0VSVDAgFw0yMzA2MDMwNzQyNDVaGA80MDk2MDEwMTAwMDAwMFowFjEUMBIG
|
|
4
|
+
A1UEAwwLU0VSVkVSX0NFUlQwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAATpSmxix5Og
|
|
5
|
+
65dj4rIXPkSFoCa11ZjiEpJVW7zloyw8dZrigMXFoYjij09qr0KBnCoK+rEjYsdK
|
|
6
|
+
B3t5Nd6bSnInLozslwT4/HptAWRxixjmXNH2icQP9YsYxTqQqSmI97GjFzAVMBMG
|
|
7
|
+
A1UdJQQMMAoGCCsGAQUFBwMBMAoGCCqGSM49BAMDA2gAMGUCMB5fhp8xmWVL1z5M
|
|
8
|
+
uHGllj1mZWnSDq7W+3711FZ2pT9A/Har408Y+qukIJXasvdioAIxALUo4V3dLazn
|
|
9
|
+
490nAYc+bMASEtY3x3fHYYoP9Ym5PlnuM4GgepRM+GFpXKuXgoxLYA==
|
|
10
|
+
-----END CERTIFICATE-----
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import base64
|
|
4
|
+
import binascii
|
|
5
|
+
import codecs
|
|
6
|
+
import hashlib
|
|
7
|
+
import json
|
|
8
|
+
import secrets
|
|
9
|
+
from pyasn1.codec.der import decoder
|
|
10
|
+
from Crypto.Cipher import AES
|
|
11
|
+
from tinyec import registry
|
|
12
|
+
from tinyec import ec
|
|
13
|
+
from Crypto.PublicKey import ECC
|
|
14
|
+
from nacl.public import Box, PrivateKey, PublicKey
|
|
15
|
+
from base64 import a85encode
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class etny_crypto:
|
|
19
|
+
curve = registry.get_curve('secp384r1')
|
|
20
|
+
|
|
21
|
+
@staticmethod
|
|
22
|
+
def compress_point(point):
|
|
23
|
+
return hex(point.x) + hex(point.y % 2)[2:]
|
|
24
|
+
|
|
25
|
+
@staticmethod
|
|
26
|
+
def ecc_point_to_256_bit_key(point):
|
|
27
|
+
value = str(point.x) + str(point.y)
|
|
28
|
+
sha = hashlib.sha256(value.encode())
|
|
29
|
+
return sha.digest()
|
|
30
|
+
|
|
31
|
+
@staticmethod
|
|
32
|
+
def encrypt_aes_gcm(msg, secret_key):
|
|
33
|
+
aes_cipher = AES.new(secret_key, AES.MODE_GCM)
|
|
34
|
+
cipher_text, auth_tag = aes_cipher.encrypt_and_digest(msg)
|
|
35
|
+
return (cipher_text, aes_cipher.nonce, auth_tag)
|
|
36
|
+
|
|
37
|
+
@staticmethod
|
|
38
|
+
def encrypt_ecc(msg, public_key):
|
|
39
|
+
cipher_text_private_key = secrets.randbelow(etny_crypto.curve.field.n)
|
|
40
|
+
shared_ecc_key = cipher_text_private_key * public_key
|
|
41
|
+
secret_key = etny_crypto.ecc_point_to_256_bit_key(shared_ecc_key)
|
|
42
|
+
ciphertext, nonce, auth_tag = etny_crypto.encrypt_aes_gcm(msg, secret_key)
|
|
43
|
+
cipher_text_public_key = cipher_text_private_key * etny_crypto.curve.g
|
|
44
|
+
return (ciphertext, nonce, auth_tag, cipher_text_public_key)
|
|
45
|
+
|
|
46
|
+
@staticmethod
|
|
47
|
+
def decrypt_ase_gcm(ciphertext, nonce, auth_tag, secret_key):
|
|
48
|
+
aes_cipher = AES.new(secret_key, AES.MODE_GCM, nonce)
|
|
49
|
+
plaintext = aes_cipher.decrypt_and_verify(ciphertext, auth_tag)
|
|
50
|
+
return plaintext
|
|
51
|
+
|
|
52
|
+
@staticmethod
|
|
53
|
+
def decrypt_ecc(encrypted_msg, priv_key):
|
|
54
|
+
(ciphertext, nonce, authTag, ciphertextPubKey) = encrypted_msg
|
|
55
|
+
shared_ecc_key = priv_key * ciphertextPubKey
|
|
56
|
+
secret_key = etny_crypto.ecc_point_to_256_bit_key(shared_ecc_key)
|
|
57
|
+
plaintext = etny_crypto.decrypt_ase_gcm(ciphertext, nonce, authTag, secret_key)
|
|
58
|
+
return plaintext
|
|
59
|
+
|
|
60
|
+
@staticmethod
|
|
61
|
+
def ecc_read_key(public_key_file):
|
|
62
|
+
with open(public_key_file) as r:
|
|
63
|
+
key = ECC.import_key(r.read())
|
|
64
|
+
return key
|
|
65
|
+
|
|
66
|
+
@staticmethod
|
|
67
|
+
def encrypt(public_key_file, message):
|
|
68
|
+
with open(public_key_file) as f:
|
|
69
|
+
ecc_public_cert = ECC.import_key(f.read())
|
|
70
|
+
pub_key_ecc_point = ec.Point(etny_crypto.curve, ecc_public_cert.pointQ.x.__int__(),
|
|
71
|
+
ecc_public_cert.pointQ.y.__int__())
|
|
72
|
+
encrypted_msg = etny_crypto.encrypt_ecc(message, pub_key_ecc_point)
|
|
73
|
+
return encrypted_msg
|
|
74
|
+
|
|
75
|
+
@staticmethod
|
|
76
|
+
def encrypt_with_pub_key(pub_key_content, message):
|
|
77
|
+
ecc_public_cert = ECC.import_key(pub_key_content)
|
|
78
|
+
pub_key_ecc_point = ec.Point(etny_crypto.curve, ecc_public_cert.pointQ.x.__int__(),
|
|
79
|
+
ecc_public_cert.pointQ.y.__int__())
|
|
80
|
+
encrypted_msg = etny_crypto.encrypt_ecc(message, pub_key_ecc_point)
|
|
81
|
+
return encrypted_msg
|
|
82
|
+
|
|
83
|
+
@staticmethod
|
|
84
|
+
def clean_private_key(private_key_data):
|
|
85
|
+
private_key_data = private_key_data.replace(b"-----BEGIN PRIVATE KEY-----", b"")
|
|
86
|
+
private_key_data = private_key_data.replace(b"-----END PRIVATE KEY-----", b"")
|
|
87
|
+
private_key_data = codecs.decode(private_key_data, 'base64')
|
|
88
|
+
return private_key_data
|
|
89
|
+
|
|
90
|
+
@staticmethod
|
|
91
|
+
def decrypt(private_key_file, encrypted_msg):
|
|
92
|
+
# Reading and calculating Private Key from PEM
|
|
93
|
+
with open(private_key_file) as f:
|
|
94
|
+
private_key_data = str.encode(f.read())
|
|
95
|
+
|
|
96
|
+
private_key_data = etny_crypto.clean_private_key(private_key_data)
|
|
97
|
+
# decode der with asn1 library
|
|
98
|
+
# - get the octet string (field-2) containing the raw key
|
|
99
|
+
asn1_object, _ = decoder.decode(private_key_data)
|
|
100
|
+
raw_keys = asn1_object.getComponentByName('field-2').asOctets()
|
|
101
|
+
# - get the octet string (field-1) containing the raw private key
|
|
102
|
+
# and the bit string (field-2) containing the uncompressed public key
|
|
103
|
+
asn1_object, _ = decoder.decode(raw_keys)
|
|
104
|
+
private_key = asn1_object.getComponentByName('field-1').asOctets()
|
|
105
|
+
|
|
106
|
+
# Generating keypair for tinyEC
|
|
107
|
+
priv_key_tec = int.from_bytes(private_key, byteorder="big")
|
|
108
|
+
decrypted_msg = etny_crypto.decrypt_ecc(encrypted_msg, priv_key_tec)
|
|
109
|
+
#print("\ndecrypted msg:", decrypted_msg)
|
|
110
|
+
return decrypted_msg
|
|
111
|
+
|
|
112
|
+
@staticmethod
|
|
113
|
+
def encrypted_data_to_base64_json(encrypted_msg):
|
|
114
|
+
json_obj = {
|
|
115
|
+
'ciphertext': binascii.hexlify(encrypted_msg[0]).decode(),
|
|
116
|
+
'nonce': binascii.hexlify(encrypted_msg[1]).decode(),
|
|
117
|
+
'authTag': binascii.hexlify(encrypted_msg[2]).decode(),
|
|
118
|
+
'x': hex(encrypted_msg[3].x),
|
|
119
|
+
'y': hex(encrypted_msg[3].y)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
json_string = json.dumps(json_obj)
|
|
123
|
+
binary_data = json_string.encode('utf-8')
|
|
124
|
+
base64_data = base64.b64encode(binary_data)
|
|
125
|
+
|
|
126
|
+
return base64_data
|
|
127
|
+
|
|
128
|
+
@staticmethod
|
|
129
|
+
def encrypted_data_from_base64_json(base64_data):
|
|
130
|
+
# decode the base64-encoded string back to a JSON string
|
|
131
|
+
decoded_json_data = base64.b64decode(base64_data).decode('utf-8')
|
|
132
|
+
|
|
133
|
+
json_load = json.loads(decoded_json_data)
|
|
134
|
+
return (binascii.unhexlify(json_load['ciphertext'].encode()),
|
|
135
|
+
binascii.unhexlify(json_load['nonce'].encode()),
|
|
136
|
+
binascii.unhexlify(json_load['authTag'].encode()),
|
|
137
|
+
ec.Point(etny_crypto.curve, int(json_load['x'], 16),
|
|
138
|
+
int(json_load['y'], 16)))
|
|
139
|
+
|
|
140
|
+
@staticmethod
|
|
141
|
+
def hex_to_bytes(hex_str: str) -> bytes:
|
|
142
|
+
return bytes.fromhex(hex_str[2:] if hex_str[:2] == "0x" else hex_str)
|
|
143
|
+
|
|
144
|
+
@staticmethod
|
|
145
|
+
def encrypt_nacl(public_key: str, data: bytes) -> str:
|
|
146
|
+
"""Encryption function using NaCl box compatible with MetaMask
|
|
147
|
+
For implementation used in MetaMask look into: https://github.com/MetaMask/eth-sig-util
|
|
148
|
+
Args:
|
|
149
|
+
public_key: public key of recipient (32 bytes)
|
|
150
|
+
data: message data
|
|
151
|
+
Returns:
|
|
152
|
+
encrypted data
|
|
153
|
+
"""
|
|
154
|
+
emph_key = PrivateKey.generate()
|
|
155
|
+
enc_box = Box(emph_key, PublicKey(etny_crypto.hex_to_bytes(public_key)))
|
|
156
|
+
# Encryption must work with MetaMask decryption (requires valid utf-8)
|
|
157
|
+
data = a85encode(data)
|
|
158
|
+
ciphertext = enc_box.encrypt(data)
|
|
159
|
+
result = bytes(emph_key.public_key) + ciphertext
|
|
160
|
+
return result.hex()
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
if __name__ == '__main__':
|
|
164
|
+
with open("./app/payload.py") as payload_data:
|
|
165
|
+
source = payload_data.read()
|
|
166
|
+
encrypted_source = etny_crypto.encrypt('./app/securelock.crt', source.encode())
|
|
167
|
+
encrypted_source_base64 = etny_crypto.encrypted_data_to_base64_json(encrypted_source)
|
|
168
|
+
#print('##############################################')
|
|
169
|
+
#print(encrypted_source)
|
|
170
|
+
#print('##############################################')
|
|
171
|
+
#print('base64: ', encrypted_source_base64.decode('utf-8'))
|
|
172
|
+
#print('##############################################')
|
|
173
|
+
encrypted_source_base64_ = etny_crypto.encrypted_data_from_base64_json(encrypted_source_base64)
|
|
174
|
+
decrypted_source = etny_crypto.decrypt('./app/cert1-ca1-clean.key', encrypted_source_base64_)
|
|
175
|
+
#print(decrypted_source)
|
|
176
|
+
#print('##############################################')
|
|
177
|
+
|
|
178
|
+
encrypted_source = etny_crypto.encrypt('./app/cert1-ca1-clean.crt', b'the result is: 123')
|
|
179
|
+
encrypted_source_base64 = etny_crypto.encrypted_data_to_base64_json(encrypted_source)
|
|
180
|
+
#print('result', encrypted_source_base64.decode('utf-8'))
|
|
181
|
+
|
|
182
|
+
encrypted_source1 = etny_crypto.encrypt('./app/cert1-ca1-clean.crt', b'0')
|
|
183
|
+
encrypted_source_base641 = etny_crypto.encrypted_data_to_base64_json(encrypted_source1)
|
|
184
|
+
#print('result code', encrypted_source_base641.decode('utf-8'))
|
|
185
|
+
# encrypted_msg_ = etny_crypto.encrypt('./app/cert1-ca1-clean.crt', b'test')
|
|
186
|
+
# print(encrypted_msg_)
|
|
187
|
+
# etny_crypto.decrypt('./certs/cert1-ca1-clean.key', encrypted_msg_)
|
|
188
|
+
# print(etny_crypto.encrypted_data_to_base64_json(encrypted_msg_))
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import os.path
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def ___etny_result___(data):
|
|
5
|
+
quit([0, data])
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class TaskStatus:
|
|
9
|
+
SUCCESS = 0
|
|
10
|
+
SYSTEM_ERROR = 1
|
|
11
|
+
KEY_ERROR = 2
|
|
12
|
+
SYNTAX_WARNING = 3
|
|
13
|
+
BASE_EXCEPTION = 4
|
|
14
|
+
PAYLOAD_NOT_DEFINED = 5
|
|
15
|
+
PAYLOAD_CHECKSUM_ERROR = 6
|
|
16
|
+
INPUT_CHECKSUM_ERROR = 7
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def execute_task(payload_data, input_data):
|
|
20
|
+
return Exec(payload_data, input_data,
|
|
21
|
+
{'___etny_result___': ___etny_result___})
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def Exec(payload_data, input_data, globals=None, locals=None):
|
|
25
|
+
try:
|
|
26
|
+
if payload_data is not None:
|
|
27
|
+
if input_data is not None:
|
|
28
|
+
globals['___etny_data_set___'] = input_data
|
|
29
|
+
exec(payload_data, globals, locals)
|
|
30
|
+
else:
|
|
31
|
+
exec(payload_data, globals, locals)
|
|
32
|
+
else:
|
|
33
|
+
return TaskStatus.PAYLOAD_NOT_DEFINED, 'Could not find the source file to execute'
|
|
34
|
+
|
|
35
|
+
return TaskStatus.SUCCESS, 'TASK EXECUTED SUCCESSFULLY'
|
|
36
|
+
except SystemError as e:
|
|
37
|
+
return TaskStatus.SYSTEM_ERROR, e.args[0]
|
|
38
|
+
except KeyError as e:
|
|
39
|
+
return TaskStatus.KEY_ERROR, e.args[0]
|
|
40
|
+
except SyntaxWarning as e:
|
|
41
|
+
return TaskStatus.SYNTAX_WARNING, e.args[0]
|
|
42
|
+
except BaseException as e:
|
|
43
|
+
try:
|
|
44
|
+
if e.args[0][0] == 0:
|
|
45
|
+
return TaskStatus.SUCCESS, e.args[0][1]
|
|
46
|
+
else:
|
|
47
|
+
return TaskStatus.BASE_EXCEPTION, e.args[0]
|
|
48
|
+
except Exception as e:
|
|
49
|
+
return TaskStatus.BASE_EXCEPTION, e.args[0]
|
|
50
|
+
|
|
51
|
+
# result = Exec('./v1/src/app/payload.py', './v1/src/app/input.txt',
|
|
52
|
+
# {'etny_print': etny_print})
|
|
53
|
+
# print('task result:', result)
|
|
54
|
+
|
|
55
|
+
# write the task result in a file
|
|
56
|
+
# generate task hash
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class metadataFormatV1:
|
|
5
|
+
|
|
6
|
+
def __init__(self, version, content_hash, yaml_hash, challenge_hash) -> None:
|
|
7
|
+
self.version = version
|
|
8
|
+
self.content_hash = content_hash
|
|
9
|
+
self.yaml_hash = yaml_hash
|
|
10
|
+
self.challenge_hash = challenge_hash
|
|
11
|
+
|
|
12
|
+
@classmethod
|
|
13
|
+
def from_string(cls, formatted_string) -> metadataFormatV1:
|
|
14
|
+
version, content_hash, yaml_hash, challenge_hash = formatted_string.split(':')
|
|
15
|
+
return metadataFormatV1(
|
|
16
|
+
version=version,
|
|
17
|
+
content_hash=content_hash,
|
|
18
|
+
yaml_hash=yaml_hash,
|
|
19
|
+
challenge_hash=challenge_hash,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
@classmethod
|
|
23
|
+
def to_string(cls, classObject=None) -> str:
|
|
24
|
+
return classObject
|
|
25
|
+
|
|
26
|
+
def __str__(self) -> str:
|
|
27
|
+
return f"{self.version}:{self.content_hash}:{self.yaml_hash}:{self.challenge_hash}"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
if __name__ == '__main__':
|
|
31
|
+
from_string = metadataFormatV1.from_string('v1:<dockerRegistryContentHash>:<containerConfigYamlHash>:<hash>')
|
|
32
|
+
print('-------from string')
|
|
33
|
+
print(f'''
|
|
34
|
+
version = {from_string.version},
|
|
35
|
+
content_hash = {from_string.content_hash},
|
|
36
|
+
yaml_hash = {from_string.yaml_hash},
|
|
37
|
+
challenge_hash = {from_string.challenge_hash},
|
|
38
|
+
''')
|
|
39
|
+
|
|
40
|
+
print('-------to string')
|
|
41
|
+
to_string = metadataFormatV1.to_string(from_string)
|
|
42
|
+
print(to_string)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"wallet","type":"address"}],"name":"AllowedWalletAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"wallet","type":"address"}],"name":"AllowedWalletRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"ipfsHash","type":"string"},{"indexed":false,"internalType":"string","name":"publicKey","type":"string"},{"indexed":false,"internalType":"string","name":"version","type":"string"}],"name":"ImageAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"ipfsHash","type":"string"}],"name":"ImagePublished","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"ipfsHash","type":"string"}],"name":"ImageRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"ipfsHash","type":"string"}],"name":"ImageValidated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"ipfsHash","type":"string"}],"name":"TrustedZoneImageAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"ipfsHash","type":"string"}],"name":"TrustedZoneImageRemoved","type":"event"},{"inputs":[{"internalType":"address","name":"wallet","type":"address"}],"name":"addAllowedWallet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"ipfsHash","type":"string"},{"internalType":"string","name":"certPublicKey","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"string","name":"imageName","type":"string"},{"internalType":"string","name":"dockerComposeHash","type":"string"},{"internalType":"string","name":"session","type":"string"},{"internalType":"uint8","name":"fee","type":"uint8"}],"name":"addImage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"ipfsHash","type":"string"},{"internalType":"string","name":"certPublicKey","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"string","name":"imageName","type":"string"},{"internalType":"string","name":"dockerComposeHash","type":"string"},{"internalType":"string","name":"session","type":"string"},{"internalType":"uint8","name":"fee","type":"uint8"}],"name":"addTrustedZoneImage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"ipfsHash","type":"string"},{"internalType":"address","name":"newRewardAddress","type":"address"}],"name":"changeImageRewardAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"changeOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"ipfsHash","type":"string"},{"internalType":"address","name":"newRewardAddress","type":"address"}],"name":"changeTrustedZoneImageRewardAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"ipfsHash","type":"string"}],"name":"publishImage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"wallet","type":"address"}],"name":"removeAllowedWallet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"ipfsHash","type":"string"}],"name":"validateImage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"allowedWallets","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"ipfsHash","type":"string"}],"name":"getImageCertPublicKey","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"ipfsHash","type":"string"}],"name":"getImageSession","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"imageName","type":"string"},{"internalType":"string","name":"version","type":"string"}],"name":"getLatestImageVersionPublicKey","outputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"imageName","type":"string"},{"internalType":"string","name":"version","type":"string"}],"name":"getLatestTrustedZoneImageCertPublicKey","outputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"ipfsHash","type":"string"}],"name":"getRewardAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"ipfsHash","type":"string"}],"name":"getTrustedZoneImageCertPublicKey","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"ipfsHash","type":"string"}],"name":"getTrustedZoneImageSession","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"ipfsHash","type":"string"}],"name":"getTrustedZoneRewardAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"imageDetails","outputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"string","name":"ipfsHash","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"string","name":"session","type":"string"},{"internalType":"uint8","name":"fee","type":"uint8"},{"internalType":"address","name":"rewardAddress","type":"address"},{"internalType":"bool","name":"validated","type":"bool"},{"internalType":"bool","name":"published","type":"bool"},{"internalType":"string","name":"certPublicKey","type":"string"},{"internalType":"string","name":"dockerComposeHash","type":"string"},{"internalType":"string","name":"name","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"images","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"imageVersions","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"imageVersionsHash","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"trustedZoneImageDetails","outputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"string","name":"ipfsHash","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"string","name":"session","type":"string"},{"internalType":"uint8","name":"fee","type":"uint8"},{"internalType":"address","name":"rewardAddress","type":"address"},{"internalType":"bool","name":"validated","type":"bool"},{"internalType":"bool","name":"published","type":"bool"},{"internalType":"string","name":"certPublicKey","type":"string"},{"internalType":"string","name":"dockerComposeHash","type":"string"},{"internalType":"string","name":"name","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"trustedZoneImageVersions","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"trustedZoneVersionsHash","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import hashlib
|
|
2
|
+
from eth_account import Account
|
|
3
|
+
|
|
4
|
+
def get_wallet_address(first_string, second_string):
|
|
5
|
+
concat = (first_string + second_string).encode()
|
|
6
|
+
_hash1 = hashlib.sha256(concat).hexdigest()
|
|
7
|
+
_hash = hashlib.sha256(_hash1.encode()).hexdigest()
|
|
8
|
+
acct = Account.from_key(_hash)
|
|
9
|
+
return acct.address, _hash
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
if __name__ == '__main__':
|
|
13
|
+
first_string = 'test'
|
|
14
|
+
second_string = 'test'
|
|
15
|
+
(addr, private) = get_wallet_address(first_string, second_string)
|
|
16
|
+
print('account address = ', addr) # 0xf63106856F7007A30025f0fFD5A534EA880878C3
|
|
17
|
+
print('private = ', private)
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
class Order:
|
|
2
|
+
def __init__(self, req, order_id):
|
|
3
|
+
self.id = order_id
|
|
4
|
+
self.do_owner = req[0]
|
|
5
|
+
self.dproc = req[1]
|
|
6
|
+
self.do_req = req[2]
|
|
7
|
+
self.dp_req = req[3]
|
|
8
|
+
self.status = req[4]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class MetadataBase:
|
|
12
|
+
def __init__(self, metadata, version):
|
|
13
|
+
self.metadata = metadata
|
|
14
|
+
self._version = version
|
|
15
|
+
|
|
16
|
+
@property
|
|
17
|
+
def version(self):
|
|
18
|
+
return self._version
|
|
19
|
+
|
|
20
|
+
@property
|
|
21
|
+
def ipfs_hash(self):
|
|
22
|
+
raise NotImplementedError("Subclass must implement this method")
|
|
23
|
+
|
|
24
|
+
def checksum(self):
|
|
25
|
+
raise NotImplementedError("Subclass must implement this method")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class PayloadFactory:
|
|
29
|
+
@staticmethod
|
|
30
|
+
def create_payload_metadata(metadata):
|
|
31
|
+
if ':' in metadata:
|
|
32
|
+
if metadata.startswith('v3'):
|
|
33
|
+
return PayloadMetadatav3(metadata)
|
|
34
|
+
else:
|
|
35
|
+
raise ValueError("Invalid payload metadata type")
|
|
36
|
+
else:
|
|
37
|
+
return PayloadMetadataV0(metadata)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class InputFactory:
|
|
41
|
+
@staticmethod
|
|
42
|
+
def create_input_metadata(metadata):
|
|
43
|
+
if ':' in metadata:
|
|
44
|
+
if metadata.startswith('v3'):
|
|
45
|
+
return InputMetadatav3(metadata)
|
|
46
|
+
else:
|
|
47
|
+
raise ValueError("Invalid payload metadata type")
|
|
48
|
+
else:
|
|
49
|
+
return InputMetadataV0(metadata)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class InputMetadataV0(MetadataBase):
|
|
53
|
+
def __init__(self, metadata):
|
|
54
|
+
super().__init__(metadata, 'v0')
|
|
55
|
+
self._ipfs_hash = metadata
|
|
56
|
+
|
|
57
|
+
@property
|
|
58
|
+
def ipfs_hash(self):
|
|
59
|
+
return self._ipfs_hash
|
|
60
|
+
|
|
61
|
+
@property
|
|
62
|
+
def checksum(self):
|
|
63
|
+
return None
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class PayloadMetadataV0(MetadataBase):
|
|
67
|
+
def __init__(self, metadata):
|
|
68
|
+
super().__init__(metadata, 'v0')
|
|
69
|
+
self._ipfs_hash = metadata
|
|
70
|
+
|
|
71
|
+
@property
|
|
72
|
+
def ipfs_hash(self):
|
|
73
|
+
return self._ipfs_hash
|
|
74
|
+
|
|
75
|
+
@property
|
|
76
|
+
def checksum(self):
|
|
77
|
+
return None
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class PayloadMetadatav3(MetadataBase):
|
|
81
|
+
|
|
82
|
+
def __init__(self, metadata):
|
|
83
|
+
super().__init__(metadata, 'v3')
|
|
84
|
+
self._checksum = metadata.split(':')[2]
|
|
85
|
+
self._ipfs_hash = metadata.split(':')[1]
|
|
86
|
+
|
|
87
|
+
@property
|
|
88
|
+
def ipfs_hash(self):
|
|
89
|
+
return self._ipfs_hash
|
|
90
|
+
|
|
91
|
+
@property
|
|
92
|
+
def checksum(self):
|
|
93
|
+
return self._checksum
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class InputMetadatav3(MetadataBase):
|
|
97
|
+
|
|
98
|
+
def __init__(self, metadata):
|
|
99
|
+
super().__init__(metadata, 'v3')
|
|
100
|
+
self._checksum = metadata.split(':')[2]
|
|
101
|
+
self._ipfs_hash = metadata.split(':')[1]
|
|
102
|
+
|
|
103
|
+
@property
|
|
104
|
+
def ipfs_hash(self):
|
|
105
|
+
return self._ipfs_hash
|
|
106
|
+
|
|
107
|
+
@property
|
|
108
|
+
def checksum(self):
|
|
109
|
+
return self._checksum if self._checksum != '0' else self._checksum
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
class DOReqMetadata:
|
|
113
|
+
def __init__(self, req, do_req):
|
|
114
|
+
self._do_req_id = do_req
|
|
115
|
+
self._do_owner = req[0]
|
|
116
|
+
self._metadata1 = req[1]
|
|
117
|
+
self._metadata2 = req[2]
|
|
118
|
+
self._metadata3 = req[3]
|
|
119
|
+
self._metadata4 = req[4]
|
|
120
|
+
self._payload_metadata_obj = PayloadFactory.create_payload_metadata(self.payload_metadata)
|
|
121
|
+
self._input_metadata_obj = InputFactory.create_input_metadata(self.input_metadata)
|
|
122
|
+
|
|
123
|
+
@property
|
|
124
|
+
def do_req_id(self):
|
|
125
|
+
return self._do_req_id
|
|
126
|
+
|
|
127
|
+
@property
|
|
128
|
+
def do_owner(self):
|
|
129
|
+
return self._do_owner
|
|
130
|
+
|
|
131
|
+
@property
|
|
132
|
+
def image_metadata(self):
|
|
133
|
+
return self._metadata1
|
|
134
|
+
|
|
135
|
+
@property
|
|
136
|
+
def public_key(self):
|
|
137
|
+
return self.image_metadata.split(':')[5]
|
|
138
|
+
|
|
139
|
+
@property
|
|
140
|
+
def image_hash(self):
|
|
141
|
+
return self.image_metadata.split(':')[1]
|
|
142
|
+
|
|
143
|
+
@property
|
|
144
|
+
def payload_metadata(self):
|
|
145
|
+
return self._metadata2
|
|
146
|
+
|
|
147
|
+
@property
|
|
148
|
+
def payload_metadata_obj(self):
|
|
149
|
+
return self._payload_metadata_obj
|
|
150
|
+
|
|
151
|
+
@property
|
|
152
|
+
def input_metadata_obj(self):
|
|
153
|
+
return self._input_metadata_obj
|
|
154
|
+
|
|
155
|
+
@property
|
|
156
|
+
def input_metadata(self):
|
|
157
|
+
return self._metadata3
|
|
158
|
+
|
|
159
|
+
@property
|
|
160
|
+
def node_address(self):
|
|
161
|
+
return self._metadata4
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
# add_do_req(..., 'v3:image_:....:...:', 'v3:payload_hash:checksum', 'v3::0', 'node_address')
|
|
165
|
+
'''
|
|
166
|
+
input + payload
|
|
167
|
+
v0: 'ipfs_hash'
|
|
168
|
+
v3: 'v3:file_ipfs_hash:file_checksum'
|
|
169
|
+
|
|
170
|
+
image
|
|
171
|
+
v0: 'ipfs_hash:image_name'
|
|
172
|
+
v3: 'v3:image_ipfs_hash:image_name:docker_Compose_ipfs_hash:client_challenge_ipfs_hash:client_public_cert'
|
|
173
|
+
'''
|
|
174
|
+
if __name__ == '__main__':
|
|
175
|
+
obj = PayloadFactory.create_payload_metadata('v3:some_img_hash:fucker')
|
|
176
|
+
obj2 = PayloadFactory.create_payload_metadata('must not!')
|