diff --git a/README.md b/README.md index 4faa6c82..684f54b1 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ distinct identifier than the generic one. ## DID Document -The did resolver takes the ethereum address, checks for the current owner, looks at contract events and builds a simple DID document. +The did resolver takes the ethereum address, checks for the current controller, looks at contract events and builds a simple DID document. The minimal DID document for a an ethereum address `0xb9c5714089478a327f09197987f16f9e5d936e8a` with no transactions to the registry looks like this: @@ -46,13 +46,13 @@ The minimal DID document for a an ethereum address `0xb9c5714089478a327f09197987 '@context': 'https://w3id.org/did/v1', id: 'did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a', publicKey: [{ - id: 'did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a#owner', + id: 'did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a#controller', type: 'Secp256k1VerificationKey2018', - owner: 'did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a', + controller: 'did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a', ethereumAddress: '0xb9c5714089478a327f09197987f16f9e5d936e8a'}], authentication: [{ type: 'Secp256k1SignatureAuthentication2018', - publicKey: 'did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a#owner'}] + publicKey: 'did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a#controller'}] } ``` @@ -64,11 +64,11 @@ The DID document is built by using read only functions and contract events on th Any value from the registry that returns an ethereum address will be added to the `publicKey` array of the DID document with type `Secp256k1VerificationKey2018` and an `ethereumAddress` attribute containing the address. -### Owner Address +### Controller Address -Each identity always has an owner address. By default it's the same as the identity address, but check the read only contract function `identityOwner(address identity)` on the deployed version of the EthrDIDRegistry contract. +Each identity always has a controller address. By default it's the same as the identity address, but check the read only contract function `identityOwner(address identity)` on the deployed version of the EthrDIDRegistry contract. -The Identity owner will always have a `publicKey` with the id set as the DID with the fragment `#owner` appended. +The Identity controller will always have a `publicKey` with the id set as the DID with the fragment `#controller` appended. An entry is also added to the `authentication` array of the DID document with type `Secp256k1SignatureAuthentication2018`. @@ -76,7 +76,7 @@ An entry is also added to the `authentication` array of the DID document with ty The `EthereumDIDRegistry` contract publishes 3 types of events for each identity. -- `DIDOwnerChanged` +- `DIDOwnerChanged` (indicating a change of controller) - `DIDDelegateChanged` - `DIDAttributeChanged` @@ -169,7 +169,7 @@ generates a `PublicKey` entry like this: { id: "did:ethr:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74#delegate-1", type: "Secp256k1VerificationKey2018", - owner: "did:ethr:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74", + controller: "did:ethr:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74", publicKeyHex: '02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71' } ``` @@ -184,7 +184,7 @@ A `DIDAttributeChanged` event for the identity `0xf3beac30c498d9e26865f34fcaa57d { id: "did:ethr:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74#delegate-1", type: "Ed25519VerificationKey2018", - owner: "did:ethr:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74", + controller: "did:ethr:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74", publicKeyBase64: "uXww3nZ/CEzjCAFo7ikwU7ozsjXXEWoyY9KfFFCTa3E=" } ``` @@ -200,7 +200,7 @@ generates a `PublicKey` entry like this: { id: "did:ethr:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74#delegate-1", type: "X25519KeyAgreementKey2019", - owner: "did:ethr:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74", + controller: "did:ethr:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74", publicKeyBase64: "MCowBQYDK2VuAyEAEYVXd3/7B4d0NxpSsA/tdVYdz5deYcR1U+ZkphdmEFI=" } ``` @@ -242,7 +242,7 @@ import { getResolver } from 'ethr-did-resolver' // You can also set an address for your own ethr-did-registry contract const providerConfig = { rpcUrl: 'https://rinkeby.infura.io/ethr-did', registry: registry.address } -// getResolver will return an object with a key/value pair of { "ethr": resolver } where resolver is a function used by the generic did resolver. +// getResolver will return an object with a key/value pair of { "ethr": resolver } where resolver is a function used by the generic did resolver. const ethrDidResolver = getResolver(providerConfig) const didResolver = new Resolver(ethrDidResolver) @@ -278,6 +278,6 @@ This allows you to resolve ethr-did's of the formats: For each network you can specify either an `rpcUrl`, a `provider` or a `web3` instance that can be used to access that particular network. -These providers will have to support and `eth_call`, `eth_getLogs` to be able to resolve DIDs specific to that network. +These providers will have to support and `eth_call`, `eth_getLogs` to be able to resolve DIDs specific to that network. You can also override the default registry address by specifying a `registry` attribute per network. diff --git a/doc/did-method-spec.md b/doc/did-method-spec.md index 384be90b..01a1eee3 100644 --- a/doc/did-method-spec.md +++ b/doc/did-method-spec.md @@ -6,9 +6,9 @@ ## Preface -The ethr DID method specification conforms to the requirements specified in -the [DID specification](https://w3c-ccg.github.io/did-core/), currently published by the -W3C Credentials Community Group. For more information about DIDs and DID method specifications, +The ethr DID method specification conforms to the requirements specified in +the [DID specification](https://w3c-ccg.github.io/did-core/), currently published by the +W3C Credentials Community Group. For more information about DIDs and DID method specifications, please see the [DID Primer](https://github.com/WebOfTrustInfo/rebooting-the-web-of-trust-fall2017/blob/master/topics-and-advance-readings/did-primer.md) ## Abstract @@ -37,18 +37,18 @@ ARTIS sigma1 | `artis_s1` | 0x03c301 | `0xdca7ef03e98e0dc2b855be647c39abe Since each Ethereum transaction must be funded, there is a growing trend of on-chain transactions that are authenticated via an externally created signature and not by the actual transaction originator. This allows for 3rd party funding services, or for receivers to pay without any fundamental changes to the underlying -Ethereum architecture. These kinds of transactions have to be signed by an actual key pair and thus cannot be used -to represent smart contract based Ethereum accounts. ERC1056 proposes a way of a smart contract or regular key pair +Ethereum architecture. These kinds of transactions have to be signed by an actual key pair and thus cannot be used +to represent smart contract based Ethereum accounts. ERC1056 proposes a way of a smart contract or regular key pair delegating signing for various purposes to externally managed key pairs. This allows a smart contract to be represented, both on-chain as well as off-chain or in payment channels through temporary or permanent delegates. For a reference implementation of this DID method specification see [3]. -### Identity Ownership -By default, each identity is controlled by itself. Each identity can only be controlled by a single -address at any given time. By default, this is the address of the identity itself. The owner can +### Identity Controller +By default, each identity is controlled by itself. Each identity can only be controlled by a single +address at any given time. By default, this is the address of the identity itself. The controller can replace themselves with any other Ethereum address, including contracts to allow more advanced -models such as multi-signature ownership. +models such as multi-signature controllership. ## Target System @@ -64,15 +64,15 @@ The target system is the Ethereum network where the ERC1056 is deployed. This co - No transaction fee on identity creation - Uses Ethereum's built-in account abstraction -- Multi-sig wallet for identity owner +- Multi-sig wallet for identity controller - Decoupling claims data from the underlying identity - Decoupling Ethereum interaction from the underlying identity - Flexibility to use key management - Flexibility to allow third-party funding service to pay the gas fee if needed -- Supports any EVM-compliant blockchain +- Supports any EVM-compliant blockchain ## JSON-LD Context Definition -Note, this DID method specification uses the `Secp256k1VerificationKey2018`, +Note, this DID method specification uses the `Secp256k1VerificationKey2018`, `Secp256k1SignatureAuthentication2018` types and an `ethereumAddress` instead of a `publicKeyHex`. @@ -91,7 +91,7 @@ The definition of the ethr DID JSON-LD context is: The namestring that shall identify this DID method is: `ethr` -A DID that uses this method MUST begin with the following prefix: `did:ethr`. Per the DID specification, this string +A DID that uses this method MUST begin with the following prefix: `did:ethr`. Per the DID specification, this string MUST be in lowercase. The remainder of the DID, after the prefix, is specified below. ## Method Specific Identifier @@ -137,28 +137,28 @@ transactions to the ERC1056 registry looks like this: '@context': 'https://w3id.org/did/v1', id: 'did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a', publicKey: [{ - id: 'did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a#owner', + id: 'did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a#controller', type: 'Secp256k1VerificationKey2018', - owner: 'did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a', + controller: 'did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a', ethereumAddress: '0xb9c5714089478a327f09197987f16f9e5d936e8a'}], authentication: [{ type: 'Secp256k1SignatureAuthentication2018', - publicKey: 'did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a#owner'}] + publicKey: 'did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a#controller'}] } ### Read (Resolve) The DID document is built by using read only functions and contract events on the ERC1056 registry. -Any value from the registry that returns an Ethereum address will be added to the `publicKey` array of the DID +Any value from the registry that returns an Ethereum address will be added to the `publicKey` array of the DID document with type `Secp256k1VerificationKey2018` and an `ethereumAddress` attribute containing the address. -#### Owner Address +#### Controller Address -Each identity always has an owner address. By default it is the same as the identity address, but check the +Each identity always has a controller address. By default it is the same as the identity address, but check the read only contract function `identityOwner(address identity)` on the deployed version of the ERC1056 contract. -The identity owner will always have a `publicKey` with the id set as the DID with the fragment `#owner` appended. +The identity controller will always have a `publicKey` with the id set as the DID with the fragment `#controller` appended. An entry is also added to the `authentication` array of the DID document with type `Secp256k1SignatureAuthentication2018`. @@ -166,7 +166,7 @@ An entry is also added to the `authentication` array of the DID document with ty The ERC1056 contract publishes three types of events for each identity. -- `DIDOwnerChanged` +- `DIDOwnerChanged` (indicating a change of controller) - `DIDDelegateChanged` - `DIDAttributeChanged` @@ -199,7 +199,7 @@ A `DIDDelegateChanged` event is published that is used to build a DID document. uint validTo, uint previousChange ); - + The only 2 `delegateTypes` that are currently published in the DID document are: @@ -207,14 +207,14 @@ The only 2 `delegateTypes` that are currently published in the DID document are: - `sigAuth` which adds a `Secp256k1SignatureAuthentication2018` to the `publicKey` section of document. An entry is also added to the `authentication` section of the DID document. -Note, the `delegateType` is a `bytes32` type for Ethereum gas efficiency reasons and not a `string`. This +Note, the `delegateType` is a `bytes32` type for Ethereum gas efficiency reasons and not a `string`. This restricts us to 32 bytes, which is why we use the short hand versions above. Only events with a `validTo` in seconds greater or equal to the current time should be included in the DID document. #### Non-Ethereum Attributes -Non-Ethereum keys, service endpoints etc. can be added using attributes. Attributes only exist on the +Non-Ethereum keys, service endpoints etc. can be added using attributes. Attributes only exist on the blockchain as contract events of type `DIDAttributeChanged` and can thus not be queried from within solidity code. event DIDAttributeChanged( @@ -225,10 +225,10 @@ blockchain as contract events of type `DIDAttributeChanged` and can thus not be uint previousChange ); -Note, the name is a `bytes32` type for Ethereum gas efficiency reasons and not a `string`. This restricts us to +Note, the name is a `bytes32` type for Ethereum gas efficiency reasons and not a `string`. This restricts us to 32 bytes, which is why we use the short hand attribute versions below. -While any attribute can be stored, for the DID document we currently support adding to each of these sections of +While any attribute can be stored, for the DID document we currently support adding to each of these sections of the DID document: - Public Keys @@ -255,7 +255,7 @@ generates a public key entry like the following: ##### Base64 encoded Ed25519 Verification Key -A `DIDAttributeChanged` event for the identity `0xf3beac30c498d9e26865f34fcaa57dbb935b0d74` with the name +A `DIDAttributeChanged` event for the identity `0xf3beac30c498d9e26865f34fcaa57dbb935b0d74` with the name `did/pub/Ed25519/veriKey/base64` and the value of `0xb97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71` generates a public key entry like this: @@ -272,8 +272,8 @@ The name of the attribute should follow this format: `did/svc/[ServiceName]` -A `DIDAttributeChanged` event for the identity `0xf3beac30c498d9e26865f34fcaa57dbb935b0d74` with the name -`did/svc/HubService` and value of the URL `https://hubs.uport.me` hex encoded as +A `DIDAttributeChanged` event for the identity `0xf3beac30c498d9e26865f34fcaa57dbb935b0d74` with the name +`did/svc/HubService` and value of the URL `https://hubs.uport.me` hex encoded as `0x68747470733a2f2f687562732e75706f72742e6d65` generates a service endpoint entry like the following: { @@ -297,22 +297,22 @@ Two cases need to be distinguished: - In case no changes were written to ERC1056, nothing needs to be done, and the private key which belongs to the Ethereum address needs to be deleted from the storage medium used to protect the keys, e.g., mobile device. - In case ERC1056 was utilized, the owner of the smart contract needs to be set to `0x0`. Although, `0x0`is a valid - Ethereum address, this will indicate the identity has no owner which is a common approach for invalidation, + Ethereum address, this will indicate the identity has no owner which is a common approach for invalidation, e.g., tokens. Other elements of the DID Document may be revoked explicitly by invoking the relevant smart contract functions as defined by the ERC1056 standard. This includes the delegates and additional attributes. Please find a detailed description in the [ERC1056 documentation](https://github.com/ethereum/EIPs/issues/1056). All these functions will trigger the respective Ethereum events which are used to build the DID Document for a given identity as - described in [Enumerating Contract Events to build the DID Document](#Enumerating-Contract-Events-to-build-the-DID-Document). + described in [Enumerating Contract Events to build the DID Document](#Enumerating-Contract-Events-to-build-the-DID-Document). ## Reference Implementations The code at [https://github.com/decentralized-identity/ethr-did-resolver](<>) is intended to present a reference implementation -of this DID method. +of this DID method. ## References **[1]** - **[2]** + **[2]** **[3]** diff --git a/src/__tests__/ethr-did-resolver-test.js b/src/__tests__/ethr-did-resolver-test.js index 5773a100..1cbbd1e2 100644 --- a/src/__tests__/ethr-did-resolver-test.js +++ b/src/__tests__/ethr-did-resolver-test.js @@ -94,12 +94,12 @@ describe('ethrResolver', () => { ) } - let registry, accounts, did, identity, owner, delegate1, delegate2, ethr, didResolver + let registry, accounts, did, identity, controller, delegate1, delegate2, ethr, didResolver beforeAll(async () => { accounts = await getAccounts() identity = accounts[1] - owner = accounts[2] + controller = accounts[2] delegate1 = accounts[3] delegate2 = accounts[4] did = `did:ethr:${identity}` @@ -120,16 +120,16 @@ describe('ethrResolver', () => { id: did, publicKey: [ { - id: `${did}#owner`, + id: `${did}#controller`, type: 'Secp256k1VerificationKey2018', - owner: did, + controller: did, ethereumAddress: identity } ], authentication: [ { type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${did}#owner` + publicKey: `${did}#controller` } ] }) @@ -143,35 +143,35 @@ describe('ethrResolver', () => { id: pubdid, publicKey: [ { - id: `${pubdid}#owner`, + id: `${pubdid}#controller`, type: 'Secp256k1VerificationKey2018', - owner: pubdid, + controller: pubdid, ethereumAddress: identity }, { - id: `${pubdid}#ownerKey`, + id: `${pubdid}#controllerKey`, type: 'Secp256k1VerificationKey2018', - owner: pubdid, + controller: pubdid, publicKeyHex: pubKey } ], authentication: [ { type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${pubdid}#owner` + publicKey: `${pubdid}#controller` }, { type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${pubdid}#ownerKey` + publicKey: `${pubdid}#controllerKey` } ] }) }) }) - describe('owner changed', () => { + describe('controller changed', () => { beforeAll(async () => { - await registry.changeOwner(identity, owner, { from: identity }) + await registry.changeOwner(identity, controller, { from: identity }) }) it('resolves document', () => { @@ -180,22 +180,22 @@ describe('ethrResolver', () => { id: did, publicKey: [ { - id: `${did}#owner`, + id: `${did}#controller`, type: 'Secp256k1VerificationKey2018', - owner: did, - ethereumAddress: owner + controller: did, + ethereumAddress: controller } ], authentication: [ { type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${did}#owner` + publicKey: `${did}#controller` } ] }) }) - it('changing owner invalidates the publicKey as identifier', async () => { + it('changing controller invalidates the publicKey as identifier', async () => { const pubKey = '0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798' const pubdid = `did:ethr:${pubKey}` const doc = await didResolver.resolve(pubdid) @@ -204,16 +204,16 @@ describe('ethrResolver', () => { id: pubdid, publicKey: [ { - id: `${pubdid}#owner`, + id: `${pubdid}#controller`, type: 'Secp256k1VerificationKey2018', - owner: pubdid, - ethereumAddress: owner + controller: pubdid, + ethereumAddress: controller } ], authentication: [ { type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${pubdid}#owner` + publicKey: `${pubdid}#controller` } ] }) @@ -225,7 +225,7 @@ describe('ethrResolver', () => { describe('delegates', () => { describe('add signing delegate', () => { beforeAll(async () => { - await registry.addDelegate(identity, Secp256k1VerificationKey2018, delegate1, 2, { from: owner }) + await registry.addDelegate(identity, Secp256k1VerificationKey2018, delegate1, 2, { from: controller }) }) it('resolves document', () => { @@ -234,22 +234,22 @@ describe('ethrResolver', () => { id: did, publicKey: [ { - id: `${did}#owner`, + id: `${did}#controller`, type: 'Secp256k1VerificationKey2018', - owner: did, - ethereumAddress: owner + controller: did, + ethereumAddress: controller }, { id: `${did}#delegate-1`, type: 'Secp256k1VerificationKey2018', - owner: did, + controller: did, ethereumAddress: delegate1 } ], authentication: [ { type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${did}#owner` + publicKey: `${did}#controller` } ] }) @@ -258,7 +258,7 @@ describe('ethrResolver', () => { describe('add auth delegate', () => { beforeAll(async () => { - await registry.addDelegate(identity, Secp256k1SignatureAuthentication2018, delegate2, 10, { from: owner }) + await registry.addDelegate(identity, Secp256k1SignatureAuthentication2018, delegate2, 10, { from: controller }) }) it('resolves document', () => { @@ -267,28 +267,28 @@ describe('ethrResolver', () => { id: did, publicKey: [ { - id: `${did}#owner`, + id: `${did}#controller`, type: 'Secp256k1VerificationKey2018', - owner: did, - ethereumAddress: owner + controller: did, + ethereumAddress: controller }, { id: `${did}#delegate-1`, type: 'Secp256k1VerificationKey2018', - owner: did, + controller: did, ethereumAddress: delegate1 }, { id: `${did}#delegate-2`, type: 'Secp256k1VerificationKey2018', - owner: did, + controller: did, ethereumAddress: delegate2 } ], authentication: [ { type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${did}#owner` + publicKey: `${did}#controller` }, { type: 'Secp256k1SignatureAuthentication2018', @@ -310,22 +310,22 @@ describe('ethrResolver', () => { id: did, publicKey: [ { - id: `${did}#owner`, + id: `${did}#controller`, type: 'Secp256k1VerificationKey2018', - owner: did, - ethereumAddress: owner + controller: did, + ethereumAddress: controller }, { id: `${did}#delegate-1`, type: 'Secp256k1VerificationKey2018', - owner: did, + controller: did, ethereumAddress: delegate2 } ], authentication: [ { type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${did}#owner` + publicKey: `${did}#controller` }, { type: 'Secp256k1SignatureAuthentication2018', @@ -338,7 +338,7 @@ describe('ethrResolver', () => { describe('revokes delegate', () => { beforeAll(async () => { - await registry.revokeDelegate(identity, Secp256k1SignatureAuthentication2018, delegate2, { from: owner }) + await registry.revokeDelegate(identity, Secp256k1SignatureAuthentication2018, delegate2, { from: controller }) await sleep(1) }) @@ -348,16 +348,16 @@ describe('ethrResolver', () => { id: did, publicKey: [ { - id: `${did}#owner`, + id: `${did}#controller`, type: 'Secp256k1VerificationKey2018', - owner: did, - ethereumAddress: owner + controller: did, + ethereumAddress: controller } ], authentication: [ { type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${did}#owner` + publicKey: `${did}#controller` } ] }) @@ -367,7 +367,7 @@ describe('ethrResolver', () => { describe('re-add auth delegate', () => { beforeAll(async () => { await sleep(3) - await registry.addDelegate(identity, Secp256k1SignatureAuthentication2018, delegate2, 86400, { from: owner }) + await registry.addDelegate(identity, Secp256k1SignatureAuthentication2018, delegate2, 86400, { from: controller }) }) it('resolves document', () => { @@ -376,22 +376,22 @@ describe('ethrResolver', () => { id: did, publicKey: [ { - id: `${did}#owner`, + id: `${did}#controller`, type: 'Secp256k1VerificationKey2018', - owner: did, - ethereumAddress: owner + controller: did, + ethereumAddress: controller }, { id: `${did}#delegate-1`, type: 'Secp256k1VerificationKey2018', - owner: did, + controller: did, ethereumAddress: delegate2 } ], authentication: [ { type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${did}#owner` + publicKey: `${did}#controller` }, { type: 'Secp256k1SignatureAuthentication2018', @@ -412,7 +412,7 @@ describe('ethrResolver', () => { stringToBytes32('did/pub/Secp256k1/veriKey'), '0x02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71', 10, - { from: owner } + { from: controller } ) }) it('resolves document', () => { @@ -421,28 +421,28 @@ describe('ethrResolver', () => { id: did, publicKey: [ { - id: `${did}#owner`, + id: `${did}#controller`, type: 'Secp256k1VerificationKey2018', - owner: did, - ethereumAddress: owner + controller: did, + ethereumAddress: controller }, { id: `${did}#delegate-1`, type: 'Secp256k1VerificationKey2018', - owner: did, + controller: did, ethereumAddress: delegate2 }, { id: `${did}#delegate-2`, type: 'Secp256k1VerificationKey2018', - owner: did, + controller: did, publicKeyHex: '02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71' } ], authentication: [ { type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${did}#owner` + publicKey: `${did}#controller` }, { type: 'Secp256k1SignatureAuthentication2018', @@ -460,7 +460,7 @@ describe('ethrResolver', () => { stringToBytes32('did/pub/Ed25519/veriKey/base64'), '0x02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71', 10, - { from: owner } + { from: controller } ) }) @@ -470,27 +470,27 @@ describe('ethrResolver', () => { id: did, publicKey: [ { - id: `${did}#owner`, + id: `${did}#controller`, type: 'Secp256k1VerificationKey2018', - owner: did, - ethereumAddress: owner + controller: did, + ethereumAddress: controller }, { id: `${did}#delegate-1`, type: 'Secp256k1VerificationKey2018', - owner: did, + controller: did, ethereumAddress: delegate2 }, { id: `${did}#delegate-2`, type: 'Secp256k1VerificationKey2018', - owner: did, + controller: did, publicKeyHex: '02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71' }, { id: `${did}#delegate-3`, type: 'Ed25519VerificationKey2018', - owner: did, + controller: did, publicKeyBase64: Buffer.from( '02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71', 'hex' @@ -500,7 +500,7 @@ describe('ethrResolver', () => { authentication: [ { type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${did}#owner` + publicKey: `${did}#controller` }, { type: 'Secp256k1SignatureAuthentication2018', @@ -518,7 +518,7 @@ describe('ethrResolver', () => { stringToBytes32('did/pub/RSA/veriKey/pem'), '-----BEGIN PUBLIC KEY...END PUBLIC KEY-----\r\n', 10, - { from: owner } + { from: controller } ) }) @@ -528,27 +528,27 @@ describe('ethrResolver', () => { id: did, publicKey: [ { - id: `${did}#owner`, + id: `${did}#controller`, type: 'Secp256k1VerificationKey2018', - owner: did, - ethereumAddress: owner + controller: did, + ethereumAddress: controller }, { id: `${did}#delegate-1`, type: 'Secp256k1VerificationKey2018', - owner: did, + controller: did, ethereumAddress: delegate2 }, { id: `${did}#delegate-2`, type: 'Secp256k1VerificationKey2018', - owner: did, + controller: did, publicKeyHex: '02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71' }, { id: `${did}#delegate-3`, type: 'Ed25519VerificationKey2018', - owner: did, + controller: did, publicKeyBase64: Buffer.from( '02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71', 'hex' @@ -557,14 +557,14 @@ describe('ethrResolver', () => { { id: `${did}#delegate-4`, type: 'RSAVerificationKey2018', - owner: did, + controller: did, publicKeyPem: '-----BEGIN PUBLIC KEY...END PUBLIC KEY-----\r\n' } ], authentication: [ { type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${did}#owner` + publicKey: `${did}#controller` }, { type: 'Secp256k1SignatureAuthentication2018', @@ -600,22 +600,22 @@ describe('ethrResolver', () => { id: did1, publicKey: [ { - id: `${did1}#owner`, + id: `${did1}#controller`, type: 'Secp256k1VerificationKey2018', - owner: did1, + controller: did1, ethereumAddress: identity1 }, { id: `${did1}#delegate-1`, type: 'X25519KeyAgreementKey2019', - owner: did1, + controller: did1, publicKeyBase64: 'MCowBQYDK2VuAyEAEYVXd3/7B4d0NxpSsA/tdVYdz5deYcR1U+ZkphdmEFI=' } ], authentication: [ { type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${did1}#owner` + publicKey: `${did1}#controller` } ] }) @@ -627,7 +627,7 @@ describe('ethrResolver', () => { describe('HubService', () => { beforeAll(async () => { await registry.setAttribute(identity, stringToBytes32('did/svc/HubService'), 'https://hubs.uport.me', 10, { - from: owner + from: controller }) }) it('resolves document', () => { @@ -636,27 +636,27 @@ describe('ethrResolver', () => { id: did, publicKey: [ { - id: `${did}#owner`, + id: `${did}#controller`, type: 'Secp256k1VerificationKey2018', - owner: did, - ethereumAddress: owner + controller: did, + ethereumAddress: controller }, { id: `${did}#delegate-1`, type: 'Secp256k1VerificationKey2018', - owner: did, + controller: did, ethereumAddress: delegate2 }, { id: `${did}#delegate-2`, type: 'Secp256k1VerificationKey2018', - owner: did, + controller: did, publicKeyHex: '02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71' }, { id: `${did}#delegate-3`, type: 'Ed25519VerificationKey2018', - owner: did, + controller: did, publicKeyBase64: Buffer.from( '02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71', 'hex' @@ -665,14 +665,14 @@ describe('ethrResolver', () => { { id: `${did}#delegate-4`, type: 'RSAVerificationKey2018', - owner: did, + controller: did, publicKeyPem: '-----BEGIN PUBLIC KEY...END PUBLIC KEY-----\r\n' } ], authentication: [ { type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${did}#owner` + publicKey: `${did}#controller` }, { type: 'Secp256k1SignatureAuthentication2018', @@ -697,7 +697,7 @@ describe('ethrResolver', () => { identity, stringToBytes32('did/pub/Secp256k1/veriKey'), '0x02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71', - { from: owner } + { from: controller } ) sleep(1) }) @@ -707,21 +707,21 @@ describe('ethrResolver', () => { id: did, publicKey: [ { - id: `${did}#owner`, + id: `${did}#controller`, type: 'Secp256k1VerificationKey2018', - owner: did, - ethereumAddress: owner + controller: did, + ethereumAddress: controller }, { id: `${did}#delegate-1`, type: 'Secp256k1VerificationKey2018', - owner: did, + controller: did, ethereumAddress: delegate2 }, { id: `${did}#delegate-3`, type: 'Ed25519VerificationKey2018', - owner: did, + controller: did, publicKeyBase64: Buffer.from( '02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71', 'hex' @@ -730,14 +730,14 @@ describe('ethrResolver', () => { { id: `${did}#delegate-4`, type: 'RSAVerificationKey2018', - owner: did, + controller: did, publicKeyPem: '-----BEGIN PUBLIC KEY...END PUBLIC KEY-----\r\n' } ], authentication: [ { type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${did}#owner` + publicKey: `${did}#controller` }, { type: 'Secp256k1SignatureAuthentication2018', @@ -760,7 +760,7 @@ describe('ethrResolver', () => { identity, stringToBytes32('did/pub/Ed25519/veriKey/base64'), '0x02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71', - { from: owner } + { from: controller } ) sleep(1) }) @@ -770,28 +770,28 @@ describe('ethrResolver', () => { id: did, publicKey: [ { - id: `${did}#owner`, + id: `${did}#controller`, type: 'Secp256k1VerificationKey2018', - owner: did, - ethereumAddress: owner + controller: did, + ethereumAddress: controller }, { id: `${did}#delegate-1`, type: 'Secp256k1VerificationKey2018', - owner: did, + controller: did, ethereumAddress: delegate2 }, { id: `${did}#delegate-4`, type: 'RSAVerificationKey2018', - owner: did, + controller: did, publicKeyPem: '-----BEGIN PUBLIC KEY...END PUBLIC KEY-----\r\n' } ], authentication: [ { type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${did}#owner` + publicKey: `${did}#controller` }, { type: 'Secp256k1SignatureAuthentication2018', @@ -814,7 +814,7 @@ describe('ethrResolver', () => { identity, stringToBytes32('did/pub/RSA/veriKey/pem'), '-----BEGIN PUBLIC KEY...END PUBLIC KEY-----\r\n', - { from: owner } + { from: controller } ) sleep(1) }) @@ -825,22 +825,22 @@ describe('ethrResolver', () => { id: did, publicKey: [ { - id: `${did}#owner`, + id: `${did}#controller`, type: 'Secp256k1VerificationKey2018', - owner: did, - ethereumAddress: owner + controller: did, + ethereumAddress: controller }, { id: `${did}#delegate-1`, type: 'Secp256k1VerificationKey2018', - owner: did, + controller: did, ethereumAddress: delegate2 } ], authentication: [ { type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${did}#owner` + publicKey: `${did}#controller` }, { type: 'Secp256k1SignatureAuthentication2018', @@ -862,7 +862,7 @@ describe('ethrResolver', () => { describe('HubService', () => { beforeAll(async () => { await registry.revokeAttribute(identity, stringToBytes32('did/svc/HubService'), 'https://hubs.uport.me', { - from: owner + from: controller }) sleep(1) }) @@ -873,22 +873,22 @@ describe('ethrResolver', () => { id: did, publicKey: [ { - id: `${did}#owner`, + id: `${did}#controller`, type: 'Secp256k1VerificationKey2018', - owner: did, - ethereumAddress: owner + controller: did, + ethereumAddress: controller }, { id: `${did}#delegate-1`, type: 'Secp256k1VerificationKey2018', - owner: did, + controller: did, ethereumAddress: delegate2 } ], authentication: [ { type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${did}#owner` + publicKey: `${did}#controller` }, { type: 'Secp256k1SignatureAuthentication2018', @@ -906,10 +906,10 @@ describe('ethrResolver', () => { await stopMining() await Promise.all([ registry.setAttribute(identity, stringToBytes32('did/svc/TestService'), 'https://test.uport.me', 10, { - from: owner + from: controller }), registry.setAttribute(identity, stringToBytes32('did/svc/TestService'), 'https://test.uport.me', 10, { - from: owner + from: controller }), sleep(1).then(() => startMining()) ]) @@ -921,22 +921,22 @@ describe('ethrResolver', () => { id: did, publicKey: [ { - id: `${did}#owner`, + id: `${did}#controller`, type: 'Secp256k1VerificationKey2018', - owner: did, - ethereumAddress: owner + controller: did, + ethereumAddress: controller }, { id: `${did}#delegate-1`, type: 'Secp256k1VerificationKey2018', - owner: did, + controller: did, ethereumAddress: delegate2 } ], authentication: [ { type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${did}#owner` + publicKey: `${did}#controller` }, { type: 'Secp256k1SignatureAuthentication2018', diff --git a/src/__tests__/networks-tests.js b/src/__tests__/networks-tests.js index afa8fbf1..d788609d 100644 --- a/src/__tests__/networks-tests.js +++ b/src/__tests__/networks-tests.js @@ -20,16 +20,16 @@ describe('ethrResolver (alt-chains)', () => { id: did, publicKey: [ { - id: `${did}#owner`, + id: `${did}#controller`, type: 'Secp256k1VerificationKey2018', - owner: did, + controller: did, ethereumAddress: addr } ], authentication: [ { type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${did}#owner` + publicKey: `${did}#controller` } ] }) @@ -46,16 +46,16 @@ describe('ethrResolver (alt-chains)', () => { id: did, publicKey: [ { - id: `${did}#owner`, + id: `${did}#controller`, type: 'Secp256k1VerificationKey2018', - owner: did, + controller: did, ethereumAddress: addr } ], authentication: [ { type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${did}#owner` + publicKey: `${did}#controller` } ] }) @@ -72,16 +72,16 @@ describe('ethrResolver (alt-chains)', () => { id: did, publicKey: [ { - id: `${did}#owner`, + id: `${did}#controller`, type: 'Secp256k1VerificationKey2018', - owner: did, + controller: did, ethereumAddress: addr } ], authentication: [ { type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${did}#owner` + publicKey: `${did}#controller` } ] }) @@ -96,16 +96,16 @@ describe('ethrResolver (alt-chains)', () => { id: did, publicKey: [ { - id: `${did}#owner`, + id: `${did}#controller`, type: 'Secp256k1VerificationKey2018', - owner: did, + controller: did, ethereumAddress: addr } ], authentication: [ { type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${did}#owner` + publicKey: `${did}#controller` } ] }) @@ -120,16 +120,16 @@ describe('ethrResolver (alt-chains)', () => { id: did, publicKey: [ { - id: `${did}#owner`, + id: `${did}#controller`, type: 'Secp256k1VerificationKey2018', - owner: did, + controller: did, ethereumAddress: addr } ], authentication: [ { type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${did}#owner` + publicKey: `${did}#controller` } ] }) @@ -145,26 +145,26 @@ describe('ethrResolver (alt-chains)', () => { id: did, publicKey: [ { - id: `${did}#owner`, + id: `${did}#controller`, type: 'Secp256k1VerificationKey2018', - owner: did, + controller: did, ethereumAddress: '0xf3beac30c498d9e26865f34fcaa57dbb935b0d74' }, { - id: `${did}#ownerKey`, + id: `${did}#controllerKey`, type: 'Secp256k1VerificationKey2018', - owner: did, + controller: did, publicKeyHex: '0x03fdd57adec3d438ea237fe46b33ee1e016eda6b585c3e27ea66686c2ea5358479' } ], authentication: [ { type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${did}#owner` + publicKey: `${did}#controller` }, { type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${did}#ownerKey` + publicKey: `${did}#controllerKey` } ] }) diff --git a/src/ethr-did-resolver.js b/src/ethr-did-resolver.js index 9a04d598..069e878f 100644 --- a/src/ethr-did-resolver.js +++ b/src/ethr-did-resolver.js @@ -31,36 +31,36 @@ const attrTypes = { enc: 'KeyAgreementKey2019' } -function wrapDidDocument(did, owner, ownerKey, history) { +function wrapDidDocument(did, controller, controllerKey, history) { const now = new BN(Math.floor(new Date().getTime() / 1000)) // const expired = {} const publicKey = [ { - id: `${did}#owner`, + id: `${did}#controller`, type: 'Secp256k1VerificationKey2018', - owner: did, - ethereumAddress: owner + controller: did, + ethereumAddress: controller } ] const authentication = [ { type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${did}#owner` + publicKey: `${did}#controller` } ] - if (ownerKey) { + if (controllerKey) { publicKey.push({ - id: `${did}#ownerKey`, + id: `${did}#controllerKey`, type: 'Secp256k1VerificationKey2018', - owner: did, - publicKeyHex: ownerKey + controller: did, + publicKeyHex: controllerKey }) authentication.push({ type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${did}#ownerKey` + publicKey: `${did}#controllerKey` }) } @@ -86,7 +86,7 @@ function wrapDidDocument(did, owner, ownerKey, history) { pks[key] = { id: `${did}#delegate-${delegateCount}`, type: 'Secp256k1VerificationKey2018', - owner: did, + controller: did, ethereumAddress: event.delegate } break @@ -105,7 +105,7 @@ function wrapDidDocument(did, owner, ownerKey, history) { const pk = { id: `${did}#delegate-${delegateCount}`, type: `${algo}${type}`, - owner: did + controller: did } switch (encoding) { case null: @@ -261,15 +261,15 @@ function getResolver(conf = {}) { async function changeLog(identity, networkId) { const history = [] let { address, publicKey } = interpretIdentifier(identity) - let owner = address + let controller = address let previousChange = await lastChanged(address, networkId) if (previousChange) { - const ownerRecord = await networks[networkId].didReg.identityOwner(address) - const newOwner = '' + ownerRecord['0'] - if (newOwner.toLowerCase() !== owner.toLowerCase()) { + const controllerRecord = await networks[networkId].didReg.identityOwner(address) + const newController = '' + controllerRecord['0'] + if (newController.toLowerCase() !== controller.toLowerCase()) { publicKey = null } - owner = newOwner + controller = newController } while (previousChange) { const blockNumber = previousChange @@ -288,7 +288,7 @@ function getResolver(conf = {}) { } } } - return { owner, history, publicKey } + return { controller, history, publicKey } } async function resolve(did, parsed) { const fullId = parsed.id.match(identifierMatcher) @@ -298,8 +298,8 @@ function getResolver(conf = {}) { if (!networks[networkId]) throw new Error(`No conf for networkId: ${networkId}`) - const { owner, history, publicKey } = await changeLog(id, networkId) - return wrapDidDocument(did, owner, publicKey, history) + const { controller, history, publicKey } = await changeLog(id, networkId) + return wrapDidDocument(did, controller, publicKey, history) } return { ethr: resolve }