Skip to content

wasmtime host: from_material — Rust-held keys as typed handles (#395) - #396

Merged
lann merged 1 commit into
mainfrom
wasmtime-embedder-keys
Aug 23, 2026
Merged

wasmtime host: from_material — Rust-held keys as typed handles (#395)#396
lann merged 1 commit into
mainfrom
wasmtime-embedder-keys

Conversation

@lannbot

@lannbot lannbot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Closes #395.

The native parity for the #392 seams: per-kind constructors on the wasmtime host that place embedder-held signature key material in the store's resource table as typed handles — SigningKey::from_material(view, SigningKeyMaterial) and VerifyingKey::from_material(view, SigPublic). No WIT change, no guest-visible change: host-implementation API, like the polyengine seam. Unblocks polyvisor's engine-host filling its app-owned device-identity import (bindgen! with-maps the signature resources onto these types; the returned Resource<_> is what its import hands the guest).

Mechanics

  • Same table, same accounting as a mint: the constructor charges the retention pool (floor-only for these kinds) and the reservation travels in the resource, releasing when it leaves the table. An exhausted budget reports the same recoverable other condition a guest mint does.
  • Kind validated at the wrap by construction: unlike a CryptoKey, SigningKeyMaterial/SigPublic carry every binding losslessly — algorithm, ECDSA curve/digest, PSS salt, policy — so the polyengine seam's family-refusal matrix has nothing to refuse here. Every family the core can represent injects; the existing getters answer from the supplied material and policy.
  • SigningKeyMaterial, SigPublic, SigningPolicy, and the core Error are re-exported so embedders build material without a version-locked direct dependency on the core crate.

Co-dependent core change (the seam makes the gap reachable): import_ed25519_seed and import_ecdsa_scalar were the only public material constructors skipping the at-least-one-usage mint check — both also cited WIT functions that no longer exist. They now enforce check_useful like every sibling, so injection cannot admit a usage-less key the WIT mints refuse (the polyengine seam's not-permitted refusal, relocated to material construction). No guest-visible effect: every WIT path already checked before reaching them.

Scope: signing/verifying now (the blocked consumer); derivation kinds on demand, mirroring the browser seam's v1.

Gates: just fmt-check, just clippy, just test (new core refusal tests, embedder_key_tests — getter/sign-verify round trip through injected handles, retention-pool parity with delete-readmits — and the runnable doctest), just rust-docs warning-free.

@lann
lann merged commit c21adf0 into main Aug 23, 2026
10 checks passed
@lann
lann deleted the wasmtime-embedder-keys branch August 23, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wasmtime host: Rust-held keys as typed handles — native parity for the #392 seams

2 participants