1. Baidu DID Resolver

Baidu DID Resolver的域名是https://did.baidu.com

提供如下四个接口:

  • DID Resolve API:DID解析接口
  • DID Dereference API:DID引用解析
  • Post DID Operation API:发起DID操作(注:此接口后续会被移到did-registrar中)
  • Get DID Operation Result API:查询DID操作结果(注:此接口后续会被移到did-registrar中)

2. DID Resolve API

描述

请求结构

GET /v1/did/resolve/{did} HTTP/1.1
Host: did.baidu.com
Content-Type: application/json

请求参数

参数名称 类型 是否必需 参数位置 描述
did String URL参数 解析的did
resultType String Query参数 解析结果类型,可选:did-document / resolution-result(暂不支持);默认:did-document
versionId String Query参数 did对应的document版本
versionTime Long Query参数 版本时间(暂不支持)
noCache Bool Query参数 是否从cache取document,默认false,即默认都是从cache取;(暂不支持)

返回参数

参数名称 类型 描述
didDocument DidDocument resultType为空或者did-document
didResolutionResult DidResolutionResult resultType为resolution-result

请求示例

GET /v1/did/resolve/did:ccp:ceNobbK6Me9F5zwyE3MKY88QZLw HTTP/1.1
Host: did.baidu.com
Content-Type: application/json

响应示例

HTTP/1.1 200 OK
Date: Wed, 10 Apr 2016 08:26:52 GMT
Content-Type: application/json;charset=UTF-8

{
    "code": 0,
    "message": "ok",
    "requestID": "",
    "content": {
        "didDocument": {
            "@context": "https://w3id.org/did/v1",
            "id": "did:ccp:ceNobbK6Me9F5zwyE3MKY88QZLw",
            "version": 2,
            "created": "2019-10-21T11:12:13.065Z",
            "updated": "2019-10-21T11:17:49.379Z",
            "publicKey": [
                {
                    "id": "did:ccp:ceNobbK6Me9F5zwyE3MKY88QZLw#key-1",
                    "type": "Secp256k1",
                    "publicKeyHex": "046fcbedd1107ca45be3e81fc445e5a366886a89e7087fe3d128e6236302f31594740f250433ebe9f0abcbd04dbf9c5979e270a0772ad1cc502cec2d5de9504c8c"
                },
                {
                    "id": "did:ccp:ceNobbK6Me9F5zwyE3MKY88QZLw#key-2",
                    "type": "Secp256k1",
                    "publicKeyHex": "0496712d16b0836684aacd5ab6ba3d489c35efa31f414a1c6a455fc6b37ff28e5fa97ac29c1021b76e5b78e2bbceac1dfc4ec98e6b2b3e65a29f7f1cd4944dfb93"
                }
            ],
            "authentication": [
                "did:ccp:ceNobbK6Me9F5zwyE3MKY88QZLw#key-1"
            ],
            "recovery": [
                "did:ccp:ceNobbK6Me9F5zwyE3MKY88QZLw#key-2"
            ],
            "service": [
                {
                    "id": "did:ccp:ceNobbK6Me9F5zwyE3MKY88QZLw#resolver",
                    "type": "DIDResolve",
                    "serviceEndpoint": "https://did.baidu.com"
                }
            ],
            "proof": {
                "type": "Secp256k1",
                "creator": "did:ccp:ceNobbK6Me9F5zwyE3MKY88QZLw#key-1",
                "signatureValue": "30440220211ffc76ae2858d6baa29faa9b576d6b2e048e8f4f7767ee1c2fba7ae6c2a78102205f5b56cd1431830b45109d716631638d961e5b252c2c2354d8bb96782d8a62ef"
            }
        }
    }
}

3. DID Dereference API

描述

请求结构

GET /v1/did/dereference/{didURL} HTTP/1.1
Host: did.baidu.com
Content-Type: application/json

请求参数

参数名称 类型 是否必需 参数位置 描述
didURL String URL参数 经过base64编码的didUR
resultType String Query参数 解析结果类型,可选:did-document / resolution-result(暂不支持);默认:did-document
serviceType String Query参数 指定Service(暂不支持)
followRedirect String Query参数 (暂不支持)

返回参数

参数名称 类型 描述
didDocument DidDocument didURL = did
didResolutionResult DidResolutionResult resultType为resolution-result
serviceEndpointUrl String didURL有service字段
resource Object didURL有fragment

请求示例

示例一:did:ccp:ceNobbK6Me9F5zwyE3MKY88QZLw;service=DIDResolve/germ#request

GET /v1/did/dereference/ZGlkOmNjcDpjZU5vYmJLNk1lOUY1end5RTNNS1k4OFFaTHc7c2VydmljZT1ESURSZXNvbHZlL2dlcm0jcmVxdWVzdA== HTTP/1.1
Host: did.baidu.com
Content-Type: application/json

示例二:did:ccp:ceNobbK6Me9F5zwyE3MKY88QZLw#key-1

