did:btc1 is a censorship resistant DID Method using the Bitcoin blockchain as a Verifiable Data Registry to announce changes to the DID document. It improves on prior work by allowing: zero-cost off-chain DID creation; aggregated updates for scalable on-chain update costs; long-term identifiers that can support frequent updates; private communication of the DID document; private DID resolution; and non-repudiation appropriate for serious contracts.
did:btc1 is created for those who wish to have it all:
To learn more about did:btc1 method, visit the specification at dcdpr.github.io/did-btc1.
To learn more about the JS/TS implementation and its component packages, visit the documentation at btc1.tools/docs.
If you would like to contribute a fix or feature, please open an issue, fork the repo, follow the steps below to get the project setup for local development and submit a PR from your fork to this repo.
Fork did-btc1-js into your own account.
Install the pnpm
package manager.
npm i -g pnpm
git clone https://github.com/{USERNAME}/did-btc1-js.git
cd did-btc1-js
pnpm install
pnpm build
main
, make your changes, push and submit a cross repo PR from fork to this repo.To use the @did-btc1/method package in your own project, install it using your favorite package manager.
pnpm install @did-btc1/{common,cryptosuite,key-pair,method}
# Swap in npm or yarn depending on preference or requirement
Once installed, import the method to your project and use it to perform CRUD operations or interact with Beacons.
// ESM
import { DidBtc1 } from "@did-btc1/method";
const idType = 'key';
const pubKeyBytes = new Uint8Array(32);
// Create
const { did, initialDocument } = await DidBtc1.create({ idType, pubKeyBytes })
console.log('{ did, initialDocument }', { did, initialDocument });
// Read / Resolve
const resolution = await DidBtc1.resolve(did);
console.log('resolution', resolution);
// Update
const update = await DidBtc1.update({
identifier : did,
sourceDocument : initialDocument,
sourceVersionId : 1,
patch : [[
{
"op": "add",
"path": "/service/1",
"value": {
"id": "#initialP2PKH",
"type": "SingletonBeacon",
"serviceEndpoint": "z66p..."
}
}
],],
verificationMethodId : `#initialP2PKH`,
beaconIds : [`${did}#initialP2PKH`],
});
// TODO: Deactivate / Delete
// CommonJS
const { DidBtc1 } = require("@did-btc1/method");
const idType = 'key';
const pubKeyBytes = new Uint8Array(32);
const { did, initialDocument } = await DidBtc1.create({ idType, pubKeyBytes })
console.log('did', did);
console.log('initialDocument', initialDocument);
package | npm | issues | prs |
---|---|---|---|
@did-btc1/common | |||
@did-btc1/cryptosuite | |||
@did-btc1/key-pair | |||
@did-btc1/method | |||
@did-btc1/cli | |||
@did-btc1/smt |
Resource | Description |
---|---|
CODEOWNERS | Outlines the project lead(s) |
LICENSE | Project Open Source License |