Commit 7fc3b2c
authored
Fix DID verification method ID encoding and add controller (#48)
## Summary
Fixed the DID document generation to correctly encode verification
method IDs and set the controller field.
## Key Changes
- **Fixed fragment encoding**: Changed `doc.Fragment("#key-0")` to
`doc.Fragment("key-0")` to prevent double-encoding of the `#` character.
The `Fragment()` method automatically prepends `#`, so passing `#key-0`
resulted in `#%23key-0` in the serialized output.
- **Set verification method controller**: Added `vm.Controller = doc.ID`
to properly associate the verification method with the DID document.
- **Added test coverage**: Created comprehensive test
(`TestDIDDocument`) that validates:
- DID document generation succeeds
- Document ID matches the service DID
- Verification method ID is correctly formatted as
`did:web:example.com#key-0`
- Verification method ID does not contain percent-encoded characters
- Verification method controller is set to the document ID
## Implementation Details
The fix ensures that DID documents conform to the W3C DID specification
by properly formatting the verification method ID and establishing the
correct controller relationship.
https://claude.ai/code/session_01YAjDX5F44mcX8ojb1ENjY
## References
- fil-forge/smelt#112 files changed
Lines changed: 44 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
67 | 70 | | |
68 | 71 | | |
69 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
0 commit comments