| // Copyright 2026 Google LLC |
| // |
| // Licensed under the Apache License, Version 2.0 (the "License"); |
| // you may not use this file except in compliance with the License. |
| // You may obtain a copy of the License at |
| // |
| // https://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, software |
| // distributed under the License is distributed on an "AS IS" BASIS, |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| // See the License for the specific language governing permissions and |
| // limitations under the License. |
| // |
| |
| #ifndef THIRD_PARTY_CREDENTIO_ASSERTION_ASSERTION_REFERENCER_H_ |
| #define THIRD_PARTY_CREDENTIO_ASSERTION_ASSERTION_REFERENCER_H_ |
| |
| #include "absl/log/die_if_null.h" |
| #include "absl/status/statusor.h" |
| #include "crypto/hash.h" |
| #include "jumbf/box_builder.h" |
| #include "proto/assertion.pb.h" |
| #include "proto/hashed_uri.pb.h" |
| |
| namespace credentio { |
| // A utility class to create a hashed, JUMBF-type URI to an assertion. |
| // For more details, see |
| // https://spec.c2pa.org/specifications/specifications/2.4/specs/C2PA_Specification.html#_uri_references |
| // and |
| // https://spec.c2pa.org/specifications/specifications/2.4/specs/C2PA_Specification.html#_hashed_uris. |
| class AssertionReferencer { |
| public: |
| explicit AssertionReferencer(const HasherFactory* hasher) |
| : hasher_factory_(*ABSL_DIE_IF_NULL(hasher)) {} |
| |
| // Generates a hashed URI for the given assertion. The URI is relative to the |
| // including manifest (e.g., "self#jumbf=c2pa.assertions/c2pa.hash.bmff.v3"). |
| // The `algorithm` field field is omitted under the assumption that the |
| // HasherFactory's algorithm will be specified as the default hash algorithm |
| // in the Claim. |
| absl::StatusOr<HashedUri> Generate( |
| const jumbf::BuiltSuperBox& assertion) const; |
| |
| private: |
| const HasherFactory& hasher_factory_; |
| }; |
| } // namespace credentio |
| |
| #endif // THIRD_PARTY_CREDENTIO_ASSERTION_ASSERTION_REFERENCER_H_ |