# repchain-vc-rest-service **Repository Path**: BTAJL/repchain-vc-rest-service ## Basic Information - **Project Name**: repchain-vc-rest-service - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2021-06-10 - **Last Updated**: 2025-06-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## repchain-vc-rest-service repchain-vc-rest-service,即基于RepChain区块链的可验证凭据(Verifiable Credential, VC)Rest Service,基于Spring Boot以Rest API的形式提供可验证凭据SDK的相应功能。 我们提供了以下语言版本的VC SDK: - [Java](https://gitee.com/BTAJL/repchain-vc-java-sdk.git) 若您使用的开发语言不在上述列表中,可考虑使用本Rest Service,通过Rest API形式使用VC SDK的相应功能以实现您的应用。 ### 使用 #### 依赖 * 运行本程序需要提前安装JRE或JDK(Oracle发行版本或开源版本皆可, version > 1.8)。 #### 配置 在配置文件config.yaml中编辑配置项: | 配置项 | 值类型 | 说明 | |----------------------------------|---------|--------------------------| | port | number | Rest服务端口 | | vc.vcconstractName | String | 可验证凭据管理合约名 | | vc.vcconstractVersion | number | 可验证凭据管理合约版本 | | vc.vcsignupCCSFunctionName | String | 注册可验证凭据属性结构所调用的合约方法名 | | vc.vcupdateCCSStatusFunctionName | String | 更改可验证凭据属性结构有效状态所调用的合约方法名 | | vc.vcsignupVCStatusFunctionName | String | 注册可验证凭据状态所调用的合约方法名 | | vc.vcupdateVCStatusFunctionName | String | 更改可验证凭据状态所调用的合约方法名 | | vc.vcrevokeVCClaimsFunctionName | String | 撤销可验证凭据部分属性所调用的合约方法名 | | vc.vcccsworldStatePrefix | String | 表示可验证凭据属性结构的合约状态数据的前缀 | | vc.vcvcstatusWorldStatePrefix | String | 表示可验证凭据状态的合约状态数据的前缀 | | vc.vcprotoVersion | String | 可验证凭据的protobuf结构版本 | | vc.vcstatusProtoVersion | String | 可验证凭据状态的protobuf结构版本 | | vc.txSigAlg | String | 构建RepChain交易所用签名算法 | | vc.peerEndpoint | String | 所连接的RepChain节点url | | vc.networkId | String | 连接的RepChain网络标识 | | vc.oid | String | 可验证凭据管理合约的实例标识 | | actor | Array[] | 可供调用方使用的账户身份及私钥信息 | | actor[i].id | String | 可供调用方使用的账户身份及私钥信息唯一标识 | | actor[i].did | String | 可供调用方使用的账户的分布式身份did | | actor[i].certName | String | 可供调用方使用的账户公钥证书名称 | | actor[i].prvKeyPath | String | 可供调用方使用的账户私钥文件路径 | #### 运行 将本程序编译打包,确保config.yaml在当前运行命令的目录下 并运行命令: ```bash java -jar repchain-vc-rest-service-{version}.jar ``` #### Rest APIs 以下内容列出了本程序提供的相应Rest APIs。 此外您可以在运行成功之后访问url查看Swagger UI形式描述的详细API文档: http://localhost:8088/swagger-ui.html (默认端口为8088,您可以通过配置进行修改)) ##### 注意 * Request body中类似"did": "did:rep:example:121000005l35120456"的属性值中的"example"在实际使用时需替换为相应已部署身份链的链标识,比如"identity-net"等。 ##### Create CCS 创建可验证凭据属性结构CCS ||| |----|----| |url|/credential-claim-schemes| |method|POST| |request content type|application/json| |response content type|none or application/json| request example: - post /credential-claim-schemes - body ```json { "ccsCreatorId": "actor1", "ccs": { "id": "CCS-001", "name": "UniversityDegreeCredential", "version": "1.0", "description": "高等学校学位证书", "attributes": [ { "name": "serialNumber", "type": "String", "required": true, "description": "学位证书编号" }, { "name": "id", "type": "String", "required": true, "description": "学位证书获得者did标识" }, { "name": "name", "type": "String", "required": true, "description": "学位获得者姓名" }, { "name": "degree", "type": "String", "required": true, "description": "学位名称" }, { "name": "date", "type": "String", "required": true, "description": "学位授予日期" }, { "name": "university", "type": "String", "required": true, "description": "学位授予学校(单位)" } ] } } ``` response example: - status: 200 - body: none ##### Get One CCS 根据唯一标识获取可验证凭据属性结构信息CCS ||| |----|----| |url|/credential-claim-schemes/:id| |method|GET| |response content type|application/json| request example: - get /credential-claim-schemes/CCS-001 response example: - status: 200 - body: ```json { "id": "CCS-001", "name": "UniversityDegreeCredential", "version": "1.0", "description": "高等学校学位证书", "created": "2021-03-17T13:13:01.075Z", "attributes": [ { "name": "serialNumber", "type": "String", "required": true, "description": "学位证书编号" }, { "name": "id", "type": "String", "required": true, "description": "学位证书获得者did标识" }, { "name": "name", "type": "String", "required": true, "description": "学位获得者姓名" }, { "name": "degree", "type": "String", "required": true, "description": "学位名称" }, { "name": "date", "type": "String", "required": true, "description": "学位授予日期" }, { "name": "university", "type": "String", "required": true, "description": "学位授予学校(单位)" } ] } ``` ##### Update CCS 更新可验证凭据属性结构CCS有效性 ||| |----|----| |url|/credential-claim-schemes/:id| |method|PUT| |request content type|application/json| |response content type|none or application/json| request example: - put /credential-claim-schemes/CCS-001 - body: ```json { "ccsCreatorId": "actor1", "valid": false } ``` response example: - status: 200 - body: none ##### Create VC 创建/签发可验证凭据VC ||| |----|----| |url|/verifiable-credentials| |method|POST| |request content type|application/json| |response content type|application/json| request example: - post /verifiable-credentials - body: ```json { "issuerId": "actor1", "credential": { "meta": { "id": "0x123456", "claimScheme": "CCS-001", "type": [ "VerifiableCredential", "UniversityDegreeCredential" ], "validFrom": "2021-03-26T10:08:59Z", "validUntil": "2099-03-26T10:08:59Z" }, "credentialSubject": { "1": { "name": "serialNumber", "value": "2021063012342176" }, "2": { "name": "id", "value": "did:rep:example:12110107bi45jh675g" }, "3": { "name": "name", "value": "Tom" }, "4": { "name": "degree", "value": "Master" }, "5": { "name": "date", "value": "2021-06-30" }, "6": { "name": "university", "value": "RepChain Training University" } } }, "sigAlg": "EcdsaPrime256v1Signature" } ``` response example: - status: 200 - body: ```json { "@context": [ "https://www.w3.org/2018/credentials/v1" ], "id": "0x123456", "type": [ "VerifiableCredential", "UniversityDegreeCredential" ], "claimScheme": "CCS-001", "issuer": "did:rep:example:121000005l35120456", "issued": "2021-05-07T08:33:03.613Z", "validFrom": "2021-03-26T10:08:59Z", "validUntil": "2099-03-26T10:08:59Z", "credentialSubject": { "1": { "serialNumber": "2021063012342176" }, "2": { "id": "did:rep:example:12110107bi45jh675g" }, "3": { "name": "Tom" }, "4": { "degree": "Master" }, "5": { "date": "2021-06-30" }, "6": { "university": "RepChain Training University" } }, "proof": { "type": "EcdsaPrime256v1Signature", "created": "2021-05-07T08:33:03.813Z", "verificationMethod": "did:rep:example:121000005l35120456#node1", "signature": { "1": "MEQCIHcYbOyh+9B7X1nm7ot+EzUr9tSEPbVcg5kYIszCuO49AiB4lPNfcFQIfeMKWQDxrN68sjEydUYibOhehJlTgHGq3g==", "2": "MEYCIQDNtTx+sx9sA4mKFrRCKzjGPQq/xubqD0lFZ79Edh8jAQIhAKJFael2JLA5FYM/VquKUFNRS+R9RaWAqkPiIYRiHK0x", "3": "MEUCIQDbtFaJmFseT5gMOuEHO9Qa54pjUnpGOTGoBNuTSv6KSAIgduDzy2c/jKR9Bi6U/3Lg0eQLt+YaJxZkoOlVnpEh2YI=", "4": "MEQCIDrgyMVGlxSPjCLtUqsvcuBjAuu08y3B/hQ+fKbUe1c7AiALsuF3KyPMRJiLcOEwJ0vgz2VSq6L2aTJz8BZwZQHYxA==", "5": "MEQCIHyfI2jCwIJoccoriSPfSRkyxaHJ+YkJceBuTMuAXlWBAiBZ2xT7MtAQZmnSqH3ZhJAyLK3EYyqOJfM2mf67MDHGbw==", "6": "MEYCIQDQvSMIomH+aerOtO8fsm0KPxGf4BQ7bEOu9ttG9yPHkwIhAN2s05PByt69H3r3/hL8v0FHNqoDwV6bk0qMjXWoAz5+" } } } ``` ##### Create VCS 创建可验证凭据状态VCS ||| |----|----| |url|/verifiable-credentials/:id/status| |method|POST| |request content type|application/json| |response content type|none or application/json| request example: - post /verifiable-credentials/0x123456/status - body: ```json { "issuerId": "actor1", "status": "VALID" } ``` response example: - status: 200 - body: none ##### Get One VCS 根据唯一标识获取可验证凭据状态信息VCS ||| |----|----| |url|/verifiable-credentials/:id/status| |method|POST| |request content type|application/json| |response content type|application/json| request example: - get /verifiable-credentials/0x123456/status response example: - status: 200 - body: ```json { "id": "0x123456", "status": "INVALID", "revokedClaimIndex": [ "0", "2", "1" ], "creator": "did:rep:example:121000005l35120456" } ``` ##### Update VCS 更新可验证凭据状态VCS ||| |----|----| |url|/verifiable-credentials/:id/status| |method|PUT| |request content type|application/json| |response content type|none or application/json| request example: - put /verifiable-credentials/0x123456/status - body: ```json { "issuerId": "actor1", "id": "0x123456", "status": "INVALID" } ``` response example: - status: 200 - body: none ##### Verify VC Signature 验证可验证凭据的签名 ||| |----|----| |url|/verifiable-credentials/:id/verifying-signature| |method|POST| |request content type|application/json| |response content type|application/json| request example: - post /verifiable-credentials/0x123456/verifying-signature - body: ```json { "verifiableCredential": { "@context": [ "https://www.w3.org/2018/credentials/v1" ], "id": "0x123456", "type": [ "VerifiableCredential", "UniversityDegreeCredential" ], "claimScheme": "CCS-001", "issuer": "did:rep:example:121000005l35120456", "issued": "2021-04-25T02:54:04.732Z", "validFrom": "2021-03-26T10:08:59Z", "validUntil": "2099-03-26T10:08:59Z", "credentialSubject": { "3": { "name": "Tom" }, "4": { "degree": "Master" }, "6": { "university": "RepChain Training University" } }, "proof": { "type": "EcdsaPrime256v1Signature", "created": "2021-04-25T02:54:04.853Z", "verificationMethod": "did:rep:example:121000005l35120456#node1", "signature": { "3": "MEYCIQDZM5T/YZUfEx4y1ToElx/L8JU8jRu3nNdUtovIUBEj6wIhAKHKTMSDe9QM1IRHKPOvolQTm0Xr1i3tEHAXT1J+bGQh", "4": "MEUCIQDcWfS/0kOq1sYdsTovmAQAr5GhUNX846WRPBdPjlOx9gIgb2vKZKpsrzorwY8jEGURHG7VAvJig1Re3C/j+m/fTZg=", "6": "MEUCIGi5zBTzHZbxQqtX6AviHWsZpuyfZYgZmGGQPnXr0Tk9AiEApK6owZAFVSCdZjc9LN+svuAnqK1hfmr7eTC/LBWHWxQ=" } } } } ``` response example: - status: 200 - body: ```json { "result": true } ``` ##### Selectively Disclose VC 选择性披露可验证凭据VC ||| |----|----| |url|/verifiable-credentials/:id/selective-disclosing| |method|POST| |request content type|application/json| |response content type|application/json| request example: - post /verifiable-credentials/0x123456/selective-disclosing - body: ```json { "verifiableCredential": { "@context": [ "https://www.w3.org/2018/credentials/v1" ], "id": "0x123456", "type": [ "VerifiableCredential", "UniversityDegreeCredential" ], "claimScheme": "CCS-001", "issuer": "did:rep:example:121000005l35120456", "issued": "2021-04-25T02:54:04.732Z", "validFrom": "2021-03-26T10:08:59Z", "validUntil": "2099-03-26T10:08:59Z", "credentialSubject": { "1": { "serialNumber": "2021063012342176" }, "2": { "id": "did:rep:example:12110107bi45jh675g" }, "3": { "name": "Tom" }, "4": { "degree": "Master" }, "5": { "date": "2021-06-30" }, "6": { "university": "RepChain Training University" } }, "proof": { "type": "EcdsaPrime256v1Signature", "created": "2021-04-25T02:54:04.853Z", "verificationMethod": "did:rep:example:121000005l35120456#node1", "signature": { "1": "MEUCIQCLhS/4RnQ47591VxCzvXyVWOUYs1JgouNCb41reW1YWgIgddtbHLTx+vJxQCFq6wcv24zl0rXQdlp91aq0/Y8u0wY=", "2": "MEUCIQCikhWKoSSO4GHonXV2TYPyOvdR+loFSYu2uW1nsVOL7wIgS7UIeO2YMC6Jq57H3dOUKJI5/a0vBPpU2v9sDvaBqgA=", "3": "MEYCIQDZM5T/YZUfEx4y1ToElx/L8JU8jRu3nNdUtovIUBEj6wIhAKHKTMSDe9QM1IRHKPOvolQTm0Xr1i3tEHAXT1J+bGQh", "4": "MEUCIQDcWfS/0kOq1sYdsTovmAQAr5GhUNX846WRPBdPjlOx9gIgb2vKZKpsrzorwY8jEGURHG7VAvJig1Re3C/j+m/fTZg=", "5": "MEQCIB4K6diQM76T+Yg0Li9CHN5K53NsDsLFP3PkIYUp/TQCAiAOj9rn0q/Qg+6G4WCHbnfPte3vNNcXK2fq9OESdQekqA==", "6": "MEUCIGi5zBTzHZbxQqtX6AviHWsZpuyfZYgZmGGQPnXr0Tk9AiEApK6owZAFVSCdZjc9LN+svuAnqK1hfmr7eTC/LBWHWxQ=" } } }, "selectiveNames": ["name", "degree", "university"] } ``` response example: - status: 200 - body: ```json { "@context": [ "https://www.w3.org/2018/credentials/v1" ], "id": "0x123456", "type": [ "VerifiableCredential", "UniversityDegreeCredential" ], "claimScheme": "CCS-001", "issuer": "did:rep:example:121000005l35120456", "issued": "2021-04-25T02:54:04.732Z", "validFrom": "2021-03-26T10:08:59Z", "validUntil": "2099-03-26T10:08:59Z", "credentialSubject": { "3": { "name": "Tom" }, "4": { "degree": "Master" }, "6": { "university": "RepChain Training University" } }, "proof": { "type": "EcdsaPrime256v1Signature", "created": "2021-04-25T02:54:04.853Z", "verificationMethod": "did:rep:example:121000005l35120456#node1", "signature": { "3": "MEYCIQDZM5T/YZUfEx4y1ToElx/L8JU8jRu3nNdUtovIUBEj6wIhAKHKTMSDe9QM1IRHKPOvolQTm0Xr1i3tEHAXT1J+bGQh", "4": "MEUCIQDcWfS/0kOq1sYdsTovmAQAr5GhUNX846WRPBdPjlOx9gIgb2vKZKpsrzorwY8jEGURHG7VAvJig1Re3C/j+m/fTZg=", "6": "MEUCIGi5zBTzHZbxQqtX6AviHWsZpuyfZYgZmGGQPnXr0Tk9AiEApK6owZAFVSCdZjc9LN+svuAnqK1hfmr7eTC/LBWHWxQ=" } } } ``` ##### Revoke VC Claims 撤销可验证凭据属性 ||| |----|----| |url|/verifiable-credentials/:id/revoking-claims| |method|PUT| |request content type|application/json| |response content type|none or application/json| request example: - put /verifiable-credentials/0x123456/revoking-claims - body: ```json { "issuerId": "actor1", "revokedClaimIndex": ["0", "2"] } ``` response example: - status: 200 - body: none ##### Create VP 创建可验证凭据出示信息VP ||| |----|----| |url|/verifiable-presentations| |method|POST| |request content type|application/json| |response content type|application/json| request example: - post /verifiable-presentations - body: ```json { "holderId": "actor2", "metadata": { "type": ["UniversityDegreePresentation"], "id": "0x987654" }, "vc": { "@context": [ "https://www.w3.org/2018/credentials/v1" ], "id": "0x123456", "type": [ "VerifiableCredential", "UniversityDegreeCredential" ], "claimScheme": "CCS-001", "issuer": "did:rep:example:121000005l35120456", "issued": "2021-04-25T02:54:04.732Z", "validFrom": "2021-03-26T10:08:59Z", "validUntil": "2099-03-26T10:08:59Z", "credentialSubject": { "3": { "name": "Tom" }, "4": { "degree": "Master" }, "6": { "university": "RepChain Training University" } }, "proof": { "type": "EcdsaPrime256v1Signature", "created": "2021-04-25T02:54:04.853Z", "verificationMethod": "did:rep:example:121000005l35120456#node1", "signature": { "3": "MEYCIQDZM5T/YZUfEx4y1ToElx/L8JU8jRu3nNdUtovIUBEj6wIhAKHKTMSDe9QM1IRHKPOvolQTm0Xr1i3tEHAXT1J+bGQh", "4": "MEUCIQDcWfS/0kOq1sYdsTovmAQAr5GhUNX846WRPBdPjlOx9gIgb2vKZKpsrzorwY8jEGURHG7VAvJig1Re3C/j+m/fTZg=", "6": "MEUCIGi5zBTzHZbxQqtX6AviHWsZpuyfZYgZmGGQPnXr0Tk9AiEApK6owZAFVSCdZjc9LN+svuAnqK1hfmr7eTC/LBWHWxQ=" } } }, "sigAlg": "EcdsaPrime256v1Signature", "challenge": "challenge-random-jsdio837jkds" } ``` response example: - status: 200 - body: ```json { "@context": [ "https://www.w3.org/2018/credentials/v1" ], "id": "0x987654", "type": [ "VerifiablePresentation", "UniversityDegreePresentation" ], "holder": "did:rep:example:12110107bi45jh675g", "verifiableCredential": { "@context": [ "https://www.w3.org/2018/credentials/v1" ], "id": "0x123456", "type": [ "VerifiableCredential", "UniversityDegreeCredential" ], "claimScheme": "CCS-001", "issuer": "did:rep:example:121000005l35120456", "issued": "2021-04-25T02:54:04.732Z", "validFrom": "2021-03-26T10:08:59Z", "validUntil": "2099-03-26T10:08:59Z", "credentialSubject": { "3": { "name": "Tom" }, "4": { "degree": "Master" }, "6": { "university": "RepChain Training University" } }, "proof": { "type": "EcdsaPrime256v1Signature", "created": "2021-04-25T02:54:04.853Z", "verificationMethod": "did:rep:example:121000005l35120456#node1", "signature": { "3": "MEYCIQDZM5T/YZUfEx4y1ToElx/L8JU8jRu3nNdUtovIUBEj6wIhAKHKTMSDe9QM1IRHKPOvolQTm0Xr1i3tEHAXT1J+bGQh", "4": "MEUCIQDcWfS/0kOq1sYdsTovmAQAr5GhUNX846WRPBdPjlOx9gIgb2vKZKpsrzorwY8jEGURHG7VAvJig1Re3C/j+m/fTZg=", "6": "MEUCIGi5zBTzHZbxQqtX6AviHWsZpuyfZYgZmGGQPnXr0Tk9AiEApK6owZAFVSCdZjc9LN+svuAnqK1hfmr7eTC/LBWHWxQ=" } } }, "proof": { "type": "EcdsaPrime256v1Signature", "created": "2021-05-07T09:15:18.845Z", "verificationMethod": "did:rep:example:12110107bi45jh675g#node2", "challenge": "challenge-random-jsdio837jkds", "signature": "MEQCID0di91TRN5qW0s16KgdzXFz7a/OPEK0l0dK8wfJtMWyAiBnfI7uwedvLfAfyJ2YOdtQHT79F2wFiemf31HeeO63Dw==" } } ``` ##### Verify VP 验证可验证凭据出示信息VP,将同时对VP签名、VP中包含VC的签名以及VC的有效期,状态进行验证 ||| |----|----| |url|/verifiable-presentations/:id/verifying| |method|POST| |request content type|application/json| |response content type|application/json| request example: - post /verifiable-presentations/0x987654/verifying - body: ```json { "vp": { "@context": [ "https://www.w3.org/2018/credentials/v1" ], "id": "0x987654", "type": [ "VerifiablePresentation", "UniversityDegreePresentation" ], "holder": "did:rep:example:12110107bi45jh675g", "verifiableCredential": { "@context": [ "https://www.w3.org/2018/credentials/v1" ], "id": "0x123456", "type": [ "VerifiableCredential", "UniversityDegreeCredential" ], "claimScheme": "CCS-001", "issuer": "did:rep:example:121000005l35120456", "issued": "2021-04-25T10:33:48.561Z", "validFrom": "2021-03-26T10:08:59Z", "validUntil": "2099-03-26T10:08:59Z", "credentialSubject": { "6": { "university": "RepChain Training University" } }, "proof": { "type": "EcdsaPrime256v1Signature", "created": "2021-04-25T10:33:48.561Z", "verificationMethod": "did:rep:example:121000005l35120456#node1", "signature": { "6": "MEYCIQDyMksOsTiXRHvAHBA+KDiRf3nQwARwDVaYOcH0pZFquAIhAOsxbXB3mUaQbnQmoJ6jUq6UNpubmQVtRiWBf177QIf7" } } }, "proof": { "type": "EcdsaPrime256v1Signature", "created": "2021-04-25T10:35:53.840Z", "verificationMethod": "did:rep:example:12110107bi45jh675g#node2", "challenge": "challenge-random-jsdio837jkds", "signature": "MEYCIQDnVcc6464yE7dKMtc1s2zPkWY3i3n72UkJNGuwzgftDQIhAJrj5UWfwHux93MsS5+yU/PdBkNGgQ0eCLUMPWS7erg2" } }, "targetChallenge": "challenge-random-jsdio837jkds", "targetStatus": [ "VALID" ] } ``` response example: - status: 200 - body: ```json { "result": true } ```