Skip to content

Conversation

@johnbillion
Copy link
Owner

Implements issue #41: a new CLI command fair-tools did rotation-key check
that validates whether a given rotation key is valid for use as a rotation
key for a DID.

Unlike verification keys (which are checked against the DID document),
rotation keys are validated against the latest operation in the DID log.

Changes:

  • Add checkRotationKey() function in verify.ts that fetches the DID log
    and checks if the key is present in the latest operation's rotationKeys
  • Add getRotationPublicKeyMultibase() and parseRotationPublicKeyOnly()
    in keys.ts for parsing rotation key inputs (did:key, multibase, PEM, hex)
  • Export parseAsRotationKey() from signing.ts for key parsing
  • Create did-rotation-key-check.ts CLI command with --did, --key, and
    --key-file options, mirroring the verification-key check command
  • Register the command in fair-tools.ts under did rotation-key check
  • Add comprehensive tests for all new functions

Supported key formats (same as issue #42):

  • did:key format (did:key:zQ3sh...)
  • Multibase format (zQ3sh...)
  • Private key from file (PEM, multibase, or hex - derives public key)

Exit codes:

  • 0: Key is valid (present in latest DID log operation)
  • 1: Key is not valid (not found or DID has no rotation keys)
  • 2: Error occurred (invalid input, network error, etc.)

Closes #41

Implements issue #41: a new CLI command `fair-tools did rotation-key check`
that validates whether a given rotation key is valid for use as a rotation
key for a DID.

Unlike verification keys (which are checked against the DID document),
rotation keys are validated against the latest operation in the DID log.

Changes:
- Add `checkRotationKey()` function in verify.ts that fetches the DID log
  and checks if the key is present in the latest operation's rotationKeys
- Add `getRotationPublicKeyMultibase()` and `parseRotationPublicKeyOnly()`
  in keys.ts for parsing rotation key inputs (did:key, multibase, PEM, hex)
- Export `parseAsRotationKey()` from signing.ts for key parsing
- Create `did-rotation-key-check.ts` CLI command with --did, --key, and
  --key-file options, mirroring the verification-key check command
- Register the command in fair-tools.ts under did rotation-key check
- Add comprehensive tests for all new functions

Supported key formats (same as issue #42):
- did:key format (did:key:zQ3sh...)
- Multibase format (zQ3sh...)
- Private key from file (PEM, multibase, or hex - derives public key)

Exit codes:
- 0: Key is valid (present in latest DID log operation)
- 1: Key is not valid (not found or DID has no rotation keys)
- 2: Error occurred (invalid input, network error, etc.)

Closes #41
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements a new CLI command fair-tools did rotation-key check that validates whether a given rotation key is valid for use with a DID. Unlike verification keys (which are checked against the DID document), rotation keys are validated against the latest operation in the DID log, following the PLC (Public Ledger of Credentials) operation model.

Changes:

  • Added checkRotationKey() function to verify rotation keys against DID log operations
  • Implemented rotation key parsing functions (getRotationPublicKeyMultibase(), parseRotationPublicKeyOnly()) supporting multiple key formats (did:key, multibase, PEM, hex)
  • Created new CLI command with comprehensive error handling and exit codes

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/verify.ts Added checkRotationKey() function and CheckRotationKeyResult interface to validate rotation keys against DID log
src/keys.ts Implemented rotation key parsing functions with validation, mirroring the verification key pattern
src/signing.ts Exported parseAsRotationKey() function for external use in key parsing
src/cli/did-rotation-key-check.ts New CLI command implementing rotation key validation with --did, --key, and --key-file options
src/cli/fair-tools.ts Registered new rotation-key check command in the command tree
test/verify.test.ts Added basic type-checking tests for checkRotationKey() function
test/keys.test.ts Added comprehensive tests for rotation key parsing functions covering various input formats and error cases

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

Copy link
Contributor

Copilot AI commented Jan 18, 2026

@johnbillion I've opened a new pull request, #49, to work on those changes. Once the pull request is ready, I'll request review from you.

@johnbillion johnbillion added this to the 0.8.1 milestone Jan 20, 2026
@johnbillion johnbillion merged commit 89dcbbc into trunk Jan 20, 2026
4 checks passed
@johnbillion johnbillion deleted the claude/implement-issue-41-UGAc0 branch January 20, 2026 10:05
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.

Add command to check validity of a rotation key

3 participants