GET /v1/did/dereference/ZGlkOmNjcDpjZU5vYmJLNk1lOUY1end5RTNNS1k4OFFaTHcja2V5LTE= HTTP/1.1
Host: did.baidu.com
Content-Type: application/json

示例三:did:ccp:ceNobbK6Me9F5zwyE3MKY88QZLw

GET /v1/did/dereference/ZGlkOmNjcDpjZU5vYmJLNk1lOUY1end5RTNNS1k4OFFaTHc= HTTP/1.1
Host: did.baidu.com
Content-Type: application/json

响应示例

响应一:

HTTP/1.1 200 OK
Date: Wed, 10 Apr 2016 08:26:52 GMT
Content-Type: application/json;charset=UTF-8

{
    "code": 0,
    "message": "ok",
    "requestID": "",
    "content": {
        "serviceEndpointUrl": "https://did.baidu.com/germ#request"
    }
}

响应二:

HTTP/1.1 200 OK
Date: Wed, 10 Apr 2016 08:26:52 GMT
Content-Type: application/json;charset=UTF-8

{
    "code": 0,
    "message": "ok",
    "requestID": "",
    "content": {
        "resource": {
            "id": "did:ccp:ceNobbK6Me9F5zwyE3MKY88QZLw#key-1",
            "type": "Secp256k1",
            "publicKeyHex": "046fcbedd1107ca45be3e81fc445e5a366886a89e7087fe3d128e6236302f31594740f250433ebe9f0abcbd04dbf9c5979e270a0772ad1cc502cec2d5de9504c8c"
        }
    }
}

响应三:

HTTP/1.1 200 OK
Date: Wed, 10 Apr 2016 08:26:52 GMT
Content-Type: application/json;charset=UTF-8

{
    "code": 0,
    "message": "ok",
    "requestID": "",
    "content": {
        "didDocument": {
            "@context": "https://w3id.org/did/v1",
            "id": "did:ccp:ceNobbK6Me9F5zwyE3MKY88QZLw",
            "version": 2,
            "created": "2019-10-21T11:12:13.065Z",
            "updated": "2019-10-21T11:17:49.379Z",
            "publicKey": [
                {
                    "id": "did:ccp:ceNobbK6Me9F5zwyE3MKY88QZLw#key-1",
                    "type": "Secp256k1",
                    "publicKeyHex": "046fcbedd1107ca45be3e81fc445e5a366886a89e7087fe3d128e6236302f31594740f250433ebe9f0abcbd04dbf9c5979e270a0772ad1cc502cec2d5de9504c8c"
                },
                {
                    "id": "did:ccp:ceNobbK6Me9F5zwyE3MKY88QZLw#key-2",
                    "type": "Secp256k1",
                    "publicKeyHex": "0496712d16b0836684aacd5ab6ba3d489c35efa31f414a1c6a455fc6b37ff28e5fa97ac29c1021b76e5b78e2bbceac1dfc4ec98e6b2b3e65a29f7f1cd4944dfb93"
                }
            ],
            "authentication": [
                "did:ccp:ceNobbK6Me9F5zwyE3MKY88QZLw#key-1"
            ],
            "recovery": [
                "did:ccp:ceNobbK6Me9F5zwyE3MKY88QZLw#key-2"
            ],
            "service": [
                {
                    "id": "did:ccp:ceNobbK6Me9F5zwyE3MKY88QZLw#resolver",
                    "type": "DIDResolve",
                    "serviceEndpoint": "https://did.baidu.com"
                }
            ],
            "proof": {
                "type": "Secp256k1",
                "creator": "did:ccp:ceNobbK6Me9F5zwyE3MKY88QZLw#key-1",
                "signatureValue": "30440220211ffc76ae2858d6baa29faa9b576d6b2e048e8f4f7767ee1c2fba7ae6c2a78102205f5b56cd1431830b45109d716631638d961e5b252c2c2354d8bb96782d8a62ef"
            }
        }
    }
}

4. Post DID Operation API

描述

  • DID Operation 接口
  • 发起一次DID操作,可选的操作有:创建DID、修改DID、删除DID

请求结构

POST /v1/did/operation HTTP/1.1
Host: did.baidu.com
Content-Type: application/json

{
    "did":"did:ccp:example",
    "document":{...},
    "operation":"edit",
    "timestamp":253146316,
    "signature":"123"
}

请求参数

参数名称 类型 是否必需 参数位置 描述
did String RequestBody did
document DidDocument RequestBody did对应的document,delete时不需要
operation String RequestBody create/delete/edit
timestamp Long RequestBody 时间戳,单位:ms
signature String RequestBody create:不需要签名;delete/edit:需要使用上一版本的document中的recovery key进行签名

返回参数

参数名称 类型 描述
operationId String 处理ID

请求示例

POST /v1/did/operation HTTP/1.1
Host: did.baidu.com
Content-Type: application/json

