1、底层链采用的FISCO BCOS V3框架,由于区块链智能合约调用与传统的HTTP接口具有差异性,接口调用的具体方法参考FISCO BCOS相关文档,详见:交易构造与调用 ,也可参考第四部分的示例程序。 2、链上数字身份合约采用Solidity 0.8版本进行编写,本文档的接口均基于此基础之上。 3、由于区块链的异步性,事务类型的交易接口,只返回当前交易的Hash,具体的接口描述中不再说明。 4、本合约通过事件机制获取链上交易的执行结果,具体使用方法,详见第四部分的示例程序。
| 命名 | 描述 |
|---|---|
| BID | Blockchain based Identity,即链上身份,用于链上的数字身份识别,标识方式为:bid:method:identity,如用公钥标识的方式为:bid:key:1234567890 |
| IDP | id provide,简称IDP,即身份提供方,有权为普通用户颁发身份证明。如CA机构可以为用户颁发数字证书,学校可以为学生颁发成绩证书等。 |
| usci | Unified Social Credit Identifier,中国境内企业的统一社会信用代码 |
IDP首先要作为普通用户进行BID初始登记,登记完成后,由权威机构对IDP身份进行认证。
/**
* register idp, can be called by anyone, will only be valid after been granted
* @param bid, bid to be registered
* @param usci, unified social credit identifier
* @param name, company or organization name
* Emits {IdpCreated} event
*/
function registerIdp(string calldata bid, string calldata name, string calldata usci) public;| 参数 | 是否必传 | 描述 |
|---|---|---|
| bid | 是 | 待登记IDP的bid |
| usci | 是 | 机构统一社会信用代码 |
| name | 是 | 机构全称 |
由权威机构对IDP角色进行认证。
/**
* grant idp, can only be called by admin
* @param bid, bid of idp to be granted
* @param idpType, type of idp
* Emits {IdpGranted} event
*/
function grantIdpRole(string calldata bid, uint256 idpType) public onlyRole(DEFAULT_ADMIN_ROLE);| 参数 | 是否必传 | 描述 |
|---|---|---|
| bid | 是 | 待给予认证IDP的bid |
| idpType | 是 | IDP的类型, 0为CA机构 |
由权威机构收回机构的IDP角色。
/**
* revoke idp grantee, can only be called by admin
* @param bid, bid of idp to be granted
* Emits {IdpRevoked} event
*/
function revokeIdpRole(string calldata bid) public onlyRole(DEFAULT_ADMIN_ROLE);| 参数 | 是否必传 | 描述 |
|---|---|---|
| bid | 是 | 待取消认证IDP的bid |
用户需要首先在链上登记BID身份,登记完成后,由IDP进行认证。
/**
* register bid, can be called by anyone, will only be valid after been certificated
* @param bid, bid to be registered
* @param socialCode, personal-sha256(id card number), business-unified social credit identifier
* @param name, personal-sha256(real name), business-company or organization name
* @param userType, 0-personal, 1-business
* Emits {BidCreated} event
*/
function registerBid(string calldata bid, string calldata name, string calldata socialCode, IdentityType userType) public;| 参数 | 是否必传 | 描述 |
|---|---|---|
| bid | 是 | 待登记的bid |
| socialCode | 是 | 社会身份编码:个人用户为身份证号码;机构用户为统一社会信用代码(usci)的明文。 |
| name | 是 | 个人用户为姓名;机构用户为机构名称的明文。 |
| type | 是 | 用户类型,0为个人用户,1为机构用户 |
由IDP机构认证其他用户的社会身份,实现公钥地址与用户法定身份的绑定。
/**
* certificate bid, can only be called by idp, and when the bid is not certificated or exceeded the validity
* @param bid, bid to be certificated
* @param validity, unix timestamp of the certification is valid
* @param comment, comment message for the certification
* Emits {BidCertificated} event
*/
function certificateBid(string calldata bid, uint256 validity, string calldata comment) public onlyRole(IDP_ROLE);