理解去中心化身份 (DID 和 DIF)
什么是 DIF?
去中心化身份基金会 构建去中心化身份的生态系统,并确保所有参与者之间的互操作性。
为什么?……问题是什么?
身份问题
将身份与个人可识别信息 (PII) 解耦的问题。身份由一组深具个人性的定义我们数据构成,您的身份只应对您自己负责。
具体来说,面临的挑战是
- 将身份与身份提供者解耦。 DIDs 应该是自我主权的,不应由中央权威拥有或控制。
- 将身份查找与集中系统解耦。 DIDs 和数据应该能够在去中心化系统中被找到,以便没有中央所有者可以做恶。
- 将身份数据与不明或未知存储解耦。 DIDs 应该能够精确控制与他人分享什么或不分享什么。
统一碎片化的格局
DIF 是一个组织,旨在统一碎片化的格局,共同解决 DID 问题并建立一个作为行业标准的生态系统。
他们如何组织这些努力?
- 设计规范
- 实施
- 对齐行业参与者
人员和组织
工作组
- 身份、名称、发现
- 存储和计算
- 声明和凭证
成员
- Blockstack
- Microsoft / IBM
- HyperLedger
- RSA
- Ontology
- Civic
- iota
- …
生态系统
DID
身份是
- 全球唯一的
- 可解析的,且
- 具有加密验证的。
DID 格式:URN
DID 方法(在下面进一步解释)定义了 DIDs 如何与特定区块链一起工作。
DID 文档
- DID 基础设施 = <DID, DID 文档> 的全球键值数据库
- DID 文档 = 用于验证实体的公钥、认证协议和服务端点,并解释如何使用它。它可能包含三项内容:
- 证明目的
- 验证方法
- 服务端点
DID 如何保护隐私?
- 成对伪匿名的 DIDs
- 链外私有数据
- 选择性披露
DID 方法规范 (DID <> 区块链)
定义如何在特定区块链上创建、解析和管理 (CRUD) DID 和 DID 文档。
如何加入 DID 方法注册?
https://w3c-ccg.github.io/did-method-registry/#the-registry
示例
通过示例学习:Blockstack DID 方法
- Blockstack 如何利用 DID?
- 如何创建一个 blockstack DID?Blockstack 如何作为身份提供者?
- 如何解析一个 DID?
Blockstack 命名服务 (BNS)
- 命名层 = 用户名 <> 公钥 & 指向存储的指针
- BNS 是区块链无关的。 从 namecoint 迁移到比特币。
- ==一个 Blockstack DID 被定义为指向由一个地址注册的第 n 个名称==。
两类
链上 DIDs
- 两笔交易在链上注册一个名称 - 所有者地址 <> 名称
- 一个所有者地址可以有多个链上名称和相应的 DIDs
- 例如
did:stack:v0:15gxXgJyT5tM5A4Cbx99nwccynHYsBouzr-3
表示第四个链上名称被创建并最初分配给地址15gxXgJyT5tM5A4Cbx99nwccynHYsBouzr
。
- 例如
链外 DIDs,也称为子域
-
批量编 码,哈希,并稍后写入区块链。
-
链外名称由链上名称实例化,由链外名称的后缀表示。
cicero.res_publica.id
由res_publica.id
的所有者处理,但并不归其所有。
Blockstack 作为身份提供者
演示: https://bitpatron.co/ 使用 Blockstack 登录
sequenceDiagram User ->> First Party: GET /login Note left of User: 登录 Note right of First Party: 存储 transitKey First Party ->> User: 重定向 User ->> Blockstack: GET /auth?authRequest=:authRequestJwt Blockstack ->> First Party: GET /manifest.json (CORS) Note left of User: 创建或选择 ID Blockstack ->> User: 重定向 User ->> First Party: GET /auth?authResponse=:authResponseJwt Note right of First Party: 用 transitKey 解密 Note left of First Party: 待处理登录 First Party ->> Blockstack: GET /v1/names/:acctName.id.blockstack Blockstack ->> First Party: 用户数据
// authRequestJwt
{
"typ": "JWT",
"alg": "ES256K"
}
{
"jti": "4d06f08b-67a7-4f7c-89fc-b8164b81f67a",
"iat": 1563432343,
"exp": 1566110743,
"iss": "did:btc-addr:19sxvnAxPXZYAEdpF7Tti6MSVhxA8PSdCT",
"public_keys": [
"03994ec7b23a8e11e40684c9b2d29febf103bd92c4bbd295f1e2537042c93ac977"
],
"domain_name": "http://localhost:4104",
"manifest_uri": "http://localhost:4104/manifest.json",
"redirect_uri": "http://localhost:4104/",
"version": "1.3.1",
"do_not_include_profile": true,
"supports_hub_url": true,
"scopes": [
"store_write"
]
}
// authResponse
{
"typ": "JWT",
"alg": "ES256K"
}
{
"jti": "30773b78-3595-499f-bbb3-d1e649470c70",
"iat": 1563432894,
"exp": 1566111294,
"iss": "did:btc-addr:1DpKMqxBnuSSQMNun1obciPSfD9rD8KNUH",
"private_key": "已编辑 - 用 transitKey 加密",
"public_keys": [
"027c8547681cc27e27b73ee0f3c0534bdd38993dcb4c1934bf424f0b3a04dcad63"
],
"profile": null,
"username": "kirbystar.id.blockstack",
"core_token": null,
"email": null,
"profile_url": "https://gaia.blockstack.org/hub/1DpKMqxBnuSSQMNun1obciPSfD9rD8KNUH/profile.json",
"hubUrl": "https://hub.blockstack.org",
"blockstackAPIUrl": "https://core.blockstack.org",
"associationToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NksifQ.eyJjaGlsZFRvQXNzb2NpYXRlIjoiMDNhMTU5YzY4YWQ1ZjFkNzcxMWY2NjJmNThkNjdmMzZlNzY3ZTBjMDBhOTU4ZWY0NzljNzU3MzU0MGFkMzExZjk2IiwiaXNzIjoiMDI3Yzg1NDc2ODFjYzI3ZTI3YjczZWUwZjNjMDUzNGJkZDM4OTkzZGNiNGMxOTM0YmY0MjRmMGIzYTA0ZGNhZDYzIiwiZXhwIjoxNTk0OTY4ODk0LjcwNSwiaWF0IjoxNTYzNDMyODk0LjcwNSwic2FsdCI6IjE4NGVhMWQyMzM3MWQ1MmYyYzhmNTAyOGUwMWYxYmZiIn0.ZceaVcIK2Z8wu6KBYOHQaK7y6BI7NfxrixphOCPs1B4hZcGYDKsuf0anbm4CdAAJbKRifCm-MYHE6fjKD9E7GQ",
"version": "1.3.1"
}
// acctName response
{
"blockchain": "bitcoin",
"status": "submitted_subdomain",
"last_txid": "851ca5e6c06723e61037aa397966aafa1a6dd7159e9e31e53116106b87101886",
"zonefile": "$ORIGIN kirbystar.id.blockstack\n$TTL 3600\n_http._tcp\tIN\tURI\t10\t1\t\"https://gaia.blockstack.org/hub/1DpKMqxBnuSSQMNun1obciPSfD9rD8KNUH/profile.json\"\n\n",
"address": "1DpKMqxBnuSSQMNun1obciPSfD9rD8KNUH",
"zonefile_hash": "a9c016921a9a60e04776251db53a8881e6d128ce"
}
// session
{
"version": "1.0.0",
"userData": {
"username": "kirbystar.id.blockstack",
"profile": {
"@type": "Person",
"@context": "http://schema.org",
"api": {
"gaiaHubConfig": {
"url_prefix": "https://gaia.blockstack.org/hub/"
},
"gaiaHubUrl": "https://hub.blockstack.org"
}
},
"email": null,
"decentralizedID": "did:btc-addr:1DpKMqxBnuSSQMNun1obciPSfD9rD8KNUH",
"identityAddress": "1DpKMqxBnuSSQMNun1obciPSfD9rD8KNUH",
"appPrivateKey": "已编辑",
"coreSessionToken": null,
"authResponseToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NksifQ.eyJqdGkiOiIyNmM4ZGM2Ny1lNzEwLTRlZDUtYmIxYi0yY2I1ODY5YTRkMTEiLCJpYXQiOjE1NjM0MzU2NjEsImV4cCI6MTU2NjExNDA2MSwiaXNzIjoiZGlkOmJ0Yy1hZGRyOjFEcEtNcXhCbnVTU1FNTnVuMW9iY2lQU2ZEOXJEOEtOVUgiLCJwcml2YXRlX2tleSI6IjdiMjI2OTc2MjIzYTIyNjQzMDMzMzMzODMyNjYzNTYxNjIzNjM0Mzg2MTM1MzYzNTM2MzI2MzMzNjEzMTYyMzY2NTYzNjEzNzMzNjU2NjIyMmMyMjY1NzA2ODY1NmQ2NTcyNjE2YzUwNGIyMjNhMjIzMDMyNjEzMzY1NjEzMzY0NjMzNjMyMzgzODY2MzgzMTY2MzAzNDMwMzU2MzY1MzI2MzMzNjUzNjY0MzMzMzMxMzQzNDM0NjY2MTM4MzA2NTY1MzIzMzMyNjEzMjM2NjQzMzMwMzczMzM2MzY2NTMzMzkzNzM3MzczMjMxMzMzNzM5MzcyMjJjMjI2MzY5NzA2ODY1NzI1NDY1Nzg3NDIyM2EyMjM2MzMzOTYzNjMzMDM5MzQzOTYyMzMzNjY0NjI2NTM1MzIzMTM0MzIzMjM3MzA2MzY1NjIzMTM0MzEzNjY2MzA2MzM0NjYzNDM4MzgzMjY0MzUzOTM0MzMzNDM2NjM2NjYyNjEzNzMxNjM2MjM1MzYzMTM2MzczMDY0MzUzMzY0MzQzNTY1MzMzODYyNj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TA0In0.9dceG_r89WCIElNIlxSmPlOnXbISldFCz2q92Q2zIJOW_8gN5XOLlfsdDBUjiPfU7y3rDaWIL_MBbqUgVpEjxQ"
},
"transitKey": "已编辑"
}
从 DID 获取实体 - 通用解析器
域名 <--DNS--> IP
表示的实体 <--通用解析器--> 自主身份标识符
DID <--通用解析器--> DID 文档
示例驱动程序:
did:stack:
从 BlockStack 注册的 DID,例如did:stack:v0:SZBrgLTLXZL9ZAX8GVNgvZKcU4DJBXkUQr-0
did:btcr
: 从 BTC 注册的 DID- 等等。
运行解析器
git clone https://github.com/decentralized-identity/universal-resolver.git
cd universal-resolver/
docker-compose -f docker-compose.yml pull
docker-compose -f docker-compose.yml up
curl -X GET http://localhost:8080/1.0/identifiers/did:stack:v0:SZBrgLTLXZL9ZAX8GVNgvZKcU4DJBXkUQr-0 | jq .
{
"redirect": null,
"didDocument": {
"id": "did:stack:v0:SZBrgLTLXZL9ZAX8GVNgvZKcU4DJBXkUQr-0",
"service": [
{
"type": "blockstack",
"serviceEndpoint": "https://core.blockstack.org"
}
],
"publicKey": [
{
"id": "did:stack:v0:SZBrgLTLXZL9ZAX8GVNgvZKcU4DJBXkUQr-0",
"type": "Secp256k1VerificationKey2018",
"publicKeyHex": "0232131c807c4b184582280bca141f2583f6a1de2e0d3e6984cdb4724527f581fa"
}
],
"@context": "https://w3id.org/did/v0.11"
},
"resolverMetadata": {
"duration": 96,
"driverId": "did-stack",
"driver": "HttpDriver",
"didUrl": {
"didUrlString": "did:stack:v0:SZBrgLTLXZL9ZAX8GVNgvZKcU4DJBXkUQr-0",
"did": {
"didString": "did:stack:v0:SZBrgLTLXZL9ZAX8GVNgvZKcU4DJBXkUQr-0",
"method": "stack",
"methodSpecificId": "v0:SZBrgLTLXZL9ZAX8GVNgvZKcU4DJBXkUQr-0",
"parseTree": null,
"parseRuleCount": null
},
"parameters": null,
"parametersMap": {},
"path": "",
"query": null,
"fragment": null,
"parseTree": null,
"parseRuleCount": null
}
},
"methodMetadata": {}
}