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

[proposal] Add support for full publicKey identifiers #56

Closed
mirceanis opened this issue Mar 23, 2020 · 5 comments · Fixed by #73
Closed

[proposal] Add support for full publicKey identifiers #56

mirceanis opened this issue Mar 23, 2020 · 5 comments · Fixed by #73
Labels
enhancement New feature or request

Comments

@mirceanis
Copy link
Member

mirceanis commented Mar 23, 2020

Problem

There is an inherent limitation to ethr-did regarding the types of keys that can be expressed in the default DID document.
The default DID document lists the ethereumAddress backing up the DID as a signature verification key, but it is not a full public key, only the truncated hash of one.
Therefore it cannot be used for Diffie Hellman negotiations, nor for direct signature checks using ecVerify(), or any encoding transformation, like key-material -> JWK representation.

In most cases the ethereumAddress of an identifier comes from a publicKey and not from a contract.
Of course, it is possible to add the full secp256k1 key but that requires a transaction and gas, going against a first principle of did:ethr which is onboarding without gas.

Proposal

The same infrastructure(ERC1056 contract) that is now used to resolve ethr-dids could support DIDs that are based on secp256k1 public keys.
The queries to the erc1056 contract would be the same, it would be up to the resolver to compute the corresponding ethereumAddress to be able to perform the queries.

Example DID

  • existing ethr-did:
    did:ethr:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74
    did:ethr:0x4:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74
    did:ethr:rinkeby:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74
  • proposed DID using publicKeyHex (compressed):
    • generic (mainnet)
      did:ethr:0x02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71
    • with chainID did:ethr:0x4:0x02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71
    • with network name did:ethr:rinkeby:0x02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71

Example default DID document

(the newer format from W3C is a separate line of work)

{
  "@context": "https://w3id.org/did/v1",
  "id": "did:ethr:0x02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71",
  "publicKey": [
    {
         "id": "did:ethr:0x02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71#owner",
         "type": "Secp256k1VerificationKey2018",
         "publicKeyHex": "0x02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71"
    },
    {
         "id": "did:ethr:0x02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71#key-1",
         "type": "Secp256k1VerificationKey2018",
         "ethereumAddress": "0xf3beac30c498d9e26865f34fcaa57dbb935b0d74"
    }
  ],
  "authentication": [
    {
         "type": "Secp256k1SignatureAuthentication2018",
         "publicKey": "did:ethr:0x02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71#owner"
    },
    {
         "type": "Secp256k1SignatureAuthentication2018",
         "publicKey": "did:ethr:0x02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71#key-1"
    }
  ]
}

Details

Owner changes

The present ERC1056 contract can only list an ethereumAddress as owner so changing owner MUST invalidate the publicKey identifier as well as the corresponding ethereumAddress from the list of publicKey and authentication sections (and any other corresponding entries that may appear in newer W3C docs).
Ownership changes that would automatically list a full public key would require changes to the contract code which is not an intent of this proposal.
If an owner needs to be changed, the assumption is that they already have access to gas, so they could first add the new publicKey as attribute and then shift ownership.

Multi-network

Multi-network support MUST NOT be affected by this change.
the format did:ethr[:<network>]:<identifier> is preserved, only the identifier can now be of 2 formats.

  • 42 chars -> ethereumAddress
  • 68 chars -> compressed publicKey

Steps

  • resolve("did:ethr:pubKey")
    • pubKey -> uncompressed pubKey -> origAddress
    • query ERC1056 contract with origAddress to get owner, delegates and attribute history
    • if owner is origAddress, add entries for both pubKey and origAddress to the publicKey and authentication sections in the resulting DID doc, otherwise, add only the new owner address
    • if origAddress is one of the delegates, add pubKey to the publicKey section of the resulting DID doc
    • continue building the rest of the document by existing rules
  • resolve("did:ethr:ethereumAddress")
    • no changes to functionality expected; resolve by existing rules
@mirceanis mirceanis added the enhancement New feature or request label Mar 23, 2020
@mirceanis
Copy link
Member Author

@awoie please share some feedback here if you have any

@awoie
Copy link
Member

awoie commented Mar 23, 2020

@mirceanis what would it take to use publicKeyJwk or publicKeyBase58 instead? publicKeyHex might get removed from the DID Core spec: w3c/did-core#236

(I will provide more feedback later this week)

@awoie
Copy link
Member

awoie commented Mar 23, 2020

@mirceanis we should already remove ethereumAddress from the publicKey section and just add it to the authentication section. You would then embed the whole value of the entry there.

@mirceanis
Copy link
Member Author

what would it take to use publicKeyJwk or publicKeyBase58 instead? publicKeyHex might get removed from the DID Core spec: w3c/did-core#236

