Repository navigation
Enforce Ed25519-only DID operations - #44
Conversation
Coverage report
Test suite run success259 tests passing in 25 suites. Report generated by 🧪jest coverage report action from 2ba7d1f |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The validation is consistently applied and adequately covered by focused tests.
Review effort: Balanced
Findings: None
What changed in this PR
Enforces Ed25519-only DID operations and rejects unsupported transaction signatures before manager signing or broadcast.
Changes:
- Validates DID, manager, and document keys as Ed25519.
- Rejects PQ and malformed wallet signatures before sponsorship.
- Updates tests, API documentation, and README guidance.
| File | Description |
|---|---|
src/did/vault-signer.ts |
Validates manager keys. |
src/did/vault-signer.spec.ts |
Tests PQ manager rejection. |
src/did/did.service.ts |
Enforces key and signature validation. |
src/did/did.service.spec.ts |
Covers unsupported keys and signatures. |
src/did/did.controller.ts |
Documents Ed25519 API requirements. |
src/did/did-key.ts |
Adds shared Ed25519 validation. |
src/did/did-document.ts |
Validates document keys. |
src/did/did-document.spec.ts |
Tests invalid document keys. |
README.md |
Documents DID restrictions. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
abd3a95 to
00876c7
Compare
There was a problem hiding this comment.
Alright everything looks fairly in place. A small nit would be on the error handling, let's create a new concrete type similar to this:
export class UnsupportedDidKeyError extends Error {
/** The offending `did:key`, when the failure came from parsing one. */
readonly didKey?: string;
constructor(message: string, didKey?: string) {
super(message);
this.name = 'UnsupportedDidKeyError';
this.didKey = didKey;
}
}And handle the error from the service (ie the error that decodeDidKeyEd25519 throws), then treat it in the controller as a BadRequestException. This should prevent 500 errors on the routes from improper inputs/encoding
decodeDidKeyEd25519 and assertEd25519PublicKey now throw a typed UnsupportedDidKeyError (carrying the offending did:key when one was parsed) instead of a plain Error. The service lets it propagate, and the DID controller maps caller did:key failures to BadRequestException on GET /did/identities/:didKey and the create/update transactions/submit routes. Raw-key failures (a non-Ed25519 manager key) remain server errors. listUserDids now skips only UnsupportedDidKeyError and rethrows anything else.
00876c7 to
2ba7d1f
Compare
DID operations now require an Ed25519
did:keyand reject PQ transaction signatures before manager signing or broadcast. DID listings skip unsupported keys; document and manager signing paths reject non-32-byte keys.Validation: 43 focused tests, build, and lint passed.