This repository has been archived by the owner on Feb 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 736
/
anoncreds.rs
2431 lines (2211 loc) · 119 KB
/
anoncreds.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
use api::{ErrorCode, IndyHandle, CommandHandle, WalletHandle, SearchHandle};
use errors::prelude::*;
use commands::{Command, CommandExecutor};
use commands::anoncreds::AnoncredsCommand;
use commands::anoncreds::issuer::IssuerCommand;
use commands::anoncreds::prover::ProverCommand;
use commands::anoncreds::verifier::VerifierCommand;
use domain::anoncreds::schema::{Schema, AttributeNames, Schemas};
use domain::crypto::did::DidValue;
use domain::anoncreds::credential_definition::{CredentialDefinition, CredentialDefinitionConfig, CredentialDefinitionId, CredentialDefinitions};
use domain::anoncreds::credential_offer::CredentialOffer;
use domain::anoncreds::credential_request::{CredentialRequest, CredentialRequestMetadata};
use domain::anoncreds::credential_attr_tag_policy::CredentialAttrTagPolicy;
use domain::anoncreds::credential::{Credential, CredentialValues};
use domain::anoncreds::revocation_registry_definition::{RevocationRegistryConfig, RevocationRegistryDefinition, RevocationRegistryId, RevocationRegistryDefinitions};
use domain::anoncreds::revocation_registry_delta::RevocationRegistryDelta;
use domain::anoncreds::proof::Proof;
use domain::anoncreds::proof_request::{ProofRequest, ProofRequestExtraQuery};
use domain::anoncreds::requested_credential::RequestedCredentials;
use domain::anoncreds::revocation_registry::RevocationRegistries;
use domain::anoncreds::revocation_state::{RevocationState, RevocationStates};
use utils::ctypes;
use libc::c_char;
use std::ptr;
use utils::validation::Validatable;
/*
These functions wrap the Ursa algorithm as documented in this paper:
https://github.com/hyperledger/ursa/blob/master/libursa/docs/AnonCred.pdf
And is documented in this HIPE:
https://github.com/hyperledger/indy-hipe/blob/c761c583b1e01c1e9d3ceda2b03b35336fdc8cc1/text/anoncreds-protocol/README.md
*/
/// Create credential schema entity that describes credential attributes list and allows credentials
/// interoperability.
///
/// Schema is public and intended to be shared with all anoncreds workflow actors usually by publishing SCHEMA transaction
/// to Indy distributed ledger.
///
/// It is IMPORTANT for current version POST Schema in Ledger and after that GET it from Ledger
/// with correct seq_no to save compatibility with Ledger.
/// After that can call indy_issuer_create_and_store_credential_def to build corresponding Credential Definition.
///
/// #Params
/// command_handle: command handle to map callback to user context
/// issuer_did: DID of schema issuer
/// name: a name the schema
/// version: a version of the schema
/// attrs: a list of schema attributes descriptions (the number of attributes should be less or equal than 125)
/// `["attr1", "attr2"]`
/// cb: Callback that takes command result as parameter
///
/// #Returns
/// schema_id: identifier of created schema
/// schema_json: schema as json:
/// {
/// id: identifier of schema
/// attrNames: array of attribute name strings
/// name: schema's name string
/// version: schema's version string,
/// ver: version of the Schema json
/// }
///
/// #Errors
/// Common*
/// Anoncreds*
#[no_mangle]
pub extern fn indy_issuer_create_schema(command_handle: CommandHandle,
issuer_did: *const c_char,
name: *const c_char,
version: *const c_char,
attrs: *const c_char,
cb: Option<extern fn(command_handle_: CommandHandle, err: ErrorCode,
schema_id: *const c_char, schema_json: *const c_char)>) -> ErrorCode {
trace!("indy_issuer_create_schema: >>> issuer_did: {:?}, name: {:?}, version: {:?}, attrs: {:?}", issuer_did, name, version, attrs);
check_useful_validatable_string!(issuer_did, ErrorCode::CommonInvalidParam2, DidValue);
check_useful_c_str!(name, ErrorCode::CommonInvalidParam3);
check_useful_c_str!(version, ErrorCode::CommonInvalidParam4);
check_useful_validatable_json!(attrs, ErrorCode::CommonInvalidParam5, AttributeNames);
check_useful_c_callback!(cb, ErrorCode::CommonInvalidParam6);
trace!("indy_issuer_create_schema: entity >>> issuer_did: {:?}, name: {:?}, version: {:?}, attrs: {:?}", issuer_did, name, version, attrs);
let result = CommandExecutor::instance()
.send(Command::Anoncreds(
AnoncredsCommand::Issuer(
IssuerCommand::CreateSchema(
issuer_did,
name,
version,
attrs,
Box::new(move |result| {
let (err, id, schema_json) = prepare_result_2!(result, String::new(), String::new());
trace!("ursa_cl_credential_public_key_to_json: id: {:?}, schema_json: {:?}", id, schema_json);
let id = ctypes::string_to_cstring(id);
let schema_json = ctypes::string_to_cstring(schema_json);
cb(command_handle, err, id.as_ptr(), schema_json.as_ptr())
})
))));
let res = prepare_result!(result);
trace!("indy_issuer_create_schema: <<< res: {:?}", res);
res
}
/// Create credential definition entity that encapsulates credentials issuer DID, credential schema, secrets used for signing credentials
/// and secrets used for credentials revocation.
///
/// Credential definition entity contains private and public parts. Private part will be stored in the wallet. Public part
/// will be returned as json intended to be shared with all anoncreds workflow actors usually by publishing CRED_DEF transaction
/// to Indy distributed ledger.
///
/// It is IMPORTANT for current version GET Schema from Ledger with correct seq_no to save compatibility with Ledger.
///
/// Note: Use combination of `indy_issuer_rotate_credential_def_start` and `indy_issuer_rotate_credential_def_apply` functions
/// to generate new keys for an existing credential definition.
///
/// #Params
/// command_handle: command handle to map callback to user context.
/// wallet_handle: wallet handle (created by open_wallet).
/// issuer_did: a DID of the issuer
/// schema_json: credential schema as a json: {
/// id: identifier of schema
/// attrNames: array of attribute name strings
/// name: schema's name string
/// version: schema's version string,
/// seqNo: (Optional) schema's sequence number on the ledger,
/// ver: version of the Schema json
/// }
/// tag: any string that allows to distinguish between credential definitions for the same issuer and schema
/// signature_type: credential definition type (optional, 'CL' by default) that defines credentials signature and revocation math.
/// Supported signature types:
/// - 'CL': Camenisch-Lysyanskaya credential signature type that is implemented according to the algorithm in this paper:
/// https://github.com/hyperledger/ursa/blob/master/libursa/docs/AnonCred.pdf
/// And is documented in this HIPE:
/// https://github.com/hyperledger/indy-hipe/blob/c761c583b1e01c1e9d3ceda2b03b35336fdc8cc1/text/anoncreds-protocol/README.md
/// config_json: (optional) type-specific configuration of credential definition as json:
/// - 'CL':
/// {
/// "support_revocation" - bool (optional, default false) whether to request non-revocation credential
/// }
/// cb: Callback that takes command result as parameter.
///
/// #Returns
/// cred_def_id: identifier of created credential definition
/// cred_def_json: public part of created credential definition
/// {
/// id: string - identifier of credential definition
/// schemaId: string - identifier of stored in ledger schema
/// type: string - type of the credential definition. CL is the only supported type now.
/// tag: string - allows to distinct between credential definitions for the same issuer and schema
/// value: Dictionary with Credential Definition's data is depended on the signature type: {
/// primary: primary credential public key,
/// Optional<revocation>: revocation credential public key
/// },
/// ver: Version of the CredDef json
/// }
///
/// Note: `primary` and `revocation` fields of credential definition are complex opaque types that contain data structures internal to Ursa.
/// They should not be parsed and are likely to change in future versions.
///
/// #Errors
/// Common*
/// Wallet*
/// Anoncreds*
#[no_mangle]
pub extern fn indy_issuer_create_and_store_credential_def(command_handle: CommandHandle,
wallet_handle: WalletHandle,
issuer_did: *const c_char,
schema_json: *const c_char,
tag: *const c_char,
signature_type: *const c_char,
config_json: *const c_char,
cb: Option<extern fn(command_handle_: CommandHandle, err: ErrorCode,
cred_def_id: *const c_char,
cred_def_json: *const c_char)>) -> ErrorCode {
trace!("indy_issuer_create_and_store_credential_def: >>> wallet_handle: {:?}, issuer_did: {:?}, schema_json: {:?}, tag: {:?}, \
signature_type: {:?}, config_json: {:?}", wallet_handle, issuer_did, schema_json, tag, signature_type, config_json);
check_useful_validatable_string!(issuer_did, ErrorCode::CommonInvalidParam3, DidValue);
check_useful_validatable_json!(schema_json, ErrorCode::CommonInvalidParam4, Schema);
check_useful_c_str!(tag, ErrorCode::CommonInvalidParam5);
check_useful_opt_c_str!(signature_type, ErrorCode::CommonInvalidParam6);
check_useful_opt_validatable_json!(config_json, ErrorCode::CommonInvalidParam7, CredentialDefinitionConfig);
check_useful_c_callback!(cb, ErrorCode::CommonInvalidParam8);
trace!("indy_issuer_create_and_store_credential_def: entities >>> wallet_handle: {:?}, issuer_did: {:?}, schema_json: {:?}, tag: {:?}, \
signature_type: {:?}, config_json: {:?}", wallet_handle, issuer_did, schema_json, tag, signature_type, config_json);
let result = CommandExecutor::instance()
.send(Command::Anoncreds(
AnoncredsCommand::Issuer(
IssuerCommand::CreateAndStoreCredentialDefinition(
wallet_handle,
issuer_did,
schema_json,
tag,
signature_type,
config_json,
Box::new(move |result| {
let (err, cred_def_id, cred_def_json) = prepare_result_2!(result, String::new(), String::new());
trace!("indy_issuer_create_and_store_credential_def: cred_def_id: {:?}, cred_def_json: {:?}", cred_def_id, cred_def_json);
let cred_def_id = ctypes::string_to_cstring(cred_def_id);
let cred_def_json = ctypes::string_to_cstring(cred_def_json);
cb(command_handle, err, cred_def_id.as_ptr(), cred_def_json.as_ptr())
})
))));
let res = prepare_result!(result);
trace!("indy_issuer_create_and_store_credential_def: <<< res: {:?}", res);
res
}
/// Generate temporary credential definitional keys for an existing one (owned by the caller of the library).
///
/// Use `indy_issuer_rotate_credential_def_apply` function to set generated temporary keys as the main.
///
/// WARNING: Rotating the credential definitional keys will result in making all credentials issued under the previous keys unverifiable.
///
/// #Params
/// command_handle: command handle to map callback to user context.
/// wallet_handle: wallet handle (created by open_wallet).
/// cred_def_id: an identifier of created credential definition stored in the wallet
/// config_json: (optional) type-specific configuration of credential definition as json:
/// - 'CL':
/// {
/// "support_revocation" - bool (optional, default false) whether to request non-revocation credential
/// }
/// cb: Callback that takes command result as parameter.
///
/// #Returns
/// cred_def_json: public part of temporary created credential definition
/// {
/// id: string - identifier of credential definition
/// schemaId: string - identifier of stored in ledger schema
/// type: string - type of the credential definition. CL is the only supported type now.
/// tag: string - allows to distinct between credential definitions for the same issuer and schema
/// value: Dictionary with Credential Definition's data is depended on the signature type: {
/// primary: primary credential public key,
/// Optional<revocation>: revocation credential public key
/// }, - only this field differs from the original credential definition
/// ver: Version of the CredDef json
/// }
///
/// Note: `primary` and `revocation` fields of credential definition are complex opaque types that contain data structures internal to Ursa.
/// They should not be parsed and are likely to change in future versions.
///
/// #Errors
/// Common*
/// Wallet*
/// Anoncreds*
#[no_mangle]
pub extern fn indy_issuer_rotate_credential_def_start(command_handle: CommandHandle,
wallet_handle: WalletHandle,
cred_def_id: *const c_char,
config_json: *const c_char,
cb: Option<extern fn(command_handle_: CommandHandle, err: ErrorCode,
cred_def_json: *const c_char)>) -> ErrorCode {
trace!("indy_issuer_rotate_credential_def_start: >>> wallet_handle: {:?}, cred_def_id: {:?}, config_json: {:?}",
wallet_handle, cred_def_id, config_json);
check_useful_validatable_string!(cred_def_id, ErrorCode::CommonInvalidParam3, CredentialDefinitionId);
check_useful_opt_validatable_json!(config_json, ErrorCode::CommonInvalidParam4, CredentialDefinitionConfig);
check_useful_c_callback!(cb, ErrorCode::CommonInvalidParam5);
trace!("indy_issuer_rotate_credential_def_start: entities >>> wallet_handle: {:?}, cred_def_id: {:?}, config_json: {:?}",
wallet_handle, cred_def_id, config_json);
let result = CommandExecutor::instance()
.send(Command::Anoncreds(
AnoncredsCommand::Issuer(
IssuerCommand::RotateCredentialDefinitionStart(
wallet_handle,
cred_def_id,
config_json,
Box::new(move |result| {
let (err, cred_def_json) = prepare_result_1!(result, String::new());
trace!("indy_issuer_rotate_credential_def_start:cred_def_json: {:?}", cred_def_json);
let cred_def_json = ctypes::string_to_cstring(cred_def_json);
cb(command_handle, err, cred_def_json.as_ptr())
})
))));
let res = prepare_result!(result);
trace!("indy_issuer_rotate_credential_def_start: <<< res: {:?}", res);
res
}
/// Apply temporary keys as main for an existing Credential Definition (owned by the caller of the library).
///
/// WARNING: Rotating the credential definitional keys will result in making all credentials issued under the previous keys unverifiable.
///
/// #Params
/// command_handle: command handle to map callback to user context.
/// wallet_handle: wallet handle (created by open_wallet).
/// cred_def_id: an identifier of created credential definition stored in the wallet
/// cb: Callback that takes command result as parameter.
///
/// #Returns
///
/// #Errors
/// Common*
/// Wallet*
/// Anoncreds*
#[no_mangle]
pub extern fn indy_issuer_rotate_credential_def_apply(command_handle: CommandHandle,
wallet_handle: WalletHandle,
cred_def_id: *const c_char,
cb: Option<extern fn(command_handle_: CommandHandle, err: ErrorCode)>) -> ErrorCode {
trace!("indy_issuer_rotate_credential_def_apply: >>> wallet_handle: {:?}, cred_def_id: {:?}",
wallet_handle, cred_def_id);
check_useful_validatable_string!(cred_def_id, ErrorCode::CommonInvalidParam3, CredentialDefinitionId);
check_useful_c_callback!(cb, ErrorCode::CommonInvalidParam4);
trace!("indy_issuer_rotate_credential_def_apply: entities >>> wallet_handle: {:?}, cred_def_id: {:?}",
wallet_handle, cred_def_id);
let result = CommandExecutor::instance()
.send(Command::Anoncreds(
AnoncredsCommand::Issuer(
IssuerCommand::RotateCredentialDefinitionApply(
wallet_handle,
cred_def_id,
Box::new(move |result| {
let err = prepare_result!(result);
trace!("indy_issuer_rotate_credential_def_apply:");
cb(command_handle, err)
})
))));
let res = prepare_result!(result);
trace!("indy_issuer_rotate_credential_def_apply: <<< res: {:?}", res);
res
}
/// Create a new revocation registry for the given credential definition as tuple of entities
/// - Revocation registry definition that encapsulates credentials definition reference, revocation type specific configuration and
/// secrets used for credentials revocation
/// - Revocation registry state that stores the information about revoked entities in a non-disclosing way. The state can be
/// represented as ordered list of revocation registry entries were each entry represents the list of revocation or issuance operations.
///
/// Revocation registry definition entity contains private and public parts. Private part will be stored in the wallet. Public part
/// will be returned as json intended to be shared with all anoncreds workflow actors usually by publishing REVOC_REG_DEF transaction
/// to Indy distributed ledger.
///
/// Revocation registry state is stored on the wallet and also intended to be shared as the ordered list of REVOC_REG_ENTRY transactions.
/// This call initializes the state in the wallet and returns the initial entry.
///
/// Some revocation registry types (for example, 'CL_ACCUM') can require generation of binary blob called tails used to hide information about revoked credentials in public
/// revocation registry and intended to be distributed out of leger (REVOC_REG_DEF transaction will still contain uri and hash of tails).
/// This call requires access to pre-configured blob storage writer instance handle that will allow to write generated tails.
///
/// #Params
/// command_handle: command handle to map callback to user context.
/// wallet_handle: wallet handle (created by open_wallet).
/// issuer_did: a DID of the issuer
/// revoc_def_type: revocation registry type (optional, default value depends on credential definition type). Supported types are:
/// - 'CL_ACCUM': Type-3 pairing based accumulator implemented according to the algorithm in this paper:
/// https://github.com/hyperledger/ursa/blob/master/libursa/docs/AnonCred.pdf
/// This type is default for 'CL' credential definition type.
/// tag: any string that allows to distinct between revocation registries for the same issuer and credential definition
/// cred_def_id: id of stored in ledger credential definition
/// config_json: type-specific configuration of revocation registry as json:
/// - 'CL_ACCUM': {
/// "issuance_type": (optional) type of issuance. Currently supported:
/// 1) ISSUANCE_BY_DEFAULT: all indices are assumed to be issued and initial accumulator is calculated over all indices;
/// Revocation Registry is updated only during revocation.
/// 2) ISSUANCE_ON_DEMAND: nothing is issued initially accumulator is 1 (used by default);
/// "max_cred_num": maximum number of credentials the new registry can process (optional, default 100000)
/// }
/// tails_writer_handle: handle of blob storage to store tails (returned by `indy_open_blob_storage_writer`).
/// cb: Callback that takes command result as parameter.
///
/// NOTE:
/// Recursive creation of folder for Default Tails Writer (correspondent to `tails_writer_handle`)
/// in the system-wide temporary directory may fail in some setup due to permissions: `IO error: Permission denied`.
/// In this case use `TMPDIR` environment variable to define temporary directory specific for an application.
///
/// #Returns
/// revoc_reg_id: identifier of created revocation registry definition
/// revoc_reg_def_json: public part of revocation registry definition
/// {
/// "id": string - ID of the Revocation Registry,
/// "revocDefType": string - Revocation Registry type (only CL_ACCUM is supported for now),
/// "tag": string - Unique descriptive ID of the Registry,
/// "credDefId": string - ID of the corresponding CredentialDefinition,
/// "value": Registry-specific data {
/// "issuanceType": string - Type of Issuance(ISSUANCE_BY_DEFAULT or ISSUANCE_ON_DEMAND),
/// "maxCredNum": number - Maximum number of credentials the Registry can serve.
/// "tailsHash": string - Hash of tails.
/// "tailsLocation": string - Location of tails file.
/// "publicKeys": <public_keys> - Registry's public key (opaque type that contains data structures internal to Ursa.
/// It should not be parsed and are likely to change in future versions).
/// },
/// "ver": string - version of revocation registry definition json.
/// }
/// revoc_reg_entry_json: revocation registry entry that defines initial state of revocation registry
/// {
/// value: {
/// prevAccum: string - previous accumulator value.
/// accum: string - current accumulator value.
/// issued: array<number> - an array of issued indices.
/// revoked: array<number> an array of revoked indices.
/// },
/// ver: string - version revocation registry entry json
/// }
///
/// #Errors
/// Common*
/// Wallet*
/// Anoncreds*
#[no_mangle]
pub extern fn indy_issuer_create_and_store_revoc_reg(command_handle: CommandHandle,
wallet_handle: WalletHandle,
issuer_did: *const c_char,
revoc_def_type: *const c_char,
tag: *const c_char,
cred_def_id: *const c_char,
config_json: *const c_char,
tails_writer_handle: IndyHandle,
cb: Option<extern fn(command_handle_: CommandHandle, err: ErrorCode,
revoc_reg_id: *const c_char,
revoc_reg_def_json: *const c_char,
revoc_reg_entry_json: *const c_char)>) -> ErrorCode {
trace!("indy_issuer_create_and_store_credential_def: >>> wallet_handle: {:?}, issuer_did: {:?}, revoc_def_type: {:?}, tag: {:?}, \
cred_def_id: {:?}, config_json: {:?}, tails_writer_handle: {:?}", wallet_handle, issuer_did, revoc_def_type, tag, cred_def_id, config_json, tails_writer_handle);
check_useful_validatable_string!(issuer_did, ErrorCode::CommonInvalidParam3, DidValue);
check_useful_opt_c_str!(revoc_def_type, ErrorCode::CommonInvalidParam4);
check_useful_c_str!(tag, ErrorCode::CommonInvalidParam5);
check_useful_validatable_string!(cred_def_id, ErrorCode::CommonInvalidParam6, CredentialDefinitionId);
check_useful_validatable_json!(config_json, ErrorCode::CommonInvalidParam7, RevocationRegistryConfig);
check_useful_c_callback!(cb, ErrorCode::CommonInvalidParam9);
trace!("indy_issuer_create_and_store_credential_def: entities >>> wallet_handle: {:?}, issuer_did: {:?}, revoc_def_type: {:?}, tag: {:?}, \
cred_def_id: {:?}, config_json: {:?}, tails_writer_handle: {:?}", wallet_handle, issuer_did, revoc_def_type, tag, cred_def_id, config_json, tails_writer_handle);
let result = CommandExecutor::instance()
.send(Command::Anoncreds(
AnoncredsCommand::Issuer(
IssuerCommand::CreateAndStoreRevocationRegistry(
wallet_handle,
issuer_did,
revoc_def_type,
tag,
cred_def_id,
config_json,
tails_writer_handle,
Box::new(move |result| {
let (err, revoc_reg_id, revoc_reg_def_json, revoc_reg_json) = prepare_result_3!(result, String::new(), String::new(), String::new());
trace!("indy_issuer_create_and_store_credential_def: revoc_reg_id: {:?}, revoc_reg_def_json: {:?}, revoc_reg_json: {:?}",
revoc_reg_id, revoc_reg_def_json, revoc_reg_json);
let revoc_reg_id = ctypes::string_to_cstring(revoc_reg_id);
let revoc_reg_def_json = ctypes::string_to_cstring(revoc_reg_def_json);
let revoc_reg_json = ctypes::string_to_cstring(revoc_reg_json);
cb(command_handle, err, revoc_reg_id.as_ptr(), revoc_reg_def_json.as_ptr(), revoc_reg_json.as_ptr())
})
))));
let res = prepare_result!(result);
trace!("indy_issuer_create_and_store_credential_def: <<< res: {:?}", res);
res
}
/// Create credential offer that will be used by Prover for
/// credential request creation. Offer includes nonce and key correctness proof
/// for authentication between protocol steps and integrity checking.
///
/// #Params
/// command_handle: command handle to map callback to user context
/// wallet_handle: wallet handle (created by open_wallet)
/// cred_def_id: id of credential definition stored in the wallet
/// cb: Callback that takes command result as parameter
///
/// #Returns
/// credential offer json:
/// {
/// "schema_id": string, - identifier of schema
/// "cred_def_id": string, - identifier of credential definition
/// // Fields below can depend on Credential Definition type
/// "nonce": string,
/// "key_correctness_proof" : key correctness proof for credential definition correspondent to cred_def_id
/// (opaque type that contains data structures internal to Ursa.
/// It should not be parsed and are likely to change in future versions).
/// }
///
/// #Errors
/// Common*
/// Wallet*
/// Anoncreds*
#[no_mangle]
pub extern fn indy_issuer_create_credential_offer(command_handle: CommandHandle,
wallet_handle: WalletHandle,
cred_def_id: *const c_char,
cb: Option<extern fn(command_handle_: CommandHandle, err: ErrorCode,
cred_offer_json: *const c_char)>) -> ErrorCode {
trace!("indy_issuer_create_credential_offer: >>> wallet_handle: {:?}, cred_def_id: {:?}", wallet_handle, cred_def_id);
check_useful_validatable_string!(cred_def_id, ErrorCode::CommonInvalidParam3, CredentialDefinitionId);
check_useful_c_callback!(cb, ErrorCode::CommonInvalidParam4);
trace!("indy_issuer_create_credential_offer: entities >>> wallet_handle: {:?}, cred_def_id: {:?}", wallet_handle, cred_def_id);
let result = CommandExecutor::instance()
.send(Command::Anoncreds(
AnoncredsCommand::Issuer(
IssuerCommand::CreateCredentialOffer(
wallet_handle,
cred_def_id,
boxed_callback_string!("indy_issuer_create_credential_offer", cb, command_handle)
))));
let res = prepare_result!(result);
trace!("indy_issuer_create_credential_offer: <<< res: {:?}", res);
res
}
/// Check Cred Request for the given Cred Offer and issue Credential for the given Cred Request.
///
/// Cred Request must match Cred Offer. The credential definition and revocation registry definition
/// referenced in Cred Offer and Cred Request must be already created and stored into the wallet.
///
/// Information for this credential revocation will be store in the wallet as part of revocation registry under
/// generated cred_revoc_id local for this wallet.
///
/// This call returns revoc registry delta as json file intended to be shared as REVOC_REG_ENTRY transaction.
/// Note that it is possible to accumulate deltas to reduce ledger load.
///
/// #Params
/// command_handle: command handle to map callback to user context.
/// wallet_handle: wallet handle (created by open_wallet).
/// cred_offer_json: a cred offer created by indy_issuer_create_credential_offer
/// cred_req_json: a credential request created by indy_prover_create_credential_req
/// cred_values_json: a credential containing attribute values for each of requested attribute names.
/// Example:
/// {
/// "attr1" : {"raw": "value1", "encoded": "value1_as_int" },
/// "attr2" : {"raw": "value1", "encoded": "value1_as_int" }
/// }
/// rev_reg_id: id of revocation registry stored in the wallet
/// blob_storage_reader_handle: configuration of blob storage reader handle that will allow to read revocation tails (returned by `indy_open_blob_storage_reader`)
/// cb: Callback that takes command result as parameter.
///
/// #Returns
/// cred_json: Credential json containing signed credential values
/// {
/// "schema_id": string, - identifier of schema
/// "cred_def_id": string, - identifier of credential definition
/// "rev_reg_def_id", Optional<string>, - identifier of revocation registry
/// "values": <see cred_values_json above>, - credential values.
/// // Fields below can depend on Cred Def type
/// "signature": <credential signature>,
/// (opaque type that contains data structures internal to Ursa.
/// It should not be parsed and are likely to change in future versions).
/// "signature_correctness_proof": credential signature correctness proof
/// (opaque type that contains data structures internal to Ursa.
/// It should not be parsed and are likely to change in future versions).
/// "rev_reg" - (Optional) revocation registry accumulator value on the issuing moment.
/// (opaque type that contains data structures internal to Ursa.
/// It should not be parsed and are likely to change in future versions).
/// "witness" - (Optional) revocation related data
/// (opaque type that contains data structures internal to Ursa.
/// It should not be parsed and are likely to change in future versions).
/// }
/// cred_revoc_id: local id for revocation info (Can be used for revocation of this credential)
/// revoc_reg_delta_json: Revocation registry delta json with a newly issued credential
///
/// #Errors
/// Anoncreds*
/// Common*
/// Wallet*
#[no_mangle]
pub extern fn indy_issuer_create_credential(command_handle: CommandHandle,
wallet_handle: WalletHandle,
cred_offer_json: *const c_char,
cred_req_json: *const c_char,
cred_values_json: *const c_char,
rev_reg_id: *const c_char,
blob_storage_reader_handle: IndyHandle,
cb: Option<extern fn(command_handle_: CommandHandle, err: ErrorCode,
cred_json: *const c_char,
cred_revoc_id: *const c_char,
revoc_reg_delta_json: *const c_char)>) -> ErrorCode {
trace!("indy_issuer_create_credential: >>> wallet_handle: {:?}, cred_offer_json: {:?}, cred_req_json: {:?}, cred_values_json: {:?}, rev_reg_id: {:?}, \
blob_storage_reader_handle: {:?}", wallet_handle, cred_offer_json, cred_req_json, cred_values_json, rev_reg_id, blob_storage_reader_handle);
check_useful_validatable_json!(cred_offer_json, ErrorCode::CommonInvalidParam3, CredentialOffer);
check_useful_validatable_json!(cred_req_json, ErrorCode::CommonInvalidParam4, CredentialRequest);
check_useful_validatable_json!(cred_values_json, ErrorCode::CommonInvalidParam5, CredentialValues);
check_useful_validatable_opt_string!(rev_reg_id, ErrorCode::CommonInvalidParam6, RevocationRegistryId);
check_useful_c_callback!(cb, ErrorCode::CommonInvalidParam8);
let blob_storage_reader_handle = if blob_storage_reader_handle != -1 { Some(blob_storage_reader_handle) } else { None };
trace!("indy_issuer_create_credential: entities >>> wallet_handle: {:?}, cred_offer_json: {:?}, cred_req_json: {:?}, cred_values_json: {:?}, rev_reg_id: {:?}, \
blob_storage_reader_handle: {:?}", wallet_handle, cred_offer_json, secret!(&cred_req_json), secret!(&cred_values_json), secret!(&rev_reg_id), blob_storage_reader_handle);
let result = CommandExecutor::instance()
.send(Command::Anoncreds(
AnoncredsCommand::Issuer(
IssuerCommand::CreateCredential(
wallet_handle,
cred_offer_json,
cred_req_json,
cred_values_json,
rev_reg_id,
blob_storage_reader_handle,
Box::new(move |result| {
let (err, cred_json, revoc_id, revoc_reg_delta_json) = prepare_result_3!(result, String::new(), None, None);
trace!("indy_issuer_create_credential: cred_json: {:?}, revoc_id: {:?}, revoc_reg_delta_json: {:?}",
secret!(cred_json.as_str()), secret!(&revoc_id), revoc_reg_delta_json);
let cred_json = ctypes::string_to_cstring(cred_json);
let revoc_id = revoc_id.map(ctypes::string_to_cstring);
let revoc_reg_delta_json = revoc_reg_delta_json.map(ctypes::string_to_cstring);
cb(command_handle, err, cred_json.as_ptr(),
revoc_id.as_ref().map(|id| id.as_ptr()).unwrap_or(ptr::null()),
revoc_reg_delta_json.as_ref().map(|delta| delta.as_ptr()).unwrap_or(ptr::null()))
})
))));
let res = prepare_result!(result);
trace!("indy_issuer_create_credential: <<< res: {:?}", res);
res
}
/// Revoke a credential identified by a cred_revoc_id (returned by indy_issuer_create_credential).
///
/// The corresponding credential definition and revocation registry must be already
/// created an stored into the wallet.
///
/// This call returns revoc registry delta as json file intended to be shared as REVOC_REG_ENTRY transaction.
/// Note that it is possible to accumulate deltas to reduce ledger load.
///
/// #Params
/// command_handle: command handle to map callback to user context.
/// wallet_handle: wallet handle (created by open_wallet).
/// blob_storage_reader_cfg_handle: configuration of blob storage reader handle that will allow to read revocation tails (returned by `indy_open_blob_storage_reader`).
/// rev_reg_id: id of revocation registry stored in wallet
/// cred_revoc_id: local id for revocation info related to issued credential
/// cb: Callback that takes command result as parameter.
///
/// #Returns
/// revoc_reg_delta_json: Revocation registry delta json with a revoked credential
/// {
/// value: {
/// prevAccum: string - previous accumulator value.
/// accum: string - current accumulator value.
/// revoked: array<number> an array of revoked indices.
/// },
/// ver: string - version revocation registry delta json
/// }
///
/// #Errors
/// Anoncreds*
/// Common*
/// Wallet*
#[no_mangle]
pub extern fn indy_issuer_revoke_credential(command_handle: CommandHandle,
wallet_handle: WalletHandle,
blob_storage_reader_cfg_handle: IndyHandle,
rev_reg_id: *const c_char,
cred_revoc_id: *const c_char,
cb: Option<extern fn(command_handle_: CommandHandle, err: ErrorCode,
revoc_reg_delta_json: *const c_char)>) -> ErrorCode {
trace!("indy_issuer_revoke_credential: >>> wallet_handle: {:?}, blob_storage_reader_cfg_handle: {:?}, rev_reg_id: {:?}, cred_revoc_id: {:?}",
wallet_handle, blob_storage_reader_cfg_handle, rev_reg_id, cred_revoc_id);
check_useful_validatable_string!(rev_reg_id, ErrorCode::CommonInvalidParam4, RevocationRegistryId);
check_useful_c_str!(cred_revoc_id, ErrorCode::CommonInvalidParam5);
check_useful_c_callback!(cb, ErrorCode::CommonInvalidParam6);
trace!("indy_issuer_revoke_credential: entities >>> wallet_handle: {:?}, blob_storage_reader_cfg_handle: {:?}, rev_reg_id: {:?}, cred_revoc_id: {:?}",
wallet_handle, blob_storage_reader_cfg_handle, rev_reg_id, secret!(cred_revoc_id.as_str()));
let result = CommandExecutor::instance()
.send(Command::Anoncreds(
AnoncredsCommand::Issuer(
IssuerCommand::RevokeCredential(
wallet_handle,
blob_storage_reader_cfg_handle,
rev_reg_id,
cred_revoc_id,
boxed_callback_string!("indy_issuer_revoke_credential", cb, command_handle)
))));
let res = prepare_result!(result);
trace!("indy_issuer_revoke_credential: <<< res: {:?}", res);
res
}
/*/// Recover a credential identified by a cred_revoc_id (returned by indy_issuer_create_credential).
///
/// The corresponding credential definition and revocation registry must be already
/// created an stored into the wallet.
///
/// This call returns revoc registry delta as json file intended to be shared as REVOC_REG_ENTRY transaction.
/// Note that it is possible to accumulate deltas to reduce ledger load.
///
/// #Params
/// command_handle: command handle to map callback to user context.
/// wallet_handle: wallet handle (created by open_wallet).
/// blob_storage_reader_cfg_handle: configuration of blob storage reader handle that will allow to read revocation tails (returned by `indy_open_blob_storage_reader`).
/// rev_reg_id: id of revocation registry stored in wallet
/// cred_revoc_id: local id for revocation info related to issued credential
/// cb: Callback that takes command result as parameter.
///
/// #Returns
/// revoc_reg_delta_json: Revocation registry delta json with a recovered credential
/// {
/// value: {
/// prevAccum: string - previous accumulator value.
/// accum: string - current accumulator value.
/// issued: array<number> an array of issued indices.
/// },
/// ver: string - version revocation registry delta json
/// }
///
/// #Errors
/// Anoncreds*
/// Common*
/// Wallet*
#[no_mangle]
pub extern fn indy_issuer_recover_credential(command_handle: CommandHandle,
wallet_handle: WalletHandle,
blob_storage_reader_cfg_handle: IndyHandle,
rev_reg_id: *const c_char,
cred_revoc_id: *const c_char,
cb: Option<extern fn(command_handle_: CommandHandle, err: ErrorCode,
revoc_reg_delta_json: *const c_char,
)>) -> ErrorCode {
check_useful_c_str!(rev_reg_id, ErrorCode::CommonInvalidParam4);
check_useful_c_str!(cred_revoc_id, ErrorCode::CommonInvalidParam5);
check_useful_c_callback!(cb, ErrorCode::CommonInvalidParam6);
let result = CommandExecutor::instance()
.send(Command::Anoncreds(
AnoncredsCommand::Issuer(
IssuerCommand::RecoverCredential(
wallet_handle,
blob_storage_reader_cfg_handle,
rev_reg_id,
cred_revoc_id,
Box::new(move |result| {
let (err, revoc_reg_update_json) = prepare_result_1!(result, String::new());
let revoc_reg_update_json = ctypes::string_to_cstring(revoc_reg_update_json);
cb(command_handle, err, revoc_reg_update_json.as_ptr())
})
))));
prepare_result!(result)
}*/
/// Merge two revocation registry deltas (returned by indy_issuer_create_credential or indy_issuer_revoke_credential) to accumulate common delta.
/// Send common delta to ledger to reduce the load.
///
/// #Params
/// command_handle: command handle to map callback to user context.
/// rev_reg_delta_json: revocation registry delta.
/// {
/// value: {
/// prevAccum: string - previous accumulator value.
/// accum: string - current accumulator value.
/// issued: array<number> an array of issued indices.
/// revoked: array<number> an array of revoked indices.
/// },
/// ver: string - version revocation registry delta json
/// }
///
/// other_rev_reg_delta_json: revocation registry delta for which PrevAccum value is equal to value of accum field of rev_reg_delta_json parameter.
/// cb: Callback that takes command result as parameter.
///
/// #Returns
/// merged_rev_reg_delta: Merged revocation registry delta
/// {
/// value: {
/// prevAccum: string - previous accumulator value.
/// accum: string - current accumulator value.
/// issued: array<number> an array of issued indices.
/// revoked: array<number> an array of revoked indices.
/// },
/// ver: string - version revocation registry delta json
/// }
///
/// #Errors
/// Anoncreds*
/// Common*
/// Wallet*
#[no_mangle]
pub extern fn indy_issuer_merge_revocation_registry_deltas(command_handle: CommandHandle,
rev_reg_delta_json: *const c_char,
other_rev_reg_delta_json: *const c_char,
cb: Option<extern fn(command_handle_: CommandHandle, err: ErrorCode,
merged_rev_reg_delta: *const c_char)>) -> ErrorCode {
trace!("indy_issuer_merge_revocation_registry_deltas: >>> rev_reg_delta_json: {:?}, other_rev_reg_delta_json: {:?}",
rev_reg_delta_json, other_rev_reg_delta_json);
check_useful_validatable_json!(rev_reg_delta_json, ErrorCode::CommonInvalidParam2, RevocationRegistryDelta);
check_useful_validatable_json!(other_rev_reg_delta_json, ErrorCode::CommonInvalidParam3, RevocationRegistryDelta);
check_useful_c_callback!(cb, ErrorCode::CommonInvalidParam4);
trace!("indy_issuer_merge_revocation_registry_deltas: entities >>> rev_reg_delta_json: {:?}, other_rev_reg_delta_json: {:?}",
rev_reg_delta_json, other_rev_reg_delta_json);
let result = CommandExecutor::instance()
.send(Command::Anoncreds(
AnoncredsCommand::Issuer(
IssuerCommand::MergeRevocationRegistryDeltas(
rev_reg_delta_json,
other_rev_reg_delta_json,
boxed_callback_string!("indy_issuer_merge_revocation_registry_deltas", cb, command_handle)
))));
let res = prepare_result!(result);
trace!("indy_issuer_merge_revocation_registry_deltas: <<< res: {:?}", res);
res
}
/// Creates a master secret with a given id and stores it in the wallet.
/// The id must be unique.
///
/// #Params
/// command_handle: command handle to map callback to user context.
/// wallet_handle: wallet handle (created by open_wallet).
/// master_secret_id: (optional, if not present random one will be generated) new master id
///
/// #Returns
/// out_master_secret_id: Id of generated master secret
///
/// #Errors
/// Anoncreds*
/// Common*
/// Wallet*
#[no_mangle]
pub extern fn indy_prover_create_master_secret(command_handle: CommandHandle,
wallet_handle: WalletHandle,
master_secret_id: *const c_char,
cb: Option<extern fn(command_handle_: CommandHandle, err: ErrorCode,
out_master_secret_id: *const c_char)>) -> ErrorCode {
trace!("indy_prover_create_master_secret: >>> wallet_handle: {:?}, master_secret_id: {:?}", wallet_handle, master_secret_id);
check_useful_opt_c_str!(master_secret_id, ErrorCode::CommonInvalidParam3);
check_useful_c_callback!(cb, ErrorCode::CommonInvalidParam4);
trace!("indy_prover_create_master_secret: entities >>> wallet_handle: {:?}, master_secret_id: {:?}", wallet_handle, master_secret_id);
let result = CommandExecutor::instance()
.send(Command::Anoncreds(
AnoncredsCommand::Prover(
ProverCommand::CreateMasterSecret(
wallet_handle,
master_secret_id,
boxed_callback_string!("indy_prover_create_master_secret", cb, command_handle)
))));
let res = prepare_result!(result);
trace!("indy_prover_create_master_secret: <<< res: {:?}", res);
res
}
/// Creates a credential request for the given credential offer.
///
/// The method creates a blinded master secret for a master secret identified by a provided name.
/// The master secret identified by the name must be already stored in the secure wallet (see prover_create_master_secret)
/// The blinded master secret is a part of the credential request.
///
/// #Params
/// command_handle: command handle to map callback to user context
/// wallet_handle: wallet handle (created by open_wallet)
/// prover_did: a DID of the prover
/// cred_offer_json: credential offer as a json containing information about the issuer and a credential
/// {
/// "schema_id": string, - identifier of schema
/// "cred_def_id": string, - identifier of credential definition
/// ...
/// Other fields that contains data structures internal to Ursa.
/// These fields should not be parsed and are likely to change in future versions.
/// }
/// cred_def_json: credential definition json related to <cred_def_id> in <cred_offer_json>
/// master_secret_id: the id of the master secret stored in the wallet
/// cb: Callback that takes command result as parameter.
///
/// #Returns
/// cred_req_json: Credential request json for creation of credential by Issuer
/// {
/// "prover_did" : string,
/// "cred_def_id" : string,
/// // Fields below can depend on Cred Def type
/// "blinded_ms" : <blinded_master_secret>,
/// (opaque type that contains data structures internal to Ursa.
/// It should not be parsed and are likely to change in future versions).
/// "blinded_ms_correctness_proof" : <blinded_ms_correctness_proof>,
/// (opaque type that contains data structures internal to Ursa.
/// It should not be parsed and are likely to change in future versions).
/// "nonce": string
/// }
/// cred_req_metadata_json: Credential request metadata json for further processing of received form Issuer credential.
/// Credential request metadata contains data structures internal to Ursa.
/// Credential request metadata mustn't be shared with Issuer.
///
/// #Errors
/// Anoncreds*
/// Common*
/// Wallet*
#[no_mangle]
pub extern fn indy_prover_create_credential_req(command_handle: CommandHandle,
wallet_handle: WalletHandle,
prover_did: *const c_char,
cred_offer_json: *const c_char,
cred_def_json: *const c_char,
master_secret_id: *const c_char,
cb: Option<extern fn(command_handle_: CommandHandle, err: ErrorCode,
cred_req_json: *const c_char,
cred_req_metadata_json: *const c_char)>) -> ErrorCode {
trace!("indy_prover_create_credential_req: >>> wallet_handle: {:?}, prover_did: {:?}, cred_offer_json: {:?}, cred_def_json: {:?}, master_secret_id: {:?}",
wallet_handle, prover_did, cred_offer_json, cred_def_json, master_secret_id);
check_useful_validatable_string!(prover_did, ErrorCode::CommonInvalidParam3, DidValue);
check_useful_validatable_json!(cred_offer_json, ErrorCode::CommonInvalidParam4, CredentialOffer);
check_useful_validatable_json!(cred_def_json, ErrorCode::CommonInvalidParam5, CredentialDefinition);
check_useful_c_str!(master_secret_id, ErrorCode::CommonInvalidParam6);
check_useful_c_callback!(cb, ErrorCode::CommonInvalidParam7);
trace!("indy_prover_create_credential_req: entities >>> wallet_handle: {:?}, prover_did: {:?}, cred_offer_json: {:?}, cred_def_json: {:?}, master_secret_id: {:?}",
wallet_handle, prover_did, cred_offer_json, cred_def_json, master_secret_id);
let result = CommandExecutor::instance()
.send(Command::Anoncreds(
AnoncredsCommand::Prover(
ProverCommand::CreateCredentialRequest(
wallet_handle,
prover_did,
cred_offer_json,
cred_def_json,
master_secret_id,
Box::new(move |result| {
let (err, cred_req_json, cred_req_metadata_json) = prepare_result_2!(result, String::new(), String::new());
trace!("indy_prover_create_credential_req: cred_req_json: {:?}, cred_req_metadata_json: {:?}", cred_req_json, cred_req_metadata_json);
let cred_req_json = ctypes::string_to_cstring(cred_req_json);
let cred_req_metadata_json = ctypes::string_to_cstring(cred_req_metadata_json);
cb(command_handle, err, cred_req_json.as_ptr(), cred_req_metadata_json.as_ptr())
})
))));
let res = prepare_result!(result);
trace!("indy_prover_create_credential_req: <<< res: {:?}", res);
res
}
/// Set credential attribute tagging policy.
/// Writes a non-secret record marking attributes to tag, and optionally
/// updates tags on existing credentials on the credential definition to match.
///
/// EXPERIMENTAL
///
/// The following tags are always present on write:
/// {
/// "schema_id": <credential schema id>,
/// "schema_issuer_did": <credential schema issuer did>,
/// "schema_name": <credential schema name>,
/// "schema_version": <credential schema version>,
/// "issuer_did": <credential issuer did>,
/// "cred_def_id": <credential definition id>,
/// "rev_reg_id": <credential revocation registry id>, // "None" as string if not present
/// }
///
/// The policy sets the following tags for each attribute it marks taggable, written to subsequent
/// credentials and (optionally) all existing credentials on the credential definition:
/// {
/// "attr::<attribute name>::marker": "1",
/// "attr::<attribute name>::value": <attribute raw value>,
/// }
///