Class Pairwise
Provides methods for managing pairwise identifiers.
Inheritance
Namespace: Hyperledger.Indy.PairwiseApi
Assembly: Hyperledger.Indy.Sdk.dll
Syntax
public static class Pairwise : Object
Remarks
A Pairwise is a record of the relationship between a DID owned by the caller of the API and
one belonging to another party, referred to respectively in this API as myDID
and theirDID
.
Pairwise records can also hold additional optional metadata.
Methods
CreateAsync(Wallet, String, String, String)
Creates a new pairwise record between two specified DIDs in the provided wallet.
Declaration
public static Task CreateAsync(Wallet wallet, string theirDid, string myDid, string metadata)
Parameters
Type | Name | Description |
---|---|---|
Wallet | wallet | The wallet to store create the pairwise record in. |
System.String | theirDid | The DID of the remote party. |
System.String | myDid | The DID belonging to the owner of the wallet. |
System.String | metadata | Optional metadata to store with the record. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | An asynchronous System.Threading.Tasks.Task completes once the operation completes. |
GetAsync(Wallet, String)
Gets the pairwise record associated with the specified DID from the provided wallet.
Declaration
public static Task<string> GetAsync(Wallet wallet, string theirDid)
Parameters
Type | Name | Description |
---|---|---|
Wallet | wallet | The wallet to get the pairwise record from. |
System.String | theirDid | The DID belonging to another party to get the pairwise record for. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.String> | An asynchronous System.Threading.Tasks.Task<> that resolves to a JSON string containing a pairwise record. |
Remarks
The JSON string that this method resolves to will contain a single pairwise record for two DIDs, the DID belonging to the record owner (my_did), the associated DID belonging to the other party (their_did) and any metadata associated with the record (metadata).
[
{"my_did":"my_did_for_A","their_did":"A's_did_for_me","metadata":"some metadata"},
{"my_did":"my_did_for_B","their_did":"B's_did_for_me"}
...
]
Note that if no metadata is present in a record the JSON will omit the metadata
key.
IsExistsAsync(Wallet, String)
Gets whether or not a pairwise record exists in the provided wallet for the specified DID .
Declaration
public static Task<bool> IsExistsAsync(Wallet wallet, string theirDid)
Parameters
Type | Name | Description |
---|---|---|
Wallet | wallet | The wallet to check for a pairwise record. |
System.String | theirDid | The DID to check. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | An asynchronous System.Threading.Tasks.Task<> that resolves to true if a pairwise exists for the DID, otherwise false. |
ListAsync(Wallet)
Lists all pairwise relationships stored in the specified wallet.
Declaration
public static Task<string> ListAsync(Wallet wallet)
Parameters
Type | Name | Description |
---|---|---|
Wallet | wallet | The wallet to get the pairwise records from. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.String> | An asynchronous System.Threading.Tasks.Task<> that resolves to a JSON string containing an array of all pairwise relationships stored in the wallet. |
Remarks
The JSON string that this method resolves to will contain a array of objects each of which describes a pairwise record for two DIDs, a DID belonging to the record owner (my_did) and the associated DID belonging to the other party (their_did).
[
{"my_did":"my_did_for_A","their_did":"A's_did_for_me"},
{"my_did":"my_did_for_B","their_did":"B's_did_for_me"}
...
]
Note that this call does not return any metadata associated with the pairwise records; to get the metadata use the GetAsync(Wallet, String) method.
SetMetadataAsync(Wallet, String, String)
Sets the metadata on the existing pairwise record for the specified DID in the provided wallet.
Declaration
public static Task SetMetadataAsync(Wallet wallet, string theirDid, string metadata)
Parameters
Type | Name | Description |
---|---|---|
Wallet | wallet | The wallet containing the pairwise record. |
System.String | theirDid | The DID belonging to another party the pairwise record exists for. |
System.String | metadata | The metadata to set on the pairwise record. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | An asynchronous System.Threading.Tasks.Task completes once the operation completes. |
Remarks
If the pairwise record already contains any existing metadata it will be replaced with the value provided
in the metadata
parameter. To remove all metadata for a record provide null
in the
metadata
parameter.