space-data-module-sdk 0.13.0 → 0.14.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 +2 -1
- package/docs/_shell/consumer-assets.html +1 -1
- package/docs/assets/sdn-chrome/sdn-chrome.js +7 -3
- package/docs/assets/vendor/sdn-stack-nav/{1.2.0/sdn-stack-nav.ba268c55a1551bcacc390ac01347c319335a1660787b55b4b239df00fc3c1a4c.js → 1.3.0/sdn-stack-nav.2e5d4efc654388c85b79e53b1b148268e4083d9252f2a367ea257ccb50d270cd.js} +5 -0
- package/docs/browser-wasmedge-isomorphic.html +1 -1
- package/docs/byo-wasm-quickstart.html +1 -1
- package/docs/conformance.html +1 -1
- package/docs/events-abi.html +1 -1
- package/docs/families/analytics.html +1 -1
- package/docs/families/attitude.html +1 -1
- package/docs/families/behavior.html +1 -1
- package/docs/families/breakup.html +1 -1
- package/docs/families/conjunction.html +1 -1
- package/docs/families/data-source.html +2 -2
- package/docs/families/effects.html +1 -1
- package/docs/families/environment.html +1 -1
- package/docs/families/estimation.html +1 -1
- package/docs/families/gnc.html +1 -1
- package/docs/families/maneuver.html +1 -1
- package/docs/families/obstruction.html +1 -1
- package/docs/families/propagator.html +1 -1
- package/docs/families/propulsion.html +1 -1
- package/docs/families/reentry.html +1 -1
- package/docs/families/rf.html +1 -1
- package/docs/families/scheduler.html +1 -1
- package/docs/families/sensor.html +1 -1
- package/docs/families/signature.html +1 -1
- package/docs/flatsql-host-contract.html +1 -1
- package/docs/flatsql-streaming-standard.html +1 -1
- package/docs/gpu-module-abi.html +1 -1
- package/docs/index.html +1 -1
- package/docs/isomorphic-pthreads.html +1 -1
- package/docs/isomorphic-sdn-runtime-plan.html +1 -1
- package/docs/language-runtime-matrix.html +1 -1
- package/docs/module-bundle-runtime-plan.html +1 -1
- package/docs/module-publication-standard.html +10 -7
- package/docs/module-publication-standard.md +25 -11
- package/docs/node-red-default-node-parity.html +1 -1
- package/docs/protect-and-sign.html +9 -7
- package/docs/protect-and-sign.md +39 -9
- package/docs/protocol-installation.html +1 -1
- package/docs/provider-access-abi.md +7 -1
- package/docs/publication-submission.html +1 -1
- package/docs/secrets-capability.html +1 -1
- package/docs/testing-harness.html +1 -1
- package/docs/tri-runtime-parity-gate.html +1 -1
- package/docs/tri-runtime-parity.html +1 -1
- package/package.json +4 -4
- package/src/bundle/sdkTestSigner.js +41 -0
- package/src/bundle/sigdomain.js +2 -2
- package/src/bundle/signing.js +214 -36
- package/src/compiler/compileModule.js +4 -2
- package/src/flow/flowCompiler.js +7 -4
- package/src/generated/spacedatastandards/plg/PLG.d.ts +15 -3
- package/src/generated/spacedatastandards/plg/PLG.d.ts.map +1 -1
- package/src/generated/spacedatastandards/plg/PLG.js +18 -6
- package/src/generated/spacedatastandards/plg/PLG.ts +31 -6
- package/src/host/browserHost.js +56 -6
- package/src/host/hostWorkerBundleSources.js +3 -3
- package/src/host/nodeHost.js +60 -3
- package/src/host/providerAccessAbi.js +17 -3
- package/src/host/providerAccessFixtureAdapter.js +14 -4
- package/src/host/providerAccessTileStoreAdapter.js +5 -1
- package/src/index.d.ts +61 -12
- package/src/licensing/records.js +18 -0
- package/src/manifest/plgCodec.js +22 -0
- package/src/transport/index.js +7 -0
- package/src/transport/pki.js +331 -172
- package/src/transport/records.js +98 -24
- package/src/utils/encoding.js +57 -2
- package/src/utils/wasmCrypto.js +187 -0
- /package/docs/assets/vendor/sdn-stack-nav/{1.2.0 → 1.3.0}/sdn-stack-nav.36a36359ce18322185e9ff179f88175bab67d5ad84a14d9c08a54f2ff27267e7.css +0 -0
package/src/host/nodeHost.js
CHANGED
|
@@ -26,6 +26,8 @@ import {
|
|
|
26
26
|
ed25519PublicKey,
|
|
27
27
|
ed25519Sign,
|
|
28
28
|
ed25519Verify,
|
|
29
|
+
mldsa65Sign,
|
|
30
|
+
x25519Mlkem768Decapsulate,
|
|
29
31
|
hkdfBytes,
|
|
30
32
|
secp256k1PublicKey,
|
|
31
33
|
secp256k1SignDigest,
|
|
@@ -2481,7 +2483,6 @@ export class NodeHost {
|
|
|
2481
2483
|
plaintext: toUint8Array(options.plaintext),
|
|
2482
2484
|
recipientPublicKey: toUint8Array(options.recipientPublicKey),
|
|
2483
2485
|
context: options.context,
|
|
2484
|
-
senderKeyPair: options.senderKeyPair,
|
|
2485
2486
|
}),
|
|
2486
2487
|
),
|
|
2487
2488
|
decryptFromEnvelope: async (options = {}) =>
|
|
@@ -2623,8 +2624,10 @@ export class NodeHost {
|
|
|
2623
2624
|
|
|
2624
2625
|
// keyslot.sign performs a host-side signature over a guest-supplied
|
|
2625
2626
|
// payload using the named slot's private key. Request:
|
|
2626
|
-
// {slotId, payload: base64, algorithm?: "ed25519" | "secp256k1"}
|
|
2627
|
-
// algorithm defaults to "ed25519".
|
|
2627
|
+
// {slotId, payload: base64, algorithm?: "ed25519" | "secp256k1" | "ml-dsa-65"}
|
|
2628
|
+
// algorithm defaults to "ed25519". "ml-dsa-65" signs with pure ML-DSA-65
|
|
2629
|
+
// (FIPS 204, deterministic, empty context) from a 32-byte seed slot; the
|
|
2630
|
+
// response signature is the raw 3309-byte signature. Response:
|
|
2628
2631
|
// {signature: base64, algorithm}
|
|
2629
2632
|
// The slot's key material never appears in the response. Mirrors
|
|
2630
2633
|
// handleKeyslotSign() in keyslot.go.
|
|
@@ -2645,6 +2648,14 @@ export class NodeHost {
|
|
|
2645
2648
|
return { signature: bytesToBase64(signature), algorithm: "ed25519" };
|
|
2646
2649
|
}
|
|
2647
2650
|
|
|
2651
|
+
if (algorithm === "ml-dsa-65") {
|
|
2652
|
+
if (keyMaterial.length !== 32) {
|
|
2653
|
+
throw new Error(`keyslot "${slotId}" is not a 32-byte ml-dsa-65 seed`);
|
|
2654
|
+
}
|
|
2655
|
+
const signature = await mldsa65Sign(payload, keyMaterial);
|
|
2656
|
+
return { signature: bytesToBase64(signature), algorithm: "ml-dsa-65" };
|
|
2657
|
+
}
|
|
2658
|
+
|
|
2648
2659
|
if (algorithm === "secp256k1") {
|
|
2649
2660
|
if (keyMaterial.length !== 32) {
|
|
2650
2661
|
throw new Error(
|
|
@@ -2672,9 +2683,34 @@ export class NodeHost {
|
|
|
2672
2683
|
// Response: {plaintext: base64}. Mirrors handleKeyslotUnwrap() in
|
|
2673
2684
|
// keyslot.go, including the wire format where `ciphertext` is
|
|
2674
2685
|
// (ciphertext || 16-byte GCM tag), per Go's crypto/cipher.GCM convention.
|
|
2686
|
+
//
|
|
2687
|
+
// algorithm "x25519-ml-kem-768" unwraps a payload sealed to the slot's
|
|
2688
|
+
// hybrid X25519+ML-KEM-768 public key instead: the slot holds the 96-byte
|
|
2689
|
+
// hybrid seed, the request adds kemCiphertext (base64, 1088 B), and the
|
|
2690
|
+
// shared secret is the X-Wing decapsulation (Go 1.26
|
|
2691
|
+
// crypto/hpke.MLKEM768X25519()); HKDF info and GCM layout are unchanged.
|
|
2675
2692
|
async #keyslotUnwrap(params = {}) {
|
|
2676
2693
|
const slotId = assertNonEmptyString(params.slotId, "slotId");
|
|
2677
2694
|
const keyMaterial = await this.#resolveKeySlotMaterial(slotId);
|
|
2695
|
+
const unwrapAlgorithm = String(params.algorithm ?? "").trim() || "x25519";
|
|
2696
|
+
if (unwrapAlgorithm === "x25519-ml-kem-768") {
|
|
2697
|
+
const { nonce, ciphertext, tag, ephemeralPublicKey } = splitKeyslotUnwrapParams(params);
|
|
2698
|
+
const sharedSecret = await x25519Mlkem768Decapsulate(keyMaterial, {
|
|
2699
|
+
x25519EphemeralPublicKey: ephemeralPublicKey,
|
|
2700
|
+
kemCiphertext: base64ToBytes(String(params.kemCiphertext ?? "")),
|
|
2701
|
+
});
|
|
2702
|
+
const aesKey = await hkdfBytes(
|
|
2703
|
+
sharedSecret,
|
|
2704
|
+
new Uint8Array(),
|
|
2705
|
+
textEncoder.encode(KEYSLOT_UNWRAP_HKDF_INFO),
|
|
2706
|
+
32,
|
|
2707
|
+
);
|
|
2708
|
+
const plaintext = await aesGcmDecrypt(aesKey, ciphertext, tag, nonce);
|
|
2709
|
+
return { plaintext: bytesToBase64(plaintext) };
|
|
2710
|
+
}
|
|
2711
|
+
if (unwrapAlgorithm !== "x25519") {
|
|
2712
|
+
throw new Error(`unsupported keyslot.unwrap algorithm: ${unwrapAlgorithm}`);
|
|
2713
|
+
}
|
|
2678
2714
|
if (keyMaterial.length !== 32) {
|
|
2679
2715
|
throw new Error(
|
|
2680
2716
|
`keyslot "${slotId}" is not a 32-byte x25519 private key`,
|
|
@@ -2715,6 +2751,27 @@ export class NodeHost {
|
|
|
2715
2751
|
}
|
|
2716
2752
|
}
|
|
2717
2753
|
|
|
2754
|
+
// The keyslot.unwrap wire fields shared by both unwrap algorithms:
|
|
2755
|
+
// ephemeralPublicKey, nonce and ciphertext (ciphertext || 16-byte GCM tag).
|
|
2756
|
+
function splitKeyslotUnwrapParams(params) {
|
|
2757
|
+
const ephemeralPublicKey = base64ToBytes(String(params.ephemeralPublicKey ?? ""));
|
|
2758
|
+
const nonce = base64ToBytes(String(params.nonce ?? ""));
|
|
2759
|
+
const wireCiphertext = base64ToBytes(String(params.ciphertext ?? ""));
|
|
2760
|
+
if (ephemeralPublicKey.length === 0 || wireCiphertext.length === 0) {
|
|
2761
|
+
throw new Error("keyslot.unwrap requires ephemeralPublicKey and ciphertext");
|
|
2762
|
+
}
|
|
2763
|
+
if (wireCiphertext.length < 16) {
|
|
2764
|
+
throw new Error("keyslot.unwrap ciphertext is too short to contain a GCM tag");
|
|
2765
|
+
}
|
|
2766
|
+
const tagStart = wireCiphertext.length - 16;
|
|
2767
|
+
return {
|
|
2768
|
+
ephemeralPublicKey,
|
|
2769
|
+
nonce,
|
|
2770
|
+
ciphertext: wireCiphertext.subarray(0, tagStart),
|
|
2771
|
+
tag: wireCiphertext.subarray(tagStart),
|
|
2772
|
+
};
|
|
2773
|
+
}
|
|
2774
|
+
|
|
2718
2775
|
export function createNodeHost(options = {}) {
|
|
2719
2776
|
return new NodeHost(options);
|
|
2720
2777
|
}
|
|
@@ -161,10 +161,25 @@ export function encodingLayout(encoding) {
|
|
|
161
161
|
* Defined HERE, once, and shared by every adapter: if the browser and the host
|
|
162
162
|
* tile store chose levels by their own arithmetic they would sample different
|
|
163
163
|
* ground and byte parity would be lost for a reason no one could see.
|
|
164
|
+
*
|
|
165
|
+
* The rule is the same on every body, at the body's own size: the caller
|
|
166
|
+
* states `options.circumference`, the equatorial circumference in metres of
|
|
167
|
+
* the body the tiles are on (providerCircumference). There is no default
|
|
168
|
+
* body: on the Moon, 3.67 times smaller than Earth, an Earth-sized rule lands
|
|
169
|
+
* two levels deeper than the spacing asks for.
|
|
164
170
|
*/
|
|
165
|
-
export
|
|
171
|
+
export function providerCircumference(equatorialRadiusMeters) {
|
|
172
|
+
return 2 * Math.PI * equatorialRadiusMeters;
|
|
173
|
+
}
|
|
166
174
|
|
|
167
175
|
export function providerLevelForSpacing(spacingMeters, options = {}) {
|
|
176
|
+
const circumference = Number(options.circumference);
|
|
177
|
+
if (!Number.isFinite(circumference) || circumference <= 0) {
|
|
178
|
+
throw new ProviderAccessError(
|
|
179
|
+
ProviderError.INVALID_REQUEST,
|
|
180
|
+
"A spacing is resolved to a level on a stated body: options.circumference (metres around its equator) is required.",
|
|
181
|
+
);
|
|
182
|
+
}
|
|
168
183
|
const tileWidth = Math.max(2, options.tileWidth ?? 65);
|
|
169
184
|
const maxLevel = options.maxLevel ?? 20;
|
|
170
185
|
const minLevel = options.minLevel ?? 0;
|
|
@@ -175,8 +190,7 @@ export function providerLevelForSpacing(spacingMeters, options = {}) {
|
|
|
175
190
|
// Level L has 2^(L+1) tiles around the equator, each covering
|
|
176
191
|
// (tileWidth - 1) sample intervals.
|
|
177
192
|
const tilesAcross = Math.pow(2, level + 1);
|
|
178
|
-
const levelSpacing =
|
|
179
|
-
PROVIDER_EARTH_CIRCUMFERENCE_METERS / (tilesAcross * (tileWidth - 1));
|
|
193
|
+
const levelSpacing = circumference / (tilesAcross * (tileWidth - 1));
|
|
180
194
|
if (levelSpacing <= spacing) return level;
|
|
181
195
|
}
|
|
182
196
|
return maxLevel;
|
|
@@ -83,7 +83,9 @@ function tileRectangle(level, x, y) {
|
|
|
83
83
|
/**
|
|
84
84
|
* Level resolution goes through the SHARED helper so the fixture and any host
|
|
85
85
|
* tile store pick the same level for the same request. Divergence here would
|
|
86
|
-
* be invisible in a diff and fatal in a parity run.
|
|
86
|
+
* be invisible in a diff and fatal in a parity run. A fixture answers a
|
|
87
|
+
* spacing request on the body it was made for (options.circumference, metres
|
|
88
|
+
* around its equator); one made for no body refuses a spacing request.
|
|
87
89
|
*/
|
|
88
90
|
function resolveLevelInfo(request, options) {
|
|
89
91
|
return resolveRequestLevel(request, options);
|
|
@@ -176,7 +178,9 @@ export function createFixtureTerrainProvider(options = {}) {
|
|
|
176
178
|
},
|
|
177
179
|
|
|
178
180
|
acquireTile(request) {
|
|
179
|
-
const { level, strategyCode } = resolveLevel(request, defaultLevel
|
|
181
|
+
const { level, strategyCode } = resolveLevel(request, defaultLevel, {
|
|
182
|
+
circumference: options.circumference,
|
|
183
|
+
});
|
|
180
184
|
const x = request.x | 0;
|
|
181
185
|
const y = request.y | 0;
|
|
182
186
|
if (isVoid(level, x, y)) {
|
|
@@ -215,6 +219,7 @@ export function createFixtureTerrainProvider(options = {}) {
|
|
|
215
219
|
|
|
216
220
|
acquireProfile(request) {
|
|
217
221
|
const { level, strategyCode } = resolveLevel(request, defaultLevel, {
|
|
222
|
+
circumference: options.circumference,
|
|
218
223
|
tileWidth,
|
|
219
224
|
maxLevel,
|
|
220
225
|
mostDetailedLevel: maxLevel,
|
|
@@ -268,6 +273,7 @@ export function createFixtureTerrainProvider(options = {}) {
|
|
|
268
273
|
|
|
269
274
|
acquireRegion(request) {
|
|
270
275
|
const { level, strategyCode } = resolveLevel(request, defaultLevel, {
|
|
276
|
+
circumference: options.circumference,
|
|
271
277
|
tileWidth,
|
|
272
278
|
maxLevel,
|
|
273
279
|
mostDetailedLevel: maxLevel,
|
|
@@ -371,7 +377,9 @@ export function createFixtureImageryProvider(options = {}) {
|
|
|
371
377
|
},
|
|
372
378
|
|
|
373
379
|
acquireTile(request) {
|
|
374
|
-
const { level, strategyCode } = resolveLevel(request, defaultLevel
|
|
380
|
+
const { level, strategyCode } = resolveLevel(request, defaultLevel, {
|
|
381
|
+
circumference: options.circumference,
|
|
382
|
+
});
|
|
375
383
|
const x = request.x | 0;
|
|
376
384
|
const y = request.y | 0;
|
|
377
385
|
return {
|
|
@@ -391,7 +399,9 @@ export function createFixtureImageryProvider(options = {}) {
|
|
|
391
399
|
},
|
|
392
400
|
|
|
393
401
|
acquireRegion(request) {
|
|
394
|
-
const { level, strategyCode } = resolveLevel(request, defaultLevel
|
|
402
|
+
const { level, strategyCode } = resolveLevel(request, defaultLevel, {
|
|
403
|
+
circumference: options.circumference,
|
|
404
|
+
});
|
|
395
405
|
const [west, south, east, north] = request.rectangle ?? [0, 0, 0, 0];
|
|
396
406
|
const width = Math.max(1, request.width | 0);
|
|
397
407
|
const height = Math.max(1, request.height | 0);
|
|
@@ -64,9 +64,13 @@ export function createTileStoreTerrainProvider(options = {}) {
|
|
|
64
64
|
// Shared with every other adapter, so a spacing request resolves to the SAME
|
|
65
65
|
// level in the browser and on the host. Two adapters doing their own level
|
|
66
66
|
// arithmetic would sample different ground and lose byte parity for a reason
|
|
67
|
-
// no diff would show.
|
|
67
|
+
// no diff would show. The spacing rule is the body's own: the store states
|
|
68
|
+
// the equatorial circumference, in metres, of the body its tiles are on
|
|
69
|
+
// (options.circumference, providerCircumference); a spacing request on a
|
|
70
|
+
// store that states none is refused, never resolved on an assumed body.
|
|
68
71
|
function resolveLevel(request) {
|
|
69
72
|
return resolveRequestLevel(request, {
|
|
73
|
+
circumference: options.circumference,
|
|
70
74
|
tileWidth,
|
|
71
75
|
maxLevel,
|
|
72
76
|
minLevel: options.minLevel ?? 0,
|
package/src/index.d.ts
CHANGED
|
@@ -1192,12 +1192,52 @@ export interface EncryptedEnvelope {
|
|
|
1192
1192
|
recipientKeyIdBase64?: string | null;
|
|
1193
1193
|
encRecordBase64?: string | null;
|
|
1194
1194
|
pnmRecordBase64?: string | null;
|
|
1195
|
-
|
|
1196
|
-
|
|
1195
|
+
/** The $ENC KEM_CIPHERTEXT (1088-byte ML-KEM-768 ciphertext), base64. */
|
|
1196
|
+
kemCiphertextBase64?: string | null;
|
|
1197
1197
|
}
|
|
1198
1198
|
|
|
1199
1199
|
export function generateX25519Keypair(): Promise<X25519Keypair>;
|
|
1200
1200
|
|
|
1201
|
+
/** A protected-delivery recipient: privateKey is the 96-byte hybrid seed, publicKey 1216 bytes (X25519 || ML-KEM-768). */
|
|
1202
|
+
export interface X25519Mlkem768Keypair {
|
|
1203
|
+
privateKey: Uint8Array;
|
|
1204
|
+
publicKey: Uint8Array;
|
|
1205
|
+
}
|
|
1206
|
+
export function generateX25519Mlkem768Keypair(): Promise<X25519Mlkem768Keypair>;
|
|
1207
|
+
|
|
1208
|
+
export const PROTECTED_DELIVERY_SCHEME: "x25519-mlkem768-hkdf-aes-256-gcm-rec";
|
|
1209
|
+
export const REMOVED_PROTECTED_DELIVERY_SCHEMES: readonly string[];
|
|
1210
|
+
export const MARKETPLACE_KEY_WRAP_ALGORITHM: "X25519-MLKEM768-HKDF-SHA256-AES-256-GCM-KMF";
|
|
1211
|
+
|
|
1212
|
+
export class ProtectedDeliveryError extends Error {
|
|
1213
|
+
code:
|
|
1214
|
+
| "classical_delivery_refused"
|
|
1215
|
+
| "missing_enc_record"
|
|
1216
|
+
| "unsupported_key_exchange"
|
|
1217
|
+
| "unsupported_symmetric_algorithm"
|
|
1218
|
+
| "unsupported_key_derivation"
|
|
1219
|
+
| "invalid_enc_record"
|
|
1220
|
+
| "invalid_recipient_public_key"
|
|
1221
|
+
| "invalid_recipient_private_key"
|
|
1222
|
+
| "unsupported_key_wrap_algorithm"
|
|
1223
|
+
| "unsupported_delivery_scheme"
|
|
1224
|
+
| "invalid_envelope";
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
export type PublicKeyMaterialKind = "x25519-ml-kem-768" | "ml-dsa-65";
|
|
1228
|
+
export function encodePublicKeyMaterial(options: {
|
|
1229
|
+
kind: PublicKeyMaterialKind;
|
|
1230
|
+
keyId?: string;
|
|
1231
|
+
publicKey: Uint8Array | string;
|
|
1232
|
+
expiresAtMs?: number;
|
|
1233
|
+
}): Uint8Array;
|
|
1234
|
+
export function decodePublicKeyMaterial(bytes: Uint8Array): {
|
|
1235
|
+
kind: PublicKeyMaterialKind;
|
|
1236
|
+
keyId: string;
|
|
1237
|
+
publicKey: Uint8Array;
|
|
1238
|
+
expiresAtMs: number;
|
|
1239
|
+
};
|
|
1240
|
+
|
|
1201
1241
|
export interface MarketplaceArtifactBinding {
|
|
1202
1242
|
listingId: string;
|
|
1203
1243
|
moduleId: string;
|
|
@@ -1231,6 +1271,8 @@ export interface MarketplaceContentKeyWrap {
|
|
|
1231
1271
|
scope: string;
|
|
1232
1272
|
expiresAtMs: number;
|
|
1233
1273
|
providerEphemeralPublicKey: Uint8Array;
|
|
1274
|
+
/** 1088-byte ML-KEM-768 ciphertext of the hybrid encapsulation. */
|
|
1275
|
+
kemCiphertext: Uint8Array;
|
|
1234
1276
|
nonce: Uint8Array;
|
|
1235
1277
|
aad: Uint8Array;
|
|
1236
1278
|
ciphertext: Uint8Array;
|
|
@@ -1273,48 +1315,55 @@ export function protectMarketplaceContent(options: {
|
|
|
1273
1315
|
recipients: MarketplaceContentRecipient[];
|
|
1274
1316
|
contentKey?: Uint8Array | ArrayBuffer | ArrayBufferView | number[] | null;
|
|
1275
1317
|
contentNonce?: Uint8Array | ArrayBuffer | ArrayBufferView | number[] | null;
|
|
1276
|
-
|
|
1318
|
+
/** 64-byte encapsulation randomness, for known-answer tests only. */
|
|
1319
|
+
encapsulationSeed?: Uint8Array | null;
|
|
1277
1320
|
wrapNonce?: Uint8Array | ArrayBuffer | ArrayBufferView | number[] | null;
|
|
1278
1321
|
}): Promise<MarketplaceProtectedContent>;
|
|
1279
1322
|
|
|
1280
|
-
|
|
1281
|
-
|
|
1323
|
+
/** Resolves the 32-byte X-Wing shared secret behind the caller's custody boundary. */
|
|
1324
|
+
export type KeyDecapsulationProvider = (params: {
|
|
1325
|
+
keyExchange: "X25519_MLKEM768";
|
|
1326
|
+
x25519EphemeralPublicKey: Uint8Array;
|
|
1327
|
+
kemCiphertext: Uint8Array;
|
|
1282
1328
|
context: string;
|
|
1283
|
-
keyExchange: string;
|
|
1284
1329
|
}) => Promise<Uint8Array>;
|
|
1285
1330
|
|
|
1286
1331
|
export function decryptMarketplaceContentKeyWrap(options: {
|
|
1287
1332
|
wrap: MarketplaceContentKeyWrap;
|
|
1288
1333
|
recipientPrivateKey?: Uint8Array | ArrayBuffer | ArrayBufferView | number[] | string;
|
|
1289
|
-
|
|
1334
|
+
keyDecapsulation?: KeyDecapsulationProvider;
|
|
1290
1335
|
}): Promise<Uint8Array>;
|
|
1291
1336
|
|
|
1292
1337
|
export function encryptBytesForRecipient(options: {
|
|
1293
1338
|
plaintext: Uint8Array | ArrayBuffer;
|
|
1339
|
+
/** 1216-byte hybrid X25519+ML-KEM-768 public key; a 32-byte X25519 key is refused. */
|
|
1294
1340
|
recipientPublicKey: Uint8Array | string;
|
|
1295
1341
|
context?: string;
|
|
1296
|
-
senderKeyPair?: X25519Keypair;
|
|
1297
1342
|
recipientKeyId?: Uint8Array | ArrayBuffer | string | null;
|
|
1298
1343
|
schemaHash?: Uint8Array | ArrayBuffer | string | null;
|
|
1299
1344
|
rootType?: string | null;
|
|
1345
|
+
/** 64-byte encapsulation randomness, for known-answer tests only. */
|
|
1346
|
+
encapsulationSeed?: Uint8Array | null;
|
|
1347
|
+
nonceStart?: Uint8Array | null;
|
|
1348
|
+
timestamp?: number | null;
|
|
1300
1349
|
}): Promise<EncryptedEnvelope>;
|
|
1301
1350
|
|
|
1302
1351
|
export function decryptProtectedBytes(options: {
|
|
1303
1352
|
protectedBytes: Uint8Array | ArrayBuffer;
|
|
1304
1353
|
recipientPrivateKey?: Uint8Array | string;
|
|
1305
|
-
|
|
1354
|
+
keyDecapsulation?: KeyDecapsulationProvider;
|
|
1306
1355
|
}): Promise<Uint8Array>;
|
|
1307
1356
|
|
|
1308
1357
|
export function decryptBytesFromEnvelope(options: {
|
|
1309
1358
|
envelope: EncryptedEnvelope;
|
|
1310
|
-
recipientPrivateKey
|
|
1359
|
+
recipientPrivateKey?: Uint8Array | string;
|
|
1360
|
+
keyDecapsulation?: KeyDecapsulationProvider;
|
|
1311
1361
|
}): Promise<Uint8Array>;
|
|
1312
1362
|
|
|
1313
1363
|
export function encryptJsonForRecipient(options: {
|
|
1314
1364
|
payload: unknown;
|
|
1315
1365
|
recipientPublicKey: Uint8Array | string;
|
|
1316
1366
|
context?: string;
|
|
1317
|
-
senderKeyPair?: X25519Keypair;
|
|
1318
1367
|
}): Promise<EncryptedEnvelope>;
|
|
1319
1368
|
|
|
1320
1369
|
export function decryptJsonFromEnvelope(options: {
|
|
@@ -2312,9 +2361,9 @@ export class NodeHost {
|
|
|
2312
2361
|
): Promise<Uint8Array>;
|
|
2313
2362
|
encryptForRecipient(options: {
|
|
2314
2363
|
plaintext: Uint8Array | ArrayBuffer | ArrayBufferView | number[];
|
|
2364
|
+
/** 1216-byte hybrid X25519+ML-KEM-768 public key. */
|
|
2315
2365
|
recipientPublicKey: Uint8Array | ArrayBuffer | ArrayBufferView | number[];
|
|
2316
2366
|
context?: string;
|
|
2317
|
-
senderKeyPair?: X25519Keypair;
|
|
2318
2367
|
}): Promise<EncryptedEnvelope>;
|
|
2319
2368
|
decryptFromEnvelope(options: {
|
|
2320
2369
|
envelope: EncryptedEnvelope;
|
package/src/licensing/records.js
CHANGED
|
@@ -666,6 +666,17 @@ function encodeDecodedWrappedHeader(builder, header) {
|
|
|
666
666
|
header.schemaHash,
|
|
667
667
|
);
|
|
668
668
|
const rootTypeOffset = createOptionalString(builder, header.rootType);
|
|
669
|
+
// ENC 1.0.3: carried through unchanged when the header has them.
|
|
670
|
+
const kemCiphertextOffset = createOptionalVector(
|
|
671
|
+
builder,
|
|
672
|
+
ENC.createKemCiphertextVector,
|
|
673
|
+
header.kemCiphertext,
|
|
674
|
+
);
|
|
675
|
+
const authTagOffset = createOptionalVector(
|
|
676
|
+
builder,
|
|
677
|
+
ENC.createAuthTagVector,
|
|
678
|
+
header.authTag,
|
|
679
|
+
);
|
|
669
680
|
return ENC.createENC(
|
|
670
681
|
builder,
|
|
671
682
|
Number(header.version ?? 1),
|
|
@@ -679,6 +690,8 @@ function encodeDecodedWrappedHeader(builder, header) {
|
|
|
679
690
|
schemaHashOffset,
|
|
680
691
|
rootTypeOffset,
|
|
681
692
|
BigInt(header.timestamp ?? 0),
|
|
693
|
+
kemCiphertextOffset,
|
|
694
|
+
authTagOffset,
|
|
682
695
|
);
|
|
683
696
|
}
|
|
684
697
|
|
|
@@ -940,6 +953,9 @@ function normalizeKeyExchange(value) {
|
|
|
940
953
|
return KeyExchange.Secp256k1;
|
|
941
954
|
case "P256":
|
|
942
955
|
return KeyExchange.P256;
|
|
956
|
+
case "X25519_MLKEM768":
|
|
957
|
+
case "X25519-MLKEM768":
|
|
958
|
+
return KeyExchange.X25519_MLKEM768;
|
|
943
959
|
default:
|
|
944
960
|
return KeyExchange.X25519;
|
|
945
961
|
}
|
|
@@ -1045,6 +1061,8 @@ function keyExchangeName(value) {
|
|
|
1045
1061
|
return "Secp256k1";
|
|
1046
1062
|
case KeyExchange.P256:
|
|
1047
1063
|
return "P256";
|
|
1064
|
+
case KeyExchange.X25519_MLKEM768:
|
|
1065
|
+
return "X25519_MLKEM768";
|
|
1048
1066
|
default:
|
|
1049
1067
|
return `UNKNOWN_${value}`;
|
|
1050
1068
|
}
|
package/src/manifest/plgCodec.js
CHANGED
|
@@ -1601,6 +1601,25 @@ export function encodePlgManifest(manifest = {}) {
|
|
|
1601
1601
|
signatureBytes,
|
|
1602
1602
|
PLG.startSignatureVector,
|
|
1603
1603
|
);
|
|
1604
|
+
// PLG 1.0.19 SIGNATURE_ALGORITHM. A signed manifest always names its
|
|
1605
|
+
// algorithm; the default is pure ML-DSA-65 (FIPS 204), the one module
|
|
1606
|
+
// signature algorithm this SDK writes. An unsigned manifest names none.
|
|
1607
|
+
const declaredSignatureAlgorithm = pick(
|
|
1608
|
+
manifest,
|
|
1609
|
+
"signatureAlgorithm",
|
|
1610
|
+
"signature_algorithm",
|
|
1611
|
+
"SIGNATURE_ALGORITHM",
|
|
1612
|
+
);
|
|
1613
|
+
const signatureAlgorithmValue =
|
|
1614
|
+
typeof declaredSignatureAlgorithm === "string" &&
|
|
1615
|
+
declaredSignatureAlgorithm.trim() !== ""
|
|
1616
|
+
? declaredSignatureAlgorithm.trim().toLowerCase()
|
|
1617
|
+
: signatureOffset
|
|
1618
|
+
? "ml-dsa-65"
|
|
1619
|
+
: null;
|
|
1620
|
+
const signatureAlgorithmOffset = signatureAlgorithmValue
|
|
1621
|
+
? builder.createString(signatureAlgorithmValue)
|
|
1622
|
+
: 0;
|
|
1604
1623
|
|
|
1605
1624
|
const invokeSurfaces = pick(
|
|
1606
1625
|
manifest,
|
|
@@ -1813,6 +1832,8 @@ export function encodePlgManifest(manifest = {}) {
|
|
|
1813
1832
|
if (flowTriggersOffset) PLG.addFlowTriggers(builder, flowTriggersOffset);
|
|
1814
1833
|
if (flowTriggerBindingsOffset)
|
|
1815
1834
|
PLG.addFlowTriggerBindings(builder, flowTriggerBindingsOffset);
|
|
1835
|
+
if (signatureAlgorithmOffset)
|
|
1836
|
+
PLG.addSignatureAlgorithm(builder, signatureAlgorithmOffset);
|
|
1816
1837
|
const rootOffset = PLG.endPLG(builder);
|
|
1817
1838
|
PLG.finishPLGBuffer(builder, rootOffset);
|
|
1818
1839
|
return builder.asUint8Array();
|
|
@@ -2037,6 +2058,7 @@ export function decodePlgManifest(data) {
|
|
|
2037
2058
|
),
|
|
2038
2059
|
listingStatus: root.LISTING_STATUS(),
|
|
2039
2060
|
signature: root.signatureArray() ?? null,
|
|
2061
|
+
signatureAlgorithm: root.SIGNATURE_ALGORITHM() || undefined,
|
|
2040
2062
|
invokeSurfaces,
|
|
2041
2063
|
methods,
|
|
2042
2064
|
hostCapabilities,
|
package/src/transport/index.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
export {
|
|
2
2
|
createMarketplaceContentAad,
|
|
3
3
|
decryptProtectedBytes,
|
|
4
|
+
decodePublicKeyMaterial,
|
|
4
5
|
decryptPublicationRecordCollection,
|
|
5
6
|
decryptBytesFromEnvelope,
|
|
6
7
|
decryptMarketplaceContentKeyWrap,
|
|
7
8
|
decryptJsonFromEnvelope,
|
|
8
9
|
encryptBytesForRecipient,
|
|
10
|
+
encodePublicKeyMaterial,
|
|
9
11
|
encryptJsonForRecipient,
|
|
10
12
|
generateX25519Keypair,
|
|
13
|
+
generateX25519Mlkem768Keypair,
|
|
14
|
+
MARKETPLACE_KEY_WRAP_ALGORITHM,
|
|
15
|
+
ProtectedDeliveryError,
|
|
11
16
|
protectMarketplaceContent,
|
|
12
17
|
} from "./pki.js";
|
|
13
18
|
|
|
@@ -34,6 +39,8 @@ export {
|
|
|
34
39
|
extractPublicationRecordCollection,
|
|
35
40
|
MAX_RUNTIME_LOCK_TTL_DAYS,
|
|
36
41
|
MIN_RUNTIME_LOCK_TTL_DAYS,
|
|
42
|
+
PROTECTED_DELIVERY_SCHEME,
|
|
43
|
+
REMOVED_PROTECTED_DELIVERY_SCHEMES,
|
|
37
44
|
signBuildProfile,
|
|
38
45
|
stripPublicationRecordCollection,
|
|
39
46
|
TRAILER_FOOTER_LENGTH,
|