2626fixtures_dir = os .path .join (os .path .dirname (__file__ ), "../tests/fixtures/" )
2727output_dir = os .path .join (os .path .dirname (__file__ ), "../output/" )
2828
29- # Ensure the output directory exists
29+ # Ensure the output directory exists.
3030if not os .path .exists (output_dir ):
3131 os .makedirs (output_dir )
3232
4343with open (fixtures_dir + "es256_private.key" , "rb" ) as key_file :
4444 key = key_file .read ()
4545
46- # Define a callback signer function
46+ # Define a callback signer function.
4747def callback_signer_es256 (data : bytes ) -> bytes :
4848 """Callback function that signs data using ES256 algorithm."""
4949 private_key = serialization .load_pem_private_key (
@@ -60,7 +60,6 @@ def callback_signer_es256(data: bytes) -> bytes:
6060# Create a manifest definition as a dictionary.
6161# This manifest follows the V2 manifest format.
6262manifest_definition = {
63- "claim_generator" : "python_example" ,
6463 "claim_generator_info" : [{
6564 "name" : "python_example" ,
6665 "version" : "0.0.1" ,
@@ -87,7 +86,7 @@ def callback_signer_es256(data: bytes) -> bytes:
8786}
8887
8988# Sign the image with the signer created above,
90- # which will use the callback signer
89+ # which will use the callback signer.
9190print ("\n Signing the image file..." )
9291
9392with c2pa .Signer .from_callback (
@@ -107,6 +106,9 @@ def callback_signer_es256(data: bytes) -> bytes:
107106print ("\n Reading signed image metadata:" )
108107with open (output_dir + "A_signed.jpg" , "rb" ) as file :
109108 with c2pa .Reader ("image/jpeg" , file ) as reader :
109+ # The validation state will depend on loaded trust settings.
110+ # Without loaded trust settings,
111+ # the manifest validation_state will be "Invalid".
110112 print (reader .json ())
111113
112114print ("\n Example completed successfully!" )
0 commit comments