UNPKG

142 kBMarkdownView Raw
1# Indy SDK for Node.js
2
3[![stability - experimental](https://img.shields.io/badge/stability-experimental-orange.svg)](https://nodejs.org/api/documentation.html#documentation_stability_index)
4![Node version](https://img.shields.io/node/v/indy-sdk.svg)
5
6Native bindings for [Hyperledger Indy](https://www.hyperledger.org/projects/hyperledger-indy).
7
8- [Installing](#installing)
9- [Usage](#usage)
10- [API](#api)
11 * [IndyError](#indyerror)
12 * [anoncreds](#anoncreds)
13 * [blob_storage](#blob_storage)
14 * [crypto](#crypto)
15 * [did](#did)
16 * [ledger](#ledger)
17 * [non_secrets](#non_secrets)
18 * [pairwise](#pairwise)
19 * [payment](#payment)
20 * [pool](#pool)
21 * [wallet](#wallet)
22 * [logger](#logger)
23 * [cache](#cache)
24 * [mod](#mod)
25- [Advanced](#advanced)
26- [Contributing](#contributing)
27
28## Installing
29
30This module has a native compile step. It compiles C++ code and dynamically links to `libindy`.
31
32You will need:
33
34* C++ build tools and Python 3.6+. See [this](https://github.com/nodejs/node-gyp#installation) for platform recommendations.
35* `libindy` v1.6+ in your system library path. (i.e. `/usr/lib/libindy.so` for linux)
36
37Then you can install via npm:
38
39```sh
40npm install --save indy-sdk
41```
42
43#### Troubleshooting
44Use environment variable `RUST_LOG={info|debug|trace}` to output logs of Libindy.
45
46##### Linking errors
47
48i.e. `ld: library not found for -llibindy`
49
50First, make sure you have the latest libindy for your platform. Also make sure you have any other libraries it depends on. See [indy-sdk/doc](https://github.com/hyperledger/indy-sdk/tree/master/doc)
51
52Second, make sure it's in the linker search path. The easiest way is to use the system library path.
53* ubuntu `/usr/lib/libindy.so`
54* osx `/usr/local/lib/libindy.dylib`
55* windows use LD_LIBRARY_PATH to indicate the location of dll as specified below
56
57If you want to put the library in a custom folder i.e. `/foo/bar/libindy.so` then you can do this:
58```sh
59LD_LIBRARY_PATH=/foo/bar npm i --save indy-sdk
60```
61Then when you run your code, you'll still need the `LD_LIBRARY_PATH` set.
62```sh
63LD_LIBRARY_PATH=/foo/bar node index.js
64```
65
66##### Other build errors
67
68We use [node-gyp](https://github.com/nodejs/node-gyp#installation) to manage the cross-platform build. Their readme is quite helpful.
69
70## Usage
71
72```js
73var indy = require('indy-sdk')
74
75var did = '...'
76var fullVerkey = '...'
77
78indy.abbreviateVerkey(did, fullVerkey, function(err, verkey){
79 ..
80})
81
82// if you do not provide a callback, a Promise is returned
83
84var verkey = await indy.abbreviateVerkey(did, fullVerkey)
85```
86
87# API
88
89### IndyError
90
91All the functions may yield an IndyError. The errors are based on libindy error codes defined [here](https://github.com/hyperledger/indy-sdk/blob/master/libindy/include/indy_mod.h).
92
93* `err.indyCode`: Int - code number from libindy
94* `err.indyName`: String - name for the error code
95* `err.indyMessage`: String - human-readable error description
96* `err.indyBacktrace`: String? - if enabled, this is the libindy backtrace string
97
98Collecting of backtrace can be enabled by:
991. Setting environment variable `RUST_BACKTRACE=1`
1002. Calling [setRuntimeConfig](#setruntimeconfig--config-)(`{collect_backtrace: true}`)
101
102### anoncreds
103
104These functions wrap the Ursa algorithm as documented in this [paper](https://github.com/hyperledger/ursa/blob/master/libursa/docs/AnonCred.pdf):
105
106And is documented in this [HIPE](https://github.com/hyperledger/indy-hipe/blob/c761c583b1e01c1e9d3ceda2b03b35336fdc8cc1/text/anoncreds-protocol/README.md):
107
108#### issuerCreateSchema \( issuerDid, name, version, attrNames \) -> \[ id, schema \]
109
110Create credential schema entity that describes credential attributes list and allows credentials
111interoperability.
112
113Schema is public and intended to be shared with all anoncreds workflow actors usually by publishing SCHEMA transaction
114to Indy distributed ledger.
115
116It is IMPORTANT for current version POST Schema in Ledger and after that GET it from Ledger
117with correct seq\_no to save compatibility with Ledger.
118After that can call issuerCreateAndStoreCredentialDef to build corresponding Credential Definition.
119
120* `issuerDid`: String - DID of schema issuer
121* `name`: String - a name the schema
122* `version`: String - a version of the schema
123* `attrNames`: Json - a list of schema attributes descriptions (the number of attributes should be less or equal than 125)
124* __->__ [ `id`: String, `schema`: Json ] - schema\_id: identifier of created schema
125schema\_json: schema as json
126
127Errors: `Common*`, `Anoncreds*`
128
129#### issuerCreateAndStoreCredentialDef \( wh, issuerDid, schema, tag, signatureType, config \) -> \[ credDefId, credDef \]
130
131Create credential definition entity that encapsulates credentials issuer DID, credential schema, secrets used for signing credentials
132and secrets used for credentials revocation.
133
134Credential definition entity contains private and public parts. Private part will be stored in the wallet. Public part
135will be returned as json intended to be shared with all anoncreds workflow actors usually by publishing CRED\_DEF transaction
136to Indy distributed ledger.
137
138It is IMPORTANT for current version GET Schema from Ledger with correct seq\_no to save compatibility with Ledger.
139
140Note: Use combination of `issuerRotateCredentialDefStart` and `indy_issuer_rotate_credential_def_apply` functions
141to generate new keys for an existing credential definition.
142
143* `wh`: Handle (Number) - wallet handle (created by openWallet)
144* `issuerDid`: String - a DID of the issuer signing cred\_def transaction to the Ledger
145* `schema`: Json - credential schema as a json
146* `tag`: String - allows to distinct between credential definitions for the same issuer and schema
147* `signatureType`: String - credential definition type \(optional, 'CL' by default\) that defines credentials signature and revocation math. Supported types are:
148 * 'CL': Camenisch-Lysyanskaya credential signature type that is implemented according to the algorithm in this paper:
149 https://github.com/hyperledger/ursa/blob/master/libursa/docs/AnonCred.pdf
150 And is documented in this HIPE:
151 https://github.com/hyperledger/indy-hipe/blob/c761c583b1e01c1e9d3ceda2b03b35336fdc8cc1/text/anoncreds-protocol/README.md
152
153* `config`: Json - \(optional\) type-specific configuration of credential definition as json:
154 * 'CL':
155 * support\_revocation: whether to request non-revocation credential \(optional, default false\)
156* __->__ [ `credDefId`: String, `credDef`: Json ] - cred\_def\_id: identifier of created credential definition
157cred\_def\_json: public part of created credential definition
158
159Errors: `Common*`, `Wallet*`, `Anoncreds*`
160
161#### issuerRotateCredentialDefStart \( wh, credDefId, config \) -> credDef
162
163 Generate temporary credential definitional keys for an existing one (owned by the caller of the library).
164
165 Use `issuerRotateCredentialDefApply` function to set temporary keys as the main.
166
167 **WARNING**: Rotating the credential definitional keys will result in making all credentials issued under the previous keys unverifiable.
168
169* `wh`: Handle (Number) - wallet handle (created by openWallet)
170* `credDefId`: String - an identifier of created credential definition stored in the wallet
171* `config`: Json - \(optional\) type-specific configuration of credential definition as json:
172 * 'CL':
173 * support\_revocation: whether to request non-revocation credential \(optional, default false\)
174* __->__ `credDef`: Json - public part of temporary created credential definition
175
176Errors: `Common*`, `Wallet*`, `Anoncreds*`
177
178#### issuerRotateCredentialDefApply \( wh, credDefId \) -> void
179
180 Apply temporary keys as main for an existing Credential Definition (owned by the caller of the library).
181
182 **WARNING**: Rotating the credential definitional keys will result in making all credentials issued under the previous keys unverifiable.
183
184* `wh`: Handle (Number) - wallet handle (created by openWallet)
185* `credDefId`: String - an identifier of created credential definition stored in the wallet
186* __->__ void
187
188Errors: `Common*`, `Wallet*`, `Anoncreds*`
189
190#### issuerCreateAndStoreRevocReg \( wh, issuerDid, revocDefType, tag, credDefId, config, tailsWriterHandle \) -> \[ revocRegId, revocRegDef, revocRegEntry \]
191
192Create a new revocation registry for the given credential definition as tuple of entities
193- Revocation registry definition that encapsulates credentials definition reference, revocation type specific configuration and
194secrets used for credentials revocation
195- Revocation registry state that stores the information about revoked entities in a non-disclosing way. The state can be
196represented as ordered list of revocation registry entries were each entry represents the list of revocation or issuance operations.
197
198Revocation registry definition entity contains private and public parts. Private part will be stored in the wallet. Public part
199will be returned as json intended to be shared with all anoncreds workflow actors usually by publishing REVOC\_REG\_DEF transaction
200to Indy distributed ledger.
201
202Revocation registry state is stored on the wallet and also intended to be shared as the ordered list of REVOC\_REG\_ENTRY transactions.
203This call initializes the state in the wallet and returns the initial entry.
204
205Some revocation registry types \(for example, 'CL\_ACCUM'\) can require generation of binary blob called tails used to hide information about revoked credentials in public
206revocation registry and intended to be distributed out of leger \(REVOC\_REG\_DEF transaction will still contain uri and hash of tails\).
207This call requires access to pre-configured blob storage writer instance handle that will allow to write generated tails.
208
209* `wh`: Handle (Number) - wallet handle (created by openWallet)
210* `issuerDid`: String - a DID of the issuer signing transaction to the Ledger
211* `revocDefType`: String - revocation registry type \(optional, default value depends on credential definition type\). Supported types are:
212 * 'CL\_ACCUM': Type-3 pairing based accumulator implemented according to the algorithm in this paper:
213 https://github.com/hyperledger/ursa/blob/master/libursa/docs/AnonCred.pdf
214 This type is default for 'CL' credential definition type.
215* `tag`: String - allows to distinct between revocation registries for the same issuer and credential definition
216* `credDefId`: String - id of stored in ledger credential definition
217* `config`: Json - type-specific configuration of revocation registry as json:
218 * 'CL\_ACCUM':
219```
220{
221 "issuance_type": (optional) type of issuance. Currently supported:
222 1) ISSUANCE_BY_DEFAULT: all indices are assumed to be issued and initial accumulator is calculated over all indices;
223 Revocation Registry is updated only during revocation.
224 2) ISSUANCE_ON_DEMAND: nothing is issued initially accumulator is 1 (used by default);
225 "max_cred_num": maximum number of credentials the new registry can process (optional, default 100000)
226}
227````
228* `tailsWriterHandle`: Handle (Number) - handle of blob storage to store tails
229
230NOTE:
231Recursive creation of folder for Default Tails Writer (correspondent to `tailsWriterHandle`)
232in the system-wide temporary directory may fail in some setup due to permissions: `IO error: Permission denied`.
233In this case use `TMPDIR` environment variable to define temporary directory specific for an application.
234
235* __->__ [ `revocRegId`: String, `revocRegDef`: Json, `revocRegEntry`: Json ] - revoc\_reg\_id: identifier of created revocation registry definition
236revoc\_reg\_def\_json: public part of revocation registry definition
237revoc\_reg\_entry\_json: revocation registry entry that defines initial state of revocation registry
238
239Errors: `Common*`, `Wallet*`, `Anoncreds*`
240
241#### issuerCreateCredentialOffer \( wh, credDefId \) -> credOffer
242
243Create credential offer that will be used by Prover for
244credential request creation. Offer includes nonce and key correctness proof
245for authentication between protocol steps and integrity checking.
246
247* `wh`: Handle (Number) - wallet handle (created by openWallet)
248* `credDefId`: String - id of credential definition stored in the wallet
249* __->__ `credOffer`: Json - credential offer json:
250```
251 {
252 "schema_id": string,
253 "cred_def_id": string,
254 // Fields below can depend on Cred Def type
255 "nonce": string,
256 "key_correctness_proof" : key correctness proof for credential definition correspondent to cred_def_id
257 (opaque type that contains data structures internal to Ursa.
258 It should not be parsed and are likely to change in future versions).
259 }
260````
261
262Errors: `Common*`, `Wallet*`, `Anoncreds*`
263
264#### issuerCreateCredential \( wh, credOffer, credReq, credValues, revRegId, blobStorageReaderHandle \) -> \[ cred, credRevocId, revocRegDelta \]
265
266Check Cred Request for the given Cred Offer and issue Credential for the given Cred Request.
267
268Cred Request must match Cred Offer. The credential definition and revocation registry definition
269referenced in Cred Offer and Cred Request must be already created and stored into the wallet.
270
271Information for this credential revocation will be store in the wallet as part of revocation registry under
272generated cred\_revoc\_id local for this wallet.
273
274This call returns revoc registry delta as json file intended to be shared as REVOC\_REG\_ENTRY transaction.
275Note that it is possible to accumulate deltas to reduce ledger load.
276
277* `wh`: Handle (Number) - wallet handle (created by openWallet)
278* `credOffer`: Json - a cred offer created by issuerCreateCredentialOffer
279* `credReq`: Json - a credential request created by proverCreateCredentialReq
280* `credValues`: Json - a credential containing attribute values for each of requested attribute names.
281Example:
282```
283 {
284 "attr1" : {"raw": "value1", "encoded": "value1_as_int" },
285 "attr2" : {"raw": "value1", "encoded": "value1_as_int" }
286 }
287````
288 If you want to use empty value for some credential field, you should set "raw" to "" and "encoded" should not be empty
289* `revRegId`: String - id of revocation registry stored in the wallet
290* `blobStorageReaderHandle`: Handle (Number) - configuration of blob storage reader handle that will allow to read revocation tails
291* __->__ [ `cred`: Json, `credRevocId`: String, `revocRegDelta`: Json ] - cred\_json: Credential json containing signed credential values
292```
293 {
294 "schema_id": string,
295 "cred_def_id": string,
296 "rev_reg_def_id", Optional<string>,
297 "values": <see cred_values_json above>,
298 // Fields below can depend on Cred Def type
299 "signature": <credential signature>,
300 (opaque type that contains data structures internal to Ursa.
301 It should not be parsed and are likely to change in future versions).
302 "signature_correctness_proof": <signature_correctness_proof>
303 (opaque type that contains data structures internal to Ursa.
304 It should not be parsed and are likely to change in future versions).
305 }
306cred_revoc_id: local id for revocation info (Can be used for revocation of this credential)
307revoc_reg_delta_json: Revocation registry delta json with a newly issued credential
308````
309
310Errors: `Annoncreds*`, `Common*`, `Wallet*`
311
312#### issuerRevokeCredential \( wh, blobStorageReaderHandle, revRegId, credRevocId \) -&gt; revocRegDelta
313
314Revoke a credential identified by a cred\_revoc\_id \(returned by issuerCreateCredential\).
315
316The corresponding credential definition and revocation registry must be already
317created an stored into the wallet.
318
319This call returns revoc registry delta as json file intended to be shared as REVOC\_REG\_ENTRY transaction.
320Note that it is possible to accumulate deltas to reduce ledger load.
321
322* `wh`: Handle (Number) - wallet handle (created by openWallet)
323* `blobStorageReaderHandle`: Handle (Number)
324* `revRegId`: String - id of revocation registry stored in wallet
325* `credRevocId`: String - local id for revocation info
326* __->__ `revocRegDelta`: Json - revoc\_reg\_delta\_json: Revocation registry delta json with a revoked credential
327
328Errors: `Annoncreds*`, `Common*`, `Wallet*`
329
330#### issuerMergeRevocationRegistryDeltas \( revRegDelta, otherRevRegDelta \) -&gt; mergedRevRegDelta
331
332Merge two revocation registry deltas \(returned by issuerCreateCredential or issuerRevokeCredential\) to accumulate common delta.
333Send common delta to ledger to reduce the load.
334
335* `revRegDelta`: Json - revocation registry delta.
336* `otherRevRegDelta`: Json - revocation registry delta for which PrevAccum value is equal to current accum value of rev\_reg\_delta\_json.
337* __->__ `mergedRevRegDelta`: Json - merged\_rev\_reg\_delta: Merged revocation registry delta
338
339Errors: `Annoncreds*`, `Common*`, `Wallet*`
340
341#### proverCreateMasterSecret \( wh, masterSecretId \) -&gt; outMasterSecretId
342
343Creates a master secret with a given id and stores it in the wallet.
344The id must be unique.
345
346* `wh`: Handle (Number) - wallet handle (created by openWallet)
347* `masterSecretId`: String - \(optional, if not present random one will be generated\) new master id
348* __->__ `outMasterSecretId`: String - out\_master\_secret\_id: Id of generated master secret
349
350Errors: `Annoncreds*`, `Common*`, `Wallet*`
351
352#### proverCreateCredentialReq \( wh, proverDid, credOffer, credDef, masterSecretId \) -&gt; \[ credReq, credReqMetadata \]
353
354Creates a credential request for the given credential offer.
355
356The method creates a blinded master secret for a master secret identified by a provided name.
357The master secret identified by the name must be already stored in the secure wallet \(see prover\_create\_master\_secret\)
358The blinded master secret is a part of the credential request.
359
360* `wh`: Handle (Number) - wallet handle (created by openWallet)
361* `proverDid`: String - a DID of the prover
362* `credOffer`: Json - credential offer as a json containing information about the issuer and a credential
363* `credDef`: Json - credential definition json related to &lt;cred\_def\_id&gt; in &lt;cred\_offer\_json&gt;
364* `masterSecretId`: String - the id of the master secret stored in the wallet
365* __->__ [ `credReq`: Json, `credReqMetadata`: Json ] - cred\_req\_json: Credential request json for creation of credential by Issuer
366```
367 {
368 "prover_did" : string,
369 "cred_def_id" : string,
370 // Fields below can depend on Cred Def type
371 "blinded_ms" : <blinded_master_secret>,
372 (opaque type that contains data structures internal to Ursa.
373 It should not be parsed and are likely to change in future versions).
374 "blinded_ms_correctness_proof" : <blinded_ms_correctness_proof>,
375 (opaque type that contains data structures internal to Ursa.
376 It should not be parsed and are likely to change in future versions).
377 "nonce": string
378 }
379cred_req_metadata_json: Credential request metadata json for further processing of received form Issuer credential.
380 Note: cred_req_metadata_json mustn't be shared with Issuer.
381````
382
383Errors: `Annoncreds*`, `Common*`, `Wallet*`
384
385#### proverStoreCredential \( wh, credId, credReqMetadata, cred, credDef, revRegDef \) -&gt; outCredId
386
387Check credential provided by Issuer for the given credential request,
388updates the credential by a master secret and stores in a secure wallet.
389
390To support efficient and flexible search the following tags will be created for stored credential:
391```
392 {
393 "schema_id": <credential schema id>,
394 "schema_issuer_did": <credential schema issuer did>,
395 "schema_name": <credential schema name>,
396 "schema_version": <credential schema version>,
397 "issuer_did": <credential issuer did>,
398 "cred_def_id": <credential definition id>,
399 "rev_reg_id": <credential revocation registry id>, // "None" as string if not present
400 // for every attribute in <credential values>
401 "attr::<attribute name>::marker": "1",
402 "attr::<attribute name>::value": <attribute raw value>,
403 }
404````
405
406* `wh`: Handle (Number) - wallet handle (created by openWallet)
407* `credId`: String - \(optional, default is a random one\) identifier by which credential will be stored in the wallet
408* `credReqMetadata`: Json - a credential request metadata created by proverCreateCredentialReq
409* `cred`: Json - credential json received from issuer
410* `credDef`: Json - credential definition json related to &lt;cred\_def\_id&gt; in &lt;cred\_json&gt;
411* `revRegDef`: Json - revocation registry definition json related to &lt;rev\_reg\_def\_id&gt; in &lt;cred\_json&gt;
412* __->__ `outCredId`: String - out\_cred\_id: identifier by which credential is stored in the wallet
413
414Errors: `Annoncreds*`, `Common*`, `Wallet*`
415
416#### proverGetCredentials \( wh, filter \) -&gt; credentials
417
418Gets human readable credentials according to the filter.
419If filter is NULL, then all credentials are returned.
420Credentials can be filtered by Issuer, credential\_def and\/or Schema.
421
422NOTE: This method is deprecated because immediately returns all fetched credentials.
423Use &lt;proverSearchCredentials&gt; to fetch records by small batches.
424
425* `wh`: Handle (Number) - wallet handle (created by openWallet)
426* `filter`: Json - filter for credentials
427```
428 {
429 "schema_id": string, (Optional)
430 "schema_issuer_did": string, (Optional)
431 "schema_name": string, (Optional)
432 "schema_version": string, (Optional)
433 "issuer_did": string, (Optional)
434 "cred_def_id": string, (Optional)
435 }
436````
437* __->__ `credentials`: Json - credentials json
438```
439 [{
440 "referent": string, // cred_id in the wallet
441 "attrs": {"key1":"raw_value1", "key2":"raw_value2"},
442 "schema_id": string,
443 "cred_def_id": string,
444 "rev_reg_id": Optional<string>,
445 "cred_rev_id": Optional<string>
446 }]
447````
448
449Errors: `Annoncreds*`, `Common*`, `Wallet*`
450
451#### proverGetCredential \( wh, credId \) -&gt; credential
452
453Gets human readable credential by the given id.
454
455* `wh`: Handle (Number) - wallet handle (created by openWallet)
456* `credId`: String - Identifier by which requested credential is stored in the wallet
457* __->__ `credential`: Json - credential json:
458```
459 {
460 "referent": string, // cred_id in the wallet
461 "attrs": {"key1":"raw_value1", "key2":"raw_value2"},
462 "schema_id": string,
463 "cred_def_id": string,
464 "rev_reg_id": Optional<string>,
465 "cred_rev_id": Optional<string>
466 }
467````
468
469Errors: `Annoncreds*`, `Common*`, `Wallet*`
470
471#### proverSearchCredentials \( wh, query \) -&gt; \[ sh, totalCount \]
472
473Search for credentials stored in wallet.
474Credentials can be filtered by tags created during saving of credential.
475
476Instead of immediately returning of fetched credentials
477this call returns search\_handle that can be used later
478to fetch records by small batches \(with proverFetchCredentials\).
479
480* `wh`: Handle (Number) - wallet handle (created by openWallet)
481* `query`: Json - Wql query filter for credentials searching based on tags.
482where query: indy-sdk\/doc\/design\/011-wallet-query-language\/README.md
483* __->__ [ `sh`: Handle (Number), `totalCount`: Number ] - search\_handle: Search handle that can be used later to fetch records by small batches \(with proverFetchCredentials\)
484total\_count: Total count of records
485
486Errors: `Annoncreds*`, `Common*`, `Wallet*`
487
488#### proverFetchCredentials \( sh, count \) -&gt; credentials
489
490Fetch next credentials for search.
491
492* `sh`: Handle (Number) - Search handle \(created by proverSearchCredentials\)
493* `count`: Number - Count of credentials to fetch
494* __->__ `credentials`: Json - credentials\_json: List of human readable credentials:
495```
496 [{
497 "referent": string, // cred_id in the wallet
498 "attrs": {"key1":"raw_value1", "key2":"raw_value2"},
499 "schema_id": string,
500 "cred_def_id": string,
501 "rev_reg_id": Optional<string>,
502 "cred_rev_id": Optional<string>
503 }]
504NOTE: The list of length less than the requested count means credentials search iterator is completed.
505````
506
507Errors: `Annoncreds*`, `Common*`, `Wallet*`
508
509#### proverCloseCredentialsSearch \( sh \) -&gt; void
510
511Close credentials search \(make search handle invalid\)
512
513* `sh`: Handle (Number) - Search handle \(created by proverSearchCredentials\)
514* __->__ void
515
516Errors: `Annoncreds*`, `Common*`, `Wallet*`
517
518#### proverGetCredentialsForProofReq \( wh, proofRequest \) -&gt; credentials
519
520Gets human readable credentials matching the given proof request.
521
522NOTE: This method is deprecated because immediately returns all fetched credentials.
523Use &lt;proverSearchCredentialsForProofReq&gt; to fetch records by small batches.
524
525* `wh`: Handle (Number) - wallet handle (created by openWallet)
526* `proofRequest`: Json - proof request json
527```
528 {
529 "name": string,
530 "version": string,
531 "nonce": string, - a decimal number represented as a string (use `generateNonce` function to generate 80-bit number)
532 "requested_attributes": { // set of requested attributes
533 "<attr_referent>": <attr_info>, // see below
534 ...,
535 },
536 "requested_predicates": { // set of requested predicates
537 "<predicate_referent>": <predicate_info>, // see below
538 ...,
539 },
540 "non_revoked": Optional<<non_revoc_interval>>, // see below,
541 // If specified prover must proof non-revocation
542 // for date in this interval for each attribute
543 // (can be overridden on attribute level)
544 "ver": Optional<str> - proof request version:
545 - omit to use unqualified identifiers for restrictions
546 - "1.0" to use unqualified identifiers for restrictions
547 - "2.0" to use fully qualified identifiers for restrictions
548 }
549where:
550 attr_info: Describes requested attribute
551 {
552 "name": Optional<string>, // attribute name, (case insensitive and ignore spaces)
553 "names": Optional<[string, string]>, // attribute names, (case insensitive and ignore spaces)
554 // NOTE: should either be "name" or "names", not both and not none of them.
555 // Use "names" to specify several attributes that have to match a single credential.
556 "restrictions": Optional<wql query>, // see below
557 "non_revoked": Optional<<non_revoc_interval>>, // see below,
558 // If specified prover must proof non-revocation
559 // for date in this interval this attribute
560 // (overrides proof level interval)
561 }
562 predicate_referent: Proof-request local identifier of requested attribute predicate
563 predicate_info: Describes requested attribute predicate
564 {
565 "name": attribute name, (case insensitive and ignore spaces)
566 "p_type": predicate type (">=", ">", "<=", "<")
567 "p_value": predicate value
568 "restrictions": Optional<wql query>, // see below
569 "non_revoked": Optional<<non_revoc_interval>>, // see below,
570 // If specified prover must proof non-revocation
571 // for date in this interval this attribute
572 // (overrides proof level interval)
573 }
574 non_revoc_interval: Defines non-revocation interval
575 {
576 "from": Optional<int>, // timestamp of interval beginning
577 "to": Optional<int>, // timestamp of interval ending
578 }
579````
580* __->__ `credentials`: Json - credentials\_json: json with credentials for the given proof request.
581```
582 {
583 "requested_attrs": {
584 "<attr_referent>": [{ cred_info: <credential_info>, interval: Optional<non_revoc_interval> }],
585 ...,
586 },
587 "requested_predicates": {
588 "requested_predicates": [{ cred_info: <credential_info>, timestamp: Optional<integer> }, { cred_info: <credential_2_info>, timestamp: Optional<integer> }],
589 "requested_predicate_2_referent": [{ cred_info: <credential_2_info>, timestamp: Optional<integer> }]
590 }
591 }, where credential is
592 {
593 "referent": <string>,
594 "attrs": {"attr_name" : "attr_raw_value"},
595 "schema_id": string,
596 "cred_def_id": string,
597 "rev_reg_id": Optional<int>,
598 "cred_rev_id": Optional<int>,
599 }
600````
601
602Errors: `Annoncreds*`, `Common*`, `Wallet*`
603
604#### proverSearchCredentialsForProofReq \( wh, proofRequest, extraQuery \) -&gt; sh
605
606Search for credentials matching the given proof request.
607
608Instead of immediately returning of fetched credentials
609this call returns search\_handle that can be used later
610to fetch records by small batches \(with proverFetchCredentialsForProofReq\).
611
612* `wh`: Handle (Number) - wallet handle (created by openWallet)
613* `proofRequest`: Json - proof request json
614```
615 {
616 "name": string,
617 "version": string,
618 "nonce": string, - a decimal number represented as a string (use `generateNonce` function to generate 80-bit number)
619 "requested_attributes": { // set of requested attributes
620 "<attr_referent>": <attr_info>, // see below
621 ...,
622 },
623 "requested_predicates": { // set of requested predicates
624 "<predicate_referent>": <predicate_info>, // see below
625 ...,
626 },
627 "non_revoked": Optional<<non_revoc_interval>>, // see below,
628 // If specified prover must proof non-revocation
629 // for date in this interval for each attribute
630 // (can be overridden on attribute level)
631 "ver": Optional<str> - proof request version:
632 - omit to use unqualified identifiers for restrictions
633 - "1.0" to use unqualified identifiers for restrictions
634 - "2.0" to use fully qualified identifiers for restrictions
635 }
636where:
637 attr_info: Describes requested attribute
638 {
639 "name": Optional<string>, // attribute name, (case insensitive and ignore spaces)
640 "names": Optional<[string, string]>, // attribute names, (case insensitive and ignore spaces)
641 // NOTE: should either be "name" or "names", not both and not none of them.
642 // Use "names" to specify several attributes that have to match a single credential.
643 "restrictions": Optional<wql query>, // see below
644 "non_revoked": Optional<<non_revoc_interval>>, // see below,
645 // If specified prover must proof non-revocation
646 // for date in this interval this attribute
647 // (overrides proof level interval)
648 }
649 predicate_referent: Proof-request local identifier of requested attribute predicate
650 predicate_info: Describes requested attribute predicate
651 {
652 "name": attribute name, (case insensitive and ignore spaces)
653 "p_type": predicate type (">=", ">", "<=", "<")
654 "p_value": predicate value
655 "restrictions": Optional<wql query>, // see below
656 "non_revoked": Optional<<non_revoc_interval>>, // see below,
657 // If specified prover must proof non-revocation
658 // for date in this interval this attribute
659 // (overrides proof level interval)
660 }
661 non_revoc_interval: Defines non-revocation interval
662 {
663 "from": Optional<int>, // timestamp of interval beginning
664 "to": Optional<int>, // timestamp of interval ending
665 }
666````
667* `extraQuery`: Json - \(Optional\) List of extra queries that will be applied to correspondent attribute\/predicate:
668```
669 {
670 "<attr_referent>": <wql query>,
671 "<predicate_referent>": <wql query>,
672 }
673where wql query: indy-sdk/docs/design/011-wallet-query-language/README.md
674````
675* __->__ `sh`: Handle (Number) - search\_handle: Search handle that can be used later to fetch records by small batches \(with proverFetchCredentialsForProofReq\)
676
677Errors: `Annoncreds*`, `Common*`, `Wallet*`
678
679#### proverFetchCredentialsForProofReq \( sh, itemReferent, count \) -&gt; credentials
680
681Fetch next credentials for the requested item using proof request search
682handle \(created by proverSearchCredentialsForProofReq\).
683
684* `sh`: Handle (Number) - Search handle \(created by proverSearchCredentialsForProofReq\)
685* `itemReferent`: String - Referent of attribute\/predicate in the proof request
686* `count`: Number - Count of credentials to fetch
687* __->__ `credentials`: Json - credentials\_json: List of credentials for the given proof request.
688```
689 [{
690 cred_info: <credential_info>,
691 interval: Optional<non_revoc_interval>
692 }]
693where
694credential_info:
695 {
696 "referent": <string>,
697 "attrs": {"attr_name" : "attr_raw_value"},
698 "schema_id": string,
699 "cred_def_id": string,
700 "rev_reg_id": Optional<int>,
701 "cred_rev_id": Optional<int>,
702 }
703non_revoc_interval:
704 {
705 "from": Optional<int>, // timestamp of interval beginning
706 "to": Optional<int>, // timestamp of interval ending
707 }
708NOTE: The list of length less than the requested count means that search iterator
709correspondent to the requested <item_referent> is completed.
710````
711
712Errors: `Annoncreds*`, `Common*`, `Wallet*`
713
714#### proverCloseCredentialsSearchForProofReq \( sh \) -&gt; void
715
716Close credentials search for proof request \(make search handle invalid\)
717
718* `sh`: Handle (Number) - Search handle \(created by proverSearchCredentialsForProofReq\)
719* __->__ void
720
721Errors: `Annoncreds*`, `Common*`, `Wallet*`
722
723#### proverCreateProof \( wh, proofReq, requestedCredentials, masterSecretName, schemas, credentialDefs, revStates \) -&gt; proof
724
725Creates a proof according to the given proof request
726Either a corresponding credential with optionally revealed attributes or self-attested attribute must be provided
727for each requested attribute \(see proverGetCredentials\_for\_pool\_req\).
728A proof request may request multiple credentials from different schemas and different issuers.
729All required schemas, public keys and revocation registries must be provided.
730The proof request also contains nonce.
731The proof contains either proof or self-attested attribute value for each requested attribute.
732
733* `wh`: Handle (Number) - wallet handle (created by openWallet)
734* `proofReq`: Json - proof request json
735```
736 {
737 "name": string,
738 "version": string,
739 "nonce": string, - a decimal number represented as a string (use `generateNonce` function to generate 80-bit number)
740 "requested_attributes": { // set of requested attributes
741 "<attr_referent>": <attr_info>, // see below
742 ...,
743 },
744 "requested_predicates": { // set of requested predicates
745 "<predicate_referent>": <predicate_info>, // see below
746 ...,
747 },
748 "non_revoked": Optional<<non_revoc_interval>>, // see below,
749 // If specified prover must proof non-revocation
750 // for date in this interval for each attribute
751 // (can be overridden on attribute level)
752 "ver": Optional<str> - proof request version:
753 - omit to use unqualified identifiers for restrictions
754 - "1.0" to use unqualified identifiers for restrictions
755 - "2.0" to use fully qualified identifiers for restrictions
756 }
757where:
758 attr_info: Describes requested attribute
759 {
760 "name": Optional<string>, // attribute name, (case insensitive and ignore spaces)
761 "names": Optional<[string, string]>, // attribute names, (case insensitive and ignore spaces)
762 // NOTE: should either be "name" or "names", not both and not none of them.
763 // Use "names" to specify several attributes that have to match a single credential.
764 "restrictions": Optional<wql query>, // see below
765 "non_revoked": Optional<<non_revoc_interval>>, // see below,
766 // If specified prover must proof non-revocation
767 // for date in this interval this attribute
768 // (overrides proof level interval)
769 }
770 predicate_referent: Proof-request local identifier of requested attribute predicate
771 predicate_info: Describes requested attribute predicate
772 {
773 "name": attribute name, (case insensitive and ignore spaces)
774 "p_type": predicate type (">=", ">", "<=", "<")
775 "p_value": predicate value
776 "restrictions": Optional<wql query>, // see below
777 "non_revoked": Optional<<non_revoc_interval>>, // see below,
778 // If specified prover must proof non-revocation
779 // for date in this interval this attribute
780 // (overrides proof level interval)
781 }
782 non_revoc_interval: Defines non-revocation interval
783 {
784 "from": Optional<int>, // timestamp of interval beginning
785 "to": Optional<int>, // timestamp of interval ending
786 }
787````
788* `requestedCredentials`: Json - either a credential or self-attested attribute for each requested attribute
789```
790 {
791 "self_attested_attributes": {
792 "self_attested_attribute_referent": string
793 },
794 "requested_attributes": {
795 "requested_attribute_referent_1": {"cred_id": string, "timestamp": Optional<number>, revealed: <bool> }},
796 "requested_attribute_referent_2": {"cred_id": string, "timestamp": Optional<number>, revealed: <bool> }}
797 },
798 "requested_predicates": {
799 "requested_predicates_referent_1": {"cred_id": string, "timestamp": Optional<number> }},
800 }
801 }
802````
803* `masterSecretName`: String
804* `schemas`: Json - all schemas json participating in the proof request
805```
806 {
807 <schema1_id>: <schema1_json>,
808 <schema2_id>: <schema2_json>,
809 <schema3_id>: <schema3_json>,
810 }
811````
812* `credentialDefs`: Json - all credential definitions json participating in the proof request
813```
814 {
815 "cred_def1_id": <credential_def1_json>,
816 "cred_def2_id": <credential_def2_json>,
817 "cred_def3_id": <credential_def3_json>,
818 }
819````
820* `revStates`: Json - all revocation states json participating in the proof request
821```
822 {
823 "rev_reg_def1_id or credential_1_id"": {
824 "timestamp1": <rev_state1>,
825 "timestamp2": <rev_state2>,
826 },
827 "rev_reg_def2_id or credential_2_id"": {
828 "timestamp3": <rev_state3>
829 },
830 "rev_reg_def3_id or credential_3_id"": {
831 "timestamp4": <rev_state4>
832 },
833 } - Note: use credential_id instead rev_reg_id in case proving several credentials from the same revocation registry.
834where
835where wql query: indy-sdk/docs/design/011-wallet-query-language/README.md
836````
837* __->__ `proof`: Json - Proof json
838For each requested attribute either a proof \(with optionally revealed attribute value\) or
839self-attested attribute value is provided.
840Each proof is associated with a credential and corresponding schema\_id, cred\_def\_id, rev\_reg\_id and timestamp.
841There is also aggregated proof part common for all credential proofs.
842```
843 {
844 "requested_proof": {
845 "revealed_attrs": {
846 "requested_attr1_id": {sub_proof_index: number, raw: string, encoded: string},
847 "requested_attr4_id": {sub_proof_index: number: string, encoded: string},
848 },
849 "revealed_attr_groups": {
850 "requested_attr5_id": {
851 "sub_proof_index": number,
852 "values": {
853 "attribute_name": {
854 "raw": string,
855 "encoded": string
856 }
857 },
858 }
859 },
860 "unrevealed_attrs": {
861 "requested_attr3_id": {sub_proof_index: number}
862 },
863 "self_attested_attrs": {
864 "requested_attr2_id": self_attested_value,
865 },
866 "requested_predicates": {
867 "requested_predicate_1_referent": {sub_proof_index: int},
868 "requested_predicate_2_referent": {sub_proof_index: int},
869 }
870 }
871 "proof": {
872 "proofs": [ <credential_proof>, <credential_proof>, <credential_proof> ],
873 "aggregated_proof": <aggregated_proof>
874 } (opaque type that contains data structures internal to Ursa.
875 It should not be parsed and are likely to change in future versions).
876 "identifiers": [{schema_id, cred_def_id, Optional<rev_reg_id>, Optional<timestamp>}]
877 }
878````
879
880Errors: `Annoncreds*`, `Common*`, `Wallet*`
881
882#### verifierVerifyProof \( proofRequest, proof, schemas, credentialDefsJsons, revRegDefs, revRegs \) -&gt; valid
883
884Verifies a proof \(of multiple credential\).
885All required schemas, public keys and revocation registries must be provided.
886
887IMPORTANT: You must use *_id's (`schema_id`, `cred_def_id`, `rev_reg_id`) listed in `proof[identifiers]`
888as the keys for corresponding `schemas`, `credentialDefsJsons`, `revRegDefs`, `revRegs` objects.
889
890* `proofRequest`: Json - proof request json
891```
892 {
893 "name": string,
894 "version": string,
895 "nonce": string, - a decimal number represented as a string (use `generateNonce` function to generate 80-bit number)
896 "requested_attributes": { // set of requested attributes
897 "<attr_referent>": <attr_info>, // see below
898 ...,
899 },
900 "requested_predicates": { // set of requested predicates
901 "<predicate_referent>": <predicate_info>, // see below
902 ...,
903 },
904 "non_revoked": Optional<<non_revoc_interval>>, // see below,
905 // If specified prover must proof non-revocation
906 // for date in this interval for each attribute
907 // (can be overridden on attribute level)
908 "ver": Optional<str> - proof request version:
909 - omit to use unqualified identifiers for restrictions
910 - "1.0" to use unqualified identifiers for restrictions
911 - "2.0" to use fully qualified identifiers for restrictions
912 }
913````
914* `proof`: Json - created for request proof json
915```
916 {
917 "requested_proof": {
918 "revealed_attrs": {
919 "requested_attr1_id": {sub_proof_index: number, raw: string, encoded: string}, // NOTE: check that `encoded` value match to `raw` value on application level
920 "requested_attr4_id": {sub_proof_index: number: string, encoded: string}, // NOTE: check that `encoded` value match to `raw` value on application level
921 },
922 "revealed_attr_groups": {
923 "requested_attr5_id": {
924 "sub_proof_index": number,
925 "values": {
926 "attribute_name": {
927 "raw": string,
928 "encoded": string
929 }
930 }, // NOTE: check that `encoded` value match to `raw` value on application level
931 }
932 },
933 "unrevealed_attrs": {
934 "requested_attr3_id": {sub_proof_index: number}
935 },
936 "self_attested_attrs": {
937 "requested_attr2_id": self_attested_value,
938 },
939 "requested_predicates": {
940 "requested_predicate_1_referent": {sub_proof_index: int},
941 "requested_predicate_2_referent": {sub_proof_index: int},
942 }
943 }
944 "proof": {
945 "proofs": [ <credential_proof>, <credential_proof>, <credential_proof> ],
946 "aggregated_proof": <aggregated_proof>
947 }
948 "identifiers": [{schema_id, cred_def_id, Optional<rev_reg_id>, Optional<timestamp>}]
949 }
950````
951* `schemas`: Json - all schema jsons participating in the proof
952```
953 {
954 <schema1_id>: <schema1_json>,
955 <schema2_id>: <schema2_json>,
956 <schema3_id>: <schema3_json>,
957 }
958````
959* `credentialDefsJsons`: Json
960* `revRegDefs`: Json - all revocation registry definitions json participating in the proof
961```
962 {
963 "rev_reg_def1_id": <rev_reg_def1_json>,
964 "rev_reg_def2_id": <rev_reg_def2_json>,
965 "rev_reg_def3_id": <rev_reg_def3_json>,
966 }
967````
968* `revRegs`: Json - all revocation registries json participating in the proof
969```
970 {
971 "rev_reg_def1_id": {
972 "timestamp1": <rev_reg1>,
973 "timestamp2": <rev_reg2>,
974 },
975 "rev_reg_def2_id": {
976 "timestamp3": <rev_reg3>
977 },
978 "rev_reg_def3_id": {
979 "timestamp4": <rev_reg4>
980 },
981 }
982````
983* __->__ `valid`: Boolean - valid: true - if signature is valid, false - otherwise
984
985Errors: `Annoncreds*`, `Common*`, `Wallet*`
986
987#### createRevocationState \( blobStorageReaderHandle, revRegDef, revRegDelta, timestamp, credRevId \) -&gt; revState
988
989Create revocation state for a credential that corresponds to a particular time.
990
991Note that revocation delta must cover the whole registry existence time.
992You can use `from`: `0` and `to`: `needed_time` as parameters for building request to get correct revocation delta.
993
994The resulting revocation state and provided timestamp can be saved and reused later with applying a new
995revocation delta with `updateRevocationState` function.
996This new delta should be received with parameters: `from`: `timestamp` and `to`: `needed_time`.
997
998* `blobStorageReaderHandle`: Handle (Number) - configuration of blob storage reader handle that will allow to read revocation tails
999* `revRegDef`: Json - revocation registry definition json
1000* `revRegDelta`: Json - revocation registry delta which covers the whole registry existence time
1001* `timestamp`: Timestamp (Number) - time represented as a total number of seconds from Unix Epoch
1002* `credRevId`: String - user credential revocation id in revocation registry
1003* __->__ `revState`: Json - revocation state json:
1004```
1005 {
1006 "rev_reg": <revocation registry>,
1007 "witness": <witness>,
1008 "timestamp" : integer
1009 }
1010````
1011
1012Errors: `Common*`, `Wallet*`, `Anoncreds*`
1013
1014#### updateRevocationState \( blobStorageReaderHandle, revState, revRegDef, revRegDelta, timestamp, credRevId \) -&gt; updatedRevState
1015
1016 Create a new revocation state for a credential based on a revocation state created before.
1017 Note that provided revocation delta must cover the registry gap from based state creation until the specified time
1018 (this new delta should be received with parameters: `from`: `state_timestamp` and `to`: `needed_time`).
1019
1020 This function reduces the calculation time.
1021
1022 The resulting revocation state and provided timestamp can be saved and reused later by applying a new revocation delta again.
1023
1024* `blobStorageReaderHandle`: Handle (Number) - configuration of blob storage reader handle that will allow to read revocation tails
1025* `revState`: Json - revocation registry state json
1026* `revRegDef`: Json - revocation registry definition json
1027* `revRegDelta`: Json - revocation registry definition delta which covers the gap form original `rev_state_json` creation till the requested timestamp
1028* `timestamp`: Timestamp (Number) - time represented as a total number of seconds from Unix Epoch
1029* `credRevId`: String - user credential revocation id in revocation registry
1030* __->__ `updatedRevState`: Json - revocation state json:
1031```
1032 {
1033 "rev_reg": <revocation registry>,
1034 "witness": <witness>,
1035 "timestamp" : integer
1036 }
1037````
1038
1039Errors: `Common*`, `Wallet*`, `Anoncreds*`
1040
1041#### generateNonce \( \) -&gt; nonce
1042
1043Generates 80-bit numbers that can be used as a nonce for proof request.
1044
1045* __->__ `nonce`: Json - generated number as a string
1046
1047Errors: `Common*`
1048
1049#### toUnqualified \( entity \) -&gt; res
1050
1051Get unqualified form (short form without method) of a fully qualified entity like DID.
1052
1053This function should be used to the proper casting of fully qualified entity to unqualified form in the following cases:
10541) Issuer, which works with fully qualified identifiers, creates a Credential Offer for Prover, which doesn't support fully qualified identifiers.
10552) Verifier prepares a Proof Request based on fully qualified identifiers or Prover, which doesn't support fully qualified identifiers.
10563) another case when casting to unqualified form needed
1057
1058* `entity`: String - target entity to disqualify. Can be one of: Did, SchemaId, CredentialDefinitionId, RevocationRegistryId, Schema, CredentialDefinition, RevocationRegistryDefinition, CredentialOffer, CredentialRequest, ProofRequest.
1059* __->__ `res`: Json - entity either in unqualified form or original if casting isn't possible
1060
1061### blob_storage
1062
1063#### openBlobStorageReader \( type, config \) -&gt; handle
1064
1065
1066
1067* `type`: String
1068* `config`: Json
1069* __->__ `handle`: Handle (Number)
1070
1071
1072#### openBlobStorageWriter \( type, config \) -&gt; handle
1073
1074
1075
1076* `type`: String
1077* `config`: Json
1078* __->__ `handle`: Handle (Number)
1079
1080
1081### crypto
1082
1083#### createKey \( wh, key \) -&gt; vk
1084
1085Creates keys pair and stores in the wallet.
1086
1087* `wh`: Handle (Number) - wallet handle (created by openWallet)
1088* `key`: Json - Key information as json. Example:
1089```
1090{
1091 "seed": string, (optional) Seed that allows deterministic key creation (if not set random one will be created).
1092 Can be UTF-8, base64 or hex string.
1093 "crypto_type": string, // Optional (if not set then ed25519 curve is used); Currently only 'ed25519' value is supported for this field.
1094}
1095````
1096* __->__ `vk`: String - Ver key of generated key pair, also used as key identifier
1097
1098Errors: `Common*`, `Wallet*`, `Crypto*`
1099
1100#### setKeyMetadata \( wh, verkey, metadata \) -&gt; void
1101
1102Saves\/replaces the meta information for the giving key in the wallet.
1103
1104* `wh`: Handle (Number) - wallet handle (created by openWallet)
1105* `verkey`: String
1106* `metadata`: String
1107* __->__ void
1108
1109Errors: `Common*`, `Wallet*`, `Crypto*`
1110
1111#### getKeyMetadata \( wh, verkey \) -&gt; metadata
1112
1113Retrieves the meta information for the giving key in the wallet.
1114
1115* `wh`: Handle (Number) - wallet handle (created by openWallet)
1116* `verkey`: String
1117* __->__ `metadata`: String - The meta information stored with the key; Can be null if no metadata was saved for this key.
1118
1119Errors: `Common*`, `Wallet*`, `Crypto*`
1120
1121#### cryptoSign \( wh, signerVk, messageRaw \) -&gt; signatureRaw
1122
1123Signs a message with a key.
1124
1125Note to use DID keys with this function you can call keyForDid to get key id \(verkey\)
1126for specific DID.
1127
1128* `wh`: Handle (Number) - wallet handle (created by openWallet)
1129* `signerVk`: String - id \(verkey\) of message signer. The key must be created by calling createKey or createAndStoreMyDid
1130* `messageRaw`: Buffer - a pointer to first byte of message to be signed
1131* __->__ `signatureRaw`: Buffer - a signature string
1132
1133Errors: `Common*`, `Wallet*`, `Crypto*`
1134
1135#### cryptoVerify \( signerVk, messageRaw, signatureRaw \) -&gt; valid
1136
1137Verify a signature with a verkey.
1138
1139Note to use DID keys with this function you can call keyForDid to get key id \(verkey\)
1140for specific DID.
1141
1142* `signerVk`: String - verkey of the message signer
1143* `messageRaw`: Buffer - a pointer to first byte of message that has been signed
1144* `signatureRaw`: Buffer - a pointer to first byte of signature to be verified
1145* __->__ `valid`: Boolean - valid: true - if signature is valid, false - otherwise
1146
1147Errors: `Common*`, `Wallet*`, `Ledger*`, `Crypto*`
1148
1149#### cryptoAuthCrypt \( wh, senderVk, recipientVk, messageRaw \) -&gt; encryptedMsgRaw
1150
1151 **** THIS FUNCTION WILL BE DEPRECATED USE packMessage INSTEAD ****
1152
1153Encrypt a message by authenticated-encryption scheme.
1154
1155Sender can encrypt a confidential message specifically for Recipient, using Sender's public key.
1156Using Recipient's public key, Sender can compute a shared secret key.
1157Using Sender's public key and his secret key, Recipient can compute the exact same shared secret key.
1158That shared secret key can be used to verify that the encrypted message was not tampered with,
1159before eventually decrypting it.
1160
1161Note to use DID keys with this function you can call keyForDid to get key id \(verkey\)
1162for specific DID.
1163
1164* `wh`: Handle (Number) - wallet handle (created by openWallet)
1165* `senderVk`: String - id \(verkey\) of message sender. The key must be created by calling createKey or createAndStoreMyDid
1166* `recipientVk`: String - id \(verkey\) of message recipient
1167* `messageRaw`: Buffer - a pointer to first byte of message that to be encrypted
1168* __->__ `encryptedMsgRaw`: Buffer - an encrypted message as a pointer to array of bytes.
1169
1170Errors: `Common*`, `Wallet*`, `Ledger*`, `Crypto*`
1171
1172#### cryptoAuthDecrypt \( wh, recipientVk, encryptedMsgRaw \) -&gt; \[ senderVk, decryptedMsgRaw \]
1173
1174 **** THIS FUNCTION WILL BE DEPRECATED USE unpackMessage INSTEAD ****
1175
1176Decrypt a message by authenticated-encryption scheme.
1177
1178Sender can encrypt a confidential message specifically for Recipient, using Sender's public key.
1179Using Recipient's public key, Sender can compute a shared secret key.
1180Using Sender's public key and his secret key, Recipient can compute the exact same shared secret key.
1181That shared secret key can be used to verify that the encrypted message was not tampered with,
1182before eventually decrypting it.
1183
1184Note to use DID keys with this function you can call keyForDid to get key id \(verkey\)
1185for specific DID.
1186
1187* `wh`: Handle (Number) - wallet handle (created by openWallet)
1188* `recipientVk`: String - id \(verkey\) of message recipient. The key must be created by calling createKey or createAndStoreMyDid
1189* `encryptedMsgRaw`: Buffer - a pointer to first byte of message that to be decrypted
1190* __->__ [ `senderVk`: String, `decryptedMsgRaw`: Buffer ] - sender verkey and decrypted message as a pointer to array of bytes
1191
1192Errors: `Common*`, `Wallet*`, `Crypto*`
1193
1194#### cryptoAnonCrypt \( recipientVk, messageRaw \) -&gt; encryptedMsgRaw
1195
1196Encrypts a message by anonymous-encryption scheme.
1197
1198Sealed boxes are designed to anonymously send messages to a Recipient given its public key.
1199Only the Recipient can decrypt these messages, using its private key.
1200While the Recipient can verify the integrity of the message, it cannot verify the identity of the Sender.
1201
1202Note to use DID keys with this function you can call keyForDid to get key id \(verkey\)
1203for specific DID.
1204
1205Note: use packMessage function for A2A goals.
1206
1207* `recipientVk`: String - verkey of message recipient
1208* `messageRaw`: Buffer - a pointer to first byte of message that to be encrypted
1209* __->__ `encryptedMsgRaw`: Buffer - an encrypted message as a pointer to array of bytes
1210
1211Errors: `Common*`, `Wallet*`, `Ledger*`, `Crypto*`
1212
1213#### cryptoAnonDecrypt \( wh, recipientVk, encryptedMsg \) -&gt; decryptedMsgRaw
1214
1215Decrypts a message by anonymous-encryption scheme.
1216
1217Sealed boxes are designed to anonymously send messages to a Recipient given its public key.
1218Only the Recipient can decrypt these messages, using its private key.
1219While the Recipient can verify the integrity of the message, it cannot verify the identity of the Sender.
1220
1221Note to use DID keys with this function you can call keyForDid to get key id \(verkey\)
1222for specific DID.
1223
1224Note: use unpackMessage function for A2A goals.
1225
1226* `wh`: Handle (Number) - wallet handle (created by openWallet)
1227* `recipientVk`: String - id \(verkey\) of my key. The key must be created by calling createKey or createAndStoreMyDid
1228* `encryptedMsg`: Buffer
1229* __->__ `decryptedMsgRaw`: Buffer - decrypted message as a pointer to an array of bytes
1230
1231Errors: `Common*`, `Wallet*`, `Crypto*`
1232
1233#### packMessage \( wh, message, receiverKeys, senderVk \) -&gt; jwe
1234
1235Packs a message by encrypting the message and serializes it in a JWE-like format (Experimental)
1236
1237Note to use DID keys with this function you can call keyForDid to get key id (verkey) for specific DID.
1238
1239* `wh`: Handle (Number) - wallet handle (created by openWallet)
1240* `message`: Buffer - message that to be packed
1241* `receiverKeys`: Array - an array of strings which contains receiver's keys the message is being encrypted for.
1242 Example: \['receiver edge_agent_1 verkey', 'receiver edge_agent_2 verkey'\]
1243* `senderVk`: String - the sender's verkey as a string When null pointer is used in this parameter, anoncrypt is used
1244* __->__ `jwe`: Buffer - a JWE
1245```
1246using authcrypt alg:
1247{
1248 "protected": "b64URLencoded({
1249 "enc": "xsalsa20poly1305",
1250 "typ": "JWM/1.0",
1251 "alg": "Authcrypt",
1252 "recipients": [
1253 {
1254 "encrypted_key": base64URLencode(libsodium.crypto_box(my_key, their_vk, cek, cek_iv))
1255 "header": {
1256 "kid": "base58encode(recipient_verkey)",
1257 "sender" : base64URLencode(libsodium.crypto_box_seal(their_vk, base58encode(sender_vk)),
1258 "iv" : base64URLencode(cek_iv)
1259 }
1260 },
1261 ],
1262 })",
1263 "iv": <b64URLencode(iv)>,
1264 "ciphertext": b64URLencode(encrypt_detached({'@type'...}, protected_value_encoded, iv, cek),
1265 "tag": <b64URLencode(tag)>
1266}
1267
1268Alternative example in using anoncrypt alg is defined below:
1269{
1270 "protected": "b64URLencoded({
1271 "enc": "xsalsa20poly1305",
1272 "typ": "JWM/1.0",
1273 "alg": "Anoncrypt",
1274 "recipients": [
1275 {
1276 "encrypted_key": base64URLencode(libsodium.crypto_box_seal(their_vk, cek)),
1277 "header": {
1278 "kid": base58encode(recipient_verkey),
1279 }
1280 },
1281 ],
1282 })",
1283 "iv": b64URLencode(iv),
1284 "ciphertext": b64URLencode(encrypt_detached({'@type'...}, protected_value_encoded, iv, cek),
1285 "tag": b64URLencode(tag)
1286}
1287````
1288
1289Errors: `Common*`, `Wallet*`, `Ledger*`, `Crypto*`
1290
1291#### unpackMessage \( wh, jwe \) -&gt; res
1292
1293Unpacks a JWE-like formatted message outputted by packMessage (Experimental)
1294
1295* `wh`: Handle (Number) - wallet handle (created by openWallet)
1296* `jwe`: Buffer - JWE to be unpacked
1297* __->__ `res`: Buffer - a result message
1298```
1299if authcrypt was used to pack the message returns this json structure:
1300{
1301 message: <decrypted message>,
1302 sender_verkey: <sender_verkey>,
1303 recipient_verkey: <recipient_verkey>
1304}
1305
1306OR
1307
1308if anoncrypt was used to pack the message returns this json structure:
1309{
1310 message: <decrypted message>,
1311 recipient_verkey: <recipient_verkey>
1312}
1313````
1314
1315Errors: `Common*`, `Wallet*`, `Ledger*`, `Crypto*`
1316
1317### did
1318
1319#### createAndStoreMyDid \( wh, did \) -&gt; \[ did, verkey \]
1320
1321Creates keys \(signing and encryption keys\) for a new
1322DID \(owned by the caller of the library\).
1323Identity's DID must be either explicitly provided, or taken as the first 16 bit of verkey.
1324Saves the Identity DID with keys in a secured Wallet, so that it can be used to sign
1325and encrypt transactions.
1326
1327* `wh`: Handle (Number) - wallet handle (created by openWallet)
1328* `did`: Json - Identity information as json
1329```
1330{
1331 "did": string, (optional;
1332 if not provided and cid param is false then the first 16 bit of the verkey will be used as a new DID;
1333 if not provided and cid is true then the full verkey will be used as a new DID;
1334 if provided, then keys will be replaced - key rotation use case)
1335 "seed": string, (optional) Seed that allows deterministic did creation (if not set random one will be created).
1336 Can be UTF-8, base64 or hex string.
1337 "crypto_type": string, (optional; if not set then ed25519 curve is used;
1338 currently only 'ed25519' value is supported for this field)
1339 "cid": bool, (optional; if not set then false is used;)
1340 "method_name": string, (optional) method name to create fully qualified did (Example: `did:method_name:NcYxiDXkpYi6ov5FcYDi1e`).
1341}
1342```
1343* __->__ [ `did`: String, `verkey`: String ] - did: DID generated and stored in the wallet
1344verkey: The DIDs verification key
1345
1346Errors: `Common*`, `Wallet*`, `Crypto*`
1347
1348#### replaceKeysStart \( wh, did, identity \) -&gt; verkey
1349
1350Generated temporary keys \(signing and encryption keys\) for an existing
1351DID \(owned by the caller of the library\).
1352
1353* `wh`: Handle (Number) - wallet handle (created by openWallet)
1354* `did`: String - target did to rotate keys.
1355* `identity`: Json
1356* __->__ `verkey`: String - verkey: The DIDs verification key
1357
1358Errors: `Common*`, `Wallet*`, `Crypto*`
1359
1360#### replaceKeysApply \( wh, did \) -&gt; void
1361
1362Apply temporary keys as main for an existing DID \(owned by the caller of the library\).
1363
1364* `wh`: Handle (Number) - wallet handle (created by openWallet)
1365* `did`: String - DID stored in the wallet
1366* __->__ void
1367
1368Errors: `Common*`, `Wallet*`, `Crypto*`
1369
1370#### storeTheirDid \( wh, identity \) -&gt; void
1371
1372Saves their DID for a pairwise connection in a secured Wallet,
1373so that it can be used to verify transaction.
1374Updates DID associated verkey in case DID already exists in the Wallet.
1375
1376* `wh`: Handle (Number) - wallet handle (created by openWallet)
1377* `identity`: Json - Identity information as json. Example:
1378```
1379 {
1380 "did": string, (required)
1381 "verkey": string
1382 - optional is case of adding a new DID, and DID is cryptonym: did == verkey,
1383 - mandatory in case of updating an existing DID
1384 }
1385````
1386* __->__ void
1387
1388Errors: `Common*`, `Wallet*`, `Crypto*`
1389
1390#### keyForDid \( poolHandle, wh, did \) -&gt; key
1391
1392Returns ver key \(key id\) for the given DID.
1393
1394"keyForDid" call follow the idea that we resolve information about their DID from
1395the ledger with cache in the local wallet. The "openWallet" call has freshness parameter
1396that is used for checking the freshness of cached pool value.
1397
1398Note if you don't want to resolve their DID info from the ledger you can use
1399"keyForLocalDid" call instead that will look only to the local wallet and skip
1400freshness checking.
1401
1402Note that "createAndStoreMyDid" makes similar wallet record as "createKey".
1403As result we can use returned ver key in all generic crypto and messaging functions.
1404
1405* `poolHandle`: Handle (Number) - Pool handle \(created by open\_pool\).
1406* `wh`: Handle (Number) - wallet handle (created by openWallet)
1407* `did`: String
1408* __->__ `key`: String - The DIDs ver key \(key id\).
1409
1410Errors: `Common*`, `Wallet*`, `Crypto*`
1411
1412#### keyForLocalDid \( wh, did \) -&gt; key
1413
1414Returns ver key \(key id\) for the given DID.
1415
1416"keyForLocalDid" call looks data stored in the local wallet only and skips freshness
1417checking.
1418
1419Note if you want to get fresh data from the ledger you can use "keyForDid" call
1420instead.
1421
1422Note that "createAndStoreMyDid" makes similar wallet record as "createKey".
1423As result we can use returned ver key in all generic crypto and messaging functions.
1424
1425* `wh`: Handle (Number) - wallet handle (created by openWallet)
1426* `did`: String
1427* __->__ `key`: String - The DIDs ver key \(key id\).
1428
1429Errors: `Common*`, `Wallet*`, `Crypto*`
1430
1431#### setEndpointForDid \( wh, did, address, transportKey \) -&gt; void
1432
1433Set\/replaces endpoint information for the given DID.
1434
1435* `wh`: Handle (Number) - wallet handle (created by openWallet)
1436* `did`: String
1437* `address`: String
1438* `transportKey`: String
1439* __->__ void
1440
1441Errors: `Common*`, `Wallet*`, `Crypto*`
1442
1443#### getEndpointForDid \( wh, poolHandle, did \) -&gt; \[ address, transportVk \]
1444
1445Returns endpoint information for the given DID.
1446
1447* `wh`: Handle (Number) - wallet handle (created by openWallet)
1448* `poolHandle`: Handle (Number)
1449* `did`: String
1450* __->__ [ `address`: String, `transportVk`: String ] - The DIDs endpoint.
1451- transport\_vk - The DIDs transport key \(ver key, key id\).
1452
1453Errors: `Common*`, `Wallet*`, `Crypto*`
1454
1455#### setDidMetadata \( wh, did, metadata \) -&gt; void
1456
1457Saves\/replaces the meta information for the giving DID in the wallet.
1458
1459* `wh`: Handle (Number) - wallet handle (created by openWallet)
1460* `did`: String
1461* `metadata`: String
1462* __->__ void
1463
1464Errors: `Common*`, `Wallet*`, `Crypto*`
1465
1466#### getDidMetadata \( wh, did \) -&gt; metadata
1467
1468Retrieves the meta information for the giving DID in the wallet.
1469
1470* `wh`: Handle (Number) - wallet handle (created by openWallet)
1471* `did`: String
1472* __->__ `metadata`: String - The meta information stored with the DID; Can be null if no metadata was saved for this DID.
1473
1474Errors: `Common*`, `Wallet*`, `Crypto*`
1475
1476#### getMyDidWithMeta \( wh, myDid \) -&gt; didWithMeta
1477
1478Retrieves the information about the giving DID in the wallet.
1479
1480* `wh`: Handle (Number) - wallet handle (created by openWallet)
1481* `myDid`: String
1482* __->__ `didWithMeta`: Json - did\_with\_meta: {
1483"did": string - DID stored in the wallet,
1484"verkey": string - The DIDs transport key \(ver key, key id\),
1485"tempVerkey": string - Temporary DIDs transport key \(ver key, key id\), exist only during the rotation of the keys.
1486After rotation is done, it becomes a new verkey.
1487"metadata": string - The meta information stored with the DID
1488}
1489
1490Errors: `Common*`, `Wallet*`, `Crypto*`
1491
1492#### listMyDidsWithMeta \( wh \) -&gt; dids
1493
1494Retrieves the information about all DIDs stored in the wallet.
1495
1496* `wh`: Handle (Number) - wallet handle (created by openWallet)
1497* __->__ `dids`: Json - dids: \[{
1498"did": string - DID stored in the wallet,
1499"verkey": string - The DIDs transport key \(ver key, key id\).,
1500"metadata": string - The meta information stored with the DID
1501}\]
1502
1503Errors: `Common*`, `Wallet*`, `Crypto*`
1504
1505#### abbreviateVerkey \( did, fullVerkey \) -&gt; verkey
1506
1507Retrieves abbreviated verkey if it is possible otherwise return full verkey.
1508
1509* `did`: String - DID.
1510* `fullVerkey`: String - The DIDs verification key,
1511* __->__ `verkey`: String - verkey: The DIDs verification key in either abbreviated or full form
1512
1513Errors: `Common*`, `Wallet*`, `Crypto*`
1514
1515#### qualifyDid \( wh, did, method \) -&gt; fullQualifiedDid
1516
1517Update DID stored in the wallet to make fully qualified, or to do other DID maintenance.
1518 - If the DID has no prefix, a prefix will be appended (prepend did:peer to a legacy did)
1519 - If the DID has a prefix, a prefix will be updated (migrate did:peer to did:peer-new)
1520
1521Update DID related entities stored in the wallet.
1522
1523* `wh`: Handle (Number) - wallet handle (created by openWallet)
1524* `did`: String - target DID stored in the wallet.
1525* `method`: String - method to apply to the DID.
1526* __->__ `fullQualifiedDid`: String - fully qualified did
1527
1528Errors: `Common*`, `Wallet*`, `Crypto*`
1529
1530### ledger
1531
1532#### signAndSubmitRequest \( poolHandle, wh, submitterDid, request \) -&gt; requestResult
1533
1534Signs and submits request message to validator pool.
1535
1536Adds submitter information to passed request json, signs it with submitter
1537sign key \(see wallet\_sign\), and sends signed request message
1538to validator pool \(see write\_request\).
1539
1540* `poolHandle`: Handle (Number) - pool handle \(created by open\_pool\_ledger\).
1541* `wh`: Handle (Number) - wallet handle (created by openWallet)
1542* `submitterDid`: String - Id of Identity stored in secured Wallet.
1543* `request`: Json - Request data json.
1544* __->__ `requestResult`: Json
1545
1546Errors: `Common*`, `Wallet*`, `Ledger*`, `Crypto*`
1547
1548#### submitRequest \( poolHandle, request \) -&gt; requestResult
1549
1550Publishes request message to validator pool \(no signing, unlike sign\_and\_submit\_request\).
1551
1552The request is sent to the validator pool as is. It's assumed that it's already prepared.
1553
1554* `poolHandle`: Handle (Number) - pool handle \(created by open\_pool\_ledger\).
1555* `request`: Json - Request data json.
1556* __->__ `requestResult`: Json
1557
1558Errors: `Common*`, `Ledger*`
1559
1560#### submitAction \( poolHandle, request, nodes, timeout \) -&gt; requestResult
1561
1562Send action to particular nodes of validator pool.
1563
1564The list of requests can be send:
1565POOL\_RESTART
1566GET\_VALIDATOR\_INFO
1567
1568The request is sent to the nodes as is. It's assumed that it's already prepared.
1569
1570* `poolHandle`: Handle (Number) - pool handle \(created by open\_pool\_ledger\).
1571* `request`: Json - Request data json.
1572* `nodes`: Json - \(Optional\) List of node names to send the request.
1573\["Node1", "Node2",...."NodeN"\]
1574* `timeout`: Number - \(Optional\) Time to wait respond from nodes \(override the default timeout\) \(in sec\).
1575Pass -1 to use default timeout
1576* __->__ `requestResult`: Json
1577
1578Errors: `Common*`, `Ledger*`
1579
1580#### signRequest \( wh, submitterDid, request \) -&gt; signedRequest
1581
1582Signs request message.
1583
1584Adds submitter information to passed request json, signs it with submitter
1585sign key \(see wallet\_sign\).
1586
1587* `wh`: Handle (Number) - wallet handle (created by openWallet)
1588* `submitterDid`: String - Id of Identity stored in secured Wallet.
1589* `request`: Json - Request data json.
1590* __->__ `signedRequest`: Json - Signed request json.
1591
1592Errors: `Common*`, `Wallet*`, `Ledger*`, `Crypto*`
1593
1594#### multiSignRequest \( wh, submitterDid, request \) -&gt; signedRequest
1595
1596Multi signs request message.
1597
1598Adds submitter information to passed request json, signs it with submitter
1599sign key \(see wallet\_sign\).
1600
1601* `wh`: Handle (Number) - wallet handle (created by openWallet)
1602* `submitterDid`: String - Id of Identity stored in secured Wallet.
1603* `request`: Json - Request data json.
1604* __->__ `signedRequest`: Json - Signed request json.
1605
1606Errors: `Common*`, `Wallet*`, `Ledger*`, `Crypto*`
1607
1608#### buildGetDdoRequest \( submitterDid, targetDid \) -&gt; requestResult
1609
1610Builds a request to get a DDO.
1611
1612* `submitterDid`: String - \(Optional\) DID of the read request sender \(if not provided then default Libindy DID will be used\).
1613* `targetDid`: String - Target DID as base58-encoded string for 16 or 32 bit DID value.
1614* __->__ `requestResult`: Json
1615
1616Errors: `Common*`
1617
1618#### buildNymRequest \( submitterDid, targetDid, verkey, alias, role \) -&gt; request
1619
1620Builds a NYM request. Request to create a new NYM record for a specific user.
1621
1622* `submitterDid`: String - Identifier (DID) of the transaction author as base58-encoded string.
1623 Actual request sender may differ if Endorser is used (look at `appendRequestEndorser`)
1624* `targetDid`: String - Target DID as base58-encoded string for 16 or 32 bit DID value.
1625* `verkey`: String - Target identity verification key as base58-encoded string.
1626* `alias`: String - NYM's alias.
1627* `role`: String - Role of a user NYM record:
1628null \(common USER\)
1629TRUSTEE
1630STEWARD
1631TRUST\_ANCHOR
1632NETWORK\_MONITOR
1633empty string to reset role
1634* __->__ `request`: Json
1635
1636Errors: `Common*`
1637
1638#### buildAttribRequest \( submitterDid, targetDid, hash, raw, enc \) -&gt; request
1639
1640Builds an ATTRIB request. Request to add attribute to a NYM record.
1641
1642* `submitterDid`: String - Identifier (DID) of the transaction author as base58-encoded string.
1643 Actual request sender may differ if Endorser is used (look at `appendRequestEndorser`)
1644* `targetDid`: String - Target DID as base58-encoded string for 16 or 32 bit DID value.
1645* `hash`: String - \(Optional\) Hash of attribute data.
1646* `raw`: Json - \(Optional\) Json, where key is attribute name and value is attribute value.
1647* `enc`: String - \(Optional\) Encrypted value attribute data.
1648* __->__ `request`: Json
1649
1650Errors: `Common*`
1651
1652#### buildGetAttribRequest \( submitterDid, targetDid, raw, hash, enc \) -&gt; request
1653
1654Builds a GET\_ATTRIB request. Request to get information about an Attribute for the specified DID.
1655
1656* `submitterDid`: String - \(Optional\) DID of the read request sender \(if not provided then default Libindy DID will be used\).
1657* `targetDid`: String - Target DID as base58-encoded string for 16 or 32 bit DID value.
1658* `raw`: String - \(Optional\) Requested attribute name.
1659* `hash`: String - \(Optional\) Requested attribute hash.
1660* `enc`: String - \(Optional\) Requested attribute encrypted value.
1661* __->__ `request`: Json
1662
1663Errors: `Common*`
1664
1665#### buildGetNymRequest \( submitterDid, targetDid \) -&gt; request
1666
1667Builds a GET\_NYM request. Request to get information about a DID \(NYM\).
1668
1669* `submitterDid`: String - \(Optional\) DID of the read request sender \(if not provided then default Libindy DID will be used\).
1670* `targetDid`: String - Target DID as base58-encoded string for 16 or 32 bit DID value.
1671* __->__ `request`: Json
1672
1673Errors: `Common*`
1674
1675#### parseGetNymResponse \( response \) -&gt; nymData
1676
1677Parse a GET_NYM response to get NYM data.
1678
1679* `response`: String - response on GET_NYM request.
1680* __->__ `nymData`: Json
1681```
1682 {
1683 did: DID as base58-encoded string for 16 or 32 bit DID value.
1684 verkey: verification key as base58-encoded string.
1685 role: Role associated number
1686 null (common USER)
1687 0 - TRUSTEE
1688 2 - STEWARD
1689 101 - TRUST_ANCHOR
1690 101 - ENDORSER - equal to TRUST_ANCHOR that will be removed soon
1691 201 - NETWORK_MONITOR
1692 }
1693```
1694
1695Errors: `Common*`
1696
1697#### buildSchemaRequest \( submitterDid, data \) -&gt; request
1698
1699Builds a SCHEMA request. Request to add Credential's schema.
1700
1701* `submitterDid`: String - Identifier (DID) of the transaction author as base58-encoded string.
1702 Actual request sender may differ if Endorser is used (look at `appendRequestEndorser`)
1703* `data`: Json - Credential schema.
1704```
1705{
1706 id: identifier of schema
1707 attrNames: array of attribute name strings
1708 name: Schema's name string (the number of attributes should be less or equal than 125)
1709 version: Schema's version string,
1710 ver: Version of the Schema json
1711}
1712````
1713* __->__ `request`: Json
1714
1715Errors: `Common*`
1716
1717#### buildGetSchemaRequest \( submitterDid, id \) -&gt; request
1718
1719Builds a GET\_SCHEMA request. Request to get Credential's Schema.
1720
1721* `submitterDid`: String - \(Optional\) DID of the read request sender \(if not provided then default Libindy DID will be used\).
1722* `id`: String - Schema ID in ledger
1723* __->__ `request`: Json
1724
1725Errors: `Common*`
1726
1727#### parseGetSchemaResponse \( getSchemaResponse \) -&gt; \[ schemaId, schema \]
1728
1729Parse a GET\_SCHEMA response to get Schema in the format compatible with Anoncreds API.
1730
1731* `getSchemaResponse`: Json - response of GET\_SCHEMA request.
1732* __->__ [ `schemaId`: String, `schema`: Json ] - Schema Id and Schema json.
1733```
1734{
1735 id: identifier of schema
1736 attrNames: array of attribute name strings
1737 name: Schema's name string
1738 version: Schema's version string
1739 ver: Version of the Schema json
1740}
1741````
1742
1743Errors: `Common*`
1744
1745#### buildCredDefRequest \( submitterDid, data \) -&gt; request
1746
1747Builds an CRED\_DEF request. Request to add a Credential Definition \(in particular, public key\),
1748that Issuer creates for a particular Credential Schema.
1749
1750* `submitterDid`: String - Identifier (DID) of the transaction author as base58-encoded string.
1751 Actual request sender may differ if Endorser is used (look at `appendRequestEndorser`)
1752* `data`: Json - credential definition json
1753```
1754{
1755 id: string - identifier of credential definition
1756 schemaId: string - identifier of stored in ledger schema
1757 type: string - type of the credential definition. CL is the only supported type now.
1758 tag: string - allows to distinct between credential definitions for the same issuer and schema
1759 value: Dictionary with Credential Definition's data:
1760{
1761 primary: primary credential public key,
1762 Optional<revocation>: revocation credential public key
1763 },
1764 ver: Version of the CredDef json
1765}
1766````
1767* __->__ `request`: Json
1768
1769Errors: `Common*`
1770
1771#### buildGetCredDefRequest \( submitterDid, id \) -&gt; request
1772
1773Builds a GET\_CRED\_DEF request. Request to get a Credential Definition \(in particular, public key\),
1774that Issuer creates for a particular Credential Schema.
1775
1776* `submitterDid`: String - \(Optional\) DID of the read request sender \(if not provided then default Libindy DID will be used\).
1777* `id`: String - Credential Definition ID in ledger.
1778* __->__ `request`: Json
1779
1780Errors: `Common*`
1781
1782#### parseGetCredDefResponse \( getCredDefResponse \) -&gt; \[ credDefId, credDef \]
1783
1784Parse a GET\_CRED\_DEF response to get Credential Definition in the format compatible with Anoncreds API.
1785
1786* `getCredDefResponse`: Json - response of GET\_CRED\_DEF request.
1787* __->__ [ `credDefId`: String, `credDef`: Json ] - Credential Definition Id and Credential Definition json.
1788```
1789{
1790 id: string - identifier of credential definition
1791 schemaId: string - identifier of stored in ledger schema
1792 type: string - type of the credential definition. CL is the only supported type now.
1793 tag: string - allows to distinct between credential definitions for the same issuer and schema
1794 value: Dictionary with Credential Definition's data: {
1795 primary: primary credential public key,
1796 Optional<revocation>: revocation credential public key
1797 },
1798 ver: Version of the Credential Definition json
1799}
1800````
1801
1802Errors: `Common*`
1803
1804#### buildNodeRequest \( submitterDid, targetDid, data \) -&gt; request
1805
1806Builds a NODE request. Request to add a new node to the pool, or updates existing in the pool.
1807
1808* `submitterDid`: String - Identifier (DID) of the transaction author as base58-encoded string.
1809 Actual request sender may differ if Endorser is used (look at `appendRequestEndorser`)
1810* `targetDid`: String - Target Node's DID. It differs from submitter\_did field.
1811* `data`: Json - Data associated with the Node:
1812```
1813{
1814 alias: string - Node's alias
1815 blskey: string - (Optional) BLS multi-signature key as base58-encoded string.
1816 blskey_pop: string - (Optional) BLS key proof of possession as base58-encoded string.
1817 client_ip: string - (Optional) Node's client listener IP address.
1818 client_port: string - (Optional) Node's client listener port.
1819 node_ip: string - (Optional) The IP address other Nodes use to communicate with this Node.
1820 node_port: string - (Optional) The port other Nodes use to communicate with this Node.
1821 services: array<string> - (Optional) The service of the Node. VALIDATOR is the only supported one now.
1822}
1823````
1824* __->__ `request`: Json
1825
1826Errors: `Common*`
1827
1828#### buildGetValidatorInfoRequest \( submitterDid \) -&gt; request
1829
1830Builds a GET\_VALIDATOR\_INFO request.
1831
1832* `submitterDid`: String - DID of the read request sender.
1833* __->__ `request`: Json
1834
1835Errors: `Common*`
1836
1837#### buildGetTxnRequest \( submitterDid, ledgerType, seqNo \) -&gt; request
1838
1839Builds a GET\_TXN request. Request to get any transaction by its seq\_no.
1840
1841* `submitterDid`: String - \(Optional\) DID of the read request sender \(if not provided then default Libindy DID will be used\).
1842* `ledgerType`: String - \(Optional\) type of the ledger the requested transaction belongs to:
1843DOMAIN - used default,
1844POOL,
1845CONFIG
1846any number
1847* `seqNo`: Number - requested transaction sequence number as it's stored on Ledger.
1848* __->__ `request`: Json
1849
1850Errors: `Common*`
1851
1852#### buildPoolConfigRequest \( submitterDid, writes, force \) -&gt; request
1853
1854Builds a POOL\_CONFIG request. Request to change Pool's configuration.
1855
1856* `submitterDid`: String - Identifier (DID) of the transaction author as base58-encoded string.
1857 Actual request sender may differ if Endorser is used (look at `appendRequestEndorser`)
1858* `writes`: Boolean - Whether any write requests can be processed by the pool
1859\(if false, then pool goes to read-only state\). True by default.
1860* `force`: Boolean - Whether we should apply transaction \(for example, move pool to read-only state\)
1861without waiting for consensus of this transaction.
1862* __->__ `request`: Json
1863
1864Errors: `Common*`
1865
1866#### buildPoolRestartRequest \( submitterDid, action, datetime \) -&gt; request
1867
1868Builds a POOL\_RESTART request.
1869
1870* `submitterDid`: String - Identifier (DID) of the transaction author as base58-encoded string.
1871 Actual request sender may differ if Endorser is used (look at `appendRequestEndorser`)
1872* `action`: String - Action that pool has to do after received transaction.
1873* `datetime`: String - &lt;Optional&gt; Restart time in datetime format. Skip to restart as early as possible.
1874* __->__ `request`: Json
1875
1876Errors: `Common*`
1877
1878#### buildPoolUpgradeRequest \( submitterDid, name, version, action, sha256, timeout, schedule, justification, reinstall, force, package\_ \) -&gt; request
1879
1880Builds a POOL\_UPGRADE request. Request to upgrade the Pool \(sent by Trustee\).
1881It upgrades the specified Nodes \(either all nodes in the Pool, or some specific ones\).
1882
1883* `submitterDid`: String - Identifier (DID) of the transaction author as base58-encoded string.
1884 Actual request sender may differ if Endorser is used (look at `appendRequestEndorser`)
1885* `name`: String - Human-readable name for the upgrade.
1886* `version`: String - The version of indy-node package we perform upgrade to.
1887Must be greater than existing one \(or equal if reinstall flag is True\).
1888* `action`: String - Either start or cancel.
1889* `sha256`: String - sha256 hash of the package.
1890* `timeout`: Number - \(Optional\) Limits upgrade time on each Node.
1891* `schedule`: String - \(Optional\) Schedule of when to perform upgrade on each node. Map Node DIDs to upgrade time.
1892* `justification`: String - \(Optional\) justification string for this particular Upgrade.
1893* `reinstall`: Boolean - Whether it's allowed to re-install the same version. False by default.
1894* `force`: Boolean - Whether we should apply transaction \(schedule Upgrade\) without waiting
1895for consensus of this transaction.
1896* `package_`: String
1897* __->__ `request`: Json
1898
1899Errors: `Common*`
1900
1901#### buildRevocRegDefRequest \( submitterDid, data \) -&gt; request
1902
1903Builds a REVOC\_REG\_DEF request. Request to add the definition of revocation registry
1904to an exists credential definition.
1905
1906* `submitterDid`: String - Identifier (DID) of the transaction author as base58-encoded string.
1907 Actual request sender may differ if Endorser is used (look at `appendRequestEndorser`)
1908* `data`: Json - Revocation Registry data:
1909```
1910 {
1911 "id": string - ID of the Revocation Registry,
1912 "revocDefType": string - Revocation Registry type (only CL_ACCUM is supported for now),
1913 "tag": string - Unique descriptive ID of the Registry,
1914 "credDefId": string - ID of the corresponding CredentialDefinition,
1915 "value": Registry-specific data {
1916 "issuanceType": string - Type of Issuance(ISSUANCE_BY_DEFAULT or ISSUANCE_ON_DEMAND),
1917 "maxCredNum": number - Maximum number of credentials the Registry can serve.
1918 "tailsHash": string - Hash of tails.
1919 "tailsLocation": string - Location of tails file.
1920 "publicKeys": <public_keys> - Registry's public key.
1921 },
1922 "ver": string - version of revocation registry definition json.
1923 }
1924````
1925* __->__ `request`: Json
1926
1927Errors: `Common*`
1928
1929#### buildGetRevocRegDefRequest \( submitterDid, id \) -&gt; request
1930
1931Builds a GET\_REVOC\_REG\_DEF request. Request to get a revocation registry definition,
1932that Issuer creates for a particular Credential Definition.
1933
1934* `submitterDid`: String - \(Optional\) DID of the read request sender \(if not provided then default Libindy DID will be used\).
1935* `id`: String - ID of Revocation Registry Definition in ledger.
1936* __->__ `request`: Json
1937
1938Errors: `Common*`
1939
1940#### parseGetRevocRegDefResponse \( getRevocRefDefResponse \) -&gt; \[ revocRegDefId, revocRegDef \]
1941
1942Parse a GET\_REVOC\_REG\_DEF response to get Revocation Registry Definition in the format
1943compatible with Anoncreds API.
1944
1945* `getRevocRefDefResponse`: Json
1946* __->__ [ `revocRegDefId`: String, `revocRegDef`: Json ] - Revocation Registry Definition Id and Revocation Registry Definition json.
1947```
1948{
1949 "id": string - ID of the Revocation Registry,
1950 "revocDefType": string - Revocation Registry type (only CL_ACCUM is supported for now),
1951 "tag": string - Unique descriptive ID of the Registry,
1952 "credDefId": string - ID of the corresponding CredentialDefinition,
1953 "value": Registry-specific data {
1954 "issuanceType": string - Type of Issuance(ISSUANCE_BY_DEFAULT or ISSUANCE_ON_DEMAND),
1955 "maxCredNum": number - Maximum number of credentials the Registry can serve.
1956 "tailsHash": string - Hash of tails.
1957 "tailsLocation": string - Location of tails file.
1958 "publicKeys": <public_keys> - Registry's public key.
1959 },
1960 "ver": string - version of revocation registry definition json.
1961}
1962````
1963
1964Errors: `Common*`
1965
1966#### buildRevocRegEntryRequest \( submitterDid, revocRegDefId, revDefType, value \) -&gt; request
1967
1968Builds a REVOC\_REG\_ENTRY request. Request to add the RevocReg entry containing
1969the new accumulator value and issued\/revoked indices.
1970This is just a delta of indices, not the whole list.
1971So, it can be sent each time a new credential is issued\/revoked.
1972
1973* `submitterDid`: String - Identifier (DID) of the transaction author as base58-encoded string.
1974 Actual request sender may differ if Endorser is used (look at `appendRequestEndorser`)
1975* `revocRegDefId`: String - ID of the corresponding RevocRegDef.
1976* `revDefType`: String - Revocation Registry type \(only CL\_ACCUM is supported for now\).
1977* `value`: Json - Registry-specific data:
1978```
1979{
1980 value:
1981{
1982 prevAccum: string - previous accumulator value.
1983 accum: string - current accumulator value.
1984 issued: array<number> - an array of issued indices.
1985 revoked: array<number> an array of revoked indices.
1986 },
1987 ver: string - version revocation registry entry json
1988}
1989````
1990* __->__ `request`: Json
1991
1992Errors: `Common*`
1993
1994#### buildGetRevocRegRequest \( submitterDid, revocRegDefId, timestamp \) -&gt; request
1995
1996Builds a GET\_REVOC\_REG request. Request to get the accumulated state of the Revocation Registry
1997by ID. The state is defined by the given timestamp.
1998
1999* `submitterDid`: String - \(Optional\) DID of the read request sender \(if not provided then default Libindy DID will be used\).
2000* `revocRegDefId`: String - ID of the corresponding Revocation Registry Definition in ledger.
2001* `timestamp`: Timestamp (Number) - Requested time represented as a total number of seconds from Unix Epoch
2002* __->__ `request`: Json
2003
2004Errors: `Common*`
2005
2006#### parseGetRevocRegResponse \( getRevocRegResponse \) -&gt; \[ revocRegDefId, revocReg, timestamp \]
2007
2008Parse a GET\_REVOC\_REG response to get Revocation Registry in the format compatible with Anoncreds API.
2009
2010* `getRevocRegResponse`: Json - response of GET\_REVOC\_REG request.
2011* __->__ [ `revocRegDefId`: String, `revocReg`: Json, `timestamp`: Timestamp (Number) ] - Revocation Registry Definition Id, Revocation Registry json and Timestamp.
2012```
2013{
2014 "value": Registry-specific data {
2015 "accum": string - current accumulator value.
2016 },
2017 "ver": string - version revocation registry json
2018}
2019````
2020
2021Errors: `Common*`
2022
2023#### buildGetRevocRegDeltaRequest \( submitterDid, revocRegDefId, from, to \) -&gt; request
2024
2025Builds a GET\_REVOC\_REG\_DELTA request. Request to get the delta of the accumulated state of the Revocation Registry.
2026The Delta is defined by from and to timestamp fields.
2027If from is not specified, then the whole state till to will be returned.
2028
2029* `submitterDid`: String - \(Optional\) DID of the read request sender \(if not provided then default Libindy DID will be used\).
2030* `revocRegDefId`: String - ID of the corresponding Revocation Registry Definition in ledger.
2031* `from`: Timestamp (Number) - Requested time represented as a total number of seconds from Unix Epoch
2032* `to`: Timestamp (Number) - Requested time represented as a total number of seconds from Unix Epoch
2033* __->__ `request`: Json
2034
2035Errors: `Common*`
2036
2037#### parseGetRevocRegDeltaResponse \( getRevocRegDeltaResponse \) -&gt; \[ revocRegDefId, revocRegDelta, timestamp \]
2038
2039Parse a GET\_REVOC\_REG\_DELTA response to get Revocation Registry Delta in the format compatible with Anoncreds API.
2040
2041* `getRevocRegDeltaResponse`: Json
2042* __->__ [ `revocRegDefId`: String, `revocRegDelta`: Json, `timestamp`: Timestamp (Number) ] - Revocation Registry Definition Id, Revocation Registry Delta json and Timestamp.
2043```
2044{
2045 "value": Registry-specific data {
2046 prevAccum: string - previous accumulator value.
2047 accum: string - current accumulator value.
2048 issued: array<number> - an array of issued indices.
2049 revoked: array<number> an array of revoked indices.
2050 },
2051 "ver": string - version revocation registry delta json
2052}
2053````
2054
2055Errors: `Common*`
2056
2057#### buildAuthRuleRequest \( submitterDid, txnType, action, field, oldValue, newValue, constraint \) -&gt; request
2058
2059Builds a AUTH_RULE request. Request to change authentication rules for a ledger transaction.
2060
2061* `submitterDid`: String - Identifier (DID) of the transaction author as base58-encoded string.
2062 Actual request sender may differ if Endorser is used (look at `appendRequestEndorser`)
2063* `txnType`: String - ledger transaction alias or associated value.
2064* `action`: String - type of an action.
2065 * "ADD" - to add a new rule
2066 * "EDIT" - to edit an existing one
2067* `field`: String - transaction field.
2068* `oldValue`: String - \(Optional\) old value of a field, which can be changed to a new_value (mandatory for EDIT action).
2069* `newValue`: String - \(Optional\) new value that can be used to fill the field.
2070* `constraint`: Json - set of constraints required for execution of an action in the following format:
2071```
2072 {
2073 constraint_id - <string> type of a constraint.
2074 Can be either "ROLE" to specify final constraint or "AND"/"OR" to combine constraints.
2075 role - <string> (optional) role of a user which satisfy to constrain.
2076 sig_count - <u32> the number of signatures required to execution action.
2077 need_to_be_owner - <bool> (optional) if user must be an owner of transaction (false by default).
2078 off_ledger_signature - <bool> (optional) allow signature of unknow for ledger did (false by default).
2079 metadata - <object> (optional) additional parameters of the constraint.
2080 }
2081can be combined by
2082 {
2083 'constraint_id': <"AND" or "OR">
2084 'auth_constraints': [<constraint_1>, <constraint_2>]
2085 }
2086```
2087
2088Default ledger auth rules: https://github.com/hyperledger/indy-node/blob/master/docs/source/auth_rules.md
2089
2090More about AUTH_RULE request: https://github.com/hyperledger/indy-node/blob/master/docs/source/requests.md#auth_rule
2091
2092* __->__ `request`: Json
2093
2094Errors: `Common*`
2095
2096#### buildAuthRulesRequest \( submitterDid, data \) -&gt; request
2097
2098Builds a AUTH_RULES request. Request to change multiple authentication rules for a ledger transaction.
2099
2100* `submitterDid`: String - Identifier (DID) of the transaction author as base58-encoded string.
2101 Actual request sender may differ if Endorser is used (look at `appendRequestEndorser`)
2102* `constraint`: Json - a list of auth rules:
2103```
2104[
2105 {
2106 "auth_type": ledger transaction alias or associated value,
2107 "auth_action": type of an action,
2108 "field": transaction field,
2109 "old_value": (Optional) old value of a field, which can be changed to a new_value (mandatory for EDIT action),
2110 "new_value": (Optional) new value that can be used to fill the field,
2111 "constraint": set of constraints required for execution of an action in the format described above for `buildAuthRuleRequest` function.
2112 },
2113 ...
2114]
2115```
2116
2117Default ledger auth rules: https://github.com/hyperledger/indy-node/blob/master/docs/source/auth_rules.md
2118
2119More about AUTH_RULE request: https://github.com/hyperledger/indy-node/blob/master/docs/source/requests.md#auth_rules
2120
2121* __->__ `request`: Json
2122
2123Errors: `Common*`
2124
2125
2126#### buildGetAuthRuleRequest \( submitterDid, txnType, action, field, oldValue, newValue \) -&gt; request
2127
2128Builds a GET_AUTH_RULE request. Request to get authentication rules for a ledger transaction.
2129
2130NOTE: Either none or all transaction related parameters must be specified (`oldValue` can be skipped for `ADD` action).
2131* none - to get all authentication rules for all ledger transactions
2132* all - to get authentication rules for specific action (`oldValue` can be skipped for `ADD` action)
2133
2134* `submitterDid`: String - \(Optional\) DID of the read request sender \(if not provided then default Libindy DID will be used\).
2135* `txnType`: String - target ledger transaction alias or associated value.
2136* `action`: String - target action type. Can be either "ADD" or "EDIT".
2137* `field`: String - target transaction field.
2138* `oldValue`: String - \(Optional\) old value of field, which can be changed to a new_value (mandatory for EDIT action).
2139* `newValue`: String - \(Optional\) new value that can be used to fill the field.
2140
2141* __->__ `request`: Json
2142
2143Errors: `Common*`
2144
2145#### buildTxnAuthorAgreementRequest \( submitterDid, text, version, ratificationTimestamp, retirementTimestamp \) -&gt; request
2146
2147Builds a TXN_AUTHR_AGRMT request.
2148Request to add a new version of Transaction Author Agreement to the ledger.
2149
2150EXPERIMENTAL
2151
2152* `submitterDid`: String - Identifier (DID) of the transaction author as base58-encoded string.
2153 Actual request sender may differ if Endorser is used (look at `appendRequestEndorser`)
2154* `text`: String - \(Optional\) a content of the TTA.
2155 * Mandatory in case of adding a new TAA. An existing TAA text can not be changed.
2156 * for Indy Node version <= 1.12.0:
2157 * Use empty string to reset TAA on the ledger
2158 * for Indy Node version > 1.12.0
2159 * Should be omitted in case of updating an existing TAA (setting `retirementTimestamp`)
2160* `version`: String - a version of the TTA (unique UTF-8 string).
2161* `version`: String - the date (timestamp) of TAA ratification by network government.
2162* `ratificationTimestamp`: Number - \(Optional\) Еhe date (timestamp) of TAA ratification by network government.
2163 * for Indy Node version <= 1.12.0:
2164 * Must be omitted
2165 * for Indy Node version > 1.12.0:
2166 * Must be specified in case of adding a new TAA
2167 * Can be omitted in case of updating an existing TAA
2168* `retirementTimestamp`: Number - \(Optional\) the date \(timestamp\) of TAA retirement.
2169 * for Indy Node version <= 1.12.0:
2170 * Must be omitted
2171 * for Indy Node version > 1.12.0:
2172 * Must be omitted in case of adding a new (latest) TAA.
2173 * Should be used for updating (deactivating) non-latest TAA on the ledger.
2174
2175Note: Use `buildDisableAllTxnAuthorAgreementsRequest` to disable all TAA's on the ledger.
2176
2177* __->__ `request`: Json
2178
2179Errors: `Common*`
2180
2181#### buildDisableAllTxnAuthorAgreementsRequest \( submitterDid \) -&gt; request
2182
2183Builds a DISABLE_ALL_TXN_AUTHR_AGRMTS request.
2184Request to disable all Transaction Author Agreement on the ledger.
2185
2186EXPERIMENTAL
2187
2188* `submitterDid`: String - Identifier (DID) of the transaction author as base58-encoded string.
2189 Actual request sender may differ if Endorser is used (look at `appendRequestEndorser`)
2190
2191* __->__ `request`: Json
2192
2193Errors: `Common*`
2194
2195
2196#### buildGetTxnAuthorAgreementRequest \( submitterDid, data \) -&gt; request
2197
2198Builds a GET_TXN_AUTHR_AGRMT request.
2199Request to get a specific Transaction Author Agreement from the ledger.
2200
2201EXPERIMENTAL
2202
2203* `submitterDid`: String - \(Optional\) DID of the read request sender \(if not provided then default Libindy DID will be used\).
2204* `data`: Json - \(Optional\) specifies a condition for getting specific TAA.
2205Contains 3 mutually exclusive optional fields:
2206```
2207{
2208 hash: Optional<str> - hash of requested TAA,
2209 version: Optional<str> - version of requested TAA.
2210 timestamp: Optional<u64> - ledger will return TAA valid at requested timestamp.
2211}
2212```
2213Null data or empty JSON are acceptable here. In this case, ledger will return the latest version of TAA.
2214
2215* __->__ `request`: Json
2216
2217Errors: `Common*`
2218
2219#### buildAcceptanceMechanismsRequest \( submitterDid, aml, version, amlContext \) -&gt; request
2220
2221Builds a SET_TXN_AUTHR_AGRMT_AML request.
2222Request to add a new list of acceptance mechanisms for transaction author agreement.
2223Acceptance Mechanism is a description of the ways how the user may accept a transaction author agreement.
2224
2225EXPERIMENTAL
2226
2227* `submitterDid`: String - Identifier (DID) of the transaction author as base58-encoded string.
2228 Actual request sender may differ if Endorser is used (look at `appendRequestEndorser`)
2229* `aml`: Json - a set of new acceptance mechanisms:
2230```
2231{
2232<acceptance mechanism label 1>”: { acceptance mechanism description 1},
2233<acceptance mechanism label 2>”: { acceptance mechanism description 2},
2234 ...
2235}
2236```
2237* `version`: String - a version of new acceptance mechanisms. (Note: unique on the Ledger).
2238* `amlContext`: String - \(Optional\) common context information about acceptance mechanisms (may be a URL to external resource).
2239
2240* __->__ `request`: Json
2241
2242Errors: `Common*`
2243
2244#### buildGetAcceptanceMechanismsRequest \( submitterDid, timestamp \) -&gt; request
2245
2246Builds a GET_TXN_AUTHR_AGRMT_AML request.
2247Request to get a list of acceptance mechanisms from the ledger valid for specified time or the latest one.
2248
2249EXPERIMENTAL
2250
2251* `submitterDid`: String - \(Optional\) DID of the read request sender \(if not provided then default Libindy DID will be used\).
2252* `timestamp`: Timestamp (Number) - \(Optional\) time to get an active acceptance mechanisms. The latest one will be returned for null.
2253* `version`: Timestamp (String) - \(Optional\) version of acceptance mechanisms.
2254
2255NOTE: timestamp and version cannot be specified together.
2256
2257* __->__ `request`: Json
2258
2259Errors: `Common*`
2260
2261#### appendTxnAuthorAgreementAcceptanceToRequest \( requestJson, text, version, taaDigest, accMechType, timeOfAcceptance \) -&gt; request
2262
2263Append transaction author agreement acceptance data to a request.
2264This function should be called before signing and sending a request
2265if there is any transaction author agreement set on the Ledger.
2266
2267EXPERIMENTAL
2268
2269This function may calculate hash by itself or consume it as a parameter.
2270If all text, version and taaDigest parameters are specified, a check integrity of them will be done.
2271
2272* `requestJson`: Json - original request data json.
2273* `text`: String - \(Optional\) raw data about TAA from ledger.
2274* `version`: String - \(Optional\) raw data about TAA from ledger.
2275 * `text` and `version` parameters should be passed together.
2276 * `text` and `version` parameters are required if taaDigest parameter is omitted.
2277* `taaDigest`: String - \(Optional\) hash on text and version. Digest is sha256 hash calculated on concatenated strings: version || text. This parameter is required if text and version parameters are omitted.
2278* `accMechType`: String - mechanism how user has accepted the TAA.
2279* `timeOfAcceptance`: Timestamp (Number) - UTC timestamp when user has accepted the TAA. Note that the time portion will be discarded to avoid a privacy risk.
2280
2281* __->__ `request`: Json
2282
2283Errors: `Common*`
2284
2285#### appendRequestEndorser \( requestJson, endorserDid \) -&gt; request
2286
2287Append Endorser to an existing request.
2288
2289An author of request still is a `DID` used as a `submitter_did` parameter for the building of the request.
2290But it is expecting that the transaction will be sent by the specified Endorser.
2291
2292Note: Both Transaction Author and Endorser must sign output request after that.
2293
2294More about Transaction Endorser: https://github.com/hyperledger/indy-node/blob/master/design/transaction_endorser.md
2295 https://github.com/hyperledger/indy-sdk/blob/master/docs/configuration.md
2296
2297* `requestJson`: Json - original request data json.
2298* `endorser_did`: String - DID of the Endorser that will submit the transaction.
2299 The Endorser's DID must be present on the ledger.
2300
2301* __->__ `request`: Json
2302
2303Errors: `Common*`
2304
2305#### getResponseMetadata \( response \) -&gt; responseMetadata
2306
2307Parse transaction response to fetch metadata.
2308The important use case for this method is validation of Node's response freshens.
2309
2310Distributed Ledgers can reply with outdated information for consequence read request after write.
2311To reduce pool load libindy sends read requests to one random node in the pool.
2312Consensus validation is performed based on validation of nodes multi signature for current ledger Merkle Trie root.
2313This multi signature contains information about the latest ldeger's transaction ordering time and sequence number that this method returns.
2314
2315If node that returned response for some reason is out of consensus and has outdated ledger
2316it can be caught by analysis of the returned latest ledger's transaction ordering time and sequence number.
2317
2318There are two ways to filter outdated responses:
23191\) based on "seqNo" - sender knows the sequence number of transaction that he consider as a fresh enough.
23202\) based on "txnTime" - sender knows the timestamp that he consider as a fresh enough.
2321
2322Note: response of GET\_VALIDATOR\_INFO request isn't supported
2323
2324* `response`: Json - response of write or get request.
2325* __->__ `responseMetadata`: Json - response metadata.
2326```
2327{
2328 "seqNo": Option<u64> - transaction sequence number,
2329 "txnTime": Option<u64> - transaction ordering time,
2330 "lastSeqNo": Option<u64> - the latest transaction seqNo for particular Node,
2331 "lastTxnTime": Option<u64> - the latest transaction ordering time for particular Node
2332}
2333````
2334
2335Errors: `Common*`, `Ledger*`
2336
2337### non_secrets
2338
2339#### addWalletRecord \( wh, type, id, value, tags \) -&gt; void
2340
2341Create a new non-secret record in the wallet
2342
2343* `wh`: Handle (Number) - wallet handle (created by openWallet)
2344* `type`: String - allows to separate different record types collections
2345* `id`: String - the id of record
2346* `value`: String - the value of record
2347* `tags`: Json - \(optional\) the record tags used for search and storing meta information as json:
2348```
2349 {
2350 "tagName1": <str>, // string tag (will be stored encrypted)
2351 "tagName2": <str>, // string tag (will be stored encrypted)
2352 "~tagName3": <str>, // string tag (will be stored un-encrypted)
2353 "~tagName4": <str>, // string tag (will be stored un-encrypted)
2354 }
2355 Note that null means no tags
2356 If tag name starts with "~" the tag will be stored un-encrypted that will allow
2357 usage of this tag in complex search queries (comparison, predicates)
2358 Encrypted tags can be searched only for exact matching
2359````
2360* __->__ void
2361
2362
2363#### updateWalletRecordValue \( wh, type, id, value \) -&gt; void
2364
2365Update a non-secret wallet record value
2366
2367* `wh`: Handle (Number) - wallet handle (created by openWallet)
2368* `type`: String - allows to separate different record types collections
2369* `id`: String - the id of record
2370* `value`: String - the new value of record
2371* __->__ void
2372
2373
2374#### updateWalletRecordTags \( wh, type, id, tags \) -&gt; void
2375
2376Update a non-secret wallet record tags
2377
2378* `wh`: Handle (Number) - wallet handle (created by openWallet)
2379* `type`: String - allows to separate different record types collections
2380* `id`: String - the id of record
2381* `tags`: Json - the record tags used for search and storing meta information as json:
2382```
2383 {
2384 "tagName1": <str>, // string tag (will be stored encrypted)
2385 "tagName2": <str>, // string tag (will be stored encrypted)
2386 "~tagName3": <str>, // string tag (will be stored un-encrypted)
2387 "~tagName4": <str>, // string tag (will be stored un-encrypted)
2388 }
2389 If tag name starts with "~" the tag will be stored un-encrypted that will allow
2390 usage of this tag in complex search queries (comparison, predicates)
2391 Encrypted tags can be searched only for exact matching
2392````
2393* __->__ void
2394
2395
2396#### addWalletRecordTags \( wh, type, id, tags \) -&gt; void
2397
2398Add new tags to the wallet record
2399
2400* `wh`: Handle (Number) - wallet handle (created by openWallet)
2401* `type`: String - allows to separate different record types collections
2402* `id`: String - the id of record
2403* `tags`: Json - the record tags used for search and storing meta information as json:
2404```
2405 {
2406 "tagName1": <str>, // string tag (will be stored encrypted)
2407 "tagName2": <str>, // string tag (will be stored encrypted)
2408 "~tagName3": <str>, // string tag (will be stored un-encrypted)
2409 "~tagName4": <str>, // string tag (will be stored un-encrypted)
2410 }
2411 If tag name starts with "~" the tag will be stored un-encrypted that will allow
2412 usage of this tag in complex search queries (comparison, predicates)
2413 Encrypted tags can be searched only for exact matching
2414 Note if some from provided tags already assigned to the record than
2415 corresponding tags values will be replaced
2416````
2417* __->__ void
2418
2419
2420#### deleteWalletRecordTags \( wh, type, id, tagNames \) -&gt; void
2421
2422Delete tags from the wallet record
2423
2424* `wh`: Handle (Number) - wallet handle (created by openWallet)
2425* `type`: String - allows to separate different record types collections
2426* `id`: String - the id of record
2427* `tagNames`: Json - the list of tag names to remove from the record as json array:
2428\["tagName1", "tagName2", ...\]
2429* __->__ void
2430
2431
2432#### deleteWalletRecord \( wh, type, id \) -&gt; void
2433
2434Delete an existing wallet record in the wallet
2435
2436* `wh`: Handle (Number) - wallet handle (created by openWallet)
2437* `type`: String - record type
2438* `id`: String - the id of record
2439* __->__ void
2440
2441
2442#### getWalletRecord \( wh, type, id, options \) -&gt; record
2443
2444Get an wallet record by id
2445
2446* `wh`: Handle (Number) - wallet handle (created by openWallet)
2447* `type`: String - allows to separate different record types collections
2448* `id`: String - the id of record
2449* `options`: Json - \/\/TODO: FIXME: Think about replacing by bitmask
2450```
2451 {
2452 retrieveType: (optional, false by default) Retrieve record type,
2453 retrieveValue: (optional, true by default) Retrieve record value,
2454 retrieveTags: (optional, false by default) Retrieve record tags
2455 }
2456````
2457* __->__ `record`: Json - wallet record json:
2458```
2459{
2460 id: "Some id",
2461 type: "Some type", // present only if retrieveType set to true
2462 value: "Some value", // present only if retrieveValue set to true
2463 tags: <tags json>, // present only if retrieveTags set to true
2464}
2465````
2466
2467
2468#### openWalletSearch \( wh, type, query, options \) -&gt; sh
2469
2470Search for wallet records.
2471
2472Note instead of immediately returning of fetched records
2473this call returns wallet\_search\_handle that can be used later
2474to fetch records by small batches \(with fetchWalletSearchNextRecords\).
2475
2476* `wh`: Handle (Number) - wallet handle (created by openWallet)
2477* `type`: String - allows to separate different record types collections
2478* `query`: Json - MongoDB style query to wallet record tags:
2479```
2480 {
2481 "tagName": "tagValue",
2482 $or:
2483{
2484 "tagName2": { $regex: 'pattern' },
2485 "tagName3": { $gte: '123' },
2486 },
2487 }
2488````
2489* `options`: Json - \/\/TODO: FIXME: Think about replacing by bitmask
2490```
2491 {
2492 retrieveRecords: (optional, true by default) If false only "counts" will be calculated,
2493 retrieveTotalCount: (optional, false by default) Calculate total count,
2494 retrieveType: (optional, false by default) Retrieve record type,
2495 retrieveValue: (optional, true by default) Retrieve record value,
2496 retrieveTags: (optional, false by default) Retrieve record tags,
2497 }
2498````
2499* __->__ `sh`: Handle (Number) - search\_handle: Wallet search handle that can be used later
2500to fetch records by small batches \(with fetchWalletSearchNextRecords\)
2501
2502
2503#### fetchWalletSearchNextRecords \( wh, walletSearchHandle, count \) -&gt; records
2504
2505Fetch next records for wallet search.
2506
2507Not if there are no records this call returns WalletNoRecords error.
2508
2509* `wh`: Handle (Number) - wallet handle (created by openWallet)
2510* `walletSearchHandle`: Handle (Number) - wallet search handle \(created by openWalletSearch\)
2511* `count`: Number - Count of records to fetch
2512* __->__ `records`: Json - wallet records json:
2513```
2514{
2515 totalCount: <str>, // present only if retrieveTotalCount set to true
2516 records: [{ // present only if retrieveRecords set to true
2517 id: "Some id",
2518 type: "Some type", // present only if retrieveType set to true
2519 value: "Some value", // present only if retrieveValue set to true
2520 tags: <tags json>, // present only if retrieveTags set to true
2521 }],
2522}
2523````
2524
2525
2526#### closeWalletSearch \( walletSearchHandle \) -&gt; void
2527
2528Close wallet search \(make search handle invalid\)
2529
2530* `walletSearchHandle`: Handle (Number) - wallet search handle
2531* __->__ void
2532
2533
2534### pairwise
2535
2536#### isPairwiseExists \( wh, theirDid \) -&gt; exists
2537
2538Check if pairwise is exists.
2539
2540* `wh`: Handle (Number) - wallet handle (created by openWallet)
2541* `theirDid`: String - encrypted DID
2542* __->__ `exists`: Boolean - exists: true - if pairwise is exists, false - otherwise
2543
2544Errors: `Common*`, `Wallet*`
2545
2546#### createPairwise \( wh, theirDid, myDid, metadata \) -&gt; void
2547
2548Creates pairwise.
2549
2550* `wh`: Handle (Number) - wallet handle (created by openWallet)
2551* `theirDid`: String - encrypted DID
2552* `myDid`: String - encrypted DID
2553metadata Optional: extra information for pairwise
2554* `metadata`: String
2555* __->__ void
2556
2557Errors: `Common*`, `Wallet*`
2558
2559#### listPairwise \( wh \) -&gt; listPairwise
2560
2561Get list of saved pairwise.
2562
2563* `wh`: Handle (Number) - wallet handle (created by openWallet)
2564* __->__ `listPairwise`: Json - list\_pairwise: list of saved pairwise
2565
2566Errors: `Common*`, `Wallet*`
2567
2568#### getPairwise \( wh, theirDid \) -&gt; pairwiseInfo
2569
2570Gets pairwise information for specific their\_did.
2571
2572* `wh`: Handle (Number) - wallet handle (created by openWallet)
2573* `theirDid`: String - encoded Did
2574* __->__ `pairwiseInfo`: Json - pairwise\_info\_json: did info associated with their did
2575
2576Errors: `Common*`, `Wallet*`
2577
2578#### setPairwiseMetadata \( wh, theirDid, metadata \) -&gt; void
2579
2580Save some data in the Wallet for pairwise associated with Did.
2581
2582* `wh`: Handle (Number) - wallet handle (created by openWallet)
2583* `theirDid`: String - encoded Did
2584* `metadata`: String - some extra information for pairwise
2585* __->__ void
2586
2587Errors: `Common*`, `Wallet*`
2588
2589### payment
2590
2591#### createPaymentAddress \( wh, paymentMethod, config \) -&gt; paymentAddress
2592
2593Create the payment address for specified payment method
2594
2595
2596This method generates private part of payment address
2597and stores it in a secure place. Ideally it should be
2598secret in libindy wallet \(see crypto module\).
2599
2600Note that payment method should be able to resolve this
2601secret by fully resolvable payment address format.
2602
2603* `wh`: Handle (Number) - wallet handle (created by openWallet)
2604* `paymentMethod`: String - payment method to use \(for example, 'sov'\)
2605* `config`: Json - payment address config as json:
2606```
2607 {
2608 seed: <str>, // allows deterministic creation of payment address
2609 }
2610````
2611* __->__ `paymentAddress`: String - payment\_address - public identifier of payment address in fully resolvable payment address format
2612
2613
2614#### listPaymentAddresses \( wh \) -&gt; paymentAddresses
2615
2616Lists all payment addresses that are stored in the wallet
2617
2618* `wh`: Handle (Number) - wallet handle (created by openWallet)
2619* __->__ `paymentAddresses`: Json - payment\_addresses\_json - json array of string with json addresses
2620
2621
2622#### addRequestFees \( wh, submitterDid, req, inputs, outputs, extra \) -&gt; \[ reqWithFees, paymentMethod \]
2623
2624Modifies Indy request by adding information how to pay fees for this transaction
2625according to this payment method.
2626
2627This method consumes set of inputs and outputs. The difference between inputs balance
2628and outputs balance is the fee for this transaction.
2629
2630Not that this method also produces correct fee signatures.
2631
2632Format of inputs is specific for payment method. Usually it should reference payment transaction
2633with at least one output that corresponds to payment address that user owns.
2634
2635* `wh`: Handle (Number) - wallet handle (created by openWallet)
2636* `submitterDid`: String - \(Optional\) DID of request sender
2637* `req`: Json - initial transaction request as json
2638* `inputs`: Json - The list of payment sources as json array:
2639\["source1", ...\]
2640- each input should reference paymentAddress
2641- this param will be used to determine payment\_method
2642* `outputs`: Json - The list of outputs as json array:
2643```
2644 [{
2645 recipient: <str>, // payment address of recipient
2646 amount: <int>, // amount
2647 }]
2648````
2649* `extra`: String - \/\/ optional information for payment operation
2650* __->__ [ `reqWithFees`: Json, `paymentMethod`: String ] - req\_with\_fees\_json - modified Indy request with added fees info
2651payment\_method - used payment method
2652
2653
2654#### parseResponseWithFees \( paymentMethod, resp \) -&gt; receipts
2655
2656Parses response for Indy request with fees.
2657
2658* `paymentMethod`: String - payment method to use
2659* `resp`: Json - response for Indy request with fees
2660* __->__ `receipts`: Json - receipts\_json - parsed \(payment method and node version agnostic\) receipts info as json:
2661```
2662 [{
2663 receipt: <str>, // receipt that can be used for payment referencing and verification
2664 recipient: <str>, //payment address of recipient
2665 amount: <int>, // amount
2666 extra: <str>, // optional data from payment transaction
2667 }]
2668````
2669
2670
2671#### buildGetPaymentSourcesRequest \( wh, submitterDid, paymentAddress \) -&gt; \[ getSourcesTxn, paymentMethod \]
2672
2673Builds Indy request for getting sources list for payment address
2674according to this payment method.
2675
2676* `wh`: Handle (Number) - wallet handle (created by openWallet)
2677* `submitterDid`: String - \(Optional\) DID of request sender
2678* `paymentAddress`: String - target payment address
2679* __->__ [ `getSourcesTxn`: Json, `paymentMethod`: String ] - get\_sources\_txn\_json - Indy request for getting sources list for payment address
2680payment\_method - used payment method
2681
2682
2683#### parseGetPaymentSourcesResponse \( paymentMethod, resp \) -&gt; sources
2684
2685Parses response for Indy request for getting sources list.
2686
2687* `paymentMethod`: String - payment method to use.
2688* `resp`: Json - response for Indy request for getting sources list
2689* __->__ `sources`: Json - sources\_json - parsed \(payment method and node version agnostic\) sources info as json:
2690```
2691 [{
2692 source: <str>, // source input
2693 paymentAddress: <str>, //payment address for this source
2694 amount: <int>, // amount
2695 extra: <str>, // optional data from payment transaction
2696 }]
2697````
2698
2699
2700#### buildPaymentReq \( wh, submitterDid, inputs, outputs, extra \) -&gt; \[ paymentReq, paymentMethod \]
2701
2702Builds Indy request for doing payment
2703according to this payment method.
2704
2705This method consumes set of inputs and outputs.
2706
2707Format of inputs is specific for payment method. Usually it should reference payment transaction
2708with at least one output that corresponds to payment address that user owns.
2709
2710* `wh`: Handle (Number) - wallet handle (created by openWallet)
2711* `submitterDid`: String - \(Optional\) DID of request sender
2712* `inputs`: Json - The list of payment sources as json array:
2713\["source1", ...\]
2714Note that each source should reference payment address
2715* `outputs`: Json - The list of outputs as json array:
2716```
2717 [{
2718 recipient: <str>, // payment address of recipient
2719 amount: <int>, // amount
2720 }]
2721````
2722* `extra`: String - \/\/ optional information for payment operation
2723* __->__ [ `paymentReq`: Json, `paymentMethod`: String ] - payment\_req\_json - Indy request for doing payment
2724payment\_method - used payment method
2725
2726
2727#### parsePaymentResponse \( paymentMethod, resp \) -&gt; receipts
2728
2729Parses response for Indy request for payment txn.
2730
2731* `paymentMethod`: String - payment method to use
2732* `resp`: Json - response for Indy request for payment txn
2733* __->__ `receipts`: Json - receipts\_json - parsed \(payment method and node version agnostic\) receipts info as json:
2734```
2735 [{
2736 receipt: <str>, // receipt that can be used for payment referencing and verification
2737 recipient: <str>, // payment address of recipient
2738 amount: <int>, // amount
2739 extra: <str>, // optional data from payment transaction
2740 }]
2741````
2742
2743#### preparePaymentExtraWithAcceptanceData \( extraJson, text, version, taaDigest, accMechType, timeOfAcceptance \) -&gt; request
2744
2745Append payment extra JSON with TAA acceptance data
2746
2747EXPERIMENTAL
2748
2749This function may calculate hash by itself or consume it as a parameter.
2750If all text, version and taaDigest parameters are specified, a check integrity of them will be done.
2751
2752* `extraJson`: Json - \(Optional\) original extra json.
2753* `text`: String - \(Optional\) raw data about TAA from ledger.
2754* `version`: String - \(Optional\) raw data about TAA from ledger.
2755 * `text` and `version` parameters should be passed together.
2756 * `text` and `version` parameters are required if taaDigest parameter is omitted.
2757* `taaDigest`: String - \(Optional\) hash on text and version. This parameter is required if text and version parameters are omitted.
2758* `accMechType`: String - mechanism how user has accepted the TAA.
2759* `timeOfAcceptance`: Timestamp (Number) - UTC timestamp when user has accepted the TAA.
2760
2761* __->__ `request`: Json
2762
2763Errors: `Common*`
2764
2765#### buildMintReq \( wh, submitterDid, outputs, extra \) -&gt; \[ mintReq, paymentMethod \]
2766
2767Builds Indy request for doing minting
2768according to this payment method.
2769
2770* `wh`: Handle (Number) - wallet handle (created by openWallet)
2771* `submitterDid`: String - \(Optional\) DID of request sender
2772* `outputs`: Json - The list of outputs as json array:
2773```
2774 [{
2775 recipient: <str>, // payment address of recipient
2776 amount: <int>, // amount
2777 }]
2778````
2779* `extra`: String - \/\/ optional information for mint operation
2780* __->__ [ `mintReq`: Json, `paymentMethod`: String ] - mint\_req\_json - Indy request for doing minting
2781payment\_method - used payment method
2782
2783
2784#### buildSetTxnFeesReq \( wh, submitterDid, paymentMethod, fees \) -&gt; setTxnFees
2785
2786Builds Indy request for setting fees for transactions in the ledger
2787
2788* `wh`: Handle (Number) - wallet handle (created by openWallet)
2789* `submitterDid`: String - \(Optional\) DID of request sender
2790* `paymentMethod`: String - payment method to use
2791fees\_json {
2792txnType1: amount1,
2793txnType2: amount2,
2794.................
2795txnTypeN: amountN,
2796}
2797* `fees`: Json
2798* __->__ `setTxnFees`: Json - set\_txn\_fees\_json - Indy request for setting fees for transactions in the ledger
2799
2800
2801#### buildGetTxnFeesReq \( wh, submitterDid, paymentMethod \) -&gt; getTxnFees
2802
2803Builds Indy get request for getting fees for transactions in the ledger
2804
2805* `wh`: Handle (Number) - wallet handle (created by openWallet)
2806* `submitterDid`: String - \(Optional\) DID of request sender
2807* `paymentMethod`: String - payment method to use
2808* __->__ `getTxnFees`: Json - get\_txn\_fees\_json - Indy request for getting fees for transactions in the ledger
2809
2810
2811#### parseGetTxnFeesResponse \( paymentMethod, resp \) -&gt; fees
2812
2813Parses response for Indy request for getting fees
2814
2815* `paymentMethod`: String - payment method to use
2816* `resp`: Json - response for Indy request for getting fees
2817* __->__ `fees`: Json - fees\_json {
2818txnType1: amount1,
2819txnType2: amount2,
2820.................
2821txnTypeN: amountN,
2822}
2823
2824
2825#### buildVerifyPaymentReq \( wh, submitterDid, receipt \) -&gt; \[ verifyTxn, paymentMethod \]
2826
2827Builds Indy request for information to verify the payment receipt
2828
2829* `wh`: Handle (Number) - wallet handle (created by openWallet)
2830* `submitterDid`: String - \(Optional\) DID of request sender
2831* `receipt`: String - payment receipt to verify
2832* __->__ [ `verifyTxn`: Json, `paymentMethod`: String ] - verify\_txn\_json: Indy request for verification receipt
2833payment\_method: used payment method
2834
2835
2836#### parseVerifyPaymentResponse \( paymentMethod, resp \) -&gt; txn
2837
2838Parses Indy response with information to verify receipt
2839
2840* `paymentMethod`: String - payment method to use
2841* `resp`: Json - response of the ledger for verify txn
2842* __->__ `txn`: Json - txn\_json: {
2843sources: \[&lt;str&gt;, \]
2844receipts: \[ {
2845recipient: &lt;str&gt;, \/\/ payment address of recipient
2846receipt: &lt;str&gt;, \/\/ receipt that can be used for payment referencing and verification
2847amount: &lt;int&gt;, \/\/ amount
2848} \],
2849extra: &lt;str&gt;, \/\/optional data
2850}
2851
2852#### getRequestInfo \( getAuthRuleResponse, requesterInfo, fees \) -&gt; requestInfo
2853
2854Gets request requirements (with minimal price) correspondent to specific auth rule
2855in case the requester can perform this action.
2856
2857*EXPERIMENTAL*
2858
2859If the requester does not match to the request constraints `TransactionNotAllowed` error will be thrown.
2860
2861* `getAuthRuleResponse`: String - response on GET_AUTH_RULE request returning action constraints set on the ledger.
2862* `requesterInfo`: Json:
2863```
2864{
2865 "role": string (optional) - role of a user which can sign a transaction.
2866 "sig_count": u64 - number of signers.
2867 "is_owner": bool (optional) - if user is an owner of transaction (false by default).
2868 "is_off_ledger_signature": bool (optional) - if user did is unknow for ledger (false by default).
2869}
2870```
2871* `fees`: Json - fees set on the ledger (result of `parseGetTxnFeesResponse`).
2872* __->__ `requestInfo`: Json - request info if a requester match to the action constraints.
2873```
2874{
2875 "price": u64 - fee required for the action performing,
2876 "requirements": [{
2877 "role": string (optional) - role of users who should sign,
2878 "sig_count": u64 - number of signers,
2879 "need_to_be_owner": bool - if requester need to be owner,
2880 "off_ledger_signature": bool - allow signature of unknow for ledger did (false by default).
2881 }]
2882}
2883```
2884
2885Errors: `Common*`, `Ledger*`
2886
2887#### signWithAddress \( wh, address, message \) -&gt; signature
2888
2889Signs a message with a payment address.
2890
2891* `wh`: Handle (Number) - wallet handle (created by openWallet)
2892* `address`: String - payment address of message signer. The key must be created by calling createPaymentAddress
2893* `message`: Buffer - a pointer to first byte of message to be signed
2894* __->__ `signature`: Buffer - a signature string
2895
2896Errors: `Common*`, `Wallet*`, `Payment*`
2897
2898#### verifyWithAddress \( address, message, signature \) -&gt; valid
2899
2900Verify a signature with a payment address.
2901
2902* `address`: String - payment address of the message signer
2903* `message`: Buffer - a pointer to first byte of message that has been signed
2904* `signature`: Buffer - a pointer to first byte of signature to be verified
2905* __->__ `valid`: Boolean - valid: true - if signature is valid, false - otherwise
2906
2907Errors: `Common*`, `Wallet*`, `Payment*`
2908
2909
2910### pool
2911
2912#### createPoolLedgerConfig \( configName, config \) -&gt; void
2913
2914Creates a new local pool ledger configuration that can be used later to connect pool nodes.
2915
2916* `configName`: String - Name of the pool ledger configuration.
2917* `config`: Json? - Pool configuration json. if NULL, then default config will be used. Example:
2918```
2919{
2920 "genesis_txn": string (optional), A path to genesis transaction file. If NULL, then a default one will be used.
2921 If file doesn't exists default one will be created.
2922}
2923````
2924* __->__ void
2925
2926Errors: `Common*`, `Ledger*`
2927
2928#### openPoolLedger \( configName, config \) -&gt; poolHandle
2929
2930Opens pool ledger and performs connecting to pool nodes.
2931
2932Pool ledger configuration with corresponded name must be previously created
2933with createPoolLedgerConfig method.
2934It is impossible to open pool with the same name more than once.
2935
2936config\_name: Name of the pool ledger configuration.
2937config \(optional\): Runtime pool configuration json.
2938if NULL, then default config will be used. Example:
2939```
2940{
2941 "timeout": int (optional), timeout for network request (in sec).
2942 "extended_timeout": int (optional), extended timeout for network request (in sec).
2943 "preordered_nodes": array<string> - (optional), names of nodes which will have a priority during request sending:
2944 ["name_of_1st_prior_node", "name_of_2nd_prior_node", .... ]
2945 This can be useful if a user prefers querying specific nodes.
2946 Assume that `Node1` and `Node2` nodes reply faster.
2947 If you pass them Libindy always sends a read request to these nodes first and only then (if not enough) to others.
2948 Note: Nodes not specified will be placed randomly.
2949 "number_read_nodes": int (optional) - the number of nodes to send read requests (2 by default)
2950 By default Libindy sends a read requests to 2 nodes in the pool.
2951 If response isn't received or `state proof` is invalid Libindy sends the request again but to 2 (`number_read_nodes`) * 2 = 4 nodes and so far until completion.
2952}
2953````
2954
2955* `configName`: String
2956* `config`: Json
2957* __->__ `poolHandle`: Handle (Number) - Handle to opened pool to use in methods that require pool connection.
2958
2959Errors: `Common*`, `Ledger*`
2960
2961#### refreshPoolLedger \( handle \) -&gt; void
2962
2963Refreshes a local copy of a pool ledger and updates pool nodes connections.
2964
2965* `handle`: Handle (Number) - pool handle returned by openPoolLedger
2966* __->__ void
2967
2968Errors: `Common*`, `Ledger*`
2969
2970#### listPools \( \) -&gt; pools
2971
2972Lists names of created pool ledgers
2973
2974* __->__ `pools`: Json
2975
2976
2977#### closePoolLedger \( handle \) -&gt; void
2978
2979Closes opened pool ledger, opened nodes connections and frees allocated resources.
2980
2981* `handle`: Handle (Number) - pool handle returned by openPoolLedger.
2982* __->__ void
2983
2984Errors: `Common*`, `Ledger*`
2985
2986#### deletePoolLedgerConfig \( configName \) -&gt; void
2987
2988Deletes created pool ledger configuration.
2989
2990* `configName`: String - Name of the pool ledger configuration to delete.
2991* __->__ void
2992
2993Errors: `Common*`, `Ledger*`
2994
2995#### setProtocolVersion \( protocolVersion \) -&gt; void
2996
2997Set PROTOCOL\_VERSION to specific version.
2998
2999There is a global property PROTOCOL\_VERSION that used in every request to the pool and
3000specified version of Indy Node which Libindy works.
3001
3002By default PROTOCOL\_VERSION=1.
3003
3004* `protocolVersion`: Number - Protocol version will be used:
30051 - for Indy Node 1.3
30062 - for Indy Node 1.4 and greater
3007* __->__ void
3008
3009Errors: `Common*`
3010
3011### wallet
3012
3013#### createWallet \( config, credentials \) -&gt; void
3014
3015Create a new secure wallet.
3016
3017* `config`: Json - Wallet configuration json.
3018```
3019{
3020 "id": string, Identifier of the wallet.
3021 Configured storage uses this identifier to lookup exact wallet data placement.
3022 "storage_type": optional<string>, Type of the wallet storage. Defaults to 'default'.
3023 'Default' storage type allows to store wallet data in the local file.
3024 Custom storage types can be registered with indy_register_wallet_storage call.
3025 "storage_config": optional<object>, Storage configuration json. Storage type defines set of supported keys.
3026 Can be optional if storage supports default configuration.
3027 For 'default' storage type configuration is:
3028 {
3029 "path": optional<string>, Path to the directory with wallet files.
3030 Defaults to $HOME/.indy_client/wallet.
3031 Wallet will be stored in the file {path}/{id}/sqlite.db
3032 }
3033}
3034````
3035* `credentials`: Json - Wallet credentials json
3036```
3037{
3038 "key": string, Key or passphrase used for wallet key derivation.
3039 Look to key_derivation_method param for information about supported key derivation methods.
3040 "storage_credentials": optional<object> Credentials for wallet storage. Storage type defines set of supported keys.
3041 Can be optional if storage supports default configuration.
3042 For 'default' storage type should be empty.
3043 "key_derivation_method": optional<string> Algorithm to use for wallet key derivation:
3044 ARGON2I_MOD - derive secured wallet master key (used by default)
3045 ARGON2I_INT - derive secured wallet master key (less secured but faster)
3046 RAW - raw wallet key master provided (skip derivation).
3047 RAW keys can be generated with generateWalletKey call
3048}
3049````
3050* __->__ void
3051
3052Errors: `Common*`, `Wallet*`
3053
3054#### openWallet \( config, credentials \) -&gt; handle
3055
3056Open the wallet.
3057
3058Wallet must be previously created with createWallet method.
3059
3060* `config`: Json - Wallet configuration json.
3061```
3062 {
3063 "id": string, Identifier of the wallet.
3064 Configured storage uses this identifier to lookup exact wallet data placement.
3065 "storage_type": optional<string>, Type of the wallet storage. Defaults to 'default'.
3066 'Default' storage type allows to store wallet data in the local file.
3067 Custom storage types can be registered with indy_register_wallet_storage call.
3068 "storage_config": optional<object>, Storage configuration json. Storage type defines set of supported keys.
3069 Can be optional if storage supports default configuration.
3070 For 'default' storage type configuration is:
3071 {
3072 "path": optional<string>, Path to the directory with wallet files.
3073 Defaults to $HOME/.indy_client/wallet.
3074 Wallet will be stored in the file {path}/{id}/sqlite.db
3075 }
3076 }
3077````
3078* `credentials`: Json - Wallet credentials json
3079```
3080 {
3081 "key": string, Key or passphrase used for wallet key derivation.
3082 Look to key_derivation_method param for information about supported key derivation methods.
3083 "rekey": optional<string>, If present than wallet master key will be rotated to a new one.
3084 "storage_credentials": optional<object> Credentials for wallet storage. Storage type defines set of supported keys.
3085 Can be optional if storage supports default configuration.
3086 For 'default' storage type should be empty.
3087 "key_derivation_method": optional<string> Algorithm to use for wallet key derivation:
3088 ARGON2I_MOD - derive secured wallet master key (used by default)
3089 ARGON2I_INT - derive secured wallet master key (less secured but faster)
3090 RAW - raw wallet key master provided (skip derivation).
3091 RAW keys can be generated with generateWalletKey call
3092 "rekey_derivation_method": optional<string> Algorithm to use for wallet rekey derivation:
3093 ARGON2I_MOD - derive secured wallet master rekey (used by default)
3094 ARGON2I_INT - derive secured wallet master rekey (less secured but faster)
3095 RAW - raw wallet rekey master provided (skip derivation).
3096 RAW keys can be generated with generateWalletKey call
3097 }
3098````
3099* __->__ `handle`: Handle (Number) - err: Error code
3100handle: Handle to opened wallet to use in methods that require wallet access.
3101
3102Errors: `Common*`, `Wallet*`
3103
3104#### exportWallet \( wh, exportConfig \) -&gt; void
3105
3106Exports opened wallet
3107
3108* `wh`: Handle (Number) - wallet handle (created by openWallet)
3109* `exportConfig`: Json
3110* __->__ void
3111
3112Errors: `Common*`, `Wallet*`
3113
3114#### importWallet \( config, credentials, importConfig \) -&gt; void
3115
3116Creates a new secure wallet and then imports its content
3117according to fields provided in import\_config
3118This can be seen as an createWallet call with additional content import
3119
3120* `config`: Json - Wallet configuration json.
3121```
3122{
3123 "id": string, Identifier of the wallet.
3124 Configured storage uses this identifier to lookup exact wallet data placement.
3125 "storage_type": optional<string>, Type of the wallet storage. Defaults to 'default'.
3126 'Default' storage type allows to store wallet data in the local file.
3127 Custom storage types can be registered with indy_register_wallet_storage call.
3128 "storage_config": optional<object>, Storage configuration json. Storage type defines set of supported keys.
3129 Can be optional if storage supports default configuration.
3130 For 'default' storage type configuration is:
3131 {
3132 "path": optional<string>, Path to the directory with wallet files.
3133 Defaults to $HOME/.indy_client/wallet.
3134 Wallet will be stored in the file {path}/{id}/sqlite.db
3135 }
3136}
3137````
3138* `credentials`: Json - Wallet credentials json
3139```
3140{
3141 "key": string, Key or passphrase used for wallet key derivation.
3142 Look to key_derivation_method param for information about supported key derivation methods.
3143 "storage_credentials": optional<object> Credentials for wallet storage. Storage type defines set of supported keys.
3144 Can be optional if storage supports default configuration.
3145 For 'default' storage type should be empty.
3146 "key_derivation_method": optional<string> Algorithm to use for wallet key derivation:
3147 ARGON2I_MOD - derive secured wallet master key (used by default)
3148 ARGON2I_INT - derive secured wallet master key (less secured but faster)
3149 RAW - raw wallet key master provided (skip derivation).
3150 RAW keys can be generated with generateWalletKey call
3151}
3152````
3153* `importConfig`: Json
3154* __->__ void
3155
3156Errors: `Common*`, `Wallet*`
3157
3158#### closeWallet \( wh \) -&gt; void
3159
3160Closes opened wallet and frees allocated resources.
3161
3162* `wh`: Handle (Number) - wallet handle (created by openWallet)
3163* __->__ void
3164
3165Errors: `Common*`, `Wallet*`
3166
3167#### deleteWallet \( config, credentials \) -&gt; void
3168
3169Deletes created wallet.
3170
3171* `config`: Json - Wallet configuration json.
3172```
3173{
3174 "id": string, Identifier of the wallet.
3175 Configured storage uses this identifier to lookup exact wallet data placement.
3176 "storage_type": optional<string>, Type of the wallet storage. Defaults to 'default'.
3177 'Default' storage type allows to store wallet data in the local file.
3178 Custom storage types can be registered with indy_register_wallet_storage call.
3179 "storage_config": optional<object>, Storage configuration json. Storage type defines set of supported keys.
3180 Can be optional if storage supports default configuration.
3181 For 'default' storage type configuration is:
3182 {
3183 "path": optional<string>, Path to the directory with wallet files.
3184 Defaults to $HOME/.indy_client/wallet.
3185 Wallet will be stored in the file {path}/{id}/sqlite.db
3186 }
3187}
3188````
3189* `credentials`: Json - Wallet credentials json
3190```
3191{
3192 "key": string, Key or passphrase used for wallet key derivation.
3193 Look to key_derivation_method param for information about supported key derivation methods.
3194 "storage_credentials": optional<object> Credentials for wallet storage. Storage type defines set of supported keys.
3195 Can be optional if storage supports default configuration.
3196 For 'default' storage type should be empty.
3197 "key_derivation_method": optional<string> Algorithm to use for wallet key derivation:
3198 ARGON2I_MOD - derive secured wallet master key (used by default)
3199 ARGON2I_INT - derive secured wallet master key (less secured but faster)
3200 RAW - raw wallet key master provided (skip derivation).
3201 RAW keys can be generated with generateWalletKey call
3202}
3203````
3204* __->__ void
3205
3206Errors: `Common*`, `Wallet*`
3207
3208#### generateWalletKey \( config \) -&gt; key
3209
3210Generate wallet master key.
3211Returned key is compatible with "RAW" key derivation method.
3212It allows to avoid expensive key derivation for use cases when wallet keys can be stored in a secure enclave.
3213
3214* `config`: Json - \(optional\) key configuration json.
3215```
3216{
3217 "seed": string, (optional) Seed that allows deterministic key creation (if not set random one will be created).
3218 Can be UTF-8, base64 or hex string.
3219}
3220````
3221* __->__ `key`: String - err: Error code
3222
3223Errors: `Common*`, `Wallet*`
3224
3225
3226### logger
3227
3228WARNING: You can only set the logger **once**. Call `setLogger`, `setDefaultLogger`, not both. Once it's been set, libindy won't let you change it.
3229
3230#### setDefaultLogger \( pattern \)
3231
3232Calling this turns on the default logger and libindy will write logs to stdout.
3233
3234* `pattern`: String - pattern that corresponds with the log messages to show.
3235
3236Errors: `Common*`
3237
3238NOTE: This is a synchronous function (does not return a promise.)
3239
3240#### setLogger \( logFn \)
3241
3242Set a function to be called every time a log is emitted from libindy.
3243
3244* `logFn`: Function(Int level, String target, String message, String module_path, String file, Int line)
3245
3246Example:
3247```js
3248indy.setLogger(function (level, target, message, modulePath, file, line) {
3249 console.log('libindy said:', level, target, message, modulePath, file, line)
3250})
3251```
3252
3253Errors: `Common*`
3254
3255NOTE: This is a synchronous function (does not return a promise) but may call `logFn` asynchronously many times.
3256
3257### cache
3258
3259#### getSchema \( poolHandle, wh, submitterDid, id, options \) -&gt; schema
3260
3261Get schema json data for specified schema id.
3262If data is present inside of cache, cached data is returned.
3263Otherwise data is fetched from the ledger and stored inside of cache for future use.
3264
3265EXPERIMENTAL
3266
3267* `poolHandle`:
3268* `wh`: Handle (Number) - wallet handle (created by openWallet)
3269* `submitterDid`: String - DID of the read request sender.
3270* `id`: String - Schema ID in ledger
3271* `options`: Json
3272```
3273 {
3274 noCache: (bool, optional, false by default) Skip usage of cache,
3275 noUpdate: (bool, optional, false by default) Use only cached data, do not try to update.
3276 noStore: (bool, optional, false by default) Skip storing fresh data if updated,
3277 minFresh: (int, optional, -1 by default) Return cached data if not older than this many seconds. -1 means do not check age.
3278 }
3279
3280```
3281__->__ schema: Json
3282```
3283{
3284 id: identifier of schema
3285 attrNames: array of attribute name strings
3286 name: Schema's name string
3287 version: Schema's version string
3288 ver: Version of the Schema json
3289}
3290```
3291
3292Errors: `Common*`, `Wallet*`, `Ledger*`
3293
3294#### getCredDef \( poolHandle, wh, submitterDid, id, options \) -&gt; credDef
3295
3296EXPERIMENTAL
3297
3298Get credential definition json data for specified credential definition id.
3299If data is present inside of cache, cached data is returned.
3300Otherwise data is fetched from the ledger and stored inside of cache for future use.
3301
3302* `poolHandle`:
3303* `wh`: Handle (Number) - wallet handle (created by openWallet)
3304* `submitterDid`: String - DID of the read request sender.
3305* `id`: String - Credential Definition ID in ledger.
3306* `options`: Json
3307```
3308 {
3309 noCache: (bool, optional, false by default) Skip usage of cache,
3310 noUpdate: (bool, optional, false by default) Use only cached data, do not try to update.
3311 noStore: (bool, optional, false by default) Skip storing fresh data if updated,
3312 minFresh: (int, optional, -1 by default) Return cached data if not older than this many seconds. -1 means do not check age.
3313 }
3314
3315```
3316__->__ credDef: Json
3317```
3318{
3319 id: string - identifier of credential definition
3320 schemaId: string - identifier of stored in ledger schema
3321 type: string - type of the credential definition. CL is the only supported type now.
3322 tag: string - allows to distinct between credential definitions for the same issuer and schema
3323 value: Dictionary with Credential Definition's data: {
3324 primary: primary credential public key,
3325 Optional<revocation>: revocation credential public key
3326 },
3327 ver: Version of the Credential Definition json
3328}
3329```
3330
3331Errors: `Common*`, `Wallet*`, `Ledger*`
3332
3333#### purgeSchemaCache \( wh, options \) -&gt; void
3334
3335Purge schema cache.
3336
3337EXPERIMENTAL
3338
3339* `wh`: Handle (Number) - wallet handle (created by openWallet)
3340* `options`: Json
3341```
3342 {
3343 maxAge: (int, optional, -1 by default) Purge cached data if older than this many seconds. -1 means purge all.
3344 }
3345```
3346* __->__ void
3347
3348Errors: `Common*`, `Wallet*`
3349
3350#### purgeCredDefCache \( wh, options \) -&gt; void
3351
3352Purge credential definition cache.
3353
3354EXPERIMENTAL
3355
3356* `wh`: Handle (Number) - wallet handle (created by openWallet)
3357* `options`: Json
3358```
3359 {
3360 maxAge: (int, optional, -1 by default) Purge cached data if older than this many seconds. -1 means purge all.
3361 }
3362```
3363* __->__ void
3364
3365Errors: `Common*`, `Wallet*`
3366
3367### mod
3368
3369#### setRuntimeConfig \( config \)
3370
3371Set libindy runtime configuration. Can be optionally called to change current params.
3372
3373* `config`: Json
3374```
3375{
3376 "crypto_thread_pool_size": Optional<int> - size of thread pool for the most expensive crypto operations. (4 by default)
3377 "collect_backtrace": Optional<bool> - whether errors backtrace should be collected.
3378 Capturing of backtrace can affect library performance.
3379 NOTE: must be set before invocation of any other API functions.
3380}
3381```
3382
3383Errors: `Common*`
3384
3385NOTE: This is a synchronous function (does not return a promise.)
3386
3387## Advanced
3388
3389If you need to get closer to the metal, you can access the node bindings directly.
3390
3391* The function names and parameters are the same.
3392* It will not json stringify or parse for you.
3393* Only callbacks.
3394* Errors are plain numbers for indy error codes.
3395
3396```js
3397var indy = require('indy-sdk')
3398
3399indy.capi.abbreviateVerkey(did, fullVerkey, function(err, verkey){
3400 // err will be 0 on success, and a code number on failure
3401 // verkey will be the result string on success
3402})
3403```
3404
3405## Contributing
3406
3407[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
3408
3409Setup an Indy SDK environment, and start a local pool.
3410
3411 * [ubuntu](https://github.com/hyperledger/indy-sdk/blob/master/docs/ubuntu-build.md)
3412 * [osx](https://github.com/hyperledger/indy-sdk/blob/master/docs/mac-build.md)
3413 * [windows](https://github.com/hyperledger/indy-sdk/blob/master/docs/windows-build.md)
3414
3415```sh
3416# You will need libindy in your system library path. (i.e. /usr/lib/libindy.so for linux)
3417# or in this directory (i.e. wrappers/nodejs/libindy.so)
3418
3419# Install dependencies and do the initial build.
3420npm install
3421
3422# Run the tests
3423TEST_POOL_IP=10.0.0.2 npm test
3424
3425# If you built with libindy locally (i.e. wrappers/nodejs/libindy.so) you need to set LD_LIBRARY_PATH
3426LD_LIBRARY_PATH=./ TEST_POOL_IP=10.0.0.2 npm test
3427
3428# To recompile the native bindings
3429npm run rebuild
3430```