Skip to content

fix(sdk): DSPX-1561 hash assertions as received - #4306

Draft
dmihalcik-virtru wants to merge 1 commit into
DSPX-1561-strict-manifestfrom
DSPX-1561-assertion-hash
Draft

dmihalcik-virtru wants to merge 1 commit into
DSPX-1561-strict-manifestfrom
DSPX-1561-assertion-hash

Conversation

@dmihalcik-virtru

@dmihalcik-virtru dmihalcik-virtru commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Proposed Changes

  • The assertion hash covers the assertion exactly as it appears in the manifest, minus only its top-level binding (ZTDF assertions specification, Section 4), instead of a re-marshalled copy of the typed struct. Members the SDK doesn't model are now covered, and an object-valued statement.value is hashed as an object.
  • New ComputeAssertionHash(wire []byte) returns the hash for one raw assertion, applying the Section 3 parsing rules first; sdk/experimental/tdf re-exports it.
  • Writers hash the object they write, and refuse with ErrInvalidAssertion (a configuration error, not a tamper error) an assertion that readers would reject: an empty id, or JSON that breaks Section 3.
  • The assertion id and binding are decoded leniently, so a manifest with a non-string id still loads with verification disabled; verification reports it.
  • github.com/gowebpki/jcs v1.0.1 → v1.0.2 (canonicalization is O(n log n) in members and linear in size, which matters now that the input comes from the file); brings testify v1.12.1.

Stacked on: #4305.
Split out of #4301 (draft; the complete change). Cross-SDK counterparts: opentdf/java-sdk#437, opentdf/web-sdk#1140.

Compatibility: assertions are verified against the hash of their stored form. A file whose writer hashed a different form (for example, one that dropped members it didn't model) fails verification.

Checklist

  • I have added or updated unit tests
  • I have added or updated integration tests (if appropriate)
  • I have added or updated documentation

Testing Instructions

  • cd sdk && go test ./... -race (hash cases in sdk/assertion_parse_test.go, including the spec Section 4.4 worked examples and a scaling check); cd otdfctl && go test ./....

Keep the raw JSON of each decoded assertion and compute assertionHash over
it, minus only the top-level binding (ZTDF assertions specification,
Section 4), instead of re-marshalling the typed struct. Members the SDK
does not model are now covered, and an object-valued statement value is
hashed as an object. ComputeAssertionHash exposes the calculation for one
raw assertion, applying the Section 3 parsing rules first, and
sdk/experimental/tdf re-exports it. Update gowebpki/jcs to v1.0.2, whose
canonicalization is O(n log n) in members and linear in size, since the
hashed object now comes from the file.

Writers hash the wire object they write, and refuse with
ErrInvalidAssertion an assertion that readers would reject: an empty id,
or JSON that breaks Section 3.

The id and binding members are decoded leniently, so that a manifest whose
assertion has a non-string id or a malformed binding still loads when
verification is disabled, and verification reports it.

Signed-off-by: Dave Mihalcik <dmihalcik@virtru.com>
@coderabbitai

coderabbitai Bot commented Nov 9, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor
Benchmark results, click to expand

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 403.913536ms
Throughput 247.58 requests/second

TDF3 Benchmark Results

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 45.617606635s
Average Latency 455.142591ms
Throughput 109.61 requests/second

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

⚠️ Govulncheck found vulnerabilities ⚠️

The following modules have known vulnerabilities:

  • otdfctl
  • sdk
  • service
  • tests-bdd

See the workflow run for details.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:sdk A software development kit, including library, for client applications and inter-service communicati size/m

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant