Skip to content

feat: add did:plc parse method#38

Merged
alanshaw merged 2 commits into
mainfrom
ash/feat/add-did-plc-parse-method
Jul 17, 2026
Merged

feat: add did:plc parse method#38
alanshaw merged 2 commits into
mainfrom
ash/feat/add-did-plc-parse-method

Conversation

@alanshaw

@alanshaw alanshaw commented Jul 13, 2026

Copy link
Copy Markdown
Member

Adds a parse method for did:plc DIDs.

The DID itself is derived from the hash of the first operation in the log, called the "genesis" operation. The signed operation is encoded in DAG-CBOR; the bytes are hashed with SHA-256; the hash bytes are base32-encoded (not hex encoded) as a string; and that string is truncated to 24 chars to yield the "identifier" segment of the DID.

In pseudo-code: did:plc:${base32Encode(sha256(createOp)).slice(0,24)}

https://github.com/did-method-plc/did-method-plc/blob/main/website/spec/v0.1/did-plc.md

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds first-class parsing/validation for did:plc identifiers in the PLC DID package, making it easy to safely accept external DID strings (not just ones generated by plc.New) while centralizing the identifier-length invariant.

Changes:

  • Introduces plc.Parse to parse a DID string, enforce the plc method, enforce a 24-character identifier, and validate base32-lower/no-padding encoding.
  • Adds IdentifierLength constant and uses it when slicing the generated identifier in plc.New.
  • Adds comprehensive unit tests covering valid parsing and common invalid inputs.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
did/plc/plc.go Adds Parse and a shared IdentifierLength constant; updates New to use the constant.
did/plc/plc_test.go Adds TestParse to validate acceptance/rejection behavior for plc.Parse.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

alanshaw added a commit to fil-forge/sprue that referenced this pull request Jul 17, 2026
This PR allows `did:plc` accounts to provision spaces. This requires a
`did:plc` resolver.

Context: Hilt uses the `/customer/add` method to add it's tenants to
Sprue. Hilts tenants are `did:plc` addressed, so that their keys can be
rotated easily. Unfortunately the addition of `/customer/add` to Sprue
did not also include this change to allow the kinds of DID that were
going to be used (`did:plc`) to provision spaces. Hence this PR.

Depends on:

* fil-forge/ucantone#38
* fil-forge/ucantone#39
…capabilityDelegation` silent (#39)

If the document is silent about `capabilityInvocation` or
`capabilityDelegation` then fallback to all `verificationMethods`, do
not fail signature verification entirely.

Context: `did:plc` documents from the official DID PLC server do not
carry these properties and so the signatures are currently unverifiable.

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
@alanshaw
alanshaw merged commit ef993e1 into main Jul 17, 2026
1 check 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