Expand description
Plugin signature & integrity verification (ADR-162, P4).
ADR-161/B5 honestly relabelled the manifest’s wasm_module_hash /
wasm_module_sig / publisher_key fields as “(P4 — not yet enforced)”:
they were parsed and round-tripped but never checked before a plugin
ran. This module makes that claim TRUE — it is the real verification gate
the plugin load path runs before instantiating any .wasm module.
§What is verified, in order
- Module hash — SHA-256 of the actual
.wasmbytes must equal the manifest’swasm_module_hash(sha256:<hex>). A tampered module (one byte changed) fails here. - Ed25519 signature —
wasm_module_sig(ed25519:<base64>, 64-byte raw signature) must verify over the 32-byte SHA-256 digest under thepublisher_key(ed25519:<base64>, 32-byte raw verifying key). - Trust policy — the
publisher_keymust be on the configured allowlist, unlessPluginPolicy::AllowUnsignedis in force (a loud dev escape hatch).
The crypto mirrors the in-repo Ed25519 pattern from
cog-ha-matter::witness_signing (same ed25519-dalek 2.x API, same
deterministic-test-key convention). SHA-256 matches the sha256: prefix
the manifest doc already declared for wasm_module_hash, and the
cog-ha-matter cog manifest’s binary_sha256 hex convention.
§Secure default
PluginPolicy::trusted (the production constructor) rejects:
- an unsigned module (no hash / sig / key),
- a signature from a key not on the allowlist,
- any hash or signature mismatch.
Only PluginPolicy::AllowUnsigned loosens this, and every load it
waves through emits a warn-level log line so it cannot pass silently.
Enums§
- Plugin
Policy - Trust policy governing which plugins may load.
Functions§
- encode_
sha256 - Encode a SHA-256 digest as the manifest
sha256:<hex>form. Exposed so tooling (and tests) can produce a manifest hash for real.wasmbytes. - encode_
signature - Encode an Ed25519 signature as the manifest
ed25519:<base64>form. - encode_
verifying_ key - Encode an Ed25519 verifying key as the manifest
ed25519:<base64>form. - verify_
module - Verify a
.wasmmodule’s integrity and signature against its manifest, under the given trustpolicy. ReturnsOk(())only if the module may be instantiated.