Expand description
C2PA manifest embedding, hard binding, and validation for structured text.
Implements the Embedding Manifests into Structured Text section of the C2PA Technical Specification, which associates a C2PA Manifest Store with source code, configuration files, markup, and other text formats that support comment syntax or front matter conventions.
The manifest block uses fixed ASCII armour-style delimiters:
-----BEGIN C2PA MANIFEST----- and -----END C2PA MANIFEST-----.
§Scope
This crate owns three things:
- Embed (
embed_manifest,embed_manifest_at_end,embed_front_matter) a reference or an inline manifest as a comment or front matter block. - Extract (
extract_manifest,classify_reference) the block and resolve its reference. - The hard binding (
hardbinding): the exactc2pa.hash.datacoverage over the normalized-free raw byte stream, with the manifest block excluded, plus compute and verify.
Signature verification, certificate trust, and assertion validation are
not implemented here; the bridge (feature c2pa) delegates them to
c2pa-rs.
§Features
hard-binding— concrete SHA2-256/384/512hardbinding::compute_data_hashandhardbinding::verify_data_hash(pullssha2). The exclusion-range and covered-byte primitives (hardbinding::manifest_exclusion,hardbinding::hashed_bytes) are always available and dependency-free.c2pa— thebridgetoc2pa-rsfor signature/trust/assertion validation.remote— HTTP(S) resolution of URL references in the bridge (pullsureq).wasm— JS/WASM bindings for the npm package (pullswasm-bindgen).python— Python bindings for the PyPI wheel (pullspyo3, built with maturin).
No feature is enabled by default; the core embed/extract/binding-range API has no dependencies.
Modules§
- bridge
- Validation bridge to
c2pa-rs. - hardbinding
- The hard binding for structured text.
Structs§
- Extraction
Result - The result of extracting a manifest block: the reference plus the byte offset and length of the block’s line(s) in the source text.
Enums§
- Error
- Manifest
Ref - A manifest reference to embed: either a URI to an external C2PA Manifest
Store (preferred) or the store itself, which is encoded as a
data:application/c2pa;base64,URI. - Reference
- A classified manifest reference: an external URI or an embedded C2PA Manifest
Store decoded from a
data:application/c2pa;base64,URI.
Functions§
- classify_
reference - Classify and resolve a reference string as extracted from a manifest block.
- embed_
front_ matter - Embed a manifest block in multi-line front matter form.
fm_delimis the host format’s front matter fence (---for YAML,+++for TOML). - embed_
manifest - Embed a manifest block as the first line of the file using single-line comment syntax. This is the recommended placement.
- embed_
manifest_ at_ end - Embed a manifest block as the last line of the file. Use this when the first
line is reserved by the host format (a shebang
#!/...or an XML declaration<?xml ...?>), so the-----END C2PA MANIFEST-----delimiter appears on the final line as the specification requires. - extract_
manifest - Locate and extract the single manifest block from structured text.