uport-project / ethr-did Goto Github PK
View Code? Open in Web Editor NEWCreate ethr DIDs
License: Apache License 2.0
Create ethr DIDs
License: Apache License 2.0
In the example DID document, the DID id value is presented as
id:'did:eth:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74',
However, later, in the DID method
subsection, it directs users to prepend did:ethr:
to an Ethereum address to create a DID under this schema.
Are these in conflict (did:eth:
vs did:ethr:
)? If so, which is the correct DID method?
how do i use delegate and signed functions?
is there any example code or usage?
Hi, I'm just curious. Does ethr-did work with web3.js
without Ethers.js
? Is there a working example? Thanks.
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
@babel/core
, @babel/preset-env
, @babel/preset-typescript
, @types/jest
, @typescript-eslint/eslint-plugin
, @typescript-eslint/parser
, eslint
, eslint-config-prettier
, eslint-plugin-jest
, eslint-plugin-prettier
, ganache
, jest
, jest-config
, prettier
, semantic-release
, ts-jest
, typescript
)@typescript-eslint/eslint-plugin
, @typescript-eslint/parser
, eslint
, eslint-plugin-jest
, semantic-release
).github/workflows/release.yml
actions/checkout v4@b4ffde65f46336ab88eb53be808477a3936bae11
actions/setup-node v4
ubuntu 22.04
.github/workflows/test.yml
actions/checkout v4@b4ffde65f46336ab88eb53be808477a3936bae11
actions/setup-node v4
codecov/codecov-action v3
ubuntu 22.04
package.json
did-jwt ^8.0.0
did-resolver ^4.1.0
ethers ^6.8.1
ethr-did-resolver 10.1.5
@babel/core 7.22.10
@babel/preset-env 7.22.10
@babel/preset-typescript 7.22.5
@semantic-release/changelog 6.0.3
@semantic-release/git 10.0.1
@types/jest 29.5.3
@typescript-eslint/eslint-plugin 6.4.0
@typescript-eslint/parser 6.4.0
cross-env 7.0.3
eslint 8.47.0
eslint-config-prettier 9.0.0
eslint-plugin-jest 27.2.3
eslint-plugin-prettier 5.0.0
ganache 7.9.0
jest 29.6.2
jest-config 29.6.2
microbundle 0.15.1
prettier 3.0.2
semantic-release 22.0.0
ts-jest 29.1.1
typescript 5.1.6
Describe the bug
When I try to create a new EthrDID object, passing a provider to the constructor, the procedure fails.
To Reproduce
import Resolver from 'did-resolver'
import getResolver from 'ethr-did-resolver'
import {EthrDID} from 'ethr-did'
import Web3 from 'web3'
//setup the provider
Web3.providers.HttpProvider.prototype.sendAsync = Web3.providers.HttpProvider.prototype.send
console.log('Connecting to provider...');
const provider = new Web3.providers.HttpProvider('http://localhost:9545');
const web3 = new Web3(provider);
console.log('Connected to the provider');
//contract address of the registry
const RegAddress = '0x1482aDFDC2A33983EE69F9F8e4F852c467688Ea0';
//function where the creation of an identity will be tested
const test = async (accounts) => {
const keyPair = EthrDID.createKeyPair();
const did0 = createDid(RegAddress, keyPair);
const ethrDidResolver = getResolver.getResolver(
{
name: 'test01',
rpcUrl: 'http://localhost:9545',
registry: RegAddress
}
);
//create signing delegate valid for 1 day
//await did0.createSigningDelegate();
const didResolver = new Resolver.Resolver(ethrDidResolver);
didResolver.resolve("did:ethr:test01:" + did0.address, ethrDidResolver).then((doc) => {
console.log(doc);
console.log(doc.didDocument.verificationMethod);
});
}
//function to create and return the object used to manage a DID
const createDid = (RegAddress, keyPair) => {
const conf = {
...keyPair,
registry: RegAddress,
chainNameOrId : 1337,
provider // NOTE : if i don't pass any provider here, it works, but provider is necessary for my work
};
const ethrDid = new EthrDID(conf);
return ethrDid;
}
//actual function that starts executing and this will invoke all the other pieces of code
web3.eth.getAccounts().then((accounts) => {
test(accounts).catch(error => console.log(error));
});
Errors
Connecting to provider...
Connected to the provider
Error: invalid signer or provider (argument="signerOrProvider", value={"withCredentials":false,"timeout":0,"connected":true,"host":"http://localhost:9545","httpAgent":{"_events":{},"_eventsCount":2,"defaultPort":80,"protocol":"http:","options":{"keepAlive":true,"path":null},"requests":{},"sockets":{},"freeSockets":{"localhost:9545:":[{"connecting":false,"_hadError":false,"_parent":null,"_host":"localhost","_readableState":{"objectMode":false,"highWaterMark":16384,"buffer":{"head":null,"tail":null,"length":0},"length":0,"pipes":[],"flowing":true,"ended":false,"endEmitted":false,"reading":true,"sync":false,"needReadable":true,"emittedReadable":false,"readableListening":false,"resumeScheduled":false,"errorEmitted":false,"emitClose":false,"autoDestroy":false,"destroyed":false,"errored":null,"closed":false,"closeEmitted":false,"defaultEncoding":"utf8","awaitDrainWriters":null,"multiAwaitDrain":false,"readingMore":false,"decoder":null,"encoding":null},"_events":{},"_eventsCount":6,"_writableState":{"objectMode":false,"highWaterMark":16384,"finalCalled":false,"needDrain":false,"ending":false,"ended":false,"finished":false,"destroyed":false,"decodeStrings":false,"defaultEncoding":"utf8","length":0,"writing":false,"corked":0,"sync":false,"bufferProcessing":false,"writecb":null,"writelen":0,"afterWriteTickInfo":null,"buffered":[],"bufferedIndex":0,"allBuffers":true,"allNoop":true,"pendingcb":0,"prefinished":false,"errorEmitted":false,"emitClose":false,"autoDestroy":false,"errored":null,"closed":false,"closeEmitted":false,"writable":true},"allowHalfOpen":false,"_sockname":null,"_pendingData":null,"_pendingEncoding":"","server":null,"_server":null,"parser":null,"_httpMessage":null,"timeout":0}]},"keepAliveMsecs":1000,"keepAlive":true,"maxSockets":null,"maxFreeSockets":256,"scheduling":"fifo","maxTotalSockets":null,"totalSocketCount":0}}, code=INVALID_ARGUMENT, version=contracts/5.1.1)
at Logger.makeError (/home/ruslan/coding/study-ethr-did/newDid/node_modules/@ethersproject/logger/lib/index.js:180:21)
at Logger.throwError (/home/ruslan/coding/study-ethr-did/newDid/node_modules/@ethersproject/logger/lib/index.js:189:20)
at Logger.throwArgumentError (/home/ruslan/coding/study-ethr-did/newDid/node_modules/@ethersproject/logger/lib/index.js:192:21)
at Contract.BaseContract (/home/ruslan/coding/study-ethr-did/newDid/node_modules/@ethersproject/contracts/lib/index.js:598:20)
at new Contract (/home/ruslan/coding/study-ethr-did/newDid/node_modules/@ethersproject/contracts/lib/index.js:1017:42)
at Contract.BaseContract.connect (/home/ruslan/coding/study-ethr-did/newDid/node_modules/@ethersproject/contracts/lib/index.js:786:24)
at P (/home/ruslan/coding/study-ethr-did/newDid/node_modules/ethr-did-resolver/lib/index.umd.js:1:3285)
at new K (/home/ruslan/coding/study-ethr-did/newDid/node_modules/ethr-did-resolver/lib/index.umd.js:1:3985)
at new o (/home/ruslan/coding/study-ethr-did/newDid/node_modules/ethr-did/lib/index.js:1:1618)
at createDid (file:///home/ruslan/coding/study-ethr-did/newDid/create_identity.js:47:18)
at test (file:///home/ruslan/coding/study-ethr-did/newDid/create_identity.js:21:15)
at file:///home/ruslan/coding/study-ethr-did/newDid/create_identity.js:54:2
at processTicksAndRejections (internal/process/task_queues.js:93:5) {
reason: 'invalid signer or provider',
code: 'INVALID_ARGUMENT',
argument: 'signerOrProvider',
value: HttpProvider {
withCredentials: false,
timeout: 0,
headers: undefined,
agent: undefined,
connected: true,
host: 'http://localhost:9545',
httpAgent: Agent {
_events: [Object: null prototype],
_eventsCount: 2,
_maxListeners: undefined,
defaultPort: 80,
protocol: 'http:',
options: [Object],
requests: {},
sockets: {},
freeSockets: [Object],
keepAliveMsecs: 1000,
keepAlive: true,
maxSockets: Infinity,
maxFreeSockets: 256,
scheduling: 'fifo',
maxTotalSockets: Infinity,
totalSocketCount: 0,
[Symbol(kCapture)]: false
}
}
}
Desktop (please complete the following information):
Observations
Following along with the files mentioned in the error, it seems like the Provider.isProvider() function from "@ethersproject/abstract-provider" returns false on the web3 provider being passed, causing the error :
line 629 of @ethersproject/contracts/src.ts/index.ts :
} else if (Provider.isProvider(signerOrProvider)) {
Is your feature request related to a problem? Please describe.
Cannot use this npm module on a React Native typescript-based project. Could not instantiate let issuer = new EthrDID({address: xxx, privateKey: yyy})
.
Getting this warning from IDE:
TS7016: Could not find a declaration file for module 'ethr-did'. '/Users/shinigami/pwc/github/io-app/node_modules/ethr-did/lib/index.js' implicitly has an 'any' type. Try `npm install @types/ethr-did` if it exists or add a new declaration (.d.ts) file containing `declare module 'ethr-did';`
Describe the solution you'd like
I would be able to install ethr-did
by using yarn: yarn add ethr-did
and be able to use it in a React-Native typescript-based project.
May this be helpful.
Hi team,
The readme states 'An example of a DID document resolved using the Ethr-Did-Resolver:'
type: 'Secp256k1SignatureAuthentication2018',
The DID v1.0 states in the specs registry:
"type": "EcdsaSecp256k1RecoveryMethod2020",
Ref: https://w3c.github.io/did-spec-registries/#ethereumaddress
Is the readme outdated? I'm not sure if this is an error
Describe the bug
I follow the "Getting Started" guide here: https://github.com/uport-project/ethr-did/blob/master/docs/guides/index.md, and try adding a Delegate Signer.
I am using Ganache for my own test private blockchain and deployed ERC1056 on it.
Here is my node.js code:
const EthrDID = require('ethr-did');
const Web3 = require('web3');
const Registry = require('./build/contracts/Registry.json');
const init = async () => {
const current_provider = new Web3.providers.HttpProvider('http://localhost:8545');
const web3 = new Web3(current_provider);
const id = await web3.eth.net.getId();
const deployedNetwork = Registry.networks[id];
const contract = new web3.eth.Contract(
Registry.abi,
deployedNetwork.address
);
const addresses = await web3.eth.getAccounts();
const ethrDid = new EthrDID({
address: addresses[0],
registry: deployedNetwork.address,
privateKey: '0x2f93aa4f85edafb71f472bbd1be5046270aed1c6f6fcdd8fa0705c5ccb59ab12',
rpcUrl: 'http://localhost:8545'
});
console.log("DiD = " + ethrDid.did);
const owner = await ethrDid.lookupOwner();
console.log("Owner = " + owner);
console.log("Set Delegate = " + addresses[1]);
await ethrDid.addDelegate(addresses[1]);
}
init();
Call to ethrDid.addDelegate() throws the following error:
(node:54879) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'delegateType' of undefined
at e.o.addDelegate (/Users/jcaporossi/Documents/ethr-did-test/node_modules/ethr-did/lib/index.js:1:1849)
at init (/Users/jcaporossi/Documents/ethr-did-test/index.js:36:16)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use node --trace-warnings ...
to show where the warning was created)
(node:54879) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:54879) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Any help would be welcome ;)
Thx,
Kind regards,
Jerome
Describe the bug
Failed to verify JWT using ethrDid.verifyJWT()
function.
Error message:
did-jwt/lib/index.js:523
throw new Error(`Unable to resolve DID document for ${issuer}: ${error}, ${message || ''}`);
^
Error: Unable to resolve DID document for
did:ethr:rinkeby:0x02b8e69f6c71348ff837043b5b51e23b43a0dabbb2b634a8d2dc08c0b156daf7b1:
unknownNetwork, The DID resolver does not have a configuration for network: rinkeby
To Reproduce
$ node index.js
Expected behavior
A verified output of JWT
Sample Code
const { EthrDID } = require("ethr-did");
const { Resolver } = require("did-resolver");
const { getResolver } = require("ethr-did-resolver");
const providerConfig = {
rpcUrl: "https://rinkeby.infura.io/v3/<project id>",
chainNameOrId: "rinkeby",
};
const ethrDidResolver = getResolver(providerConfig);
const didResolver = new Resolver(ethrDidResolver);
let createDid = async () => {
const keypair = EthrDID.createKeyPair();
// 1. create did
const ethrDid = new EthrDID({
...keypair,
...providerConfig,
resolver: didResolver,
});
// 2. sign jwt
const jwt = await ethrDid.signJWT({ hello: "world" });
// 3. verify jwt
const { payload, issuer } = await ethrDid.verifyJWT(jwt, didResolver);
console.log(payload);
console.log(issuer);
};
createDid();
Additional context
Dependencies:
"did-jwt": "^5.6.0",
"did-resolver": "^3.1.0",
"ethr-did": "^2.1.4",
"ethr-did-resolver": "^4.3.3",
any help what I'm missing here? Thanks
Using the await ethrDid.createSigningDelegate()
method in the documentation I'm able to succesfully assign a new delegate to my Rinkeby MetaMask account.
const provider = window.web3.currentProvider // MetaMask Web3 injection
const defaultAccount = window.web3.eth.defaultAccount // MetaMask Web3 injection
const ethrDid = new EthrDID({provider: provider, address: defaultAccount})
In addition to returning the kp
(keypair) it might be nice to also return the transaction hash?
Developers may want to log transactions responsible for creating signing delegates?
Is your feature request related to a problem? Please describe.
I want to add a RSA 4096 bit public key but cannot because its size makes the transaction go over the transaction gas limit.
Example:
const rsa4096PublicKey = `-----BEGIN PUBLIC KEY-----
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAolN9csarxOP++9pbjLE/
/ybicmTGL0+or6LmLkos9YEXOb8w1RaoQoLuPNbCqfHlnbiPdvl9zdVHCswf9DwK
Ba6ecs0Vr3OW3FTSyejHiqinkfmEgRKOoAf7S8nQcsiDzANPondL+1z+dgmo8nTK
9806ei8LYzKzLjpi+SmdtTVvUQZGuxAT1GuzzT5jyE+MyR2zwSaCTyNC6zwnk51i
z+zf8WRNe32WtBLhNbz6MKlwup1CSear9oeZQJRQspkud7b84Clv6QeOCPqMuRLy
ibM8J+BC5cRyxVyV2rHshvD134cbR6uEIsggoC9NvvZcaJlcG25gA7rUrIJ8CGEG
9WZsmqUfrykOJ3HFqGyJZlpVq0hHM6ikcexdbqPFcwj9Vcx3yecb6WABZCeYVHDw
3AoGu/Y/m2xJ7L3iPCWcpB94y0e7Yp3M6S8Y4RpL2iEykCXd7CVYVV1QVPz4/5D8
mT4S4PG0I0/yBbblUz9CcYSJ/9eFOekSRY7TAEEJcrBY7MkXZcNRwcFtgi9PWpaC
XTsIYri2eBKqAgFT9xaPiFCFYJlpfUe81pgp+5mZsObYlB0AKJb7o0rRa5XLO4JL
ZiovTaqHZW9gvO3KZyJNYx7XM9Vjwm4FB5NUxSvqHJyUgGC6H7jwK2wKtrThrjkt
P9+7B63q+4nzilC9UUHEIosCAwEAAQ==
-----END PUBLIC KEY-----`
const rsa4096PublicKeyHex = Buffer.from(rsa4096PublicKey)
await ethrDid.setAttribute('did/pub/Rsa/veriKey/pem', rsa4096PublicKeyHex)
})
Gives the following error: VM Exception while processing transaction: out of gas
because default transaction gas limit is 90000.
Describe the solution you'd like
Add the possibility to choose the gas limit for transactions to the registry
Example:
Add an optional gas
parameter for setAttribute()
, so that a user can increase the transaction gas limit when adding big keys
I'm trying to instantiate EthrDID in the following way:
const providerConfig = { rpcUrl: 'https://rinkeby.infura.io/ethr-did' }
const issuer: Issuer = new EthrDID({
identifier: identity.did, // my did
privateKey: identity.privateKey, // my private key
providerConfig
})
I get this error:
error TS2351: This expression is not constructable.
Type 'typeof import("/app/node_modules/ethr-did/lib/index")' has no construct signatures.
I'm using "ethr-did": "^2.1.4" on package.json
Maybe I'm misconfiguring the providerConfig parameter?
Thanks and best regards
Hello, I just approached this library and I have this issue that I cannot solve. Sorry if I am missing a very basic step.
I create a ethrDid object using the ethrs InfuraProvider as explained here. I provide the private key of one of my Ropsten addresses.
If I call ethrDid.setAttribute() (or any other transaction) I get the error "Missing provider".
Execute the ethrDid.setAttribute() function.
reason: 'missing provider',
code: 'UNSUPPORTED_OPERATION',
operation: 'sendTransaction'
(more details below)
import { EthrDID } from "ethr-did";
import { InfuraProvider } from "@ethersproject/providers";
const infuraProjectId = "abcde"
const myRopstenAddress = "0x..."
const pk = "123456789" // Private key of the address above
async function foo() {
const chainNameOrId = 3
const infura = new InfuraProvider("ropsten", infuraProjectId)
const ethrDid = new EthrDID({identifier: myRopstenAddress, privateKey: pk, provider: infura, chainNameOrId})
await ethrDid.setAttribute('did/svc/HubService', 'https://hubs.uport.me', 3600)
}
// Execute
foo()
https://gist.github.com/0Alic/feb5b04fc05e76bf358c8d81114b228c
Thank you in advance.
Hi,
to understand better how to validate a DID on-chain and off-chain. It will be great to have full examples.
Examples (recomendation):
1- how to create a DID on-chain and then execute a method in other smartcontract, which validates the identity with registry somehow.
1.a - Change the owner of the DID, and execute again the method on the smartcontract and be authethicated as the same DID.
1.b- Add a delegate, to work with that same contract. Execute a method on the smartcintract as the delegate and validate the delegate on the smartcontract and consider it as the same DID.
2- Same example as point 1 but with a off-chain validation.
Regards,
Mariano
var provider = new ethers.providers.Web3Provider(new Web3.providers.HttpProvider('http://localhost:8545'),{ chainId: 123456, name: '0x1e240' })
var ethrdid = new EthrDID.EthrDID({ identifier:keypair.identifier,
chainNameOrId: 0x1e240,
registry: '0x4b0DA3a1a20fc121f586c014170E3a14Cf897011',
provider: provider,
txSigner: '0xD241B460BD7896b1bDe396a21E3C6248F3C58503',
signer: didJWT.ES256KSigner(keypair.privateKey),
alg: 'ES256K'
})
ethrdid.setAttribute('testkey', 'test')
.then(res => console.log('then',res))
.catch(err => console.log('catch',err))
i made EthrDID object and tried to setAttribute. So I got error
reason: 'cannot estimate gas; transaction may fail or may require manual gas limit',
code: 'UNPREDICTABLE_GAS_LIMIT',
And then tried this
let txOptions = { gasLimit: 10000000}
or
var bn = ethers.BigNumber.from(100000)
let txOptions = { gasLimit: bn}
ethrdid.setAttribute('testkey', 'test', txOptions)
.then(res => console.log('then',res))
.catch(err => console.log('catch',err))
reason: 'invalid BigNumber value',
code: 'INVALID_ARGUMENT',
But both same error...
please help me out of this...
For each documentation markdown file:
category
to ethr-did
type
to guide | tutorial | reference
A user add some address as a delegate. This delegate then signs a JWT on behalf of this user.
Now after 1 week if user revoked this delegate, the signed delegate doesn't get verified using verifyJWT() function.
Is it a normal behaviour?
Is there something like if a user revoked a delegate then the JWT this delegate signed, should not be verified after revoking the delegate but past JWT should get verified?
Hi,i had searched and tried for a long time , i really really want get help.
i want to call my contract with my local account or privatekey, is there some fuction i can use to do this ?
for example :
pragma solidity ^0.4.4;
contract SimpleStorage {
uint storedData;
function set(uint x) public returns (address){
storedData = x;
return msg.sender;
}
function get() public view returns (uint) {
return storedData;
}
}
i can get call the methods this way
DidReg = new EthContract(provider)(abi)
registry = DidReg.at(registryAddress)
const hash = registry.set(10)
but in this way , the msg.sender
is the eth.account[0]
, i want to use my local account.
i tried the addWallet ,but it doesn't work
web3.eth.accounts.wallet.add(account)
so Can i use the privatekey to call the methods of the contract with ethjs-contract?
We need an overview page which should live in docs/index.md see @localredhead for more details.
First version should include:
5 bullet points with features
2-3 supporting paragraphs
Story will be updated with Value Prop and bullet points. Source for that will be here
Hi, I'm just testing out ethr-did
but the most simple code doesn't work for me:
const EthrDID = require("ethr-did");
const keypair = EthrDID.createKeyPair();
It gives me
TypeError: EthrDID.createKeyPair is not a function
I have Node 16.15 , npm8.5.5 and ethr-did 2.2.2
Describe the bug
I am using ethr-did to verify a jwt. I sign the JWT and then verify it using..
const {payload, issuer} = ethrDid.verifyJWT(jwt)
but it is giving me that error back that : Signature invalid for JWT
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Should print kp , signed JWT and verified JWT response on console
Additional context
Ethr-did version is 1.1.0. And i am using an Ethereum Blockchain called volta with registry already deployed.
hi ,
I have deeply read the ERC1056
, but there is something I can't understand , can you help me ?
for example :
I have an ethereum account ,as mentioned in the ERC1056
, I have naturally have an identity right ? I don't need to register on the registry contract .
but if I don't register on the registry contract ,how can I get the public Key ? because an important feature of DID is to get the public Key
from the DID
, so we can use the public Key
to encrypted something .
What is the current behavior?
Getting the error: Cannot read properties of undefined (reading 'getResolver')
when importing ethr-did
in a completely new React app generated with create vite
.
No errors
Please provide detailed steps for reproducing the issue.
npm create vite@latest
npm i ethr-did
npm run dev
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.
Most web3 providers also do not let the user sign data that is compatible with JWT standards, which means that you would have to add a sepa
-Kames
Namaste
Hi all, I plan to test the performances of ethr-did. I plan to test on a local ethereum network fellow the block time of mainnet. How can I deploy the ethr-did in local ethereum? Is there such tutorial about that?
The ethr-did-registry
offers a method to revoke an attribute. I do not find a corresponding method here in this implementation. Shouldn't this be added or are there any reasons (apart from no time maybe) why this has not been done yet?
Hello. Considering the following scenario, I would really like to know how a receiver can check who is X when receiving a credential signed by X from a User.
As a server, I create an application identity X and I interact with some users, exchanging credentials.
Now as a user, I have certain data attested by DID:X, which I present to "Receiver" as a proof of my relation with X.
As a "Receiver", I need some way to know who is DID:X, so I go to the server webpage where I can find their DID posted on the landing page.
However: What if the server erases this from the page? How to know the real identity behind a DID?
Possible answer: The server uploads to the ERC780 registry a claim saying: website URL = DIDX , whith date prior to the private exchange of credentials between user and server
Possible attack: I create a ERC780 claim saying: URL_to_impersonate = DID_I_control.
How to solve this problem? I understand how Ethereum serves as a DKPI for the creation of identities, but how to link DIDs to identities in the real world in a secure fashion? In centralized PKI this is done through a Certification Authority, or in solutions like Sovrin with a permissioned ledger of authorities. Also I saw how you can register in MyApps an application identity, and obtain a verification badge by uPort by uploading the said self-attested-claim to a certain URL. If this is the solution, doesnt it make uPort a Certification Authority?
As identified in decentralized-identity/ethr-did-resolver#127
const conf = {
...keyPair,
registry,
chainNameOrId,
rpcUrl: 'http://localhost:9545',
};
const ethrDid = new EthrDID(conf);
throws: Error: either a contract instance or a provider or rpcUrl is required to initialize...
In the public key section of W3C specs it says that: The value property of a public key may be publicKeyPem, publicKeyJwk, publicKeyHex, publicKeyBase64 or similar, depending on the format and encoding of the public key.
-> It not explicitly said, but it is implied that the format for the value property should bepublicKey<ENCODING>
therefore the example in the README using ethereumAddress
as the value property is not valid
In the W3C registry that summarizes the Linked Data key specifications currently known to the community, the identifier "Secp256k1VerificationKey2018" is not listed, but it is used in the README example.
const provider = getDefaultProvider(process.env.INFURA_PROJECT_ID, "sepolia");
const ethrDID = new EthrDID({
privateKey,
// @ts-ignore
provider,
registry: '...'
});
Error: Cannot assign type 'BaseProvider' to type 'Provider'.
const provider = getDefaultProvider(process.env.INFURA_PROJECT_ID, "sepolia");
const ethrDID = new EthrDID({
privateKey,
// @ts-ignore
provider,
registry: '...'
});
No compile errors, since the type of provider
and the type expected by the constructor of EthrDID
for provider
should match.
I have not find a way to cast provider
as of type Provider
as defined by ethers
.
If I do the following:
import { Provider } from '@ethersproject/providers'
const provider: Provider = getDefaultProvider(process.env.INFURA_PROJECT_ID, "sepolia");
const ethrDID = new EthrDID({
privateKey,
// @ts-ignore
provider,
registry: '...'
});
Then I get the following error:
Type 'import("node_modules/@ethersproject/abstract-provider/lib/index").Provider' cannot be assigned to type 'import("node_modules/ethr-did/node_modules/@ethersproject/abstract-provider/lib/index").Provider'.
Types returned by 'getFeeData()' are not compatible.
Type 'Promise<import("node_modules/@ethersproject/abstract-provider/lib/index").FeeData>' cannot be assigned to type 'Promise<import("node_modules/ethr-did/node_modules/@ethersproject/abstract-provider/lib/index").FeeData>'.
Property 'lastBaseFeePerGas' is missing in type 'import("node_modules/@ethersproject/abstract-provider/lib/index").FeeData', but it's mandatory in type 'import("node_modules/ethr-did/node_modules/@ethersproject/abstract-provider/lib/index").FeeData'.
Describe the bug
I am trying to verify the the JWT both with ethr-did and did-jwt but it is giving me an error about the Error: Unsupported DID method: 'ethr'.
I created the signer of my private key by
const didJWT = require('did-jwt')
const signer = didJWT.SimpleSigner('fa09a3ff0d486be2eb69545c393e2cf47cb53feb44a3550199346bdfa6f53245');
and then created and decoded the JWT succesfully.
But it gaves me an error on verify method
Project link
What is the current behavior?
unable to resolve module due to missing lib/index.js defined in package.js and not provided by microbuilder (in case ethr-did is used as package and build).
Please describe the behavior you are expecting
Same as in @2.2.0
Hi, I tried some transactions on Goerli and it works very well now.
I tried one changeOwner
on Ropsten the other day and it worked. However, every transactions I try on Ropsten now (changeOwner
and setAttribute
) are stuck at pending, on https://ropsten.etherscan.io/address/0xdca7ef03e98e0dc2b855be647c39abe984fcf21b
I don't get what is going on. Do I need to cancel these pending transactions?
Thanks
The contract address changed so make sure the address and abi is updated.
delegateType
is changed to bytes32
. Change calls to addDelegate()
to use the new name and encode it correctly (see tests in ethr-did-resolver for example)name
is changed to bytes32
for setAttribute()
call to use the new encodings as well.This should match the changes here: decentralized-identity/ethr-did-resolver#4
I'm having a dependency error whenever I'm importing the EthrDid which is:
./node_modules/did-jwt/node_modules/elliptic/lib/elliptic.js Error: ENOENT: no such file or directory
Any idea how to resolve this? I encounter this error on other libraries, too like uport-connect.
The docs for ethr-did-registry
mention this:
Since each Ethereum transaction has to 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 3rd party funding services or receiver pays without any fundamental changes to the underlying Ethereum architecture.
I assume this is done by using the *Signed
version of the methods like setAttributeSigned
, but I couldn't find support for this in this library nor in the ethr-did-resolver
.
Thanks!
Version 12/08/2020: https://www.w3.org/TR/2020/WD-did-core-20201108/
Changes to current:
I try to use Ether-DID library to create new jwt token and after that i can NOT verify it.
Here is example code i used.
`const EthrDID = require('ethr-did');
const ethrDid = new EthrDID({
provider: web3.currentProvider,
address: 'address',
privateKey: 'priv-key'
});
var jwt = await ethrDid.signJWT({ claims: { name: 'Joe Lubin' } });
//Problem here
const { payload, issuer } = ethrDid.verifyJWT(jwt);
console.log(payload); // return undefined
console.log(issuer); // return undefined`
In the case of a Ethereum hard fork, the DIDs registered exist on both chains. However, Is my assumption correct, that this will not result in data inconsistencies, since the DID method of the forked network would be different? did:ethr
would continue to exist as before the fork. A new DID method such as did:ethr:fork
would emerge and would resolve these new types of DIDs. Verifiable Credentials linked to the ethr:did
only work with the original version of DID. However, who decides which fork can continue to exist under the DID method ethr:did
? In my eyes this would be the developers of the DID resolver. Is that correct?
If an issuer has security concern and does not agree that the Ethereum DID resolver now supports the latest changes on the network, does this mean, that the issuer must revoke all previously issued credentials and issue new ones on the forked network?
I could not find any good resources on that. Any help is appreciated.
The library cannot be used at its current state. If I try to import it in any typescript project, I get the following error:
Cannot use MetaSignature namespace as type
At node_modules/ethr-did/lib/index.d.ts
. Every occurrence of the MetaSignature
keywork is marked with the error above. This results in typescript failing build and as a consequence the whole library is unusable.
Just running the code in the README should work without any error.
The following code snippet is enough to produce the error:
import { EthrDID } from 'ethr-did'
// some code
const stockVc = await createVerifiableCredentialJwt(
payload,
new EthrDID({
identifier: issuer.getAddress(),
privateKey: issuer.getPrivateKey()
}) as Issuer
)
// some code
Please answer the following questions for yourself before submitting an issue.
YOU MAY DELETE THE PREREQUISITES SECTION if you're sure you checked all the boxes.
What is the current behavior?
keep saying this:
my code:
import { EthrDID } from 'ethr-did'
console.log(new EthrDID({ identifier: '0xb9c5714089478a327f09197987f16f9e5d936e8a', chainNameOrId: 'mainnet' }).did)
Please describe the behavior you are expecting
Please help provide information about the failure.
Please provide detailed steps for reproducing the issue.
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.
Please include any relevant log snippets or files here.
Create a GIST which is a paste of your full or sanitized logs, and link them here.
Please do NOT paste your full logs here, as it will make this issue very long and hard to read!
Please provide details about an environment where this bug does not occur.
Don't paste private keys anywhere public!
I am using Ganache to run a local ethereum blockchain network. I am trying to create a DID using EthrDID from the ethr-did package (v2.3.6). I am trying to use the ethr-did-resolver providing the network configuration for Ganache network.
I expect to resolve to a DID document as per documentation in this project's README. The DID generated is like did:ethr:0x539:0xc753...
I do see a eth_call in the Ganache logs when the resolve is being called which. But if fails to resolve and get a call revert exception with code=CALL_EXCEPTION. I have already referred to https://docs.ethers.org/v5/troubleshooting/errors/ with not much details.
The error is:
call revert exception [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (method="changed(address)", data="0x", errorArgs=null, errorName=null, errorSignature=null, reason=null, code=CALL_EXCEPTION, version=abi/5.7.0)
Here is a code snippet used to create a DID and trying to resolve using ethr-did-resolver
const provider = new ethers.providers.JsonRpcProvider(rpcUrl);
const sign = didJWT.ES256KSigner(didJWT.hexToBytes(privateKey))
const ethrDid = new EthrDID({provider: provider, identifier: registry, chainNameOrId: chainNameOrId})
const privateNetworkConfig = [ {
name: "0x539",
rpcUrl: rpcUrl,
chainId: 1337,
registry: registry,
address: issuerAddress
}]
const ethrDidResolver = getResolver({networks: privateNetworkConfig})
const didResolver = new Resolver(ethrDidResolver)
const resolved = await didResolver.resolve(ethrDid.did)
I expect the resolve to resolve to a DID document. The DID generated is like did:ethr:0x539:0xc753...
I installed Ganache to run a local blockchain network and my provider config uses the RPC URL as shown on the Ganache network. My chainId is 1337.
I was trying to perform CRUD operations on a DID document. When I try to set attribute as it was in the documentation it throws an error
Error: [ethjs-query] while formatting outputs from RPC '{"value":{"code":-32602,"message":"invalid argument 0: hex string has length 0, want 40 for common.Address"}}'
This is my code.
const EthrDID = require('ethr-did')
const registerResolver = require('ethr-did-resolver').default
const HttpProvider = require('ethjs-provider-http')
const { address, privateKey } = EthrDID.createKeyPair()
const provider = new HttpProvider('http://127.0.0.1:8545')
const ethrDid = new EthrDID({
address,
privateKey,
provider
})
registerResolver({
provider,
registry: '0xdca7ef03e98e0dc2b855be647c39abe984fcf21b'
})
ethrDid.setAttribute('did/svc/HubService', 'https://hubs.uport.me', 10).then(console.log).catch(console.log)
dependencies:
"did-jwt": "^4.8.0",
"did-resolver": "^2.1.1",
"ethjs-provider-http": "^0.1.6",
"ethr-did": "^1.1.0",
"ethr-did-resolver": "^0.2.0",
Desktop :
Thank you in advance.
Description
In the documentation, it is mentioned that 'either signer or privateKey' is required to create a new Ethr-DID. However, a new Ethr-Did can be created just passing the Ethereum address.
To Reproduce
npm
projectinde.js
provider
[email protected]
and [email protected]
node index.js
Sample Code
const HttpProvider = require('ethjs-provider-http')
const provider = new HttpProvider('http://127.0.0.1:8545')
const EthrDID = require('ethr-did');
let createDid = async () => {
const address = '0xCF402F0891f9551eA0e2cEE7A7e491C4e83Fc079';
const ethrDid = new EthrDID({ address });
console.log(ethrDid);
}
createDid()
Expected behavior
It should throw an error stating 'either signer or private key is required'.
Actual behavior
It successfully creates a new did.
Dependencies:
10.16.3
^0.1.6
^1.1.0
This returns a fully functional ethrdid object
const ethrDid = new EthrDID({address: '0x...', privateKey: '...', provider})
Then, this errors out with message "Uncaught (in promise) Error: [ethjs-query] while formatting outputs from RPC '{}'"
const kp = await ethrDid.createSigningDelegate()
Used both ganache and private chain as providers over http.
I am trying to run the following code on bsc testnet (already deployed the smart contract on bsc testnet)
I already ran in Ropsten Network and had no issues
On the following code, I pretend to set an attribute and I am getting the following error: { code: -32000, message: 'transaction underpriced' }
So i decided to add gasPrice as a parameter on setAttribute() function, but now I am getting another error: { code: -32000, message: 'exceeds block gas limit' }
Should just return the Tx hash
when i decrease the gasPrice, i receive this message { code: -32000, message: 'transaction underpriced' }
when i increase the gasPrice, i receive this message: { code: -32000, message: 'exceeds block gas limit' }
Running the following code:
const EthrDID = require('ethr-did').EthrDID
const HDWalletProvider = require("@truffle/hdwallet-provider")
const mnemonic = "**** MNEMONIC ***".toString().trim()
const rpcLink = "https://data-seed-prebsc-1-s3.binance.org:8545/"
const chainId = 97
let provider = new HDWalletProvider(mnemonic, rpcLink, 0)
let Web3Provider = require ('@ethersproject/providers').Web3Provider
const bscAddr='0xA2D2Cb7Bb660E81032Db2a745986D3eDDaB34341' // Smart contract address on bsc testnet
pubkey = 'PUBLIC KEY'
identif='did:ethr:0x2: PUBLIC KEY'
const main = async () => {
let prov = await new Web3Provider(provider)
const ethrDid = await new EthrDID({identifier: identif, provider: prov, signer: pubkey, registry:bscAddr, chainNameOrId:chainId, gasLimit: gasPrice})
// let gasPrice = parseInt(29882814*1.04)
let response = ethrDid.setAttribute('drivL','142536',1629981511)
.then( (info) => console.log(response))
.catch( (error) => console.log(error)
)
provider.engine.stop()
}
main()
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.
Node version 14.17.1
Hi, I'm trying Ethr-did on the goerli
testnet.
I tried sending a few changeOwner
requests today in goerli
with NodeJS.
I checked the transactions at
https://goerli.etherscan.io/address/0xdca7ef03e98e0dc2b855be647c39abe984fcf21b
One of the changeOwner
transactions is successful but 3 other fail. What is the reason here?
I would like to check myself the reason it fails, too, if possible.
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.