{
    "did": "did:ccp:example",
    "document": {
        "@context": "https://w3id.org/did/v1",
        "id": "did:ccp:ceNobbK6Me9F5zwyE3MKY88QZLw",
        "version": 2,
        "created": "2019-10-21T11:12:13.065Z",
        "updated": "2019-10-21T11:17:49.379Z",
        "publicKey": [
            {
                "id": "did:ccp:ceNobbK6Me9F5zwyE3MKY88QZLw#key-1",
                "type": "Secp256k1",
                "publicKeyHex": "046fcbedd1107ca45be3e81fc445e5a366886a89e7087fe3d128e6236302f31594740f250433ebe9f0abcbd04dbf9c5979e270a0772ad1cc502cec2d5de9504c8c"
            },
            {
                "id": "did:ccp:ceNobbK6Me9F5zwyE3MKY88QZLw#key-2",
                "type": "Secp256k1",
                "publicKeyHex": "0496712d16b0836684aacd5ab6ba3d489c35efa31f414a1c6a455fc6b37ff28e5fa97ac29c1021b76e5b78e2bbceac1dfc4ec98e6b2b3e65a29f7f1cd4944dfb93"
            }
        ],
        "authentication": [
            "did:ccp:ceNobbK6Me9F5zwyE3MKY88QZLw#key-1"
        ],
        "recovery": [
            "did:ccp:ceNobbK6Me9F5zwyE3MKY88QZLw#key-2"
        ],
        "service": [
            {
                "id": "did:ccp:ceNobbK6Me9F5zwyE3MKY88QZLw#resolver",
                "type": "DIDResolve",
                "serviceEndpoint": "https://did.baidu.com"
            }
        ],
        "proof": {
            "type": "Secp256k1",
            "creator": "did:ccp:ceNobbK6Me9F5zwyE3MKY88QZLw#key-1",
            "signatureValue": "30440220211ffc76ae2858d6baa29faa9b576d6b2e048e8f4f7767ee1c2fba7ae6c2a78102205f5b56cd1431830b45109d716631638d961e5b252c2c2354d8bb96782d8a62ef"
        }
    },
    "operation": "edit",
    "timestamp": 253146316,
    "signature": "123"
}

响应示例

HTTP/1.1 200 OK
Date: Wed, 10 Apr 2016 08:26:52 GMT
Content-Type: application/json;charset=UTF-8

{
    "code": 0,
    "message": "ok",
    "requestID": "",
    "content": {
        "operationId": "123"
    }
}

5. Get DID Operation Result API

描述

  • DID Operation Result 接口
  • 查询DID操作的结果

请求结构

GET /v1/did/operation/{operationId} HTTP/1.1
Host: did.baidu.com
Content-Type: application/json

请求参数

参数名称 类型 是否必需 参数位置 描述
operationId String URL参数 DID操作处理ID

返回参数

参数名称 类型 描述
status String 操作状态, Doing、Done、Failed
msg String Failed是的错误原因

请求示例

GET /v1/did/operation/12312s12 HTTP/1.1
Host: did.baidu.com
Content-Type: application/json

响应示例

HTTP/1.1 200 OK
Date: Wed, 10 Apr 2016 08:26:52 GMT
Content-Type: application/json;charset=UTF-8

{
    "code": 0,
    "message": "ok",
    "requestID": "",
    "content": {
        "status": "Done"
    }
}

6. DidDocument数据结构

DID-Spec

7. DidResolutionResult数据结构

{
    "didDocument": {},
    "resolverMetadata": {
        "duration": 1048,
        "identifier": "did:ccp:ceNobbK6Me9F5zwyE3MKY88QZLw",
        "driverId": "driver-hello2mao/driver-did-ccp",
        "didUrl": {
            "didUrlString": "did:ccp:ceNobbK6Me9F5zwyE3MKY88QZLw",
            "did": {
                "didString": "did:ccp:ceNobbK6Me9F5zwyE3MKY88QZLw",
                "method": "ccp",
                "methodSpecificId": "ceNobbK6Me9F5zwyE3MKY88QZLw",
                "parseTree": null,
                "parseRuleCount": null
            },
            "parameters": null,
            "parametersMap": {},
            "path": "",
            "query": null,
            "fragment": null,
            "parseTree": null,
            "parseRuleCount": null
        }
        },
    "methodMetadata": {
        "version": 2,
        "proof": {
            "creator": "did:ccp:ceNobbK6Me9F5zwyE3MKY88QZLw#key-1",
            "type": "Secp256k1",
            "signatureValue": "30440220211ffc76ae2858d6baa29faa9b576d6b2e048e8f4f7767ee1c2fba7ae6c2a78102205f5b56cd1431830b45109d716631638d961e5b252c2c2354d8bb96782d8a62ef"
        },
        "created": "2019-10-21T11:12:13.065Z",
        "updated": "2019-10-21T11:17:49.379Z"
    }
}