Skip to main content

KernelManifest

Struct KernelManifest 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§name: String

Stable name (e.g. "matmul.f32").

§version: String

SemVer-style version ("1.0.0").

§sm_version: u32

Compute 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: u64

Wall-clock publish timestamp (Unix millis). Covered by the v2 signature envelope — tampering with this field invalidates the signature.

§publisher: String

Publisher 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

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> KernelManifest

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for KernelManifest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for KernelManifest

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for KernelManifest

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts 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>

Converts 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)

Converts &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)

Converts &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
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more