How contentauth/c2pa-min works
Project type and purpose
• This is a minimal command-line example application, written in Rust, demonstrating how to sign media assets using the C2PA Rust SDK without OpenSSL.
• It consists of two binaries:
– c2pa_min (main): orchestrates manifest building and external signing
– signer: a standalone signing tool that reads data from stdin, signs with a private key, and writes to stdout
File structure
• Cargo.toml / Cargo.lock: Rust project metadata and dependencies (including the C2PA Rust SDK)
• src/main.rs: Main application logic (calls into C2PA Builder & Reader API and invokes the signer)
• src/bin/signer.rs: Standalone signer binary that performs Ed25519 signing
• src/fixtures/: Contains test private key, public key, and certs used by the signer
• compose-dev.yaml, deny.toml, CI workflow: Auxiliary configuration for development, linting, and CI
Key insights from the README
• The main binary builds a C2PA manifest using the new API (Builder / Reader)
• It spawns the signer as a child process, passing payload bytes via stdin
• The signer returns the signed payload via stdout, keeping private keys out of the main process
• The application writes the signed output to a file (e.g., target/output.jpg)
Main components
a. c2pa_min (Main CLI App)
– Uses C2PA Rust SDK (Builder & Reader modules)
– Invokes signer as an external process
– Reads input asset, constructs manifest, writes output file
b. signer (External Signing App)
– Reads raw bytes from stdin
– Loads private key & certs from src/fixtures
– Uses Ed25519 algorithm to sign data
– Emits signed bytes to stdout
c. C2PA Rust Library
– Exposed in main app via Builder / Reader
– Responsible for packaging metadata into the asset
d. Fixtures (Private/Public Keys, Certificates)
– Stored under src/fixtures
– Accessed only by signer
e. Target/output.jpg (or other asset)
– Final signed asset, which can be verified by external tools
Relationships & data flows
1. User invokes c2pa_min CLI
2. c2pa_min reads original asset bytes
3. c2pa_min calls into C2PA Builder to generate a manifest and payload that needs signing
4. c2pa_min spawns signer process
– Passes payload bytes via stdin pipe
5. signer reads bytes → loads fixtures → signs bytes → writes signed bytes to stdout
6. c2pa_min reads signed bytes from stdout, finalizes the manifest, and writes the output asset to disk
7. The final asset can be validated later with OpenSSL-enabled tools or C2PA verification services
Architectural patterns & design principles
• Separation of concerns:
– Main app handles manifest building and I/O orchestration
– Signer app handles key material and cryptographic operations
• Security principle: keys never loaded into the main process
• Modular design: Both binaries are built from the same Cargo workspace but run independently
• Pipe & filter: Unix-style piping (stdin/stdout) to decouple processes