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:
- resistance to censorship;
- non-correlation through pairwise DIDs;
- private communication of the DID document;
- a closed loop on private DID resolution;
- efficiency (in cost and energy usage), via offline DID creation and aggregatable updates;
- long-term identifiers that can support frequent updates; and
- Non-Repudiation appropriate for serious contracts.
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
pnpmpackage manager.
npm i -g pnpm- Clone the did-btc1-js monorepo.
git clone https://github.com/{USERNAME}/did-btc1-js.git
cd did-btc1-js- Install project dependencies.
pnpm install- Build project packages.
pnpm build- Create a new branch off of
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,keypair,method}
# Swap in npm or yarn depending on preference or requirementOnce installed, import the method to your project and use it to perform CRUD operations or interact with Beacons.
// ESM
import { DidBtc1, BeaconUtils, getNetwork } from "@did-btc1/method";
import { KeyPairUtils } from "@did-btc1/keypair";
const idType = 'key';
const { publicKey } = KeyPairUtils.generate();
const pubKeyBytes = publicKey.bytes;
// 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);
const patch = JSON.patch.create([
{
op : 'replace',
path : '/service/0',
value : BeaconUtils.generateBeaconService({
id : identifier,
publicKey : Buffer.from(keyPair1.publicKey.hex, 'hex'),
network : getNetwork('regtest'),
addressType : 'p2pkh',
beaconType : 'SingletonBeacon',
})
}
]);
// Update
const update = await DidBtc1.update({
identifier : did,
sourceDocument : initialDocument,
sourceVersionId : 1,
patch : JSON.patch.create([
{
op : 'replace',
path : '/service/0',
value : BeaconUtils.generateBeaconService({
id : identifier,
publicKey : Buffer.from(keyPair1.publicKey.hex, 'hex'),
network : getNetwork('regtest'),
addressType : 'p2pkh',
beaconType : 'SingletonBeacon',
})
}
]),
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);- @did-btc1/cryptosuite
- @did-btc1/common
- @did-btc1/keypair
- @did-btc1/method
- @did-btc1/cli
- @did-btc1/smt
| package | npm | issues | prs |
|---|---|---|---|
| @did-btc1/common | |||
| @did-btc1/cryptosuite | |||
| @did-btc1/keypair | |||
| @did-btc1/method | |||
| @did-btc1/cli | |||
| @did-btc1/smt |
| Resource | Description |
|---|---|
| CODEOWNERS | Outlines the project lead(s) |
| LICENSE | Project Open Source License |