space-data-module-sdk 0.10.3 → 0.11.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/bin/space-data-module.js +28 -6
- package/docs/conformance.html +1 -1
- package/docs/conformance.md +4 -2
- package/docs/isomorphic-pthreads.md +33 -0
- package/docs/module-publication-standard.html +6 -4
- package/docs/module-publication-standard.md +30 -8
- package/docs/protect-and-sign.html +3 -3
- package/docs/protect-and-sign.md +12 -5
- package/package.json +3 -2
- package/src/bundle/codeManifest.js +579 -0
- package/src/bundle/index.js +1 -0
- package/src/bundle/signing.js +385 -304
- package/src/bundle/wasm.js +60 -0
- package/src/compliance/index.js +2 -0
- package/src/compliance/pluginCompliance.js +144 -32
- package/src/flow/flowCompiler.js +41 -43
- package/src/flow/isomorphicFlowHost.js +17 -27
- package/src/host/browserModuleHarness.js +13 -0
- package/src/host/isomorphicLoader.js +89 -11
- package/src/index.d.ts +7 -0
package/bin/space-data-module.js
CHANGED
|
@@ -139,6 +139,9 @@ function parseArgs(argv) {
|
|
|
139
139
|
case "--require-signature":
|
|
140
140
|
options.requireSignature = true;
|
|
141
141
|
break;
|
|
142
|
+
case "--scope":
|
|
143
|
+
options.signatureScope = requireValue(argv, ++index, value);
|
|
144
|
+
break;
|
|
142
145
|
case "--fixture":
|
|
143
146
|
options.fixturePath = path.resolve(requireValue(argv, ++index, value));
|
|
144
147
|
break;
|
|
@@ -167,6 +170,9 @@ function parseArgs(argv) {
|
|
|
167
170
|
case "--allow-single-lane":
|
|
168
171
|
options.allowSingleLane = true;
|
|
169
172
|
break;
|
|
173
|
+
case "--allow-test-signer":
|
|
174
|
+
options.allowTestSigner = true;
|
|
175
|
+
break;
|
|
170
176
|
case "--gate-manifest":
|
|
171
177
|
options.gateManifestPath = path.resolve(
|
|
172
178
|
requireValue(argv, ++index, value),
|
|
@@ -257,7 +263,7 @@ function printUsage() {
|
|
|
257
263
|
space-data-module conformance estimation --evidence ./conformance/estimation-evidence.json --json
|
|
258
264
|
space-data-module conformance estimation --self-test (proves EKF/UKF alias, runtime divergence, and placeholder OCM are caught)
|
|
259
265
|
space-data-module flow check ./flows/my.flow.json --deps ./modules-root
|
|
260
|
-
space-data-module flow compile ./flows/my.flow.json --deps ./modules-root [--out ./flows/my/dist]
|
|
266
|
+
space-data-module flow compile ./flows/my.flow.json --deps ./modules-root [--out ./flows/my/dist] [--allow-test-signer]
|
|
261
267
|
space-data-module protect --manifest ./manifest.json --wasm ./dist/module.wasm --json
|
|
262
268
|
space-data-module protect --manifest ./manifest.json --wasm ./dist/module.wasm --recipient-public-key <hex> --out ./dist/module.wasm.enc
|
|
263
269
|
space-data-module protect --manifest ./manifest.json --wasm ./dist/module.wasm --single-file-bundle --out ./dist/module.bundle.wasm
|
|
@@ -343,6 +349,7 @@ async function runFlow(argv) {
|
|
|
343
349
|
dependencies,
|
|
344
350
|
outDir,
|
|
345
351
|
flowSourcePath: flowPath,
|
|
352
|
+
allowTestSigner: options.allowTestSigner === true,
|
|
346
353
|
});
|
|
347
354
|
if (options.json) {
|
|
348
355
|
console.log(
|
|
@@ -760,6 +767,7 @@ async function runSign(argv) {
|
|
|
760
767
|
const result = await signModuleArtifact(wasmBytes, {
|
|
761
768
|
privateKeySeedHex: keypair.privateKeySeedHex,
|
|
762
769
|
keyId: keypair.keyId ?? null,
|
|
770
|
+
...(options.signatureScope ? { signatureScope: options.signatureScope } : {}),
|
|
763
771
|
});
|
|
764
772
|
const outputPath = options.outputPath ?? options.wasmPath;
|
|
765
773
|
await writeFile(outputPath, result.wasmBytes);
|
|
@@ -770,6 +778,9 @@ async function runSign(argv) {
|
|
|
770
778
|
outputPath,
|
|
771
779
|
keyId: result.signature.keyId,
|
|
772
780
|
publicKeyHex: result.signature.publicKeyHex,
|
|
781
|
+
signatureScope: result.signatureScope,
|
|
782
|
+
statementDomain: result.signature.statementDomain ?? null,
|
|
783
|
+
signedHashHex: result.signedHashHex,
|
|
773
784
|
canonicalModuleHashHex: result.canonicalModuleHashHex,
|
|
774
785
|
},
|
|
775
786
|
null,
|
|
@@ -780,6 +791,9 @@ async function runSign(argv) {
|
|
|
780
791
|
console.log(`signed=${outputPath}`);
|
|
781
792
|
console.log(`keyId=${result.signature.keyId}`);
|
|
782
793
|
console.log(`publicKeyHex=${result.signature.publicKeyHex}`);
|
|
794
|
+
console.log(`signatureScope=${result.signatureScope}`);
|
|
795
|
+
if (result.signature.statementDomain) console.log(`statementDomain=${result.signature.statementDomain}`);
|
|
796
|
+
console.log(`signedHashHex=${result.signedHashHex}`);
|
|
783
797
|
console.log(`canonicalModuleHashHex=${result.canonicalModuleHashHex}`);
|
|
784
798
|
}
|
|
785
799
|
return 0;
|
|
@@ -800,13 +814,21 @@ async function runVerify(argv) {
|
|
|
800
814
|
trustedPublicKeys,
|
|
801
815
|
requireSignature: options.requireSignature ?? true,
|
|
802
816
|
});
|
|
817
|
+
// The form verified is named by its statement domain. The result's
|
|
818
|
+
// signatureScope ("module", the node's status label, kept for the shared
|
|
819
|
+
// vectors) is not printed: it reads like the removed bare-digest form.
|
|
820
|
+
const { signatureScope: _nodeStatusLabel, ...printed } = result;
|
|
803
821
|
if (options.json) {
|
|
804
|
-
console.log(JSON.stringify(
|
|
822
|
+
console.log(JSON.stringify(printed, null, 2));
|
|
805
823
|
} else {
|
|
806
|
-
console.log(`verified=${
|
|
807
|
-
console.log(`signed=${
|
|
808
|
-
|
|
809
|
-
|
|
824
|
+
console.log(`verified=${printed.verified}`);
|
|
825
|
+
console.log(`signed=${printed.signed}`);
|
|
826
|
+
// The signer's role comes from the verified KEY. The entry's keyId is an
|
|
827
|
+
// unsigned label the file carries about itself, printed as such.
|
|
828
|
+
if (printed.verified) console.log(`signer=${printed.testSigner ? "test" : "other"}`);
|
|
829
|
+
if (printed.publicKeyHex) console.log(`publicKeyHex=${printed.publicKeyHex}`);
|
|
830
|
+
if (printed.keyId) console.log(`unsignedKeyId=${printed.keyId}`);
|
|
831
|
+
if (printed.statementDomain) console.log(`statementDomain=${printed.statementDomain}`);
|
|
810
832
|
}
|
|
811
833
|
return result.verified ? 0 : 1;
|
|
812
834
|
}
|
package/docs/conformance.html
CHANGED
|
@@ -120,7 +120,7 @@ space-data-module conformance estimation --self-test # planted failures</code
|
|
|
120
120
|
<div class="table-wrap"><table><thead><tr><th>Planted defect</th><th>Real-world citation</th><th>Must be caught by</th></tr></thead><tbody><tr><td><code>units-km</code> (1000× error)</td><td>the <code>orbpro_propagator.h</code> km/meters contradiction (finding §4.1)</td><td><code>tierB/anchors</code></td></tr><tr><td><code>leaky-destroy</code></td><td><code>destroySource(){}</code> in both shipped propagators (§4.5)</td><td><code>tier4/lifecycle-leak</code></td></tr><tr><td><code>confident-nonsense</code> (accepts e ≥ 1)</td><td>the underground phasing orbit (§5)</td><td><code>tierC/typed-refusals</code></td></tr><tr><td><code>count-fallback</code> (returns success, not the handle)</td><td>three families deriving count−1 (§4.4)</td><td><code>tierC/create-returns-handle</code></td></tr><tr><td><code>frame-lies</code> (declares TEME, writes ECEF)</td><td>the Δv frame never pinned (§4.3)</td><td><code>tierC/frame-flags-reserved-declared</code></td></tr><tr><td><code>batch-divergence</code></td><td>batch path not the same physics</td><td><code>tierC/batch-single-agreement</code></td></tr><tr><td><code>nondeterministic</code></td><td>byte-determinism is the parity envelope's floor</td><td><code>tierC/determinism-byte-identity</code></td></tr><tr><td><code>missing-exports</code></td><td>destroy was optional once; it is not now</td><td><code>tier0/instantiation-and-exports</code></td></tr></tbody></table></div>
|
|
121
121
|
<p>The self-test exits 0 only when the conformant baseline mock is clean AND every planted defect is caught by the check that owns it. It needs no toolchain, no artifact and no network — <code>npm run conformance:self-test</code>.</p>
|
|
122
122
|
<h2 id="receipt-trust-wave-4-not-yet-wired"><a class="anchor" href="#receipt-trust-wave-4-not-yet-wired" aria-hidden="true">#</a>Receipt & trust (Wave 4, not yet wired)</h2>
|
|
123
|
-
<p>The conformance receipt travels as a bundle <code>ATTESTATION</code> entry (
|
|
123
|
+
<p>The conformance receipt travels as a bundle <code>ATTESTATION</code> entry in the trailer. The module's publication signature does not cover it (that signature covers only the bytes before the trailer), so the entry needs its own attestor signature under the attestor domain named below. The graduated listing requirement (receipt REQUIRED for <code>CORE</code>+<code>ANONYMOUS</code>, badge for <code>RECOMMENDED</code>) and the <code>SDN-CONFORMANCE-RECEIPT-V1</code> third-party attestor domain are W4.1/W4.2 of the program — see the finding §5 "Receipt & trust".</p>
|
|
124
124
|
<p>The estimation self-test plants runtime-byte divergence, the historical EKF/UKF covariance alias, and a placeholder <code>$OCM</code>. All three must be caught.</p>
|
|
125
125
|
<h2 id="reference-implementation"><a class="anchor" href="#reference-implementation" aria-hidden="true">#</a>Reference implementation</h2>
|
|
126
126
|
<p><code>space-data-network-modules propagator/keplerian-reference</code> is the exemplar the kit was generalized from: its <code>tests/</code> are the original expression of these checks, its <code>vectors/</code> suite is the corpus format, and <code>tests/sdk-conformance-runner.test.mjs</code> proves the runner reaches the same verdict on the same artifact — including the corrupted-corpus negative control.</p>
|
package/docs/conformance.md
CHANGED
|
@@ -84,8 +84,10 @@ toolchain, no artifact and no network — `npm run conformance:self-test`.
|
|
|
84
84
|
|
|
85
85
|
## Receipt & trust (Wave 4, not yet wired)
|
|
86
86
|
|
|
87
|
-
The conformance receipt travels as a bundle `ATTESTATION` entry
|
|
88
|
-
|
|
87
|
+
The conformance receipt travels as a bundle `ATTESTATION` entry in the trailer.
|
|
88
|
+
The module's publication signature does not cover it (that signature covers only
|
|
89
|
+
the bytes before the trailer), so the entry needs its own attestor signature
|
|
90
|
+
under the attestor domain named below. The graduated listing requirement
|
|
89
91
|
(receipt REQUIRED for `CORE`+`ANONYMOUS`, badge for `RECOMMENDED`) and the
|
|
90
92
|
`SDN-CONFORMANCE-RECEIPT-V1` third-party attestor domain are W4.1/W4.2 of the
|
|
91
93
|
program — see the finding §5 "Receipt & trust".
|
|
@@ -422,6 +422,39 @@ worker bundles and the browser capability probe.
|
|
|
422
422
|
|
|
423
423
|
### Explicit pool size, partial spawns, supervision hooks
|
|
424
424
|
|
|
425
|
+
`createBrowserModuleHarness` accepts `wasiThreadProbeTimeoutMs`, the browser
|
|
426
|
+
pool arming deadline in milliseconds. It forwards the value as
|
|
427
|
+
`createWasiThreadSpawn`'s `probeTimeoutMs`. The default is 1500. An explicit
|
|
428
|
+
value must be a positive finite number; invalid values throw an `Error` before
|
|
429
|
+
the artifact is loaded. The option applies to the initial context and each
|
|
430
|
+
fresh command invocation. It has no effect on Node's on-demand pool startup.
|
|
431
|
+
|
|
432
|
+
After harness creation, the read-only `harness.wasiThreadPoolReport` property
|
|
433
|
+
returns a frozen `{ requested, armed }` snapshot. Counts refer to pool workers
|
|
434
|
+
and exclude the calling thread. With `wasiThreadPoolSize`, `requested` is that
|
|
435
|
+
explicit size, including when threading is unavailable. Without an explicit
|
|
436
|
+
size, it is the browser's selected pool size. Non-threaded artifacts return
|
|
437
|
+
`null`. Node reports its explicit cap (or `null` without one) and the number
|
|
438
|
+
of workers started on demand.
|
|
439
|
+
|
|
440
|
+
For an explicit browser pool, fewer armed workers do not throw. Workers that
|
|
441
|
+
miss the deadline are terminated before the harness returns; successfully
|
|
442
|
+
armed workers remain available. The host uses the report to decide whether
|
|
443
|
+
the capacity meets its needs. A guest must handle declined spawns to execute
|
|
444
|
+
successfully with fewer workers. After a command invocation, the property
|
|
445
|
+
reports that invocation's arming counts, even though its pool is terminated.
|
|
446
|
+
These are startup counts, not a live-worker health report.
|
|
447
|
+
|
|
448
|
+
```js
|
|
449
|
+
const harness = await createBrowserModuleHarness({
|
|
450
|
+
wasmSource,
|
|
451
|
+
enableBrowserWasiThreads: true,
|
|
452
|
+
wasiThreadPoolSize: 8,
|
|
453
|
+
wasiThreadProbeTimeoutMs: 10000,
|
|
454
|
+
});
|
|
455
|
+
const { requested, armed } = harness.wasiThreadPoolReport;
|
|
456
|
+
```
|
|
457
|
+
|
|
425
458
|
`createWasiThreadSpawn` options added in 0.8.22:
|
|
426
459
|
|
|
427
460
|
| Option | Effect |
|
|
@@ -170,13 +170,15 @@
|
|
|
170
170
|
</ul>
|
|
171
171
|
<p>In practice this is the record a host inspects to determine what artifact was published and which signer attested to it.</p>
|
|
172
172
|
<h3 id="mbl-signature-entry-domain-separation-statementdomain"><a class="anchor" href="#mbl-signature-entry-domain-separation-statementdomain" aria-hidden="true">#</a>MBL <code>signature</code> entry — domain separation (<code>statementDomain</code>)</h3>
|
|
173
|
-
<p>The detached Ed25519 signature carried as the MBL bundle's <code>signature</code>-role entry has
|
|
174
|
-
<div class="table-wrap"><table><thead><tr><th><code>statementDomain</code></th><th>signature covers</th></tr></thead><tbody><tr><td><code>SDN-MODULE-PUBLICATION-V1</code></td><td>`"SDN-MODULE-PUBLICATION-V1" \</td><td>\</td><td>0x00 \</td><td>\</td><td>sha256(portable)`</td></tr
|
|
175
|
-
<p><code>portable</code> is the trailer-stripped payload: the exact bytes the runtime instantiates and the node's capability policy identifies by content hash.</p>
|
|
173
|
+
<p>The detached Ed25519 signature carried as the MBL bundle's <code>signature</code>-role entry has ONE form:</p>
|
|
174
|
+
<div class="table-wrap"><table><thead><tr><th><code>statementDomain</code></th><th>signature covers</th></tr></thead><tbody><tr><td><code>SDN-MODULE-PUBLICATION-V1</code></td><td>`"SDN-MODULE-PUBLICATION-V1" \</td><td>\</td><td>0x00 \</td><td>\</td><td>sha256(portable)`</td></tr></tbody></table></div>
|
|
175
|
+
<p><code>portable</code> is the trailer-stripped payload: the exact bytes the runtime instantiates and the node's capability policy identifies by content hash. The signature covers every byte of it (the code, every data segment, every custom section left in it) and none of the trailer: the MBL entries beside the signature, the manifest copy among them, are not signed. A host takes the manifest from the signed code, never from the trailer, and refuses an artifact whose trailer copy differs from the code's copy.</p>
|
|
176
|
+
<p><code>signModuleArtifact</code> writes it (<code>signatureScope: "publication"</code>, the default and the only value), the same entry, field for field, as the node's signing endpoint; so does the CLI's <code>sign</code>. The entry's <code>signedHashHex</code> is REQUIRED and equal to sha256(portable) (<code>missing_signed_hash</code>, <code>hash_mismatch</code>), and its <code>signedHashAlgorithm</code> is REQUIRED and is the fixed label <code>sha256-canonical-module-hash</code>, the string the node writes; it is a label, not a description of the hash (<code>unsupported_hash_algorithm</code>).</p>
|
|
177
|
+
<p>A signature with no <code>statementDomain</code> is one of the two forms removed in 0.11.0, and every verifier in this SDK refuses it by name, before the signer is asked about: <code>legacy_module_signature</code> for the bare canonical module digest (<code>signedHashAlgorithm</code> <code>sha256-canonical-module-hash</code> or absent) and <code>legacy_bundle_signature</code> for the whole-bundle digest (<code>signedHashAlgorithm</code> <code>sha256-sdn-module-bundle-v1</code>). No writer produces either, and <code>signatureScope: "module"</code> or <code>"bundle"</code> is refused. A module signed in either must be signed again.</p>
|
|
176
178
|
<p>The domain prefix exists because the node's publisher key is the NODE key, and that one bonded key signs several unrelated kinds of statement (dataset publications, module artifacts, update SIGNALS — the advisory pub/sub nudge a publisher pushes so every install upgrades itself in place, which has a live producer — and, still reserved, update manifests). If every statement were a bare SHA-256 digest, a caller who could reach the node's signing endpoint could submit the bytes of one kind of document and staple the returned signature onto another. An ASCII domain label, a <code>NUL</code> that cannot occur inside the label, and a fixed-width 32-byte tail put each statement kind in a disjoint message space with no length ambiguity anywhere in the preimage.</p>
|
|
177
179
|
<p>The domain registry is <strong>closed</strong>: a verifier refuses any label that is not registered, and a module verifier additionally refuses any registered label other than <code>SDN-MODULE-PUBLICATION-V1</code> — so a signature minted for an update manifest or an update signal can never be replayed into a module trailer, which the shared vectors pin as <code>foreign-registered-domain</code> and <code>update-signal-domain-is-refused-for-a-module</code>. Adding a domain is a reviewed change in every implementation at once (<code>src/bundle/sigdomain.js</code> here; <code>internal/sigdomain</code> and its kubo twin in the node), never a request parameter.</p>
|
|
178
180
|
<p><code>statementDomain</code> and <code>algorithm</code> are compared after trimming <strong>Go's</strong> whitespace set (<code>unicode.IsSpace</code> / Unicode <code>White_Space</code>), which is not JavaScript's: Go trims U+0085 NEL and JS does not, JS trims U+FEFF BOM and Go does not. Either mismatch is a "loads on the node, dies in the browser" split, so both are pinned by vectors rather than left to each language's default.</p>
|
|
179
|
-
<p>
|
|
181
|
+
<p>The forms, the preimage bytes and every refusal reason are pinned as shared cross-language vectors in <code>test/support/statement-domain-vectors.json</code>, byte-identical to the node's copies, and asserted by the JS suite and both Go suites. Four vectors, <code>legacy-bare-digest-no-domain</code> and the three <code>bundle-scope-*</code>, are refused by this SDK where the file records the node's verdict; the JS suite states those differences by name.</p>
|
|
180
182
|
<h3 id="enc-encrypted-delivery-extension"><a class="anchor" href="#enc-encrypted-delivery-extension" aria-hidden="true">#</a><code>ENC</code> encrypted-delivery extension</h3>
|
|
181
183
|
<p><code>ENC</code> carries the decryption parameters for a transport-protected module:</p>
|
|
182
184
|
<ul>
|
|
@@ -115,16 +115,36 @@ published and which signer attested to it.
|
|
|
115
115
|
### MBL `signature` entry — domain separation (`statementDomain`)
|
|
116
116
|
|
|
117
117
|
The detached Ed25519 signature carried as the MBL bundle's `signature`-role
|
|
118
|
-
entry has
|
|
119
|
-
verifier, never a policy:
|
|
118
|
+
entry has ONE form:
|
|
120
119
|
|
|
121
120
|
| `statementDomain` | signature covers |
|
|
122
121
|
| ---------------------------- | --------------------------------------------------- |
|
|
123
122
|
| `SDN-MODULE-PUBLICATION-V1` | `"SDN-MODULE-PUBLICATION-V1" \|\| 0x00 \|\| sha256(portable)` |
|
|
124
|
-
| absent | the bare canonical module (or bundle) digest — legacy |
|
|
125
123
|
|
|
126
124
|
`portable` is the trailer-stripped payload: the exact bytes the runtime
|
|
127
|
-
instantiates and the node's capability policy identifies by content hash.
|
|
125
|
+
instantiates and the node's capability policy identifies by content hash. The
|
|
126
|
+
signature covers every byte of it (the code, every data segment, every custom
|
|
127
|
+
section left in it) and none of the trailer: the MBL entries beside the
|
|
128
|
+
signature, the manifest copy among them, are not signed. A host takes the
|
|
129
|
+
manifest from the signed code, never from the trailer, and refuses an artifact
|
|
130
|
+
whose trailer copy differs from the code's copy.
|
|
131
|
+
|
|
132
|
+
`signModuleArtifact` writes it (`signatureScope: "publication"`, the default and
|
|
133
|
+
the only value), the same entry, field for field, as the node's signing
|
|
134
|
+
endpoint; so does the CLI's `sign`. The entry's `signedHashHex` is REQUIRED and
|
|
135
|
+
equal to sha256(portable) (`missing_signed_hash`, `hash_mismatch`), and its
|
|
136
|
+
`signedHashAlgorithm` is REQUIRED and is the fixed label
|
|
137
|
+
`sha256-canonical-module-hash`, the string the node writes; it is a label, not
|
|
138
|
+
a description of the hash (`unsupported_hash_algorithm`).
|
|
139
|
+
|
|
140
|
+
A signature with no `statementDomain` is one of the two forms removed in
|
|
141
|
+
0.11.0, and every verifier in this SDK refuses it by name, before the signer is
|
|
142
|
+
asked about: `legacy_module_signature` for the bare canonical module digest
|
|
143
|
+
(`signedHashAlgorithm` `sha256-canonical-module-hash` or absent) and
|
|
144
|
+
`legacy_bundle_signature` for the whole-bundle digest (`signedHashAlgorithm`
|
|
145
|
+
`sha256-sdn-module-bundle-v1`). No writer produces either, and
|
|
146
|
+
`signatureScope: "module"` or `"bundle"` is refused. A module signed in either
|
|
147
|
+
must be signed again.
|
|
128
148
|
|
|
129
149
|
The domain prefix exists because the node's publisher key is the NODE key, and
|
|
130
150
|
that one bonded key signs several unrelated kinds of statement (dataset
|
|
@@ -153,10 +173,12 @@ JavaScript's: Go trims U+0085 NEL and JS does not, JS trims U+FEFF BOM and Go
|
|
|
153
173
|
does not. Either mismatch is a "loads on the node, dies in the browser" split,
|
|
154
174
|
so both are pinned by vectors rather than left to each language's default.
|
|
155
175
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
176
|
+
The forms, the preimage bytes and every refusal reason are pinned as shared
|
|
177
|
+
cross-language vectors in `test/support/statement-domain-vectors.json`,
|
|
178
|
+
byte-identical to the node's copies, and asserted by the JS suite and both Go
|
|
179
|
+
suites. Four vectors, `legacy-bare-digest-no-domain` and the three
|
|
180
|
+
`bundle-scope-*`, are refused by this SDK where the file records the node's
|
|
181
|
+
verdict; the JS suite states those differences by name.
|
|
160
182
|
|
|
161
183
|
### `ENC` encrypted-delivery extension
|
|
162
184
|
|
|
@@ -125,8 +125,8 @@ space-data-module protect \
|
|
|
125
125
|
--wasm ./dist/module.wasm \
|
|
126
126
|
--key ./keys/module-signing-keypair.json \
|
|
127
127
|
--out ./dist/module.signed.wasm</code></pre></div>
|
|
128
|
-
<div class="table-wrap"><table><thead><tr><th>Flag</th><th>Required</th><th>Meaning</th></tr></thead><tbody><tr><td><code>--wasm <path></code></td><td>yes</td><td>Artifact to sign</td></tr><tr><td><code>--key <path></code></td><td>yes</td><td>Keypair JSON; must contain <code>privateKeySeedHex</code></td></tr><tr><td><code>--out <path></code></td><td>no</td><td>Output path; otherwise the input is signed in place</td></tr></tbody></table></div>
|
|
129
|
-
<p>The key file must carry <code>privateKeySeedHex</code> or the command refuses. Output reports <code>signed</code>, <code>keyId</code>, <code>publicKeyHex</code>, and <code>canonicalModuleHashHex</code
|
|
128
|
+
<div class="table-wrap"><table><thead><tr><th>Flag</th><th>Required</th><th>Meaning</th></tr></thead><tbody><tr><td><code>--wasm <path></code></td><td>yes</td><td>Artifact to sign</td></tr><tr><td><code>--key <path></code></td><td>yes</td><td>Keypair JSON; must contain <code>privateKeySeedHex</code></td></tr><tr><td><code>--scope <form></code></td><td>no</td><td><code>publication</code>, the one form (the <code>SDN-MODULE-PUBLICATION-V1</code> statement over the bytes before the trailer) and the default. <code>module</code> and <code>bundle</code> are refused: those forms were removed in 0.11.0</td></tr><tr><td><code>--out <path></code></td><td>no</td><td>Output path; otherwise the input is signed in place</td></tr></tbody></table></div>
|
|
129
|
+
<p>The key file must carry <code>privateKeySeedHex</code> or the command refuses. Output reports <code>signed</code>, <code>keyId</code>, <code>publicKeyHex</code>, <code>signatureScope</code>, <code>statementDomain</code>, <code>signedHashHex</code> and <code>canonicalModuleHashHex</code>. Any previous signature entry is replaced, whatever its form. The form is defined in <a href="./module-publication-standard.html">the publication standard</a>.</p>
|
|
130
130
|
<h2 id="verify"><a class="anchor" href="#verify" aria-hidden="true">#</a>Verify</h2>
|
|
131
131
|
<div class="codeblock"><div class="codeblock-head">sh</div><pre><code>space-data-module verify \
|
|
132
132
|
--wasm ./dist/module.wasm \
|
|
@@ -135,7 +135,7 @@ space-data-module protect \
|
|
|
135
135
|
<div class="codeblock"><div class="codeblock-head">sh</div><pre><code>space-data-module verify \
|
|
136
136
|
--wasm ./dist/module.wasm \
|
|
137
137
|
--key ./keys/module-signing-keypair.json</code></pre></div>
|
|
138
|
-
<p><code>--trusted</code> takes a comma-separated list of trusted public keys; <code>--key</code> reads <code>publicKeyHex</code> out of a keypair JSON instead. Signature requirement defaults to true. Output reports <code>verified</code>, <code>signed</code>, <code>
|
|
138
|
+
<p><code>--trusted</code> takes a comma-separated list of trusted public keys; <code>--key</code> reads <code>publicKeyHex</code> out of a keypair JSON instead. Signature requirement defaults to true. Output reports <code>verified</code>, <code>signed</code>, <code>signer</code> (<code>test</code> or <code>other</code>, from the verified key), <code>publicKeyHex</code>, <code>unsignedKeyId</code> (a label the file carries about itself) and <code>statementDomain</code>, the form verified; check <code>statementDomain</code>, not a scope. The process exits non-zero unless verification succeeded. An artifact signed in the bare module digest form is refused with <code>legacy_module_signature</code>, one in the whole-bundle form with <code>legacy_bundle_signature</code>; sign it again.</p>
|
|
139
139
|
<h2 id="key-custody"><a class="anchor" href="#key-custody" aria-hidden="true">#</a>Key custody</h2>
|
|
140
140
|
<p>Signing keys are HD-derived from a node's root identity by default; supplying an external key is an explicit opt-in. Never commit a private key or a mnemonic to a repository, and never paste one into a build log. The dev keypairs that appear in the SDK's own test fixtures are test material and are not valid for a published module.</p>
|
|
141
141
|
<h2 id="honest-gaps"><a class="anchor" href="#honest-gaps" aria-hidden="true">#</a>Honest gaps</h2>
|
package/docs/protect-and-sign.md
CHANGED
|
@@ -75,12 +75,14 @@ space-data-module sign \
|
|
|
75
75
|
| --- | --- | --- |
|
|
76
76
|
| `--wasm <path>` | yes | Artifact to sign |
|
|
77
77
|
| `--key <path>` | yes | Keypair JSON; must contain `privateKeySeedHex` |
|
|
78
|
+
| `--scope <form>` | no | `publication`, the one form (the `SDN-MODULE-PUBLICATION-V1` statement over the bytes before the trailer) and the default. `module` and `bundle` are refused: those forms were removed in 0.11.0 |
|
|
78
79
|
| `--out <path>` | no | Output path; otherwise the input is signed in place |
|
|
79
80
|
|
|
80
81
|
The key file must carry `privateKeySeedHex` or the command refuses. Output
|
|
81
|
-
reports `signed`, `keyId`, `publicKeyHex`,
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
reports `signed`, `keyId`, `publicKeyHex`, `signatureScope`, `statementDomain`,
|
|
83
|
+
`signedHashHex` and `canonicalModuleHashHex`. Any previous
|
|
84
|
+
signature entry is replaced, whatever its form. The form is defined in
|
|
85
|
+
[the publication standard](./module-publication-standard.md).
|
|
84
86
|
|
|
85
87
|
## Verify
|
|
86
88
|
|
|
@@ -99,8 +101,13 @@ space-data-module verify \
|
|
|
99
101
|
|
|
100
102
|
`--trusted` takes a comma-separated list of trusted public keys; `--key` reads
|
|
101
103
|
`publicKeyHex` out of a keypair JSON instead. Signature requirement defaults to
|
|
102
|
-
true. Output reports `verified`, `signed`, `
|
|
103
|
-
|
|
104
|
+
true. Output reports `verified`, `signed`, `signer` (`test` or `other`, from the
|
|
105
|
+
verified key), `publicKeyHex`, `unsignedKeyId` (a label the file carries about
|
|
106
|
+
itself) and `statementDomain`, the form verified; check `statementDomain`, not a
|
|
107
|
+
scope. The process exits non-zero unless
|
|
108
|
+
verification succeeded. An artifact signed in the bare module digest form is
|
|
109
|
+
refused with `legacy_module_signature`, one in the whole-bundle form with
|
|
110
|
+
`legacy_bundle_signature`; sign it again.
|
|
104
111
|
|
|
105
112
|
## Key custody
|
|
106
113
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "space-data-module-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Module SDK for building, validating, signing, and deploying WebAssembly modules on the Space Data Network.",
|
|
6
6
|
"type": "module",
|
|
@@ -93,7 +93,8 @@
|
|
|
93
93
|
"templates/"
|
|
94
94
|
],
|
|
95
95
|
"scripts": {
|
|
96
|
-
"test": "node scripts/flatsql-release-e2e.mjs",
|
|
96
|
+
"test": "node scripts/flatsql-release-e2e.mjs && npm run test:signatures",
|
|
97
|
+
"test:signatures": "node --test test/module-signature-forms.test.js test/module-signature-writer.test.js test/module-signing.test.js test/signature-policy-keys.test.js test/signature-entry-parsing.test.js test/signed-code-manifest.test.js test/code-manifest-not-run.test.js test/statement-domain-parity.test.js test/loader-verified-bytes.test.js test/flow-compiler.test.js test/isomorphic-flow-host.test.js",
|
|
97
98
|
"test:host-surfaces": "node --test test/node-host.test.js test/host-abi.test.js test/browser-host.test.js test/browser-module-harness.test.js test/testing-harness.test.js test/browser-owner-tls.test.js",
|
|
98
99
|
"test:runtime-matrix": "SPACE_DATA_MODULE_SDK_ENABLE_RUNTIME_MATRIX=1 node --test test/runtime-matrix.test.js",
|
|
99
100
|
"test:parity": "node --test test/parity-harness.test.js",
|