#[non_exhaustive]pub struct KernelManifest {
pub name: String,
pub version: String,
pub sm_version: u32,
pub digest: [u8; 32],
pub signature: [u8; 32],
pub published_unix_ms: u64,
pub publisher: String,
pub launch_geometry: Option<(u32, u32)>,
}Expand description
Signed kernel manifest. Cargo for vetted PTX.
Marked #[non_exhaustive] so future revisions can add fields
without breaking downstream pattern-matching consumers. Construct
instances via KernelManifest::new from outside this crate (the
non_exhaustive attribute disallows struct-literal construction
from foreign crates).
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: StringStable name (e.g. "matmul.f32").
version: StringSemVer-style version ("1.0.0").
sm_version: u32Compute capability the PTX was built for (e.g. 80 for sm_80).
digest: [u8; 32]BLAKE3 hash of the PTX text. Content-addresses the artifact.
signature: [u8; 32]HMAC-SHA256 tag computed over the canonical signed-bytes of
this manifest — see the module-level docstring for the exact
envelope layout (v2). Covers name, version, publisher,
published_unix_ms, sm_version, and digest.
The tag is PUBLIC by design. It authenticates the
manifest’s authorship (i.e. proves the holder of the publishing
HMAC key produced it) but is NOT a private signature in the
asymmetric-crypto sense and MUST NOT be treated as a secret.
KernelManifest deliberately derives Serialize / Deserialize
and the field is pub so the tag travels with the manifest
over the wire and through storage — that is the intended,
audited behaviour, not an oversight.
What IS a secret is the HMAC key used to compute the tag (the
publisher’s signing key); see sign_manifest. Leaking the
signing key — not the tag — is what would let an attacker
forge manifests.
published_unix_ms: u64Wall-clock publish timestamp (Unix millis). Covered by the v2 signature envelope — tampering with this field invalidates the signature.
publisher: StringPublisher identifier (typically a tenant id or signing-key id). Covered by the v2 signature envelope — tampering with this field invalidates the signature.
launch_geometry: Option<(u32, u32)>Optional launch geometry hint (grid_size, block_size) the
kernel expects, mirroring EmittedPtx::launch_geometry on the
freshly-emitted path. Used by the JIT L3 registry-promotion path
(KernelCache::get_with_registry_fallback) to populate the
promoted L1 entry’s geometry instead of falling back to (0, 0).
Deliberately NOT covered by the v2 signature envelope.
Launch geometry is an advisory launch hint, not a security
boundary — the PTX content itself is authenticated by digest
(and transitively by the signature, which binds digest). Folding
geometry into KernelManifest::canonical_signed_bytes would
invalidate every previously-signed twasm-kmf-v2 blob (a magic
bump to -v3 plus a dual-version verify path) for no security
gain, so it is carried as an unsigned hint instead. A bad actor
who could rewrite this field could at worst mis-hint a launch grid
for a kernel whose code is already separately authenticated.
#[serde(default)] makes manifests serialized before this field
existed deserialize cleanly (the field reads back as None), so
older on-disk blobs and wire payloads remain forward-compatible.
Implementations§
Source§impl KernelManifest
impl KernelManifest
Sourcepub fn new(
name: String,
version: String,
sm_version: u32,
digest: [u8; 32],
signature: [u8; 32],
published_unix_ms: u64,
publisher: String,
) -> Self
pub fn new( name: String, version: String, sm_version: u32, digest: [u8; 32], signature: [u8; 32], published_unix_ms: u64, publisher: String, ) -> Self
Construct a manifest from its component fields.
KernelManifest is #[non_exhaustive], so foreign crates cannot
build one via a struct literal — they must go through this
constructor. The signature field is typically left as
[0u8; 32] here and filled in afterwards by sign_manifest,
because the publisher’s HMAC key is what produces the
signature value.
The optional launch_geometry hint defaults to None; publishers
that know the kernel’s grid/block geometry chain
Self::with_launch_geometry after this constructor to set it.
Keeping this signature stable (geometry is set via the builder, not
a new positional argument) is intentional so the cross-crate
callers in tensor-wasm-cli / tensor-wasm-api and the integration
tests keep compiling unchanged.
Sourcepub fn with_launch_geometry(self, launch_geometry: Option<(u32, u32)>) -> Self
pub fn with_launch_geometry(self, launch_geometry: Option<(u32, u32)>) -> Self
Builder: attach an optional launch-geometry hint
(grid_size, block_size) to this manifest and return it.
This is the publisher-facing way to populate the
KernelManifest::launch_geometry field without widening
KernelManifest::new’s signature. Because geometry is carried
as an unsigned hint (see the field docs), this may be called
either before or after sign_manifest without affecting
signature verification — the canonical signed bytes do not include
it. Pass None to explicitly clear any previously-set hint.
Sourcepub fn digest_as_u64(&self) -> u64
pub fn digest_as_u64(&self) -> u64
First 8 bytes of digest interpreted as a little-endian u64.
Used as the synthetic fingerprint field on the CachedKernel
that the registry path promotes into L1.
Trait Implementations§
Source§impl Clone for KernelManifest
impl Clone for KernelManifest
Source§fn clone(&self) -> KernelManifest
fn clone(&self) -> KernelManifest
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for KernelManifest
impl Debug for KernelManifest
Source§impl<'de> Deserialize<'de> for KernelManifest
impl<'de> Deserialize<'de> for KernelManifest
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for KernelManifest
impl RefUnwindSafe for KernelManifest
impl Send for KernelManifest
impl Sync for KernelManifest
impl Unpin for KernelManifest
impl UnsafeUnpin for KernelManifest
impl UnwindSafe for KernelManifest
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more