The identifier could be represented in other encodings. I chose publicKeyHex in compressed form as a simple mechanism to represent the key material that one can easily tell apart with a simple regex.

I considered base64 or 58 as well but then realized that future improvements to this spec are more likely to use something similar to did:key so publicKeyHex is easier to use as there is no ambiguity.

For the identifier part, JWK does not make sense.

The representation of the key in the DID document does not have to match the identifier encoding.
If needed, the key entry in the resulting DID doc can be JWK or base58. That's one of the reasons for the existence of this proposal :)


we should already remove ethereumAddress from the publicKey section and just add it to the authentication section. You would then embed the whole value of the entry there.

I think it is too early for that since there is no real benefit other than semantics and there is a huge amount of technical damage and a hard transition period if it is done prematurely.
I would rather wait for the DID spec to be closer to a stable form before deciding this.

@uport-automation-bot
Copy link
Collaborator

🎉 This issue has been resolved in version 2.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

veramo-bot pushed a commit to veramolabs/ens-did-resolver that referenced this issue Jul 10, 2022
# 1.0.0 (2022-07-10)

### Bug Fixes

* change 'owner' to 'controller' to follow W3C Spec ([decentralized-identity#75](https://github.com/veramolabs/ens-did-resolver/issues/75)) ([decentralized-identity#81](https://github.com/veramolabs/ens-did-resolver/issues/81)) ([af37b3f](af37b3f))
* ignore query string when interpreting identifiers ([decentralized-identity#123](https://github.com/veramolabs/ens-did-resolver/issues/123)) ([5508f8a](5508f8a)), closes [decentralized-identity#122](https://github.com/veramolabs/ens-did-resolver/issues/122)
* maintenance of dependencies, bots and build scripts ([decentralized-identity#136](https://github.com/veramolabs/ens-did-resolver/issues/136)) ([0d3fcf7](0d3fcf7))
* remove unused dependency ([#4](#4)) ([a97c826](a97c826))
* removed redundant code ([ca4d101](ca4d101))
* reverse events to have consistent order ([decentralized-identity#87](https://github.com/veramolabs/ens-did-resolver/issues/87)) ([08b9692](08b9692)), closes [/github.com/decentralized-identity/issues/86#issuecomment-699961595](https://github.com//github.com/decentralized-identity/ethr-did-resolver/issues/86/issues/issuecomment-699961595)
* strip milliseconds from dateTime strings ([decentralized-identity#129](https://github.com/veramolabs/ens-did-resolver/issues/129)) ([3e958af](3e958af)), closes [decentralized-identity#126](https://github.com/veramolabs/ens-did-resolver/issues/126)
* use rpcUrl in controller config ([decentralized-identity#128](https://github.com/veramolabs/ens-did-resolver/issues/128)) ([5302536](5302536)), closes [decentralized-identity#127](https://github.com/veramolabs/ens-did-resolver/issues/127)
* **deps:** update dependency buffer to v6 ([decentralized-identity#93](https://github.com/veramolabs/ens-did-resolver/issues/93)) ([e1dc861](e1dc861))
* **deps:** update dependency did-resolver to v1.1.0 ([ab47058](ab47058))
* **deps:** update dependency did-resolver to v2 ([decentralized-identity#68](https://github.com/veramolabs/ens-did-resolver/issues/68)) ([831ec17](831ec17))
* **deps:** update dependency did-resolver to v2.1.0 ([b26d387](b26d387))
* **deps:** update dependency did-resolver to v2.1.1 ([1a4cbca](1a4cbca))
* **deps:** update dependency did-resolver to v2.1.2 ([8c2294e](8c2294e))
* **deps:** update dependency ethjs-contract to ^0.2.0 ([b667ce6](b667ce6))
* **deps:** use Resolvable type from did-resolver ([d213ae6](d213ae6))
* **types:** simplify type exports ([decentralized-identity#101](https://github.com/veramolabs/ens-did-resolver/issues/101)) ([90ca9b5](90ca9b5))
* remove ejs module distribution ([780ec08](780ec08)), closes [decentralized-identity#39](https://github.com/veramolabs/ens-did-resolver/issues/39)
* require a configuration to be used when initializing the resolver ([3adc029](3adc029))

### Features

* add `assertionMethod` by default to didDocument ([decentralized-identity#124](https://github.com/veramolabs/ens-did-resolver/issues/124)) ([11b2096](11b2096)), closes [decentralized-identity#117](https://github.com/veramolabs/ens-did-resolver/issues/117) [decentralized-identity#115](https://github.com/veramolabs/ens-did-resolver/issues/115)
* add ability to use a compressed publicKey as identifier ([decentralized-identity#73](https://github.com/veramolabs/ens-did-resolver/issues/73)) ([e257eb3](e257eb3)), closes [decentralized-identity#56](https://github.com/veramolabs/ens-did-resolver/issues/56)
* add encryption key support for ethr-did-documents ([dff7b0f](dff7b0f)), closes [decentralized-identity#52](https://github.com/veramolabs/ens-did-resolver/issues/52)
* add encryption key support for ethr-did-documents ([2f5825c](2f5825c)), closes [decentralized-identity#52](https://github.com/veramolabs/ens-did-resolver/issues/52)
* Add types declaration stubb ([05944b1](05944b1))
* export `EthrDidController` helper class ([decentralized-identity#120](https://github.com/veramolabs/ens-did-resolver/issues/120)) ([745100d](745100d))
* import instead of require networks.json ([50c0832](50c0832))
* Initial version ([#1](#1)) ([d7a3cf8](d7a3cf8))
* upgrade to latest did core spec ([decentralized-identity#99](https://github.com/veramolabs/ens-did-resolver/issues/99)) ([decentralized-identity#109](https://github.com/veramolabs/ens-did-resolver/issues/109)) ([d46eea3](d46eea3)), closes [decentralized-identity#105](https://github.com/veramolabs/ens-did-resolver/issues/105) [decentralized-identity#95](https://github.com/veramolabs/ens-did-resolver/issues/95) [decentralized-identity#106](https://github.com/veramolabs/ens-did-resolver/issues/106) [decentralized-identity#83](https://github.com/veramolabs/ens-did-resolver/issues/83) [decentralized-identity#85](https://github.com/veramolabs/ens-did-resolver/issues/85) [decentralized-identity#83](https://github.com/veramolabs/ens-did-resolver/issues/83) [decentralized-identity#85](https://github.com/veramolabs/ens-did-resolver/issues/85) [decentralized-identity#95](https://github.com/veramolabs/ens-did-resolver/issues/95) [decentralized-identity#105](https://github.com/veramolabs/ens-did-resolver/issues/105) [decentralized-identity#106](https://github.com/veramolabs/ens-did-resolver/issues/106)
* upgrade to latest did core spec ([decentralized-identity#99](https://github.com/veramolabs/ens-did-resolver/issues/99)) ([decentralized-identity#109](https://github.com/veramolabs/ens-did-resolver/issues/109)) ([decentralized-identity#111](https://github.com/veramolabs/ens-did-resolver/issues/111)) ([2a023b1](2a023b1)), closes [decentralized-identity#105](https://github.com/veramolabs/ens-did-resolver/issues/105) [decentralized-identity#95](https://github.com/veramolabs/ens-did-resolver/issues/95) [decentralized-identity#106](https://github.com/veramolabs/ens-did-resolver/issues/106) [decentralized-identity#83](https://github.com/veramolabs/ens-did-resolver/issues/83) [decentralized-identity#85](https://github.com/veramolabs/ens-did-resolver/issues/85) [decentralized-identity#83](https://github.com/veramolabs/ens-did-resolver/issues/83) [decentralized-identity#85](https://github.com/veramolabs/ens-did-resolver/issues/85) [decentralized-identity#95](https://github.com/veramolabs/ens-did-resolver/issues/95) [decentralized-identity#105](https://github.com/veramolabs/ens-did-resolver/issues/105) [decentralized-identity#106](https://github.com/veramolabs/ens-did-resolver/issues/106)
* use only named exports ([decentralized-identity#31](https://github.com/veramolabs/ens-did-resolver/issues/31)) ([a558e14](a558e14))
* versioning ([decentralized-identity#121](https://github.com/veramolabs/ens-did-resolver/issues/121)) ([b794d69](b794d69)), closes [decentralized-identity#119](https://github.com/veramolabs/ens-did-resolver/issues/119) [decentralized-identity#118](https://github.com/veramolabs/ens-did-resolver/issues/118) [decentralized-identity#119](https://github.com/veramolabs/ens-did-resolver/issues/119) [decentralized-identity#118](https://github.com/veramolabs/ens-did-resolver/issues/118)

### BREAKING CHANGES

* The return type is `DIDResolutionResult` which wraps a `DIDDocument`.
* No errors are thrown during DID resolution. Please check `result.didResolutionMetadata.error` instead.
* This DID core spec requirement will break for users expecting `publicKey`, `ethereumAddress`, `Secp256k1VerificationKey2018` entries in the DID document. They are replaced with `verificationMethod`, `blockchainAccountId` and `EcdsaSecp256k1VerificationKey2019` and `EcdsaSecp256k1RecoveryMethod2020` depending on the content.
* JWTs that refer to the `did:ethr:...#owner` key in their header may be considered invalid after this upgrade, as the key id is now `did:ethr:...#controller`
* this removes the fallback hardcoded RPC URLs and will fail early when a wrong configuration (or none) is provided to `getResolver()`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants