Skip to content

Commit

Permalink
test without compression or diffing
Browse files Browse the repository at this point in the history
  • Loading branch information
ok-nick committed Aug 5, 2024
1 parent 91314cb commit a39ec83
Show file tree
Hide file tree
Showing 42 changed files with 46 additions and 42 deletions.
18 changes: 10 additions & 8 deletions c2pa-compat/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,12 @@ fn main() -> Result<()> {
&mut signed_remote_asset,
)?;

let signed_remote_asset_patch =
diffy::create_patch_bytes(&original_asset, &signed_remote_asset.into_inner())
.to_bytes();
let signed_remote_asset_patch = signed_remote_asset.into_inner();
// let signed_remote_asset_patch =
// diffy::create_patch_bytes(&original_asset, &signed_remote_asset.into_inner())
// .to_bytes();
asset_details.uncompressed_remote_size = Some(signed_remote_asset_patch.len());
let signed_remote_asset_patch = lz4_flex::compress(&signed_remote_asset_patch);
// let signed_remote_asset_patch = lz4_flex::compress(&signed_remote_asset_patch);

fs::write(dir_path.join("remote.patch"), signed_remote_asset_patch)?;
fs::write(dir_path.join("remote.c2pa"), remote_c2pa_manifest)?;
Expand All @@ -163,11 +164,12 @@ fn main() -> Result<()> {
Err(err) => return Err(err),
}

let signed_embedded_asset_patch =
diffy::create_patch_bytes(&original_asset, &signed_embedded_asset.into_inner())
.to_bytes();
let signed_embedded_asset_patch = signed_embedded_asset.into_inner();
// let signed_embedded_asset_patch =
// diffy::create_patch_bytes(&original_asset, &signed_embedded_asset.into_inner())
// .to_bytes();
asset_details.uncompressed_embedded_size = Some(signed_embedded_asset_patch.len());
let signed_embedded_asset_patch = lz4_flex::compress(&signed_embedded_asset_patch);
// let signed_embedded_asset_patch = lz4_flex::compress(&signed_embedded_asset_patch);

