contentauth / c2patool

Command line tool for displaying and adding C2PA manifests
Apache License 2.0
94 stars 30 forks source link

No way to refer to ingredients from the current manifest in action parameters #129

Closed eeeps closed 11 months ago

eeeps commented 11 months ago

According to the C2PA spec:

When using a c2pa.transcoded, c2pa.repackaged, c2pa.opened, or a c2pa.placed action, the ingredient field (for v1) or ingredients field (for v2) in the parameters object shall contain the hashed JUMBF URI to one or more related ingredient assertion.

In addition, the presence of the ingredients field in the parameters object seems to allow for specific actions to only apply to specific ingredients, in cases where there are multiple ingredients.

Right now c2patool seems to pass through any JSON I put in assertions[i].data.actions[i].parameters.ingredients unmodified. But I can't know the hashed JUMBF URI of the ingredient, which I am adding with c2patool at the same time that I am adding the action.

eeeps commented 11 months ago

So apparently, there is! However it is currently undocumented.

Thanks to @gpeacock in the Discord for showing me the way; it currently works by sticking the instance_id from the ingredient report JSON into a field called instanceId on the action. e.g.:

  "assertions": [
    {
      "label": "c2pa.actions",
      "data": {
        "actions": [
          {
            "action": "c2pa.resized",
            "when": "2023-07-20T15:57:41-0700",
            "instanceId": "xmp:iid:8dab8f63-ab54-4381-9c54-01dcd48c1255"
          }
        ]
      }
    }
  ]

This should result in a v1-style ingredient parameter on the action:

      "assertions": [
        {
          "label": "c2pa.actions",
          "data": {
            "actions": [
              {
                "action": "c2pa.resized",
                "instanceId": "xmp:iid:8dab8f63-ab54-4381-9c54-01dcd48c1255",
                "parameters": {
                  "ingredient": {
                    "hash": "A+c+6tBgK3YeN9njQsYdcn1Mv1A2iFBPA9LNMjo7SqU=",
                    "url": "self#jumbf=c2pa.assertions/c2pa.ingredient"
                  }
                },
                "when": "2023-07-20T15:57:41-0700"
              }
            ]
          }
        }
      ]