Provider API
Each API contains at least 3 parts: Description
, Params
, Return
, for the verification of several API (e.g. did_login
, did_requestCredentialDigest
, did_requestCredentialContent
, did_sign
) we provide the Verification Method in the SDK respectively.
All Methods
Authorization Method
requestAuth( )
Description
This API is designed for websites to request authorization from Users. User permission is the premise of all interaction, if the website hasn't obtained User permission yet, it can not be able to use the following API to interact with the User.
If this API returns Error Code -32001
, it means that the User rejects this request.
Return
Boolean
- whether the User request for authorization is successfully allowed.
isAuth( )
Description
This API's return shows whether the authorization is allowed. It is used for developer to query the user's authorization permission status. If the query status is true
, developer can continue to call other APIs. Otherwise, developer must first call wallet_requestAuth()
to get permission.
Return
Boolean
- whether the user allows authorization already.
DID Request Method
getCurrentDid( )
Description
As mentioned before, DID is the unique identifier of an entity. This API aims to fetch the current didUri
in the zkID Wallet, which helps developers to identify each User.
Return
DidInfo
Object - an example is shown below:
did_login(param)
Description
This API is for users to login the website with their DID. With this API, the user needs to make a signature on some message (given by the website) via the user's DID AuthenticationKey
. Once the user has successfully signed, the API returns the result of the user's signature, and developers can verify the validity of the signature through the Verify Method in our SDK. If the verification passes, then the login request should be permitted.
If this API returns Error Code -32001
, it means that the User rejects this request.
Param:
data (required)
Return:
HexString
- the user's signature on that data
Usage Of Return
After receiving the HexString
signature, developers need to verify its validity in order to check user's identity. In the SDK, we offer this verifyDidLogin function to help achieve that.
requestAuthAndLogin(param)
Description
This API is used to request authorization from Users, and ask the User to sign on some specific data to achieve DID Login
. You can see this API as the combination of requestAuth
and did_login
.
If the User hasn't give an authorization to the website, this function will request for the authorization first, and then do did_login.
If the User already give an authorization to the website, then this function does the same thing as did_login
.
If this API returns Error Code -32001
, it means that the User rejects this request.
Param:
data (required)
Return:
HexString
- the user's signature on that data
Usage Of Return
After receiving the HexString
signature, developers need to verify its validity in order to check user's identity. In the SDK, we offer this verifyDidLogin function to help achieve that.
VC Request Method
requestCredentialDigest(params)
Description
This API is used to obtain a Digest Disclosure of a credential, which won't reveal any details of other information. The return result contains some digest information(roothash, attested
status, revoked
status) and several helper information (including ctypeHash
, owner
, attester
, signature
)
If this API returns Error Code -32001
, it means that the User rejects this request.
If this API returns Error Code -32801
, it means that the Credential doesn't exist.
If this API returns Error Code -32010
, it means that the User hasn't give any authorization to this website, the request is not legal.
Params:
challenge
(required): a random stringctypehash
(optional),the ctypehash of credential, if passed, the wallet will only return the credential with the samectypehash
attester
(optional): attester's DID Url
Return:
VerifiablePresentation
Usage Of Return
This verifyCredentialDigest
method provided in our SDK can be used to check whether the Digest Disclosure is valid, whether the User is the Credential's Owner.
requestCredentialContent(params)
Description
This API is used to obtain a further disclosure of a credential, developers could use this API to achieve Selective Disclosure or All Credential Content Disclosure via passing different params.
If this API returns Error Code -32001
, it means that the User rejects this request.
If this API returns Error Code -32801
, it means that the Credential doesn't exist.
If this API returns Error Code -32802
, it means that the Credential Metadata doesn't match.
Params:
challenge
(required): a random stringcontentKeys
(optional): the content keys need to be disclosedctypehash
(optional),the ctypehash of credential, if passed, the wallet will only return the credential with the samectypehash
attester
(optional): attester's DID Url
Developers will get the Selective Disclosure result if they pass specific
contentKeys
into this API; Otherwise, if the fieldcontentKeys
is empty, they will obtain a All Credential Content Disclosure.
Return:
VerifiablePresentation
Usage Of Return
This verifyCredentialContent
method provided in our SDK can be used to check whether the Selective Disclosure or All Credential Content Disclosure is valid, whether the User is the Credential's Owner.
DID-Key Method
sign(param)
Description
This API is for users to make a signature on some data via the user's DID AuthenticationKey
. Once the user has successfully signed, the API returns the result of the user's signature, and developers can verify the validity of the signature through the Verify Method in our SDK.
If this API returns Error Code -32001
, it means that the User rejects this request.
Param:
data
(required): data to be signedkey_Id
(optional): the key used to sign, if not specified, useauthenticationkey
by defalut.
Return:
HexString
- the user's signature on that data
encrypt(params)
Description
This API uses user's and peer's AgreementKey
to encrypt data, can be used for build secret communication channel. Using this API, both parties of message transmission do not need to worry about message eavesdropping or leakage, encrypted messages can only be read through Decryption Method.
If this API returns Error Code -32001
, it means that the User rejects this request.
Params:
data
(required) : the data to be encryptedreceiver
:(required): the DID Url of the receiver, used to encrypt
Return:
HexString
- the encryption result
decrypt(params)
Description
This API uses user's and peer's AgreementKey
to decrypt data, can be used for decrypt message transferred by secret communication channel.
If this API returns Error Code -32001
, it means that the User rejects this request.
Params
data
(required) : the data to be decryptedsender
:(required): the DID Url of the sender, used to decrypt
Return:
HexString
- the decryption result
ZKP Method
generateZkp(params)
Description
This API is used to generate zero-knowledge proof with specific ZKP Program
and VC
.
The ZKP Program
used should be passed as a parameter. Besides, the VC
used to run such ZKP Program should also be specified via its ctypehash
and attester
.
Params
ZkpGenRequest
ctype
(optional) : the specifiedctypehash
of the VCattester
:(optional): the specified attester's DID Urlprogram
:(required): String of the ZKP Program
Return:
ZkpGenResponse
outputs
- the execution result of the ZKP Programstarkproof
- the zero-knowledge proof of running such ZKP ProgramprogramHash
- the ZKP Program's hashctype
- the specifiedctypehash
of the VCattester
- the specified attester's DID Url
Last updated