tydids-p2p
A consensus driven decentralized data governance framework.
Imagine a dataset that is available somewhere in the world might be accessed everywhere. How? You just need to know its address.
- Decide who is allowed to see this dataset.
- Forget about protocols, p2p, request-responds, polling for changes.
- Set a value in your dataset with one line of code
- Subscribe to changes with another single line of code
This is TyDIDs.
Installation
Use on CLI
npm i -g tydids-p2p
tydids -h
Use as Module
npm i -s tydids-p2p
Node
const tydids = require("tydids-p2p");
const wallet = tydids.ethers.Wallet.createRandom();
const privateKey = wallet.privateKey;
const ssi = await tydids.ssi(privateKey);
API / Usage
Create Private Key (SSI)
Each self sovereign identity needs to have a private-key. So any usage/function starts with requires it.
Shell / CLI
tydids --createPrivateKey
0x62c3e5c1906d6e19e35e6fc1575dde0bc9bc5bc0c1ea84caf84b371a4bc00dca
tydids --priv 0x62c3e5c1906d6e19e35e6fc1575dde0bc9bc5bc0c1ea84caf84b371a4bc00dca --identity -x
Node
const wallet = tydids.ethers.Wallet.createRandom();
const privateKey = wallet.privateKey;
const ssi = await tydids.ssi(privateKey);
console.log(ssi.identity);
Note: For better readability private-key (eq. init of SSI) is implicit on the other examples. So in console/shell always add --priv
argument. In your code do const ssi = await tydids.ssi(privateKey);
.
Retrieve a public presentation
Shell / CLI
tydids --presentation 0x8b77634AE6D170C34657880fF1eAC9Aaf566Fd1E -x
{
iat: 1644793815,
id: 'did:ethr:6226:0x8b77634AE6D170C34657880fF1eAC9Aaf566Fd1E',
address: '0x8b77634AE6D170C34657880fF1eAC9Aaf566Fd1E',
publicKey: 'be2ad6f7a6ca94cf1682d8c5ac8a98cfc208c62da6289fd2a9ea68841f69a39e945aab35a0752c24a252bdab81b742669e21daae04a228d5ab2941beda8bcf91',
creator: '0xB123089d1d094E128caec0DeD1A95A12159BA48D',
iss: 'did:ethr:6226:0x8b77634AE6D170C34657880fF1eAC9Aaf566Fd1E',
hello: 'world',
...
}
Note: parameter -x
allows to quit/exit directly after receiving the did. Not listening to updates.
Note: You might store your privateKey in a .tydids.json
as like {privateKey:'YOUR-KEY-HERE'}
Node
let presentation = await ssi.retrieveVP(address);
console.log(presentation);
Create a new presentation
Will be owned by SSI and will have a unique ID (address).
Shell / CLI
tydids --createPresentation -x
{
id: 'did:ethr:6226:0xb80A4B2E0CC4d51cC6365eB5B12523730fC7bb04',
address: '0xb80A4B2E0CC4d51cC6365eB5B12523730fC7bb04',
publicKey: '71085032d5cd1b5ce70cc535d4a30f6ef60628388fa38d08df335c7e2b6ed0517b248ded789da07a0b1e01d15e0003000b7150876bc2efb0aa9cd7acb6b7f492',
creator: '0x5Cb08Dec0595671E2C1f45Da3BbBF6f75ED3F4C7'
}
Node
let presentation = await ssi.createManagedPresentation();
console.log(presentation);
Set field/attribute of presentation with value
In order to change a value SSI needs to be either owner or delegate.
Shell / CLI
tydids -x -p 0xb80A4B2E0CC4d51cC6365eB5B12523730fC7bb04 -s key1 value1
tydids -x -p 0xb80A4B2E0CC4d51cC6365eB5B12523730fC7bb04
{
iat: 1644885295,
id: 'did:ethr:6226:0xb80A4B2E0CC4d51cC6365eB5B12523730fC7bb04',
address: '0xb80A4B2E0CC4d51cC6365eB5B12523730fC7bb04',
publicKey: '71085032d5cd1b5ce70cc535d4a30f6ef60628388fa38d08df335c7e2b6ed0517b248ded789da07a0b1e01d15e0003000b7150876bc2efb0aa9cd7acb6b7f492',
creator: '0x5Cb08Dec0595671E2C1f45Da3BbBF6f75ED3F4C7',
iss: 'did:ethr:6226:0xb80A4B2E0CC4d51cC6365eB5B12523730fC7bb04',
key1: 'value1'
}
Node
let presentation = await ssi.retrieveVP(address);
presentation[key] = value;
await ssi.updateVP(address,presentation);
Maintainer / Imprint
STROMDAO GmbH
Gerhard Weiser Ring 29
69256 Mauer
Germany
+49 6226 968 009 0
kontakt@stromdao.com
Handelsregister: HRB 728691 (Amtsgericht Mannheim)
Project Website: https://tydids.com/
LICENSE
Apache-2.0