fs::write(dir_path.join("embedded.patch"), signed_embedded_asset_patch)?;
fs::write(dir_path.join("embedded.c2pa"), embedded_c2pa_manifest)?;
Expand Down
42 changes: 22 additions & 20 deletions sdk/tests/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,17 @@ fn test_compat() -> Result<()> {
let remote_asset_path = asset_dir.join("remote.patch");
if remote_asset_path.exists() {
let expected_remote_asset_patch = fs::read(remote_asset_path)?;
let expected_remote_asset_patch = lz4_flex::decompress(
&expected_remote_asset_patch,
asset_details.uncompressed_remote_size.unwrap(),
)
.expect("TODO"); // TODO: err msg
let expected_remote_asset = diffy::apply_bytes(
&original_asset,
&diffy::Patch::from_bytes(&expected_remote_asset_patch).expect("TODO"),
)
.expect("TODO");
let expected_remote_asset = expected_remote_asset_patch;
// let expected_remote_asset_patch = lz4_flex::decompress(
// &expected_remote_asset_patch,
// asset_details.uncompressed_remote_size.unwrap(),
// )
// .expect("TODO"); // TODO: err msg
// let expected_remote_asset = diffy::apply_bytes(
// &original_asset,
// &diffy::Patch::from_bytes(&expected_remote_asset_patch).expect("TODO"),
// )
// .expect("TODO");

let expected_remote_reader: Reader =
serde_json::from_reader(File::open(asset_dir.join("remote.json"))?)?;
Expand All @@ -193,16 +194,17 @@ fn test_compat() -> Result<()> {
}

let expected_embedded_asset_patch = fs::read(asset_dir.join("embedded.patch"))?;
let expected_embedded_asset_patch = lz4_flex::decompress(
&expected_embedded_asset_patch,
asset_details.uncompressed_embedded_size,
)
.expect("TODO"); // TODO: err msg
let expected_embedded_asset = diffy::apply_bytes(
&original_asset,
&diffy::Patch::from_bytes(&expected_embedded_asset_patch).expect("TODO"),
)
.expect("TODO");
let expected_embedded_asset = expected_embedded_asset_patch;
// let expected_embedded_asset_patch = lz4_flex::decompress(
// &expected_embedded_asset_patch,
// asset_details.uncompressed_embedded_size,
// )
// .expect("TODO"); // TODO: err msg
// let expected_embedded_asset = diffy::apply_bytes(
// &original_asset,
// &diffy::Patch::from_bytes(&expected_embedded_asset_patch).expect("TODO"),
// )
// .expect("TODO");

let expected_embedded_reader: Reader =
serde_json::from_reader(File::open(asset_dir.join("embedded.json"))?)?;
Expand Down
Binary file modified sdk/tests/fixtures/compat/0.33.0/bmff/embedded.c2pa
Binary file not shown.
2 changes: 1 addition & 1 deletion sdk/tests/fixtures/compat/0.33.0/bmff/embedded.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"manifest_store":{"active_manifest":"urn:uuid:22eb8f61-61a9-40a3-a9df-5f694f93340b","manifests":{"urn:uuid:22eb8f61-61a9-40a3-a9df-5f694f93340b":{"claim_generator":"test/1.0 c2pa-rs/0.33.0","claim_generator_info":[{"name":"test","version":"1.0"},{"name":"c2pa-rs","version":"0.33.0"}],"format":"video/mp4","instance_id":"xmp:iid:a1a80ffc-d6e4-40bd-856d-b41b020b1651","ingredients":[],"assertions":[{"label":"c2pa.actions.v2","data":{"actions":[{"action":"c2pa.opened","softwareAgent":{"name":"TestApp","version":"1.0","something":"else"},"parameters":{"description":"import"},"digitalSourceType":"http://cv.iptc.org/newscodes/digitalsourcetype/algorithmicMedia"}]}},{"label":"c2pa.hash.bmff.v2","data":{"exclusions":[{"xpath":"/uuid","length":null,"data":[{"offset":8,"value":[216,254,195,214,27,14,72,60,146,151,88,40,135,126,196,129]}],"subset":null,"version":null,"flags":null,"exact":null},{"xpath":"/ftyp","length":null,"data":null,"subset":null,"version":null,"flags":null,"exact":null},{"xpath":"/meta/iloc","length":null,"data":null,"subset":null,"version":null,"flags":null,"exact":null},{"xpath":"/mfra/tfra","length":null,"data":null,"subset":null,"version":null,"flags":null,"exact":null},{"xpath":"/moov/trak/mdia/minf/stbl/stco","length":null,"data":null,"subset":[{"offset":16,"length":0}],"version":null,"flags":null,"exact":null},{"xpath":"/moov/trak/mdia/minf/stbl/co64","length":null,"data":null,"subset":[{"offset":16,"length":0}],"version":null,"flags":null,"exact":null},{"xpath":"/moof/traf/tfhd","length":null,"data":null,"subset":[{"offset":16,"length":8}],"version":null,"flags":[1,0,0],"exact":null},{"xpath":"/moof/traf/trun","length":null,"data":null,"subset":[{"offset":16,"length":4}],"version":null,"flags":[1,0,0],"exact":null}],"alg":"sha256","hash":[200,32,148,169,15,166,231,86,102,210,152,227,69,66,172,110,226,206,198,129,95,47,38,164,140,189,109,46,157,228,177,15],"name":"jumbf manifest"}}],"signature_info":{"alg":"Ed25519","issuer":"C2PA Test Signing Cert","cert_serial_number":"638838410810235485828984295321338730070538954823"},"label":"urn:uuid:22eb8f61-61a9-40a3-a9df-5f694f93340b"}}}}
{"manifest_store":{"active_manifest":"urn:uuid:61715312-fe4e-472b-bc14-9ffcc88bcaa2","manifests":{"urn:uuid:61715312-fe4e-472b-bc14-9ffcc88bcaa2":{"claim_generator":"test/1.0 c2pa-rs/0.33.0","claim_generator_info":[{"name":"test","version":"1.0"},{"name":"c2pa-rs","version":"0.33.0"}],"format":"video/mp4","instance_id":"xmp:iid:ad5c3fc2-2600-412e-a0b8-edc6cd592c6d","ingredients":[],"assertions":[{"label":"c2pa.actions.v2","data":{"actions":[{"action":"c2pa.opened","softwareAgent":{"name":"TestApp","version":"1.0","something":"else"},"parameters":{"description":"import"},"digitalSourceType":"http://cv.iptc.org/newscodes/digitalsourcetype/algorithmicMedia"}]}},{"label":"c2pa.hash.bmff.v2","data":{"exclusions":[{"xpath":"/uuid","length":null,"data":[{"offset":8,"value":[216,254,195,214,27,14,72,60,146,151,88,40,135,126,196,129]}],"subset":null,"version":null,"flags":null,"exact":null},{"xpath":"/ftyp","length":null,"data":null,"subset":null,"version":null,"flags":null,"exact":null},{"xpath":"/meta/iloc","length":null,"data":null,"subset":null,"version":null,"flags":null,"exact":null},{"xpath":"/mfra/tfra","length":null,"data":null,"subset":null,"version":null,"flags":null,"exact":null},{"xpath":"/moov/trak/mdia/minf/stbl/stco","length":null,"data":null,"subset":[{"offset":16,"length":0}],"version":null,"flags":null,"exact":null},{"xpath":"/moov/trak/mdia/minf/stbl/co64","length":null,"data":null,"subset":[{"offset":16,"length":0}],"version":null,"flags":null,"exact":null},{"xpath":"/moof/traf/tfhd","length":null,"data":null,"subset":[{"offset":16,"length":8}],"version":null,"flags":[1,0,0],"exact":null},{"xpath":"/moof/traf/trun","length":null,"data":null,"subset":[{"offset":16,"length":4}],"version":null,"flags":[1,0,0],"exact":null}],"alg":"sha256","hash":[200,32,148,169,15,166,231,86,102,210,152,227,69,66,172,110,226,206,198,129,95,47,38,164,140,189,109,46,157,228,177,15],"name":"jumbf manifest"}}],"signature_info":{"alg":"Ed25519","issuer":"C2PA Test Signing Cert","cert_serial_number":"638838410810235485828984295321338730070538954823"},"label":"urn:uuid:61715312-fe4e-472b-bc14-9ffcc88bcaa2"}}}}
Binary file modified sdk/tests/fixtures/compat/0.33.0/bmff/embedded.patch
Binary file not shown.
Binary file modified sdk/tests/fixtures/compat/0.33.0/bmff/remote.c2pa
Binary file not shown.
2 changes: 1 addition & 1 deletion sdk/tests/fixtures/compat/0.33.0/bmff/remote.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"manifest_store":{"active_manifest":"urn:uuid:305b5b3d-2db6-4fb1-9d41-bcfd21bca7d1","manifests":{"urn:uuid:305b5b3d-2db6-4fb1-9d41-bcfd21bca7d1":{"claim_generator":"test/1.0 c2pa-rs/0.33.0","claim_generator_info":[{"name":"test","version":"1.0"},{"name":"c2pa-rs","version":"0.33.0"}],"format":"video/mp4","instance_id":"xmp:iid:3f80e941-cd18-4130-8aae-6d8ca0c33fcd","ingredients":[],"assertions":[{"label":"c2pa.actions.v2","data":{"actions":[{"action":"c2pa.opened","softwareAgent":{"name":"TestApp","version":"1.0","something":"else"},"parameters":{"description":"import"},"digitalSourceType":"http://cv.iptc.org/newscodes/digitalsourcetype/algorithmicMedia"}]}},{"label":"c2pa.hash.bmff.v2","data":{"exclusions":[{"xpath":"/uuid","length":null,"data":[{"offset":8,"value":[216,254,195,214,27,14,72,60,146,151,88,40,135,126,196,129]}],"subset":null,"version":null,"flags":null,"exact":null},{"xpath":"/ftyp","length":null,"data":null,"subset":null,"version":null,"flags":null,"exact":null},{"xpath":"/meta/iloc","length":null,"data":null,"subset":null,"version":null,"flags":null,"exact":null},{"xpath":"/mfra/tfra","length":null,"data":null,"subset":null,"version":null,"flags":null,"exact":null},{"xpath":"/moov/trak/mdia/minf/stbl/stco","length":null,"data":null,"subset":[{"offset":16,"length":0}],"version":null,"flags":null,"exact":null},{"xpath":"/moov/trak/mdia/minf/stbl/co64","length":null,"data":null,"subset":[{"offset":16,"length":0}],"version":null,"flags":null,"exact":null},{"xpath":"/moof/traf/tfhd","length":null,"data":null,"subset":[{"offset":16,"length":8}],"version":null,"flags":[1,0,0],"exact":null},{"xpath":"/moof/traf/trun","length":null,"data":null,"subset":[{"offset":16,"length":4}],"version":null,"flags":[1,0,0],"exact":null}],"alg":"sha256","hash":[184,150,116,156,174,50,81,9,210,20,52,43,49,218,250,178,241,170,78,24,130,120,178,139,133,227,229,58,224,106,28,178],"name":"jumbf manifest"}}],"signature_info":{"alg":"Ed25519","issuer":"C2PA Test Signing Cert","cert_serial_number":"638838410810235485828984295321338730070538954823"},"label":"urn:uuid:305b5b3d-2db6-4fb1-9d41-bcfd21bca7d1"}}}}
{"manifest_store":{"active_manifest":"urn:uuid:8ef2297e-b32c-4cc0-93f8-006207822769","manifests":{"urn:uuid:8ef2297e-b32c-4cc0-93f8-006207822769":{"claim_generator":"test/1.0 c2pa-rs/0.33.0","claim_generator_info":[{"name":"test","version":"1.0"},{"name":"c2pa-rs","version":"0.33.0"}],"format":"video/mp4","instance_id":"xmp:iid:bcf15ff7-9d5d-4595-9f5d-1d9eadee5d83","ingredients":[],"assertions":[{"label":"c2pa.actions.v2","data":{"actions":[{"action":"c2pa.opened","softwareAgent":{"name":"TestApp","version":"1.0","something":"else"},"parameters":{"description":"import"},"digitalSourceType":"http://cv.iptc.org/newscodes/digitalsourcetype/algorithmicMedia"}]}},{"label":"c2pa.hash.bmff.v2","data":{"exclusions":[{"xpath":"/uuid","length":null,"data":[{"offset":8,"value":[216,254,195,214,27,14,72,60,146,151,88,40,135,126,196,129]}],"subset":null,"version":null,"flags":null,"exact":null},{"xpath":"/ftyp","length":null,"data":null,"subset":null,"version":null,"flags":null,"exact":null},{"xpath":"/meta/iloc","length":null,"data":null,"subset":null,"version":null,"flags":null,"exact":null},{"xpath":"/mfra/tfra","length":null,"data":null,"subset":null,"version":null,"flags":null,"exact":null},{"xpath":"/moov/trak/mdia/minf/stbl/stco","length":null,"data":null,"subset":[{"offset":16,"length":0}],"version":null,"flags":null,"exact":null},{"xpath":"/moov/trak/mdia/minf/stbl/co64","length":null,"data":null,"subset":[{"offset":16,"length":0}],"version":null,"flags":null,"exact":null},{"xpath":"/moof/traf/tfhd","length":null,"data":null,"subset":[{"offset":16,"length":8}],"version":null,"flags":[1,0,0],"exact":null},{"xpath":"/moof/traf/trun","length":null,"data":null,"subset":[{"offset":16,"length":4}],"version":null,"flags":[1,0,0],"exact":null}],"alg":"sha256","hash":[184,150,116,156,174,50,81,9,210,20,52,43,49,218,250,178,241,170,78,24,130,120,178,139,133,227,229,58,224,106,28,178],"name":"jumbf manifest"}}],"signature_info":{"alg":"Ed25519","issuer":"C2PA Test Signing Cert","cert_serial_number":"638838410810235485828984295321338730070538954823"},"label":"urn:uuid:8ef2297e-b32c-4cc0-93f8-006207822769"}}}}
Binary file modified sdk/tests/fixtures/compat/0.33.0/bmff/remote.patch
Binary file not shown.
2 changes: 1 addition & 1 deletion sdk/tests/fixtures/compat/0.33.0/compat-details.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"assets":[{"asset":"C.jpg","category":"jpeg","uncompressed_remote_size":52926,"uncompressed_embedded_size":65326},{"asset":"sample1.gif","category":"gif","uncompressed_remote_size":2722,"uncompressed_embedded_size":14907},{"asset":"sample1.svg","category":"svg","uncompressed_remote_size":null,"uncompressed_embedded_size":18163},{"asset":"video1.mp4","category":"bmff","uncompressed_remote_size":96487,"uncompressed_embedded_size":49024},{"asset":"sample1.mp3","category":"mp3","uncompressed_remote_size":1447,"uncompressed_embedded_size":13896},{"asset":"libpng-test.png","category":"png","uncompressed_remote_size":3355,"uncompressed_embedded_size":15725},{"asset":"TUSCANY.TIF","category":"tiff","uncompressed_remote_size":4257,"uncompressed_embedded_size":16646}],"public_key":"certs/ed25519.pub","private_key":"certs/ed25519.pem"}
{"assets":[{"asset":"C.jpg","category":"jpeg","uncompressed_remote_size":87041,"uncompressed_embedded_size":99441},{"asset":"sample1.gif","category":"gif","uncompressed_remote_size":741149,"uncompressed_embedded_size":753333},{"asset":"sample1.svg","category":"svg","uncompressed_remote_size":null,"uncompressed_embedded_size":39649},{"asset":"video1.mp4","category":"bmff","uncompressed_remote_size":795882,"uncompressed_embedded_size":811373},{"asset":"sample1.mp3","category":"mp3","uncompressed_remote_size":1954616,"uncompressed_embedded_size":1967065},{"asset":"libpng-test.png","category":"png","uncompressed_remote_size":4135,"uncompressed_embedded_size":16505},{"asset":"TUSCANY.TIF","category":"tiff","uncompressed_remote_size":206254,"uncompressed_embedded_size":218642}],"public_key":"certs/ed25519.pub","private_key":"certs/ed25519.pem"}
Binary file modified sdk/tests/fixtures/compat/0.33.0/gif/embedded.c2pa
Binary file not shown.
2 changes: 1 addition & 1 deletion sdk/tests/fixtures/compat/0.33.0/gif/embedded.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"manifest_store":{"active_manifest":"urn:uuid:e7652c72-a4a6-480e-8129-387d41996512","manifests":{"urn:uuid:e7652c72-a4a6-480e-8129-387d41996512":{"claim_generator":"test/1.0 c2pa-rs/0.33.0","claim_generator_info":[{"name":"test","version":"1.0"},{"name":"c2pa-rs","version":"0.33.0"}],"format":"image/gif","instance_id":"xmp:iid:21d5b1b2-3975-491b-bc03-636abf940fec","ingredients":[],"assertions":[{"label":"c2pa.actions.v2","data":{"actions":[{"action":"c2pa.opened","softwareAgent":{"name":"TestApp","version":"1.0","something":"else"},"parameters":{"description":"import"},"digitalSourceType":"http://cv.iptc.org/newscodes/digitalsourcetype/algorithmicMedia"}]}}],"signature_info":{"alg":"Ed25519","issuer":"C2PA Test Signing Cert","cert_serial_number":"638838410810235485828984295321338730070538954823"},"label":"urn:uuid:e7652c72-a4a6-480e-8129-387d41996512"}}}}
{"manifest_store":{"active_manifest":"urn:uuid:cba77be8-dc0f-41f4-92f6-a635ef3077de","manifests":{"urn:uuid:cba77be8-dc0f-41f4-92f6-a635ef3077de":{"claim_generator":"test/1.0 c2pa-rs/0.33.0","claim_generator_info":[{"name":"test","version":"1.0"},{"name":"c2pa-rs","version":"0.33.0"}],"format":"image/gif","instance_id":"xmp:iid:99a2a935-431c-48a2-9baf-6a4fffe461d8","ingredients":[],"assertions":[{"label":"c2pa.actions.v2","data":{"actions":[{"action":"c2pa.opened","softwareAgent":{"name":"TestApp","version":"1.0","something":"else"},"parameters":{"description":"import"},"digitalSourceType":"http://cv.iptc.org/newscodes/digitalsourcetype/algorithmicMedia"}]}}],"signature_info":{"alg":"Ed25519","issuer":"C2PA Test Signing Cert","cert_serial_number":"638838410810235485828984295321338730070538954823"},"label":"urn:uuid:cba77be8-dc0f-41f4-92f6-a635ef3077de"}}}}
Binary file modified sdk/tests/fixtures/compat/0.33.0/gif/embedded.patch
Binary file not shown.
Binary file modified sdk/tests/fixtures/compat/0.33.0/gif/remote.c2pa
Binary file not shown.
2 changes: 1 addition & 1 deletion sdk/tests/fixtures/compat/0.33.0/gif/remote.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"manifest_store":{"active_manifest":"urn:uuid:ac12e1b4-312c-40a9-9abd-565e1d33a91a","manifests":{"urn:uuid:ac12e1b4-312c-40a9-9abd-565e1d33a91a":{"claim_generator":"test/1.0 c2pa-rs/0.33.0","claim_generator_info":[{"name":"test","version":"1.0"},{"name":"c2pa-rs","version":"0.33.0"}],"format":"image/gif","instance_id":"xmp:iid:f1eb70ae-f5af-481a-8e94-40fb07c55378","ingredients":[],"assertions":[{"label":"c2pa.actions.v2","data":{"actions":[{"action":"c2pa.opened","softwareAgent":{"name":"TestApp","version":"1.0","something":"else"},"parameters":{"description":"import"},"digitalSourceType":"http://cv.iptc.org/newscodes/digitalsourcetype/algorithmicMedia"}]}}],"signature_info":{"alg":"Ed25519","issuer":"C2PA Test Signing Cert","cert_serial_number":"638838410810235485828984295321338730070538954823"},"label":"urn:uuid:ac12e1b4-312c-40a9-9abd-565e1d33a91a"}}}}
{"manifest_store":{"active_manifest":"urn:uuid:d98fad5e-65ab-4841-a376-aef5627b9856","manifests":{"urn:uuid:d98fad5e-65ab-4841-a376-aef5627b9856":{"claim_generator":"test/1.0 c2pa-rs/0.33.0","claim_generator_info":[{"name":"test","version":"1.0"},{"name":"c2pa-rs","version":"0.33.0"}],"format":"image/gif","instance_id":"xmp:iid:d987453c-fc2e-488f-8743-12964168f699","ingredients":[],"assertions":[{"label":"c2pa.actions.v2","data":{"actions":[{"action":"c2pa.opened","softwareAgent":{"name":"TestApp","version":"1.0","something":"else"},"parameters":{"description":"import"},"digitalSourceType":"http://cv.iptc.org/newscodes/digitalsourcetype/algorithmicMedia"}]}}],"signature_info":{"alg":"Ed25519","issuer":"C2PA Test Signing Cert","cert_serial_number":"638838410810235485828984295321338730070538954823"},"label":"urn:uuid:d98fad5e-65ab-4841-a376-aef5627b9856"}}}}
Binary file modified sdk/tests/fixtures/compat/0.33.0/gif/remote.patch
Binary file not shown.
Binary file modified sdk/tests/fixtures/compat/0.33.0/jpeg/embedded.c2pa
Binary file not shown.
Loading

0 comments on commit a39ec83

Please sign in to comment.