Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: did prinicipal #149

Merged
merged 7 commits into from
Dec 1, 2022
Merged

feat: did prinicipal #149

merged 7 commits into from
Dec 1, 2022

Conversation

Gozala
Copy link
Collaborator

@Gozala Gozala commented Nov 30, 2022

This PR generalizes #139 to arbitrary DIDs and supersedes it. It also changes following things

  1. Instead of carrying DID method type around we carry DID itself.
  2. .withDID method is added so you could wrap did:key (or other) into e.g. did:dns or did:web.
  3. Archive format hash changed instead to be a better fit DIDs
    • toArchive() no longer returns bytes, instead it always returns { id: DID, keys: Record<DID<'key'>, CryptoKey|Uint8Array> }
    • It should be possible to read/write into IndexDB
    • In node you could use any IPLD codec to serialize into bytes or string
    • 💣 🚨 This is a breaking change in a sense that old records in IndexDB or binary will not be loadable in new code
    • ⚠️ Even though archive returns keys it will only have one key, however it addresses feat: did:dns support #139 (comment) and provides a way to have multiple keys in the future

Fixes #137

packages/interface/src/lib.ts Outdated Show resolved Hide resolved
packages/interface/src/lib.ts Outdated Show resolved Hide resolved
packages/interface/src/lib.ts Outdated Show resolved Hide resolved
packages/interface/src/lib.ts Outdated Show resolved Hide resolved
packages/interface/src/lib.ts Show resolved Hide resolved
*/
async resolveAndVerify(payload, signature) {
try {
const key = await this.resolve()
Copy link
Contributor

Choose a reason for hiding this comment

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

What if Principal id is a non-key DID that resolves to more than one key?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We’ll update this once we start supporting multiple keys, right now we don’t so we keep it simple

packages/principal/src/did.js Show resolved Hide resolved

export const code = 0x1300
export const name = Verifier.name

/** @type {'EdDSA'} */
Copy link
Contributor

Choose a reason for hiding this comment

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

This type assertion could be helpfully moved into Verifier.signatureAlgorithm (or in there you could use a /** @type {const} */ when assigning the eddsa string

packages/principal/src/rsa.js Show resolved Hide resolved
packages/principal/src/rsa/type.ts Show resolved Hide resolved
@gobengo gobengo self-requested a review December 1, 2022 00:35
@Gozala Gozala merged commit 72d4b9d into main Dec 1, 2022
Gozala added a commit that referenced this pull request Dec 1, 2022
- add .withDID method to principals for wrapping keys in DIDs
- 💣 🚨 change output of .toArchive .from to support multikey signers
Gozala added a commit that referenced this pull request Dec 1, 2022
- add .withDID method to principals for wrapping keys in DIDs
- 💣 🚨 change output of .toArchive .from to support multikey signers
@github-actions github-actions bot mentioned this pull request Dec 1, 2022
gobengo added a commit to storacha/w3up that referenced this pull request Dec 7, 2022
…#246)

Motivation:
* second attempt at this
#238
* after first was reverted
#245

Warning:
* the versions of ucanto we're upgrading to were backward-incompatible.
storacha/ucanto#149
* Old 'SignerArchive' exports will probably no longer import using the
new `@ucanto/principal@^4.0.0` `SignerArchive`
* in slack, @alanshaw said he thinks this is unlikely to cause problems:
"There’s no code in production that uses toArchive"

Blockers
* [x] Wait for these two to land first (@hugomrdias says so)
  * [x] @hugomrdias #207
  * [x] @alanshaw #228
* [x] then will need to resolve merge conflicts on this branch
* [x] @gobengo resolve conflicts after
#207
* [x] @gobengo resolve conflicts after
#228

Co-authored-by: Irakli Gozalishvili <contact@gozala.io>
This was referenced Dec 14, 2022
gobengo added a commit to storacha/w3up that referenced this pull request Apr 11, 2023
…#246)

Motivation:
* second attempt at this
#238
* after first was reverted
#245

Warning:
* the versions of ucanto we're upgrading to were backward-incompatible.
storacha/ucanto#149
* Old 'SignerArchive' exports will probably no longer import using the
new `@ucanto/principal@^4.0.0` `SignerArchive`
* in slack, @alanshaw said he thinks this is unlikely to cause problems:
"There’s no code in production that uses toArchive"

Blockers
* [x] Wait for these two to land first (@hugomrdias says so)
  * [x] @hugomrdias #207
  * [x] @alanshaw #228
* [x] then will need to resolve merge conflicts on this branch
* [x] @gobengo resolve conflicts after
#207
* [x] @gobengo resolve conflicts after
#228

Co-authored-by: Irakli Gozalishvili <contact@gozala.io>
This was referenced Apr 11, 2023
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 did:dns support
2 participants