1. createWeId¶
基本信息
接口名称:com.webank.weid.rpc.WeIdService.createWeId
接口定义:ResponseData<CreateWeIdDataResult> createWeId()
接口描述: 内部创建公私钥,并链上注册WeIdentity DID, 并返回公钥、私钥以及WeIdentity DID。
接口入参: 无
接口返回: com.webank.weid.protocol.response.ResponseData<CreateWeIdDataResult>;
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
errorCode | Integer | 返回结果码 | |
errorMessage | String | 返回结果描述 | |
result | CreateWeIdDataResult | 见下 | |
transactionInfo | TransactionInfo | 交易信息 |
com.webank.weid.protocol.response.TransactionInfo
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
blockNumber | BigInteger | 交易块高 | |
transactionHash | String | 交易hash | |
transactionIndex | BigInteger | 交易索引 |
com.webank.weid.protocol.response.CreateWeIdDataResult
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
weId | String | 公钥WeIdentity DID格式字符串 | 格式: did:weid:1000:0x…………………. |
userWeIdPublicKey | WeIdPublicKey | ||
userWeIdPrivateKey | WeIdPrivateKey |
com.webank.weid.protocol.base.WeIdPublicKey
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
publicKey | String | 数字公钥 | 如下调用示例返回,使用十进制数字表示 |
com.webank.weid.protocol.base.WeIdPrivateKey
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
privateKey | String | 私钥 | 如下调用示例返回,使用十进制数字表示 |
此方法返回code
enum | code | desc |
---|---|---|
SUCCESS | 0 | 成功 |
WEID_KEYPAIR_CREATE_FAILED | 100107 | 创建密钥对失败 |
TRANSACTION_TIMEOUT | 160001 | 超时 |
TRANSACTION_EXECUTE_ERROR | 160002 | 交易错误 |
WEID_PRIVATEKEY_DOES_NOT_MATCH | 100106 | 私钥和weid不匹配 |
UNKNOW_ERROR | 160003 | 其他错误 |
调用示例
WeIdService weIdService = new WeIdServiceImpl();
ResponseData<CreateWeIdDataResult> response = weIdService.createWeId();
输出结果如下:
result:(com.webank.weid.protocol.response.CreateWeIdDataResult)
weId: did:weid:101:0xf4e5f96de0627960c8b91c1cc126f7b5cdeacbd0
userWeIdPublicKey:(com.webank.weid.protocol.base.WeIdPublicKey)
publicKey: 3140516665390655972698269231665028730625296545812754612198268107926656717368563044260511639762256438305037318801307432426840176526241566631412406151716674
userWeIdPrivateKey:(com.webank.weid.protocol.base.WeIdPrivateKey)
privateKey: 70694712486452850283637015242845250545254342779640874305734061338958342229003
errorCode: 0
errorMessage: success
transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
blockNumber: 30005
transactionHash: 0x7e4fcacdd296f10936e53d64c7d6470dd4ffa52e22405c86ed8f72389419821f
transactionIndex: 0
时序图
2. createWeId¶
基本信息
接口名称:com.webank.weid.rpc.WeIdService.createWeId
接口定义:ResponseData<String> createWeId(CreateWeIdArgs createWeIdArgs)
接口描述: 根据传入的公私钥,链上注册WeIdentity DID,并返回WeIdentity DID。
接口入参: com.webank.weid.protocol.request.CreateWeIdArgs
名称 | 类型 | 非空 | 说明 | 备注 |
---|---|---|---|---|
publicKey | String | Y | 数字公钥 | |
weIdPrivateKey | WeIdPrivateKey | Y | 后期鉴权使用 |
com.webank.weid.protocol.base.WeIdPrivateKey
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
privateKey | String | 私钥 | 使用十进制数字表示 |
接口返回: com.webank.weid.protocol.response.ResponseData<String>;
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
errorCode | Integer | 返回结果码 | |
errorMessage | String | 返回结果描述 | |
result | String | 公钥WeIdentity DID格式字符串 | 如:did:weid:1000:0x…………………. |
transactionInfo | TransactionInfo | 交易信息 |
com.webank.weid.protocol.response.TransactionInfo
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
blockNumber | BigInteger | 交易块高 | |
transactionHash | String | 交易hash | |
transactionIndex | BigInteger | 交易索引 |
此方法返回code
enum | code | desc |
---|---|---|
SUCCESS | 0 | 成功 |
WEID_PUBLICKEY_INVALID | 100102 | 公钥无效 |
WEID_PRIVATEKEY_INVALID | 100103 | 私钥格式非法 |
WEID_ALREADY_EXIST | 100105 | WeIdentity DID已存在 |
WEID_PRIVATEKEY_DOES_NOT_MATCH | 100106 | 私钥不与WeIdentity DID所对应 |
WEID_PUBLICKEY_AND_PRIVATEKEY_NOT_MATCHED | 100108 | 公私钥不成对 |
TRANSACTION_TIMEOUT | 160001 | 超时 |
TRANSACTION_EXECUTE_ERROR | 160002 | 交易错误 |
UNKNOW_ERROR | 160003 | 其他异常 |
ILLEGAL_INPUT | 160004 | 参数为空 |
调用示例
WeIdService weIdService = new WeIdServiceImpl();
CreateWeIdArgs createWeIdArgs = new CreateWeIdArgs();
createWeIdArgs.setPublicKey(
"2905679808560626772263712571437125497429146398815877180317365034921958007199576809718056336050058032599743534507469742764670961100255274766148096681073592");
WeIdPrivateKey weIdPrivateKey = new WeIdPrivateKey();
weIdPrivateKey.setPrivateKey("7581560237967740187496354914151086729152742173850631851769274217992481997665");
createWeIdArgs.setWeIdPrivateKey(weIdPrivateKey);
ResponseData<String> response = weIdService.createWeId(createWeIdArgs);
输出结果如下:
result: did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a
errorCode: 0
errorMessage: success
transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
blockNumber: 30007
transactionHash: 0x7f9e0fe2bcb0e77bad9aa5c38f8440e71a48dc29406d9ad43e12130afd211c67
transactionIndex: 0
时序图
3. delegateCreateWeId¶
基本信息
接口名称:com.webank.weid.rpc.WeIdService.delegateCreateWeId
接口定义:ResponseData<String> delegateCreateWeId(WeIdPublicKey publicKey,WeIdAuthentication weIdAuthentication)
接口描述: 根据传入的公钥和代理的私钥,通过代理发交易链上注册WeIdentity DID,并返回WeIdentity DID。
接口入参: com.webank.weid.protocol.base.WeIdPublicKey
名称 | 类型 | 非空 | 说明 | 备注 |
---|---|---|---|---|
publicKey | String | Y | 数字公钥,代理会根据这个公钥来创建WeID |
com.webank.weid.protocol.base.WeIdAuthentication
名称 | 类型 | 非空 | 说明 | 备注 |
---|---|---|---|---|
weId | String | Y | WeIdentity DID | WeIdentity DID的格式传入 |
weIdPublicKeyId | String | N | 公钥Id | |
weIdPrivateKey | WeIdPrivateKey | Y | 交易私钥,见下 |
com.webank.weid.protocol.base.WeIdPrivateKey
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
privateKey | String | 私钥 | 使用十进制数字表示 |
接口返回: com.webank.weid.protocol.response.ResponseData<String>;
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
errorCode | Integer | 返回结果码 | |
errorMessage | String | 返回结果描述 | |
result | String | 公钥WeIdentity DID格式字符串 | 如:did:weid:1000:0x…………………. |
transactionInfo | TransactionInfo | 交易信息 |
com.webank.weid.protocol.response.TransactionInfo
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
blockNumber | BigInteger | 交易块高 | |
transactionHash | String | 交易hash | |
transactionIndex | BigInteger | 交易索引 |
此方法返回code
enum | code | desc |
---|---|---|
SUCCESS | 0 | 成功 |
WEID_PUBLICKEY_INVALID | 100102 | 公钥无效 |
WEID_PRIVATEKEY_INVALID | 100103 | 私钥格式非法 |
WEID_ALREADY_EXIST | 100105 | WeIdentity DID已存在 |
TRANSACTION_TIMEOUT | 160001 | 超时 |
TRANSACTION_EXECUTE_ERROR | 160002 | 交易错误 |
UNKNOW_ERROR | 160003 | 其他异常 |
ILLEGAL_INPUT | 160004 | 参数为空 |
调用示例
WeIdService weIdService = new WeIdServiceImpl();
WeIdPublicKey weIdPublicKey = new WeIdPublicKey();
weIdPublicKey.setPublicKey(
"2905679808560626772263712571437125497429146398815877180317365034921958007199576809718056336050058032599743534507469742764670961100255274766148096681073592");
String delegateWeId = "did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7";
String delegatePrivateKey = "60866441986950167911324536025850958917764441489874006048340539971987791929772";
WeIdAuthentication weIdAuthentication = new WeIdAuthentication(delegateWeId, delegatePrivateKey);
weIdAuthentication.setWeIdPublicKeyId("did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7#key0");
ResponseData<String> response = weIdService.delegateCreateWeId(weIdPublicKey, weIdAuthentication);
输出结果如下:
result: did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a
errorCode: 0
errorMessage: success
transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
blockNumber: 30007
transactionHash: 0x7f9e0fe2bcb0e77bad9aa5c38f8440e71a48dc29406d9ad43e12130afd211c67
transactionIndex: 0
时序图
4. getWeIdDocumentJson¶
基本信息
接口名称:com.webank.weid.rpc.WeIdService.getWeIdDocumentJson
接口定义:ResponseData<String> getWeIdDocumentJson(String weId)
接口描述: 根据WeIdentity DID查询WeIdentity DID Document信息,并以JSON格式返回。
接口入参: String
名称 | 类型 | 非空 | 说明 | 备注 |
---|---|---|---|---|
weId | String | Y | WeIdentity DID字符串 |
接口返回: com.webank.weid.protocol.response.ResponseData<String>;
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
errorCode | Integer | 返回结果码 | |
errorMessage | String | 返回结果描述 | |
result | String | weidDocument Json |
此方法返回code
enum | code | desc |
---|---|---|
SUCCESS | 0 | 成功 |
WEID_INVALID | 100101 | 无效的WeIdentity DID |
WEID_DOES_NOT_EXIST | 100104 | WeIdentity DID不存在 |
TRANSACTION_TIMEOUT | 160001 | 超时 |
TRANSACTION_EXECUTE_ERROR | 160002 | 交易错误 |
UNKNOW_ERROR | 160003 | 其他错误 |
调用示例
WeIdService weIdService = new WeIdServiceImpl();
ResponseData<String> response = weIdService.getWeIdDocumentJson("did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a");
返回结果如下:
result: {"@context" : "https://github.com/WeBankFinTech/WeIdentity/blob/master/context/v1",
"id" : "did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a",
"created" : 1560419409898,
"updated" : 1560419409898,
"publicKey" : [ {
"id" : "did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a#keys-0",
"type" : "Secp256k1",
"owner" : "did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a",
"publicKey" : "2905679808560626772263712571437125497429146398815877180317365034921958007199576809718056336050058032599743534507469742764670961100255274766148096681073592"
} ],
"authentication" : [ {
"type" : "Secp256k1",
"publicKey" : "did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a#keys-0"
} ],
"service" : [ {
"type" : "drivingCardService",
"serviceEndpoint" : "https://weidentity.webank.com/endpoint/xxxxx"
} ]
}
errorCode: 0
errorMessage: success
transactionInfo:null
时序图
(同时也包含getWeIDDocment时序)
5. getWeIDDocment¶
基本信息
接口名称:com.webank.weid.rpc.WeIdService.getWeIdDocument
接口定义:ResponseData<WeIdDocument> getWeIdDocument(String weId)
接口描述: 根据WeIdentity DID查询出WeIdentity DID Document对象。
接口入参: String
名称 | 类型 | 非空 | 说明 | 备注 |
---|---|---|---|---|
weId | String | Y | WeIdentity DID字符串 |
接口返回: com.webank.weid.protocol.response.ResponseData<WeIdDocument>;
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
errorCode | Integer | 返回结果码 | |
errorMessage | String | 返回结果描述 | |
result | WeIdDocument | 见下 | |
transactionInfo | TransactionInfo | 交易信息 |
com.webank.weid.protocol.response.TransactionInfo
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
blockNumber | BigInteger | 交易块高 | |
transactionHash | String | 交易hash | |
transactionIndex | BigInteger | 交易索引 |
com.webank.weid.protocol.base.WeIdDocument
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
id | String | WeIdentity DID | |
created | Long | 创建时间 | |
updated | Long | 更新时间 | |
publicKey | List |
列出公钥集合,见下 | |
authentication | List |
认证方集合,见下 | |
service | List |
服务端点集合,见下 |
com.webank.weid.protocol.base.PublicKeyProperty
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
id | String | ||
type | String | 类型 | 默认为:Secp256k1 |
owner | String | 拥有者WeIdentity DID | |
publicKey | String | 数字公钥 |
com.webank.weid.protocol.base.AuthenticationProperty
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
type | String | 类型 | 默认为:Secp256k1 |
publicKey | String |
com.webank.weid.protocol.base.ServiceProperty
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
type | String | 类型 | |
serviceEndpoint | String |
此方法返回code
enum | code | desc |
---|---|---|
SUCCESS | 0 | 成功 |
WEID_INVALID | 100101 | 无效的WeIdentity DID |
WEID_DOES_NOT_EXIST | 100104 | WeIdentity DID不存在 |
TRANSACTION_TIMEOUT | 160001 | 超时 |
TRANSACTION_EXECUTE_ERROR | 160002 | 交易错误 |
UNKNOW_ERROR | 160003 | 其他错误 |
调用示例
WeIdService weIdService = new WeIdServiceImpl();
ResponseData<WeIdDocument> response = weIdService.getWeIdDocument("did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a");
返回结果如下:
result:(com.webank.weid.protocol.base.WeIdDocument)
id: did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a
created: 1560419409898
updated: 1560419409898
publicKey:(java.util.ArrayList)
[0]:com.webank.weid.protocol.base.PublicKeyProperty
id: did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a#keys-0
type: Secp256k18
owner: did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a
publicKey: 2905679808560626772263712571437125497429146398815877180317365034921958007199576809718056336050058032599743534507469742764670961100255274766148096681073592
authentication:(java.util.ArrayList)
[0]:com.webank.weid.protocol.base.AuthenticationProperty
type: Secp256k1
publicKey: did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a#keys-0
service:(java.util.ArrayList)
[0]:com.webank.weid.protocol.base.ServiceProperty
type: drivingCardService
serviceEndpoint: https://weidentity.webank.com/endpoint/8377464
errorCode: 0
errorMessage: success
transactionInfo:null
6. setPublicKey¶
基本信息
接口名称:com.webank.weid.rpc.WeIdService.setPublicKey
接口定义:ResponseData<Boolean> setPublicKey(SetPublicKeyArgs setPublicKeyArgs)
接口描述: 根据WeIdentity DID添加公钥。
接口入参: com.webank.weid.protocol.request.SetPublicKeyArgs
名称 | 类型 | 非空 | 说明 | 备注 |
---|---|---|---|---|
weId | String | Y | WeIdentity DID格式字符串 | 如:did:weid:1000:1:0x…. |
owner | String | N | 所有者 | 默认为当前WeIdentity DID |
publicKey | String | Y | 数字公钥 | |
userWeIdPrivateKey | WeIdPrivateKey | Y | 交易私钥,后期鉴权使用,见下 |
com.webank.weid.protocol.base.WeIdPrivateKey
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
privateKey | String | 私钥 | 使用十进制数字表示 |
接口返回: com.webank.weid.protocol.response.ResponseData<Boolean>;
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
errorCode | Integer | 返回结果码 | |
errorMessage | String | 返回结果描述 | |
result | Boolean | 是否set成功 | |
transactionInfo | TransactionInfo | 交易信息 |
com.webank.weid.protocol.response.TransactionInfo
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
blockNumber | BigInteger | 交易块高 | |
transactionHash | String | 交易hash | |
transactionIndex | BigInteger | 交易索引 |
此方法返回code
enum | code | desc |
---|---|---|
SUCCESS | 0 | 成功 |
WEID_INVALID | 100101 | 无效的WeIdentity DID |
WEID_PRIVATEKEY_INVALID | 100103 | 私钥格式非法 |
WEID_PRIVATEKEY_DOES_NOT_MATCH | 100106 | 私钥不与WeIdentity DID所对应 |
TRANSACTION_TIMEOUT | 160001 | 超时 |
TRANSACTION_EXECUTE_ERROR | 160002 | 交易错误 |
UNKNOW_ERROR | 160003 | 其他错误 |
ILLEGAL_INPUT | 160004 | 参数为空 |
调用示例
WeIdService weIdService = new WeIdServiceImpl();
SetPublicKeyArgs setPublicKeyArgs = new SetPublicKeyArgs();
setPublicKeyArgs.setWeId("did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7");
setPublicKeyArgs.setPublicKey(
"13161444623157635919577071263152435729269604287924587017945158373362984739390835280704888860812486081963832887336483721952914804189509503053687001123007342");
WeIdPrivateKey weIdPrivateKey = new WeIdPrivateKey();
weIdPrivateKey.setPrivateKey("60866441986950167911324536025850958917764441489874006048340539971987791929772");
setPublicKeyArgs.setUserWeIdPrivateKey(weIdPrivateKey);
ResponseData<Boolean> response = weIdService.setPublicKey(setPublicKeyArgs);
返回结果如下:
result: true
errorCode: 0
errorMessage: success
transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
blockNumber: 30011
transactionHash: 0xda4a1c64a3991170975475fdd6604bb2897512948ea491d3c88f24c4c3fd0028
transactionIndex: 0
时序图
7. delegateSetPublicKey¶
基本信息
接口名称:com.webank.weid.rpc.WeIdService.delegateSetPublicKey
接口定义:ResponseData<Boolean> setPublicKey(PublicKeyArgs publicKeyArgs, WeIdAuthentication delegateAuth)
接口描述: 由代理来给WeIdentity DID添加公钥。
接口入参: com.webank.weid.protocol.request.PublicKeyArgs
名称 | 类型 | 非空 | 说明 | 备注 |
---|---|---|---|---|
weId | String | Y | WeIdentity DID格式字符串 | 如:did:weid:1000:1:0x…. |
owner | String | N | 所有者 | 默认为当前WeIdentity DID |
publicKey | String | Y | 数字公钥 |
com.webank.weid.protocol.base.WeIdAuthentication
名称 | 类型 | 非空 | 说明 | 备注 |
---|---|---|---|---|
weId | String | Y | WeIdentity DID | WeIdentity DID的格式传入 |
weIdPublicKeyId | String | N | 公钥Id | |
weIdPrivateKey | WeIdPrivateKey | Y | 交易私钥,见下 |
com.webank.weid.protocol.base.WeIdPrivateKey
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
privateKey | String | 私钥 | 使用十进制数字表示 |
接口返回: com.webank.weid.protocol.response.ResponseData<Boolean>;
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
errorCode | Integer | 返回结果码 | |
errorMessage | String | 返回结果描述 | |
result | Boolean | 是否set成功 | |
transactionInfo | TransactionInfo | 交易信息 |
com.webank.weid.protocol.response.TransactionInfo
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
blockNumber | BigInteger | 交易块高 | |
transactionHash | String | 交易hash | |
transactionIndex | BigInteger | 交易索引 |
此方法返回code
enum | code | desc |
---|---|---|
SUCCESS | 0 | 成功 |
WEID_INVALID | 100101 | 无效的WeIdentity DID |
WEID_PRIVATEKEY_INVALID | 100103 | 私钥格式非法 |
TRANSACTION_TIMEOUT | 160001 | 超时 |
TRANSACTION_EXECUTE_ERROR | 160002 | 交易错误 |
UNKNOW_ERROR | 160003 | 其他错误 |
ILLEGAL_INPUT | 160004 | 参数为空 |
调用示例
WeIdService weIdService = new WeIdServiceImpl();
PublicKeyArgs publicKeyArgs = new PublicKeyArgs();
publicKeyArgs.setWeId("did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7");
publicKeyArgs.setPublicKey(
"13161444623157635919577071263152435729269604287924587017945158373362984739390835280704888860812486081963832887336483721952914804189509503053687001123007342");
String delegateWeId = "did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7";
String delegatePrivateKey = "60866441986950167911324536025850958917764441489874006048340539971987791929772";
WeIdAuthentication weIdAuthentication = new WeIdAuthentication(delegateWeId, delegatePrivateKey);
weIdAuthentication.setWeIdPublicKeyId("did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7#key0");
ResponseData<Boolean> response = weIdService.delegateSetPublicKey(publicKeyArgs,weIdAuthentication);
返回结果如下:
result: true
errorCode: 0
errorMessage: success
transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
blockNumber: 30011
transactionHash: 0xda4a1c64a3991170975475fdd6604bb2897512948ea491d3c88f24c4c3fd0028
transactionIndex: 0
时序图
8. setService¶
基本信息
接口名称:com.webank.weid.rpc.WeIdService.setService
接口定义:ResponseData<Boolean> setService(SetServiceArgs setServiceArgs)
接口描述: 根据WeIdentity DID添加Service信息。
接口入参: com.webank.weid.protocol.request.SetServiceArgs
名称 | 类型 | 非空 | 说明 | 备注 |
---|---|---|---|---|
weId | String | Y | WeIdentity DID格式字符串 | 如:did:weid:101:0x….. |
type | String | Y | 类型 | 如:drivingCardService |
serviceEndpoint | String | Y | 服务端点 | 如:”https://weidentity.webank.com/endpoint/8377464” |
userWeIdPrivateKey | WeIdPrivateKey | Y | 交易私钥,后期鉴权使用,见下 |
com.webank.weid.protocol.base.WeIdPrivateKey
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
privateKey | String | 私钥 | 使用十进制数字表示 |
接口返回: com.webank.weid.protocol.response.ResponseData<Boolean>;
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
errorCode | Integer | 返回结果码 | |
errorMessage | String | 返回结果描述 | |
result | Boolean | 是否set成功 | |
transactionInfo | TransactionInfo | 交易信息 |
com.webank.weid.protocol.response.TransactionInfo
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
blockNumber | BigInteger | 交易块高 | |
transactionHash | String | 交易hash | |
transactionIndex | BigInteger | 交易索引 |
此方法返回code
enum | code | desc |
---|---|---|
SUCCESS | 0 | 成功 |
WEID_INVALID | 100101 | 无效的WeIdentity DID |
WEID_PRIVATEKEY_INVALID | 100103 | 私钥格式非法 |
WEID_PRIVATEKEY_DOES_NOT_MATCH | 100106 | 私钥不与WeIdentity DID所对应 |
WEID_SERVICE_TYPE_OVERLIMIT | 100110 | type字段超长 |
TRANSACTION_TIMEOUT | 160001 | 超时 |
TRANSACTION_EXECUTE_ERROR | 160002 | 交易错误 |
UNKNOW_ERROR | 160003 | 其他错误 |
ILLEGAL_INPUT | 160004 | 参数为空 |
调用示例
WeIdService weIdService = new WeIdServiceImpl();
SetServiceArgs setServiceArgs = new SetServiceArgs();
setServiceArgs.setWeId("did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7");
setServiceArgs.setType("drivingCardService");
setServiceArgs.setServiceEndpoint("https://weidentity.webank.com/endpoint/8377464");
WeIdPrivateKey weIdPrivateKey = new WeIdPrivateKey();
weIdPrivateKey.setPrivateKey("60866441986950167911324536025850958917764441489874006048340539971987791929772");
setServiceArgs.setUserWeIdPrivateKey(weIdPrivateKey);
ResponseData<Boolean> response = weIdService.setService(setServiceArgs);
返回结果如下:
result: true
errorCode: 0
errorMessage: success
transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
blockNumber: 30012
transactionHash: 0xf4992c4d190a9338f13119125861aaa3fa86622de1ab6862d06c05c6e6d1d9be
transactionIndex: 0
时序图
9. delegateSetService¶
基本信息
接口名称:com.webank.weid.rpc.WeIdService.delegateSetService
接口定义:ResponseData<Boolean> setService(ServiceArgs serviceArgs,WeIdAuthentication delegateAuth)
接口描述: 根据WeIdentity DID添加Service信息。
接口入参: com.webank.weid.protocol.request.ServiceArgs
名称 | 类型 | 非空 | 说明 | 备注 |
---|---|---|---|---|
weId | String | Y | WeIdentity DID格式字符串 | 如:did:weid:101:0x….. |
type | String | Y | 类型 | 如:drivingCardService |
serviceEndpoint | String | Y | 服务端点 | 如:”https://weidentity.webank.com/endpoint/8377464” |
com.webank.weid.protocol.base.WeIdAuthentication
名称 | 类型 | 非空 | 说明 | 备注 |
---|---|---|---|---|
weId | String | Y | WeIdentity DID | WeIdentity DID的格式传入 |
weIdPublicKeyId | String | N | 公钥Id | |
weIdPrivateKey | WeIdPrivateKey | Y | 交易私钥,见下 |
com.webank.weid.protocol.base.WeIdPrivateKey
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
privateKey | String | 私钥 | 使用十进制数字表示 |
接口返回: com.webank.weid.protocol.response.ResponseData<Boolean>;
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
errorCode | Integer | 返回结果码 | |
errorMessage | String | 返回结果描述 | |
result | Boolean | 是否set成功 | |
transactionInfo | TransactionInfo | 交易信息 |
com.webank.weid.protocol.response.TransactionInfo
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
blockNumber | BigInteger | 交易块高 | |
transactionHash | String | 交易hash | |
transactionIndex | BigInteger | 交易索引 |
此方法返回code
enum | code | desc |
---|---|---|
SUCCESS | 0 | 成功 |
WEID_INVALID | 100101 | 无效的WeIdentity DID |
WEID_PRIVATEKEY_INVALID | 100103 | 私钥格式非法 |
WEID_SERVICE_TYPE_OVERLIMIT | 100110 | type字段超长 |
TRANSACTION_TIMEOUT | 160001 | 超时 |
TRANSACTION_EXECUTE_ERROR | 160002 | 交易错误 |
UNKNOW_ERROR | 160003 | 其他错误 |
ILLEGAL_INPUT | 160004 | 参数为空 |
调用示例
WeIdService weIdService = new WeIdServiceImpl();
ServiceArgs serviceArgs = new ServiceArgs();
serviceArgs.setWeId("did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7");
serviceArgs.setType("drivingCardService");
serviceArgs.setServiceEndpoint("https://weidentity.webank.com/endpoint/8377464");
String delegateWeId = "did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7";
String delegatePrivateKey = "60866441986950167911324536025850958917764441489874006048340539971987791929772";
WeIdAuthentication weIdAuthentication = new WeIdAuthentication(delegateWeId, delegatePrivateKey);
weIdAuthentication.setWeIdPublicKeyId("did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7#key0");
ResponseData<Boolean> response = weIdService.delegateSetService(serviceArgs, weIdAuthentication);
返回结果如下:
result: true
errorCode: 0
errorMessage: success
transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
blockNumber: 30012
transactionHash: 0xf4992c4d190a9338f13119125861aaa3fa86622de1ab6862d06c05c6e6d1d9be
transactionIndex: 0
时序图
10. setAuthentication¶
基本信息
接口名称:com.webank.weid.rpc.WeIdService.setAuthentication
接口定义:ResponseData<Boolean> setAuthentication(SetAuthenticationArgs setAuthenticationArgs)
接口描述: 根据WeIdentity DID添加认证者。
接口入参: com.webank.weid.protocol.request.SetAuthenticationArgs
名称 | 类型 | 非空 | 说明 | 备注 |
---|---|---|---|---|
weId | String | Y | WeIdentity DID格式字符串 | 如:did:weid:101:0x…. |
owner | String | N | 所有者 | 默认为当前WeIdentity DID |
publicKey | String | Y | 数字公钥 | |
userWeIdPrivateKey | WeIdPrivateKey | Y | 交易私钥,后期鉴权使用,见下 |
com.webank.weid.protocol.base.WeIdPrivateKey
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
privateKey | String | 私钥 | 使用十进制数字表示 |
接口返回: com.webank.weid.protocol.response.ResponseData<Boolean>;
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
errorCode | Integer | 返回结果码 | |
errorMessage | String | 返回结果描述 | |
result | Boolean | 是否set成功 | |
transactionInfo | TransactionInfo | 交易信息 |
com.webank.weid.protocol.response.TransactionInfo
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
blockNumber | BigInteger | 交易块高 | |
transactionHash | String | 交易hash | |
transactionIndex | BigInteger | 交易索引 |
此方法返回code
enum | code | desc |
---|---|---|
SUCCESS | 0 | 成功 |
WEID_INVALID | 100101 | 无效的WeIdentity DID |
WEID_PRIVATEKEY_INVALID | 100103 | 私钥格式非法 |
WEID_PRIVATEKEY_DOES_NOT_MATCH | 100106 | 私钥不与WeIdentity DID所对应 |
TRANSACTION_TIMEOUT | 160001 | 超时 |
TRANSACTION_EXECUTE_ERROR | 160002 | 交易错误 |
UNKNOW_ERROR | 160003 | 其他错误 |
ILLEGAL_INPUT | 160004 | 参数为空 |
调用示例
WeIdService weIdService = new WeIdServiceImpl();
SetAuthenticationArgs setAuthenticationArgs = new SetAuthenticationArgs();
setAuthenticationArgs.setWeId("did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7");
setAuthenticationArgs.setPublicKey(
"13161444623157635919577071263152435729269604287924587017945158373362984739390835280704888860812486081963832887336483721952914804189509503053687001123007342");
WeIdPrivateKey weIdPrivateKey = new WeIdPrivateKey();
weIdPrivateKey.setPrivateKey("60866441986950167911324536025850958917764441489874006048340539971987791929772");
setAuthenticationArgs.setUserWeIdPrivateKey(weIdPrivateKey);
ResponseData<Boolean> response = weIdService.setAuthentication(setAuthenticationArgs);
返回结果如下:
result: true
errorCode: 0
errorMessage: success
transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
blockNumber: 30013
transactionHash: 0xfbf8338e7df2af0612eca5107c0d2ed75dfd7a795988687f49c010112678f847
transactionIndex: 0
时序图
11. delegateSetAuthentication¶
基本信息
接口名称:com.webank.weid.rpc.WeIdService.delegateSetAuthentication
接口定义:ResponseData<Boolean> delegateSetAuthentication(AuthenticationArgs authenticationArgs,WeIdAuthentication delegateAuth)
接口描述: 根据WeIdentity DID添加认证者。
接口入参: com.webank.weid.protocol.request.AuthenticationArgs
名称 | 类型 | 非空 | 说明 | 备注 |
---|---|---|---|---|
weId | String | Y | WeIdentity DID格式字符串 | 如:did:weid:101:0x…. |
owner | String | N | 所有者 | 默认为当前WeIdentity DID |
publicKey | String | Y | 数字公钥 |
com.webank.weid.protocol.base.WeIdAuthentication
名称 | 类型 | 非空 | 说明 | 备注 |
---|---|---|---|---|
weId | String | Y | WeIdentity DID | WeIdentity DID的格式传入 |
weIdPublicKeyId | String | N | 公钥Id | |
weIdPrivateKey | WeIdPrivateKey | Y | 交易私钥,见下 |
com.webank.weid.protocol.base.WeIdPrivateKey
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
privateKey | String | 私钥 | 使用十进制数字表示 |
接口返回: com.webank.weid.protocol.response.ResponseData<Boolean>;
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
errorCode | Integer | 返回结果码 | |
errorMessage | String | 返回结果描述 | |
result | Boolean | 是否set成功 | |
transactionInfo | TransactionInfo | 交易信息 |
com.webank.weid.protocol.response.TransactionInfo
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
blockNumber | BigInteger | 交易块高 | |
transactionHash | String | 交易hash | |
transactionIndex | BigInteger | 交易索引 |
此方法返回code
enum | code | desc |
---|---|---|
SUCCESS | 0 | 成功 |
WEID_INVALID | 100101 | 无效的WeIdentity DID |
WEID_PRIVATEKEY_INVALID | 100103 | 私钥格式非法 |
TRANSACTION_TIMEOUT | 160001 | 超时 |
TRANSACTION_EXECUTE_ERROR | 160002 | 交易错误 |
UNKNOW_ERROR | 160003 | 其他错误 |
ILLEGAL_INPUT | 160004 | 参数为空 |
调用示例
WeIdService weIdService = new WeIdServiceImpl();
AuthenticationArgs authenticationArgs = new AuthenticationArgs();
authenticationArgs.setWeId("did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7");
authenticationArgs.setPublicKey(
"13161444623157635919577071263152435729269604287924587017945158373362984739390835280704888860812486081963832887336483721952914804189509503053687001123007342");
String delegateWeId = "did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7";
String delegatePrivateKey = "60866441986950167911324536025850958917764441489874006048340539971987791929772";
WeIdAuthentication weIdAuthentication = new WeIdAuthentication(delegateWeId, delegatePrivateKey);
weIdAuthentication.setWeIdPublicKeyId("did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7#key0");
ResponseData<Boolean> response = weIdService.delegateSetAuthentication(authenticationArgs,weIdAuthentication);
返回结果如下:
result: true
errorCode: 0
errorMessage: success
transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
blockNumber: 30013
transactionHash: 0xfbf8338e7df2af0612eca5107c0d2ed75dfd7a795988687f49c010112678f847
transactionIndex: 0
时序图
12. isWeIdExist¶
基本信息
接口名称:com.webank.weid.rpc.WeIdService.isWeIdExist
接口定义:ResponseData<Boolean> isWeIdExist(String weId)
接口描述: 根据WeIdentity DID判断链上是否存在。
接口入参: String
名称 | 类型 | 非空 | 说明 | 备注 |
---|---|---|---|---|
weId | String | Y | WeIdentity DID格式字符串 | 如:did:weid:101:0x…. |
接口返回: com.webank.weid.protocol.response.ResponseData<Boolean>;
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
errorCode | Integer | 返回结果码 | |
errorMessage | String | 返回结果描述 | |
result | Boolean | 是否set成功 | |
transactionInfo | TransactionInfo | 交易信息 |
com.webank.weid.protocol.response.TransactionInfo
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
blockNumber | BigInteger | 交易块高 | |
transactionHash | String | 交易hash | |
transactionIndex | BigInteger | 交易索引 |
此方法返回code
enum | code | desc |
---|---|---|
SUCCESS | 0 | 成功 |
WEID_INVALID | 100101 | 无效的WeIdentity DID |
TRANSACTION_TIMEOUT | 160001 | 超时 |
TRANSACTION_EXECUTE_ERROR | 160002 | 交易错误 |
UNKNOW_ERROR | 160003 | 未知异常 |
调用示例
WeIdService weIdService = new WeIdServiceImpl();
ResponseData<Boolean> response = weIdService.isWeIdExist("did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7");
返回结果如下:
result: true
errorCode: 0
errorMessage: success
transactionInfo:null
时序图