enigma-memory 0.1.17 → 0.1.22
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 +85 -27
- package/apps/cli/bin/enigma-desktop.mjs +140 -0
- package/apps/cli/bin/enigma-terminal.mjs +78 -0
- package/apps/cli/bin/enigma.mjs +4979 -3263
- package/apps/desktop/electron-main.cjs +217 -0
- package/apps/desktop/package.json +12 -0
- package/apps/desktop/src/app.js +264 -7
- package/apps/desktop/src/index.html +3514 -1373
- package/apps/desktop/src/launch-electron.mjs +51 -0
- package/apps/desktop/src/server.mjs +2914 -0
- package/apps/desktop/src/styles.css +2972 -260
- package/apps/desktop/src/zk-browser-prove.mjs +53 -0
- package/apps/desktop/src/zk-state.mjs +1789 -0
- package/apps/gateway/bin/enigma-gateway.mjs +102 -5
- package/apps/gateway/src/server.mjs +271 -8
- package/apps/ios/EnigmaCore/Package.swift +12 -0
- package/apps/ios/EnigmaCore/Sources/EnigmaCore/EnigmaAPIClient.swift +227 -0
- package/apps/ios/EnigmaCore/Sources/EnigmaCore/Models.swift +278 -0
- package/apps/ios/EnigmaCore/Sources/EnigmaCore/PKCE.swift +96 -0
- package/apps/ios/EnigmaCore/Sources/EnigmaCore/PrivacyMinimizer.swift +187 -0
- package/apps/ios/EnigmaCore/Sources/EnigmaCore/ToolModels.swift +129 -0
- package/apps/ios/EnigmaCore/Tests/EnigmaCoreTests/EnigmaCoreTests.swift +42 -0
- package/apps/ios/EnigmaIOS/Enigma/AppModel.swift +346 -0
- package/apps/ios/EnigmaIOS/Enigma/Assets.xcassets/AccentColor.colorset/Contents.json +12 -0
- package/apps/ios/EnigmaIOS/Enigma/Assets.xcassets/AppIcon.appiconset/Contents.json +11 -0
- package/apps/ios/EnigmaIOS/Enigma/Assets.xcassets/AppIcon.appiconset/EnigmaAppIcon.png +0 -0
- package/apps/ios/EnigmaIOS/Enigma/Assets.xcassets/Contents.json +3 -0
- package/apps/ios/EnigmaIOS/Enigma/Assets.xcassets/LaunchBackground.colorset/Contents.json +12 -0
- package/apps/ios/EnigmaIOS/Enigma/ChatView.swift +181 -0
- package/apps/ios/EnigmaIOS/Enigma/CouncilView.swift +78 -0
- package/apps/ios/EnigmaIOS/Enigma/CreateView.swift +152 -0
- package/apps/ios/EnigmaIOS/Enigma/EnigmaApp.swift +52 -0
- package/apps/ios/EnigmaIOS/Enigma/Info.plist +52 -0
- package/apps/ios/EnigmaIOS/Enigma/NaturalLanguagePrivacyTagger.swift +26 -0
- package/apps/ios/EnigmaIOS/Enigma/OAuthClient.swift +321 -0
- package/apps/ios/EnigmaIOS/Enigma/OnboardingView.swift +105 -0
- package/apps/ios/EnigmaIOS/Enigma/PrivateVaultView.swift +275 -0
- package/apps/ios/EnigmaIOS/Enigma/SecureStore.swift +76 -0
- package/apps/ios/EnigmaIOS/Enigma/SettingsView.swift +60 -0
- package/apps/ios/EnigmaIOS/Enigma/Theme.swift +80 -0
- package/apps/ios/EnigmaIOS/EnigmaIOS.xcodeproj/project.pbxproj +211 -0
- package/apps/ios/EnigmaIOS/EnigmaIOS.xcodeproj/xcshareddata/xcschemes/Enigma.xcscheme +23 -0
- package/apps/native-host/README.md +19 -8
- package/apps/native-host/bin/enigma-native-host.mjs +229 -13
- package/apps/relay/bin/enigma-relay.mjs +103 -5
- package/apps/relay/src/federation-runtime.mjs +618 -0
- package/apps/relay/src/server.mjs +310 -9
- package/apps/verifier/bin/enigma-verify.mjs +327 -11
- package/cortex-v3/circuits/build/intent_vk_bytes.json +35 -0
- package/cortex-v3/circuits/build/sale_vk_bytes.json +35 -0
- package/cortex-v3/circuits/build/vk_bytes.json +32 -0
- package/cortex-v3/proving-assets.json +64 -0
- package/cortex-v3/zk/BUILD-CONTRACT.md +87 -0
- package/cortex-v3/zk/action-transition-vk.json +119 -0
- package/cortex-v3/zk/alias-adversarial.test.mjs +220 -0
- package/cortex-v3/zk/groth16-verify-child.mjs +17 -0
- package/cortex-v3/zk/intent-witness.mjs +365 -0
- package/cortex-v3/zk/intent-witness.test.mjs +485 -0
- package/cortex-v3/zk/proving-assets.mjs +203 -0
- package/cortex-v3/zk/sale-witness.mjs +783 -0
- package/cortex-v3/zk/sale-witness.test.mjs +784 -0
- package/cortex-v3/zk/sealed-sale-release-vk.json +119 -0
- package/cortex-v3/zk/settlement-evidence.mjs +722 -0
- package/cortex-v3/zk/setup-intent.mjs +688 -0
- package/cortex-v3/zk/setup-sale.mjs +666 -0
- package/cortex-v3/zk/setup.mjs +594 -0
- package/cortex-v3/zk/witness.mjs +184 -0
- package/cortex-v3/zk/zk-codec.mjs +232 -0
- package/cortex-v3/zk/zk-codec.test.mjs +293 -0
- package/cortex-v3/zk/zk-settle.mjs +370 -0
- package/cortex-v3/zk/zk-tree.mjs +256 -0
- package/cortex-v3/zk/zk-tree.test.mjs +419 -0
- package/deploy/SIMULATION.md +14 -9
- package/deploy/docker-compose.local-production-simulation.yml +54 -12
- package/docs/benchmark-attestation-network.md +487 -487
- package/docs/benchmark-reproducibility.md +289 -289
- package/docs/blockchain-only-mechanisms.md +400 -400
- package/docs/browser-extension-install.md +8 -6
- package/docs/client-connectors.md +16 -12
- package/docs/demo-proof-network.md +275 -275
- package/docs/developer-ecosystem.md +15 -13
- package/docs/developer-proof-quickstart.md +325 -325
- package/docs/enigma-memory-ready-conformance.md +378 -376
- package/docs/install-anywhere.md +64 -30
- package/docs/installers-and-desktop.md +8 -7
- package/docs/memory-benchmarks.md +1 -1
- package/docs/memory-drive-health-model.md +690 -690
- package/docs/novelty-invention-candidates.md +161 -161
- package/docs/proof-network-build-notes.md +240 -240
- package/docs/proof-network-claim-boundaries.md +320 -318
- package/docs/proof-network.md +339 -339
- package/docs/sdk-api.md +324 -324
- package/docs/solana-proof-rail.md +453 -453
- package/examples/01-quickstart-agent/index.mjs +49 -0
- package/examples/01_agent_memory_quickstart.mjs +57 -0
- package/examples/02-multi-agent-swarm/index.mjs +57 -0
- package/examples/02_cross_model_passport.mjs +64 -0
- package/examples/03-langchain-memory/index.mjs +41 -0
- package/examples/03_poseidon_commitment_verification.mjs +71 -0
- package/examples/04-python-trading-agent/trader.py +49 -0
- package/examples/README.md +27 -0
- package/examples/ci/github-actions.yml +7 -2
- package/package.json +410 -278
- package/packages/adapters/PACKAGE_CONTRACT.md +1 -1
- package/packages/connectors/src/index.js +196 -4
- package/packages/connectors/swarm-router.mjs +168 -0
- package/packages/core/src/index.js +249 -2
- package/packages/core/src/version.mjs +7 -0
- package/packages/dev-tools/package.json +19 -0
- package/packages/dev-tools/src/index.js +4 -0
- package/packages/dev-tools/src/memory-benchmark-suite.js +112 -0
- package/packages/dev-tools/src/swarm-simulator.js +101 -0
- package/packages/dev-tools/src/vault-inspector.js +114 -0
- package/packages/dev-tools/src/vector-benchmark.js +100 -0
- package/packages/developer-platform/src/access-credentials.js +341 -0
- package/packages/developer-platform/src/http.js +132 -0
- package/packages/developer-platform/src/index.js +4 -0
- package/packages/developer-platform/src/usage-http.js +60 -0
- package/packages/developer-platform/src/usage.js +295 -0
- package/packages/enclave-runtime/attestation.mjs +159 -0
- package/packages/enclave-runtime/index.mjs +47 -0
- package/packages/enclave-runtime/session-manager.mjs +253 -0
- package/packages/enclave-runtime/zeroization-proof.mjs +227 -0
- package/packages/enigma-reflex/package.json +14 -0
- package/packages/enigma-reflex/src/index.js +204 -0
- package/packages/enigma-reflex/training/generate-dataset.mjs +40 -0
- package/packages/enigma-reflex/training/requirements.txt +8 -0
- package/packages/enigma-reflex/training/train.py +314 -0
- package/packages/enigma-weave/LICENSE +22 -0
- package/packages/enigma-weave/UPSTREAM.json +21 -0
- package/packages/enigma-weave/package.json +14 -0
- package/packages/enigma-weave/src/index.js +286 -0
- package/packages/hosted-cloud/src/index.js +80 -5
- package/packages/importers/src/index.js +432 -0
- package/packages/inference-runtime/src/browser.js +401 -0
- package/packages/inference-runtime/src/chat.js +265 -0
- package/packages/inference-runtime/src/code.js +407 -0
- package/packages/inference-runtime/src/contracts.js +162 -0
- package/packages/inference-runtime/src/http.js +232 -0
- package/packages/inference-runtime/src/image.js +186 -0
- package/packages/inference-runtime/src/index.js +10 -0
- package/packages/inference-runtime/src/model-router.js +320 -0
- package/packages/inference-runtime/src/platform.js +125 -0
- package/packages/inference-runtime/src/privacy.js +400 -0
- package/packages/inference-runtime/src/video.js +253 -0
- package/packages/mcp-server/README.md +22 -6
- package/packages/mcp-server/bin/enigma-mcp.mjs +2 -1
- package/packages/mcp-server/src/index.js +2498 -1185
- package/packages/mcp-server/src/oauth.js +561 -0
- package/packages/mcp-server/src/private-handoff.js +84 -0
- package/packages/mcp-server/src/remote-http.js +273 -0
- package/packages/mcp-server/src/remote-policy.js +72 -0
- package/packages/mcp-server/swarm-bridge.mjs +361 -0
- package/packages/mesh/index.d.ts +283 -0
- package/packages/mesh/package.json +23 -0
- package/packages/mesh/src/crypto.js +189 -0
- package/packages/mesh/src/federation-packets.js +353 -0
- package/packages/mesh/src/gossip.js +311 -0
- package/packages/mesh/src/index.js +6 -0
- package/packages/mesh/src/protocol.js +255 -0
- package/packages/mesh/src/router.js +279 -0
- package/packages/mesh/src/transport.js +306 -0
- package/packages/passport/src/index.js +436 -7
- package/packages/private-economy/src/credits-http.js +100 -0
- package/packages/private-economy/src/credits.js +447 -0
- package/packages/private-economy/src/index.js +5 -0
- package/packages/private-economy/src/payments-http.js +120 -0
- package/packages/private-economy/src/payments.js +509 -0
- package/packages/private-economy/src/x402.js +346 -0
- package/packages/proof-network/PACKAGE_CONTRACT.md +21 -0
- package/packages/rag/index.d.ts +182 -0
- package/packages/rag/models/Xenova/all-MiniLM-L6-v2/THIRD_PARTY_LICENSES.txt +207 -0
- package/packages/rag/models/Xenova/all-MiniLM-L6-v2/config.json +25 -0
- package/packages/rag/models/Xenova/all-MiniLM-L6-v2/onnx/model_quantized.onnx +0 -0
- package/packages/rag/models/Xenova/all-MiniLM-L6-v2/sha256-manifest.json +28 -0
- package/packages/rag/models/Xenova/all-MiniLM-L6-v2/tokenizer.json +30686 -0
- package/packages/rag/models/Xenova/all-MiniLM-L6-v2/tokenizer_config.json +15 -0
- package/packages/rag/package.json +27 -0
- package/packages/rag/src/blinded-search.js +109 -0
- package/packages/rag/src/bm25.js +169 -0
- package/packages/rag/src/embeddings.js +459 -0
- package/packages/rag/src/hybrid.js +76 -0
- package/packages/rag/src/index.js +38 -0
- package/packages/rag/src/reranker.js +61 -0
- package/packages/rag/src/research.js +107 -0
- package/packages/rag/src/vector-store.js +430 -0
- package/packages/rag/src/verify-model-artifacts.mjs +4 -0
- package/packages/sdk/index.d.ts +760 -0
- package/packages/sdk/package.json +33 -0
- package/packages/sdk/python/README.md +24 -0
- package/packages/sdk/python/enigma_sdk.py +250 -0
- package/packages/sdk/python/pyproject.toml +34 -0
- package/packages/sdk/python/requirements.txt +1 -0
- package/packages/sdk/python/setup.py +20 -0
- package/packages/sdk/src/federation/capability-grant.js +389 -0
- package/packages/sdk/src/federation/federation-router.js +360 -0
- package/packages/sdk/src/federation/ghostmesh-bridge.js +497 -0
- package/packages/sdk/src/federation/index.js +3 -0
- package/packages/sdk/src/index.js +1796 -0
- package/packages/sdk/src/intelligence/contradiction.js +337 -0
- package/packages/sdk/src/intelligence/decision-engine.js +155 -0
- package/packages/sdk/src/intelligence/index.js +4 -0
- package/packages/sdk/src/intelligence/ontology.js +122 -0
- package/packages/sdk/src/intelligence/temporal.js +123 -0
- package/packages/sdk/src/market-client.js +142 -0
- package/packages/sdk/src/mesh-client.js +110 -0
- package/packages/sdk/src/middleware/index.js +3 -0
- package/packages/sdk/src/middleware/langchain.js +159 -0
- package/packages/sdk/src/middleware/llamaindex.js +101 -0
- package/packages/sdk/src/middleware/vercel-ai.js +112 -0
- package/packages/sdk/src/rag-client.js +85 -0
- package/packages/sdk/src/swarm-orchestrator.js +260 -0
- package/packages/settlement/PACKAGE_CONTRACT.md +1 -1
- package/packages/snapcompact/THIRD_PARTY_LICENSES.txt +40 -0
- package/packages/snapcompact/assets/8x13-latin1.bdf +3837 -0
- package/packages/snapcompact/index.d.ts +284 -0
- package/packages/snapcompact/package.json +25 -0
- package/packages/snapcompact/src/index.js +716 -0
- package/packages/storage/PACKAGE_CONTRACT.md +1 -1
- package/packages/terminal-console/animations.mjs +240 -0
- package/packages/terminal-console/auto-anchor.mjs +220 -0
- package/packages/terminal-console/banner.mjs +91 -0
- package/packages/terminal-console/commands.mjs +459 -0
- package/packages/terminal-console/delegation.mjs +152 -0
- package/packages/terminal-console/index.mjs +5 -0
- package/packages/terminal-console/outbox.mjs +143 -0
- package/packages/terminal-console/phantom-bridge.mjs +637 -0
- package/packages/terminal-console/repl.mjs +136 -0
- package/packages/terminal-console/signer-store.mjs +130 -0
- package/packages/terminal-console/solana-rpc.mjs +214 -0
- package/packages/terminal-console/solana-transport.mjs +189 -0
- package/packages/terminal-tui/dashboard.mjs +214 -0
- package/packages/terminal-tui/index.mjs +28 -0
- package/packages/terminal-tui/merkle-tree-renderer.mjs +268 -0
- package/packages/terminal-tui/telemetry-hud.mjs +137 -0
- package/packages/vault/index.d.ts +449 -0
- package/packages/vault/package.json +27 -0
- package/packages/vault/src/e2ee.mjs +393 -0
- package/packages/vault/src/enclave.js +481 -0
- package/packages/vault/src/erasure.js +207 -0
- package/packages/vault/src/index.js +1150 -125
- package/packages/vault/src/persistence.js +307 -0
- package/packages/vault/src/poseidon.js +354 -0
- package/packages/vault/src/receipt.js +459 -0
- package/scripts/benchmark-optical-context.mjs +166 -0
- package/scripts/bootstrap-enigma.mjs +502 -0
- package/scripts/build-edge-backend-workers.mjs +20 -5
- package/scripts/build-goal-completion-audit.mjs +72 -25
- package/scripts/build-hosted-api-key-lifecycle.mjs +292 -274
- package/scripts/build-hosted-customer-lifecycle.mjs +493 -476
- package/scripts/build-hosted-probe-worker.mjs +19 -4
- package/scripts/build-installer-assets.mjs +409 -389
- package/scripts/build-operator-evidence-starter.mjs +59 -1
- package/scripts/build-production-backend-env-kit.mjs +2 -0
- package/scripts/build-production-unblocker.mjs +4 -1
- package/scripts/build-proof-network-packet.mjs +213 -213
- package/scripts/check.mjs +25 -4
- package/scripts/collect-hosted-backend-live-evidence.mjs +49 -12
- package/scripts/install-enigma-local.mjs +18 -5
- package/scripts/release-audit.mjs +74 -115
- package/scripts/release-provenance.mjs +12 -2
- package/scripts/run-backend-readiness-smoke.mjs +112 -10
- package/scripts/run-standard-memory-benchmarks.mjs +1354 -1352
- package/scripts/scan-secrets.mjs +178 -0
- package/scripts/simulate-production-env.mjs +71 -10
- package/scripts/validate-hosted-backend-live.mjs +112 -1
- package/specs/antibody-pack-v1.schema.json +95 -0
- package/specs/antigen-envelope-v1.schema.json +81 -0
- package/specs/boundary-manifest-v1.schema.json +35 -35
- package/specs/capsule-v1.schema.json +55 -55
- package/specs/claim-boundary-manifest-v1.schema.json +22 -22
- package/specs/claim-ledger-v1.schema.json +291 -0
- package/specs/context-passport-v1.schema.json +59 -0
- package/specs/deletion-tombstone-v1.schema.json +26 -26
- package/specs/evidence-packet-v1.schema.json +177 -0
- package/specs/hosted-backend-live-evidence-v1.schema.json +72 -3
- package/specs/immune-scan-report-v1.schema.json +112 -0
- package/specs/lifecycle-receipt-log-v1.schema.json +67 -0
- package/specs/memory-atom-v1.schema.json +59 -0
- package/specs/memory-event-v1.schema.json +42 -42
- package/specs/passport-v1.schema.json +50 -50
- package/specs/proof-of-non-use-v1.schema.json +65 -0
- package/specs/quarantine-record-v1.schema.json +126 -0
- package/specs/receipt-v1.schema.json +61 -61
- package/specs/state-checkpoint-v1.schema.json +37 -37
- package/specs/trust-bundle-v1.schema.json +56 -56
- package/specs/trust-card-v1.schema.json +119 -0
- package/docs/proof-network-launch-plan.md +0 -421
- package/packages/metering/PACKAGE_CONTRACT.md +0 -20
- package/scripts/build-ai-orchestration-plan.mjs +0 -248
|
@@ -4,7 +4,13 @@ import { join, resolve } from 'node:path';
|
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
import { buildOperatorAcceptancePacket } from './build-operator-acceptance-packet.mjs';
|
|
6
6
|
import { buildProductionReadinessManifest } from './build-production-readiness-manifest.mjs';
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
HOSTED_BACKEND_AUTHENTICATED_DATA_PLANE_SCHEMA,
|
|
9
|
+
HOSTED_BACKEND_LIVE_EVIDENCE_SCHEMA,
|
|
10
|
+
HOSTED_BACKEND_RUNTIME_CAPABILITY_SCHEMA,
|
|
11
|
+
PRIVATE_DATA_PLANE_RUNTIME_MARKER,
|
|
12
|
+
REQUIRED_REF_KEYS,
|
|
13
|
+
} from './validate-hosted-backend-live.mjs';
|
|
8
14
|
import { REQUIRED_EVIDENCE_ITEMS, REQUIRED_OWNER_ROLES, REQUIRED_PACKET_METADATA } from './validate-operator-acceptance.mjs';
|
|
9
15
|
import { groupHostedRefsByWorkstream } from './hosted-ref-workstreams.mjs';
|
|
10
16
|
|
|
@@ -97,6 +103,7 @@ function buildHostedBackendLiveEvidenceTemplate({ domain }) {
|
|
|
97
103
|
region: '<public-region-code>',
|
|
98
104
|
owner: '<operator-team-or-role>',
|
|
99
105
|
status: 'observed',
|
|
106
|
+
local_simulation: false,
|
|
100
107
|
},
|
|
101
108
|
refs: Object.fromEntries(HOSTED_REF_KEYS.map((key) => [key, `<operator-provided-${key}-evidence-ref>`])),
|
|
102
109
|
probes: {
|
|
@@ -105,6 +112,57 @@ function buildHostedBackendLiveEvidenceTemplate({ domain }) {
|
|
|
105
112
|
gateway_livez: hostedProbeTemplate('gateway', 'livez', domain),
|
|
106
113
|
gateway_readyz: hostedProbeTemplate('gateway', 'readyz', domain),
|
|
107
114
|
},
|
|
115
|
+
runtime_capability: {
|
|
116
|
+
schema: HOSTED_BACKEND_RUNTIME_CAPABILITY_SCHEMA,
|
|
117
|
+
marker: PRIVATE_DATA_PLANE_RUNTIME_MARKER,
|
|
118
|
+
observed_at: '<runtime-capability-observed-at-iso8601>',
|
|
119
|
+
services: {
|
|
120
|
+
relay: {
|
|
121
|
+
service: 'enigma-relay',
|
|
122
|
+
private_data_plane_operational: true,
|
|
123
|
+
authentication_enforced: true,
|
|
124
|
+
bootstrap_worker: false,
|
|
125
|
+
evidence_ref: '<operator-provided-relay-runtime-capability-ref>',
|
|
126
|
+
},
|
|
127
|
+
gateway: {
|
|
128
|
+
service: 'enigma-gateway',
|
|
129
|
+
private_data_plane_operational: true,
|
|
130
|
+
authentication_enforced: true,
|
|
131
|
+
bootstrap_worker: false,
|
|
132
|
+
evidence_ref: '<operator-provided-gateway-runtime-capability-ref>',
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
authenticated_data_plane: {
|
|
137
|
+
schema: HOSTED_BACKEND_AUTHENTICATED_DATA_PLANE_SCHEMA,
|
|
138
|
+
observed_at: '<authenticated-data-plane-observed-at-iso8601>',
|
|
139
|
+
proofs: {
|
|
140
|
+
relay: {
|
|
141
|
+
service: 'enigma-relay',
|
|
142
|
+
url: `https://relay.${domain}/pairing/complete`,
|
|
143
|
+
method: 'POST',
|
|
144
|
+
status_code: 200,
|
|
145
|
+
authenticated: true,
|
|
146
|
+
authorization_result: 'allowed',
|
|
147
|
+
observed_at: '<relay-data-plane-observed-at-iso8601>',
|
|
148
|
+
request_hash: 'sha256:<operator-provided-relay-request-sha256-hex>',
|
|
149
|
+
response_hash: 'sha256:<operator-provided-relay-response-sha256-hex>',
|
|
150
|
+
evidence_ref: '<operator-provided-relay-authenticated-data-plane-ref>',
|
|
151
|
+
},
|
|
152
|
+
gateway: {
|
|
153
|
+
service: 'enigma-gateway',
|
|
154
|
+
url: `https://gateway.${domain}/gateway/decision`,
|
|
155
|
+
method: 'POST',
|
|
156
|
+
status_code: 200,
|
|
157
|
+
authenticated: true,
|
|
158
|
+
authorization_result: 'allowed',
|
|
159
|
+
observed_at: '<gateway-data-plane-observed-at-iso8601>',
|
|
160
|
+
request_hash: 'sha256:<operator-provided-gateway-request-sha256-hex>',
|
|
161
|
+
response_hash: 'sha256:<operator-provided-gateway-response-sha256-hex>',
|
|
162
|
+
evidence_ref: '<operator-provided-gateway-authenticated-data-plane-ref>',
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
},
|
|
108
166
|
operator_acceptance: {
|
|
109
167
|
decision: 'go',
|
|
110
168
|
packet_ref: '<operator-acceptance-packet-ref>',
|
|
@@ -194,6 +194,7 @@ function serviceEnv({ service, domain, tenant, environment }) {
|
|
|
194
194
|
['ENIGMA_INCIDENT_DRILL_REF', placeholderFor('ENIGMA_INCIDENT_DRILL_REF')],
|
|
195
195
|
['ENIGMA_BACKUP_RESTORE_DRILL_REF', placeholderFor('ENIGMA_BACKUP_RESTORE_DRILL_REF')],
|
|
196
196
|
['ENIGMA_OPERATOR_ACCEPTANCE_DECISION', '<operator-required-go-decision>'],
|
|
197
|
+
['ENIGMA_BACKUP_TARGET_REF', placeholderFor('ENIGMA_BACKUP_TARGET_REF')],
|
|
197
198
|
['ENIGMA_BACKUP_TARGET_URI_FILE', '/run/secrets/backup_target_uri'],
|
|
198
199
|
['ENIGMA_KMS_KEY_REF_FILE', '/run/secrets/kms_key_ref'],
|
|
199
200
|
['ENIGMA_OPERATOR_ACCEPTANCE_EVIDENCE_URI_FILE', '/run/secrets/operator_acceptance_evidence_uri'],
|
|
@@ -211,6 +212,7 @@ function serviceEnv({ service, domain, tenant, environment }) {
|
|
|
211
212
|
['ENIGMA_RELAY_DNS_TLS_REF', placeholderFor('ENIGMA_RELAY_DNS_TLS_REF')],
|
|
212
213
|
['ENIGMA_RELAY_RUNTIME_AUTH_REF', placeholderFor('ENIGMA_RELAY_RUNTIME_AUTH_REF')],
|
|
213
214
|
['ENIGMA_RELAY_MONITORING_REF', placeholderFor('ENIGMA_RELAY_MONITORING_REF')],
|
|
215
|
+
['ENIGMA_RELAY_STORAGE_REF', placeholderFor('ENIGMA_RELAY_STORAGE_REF')],
|
|
214
216
|
['ENIGMA_RELAY_SIGNING_KEY_FILE', '/run/secrets/relay_signing_key'],
|
|
215
217
|
['ENIGMA_EXTERNAL_STORAGE_DSN_FILE', '/run/secrets/external_storage_dsn'],
|
|
216
218
|
...common,
|
|
@@ -4,7 +4,10 @@ import { dirname, resolve } from 'node:path';
|
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
|
|
6
6
|
export const PRODUCTION_UNBLOCKER_SCHEMA = 'enigma.production_unblocker.v1';
|
|
7
|
-
|
|
7
|
+
// Last VERIFIED live registry version (`npm view enigma-memory version`), distinct
|
|
8
|
+
// from the source release candidate (ENIGMA_VERSION). Bump ONLY after a publish is
|
|
9
|
+
// confirmed live on the registry — never to the candidate version in advance.
|
|
10
|
+
export const CURRENT_PUBLIC_PACKAGE_VERSION = '0.1.18';
|
|
8
11
|
|
|
9
12
|
const STATUS_VALUES = Object.freeze([
|
|
10
13
|
'ready_now',
|
|
@@ -1,213 +1,213 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { createHash } from 'node:crypto';
|
|
3
|
-
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
4
|
-
import { dirname, isAbsolute, resolve } from 'node:path';
|
|
5
|
-
import { fileURLToPath } from 'node:url';
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
assertNoPrivateProofPayload,
|
|
9
|
-
createBenchmarkAttestation,
|
|
10
|
-
createProofNetworkAnchorBatch,
|
|
11
|
-
createProofNetworkPacket,
|
|
12
|
-
sha256Json,
|
|
13
|
-
validateBenchmarkAttestation,
|
|
14
|
-
validateProofNetworkAnchorBatch,
|
|
15
|
-
validateProofNetworkPacket,
|
|
16
|
-
} from '../packages/proof-network/src/index.js';
|
|
17
|
-
|
|
18
|
-
export const PROOF_NETWORK_PACKET_RELEASE_TARGET = '0.1.17';
|
|
19
|
-
|
|
20
|
-
const HASH_RE = /^(?:sha256:)?[a-f0-9]{64}$/iu;
|
|
21
|
-
const SECRET_VALUE_RE = /(?:Bearer\s+[A-Za-z0-9._~+/=-]{12,}|Basic\s+[A-Za-z0-9+/=-]{12,}|-----BEGIN [A-Z ]*PRIVATE KEY-----|https?:\/\/[^\s/@]+:[^\s/@]+@|sk-[A-Za-z0-9_-]{16,}|AKIA[0-9A-Z]{16}|\b(?:raw[\s_-]*memory|plaintext[\s_-]*prompts?|plain[\s_-]*text[\s_-]*prompts?|private[\s_-]*prompts?|provider[\s_-]*responses?|full[\s_-]*transcript|decrypted[\s_-]*memory|credentials?|secrets?|passwords?|private[\s_-]*keys?|api[\s_-]*key[\s_-]*(?:secret|material|value)|api[\s_-]*secrets?|access[\s_-]*tokens?|refresh[\s_-]*tokens?|token[\s_-]*values?|credential[\s_-]*material|tenant[\s_-]*names?)\b)/iu;
|
|
22
|
-
const ABSOLUTE_LOCAL_PATH_RE = /^(?:[A-Za-z]:[\\/]|\\\\|\/(?:Users|home|tmp|var|etc|mnt|Volumes)\b)/u;
|
|
23
|
-
|
|
24
|
-
class UsageError extends Error {
|
|
25
|
-
constructor(message) {
|
|
26
|
-
super(message);
|
|
27
|
-
this.name = 'UsageError';
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function readRequiredValue(argv, index, flag) {
|
|
32
|
-
const value = argv[index + 1];
|
|
33
|
-
if (value === undefined || value.startsWith('--')) throw new UsageError(`${flag} requires a value`);
|
|
34
|
-
return value;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function assertPublicSafeString(value, label) {
|
|
38
|
-
if (typeof value !== 'string' || value.trim() === '') throw new UsageError(`${label} must be a non-empty public ref or hash`);
|
|
39
|
-
const normalized = value.trim();
|
|
40
|
-
if (SECRET_VALUE_RE.test(normalized)) throw new UsageError(`${label} contains private or secret material`);
|
|
41
|
-
return normalized;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function assertPublicHash(value, label) {
|
|
45
|
-
const normalized = assertPublicSafeString(value, label);
|
|
46
|
-
if (!HASH_RE.test(normalized)) throw new UsageError(`${label} must be a sha256 hash as 64 hex characters or sha256:<64 hex>`);
|
|
47
|
-
return normalized.toLowerCase().startsWith('sha256:') ? normalized.toLowerCase() : `sha256:${normalized.toLowerCase()}`;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function assertRelativeOutFile(value) {
|
|
51
|
-
const normalized = assertPublicSafeString(value, 'output file');
|
|
52
|
-
if (isAbsolute(normalized) || ABSOLUTE_LOCAL_PATH_RE.test(normalized)) throw new UsageError('output file must be a relative path');
|
|
53
|
-
return normalized;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function parseArgs(argv = process.argv.slice(2)) {
|
|
57
|
-
const args = {
|
|
58
|
-
activeRoot: undefined,
|
|
59
|
-
receiptRoot: undefined,
|
|
60
|
-
benchmarkReport: undefined,
|
|
61
|
-
datasetHash: undefined,
|
|
62
|
-
runnerHash: undefined,
|
|
63
|
-
operatorRef: undefined,
|
|
64
|
-
out: undefined,
|
|
65
|
-
help: false,
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
for (let index = 0; index < argv.length; index += 1) {
|
|
69
|
-
const raw = argv[index];
|
|
70
|
-
const equalsIndex = raw.indexOf('=');
|
|
71
|
-
const flag = equalsIndex > 0 ? raw.slice(0, equalsIndex) : raw;
|
|
72
|
-
const inlineValue = equalsIndex > 0 ? raw.slice(equalsIndex + 1) : undefined;
|
|
73
|
-
const value = () => {
|
|
74
|
-
if (inlineValue !== undefined) return inlineValue;
|
|
75
|
-
const next = readRequiredValue(argv, index, flag);
|
|
76
|
-
index += 1;
|
|
77
|
-
return next;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
if (flag === '--help' || flag === '-h') args.help = true;
|
|
81
|
-
else if (flag === '--active-root') args.activeRoot = assertPublicHash(value(), 'active root');
|
|
82
|
-
else if (flag === '--receipt-root') args.receiptRoot = assertPublicHash(value(), 'receipt root');
|
|
83
|
-
else if (flag === '--benchmark-report') args.benchmarkReport = value();
|
|
84
|
-
else if (flag === '--dataset-hash') args.datasetHash = assertPublicHash(value(), 'dataset hash');
|
|
85
|
-
else if (flag === '--runner-hash') args.runnerHash = assertPublicHash(value(), 'runner hash');
|
|
86
|
-
else if (flag === '--operator-ref') args.operatorRef = assertPublicSafeString(value(), 'operator ref');
|
|
87
|
-
else if (flag === '--out') args.out = assertRelativeOutFile(value());
|
|
88
|
-
else throw new UsageError(`unknown option ${raw}; use --help`);
|
|
89
|
-
}
|
|
90
|
-
return args;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export function usage() {
|
|
94
|
-
return `Usage: node scripts/build-proof-network-packet.mjs --active-root <sha256> --receipt-root <sha256> --benchmark-report <file> --dataset-hash <sha256> --runner-hash <sha256> --operator-ref <ref> [--out <file>]
|
|
95
|
-
|
|
96
|
-
Builds a public-safe proof-network packet from local refs and hashes. The benchmark report file is hashed only; its body and path are never copied into the packet. This script does not call a network, deploy contracts, create accounts, sign transactions, or write raw memory, prompts, transcripts, completions, embeddings, ACL bodies, tenant names, private keys, API keys, seed phrases, or provider responses.
|
|
97
|
-
`;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function requireArgs(args) {
|
|
101
|
-
const required = [
|
|
102
|
-
['--active-root', args.activeRoot],
|
|
103
|
-
['--receipt-root', args.receiptRoot],
|
|
104
|
-
['--benchmark-report', args.benchmarkReport],
|
|
105
|
-
['--dataset-hash', args.datasetHash],
|
|
106
|
-
['--runner-hash', args.runnerHash],
|
|
107
|
-
['--operator-ref', args.operatorRef],
|
|
108
|
-
];
|
|
109
|
-
const missing = required.filter(([, value]) => value === undefined).map(([name]) => name);
|
|
110
|
-
if (missing.length > 0) throw new UsageError(`missing required option(s): ${missing.join(', ')}`);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function sha256Buffer(buffer) {
|
|
114
|
-
return `sha256:${createHash('sha256').update(buffer).digest('hex')}`;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function withBoundaryFlags(packet) {
|
|
118
|
-
return {
|
|
119
|
-
transaction_submitted: false,
|
|
120
|
-
raw_memory_on_chain: false,
|
|
121
|
-
...packet,
|
|
122
|
-
transaction_submitted: false,
|
|
123
|
-
raw_memory_on_chain: false,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function assertValidation(validation, label) {
|
|
128
|
-
if (validation?.ok !== true) throw new Error(`${label} validation failed: ${(validation?.errors ?? ['unknown error']).join('; ')}`);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export async function buildProofNetworkPacket(args, options = {}) {
|
|
132
|
-
requireArgs(args);
|
|
133
|
-
const generatedAt = options.generated_at ?? options.generatedAt ?? new Date().toISOString();
|
|
134
|
-
const reportBytes = await readFile(args.benchmarkReport);
|
|
135
|
-
const reportHash = sha256Buffer(reportBytes);
|
|
136
|
-
const packageRef = `npm:enigma-memory@${PROOF_NETWORK_PACKET_RELEASE_TARGET}`;
|
|
137
|
-
|
|
138
|
-
const publicInputs = {
|
|
139
|
-
active_root: args.activeRoot,
|
|
140
|
-
receipt_root: args.receiptRoot,
|
|
141
|
-
report_hash: reportHash,
|
|
142
|
-
dataset_ref: args.datasetHash,
|
|
143
|
-
runner_ref: args.runnerHash,
|
|
144
|
-
operator_ref: args.operatorRef,
|
|
145
|
-
package_ref: packageRef,
|
|
146
|
-
transaction_submitted: false,
|
|
147
|
-
raw_memory_on_chain: false,
|
|
148
|
-
};
|
|
149
|
-
assertNoPrivateProofPayload(publicInputs);
|
|
150
|
-
|
|
151
|
-
const operatorSignatureRef = `signature:${sha256Json(args.operatorRef).slice('sha256:'.length)}`;
|
|
152
|
-
const benchmarkAttestation = createBenchmarkAttestation({
|
|
153
|
-
report_hash: reportHash,
|
|
154
|
-
dataset_ref: args.datasetHash,
|
|
155
|
-
runner_ref: args.runnerHash,
|
|
156
|
-
package_ref: packageRef,
|
|
157
|
-
benchmark_ref: `benchmark-report:${reportHash}`,
|
|
158
|
-
signature_ref: operatorSignatureRef,
|
|
159
|
-
attested_at: generatedAt,
|
|
160
|
-
});
|
|
161
|
-
assertValidation(validateBenchmarkAttestation(benchmarkAttestation), 'benchmark attestation');
|
|
162
|
-
|
|
163
|
-
const anchorBatch = createProofNetworkAnchorBatch({
|
|
164
|
-
chain: 'solana',
|
|
165
|
-
generated_at: generatedAt,
|
|
166
|
-
anchor_ref: `anchor:${sha256Json([args.activeRoot, args.receiptRoot, reportHash]).slice('sha256:'.length, 'sha256:'.length + 32)}`,
|
|
167
|
-
commitments: [
|
|
168
|
-
{ kind: 'active_root', root: args.activeRoot, ref: 'active-root' },
|
|
169
|
-
{ kind: 'receipt_root', root: args.receiptRoot, ref: 'receipt-root' },
|
|
170
|
-
{ kind: 'benchmark_report', root: reportHash, ref: 'benchmark-report' },
|
|
171
|
-
{ kind: 'benchmark_attestation', root: benchmarkAttestation.benchmark_attestation_hash, ref: 'benchmark-attestation' },
|
|
172
|
-
{ kind: 'operator_ref', root: sha256Json(args.operatorRef), ref: args.operatorRef },
|
|
173
|
-
],
|
|
174
|
-
});
|
|
175
|
-
assertValidation(validateProofNetworkAnchorBatch(anchorBatch), 'anchor batch');
|
|
176
|
-
|
|
177
|
-
const packet = withBoundaryFlags(createProofNetworkPacket({
|
|
178
|
-
anchor_batches: [anchorBatch],
|
|
179
|
-
attestations: [benchmarkAttestation],
|
|
180
|
-
packet_ref: `proof-network-packet:${sha256Json([anchorBatch.anchor_batch_hash, benchmarkAttestation.benchmark_attestation_hash]).slice('sha256:'.length, 'sha256:'.length + 32)}`,
|
|
181
|
-
created_at: generatedAt,
|
|
182
|
-
}));
|
|
183
|
-
assertNoPrivateProofPayload(packet);
|
|
184
|
-
assertValidation(validateProofNetworkPacket(packet), 'proof-network packet');
|
|
185
|
-
return packet;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export async function main(argv = process.argv.slice(2)) {
|
|
189
|
-
const args = parseArgs(argv);
|
|
190
|
-
if (args.help) {
|
|
191
|
-
process.stdout.write(usage());
|
|
192
|
-
return 0;
|
|
193
|
-
}
|
|
194
|
-
const packet = await buildProofNetworkPacket(args);
|
|
195
|
-
const json = `${JSON.stringify(packet, null, 2)}\n`;
|
|
196
|
-
if (args.out) {
|
|
197
|
-
try {
|
|
198
|
-
await mkdir(dirname(args.out), { recursive: true });
|
|
199
|
-
await writeFile(args.out, json, 'utf8');
|
|
200
|
-
} catch {
|
|
201
|
-
throw new Error('failed to write proof-network packet output');
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
process.stdout.write(json);
|
|
205
|
-
return 0;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if (process.argv[1] && fileURLToPath(import.meta.url) === resolve(process.argv[1])) {
|
|
209
|
-
main().catch((error) => {
|
|
210
|
-
process.stderr.write(`${error.name ?? 'Error'}: ${error.message ?? 'failed to build proof-network packet'}\n`);
|
|
211
|
-
process.exitCode = 1;
|
|
212
|
-
});
|
|
213
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { dirname, isAbsolute, resolve } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
assertNoPrivateProofPayload,
|
|
9
|
+
createBenchmarkAttestation,
|
|
10
|
+
createProofNetworkAnchorBatch,
|
|
11
|
+
createProofNetworkPacket,
|
|
12
|
+
sha256Json,
|
|
13
|
+
validateBenchmarkAttestation,
|
|
14
|
+
validateProofNetworkAnchorBatch,
|
|
15
|
+
validateProofNetworkPacket,
|
|
16
|
+
} from '../packages/proof-network/src/index.js';
|
|
17
|
+
|
|
18
|
+
export const PROOF_NETWORK_PACKET_RELEASE_TARGET = '0.1.17';
|
|
19
|
+
|
|
20
|
+
const HASH_RE = /^(?:sha256:)?[a-f0-9]{64}$/iu;
|
|
21
|
+
const SECRET_VALUE_RE = /(?:Bearer\s+[A-Za-z0-9._~+/=-]{12,}|Basic\s+[A-Za-z0-9+/=-]{12,}|-----BEGIN [A-Z ]*PRIVATE KEY-----|https?:\/\/[^\s/@]+:[^\s/@]+@|sk-[A-Za-z0-9_-]{16,}|AKIA[0-9A-Z]{16}|\b(?:raw[\s_-]*memory|plaintext[\s_-]*prompts?|plain[\s_-]*text[\s_-]*prompts?|private[\s_-]*prompts?|provider[\s_-]*responses?|full[\s_-]*transcript|decrypted[\s_-]*memory|credentials?|secrets?|passwords?|private[\s_-]*keys?|api[\s_-]*key[\s_-]*(?:secret|material|value)|api[\s_-]*secrets?|access[\s_-]*tokens?|refresh[\s_-]*tokens?|token[\s_-]*values?|credential[\s_-]*material|tenant[\s_-]*names?)\b)/iu;
|
|
22
|
+
const ABSOLUTE_LOCAL_PATH_RE = /^(?:[A-Za-z]:[\\/]|\\\\|\/(?:Users|home|tmp|var|etc|mnt|Volumes)\b)/u;
|
|
23
|
+
|
|
24
|
+
class UsageError extends Error {
|
|
25
|
+
constructor(message) {
|
|
26
|
+
super(message);
|
|
27
|
+
this.name = 'UsageError';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function readRequiredValue(argv, index, flag) {
|
|
32
|
+
const value = argv[index + 1];
|
|
33
|
+
if (value === undefined || value.startsWith('--')) throw new UsageError(`${flag} requires a value`);
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function assertPublicSafeString(value, label) {
|
|
38
|
+
if (typeof value !== 'string' || value.trim() === '') throw new UsageError(`${label} must be a non-empty public ref or hash`);
|
|
39
|
+
const normalized = value.trim();
|
|
40
|
+
if (SECRET_VALUE_RE.test(normalized)) throw new UsageError(`${label} contains private or secret material`);
|
|
41
|
+
return normalized;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function assertPublicHash(value, label) {
|
|
45
|
+
const normalized = assertPublicSafeString(value, label);
|
|
46
|
+
if (!HASH_RE.test(normalized)) throw new UsageError(`${label} must be a sha256 hash as 64 hex characters or sha256:<64 hex>`);
|
|
47
|
+
return normalized.toLowerCase().startsWith('sha256:') ? normalized.toLowerCase() : `sha256:${normalized.toLowerCase()}`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function assertRelativeOutFile(value) {
|
|
51
|
+
const normalized = assertPublicSafeString(value, 'output file');
|
|
52
|
+
if (isAbsolute(normalized) || ABSOLUTE_LOCAL_PATH_RE.test(normalized)) throw new UsageError('output file must be a relative path');
|
|
53
|
+
return normalized;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function parseArgs(argv = process.argv.slice(2)) {
|
|
57
|
+
const args = {
|
|
58
|
+
activeRoot: undefined,
|
|
59
|
+
receiptRoot: undefined,
|
|
60
|
+
benchmarkReport: undefined,
|
|
61
|
+
datasetHash: undefined,
|
|
62
|
+
runnerHash: undefined,
|
|
63
|
+
operatorRef: undefined,
|
|
64
|
+
out: undefined,
|
|
65
|
+
help: false,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
69
|
+
const raw = argv[index];
|
|
70
|
+
const equalsIndex = raw.indexOf('=');
|
|
71
|
+
const flag = equalsIndex > 0 ? raw.slice(0, equalsIndex) : raw;
|
|
72
|
+
const inlineValue = equalsIndex > 0 ? raw.slice(equalsIndex + 1) : undefined;
|
|
73
|
+
const value = () => {
|
|
74
|
+
if (inlineValue !== undefined) return inlineValue;
|
|
75
|
+
const next = readRequiredValue(argv, index, flag);
|
|
76
|
+
index += 1;
|
|
77
|
+
return next;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
if (flag === '--help' || flag === '-h') args.help = true;
|
|
81
|
+
else if (flag === '--active-root') args.activeRoot = assertPublicHash(value(), 'active root');
|
|
82
|
+
else if (flag === '--receipt-root') args.receiptRoot = assertPublicHash(value(), 'receipt root');
|
|
83
|
+
else if (flag === '--benchmark-report') args.benchmarkReport = value();
|
|
84
|
+
else if (flag === '--dataset-hash') args.datasetHash = assertPublicHash(value(), 'dataset hash');
|
|
85
|
+
else if (flag === '--runner-hash') args.runnerHash = assertPublicHash(value(), 'runner hash');
|
|
86
|
+
else if (flag === '--operator-ref') args.operatorRef = assertPublicSafeString(value(), 'operator ref');
|
|
87
|
+
else if (flag === '--out') args.out = assertRelativeOutFile(value());
|
|
88
|
+
else throw new UsageError(`unknown option ${raw}; use --help`);
|
|
89
|
+
}
|
|
90
|
+
return args;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function usage() {
|
|
94
|
+
return `Usage: node scripts/build-proof-network-packet.mjs --active-root <sha256> --receipt-root <sha256> --benchmark-report <file> --dataset-hash <sha256> --runner-hash <sha256> --operator-ref <ref> [--out <file>]
|
|
95
|
+
|
|
96
|
+
Builds a public-safe proof-network packet from local refs and hashes. The benchmark report file is hashed only; its body and path are never copied into the packet. This script does not call a network, deploy contracts, create accounts, sign transactions, or write raw memory, prompts, transcripts, completions, embeddings, ACL bodies, tenant names, private keys, API keys, seed phrases, or provider responses.
|
|
97
|
+
`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function requireArgs(args) {
|
|
101
|
+
const required = [
|
|
102
|
+
['--active-root', args.activeRoot],
|
|
103
|
+
['--receipt-root', args.receiptRoot],
|
|
104
|
+
['--benchmark-report', args.benchmarkReport],
|
|
105
|
+
['--dataset-hash', args.datasetHash],
|
|
106
|
+
['--runner-hash', args.runnerHash],
|
|
107
|
+
['--operator-ref', args.operatorRef],
|
|
108
|
+
];
|
|
109
|
+
const missing = required.filter(([, value]) => value === undefined).map(([name]) => name);
|
|
110
|
+
if (missing.length > 0) throw new UsageError(`missing required option(s): ${missing.join(', ')}`);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function sha256Buffer(buffer) {
|
|
114
|
+
return `sha256:${createHash('sha256').update(buffer).digest('hex')}`;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function withBoundaryFlags(packet) {
|
|
118
|
+
return {
|
|
119
|
+
transaction_submitted: false,
|
|
120
|
+
raw_memory_on_chain: false,
|
|
121
|
+
...packet,
|
|
122
|
+
transaction_submitted: false,
|
|
123
|
+
raw_memory_on_chain: false,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function assertValidation(validation, label) {
|
|
128
|
+
if (validation?.ok !== true) throw new Error(`${label} validation failed: ${(validation?.errors ?? ['unknown error']).join('; ')}`);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export async function buildProofNetworkPacket(args, options = {}) {
|
|
132
|
+
requireArgs(args);
|
|
133
|
+
const generatedAt = options.generated_at ?? options.generatedAt ?? new Date().toISOString();
|
|
134
|
+
const reportBytes = await readFile(args.benchmarkReport);
|
|
135
|
+
const reportHash = sha256Buffer(reportBytes);
|
|
136
|
+
const packageRef = `npm:enigma-memory@${PROOF_NETWORK_PACKET_RELEASE_TARGET}`;
|
|
137
|
+
|
|
138
|
+
const publicInputs = {
|
|
139
|
+
active_root: args.activeRoot,
|
|
140
|
+
receipt_root: args.receiptRoot,
|
|
141
|
+
report_hash: reportHash,
|
|
142
|
+
dataset_ref: args.datasetHash,
|
|
143
|
+
runner_ref: args.runnerHash,
|
|
144
|
+
operator_ref: args.operatorRef,
|
|
145
|
+
package_ref: packageRef,
|
|
146
|
+
transaction_submitted: false,
|
|
147
|
+
raw_memory_on_chain: false,
|
|
148
|
+
};
|
|
149
|
+
assertNoPrivateProofPayload(publicInputs);
|
|
150
|
+
|
|
151
|
+
const operatorSignatureRef = `signature:${sha256Json(args.operatorRef).slice('sha256:'.length)}`;
|
|
152
|
+
const benchmarkAttestation = createBenchmarkAttestation({
|
|
153
|
+
report_hash: reportHash,
|
|
154
|
+
dataset_ref: args.datasetHash,
|
|
155
|
+
runner_ref: args.runnerHash,
|
|
156
|
+
package_ref: packageRef,
|
|
157
|
+
benchmark_ref: `benchmark-report:${reportHash}`,
|
|
158
|
+
signature_ref: operatorSignatureRef,
|
|
159
|
+
attested_at: generatedAt,
|
|
160
|
+
});
|
|
161
|
+
assertValidation(validateBenchmarkAttestation(benchmarkAttestation), 'benchmark attestation');
|
|
162
|
+
|
|
163
|
+
const anchorBatch = createProofNetworkAnchorBatch({
|
|
164
|
+
chain: 'solana',
|
|
165
|
+
generated_at: generatedAt,
|
|
166
|
+
anchor_ref: `anchor:${sha256Json([args.activeRoot, args.receiptRoot, reportHash]).slice('sha256:'.length, 'sha256:'.length + 32)}`,
|
|
167
|
+
commitments: [
|
|
168
|
+
{ kind: 'active_root', root: args.activeRoot, ref: 'active-root' },
|
|
169
|
+
{ kind: 'receipt_root', root: args.receiptRoot, ref: 'receipt-root' },
|
|
170
|
+
{ kind: 'benchmark_report', root: reportHash, ref: 'benchmark-report' },
|
|
171
|
+
{ kind: 'benchmark_attestation', root: benchmarkAttestation.benchmark_attestation_hash, ref: 'benchmark-attestation' },
|
|
172
|
+
{ kind: 'operator_ref', root: sha256Json(args.operatorRef), ref: args.operatorRef },
|
|
173
|
+
],
|
|
174
|
+
});
|
|
175
|
+
assertValidation(validateProofNetworkAnchorBatch(anchorBatch), 'anchor batch');
|
|
176
|
+
|
|
177
|
+
const packet = withBoundaryFlags(createProofNetworkPacket({
|
|
178
|
+
anchor_batches: [anchorBatch],
|
|
179
|
+
attestations: [benchmarkAttestation],
|
|
180
|
+
packet_ref: `proof-network-packet:${sha256Json([anchorBatch.anchor_batch_hash, benchmarkAttestation.benchmark_attestation_hash]).slice('sha256:'.length, 'sha256:'.length + 32)}`,
|
|
181
|
+
created_at: generatedAt,
|
|
182
|
+
}));
|
|
183
|
+
assertNoPrivateProofPayload(packet);
|
|
184
|
+
assertValidation(validateProofNetworkPacket(packet), 'proof-network packet');
|
|
185
|
+
return packet;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export async function main(argv = process.argv.slice(2)) {
|
|
189
|
+
const args = parseArgs(argv);
|
|
190
|
+
if (args.help) {
|
|
191
|
+
process.stdout.write(usage());
|
|
192
|
+
return 0;
|
|
193
|
+
}
|
|
194
|
+
const packet = await buildProofNetworkPacket(args);
|
|
195
|
+
const json = `${JSON.stringify(packet, null, 2)}\n`;
|
|
196
|
+
if (args.out) {
|
|
197
|
+
try {
|
|
198
|
+
await mkdir(dirname(args.out), { recursive: true });
|
|
199
|
+
await writeFile(args.out, json, 'utf8');
|
|
200
|
+
} catch {
|
|
201
|
+
throw new Error('failed to write proof-network packet output');
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
process.stdout.write(json);
|
|
205
|
+
return 0;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (process.argv[1] && fileURLToPath(import.meta.url) === resolve(process.argv[1])) {
|
|
209
|
+
main().catch((error) => {
|
|
210
|
+
process.stderr.write(`${error.name ?? 'Error'}: ${error.message ?? 'failed to build proof-network packet'}\n`);
|
|
211
|
+
process.exitCode = 1;
|
|
212
|
+
});
|
|
213
|
+
}
|
package/scripts/check.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
4
|
-
|
|
4
|
+
import { scanForSecrets } from './scan-secrets.mjs';
|
|
5
5
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
6
6
|
const packageJsonPath = process.env.ENIGMA_CHECK_PACKAGE_JSON_OVERRIDE
|
|
7
7
|
? path.resolve(process.env.ENIGMA_CHECK_PACKAGE_JSON_OVERRIDE)
|
|
@@ -265,14 +265,28 @@ function validatePackageMetadata(pkg) {
|
|
|
265
265
|
'./gateway',
|
|
266
266
|
'./desktop'
|
|
267
267
|
];
|
|
268
|
+
function extractExportTargets(target) {
|
|
269
|
+
if (typeof target === 'string') return [target];
|
|
270
|
+
if (isPlainObject(target)) return Object.values(target).flatMap(extractExportTargets);
|
|
271
|
+
if (Array.isArray(target)) return target.flatMap(extractExportTargets);
|
|
272
|
+
return [];
|
|
273
|
+
}
|
|
274
|
+
|
|
268
275
|
if (!isPlainObject(pkg.exports)) throw new Error('package.json missing exports');
|
|
269
276
|
for (const key of requiredExports) {
|
|
270
277
|
const target = pkg.exports[key];
|
|
271
|
-
if (typeof target !== 'string') throw new Error(`package.json missing export ${key}`);
|
|
272
|
-
|
|
278
|
+
if (typeof target !== 'string' && !isPlainObject(target)) throw new Error(`package.json missing export ${key}`);
|
|
279
|
+
const targets = extractExportTargets(target);
|
|
280
|
+
if (targets.length === 0) throw new Error(`package.json missing export ${key}`);
|
|
281
|
+
for (const t of targets) {
|
|
282
|
+
if (!packageFileExists(t)) throw new Error(`package.json export ${key} points to a missing file: ${t}`);
|
|
283
|
+
}
|
|
273
284
|
}
|
|
274
285
|
for (const [key, target] of Object.entries(pkg.exports)) {
|
|
275
|
-
|
|
286
|
+
const targets = extractExportTargets(target);
|
|
287
|
+
for (const t of targets) {
|
|
288
|
+
if (!packageFileExists(t)) throw new Error(`package.json export ${key} points to a missing file: ${t}`);
|
|
289
|
+
}
|
|
276
290
|
}
|
|
277
291
|
|
|
278
292
|
const requiredBins = ['enigma', 'enigma-verify', 'enigma-mcp', 'enigma-relay', 'enigma-gateway', 'enigma-native-host'];
|
|
@@ -417,5 +431,12 @@ for (const name of fs.readdirSync(specsDir)) {
|
|
|
417
431
|
}
|
|
418
432
|
validateSchemaNode(name, parsed, parsed);
|
|
419
433
|
}
|
|
434
|
+
const secretFindings = scanForSecrets(root);
|
|
435
|
+
if (secretFindings.length > 0) {
|
|
436
|
+
throw new Error(
|
|
437
|
+
`secret-scan detected ${secretFindings.length} unapproved secret-like value(s):\n` +
|
|
438
|
+
secretFindings.map((f) => `${f.file}:${f.line} ${f.type}`).join('\n')
|
|
439
|
+
);
|
|
440
|
+
}
|
|
420
441
|
|
|
421
442
|
console.log('enigma check ok');
|