numbersprotocol / pyc2pa

Python implementation of C2PA: Coalition for Content Provenance and Authenticity.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support Assertion hash validation

bafu opened this issue · comments

Choose cai.rights as example

hashlink

self#jumbf=cai/cb.adobe/cai.assertions/cai.rights?hl=mEiBChBVd8onGt71mftnzv4e9C6m67kAeHCK1K8TDtuKfDA

assertion

{"copyright":"Starling Labs"}

$ python3 utils/encode_hashlink.py -i starling.rights.2-spaces.json.txt
Input file: starling.rights.2-spaces.json.txt
hashlink param: mEiAUSYX4dM+r9uhZz4IVP8Z/LFBDJc/x/UAfi6urkpOjmw

$ python3 utils/encode_hashlink.py -i starling.rights.4-spaces.json.txt 
Input file: starling.rights.4-spaces.json.txt
hashlink param: mEiBzzxFzjFEAQUsPQwtzkUHefGTpMegWzfi+bxEUlWSZCw

$ python3 utils/encode_hashlink.py -i starling.rights.no-spaces.json.txt
Input file: starling.rights.no-spaces.json.txt
hashlink param: mEiDERxtUoEmJ2b13EgVVzBZDBcLLnz3GE9qMkCnMwacwEQ

Extract the cai/cb.adobe/cai.rights Assertion Superbox

Superbox
LBox 00 00 00 51
TBox 6A 75 6D 62

Description Box
LBox 00 00 00 24
TBox 6A 75 6D 64
db_type 6A 73 6F 6E 00 11 00 10 80 00 00 AA 00 38 9B 71
db_toggle 03
db_label 63 61 69 2E 72 69 67 68 74 73 00 (cai.rights)

Content Box
LBox 00 00 00 25
TBox 6A 73 6F 6E (json)
Content 7B 22 63 6F 70 79 72 69 67 68 74 22 3A 22 53 74 61 72 6C 69 6E 67 20 4C 61 62 73 22 7D

Content (29)

{"copyright":"Starling Labs"}

open will add a newline char 0a at the end of content bytes.

The length of read data will be 30 instead of 29. We need to add strip to prevent this issue.

Bofu Chen 3:24 PM
@mfisher @dkozma Thanks for Maurice's suggestion and the Claim tool, I update the multi-claim injection function.

Q1 The verify site will only show the newly injected Claim. I took two screenshots of the Chrome console messages, and would you help check them?
From the output of the Claim tool, the multi-claim injection looks okay. The AssertionHash errors should not affect the Claim display because the verification in the verify site has not been enabled?

Q2 For the AssertionHash errors, would you help check the encoding algorithm is correct?
We use the same hashlink generation function for the two Claims: cb.reuters_1 and cb.starling_1, and the Claim tool only returned the AssertionHash errors for cb.starling_1.

Q3 When generating assertion hash, should we use Superbox or raw content (e.g., JSON bytes or thumbnail in a Content Box) as the input?


Leonard Rosenthol 8:25 PM
Q3 - assertion hash is on the raw content


Bofu Chen 2:17 AM
Based on Leonard's answer for Q3, I can answer Q2 by myself now: the hashlink algorithm is correct.
I use the cai/cb.adobe/cai.rights Assertion content as the input

{"coyright":"Starling Labs"}

and can generate the same hash mEiBChBVd8onGt71mftnzv4e9C6m67kAeHCK1K8TDtuKfDA

Checking that why the Claim tool returned the AssertionHash errors if the hashlink algorithm is correct. (root cause and solution)

This issue had been fixed by commit 18026b7. Hash algorithm example is utils/encode_hashlink.py