Skip to main content

Crate c2pa_ml

Crate c2pa_ml 

Source
Expand description

C2PA manifest embedding for AI/ML model container formats.

A C2PA Manifest Store is associated with a model by writing it into the format’s own metadata slot, so the model stays loadable by its usual runtime:

  • GGUF (llama.cpp) — a c2pa:manifest key/value metadata entry (gguf).
  • SafeTensors — a c2pa:manifest entry in the JSON header’s __metadata__ (safetensors).
  • ONNX — a c2pa:manifest entry in the protobuf metadata_props (onnx).

A remote (or side-car) manifest can instead be referenced by URI under c2pa:manifest.uri, or both an embedded store and a URI can be written together (see ManifestSource).

The top-level functions auto-detect the format:

use c2pa_ml::{embed_manifest, read_manifest, ManifestSource};
let signed = embed_manifest(model, &ManifestSource::embedded(store))?;
let manifest = read_manifest(&signed)?;

§Asset type

The C2PA core specification defines no dedicated embedding method for model containers; a manifest embedded in a model declares what the asset is with the asset type assertion. Format::model_type and asset_type::ModelType provide the canonical c2pa.types.model.* strings for that assertion.

§Scope

This crate implements embedding and extraction only. Manifest construction, signing, and content (hard/soft) binding are out of scope; use the official C2PA SDK to build and sign manifests. The c2pa.hash.data assertion should exclude the metadata region carrying the Manifest Store.

Zero dependencies on native targets; the WebAssembly/npm build uses only wasm-bindgen.

Re-exports§

pub use asset_type::ModelType;

Modules§

asset_type
The C2PA asset type values for AI/ML assets, from Table 11 (“Asset type values”) of the C2PA Technical Specification.
binding
The c2pa.hash.data hard binding for ML model containers.
gguf
GGUF (the llama.cpp model container) embedding.
onnx
ONNX embedding.
safetensors
SafeTensors embedding.

Structs§

ManifestSource
What to associate with a model: an embedded Manifest Store, a remote manifest URI, or both.
Report
A report on a model’s C2PA embedding.

Enums§

Error
Errors returned by the crate.
Format
A supported ML model container format.

Functions§

embed_manifest
Embed a C2PA manifest into a model, auto-detecting the container format.
embed_manifest_as
Embed a C2PA manifest into a model of a known format.
read_manifest
Read the embedded C2PA Manifest Store from a model, auto-detecting the format.
read_manifest_uri
Read the remote manifest URI from a model, if present, auto-detecting the format.
remove_manifest
Remove any C2PA metadata from a model, auto-detecting the format.
verify
Report on a model’s C2PA embedding, auto-detecting the format.