@ethernity-cloud/sdk-js 1.6.1 → 1.7.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/README.md +44 -6
- package/cas/config.js +61 -3
- package/info.js +333 -324
- package/init.js +20 -4
- package/nodenithy/build/securelock/Dockerfile.tmpl +34 -32
- package/nodenithy/build/securelock/scripts/binary-fs-build.sh +7 -6
- package/nodenithy/build/securelock/src/securelock.js.tmpl +5 -2
- package/nodenithy/build.mjs +83 -71
- package/nodenithy/run/docker-compose-final.yml.tmpl +36 -31
- package/nodenithy/run/docker-compose.yml.tmpl +34 -45
- package/nodenithy/run/image_registry.js +396 -380
- package/nodenithy/run.js +42 -28
- package/package.json +5 -3
- package/publish.js +4 -2
- package/pynithy/build/securelock/Dockerfile.base.tpl +13 -0
- package/pynithy/build/securelock/Dockerfile.tpl +131 -0
- package/pynithy/build/securelock/scripts/binary-fs-build.sh +25 -34
- package/pynithy/build/securelock/scripts/pyfreeze.sh +32 -0
- package/pynithy/build/securelock/src/{pox.abi → abi/etnyImplementationV2.abi} +1489 -1489
- package/pynithy/build/securelock/src/abi/image_registry.abi +1 -0
- package/pynithy/build/securelock/src/ecld_state.py +906 -0
- package/pynithy/build/securelock/src/esr.abi +1 -0
- package/pynithy/build/securelock/src/esr_local.py +267 -0
- package/pynithy/build/securelock/src/esr_wallet.py +150 -0
- package/pynithy/build/securelock/src/etny_crypto.py +208 -167
- package/pynithy/build/securelock/src/etny_exec.py +385 -79
- package/pynithy/build/securelock/src/etny_exec_flask.py +535 -0
- package/pynithy/build/securelock/src/etny_exec_serv.py +353 -0
- package/pynithy/build/securelock/src/etny_session_exec.py +245 -0
- package/pynithy/build/securelock/src/get_sgx_report.so +0 -0
- package/pynithy/build/securelock/src/image_registry.abi +1 -1
- package/pynithy/build/securelock/src/key_generation.py +17 -17
- package/pynithy/build/securelock/src/local_api.py +189 -0
- package/pynithy/build/securelock/src/models.py +200 -176
- package/pynithy/build/securelock/src/securelock.py.tmpl +1037 -727
- package/pynithy/build/securelock/src/swift_stream_service.py +206 -186
- package/pynithy/build.mjs +142 -92
- package/pynithy/run/docker-compose-final.yml.tmpl +58 -51
- package/pynithy/run/docker-compose.yml.tmpl +62 -48
- package/pynithy/run/etny-securelock-test.yaml.tpl +4 -1
- package/pynithy/run/image_registry.js +396 -380
- package/pynithy/run.js +44 -28
- package/pynithy/src/serverless/Dockerfile.serverless +8 -0
- package/pynithy/src/serverless/requirements.txt +6 -0
- package/run.js +69 -28
- package/nodenithy/build/las/Dockerfile +0 -5
- package/pynithy/build/docker-compose.yml +0 -70
- package/pynithy/build/las/Dockerfile +0 -11
- package/pynithy/build/las/src/etny_entrypoint.sh +0 -6
- package/pynithy/build/las/src/las_entrypoint.sh +0 -26
- package/pynithy/build/scripts/binary-fs-build.sh +0 -28
- package/pynithy/build/securelock/Dockerfile.tmpl +0 -95
package/README.md
CHANGED
|
@@ -43,17 +43,52 @@ The sdk has been tested on the following operating systems:
|
|
|
43
43
|
provisioned by the ethernity-cas validator set exactly as on mainnet.
|
|
44
44
|
`ecld-publish` registers the securelock session on-chain in the
|
|
45
45
|
SessionRegistry (`0xcb1F389b...`, see `cas/config.js`), resolves a CAS
|
|
46
|
-
from the ValidatorRegistry (`
|
|
46
|
+
from the ValidatorRegistry (`0xa821b36F...`, or `ECLD_CAS_ADDR=host:port`)
|
|
47
47
|
for the compose and the certificate harvest, takes the trustedzone
|
|
48
|
-
session name from the ImageRegistry,
|
|
49
|
-
published image. `ecld-build` signs the securelock `--production`.
|
|
50
|
-
Harvesting the certificate needs SGX.
|
|
51
|
-
|
|
48
|
+
session name from the ImageRegistry (ECImageRegistryV2,
|
|
49
|
+
`0x99A84C62...`), and links the session to the published image. `ecld-build` signs the securelock `--production`.
|
|
50
|
+
Harvesting the certificate needs SGX.
|
|
51
|
+
- Testnet Unsafe - the unsafe network beside the testnet (see below).
|
|
52
52
|
- Mainnet - to be provided during the following updates
|
|
53
|
+
- LitVM:
|
|
54
|
+
- LiteForge - CAS-attested the same way, by LitVM's own ethernity-cas
|
|
55
|
+
validator set (SessionRegistry `0x8ad24b3F...`, ValidatorRegistry
|
|
56
|
+
`0x2E27677f...`).
|
|
57
|
+
- LiteForge Unsafe - the unsafe network beside LiteForge (see below).
|
|
53
58
|
- Polyhon:
|
|
54
59
|
- Amoy Testnet - to be provided during the following updates
|
|
55
60
|
- Mainnet - to be provided during the following updates
|
|
56
61
|
|
|
62
|
+
The remaining testnets (Amoy, IoTeX, Sepolia) have no ethernity-cas
|
|
63
|
+
deployment: their enclaves are debug-signed and sign their own certificates
|
|
64
|
+
from their measurement, and `ecld-publish` registers no CAS session for them.
|
|
65
|
+
|
|
66
|
+
### The testnets and their unsafe networks
|
|
67
|
+
`Bloxberg Testnet` and `LitVM LiteForge` run your securelock in an enclave
|
|
68
|
+
attested through that chain's ethernity-cas validator set, on nodes whose
|
|
69
|
+
platform the CAS can attest (DCAP). Each has an unsafe network beside it,
|
|
70
|
+
`Bloxberg Testnet Unsafe` (`Bloxberg_Testnet_Unsafe`) and `LitVM LiteForge
|
|
71
|
+
Unsafe` (`LitVM_LiteForge_Unsafe`): the same chain and contracts, for hardware
|
|
72
|
+
SGX platforms the CAS cannot attest (EPID-only, SGX1). No CAS and no LAS: the
|
|
73
|
+
enclaves are debug-signed and sign their own certificates from their
|
|
74
|
+
measurement, so a result proves which image ran but not that an enclave ran
|
|
75
|
+
it. You choose an unsafe network by name in `ecld-init`, and the runner runs an
|
|
76
|
+
`-unsafe` trustedzone on nothing else, so a dApp that runs without a CAS
|
|
77
|
+
always says so in the network it names. A dApp publishes one securelock per
|
|
78
|
+
network from two project directories with the same project name: the unsafe
|
|
79
|
+
one is registered as `<project>-unsafe` and runs on the
|
|
80
|
+
`etny-<nodenithy|pynithy>-testnet-unsafe`
|
|
81
|
+
(`ecld-<nodenithy|pynithy>-litvm-testnet-unsafe`) trustedzone. Both dApp types
|
|
82
|
+
build for both networks. Mainnet has no unsafe network.
|
|
83
|
+
|
|
84
|
+
### Pynithy dApps
|
|
85
|
+
The Pynithy securelock is built exactly as `ethernity-cloud-sdk-py` builds it
|
|
86
|
+
(`pynithy/build/securelock` is its copy): a SCONE 6.0.7 Python 3.14 enclave
|
|
87
|
+
your backend is frozen into. `src/serverless/requirements.txt` lists the
|
|
88
|
+
Python packages your backend imports, and `src/serverless/Dockerfile.serverless`
|
|
89
|
+
adds system packages to the securelock base image. `ECLD_MEMORY_TO_ALLOCATE`
|
|
90
|
+
sets the enclave heap (default `1024M`).
|
|
91
|
+
|
|
57
92
|
### Scripts
|
|
58
93
|
|
|
59
94
|
- **Initialize**: To initialize the project, run:
|
|
@@ -97,6 +132,7 @@ The sdk has been tested on the following operating systems:
|
|
|
97
132
|
npx ecld-run --file payload.js
|
|
98
133
|
npx ecld-run --input data.json 'processData(___etny_data_set___)'
|
|
99
134
|
npx ecld-run --json 'esrIncrement()'
|
|
135
|
+
npx ecld-run --unsafe 'hello("World")'
|
|
100
136
|
```
|
|
101
137
|
This is the network-side sibling of `ecld-test`: instead of executing locally
|
|
102
138
|
it drives the runner end to end — encrypt → IPFS → on-chain request → wait for
|
|
@@ -106,7 +142,9 @@ The sdk has been tested on the following operating systems:
|
|
|
106
142
|
`--network`/`--securelock`/`--trustedzone`; the signing key is `PRIVATE_KEY`
|
|
107
143
|
(or `ECLD_PRIVATE_KEY`) — a funded `0x` key that pays for the order. Resources
|
|
108
144
|
are tunable with `--task-price`/`--cpu`/`--memory`/`--storage`/`--bandwidth`/`--duration`/`--validators`.
|
|
109
|
-
Exit code 0 on a `SUCCESS` task result, 1 otherwise.
|
|
145
|
+
Exit code 0 on a `SUCCESS` task result, 1 otherwise. `--unsafe` runs the
|
|
146
|
+
network's unsafe variant; on an unsafe network the securelock and
|
|
147
|
+
trustedzone default to their `-unsafe` names.
|
|
110
148
|
|
|
111
149
|
- **Inspect (read-only)**: To read enclave and on-chain diagnostics — network,
|
|
112
150
|
trustedzone/securelock registration, and ESR state — without spending gas, run:
|
package/cas/config.js
CHANGED
|
@@ -14,23 +14,81 @@
|
|
|
14
14
|
// Kept in sync with etny-{pynithy,nodenithy}/v3/networks.yaml
|
|
15
15
|
// (cas_session_registry_address, validator_registry_address).
|
|
16
16
|
const VALIDATOR_REGISTRY = {
|
|
17
|
-
'etny-pynithy-testnet': '
|
|
18
|
-
'etny-nodenithy-testnet': '
|
|
17
|
+
'etny-pynithy-testnet': '0xa821b36F378F76c793c436F5f9c9CC36c684eBE5',
|
|
18
|
+
'etny-nodenithy-testnet': '0xa821b36F378F76c793c436F5f9c9CC36c684eBE5',
|
|
19
|
+
'ecld-pynithy-litvm-testnet': '0x2E27677fb67531eb09134fE331C27899f87ADe10',
|
|
20
|
+
'ecld-nodenithy-litvm-testnet': '0x2E27677fb67531eb09134fE331C27899f87ADe10',
|
|
19
21
|
};
|
|
20
22
|
|
|
21
23
|
const SESSION_REGISTRY = {
|
|
22
24
|
'etny-pynithy-testnet': '0xcb1F389bF4524d1D61EDcbC24eC1F1F9C3FF4Fa6',
|
|
23
25
|
'etny-nodenithy-testnet': '0xcb1F389bF4524d1D61EDcbC24eC1F1F9C3FF4Fa6',
|
|
26
|
+
'ecld-pynithy-litvm-testnet': '0x8ad24b3F406A41a0F8D3440021792EB203957F43',
|
|
27
|
+
'ecld-nodenithy-litvm-testnet': '0x8ad24b3F406A41a0F8D3440021792EB203957F43',
|
|
24
28
|
};
|
|
25
29
|
|
|
26
30
|
// The chain the registries above live on.
|
|
27
31
|
const CHAIN = {
|
|
28
32
|
'etny-pynithy-testnet': { rpcUrl: 'https://bloxberg.ethernity.cloud', chainId: 8995 },
|
|
29
33
|
'etny-nodenithy-testnet': { rpcUrl: 'https://bloxberg.ethernity.cloud', chainId: 8995 },
|
|
34
|
+
'ecld-pynithy-litvm-testnet': { rpcUrl: 'https://liteforge.rpc.caldera.xyz/infra-partner-http', chainId: 4441 },
|
|
35
|
+
'ecld-nodenithy-litvm-testnet': { rpcUrl: 'https://liteforge.rpc.caldera.xyz/infra-partner-http', chainId: 4441 },
|
|
30
36
|
};
|
|
31
37
|
|
|
32
38
|
// Whether the securelock takes its certificate from a CAS session: mainnet
|
|
33
39
|
// (Scontain CAS), or a testnet template with a SessionRegistry (ethernity-cas).
|
|
34
40
|
const casProvisioned = (templateName, isMainnet) => isMainnet || Boolean(SESSION_REGISTRY[templateName]);
|
|
35
41
|
|
|
36
|
-
|
|
42
|
+
// The mainnets, by BLOCKCHAIN_NETWORK. A template name does not tell: the Amoy
|
|
43
|
+
// templates (ecld-*-amoy) do not contain "testnet".
|
|
44
|
+
const MAINNETS = ['Bloxberg_Mainnet', 'Polygon_Mainnet'];
|
|
45
|
+
const isMainnetNetwork = (network) =>
|
|
46
|
+
MAINNETS.some((name) => name.toUpperCase() === String(network || '').toUpperCase());
|
|
47
|
+
|
|
48
|
+
// The -unsafe networks, by BLOCKCHAIN_NETWORK, each with the network it is the
|
|
49
|
+
// unsafe variant of: the same chain and contracts, for SGX platforms the CAS
|
|
50
|
+
// cannot attest (EPID-only, SGX1). No CAS and no LAS: the securelock is
|
|
51
|
+
// debug-signed and self-signs from MR_ENCLAVE, is registered as
|
|
52
|
+
// <project>-unsafe, and runs only against an -unsafe trustedzone. Mainnet has
|
|
53
|
+
// none. Kept in sync with the *_unsafe entries of
|
|
54
|
+
// etny-{pynithy,nodenithy}/v3/networks.yaml.
|
|
55
|
+
const UNSAFE_NETWORKS = {
|
|
56
|
+
Bloxberg_Testnet_Unsafe: 'Bloxberg_Testnet',
|
|
57
|
+
LitVM_LiteForge_Unsafe: 'LitVM_LiteForge',
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// Case-insensitive: ecld-init writes Bloxberg_Testnet_Unsafe, a --network
|
|
61
|
+
// flag may say BLOXBERG_TESTNET_UNSAFE.
|
|
62
|
+
const isUnsafeNetwork = (network) =>
|
|
63
|
+
Object.keys(UNSAFE_NETWORKS).some((name) => name.toUpperCase() === String(network || '').toUpperCase());
|
|
64
|
+
|
|
65
|
+
// The name an image is registered and run under on `network`: <name>-unsafe
|
|
66
|
+
// on an -unsafe network. A dApp's securelock is <project>-unsafe there, so its
|
|
67
|
+
// two variants never share an image name, and an -unsafe network's
|
|
68
|
+
// trustedzone is the -unsafe variant of its sibling's.
|
|
69
|
+
const nameOnNetwork = (name, network) =>
|
|
70
|
+
!name || !isUnsafeNetwork(network) || name.endsWith('-unsafe') ? name : `${name}-unsafe`;
|
|
71
|
+
|
|
72
|
+
// The network part of ENCLAVE_NAME_SECURELOCK: the second word of
|
|
73
|
+
// BLOCKCHAIN_NETWORK, with _unsafe on an -unsafe network so the two variants
|
|
74
|
+
// never share a session name.
|
|
75
|
+
const sessionTag = (network) =>
|
|
76
|
+
`${network.split('_')[1].toLowerCase()}${isUnsafeNetwork(network) ? '_unsafe' : ''}`;
|
|
77
|
+
|
|
78
|
+
// A compose template rendered for its network. A line tagged `# __CAS_ONLY__`
|
|
79
|
+
// serves CAS attestation and is kept where a CAS provisions the enclaves, one
|
|
80
|
+
// tagged `# __NO_CAS_ONLY__` where they self-sign, and one tagged
|
|
81
|
+
// `# __SAFE_ONLY__` (the LAS) on every network but an -unsafe one. Kept lines
|
|
82
|
+
// lose their tag.
|
|
83
|
+
const renderCompose = (content, cas, unsafe) => content
|
|
84
|
+
.split('\n')
|
|
85
|
+
.filter((line) => !(/# __CAS_ONLY__$/.test(line) && !cas))
|
|
86
|
+
.filter((line) => !(/# __NO_CAS_ONLY__$/.test(line) && cas))
|
|
87
|
+
.filter((line) => !(/# __SAFE_ONLY__$/.test(line) && unsafe))
|
|
88
|
+
.map((line) => line.replace(/\s*# __(?:CAS|NO_CAS|SAFE)_ONLY__$/, ''))
|
|
89
|
+
.join('\n');
|
|
90
|
+
|
|
91
|
+
module.exports = {
|
|
92
|
+
VALIDATOR_REGISTRY, SESSION_REGISTRY, CHAIN, casProvisioned, isMainnetNetwork,
|
|
93
|
+
UNSAFE_NETWORKS, isUnsafeNetwork, nameOnNetwork, sessionTag, renderCompose,
|
|
94
|
+
};
|