@@ -13,7 +13,7 @@ language package ecosystems used around the SDK runtime surface:
1313
1414The goal is simple: a loader should be able to inspect a package, locate the
1515module artifact, and determine whether signatures or encrypted transport
16- metadata are appended as SDS publication records after the module bytes or
16+ metadata are appended as SDS publication records in the module delivery file or
1717shipped as sidecar FlatBuffers.
1818
1919## Scope
@@ -28,7 +28,8 @@ In both cases the module artifact remains the same canonical format already
2828defined by this repo:
2929
3030- a runtime payload that is valid WebAssembly bytes once any SDS publication
31- trailer has been stripped
31+ trailer has been stripped and any encrypted delivery payload has been
32+ decrypted
3233- embedded ` PluginManifest.fbs `
3334- manifest accessors
3435 - ` plugin_get_manifest_flatbuffer `
@@ -37,16 +38,20 @@ defined by this repo:
3738
3839## Core Rules
3940
40- 1 . The runtime payload before any publication trailer MUST remain valid ` .wasm ` .
41- 2 . If signatures or encrypted-delivery metadata are carried in the same file,
42- they MUST be appended after the wasm bytes as an SDS ` REC ` trailer.
43- 3 . ` REC ` trailers MUST carry standards-sourced ` MBL ` metadata plus ` PNM ` and
41+ 1 . A signed-only or unencrypted artifact payload before any publication trailer
42+ MUST remain valid ` .wasm ` .
43+ 2 . An encrypted binary delivery file MUST be encoded as encrypted payload bytes
44+ followed by an appended SDS ` REC ` trailer. The bytes before the trailer are
45+ ciphertext and are not required to validate as wasm until decrypted.
46+ 3 . If bundle, signature, or encrypted-delivery metadata are carried in the same
47+ file, they MUST be appended as an SDS ` REC ` trailer at the end of that file.
48+ 4 . ` REC ` trailers MUST carry standards-sourced ` MBL ` metadata plus ` PNM ` and
4449 optional ` ENC ` records where applicable.
45- 4 . Single-file bundle metadata MUST be read from the appended ` REC ` trailer,
50+ 5 . Single-file bundle metadata MUST be read from the appended ` REC ` trailer,
4651 not from an in-wasm custom section.
47- 5 . Sidecar FlatBuffers are allowed when a package chooses not to append those
52+ 6 . Sidecar FlatBuffers are allowed when a package chooses not to append those
4853 metadata payloads to the module artifact.
49- 6 . Paths in publication metadata are package-relative, never absolute.
54+ 7 . Paths in publication metadata are package-relative, never absolute.
5055
5156## Publication Record Extensions
5257
@@ -76,6 +81,25 @@ The runtime-facing rule stays strict:
7681` MBL ` , ` PNM ` , and ` ENC ` extend publication and transport handling only. They do
7782not change the canonical module ABI or manifest exports.
7883
84+ ## Protected Binary Layout
85+
86+ The official same-file protection layout is:
87+
88+ ``` text
89+ protected-payload-bytes || REC-flatbuffer-bytes || uint32le(REC length) || "$REC"
90+ ```
91+
92+ For signed-only delivery, ` protected-payload-bytes ` are the wasm bytes. For
93+ encrypted delivery, ` protected-payload-bytes ` are ciphertext and the appended
94+ ` REC ` MUST contain an ` ENC ` record with the decryption parameters. Loaders MUST
95+ decrypt those ciphertext bytes before attempting wasm validation, manifest
96+ inspection, or bundle metadata parsing.
97+
98+ The ` PNM ` content identity applies to the protected payload bytes as stored in
99+ the file. For encrypted delivery this means the ` PNM.CID ` identifies the
100+ ciphertext payload, while the decrypted bytes remain the canonical wasm module
101+ that is passed to the runtime.
102+
79103### ` PNM ` digital-signature extension
80104
81105` PNM ` carries the publication notice for the module:
@@ -437,15 +461,16 @@ A loader consuming this standard SHOULD:
4374612 . read ` module.path `
4384623 . scan the artifact from the end for an appended SDS ` REC ` trailer
4394634 . resolve ` PNM ` / ` ENC ` from that trailer before runtime startup
440- 5 . if ` ENC ` is present, decrypt and strip the trailer before passing bytes to
441- WasmEdge or any other runtime
442- 6 . inspect the stripped artifact's ` REC ` trailer for ` MBL `
443- 7 . resolve any ` package-file ` metadata through relative paths
444- 8 . validate manifest exports and any declared integrity hashes
445-
446- If ` module.packaging ` is ` sds-bundled-wasm ` , loaders SHOULD treat the stripped
447- wasm payload as the runtime artifact and the appended ` REC ` trailer as the
448- single-file bundle/publication metadata container.
464+ 5 . if ` ENC ` is present, decrypt the protected payload bytes before passing bytes
465+ to WasmEdge or any other runtime
466+ 6 . if ` ENC ` is absent, strip the trailer and use the remaining wasm payload
467+ 7 . inspect the parsed ` REC ` trailer for ` MBL `
468+ 8 . resolve any ` package-file ` metadata through relative paths
469+ 9 . validate manifest exports and any declared integrity hashes
470+
471+ If ` module.packaging ` is ` sds-bundled-wasm ` , loaders SHOULD treat the decrypted
472+ or stripped wasm payload as the runtime artifact and the appended ` REC ` trailer
473+ as the single-file bundle/publication metadata container.
449474
450475## Relationship To Existing Bundle Format
451476
0 commit comments