Repository navigation
fix(sdk): DSPX-1561 hash assertions as received - #437
Draft
dmihalcik-virtru wants to merge 1 commit into
Draft
dmihalcik-virtru wants to merge 1 commit into
dmihalcik-virtru wants to merge 1 commit into
Conversation
Each assertion keeps the JSON object it was parsed from. assertionHash is computed over that object minus only its top-level binding, as Section 4 of the ZTDF assertions specification defines it, never over a re-serialization of the typed model, so members this SDK does not model and the JSON type of statement.value are covered. The object is written back unchanged when a manifest is serialized; changing a typed field replaces only that member. The id and binding members are read leniently, so that verification, not parsing, reports a bad value. Writers hash the wire form they write, emit binding method "jws", and refuse, as a configuration error, an assertion that a reader would reject while parsing or that has no id. Add the public Manifest.Assertion.computeAssertionHash(String), which applies the Section 3 parsing rules to the raw JSON of one assertion and returns its hash. A recomputed hash or assertionSig that does not match the signed one is reported as an AssertionFailureException with binding-mismatch. Signed-off-by: Dave Mihalcik <dmihalcik@virtru.com>
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
This was referenced Nov 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed Changes
binding(ZTDF assertions specification, Section 4), never a re-serialization of the typed model, so members the SDK doesn't model and the JSON type ofstatement.valueare covered.Manifest.Assertion.computeAssertionHash(String)returns the hash for one raw assertion, applying the Section 3 parsing rules first.jws, and refuse withIllegalArgumentException(a configuration error, not a tamper error) an assertion that readers would reject, or one without an id.idandbindingare read leniently, so verification, not parsing, reports a bad value. A recomputed hash orassertionSigthat doesn't match is reported asSDK.AssertionFailureExceptionwithbinding-mismatch.Stacked on: #436.
Split out of #432 (draft; the complete change). Cross-SDK counterparts: opentdf/platform#4306, opentdf/web-sdk#1140.
Compatibility: assertions are verified against the hash of their stored form. A file whose writer hashed a different form fails verification.
Checklist
Testing Instructions
mvn -pl sdk,cmdline -am test(new cases inAssertionHashTest, including the spec Section 4.4 worked examples; round-trip cases inStrictManifestParsingTest; writer cases inTDFTest).