Assertions
Assertion guides
This page complements the Add Assertions documentation, which details each assertion in JSON format. Here, we focus on the C++ library's specific schema, using raw string literals.
Standard Assertions Supported by libc2pa
libc2pa
The Truepic libc2pa
library supports a small subset of the assertions defined in the C2PA specification. When adding these supported assertions, the client code must provide the assertion data in a specific format. The library will check the format of the provided data to make sure that it looks correct, and it will reformat that data into the proper assertion structure.
These assertions are added to the C2PA Claim via the ClaimGeneratorBuilder
's add_assertion()
method, as documented here.
Exif assertions
Deprecated
The expected format for the data of an Exif assertion looks very similar to the format as defined in the C2PA spec. The difference is that the client does not need to specify the @context
field. That will be added automatically by libc2pa
.
builder->add_assertion(
"exif",
R"({
"tiff:Make": "Google",
"tiff:Model": "Pixel 7"
})"
);
Thumbnail assertions
The client code can generate a thumbnail image externally and then provide that image to libc2pa
via the set_provided_thumbnail_assertion()
method of the ClaimGenerator
, or the client code can request that libc2pa
generate a thumbnail automatically and add an assertion with this auto-generated thumbnail.
Thumbnails can currently only be auto-generated for JPEG and PNG images.
In order to have libc2pa
generate the thumbnail, the following two parameters should be specified:
MaxDimension
- A string. This dictates the size of the thumbnail image, in pixels.Quality
- JPEG only A string. This is the desired compression quality to use (1 - 100) when compressing the thumbnail image.
builder->add_assertion(
"thumbnail",
R"({
"MaxDimension": "1024",
"Quality": "90"
})"
);
Actions assertions
The data for an actions assertion pretty much exactly follows the format defined in the C2PA spec. The following automatic substitutions are provided by libc2pa
:
- If the
softwareAgent
field is not specified in the provided data, then it will be added automatically. - If the
when
field is set to the special string,@now
, then it will automatically be populated with the current time and date.
builder->add_assertion(
"actions",
R"({
"actions": [
{
"action": "c2pa.opened",
"when": "@now",
"parameters": {
...
}
},
{
"action": "c2pa.edited",
"when": "@now",
"parameters": {
...
}
}
]
})"
);
Actions v2 assertions
This behaves exactly the same as the actions
assertion, but it follows the v2 schema from the C2PA spec.
Creative Work assertions
Deprecated
The libc2pa
library currently has very limited support for Creative Work assertions. Only the author
field is supported, and within that structure, only the @type
and name
fields are supported.
builder->add_assertion(
"creative_work",
R"({
"author": [
{
"@type": "Person",
"name": "Fred Flintstone"
}
]
})"
);
Custom Assertions
Custom assertions are a way to add any assertion data that doesn't fit into one of the supported standard assertions supported by libc2pa
. These assertions are added to the C2PA Claim via the ClaimGenerator
's add_custom_assertion()
method, as documented here.
Assertions Automatically Added by libc2pa
libc2pa
When creating a claim, libc2pa
will automatically add these assertions:
- A hard binding, either a
c2pa.hash.data
assertion, ac2pa.hash.boxes
assertion, or ac2pa.hash.bmff.v2
assertion. - A
com.truepic.libc2pa
assertion containing information about the version oflibc2pa
used to create the Claim.
Updated 3 months ago