8000 fix: verify did:webvh SCID over the published log entry by maratsh · Pull Request #290 · affinidi/affinidi-ssi-dart · GitHub
[go: up one dir, main page]

Skip to content

fix: verify did:webvh SCID over the published log entry - #290

Merged
marat-affinidi merged 1 commit into
affinidi:mainfrom
maratsh:fix/webvh-scid-verification-over-published-entry
Jun 30, 2026
Merged

marat-affinidi merged 1 commit into
affinidi:mainfrom
maratsh:fix/webvh-scid-verification-over-published-entry

Conversation

@maratsh
@maratsh maratsh commented Jun 13, 2026
Copy link
Copy Markdown
Contributor

SCID and entry-hash verification rebuilt the first log entry from the typed DidWebVhLogEntry via toJson() before canonicalizing and hashing it. The did:webvh 1.0 spec (SCID Generation and Verification) requires hashing the log entry as published ("treat the resulting log entry as a string"), and the typed round-trip does not preserve every value verbatim. In particular a DID document service whose type is a single-element array, e.g. "type": ["DIDCommMessaging"], is collapsed to the string "type": "DIDCommMessaging". After JCS canonicalization an array and a string are distinct values, so the recomputed SCID no longer matches the published one and resolution fails for a spec-valid DID.

DID Core permits service type to be a string or an array of strings, and the array form is produced by didwebvh-rs (the reference Rust implementation) among others, so these DIDs were unresolvable.

Retain the entry's published JSON on parse and canonicalize that for SCID and entry-hash verification, so the hash is computed over the bytes the controller signed regardless of how the typed model serializes them.

Adds a regression test using a real didwebvh-rs-minted entry whose DID document service type is a single-element array; it fails before this change and passes after.

@maratsh
maratsh requested a review from a team as a code owner June 13, 2026 17:18
@maratsh
maratsh force-pushed the fix/webvh-scid-verification-over-published-entry branch from 462ea42 to b4f698e Compare June 13, 2026 18:56
SCID and entry-hash verification rebuilt the first log entry from the typed
DidWebVhLogEntry via toJson() before canonicalizing and hashing it. The
did:webvh 1.0 spec (SCID Generation and Verification) requires hashing the
log entry as published ("treat the resulting log entry as a string"), and
the typed round-trip does not preserve every value verbatim. In particular a
DID document service whose `type` is a single-element array, e.g.
`"type": ["DIDCommMessaging"]`, is collapsed to the string
`"type": "DIDCommMessaging"`. After JCS canonicalization an array and a
string are distinct values, so the recomputed SCID no longer matches the
published one and resolution fails for a spec-valid DID.

DID Core permits service `type` to be a string or an array of strings, and
the array form is produced by didwebvh-rs (the reference Rust implementation)
among others, so these DIDs were unresolvable.

Retain the entry's published JSON on parse and canonicalize that for SCID and
entry-hash verification, so the hash is computed over the bytes the
controller signed regardless of how the typed model serializes them.

Adds a regression test using a real didwebvh-rs-minted entry whose DID
document service type is a single-element array; it fails before this change
and passes after.
@maratsh
maratsh force-pushed the fix/webvh-scid-verification-over-published-entry branch from b4f698e to 248dca9 Compare June 13, 2026 19:12
IVIR3zaM added a commit to decentralized-identity/didwebvh-dart that referenced this pull request Jun 14, 2026
…dart#290)

Add regression tests ensuring a single-element service.type array (e.g.
["DIDCommMessaging"]) survives SCID and entry-hash verification.

Upstream affinidi/affinidi-ssi-dart#290 fixed a bug where rebuilding a log
entry from a typed DID-document model collapsed single-element arrays to
scalars, changing the JCS bytes and breaking verification. This port keeps
the DID document `state` as a verbatim map and was never affected; these
tests lock that behaviour in so a future refactor can't regress it.

Document the guarantee in the root and package
8000
 changelogs.
@reza-maghoul-affinidi reza-maghoul-affinidi left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@marat-affinidi
marat-affinidi merged commit 0b28a31 into affinidi:main Jun 30, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

0