Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Commit 55b77ec

Browse files
authored
Merge pull request #1916 from Artemkaaas/rc-1.12.0-updates
Rc 1.12.0 Updates
2 parents 9e042de + 40f440b commit 55b77ec

File tree

16 files changed

+186
-54
lines changed

16 files changed

+186
-54
lines changed

CHANGELOG.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Changelog
22

33
## 1.12.0 - 2019-09-XX
4-
* Minimal Support of Fully-Qualified identifiers:
4+
* Minimal *EXPERIMENTAL* support of Fully-Qualified identifiers:
55
* general format of fully-qualified identifier is `<prefix>:<method>:<value>`.
66
* extended `did_info` parameter of `indy_create_and_store_my_did` function to accepts optional `method_name` filed. This field should be used to create fully qualified DID.
77
* all functions can work with fully-qualified identifiers (new way) as well as with unqualified.
@@ -66,7 +66,7 @@ Old `indy_build_get_payment_sources_request` and `indy_parse_get_payment_sources
6666

6767
Added correspondent `payment-address sign/verify` commands to Indy CLI.
6868

69-
* Added new *EXPEREMENTAL* functions to get requirements and price for a ledger request.
69+
* Added new *EXPERIMENTAL* functions to get requirements and price for a ledger request.
7070
* Libindy `indy_get_request_info` - returns request requirements (with minimal price) correspondent to specific auth rule in case the requester can perform this action.
7171
* Libvcx `vcx_get_request_price` - returns request minimal request price for performing an action in case the requester can do it.
7272
* Added a set of new Libvcx APIs around credentials and proofs that work with messages that should be exchanged without handling the transport of those messages.

docs/migration-guides/migration-guide-1.11.0-1.12.0.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,20 @@ This functions also updates all DID related entities stored in the wallet to poi
4848

4949
#### Anoncreds API
5050

51-
As we have released Fully-Qualified identifiers, we can work with both identifier formats in a compatible way.
51+
As we have released *EXPERIMENTAL* Fully-Qualified identifiers, we can work with both identifier formats in a compatible way.
5252

53-
The new function [indy_to_unqualified](https://github.com/hyperledger/indy-sdk/blob/v1.12.0/libindy/src/api/did.rs#L729) was added.
53+
The new function [indy_to_unqualified](https://github.com/hyperledger/indy-sdk/blob/v1.12.0/libindy/src/api/anoncreds.rs#L2378) was added.
5454
This function gets unqualified form of a fully-qualified identifier.
5555
This function can accept the following entities:
5656
* DID
5757
* SchemaId
5858
* CredentialDefinitionId
5959
* RevocationRegistryId
60-
* CredentialOffer
60+
* Schema
61+
* CredentialDefinition
62+
* RevocationRegistryDefinition
63+
* CredentialOffer
64+
* CredentialRequest
6165
* ProofRequest
6266

6367
Let's consider Credential Issuance and Proof Presentation for different cases.

libindy/debian/changelog

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ libindy (1.12.0) unstable; urgency=medium
33
[ Hyperledger ]
44

55
## 1.12.0
6-
* Minimal Support of Fully-Qualified identifiers:
6+
* Minimal *EXPERIMENTAL* support of Fully-Qualified identifiers:
77
* extended `did_info` parameter of `indy_create_and_store_my_did` function to accepts optional `method_name` filed. This field should be used to create fully qualified DID.
88
* all functions can work with fully-qualified identifiers (new way) as well as with unqualified.
99
* added a new function -- `indy_to_unqualified` -- that gets unqualified form of a fully qualified identifier.

libindy/src/api/anoncreds.rs

+4
Original file line numberDiff line numberDiff line change
@@ -2389,7 +2389,11 @@ pub extern fn indy_generate_nonce(command_handle: CommandHandle,
23892389
/// SchemaId
23902390
/// CredentialDefinitionId
23912391
/// RevocationRegistryId
2392+
/// Schema
2393+
/// CredentialDefinition
2394+
/// RevocationRegistryDefinition
23922395
/// CredentialOffer
2396+
/// CredentialRequest
23932397
/// ProofRequest
23942398
///
23952399
/// #Returns

libindy/src/domain/anoncreds/credential_definition.rs

+16
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,22 @@ pub struct TemporaryCredentialDefinition {
7777
pub cred_def_correctness_proof: CredentialDefinitionCorrectnessProof
7878
}
7979

80+
impl CredentialDefinition {
81+
pub fn to_unqualified(self) -> CredentialDefinition {
82+
match self {
83+
CredentialDefinition::CredentialDefinitionV1(cred_def) => {
84+
CredentialDefinition::CredentialDefinitionV1(CredentialDefinitionV1 {
85+
id: cred_def.id.to_unqualified(),
86+
schema_id: cred_def.schema_id.to_unqualified(),
87+
signature_type: cred_def.signature_type,
88+
tag: cred_def.tag,
89+
value: cred_def.value,
90+
})
91+
}
92+
}
93+
}
94+
}
95+
8096
impl From<CredentialDefinition> for CredentialDefinitionV1 {
8197
fn from(cred_def: CredentialDefinition) -> Self {
8298
match cred_def {

libindy/src/domain/anoncreds/credential_request.rs

+12
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ pub struct CredentialRequestMetadata {
2626
pub master_secret_name: String
2727
}
2828

29+
impl CredentialRequest {
30+
pub fn to_unqualified(self) -> CredentialRequest {
31+
CredentialRequest {
32+
prover_did: self.prover_did.to_unqualified(),
33+
cred_def_id: self.cred_def_id.to_unqualified(),
34+
blinded_ms: self.blinded_ms,
35+
blinded_ms_correctness_proof: self.blinded_ms_correctness_proof,
36+
nonce: self.nonce
37+
}
38+
}
39+
}
40+
2941
impl Validatable for CredentialRequest {
3042
fn validate(&self) -> Result<(), String> {
3143
self.cred_def_id.validate()?;

libindy/src/domain/anoncreds/revocation_registry_definition.rs

+16
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,22 @@ pub enum RevocationRegistryDefinition {
8585
RevocationRegistryDefinitionV1(RevocationRegistryDefinitionV1)
8686
}
8787

88+
impl RevocationRegistryDefinition {
89+
pub fn to_unqualified(self) -> RevocationRegistryDefinition {
90+
match self {
91+
RevocationRegistryDefinition::RevocationRegistryDefinitionV1(rev_ref_def) => {
92+
RevocationRegistryDefinition::RevocationRegistryDefinitionV1(RevocationRegistryDefinitionV1 {
93+
id: rev_ref_def.id.to_unqualified(),
94+
revoc_def_type: rev_ref_def.revoc_def_type,
95+
tag: rev_ref_def.tag,
96+
cred_def_id: rev_ref_def.cred_def_id.to_unqualified(),
97+
value: rev_ref_def.value,
98+
})
99+
}
100+
}
101+
}
102+
}
103+
88104
impl From<RevocationRegistryDefinition> for RevocationRegistryDefinitionV1 {
89105
fn from(rev_reg_def: RevocationRegistryDefinition) -> Self {
90106
match rev_reg_def {

libindy/src/domain/anoncreds/schema.rs

+16
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,22 @@ pub enum Schema {
2828
SchemaV1(SchemaV1)
2929
}
3030

31+
impl Schema {
32+
pub fn to_unqualified(self) -> Schema {
33+
match self {
34+
Schema::SchemaV1(schema) => {
35+
Schema::SchemaV1(SchemaV1 {
36+
id: schema.id.to_unqualified(),
37+
name: schema.name,
38+
version: schema.version,
39+
attr_names: schema.attr_names,
40+
seq_no: schema.seq_no,
41+
})
42+
}
43+
}
44+
}
45+
}
46+
3147
impl From<Schema> for SchemaV1 {
3248
fn from(schema: Schema) -> Self {
3349
match schema {

libindy/src/services/anoncreds/helpers.rs

+33-29
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ use domain::crypto::did::DidValue;
88
use domain::anoncreds::schema::SchemaId;
99
use domain::anoncreds::credential_definition::CredentialDefinitionId;
1010
use domain::anoncreds::revocation_registry_definition::RevocationRegistryId;
11+
use domain::anoncreds::schema::Schema;
12+
use domain::anoncreds::credential_definition::CredentialDefinition;
13+
use domain::anoncreds::revocation_registry_definition::RevocationRegistryDefinition;
1114
use domain::anoncreds::credential_offer::CredentialOffer;
15+
use domain::anoncreds::credential_request::CredentialRequest;
1216
use domain::anoncreds::proof_request::ProofRequest;
1317

1418
use std::collections::{HashSet, HashMap};
@@ -105,42 +109,42 @@ pub fn get_non_revoc_interval(global_interval: &Option<NonRevocedInterval>, loca
105109
interval
106110
}
107111

108-
pub fn to_unqualified(entity: &str) -> IndyResult<String> {
109-
info!("to_unqualified >>> entity: {:?}", entity);
110-
111-
if entity.starts_with(DidValue::PREFIX) {
112-
return Ok(DidValue(entity.to_string()).to_unqualified().0);
113-
}
114-
115-
if entity.starts_with(SchemaId::PREFIX) {
116-
return Ok(SchemaId(entity.to_string()).to_unqualified().0);
117-
}
112+
macro_rules! _id_to_unqualified {
113+
($entity:expr, $type_:ident) => ({
114+
if $entity.starts_with($type_::PREFIX) {
115+
return Ok($type_($entity.to_string()).to_unqualified().0);
116+
}
117+
})
118+
}
118119

119-
if entity.starts_with(CredentialDefinitionId::PREFIX) {
120-
return Ok(CredentialDefinitionId(entity.to_string()).to_unqualified().0);
121-
}
120+
macro_rules! _object_to_unqualified {
121+
($entity:expr, $type_:ident) => ({
122+
if let Ok(object) = ::serde_json::from_str::<$type_>(&$entity) {
123+
return Ok(json!(object.to_unqualified()).to_string())
124+
}
125+
})
126+
}
122127

123-
if entity.starts_with(RevocationRegistryId::PREFIX) {
124-
return Ok(RevocationRegistryId(entity.to_string()).to_unqualified().0);
125-
}
128+
pub fn to_unqualified(entity: &str) -> IndyResult<String> {
129+
info!("to_unqualified >>> entity: {:?}", entity);
126130

127-
if let Ok(cred_offer) = ::serde_json::from_str::<CredentialOffer>(&entity) {
128-
let cred_offer = cred_offer.to_unqualified();
129-
return serde_json::to_string(&cred_offer)
130-
.map_err(|err| IndyError::from_msg(IndyErrorKind::InvalidState, format!("Cannot serialize Credential Offer: {:?}", err)));
131-
}
131+
_id_to_unqualified!(entity, DidValue);
132+
_id_to_unqualified!(entity, SchemaId);
133+
_id_to_unqualified!(entity, CredentialDefinitionId);
134+
_id_to_unqualified!(entity, RevocationRegistryId);
132135

133-
if let Ok(proof_request) = ::serde_json::from_str::<ProofRequest>(&entity) {
134-
let proof_request = proof_request.to_unqualified();
135-
return serde_json::to_string(&proof_request)
136-
.map_err(|err| IndyError::from_msg(IndyErrorKind::InvalidState, format!("Cannot serialize Proof Request: {:?}", err)));
137-
}
136+
_object_to_unqualified!(entity, Schema);
137+
_object_to_unqualified!(entity, CredentialDefinition);
138+
_object_to_unqualified!(entity, RevocationRegistryDefinition);
139+
_object_to_unqualified!(entity, CredentialOffer);
140+
_object_to_unqualified!(entity, CredentialRequest);
141+
_object_to_unqualified!(entity, ProofRequest);
138142

139143
Ok(entity.to_string())
140144
}
141145

142146
#[cfg(test)]
143-
mod tests{
147+
mod tests {
144148
use super::*;
145149

146150
fn _interval() -> NonRevocedInterval { NonRevocedInterval { from: None, to: Some(123) } }
@@ -165,7 +169,7 @@ mod tests{
165169

166170
mod to_unqualified {
167171
use super::*;
168-
172+
169173
const DID_QUALIFIED: &str = "did:sov:NcYxiDXkpYi6ov5FcYDi1e";
170174
const DID_UNQUALIFIED: &str = "NcYxiDXkpYi6ov5FcYDi1e";
171175
const SCHEMA_ID_QUALIFIED: &str = "schema:sov:did:sov:NcYxiDXkpYi6ov5FcYDi1e:2:gvt:1.0";
@@ -176,7 +180,7 @@ mod tests{
176180
const REV_REG_ID_UNQUALIFIED: &str = "NcYxiDXkpYi6ov5FcYDi1e:4:NcYxiDXkpYi6ov5FcYDi1e:3:CL:NcYxiDXkpYi6ov5FcYDi1e:2:gvt:1.0:tag:CL_ACCUM:TAG_1";
177181
const SCHEMA_ID_WITH_SPACES_QUALIFIED: &str = "schema:sov:did:sov:NcYxiDXkpYi6ov5FcYDi1e:2:Passport Schema:1.0";
178182
const SCHEMA_ID_WITH_SPACES_UNQUALIFIED: &str = "NcYxiDXkpYi6ov5FcYDi1e:2:Passport Schema:1.0";
179-
183+
180184
#[test]
181185
fn test_to_unqualified() {
182186
// DID

libindy/tests/anoncreds.rs

+48-5
Original file line numberDiff line numberDiff line change
@@ -3452,14 +3452,57 @@ mod high_cases {
34523452

34533453
mod to_unqualified {
34543454
use super::*;
3455+
use utils::domain::anoncreds::schema::SchemaV1;
3456+
use utils::domain::anoncreds::credential_definition::CredentialDefinitionV1;
3457+
use utils::domain::anoncreds::credential_offer::CredentialOffer;
3458+
use utils::domain::anoncreds::credential_request::CredentialRequest;
34553459

34563460
#[test]
3457-
fn to_unqualified() {
3458-
let qualified = "did:sov:NcYxiDXkpYi6ov5FcYDi1e";
3459-
let unqualified = "NcYxiDXkpYi6ov5FcYDi1e";
3461+
fn to_unqualified_ids() {
3462+
assert_eq!(DID_MY1, anoncreds::to_unqualified(DID_MY1_V1).unwrap());
3463+
assert_eq!(DID_MY1, anoncreds::to_unqualified(DID_MY1).unwrap());
34603464

3461-
assert_eq!(unqualified, anoncreds::to_unqualified(qualified).unwrap());
3462-
assert_eq!(unqualified, anoncreds::to_unqualified(unqualified).unwrap());
3465+
assert_eq!(anoncreds::gvt_schema_id(), anoncreds::to_unqualified(&anoncreds::gvt_schema_id_fully_qualified()).unwrap());
3466+
assert_eq!(anoncreds::gvt_cred_def_id(), anoncreds::to_unqualified(&anoncreds::gvt_cred_def_id_fully_qualified()).unwrap());
3467+
assert_eq!(anoncreds::local_gvt_cred_def_id(), anoncreds::to_unqualified(&anoncreds::local_gvt_cred_def_id_fully_qualified()).unwrap());
3468+
}
3469+
3470+
#[test]
3471+
fn to_unqualified_objects() {
3472+
let setup = Setup::wallet();
3473+
3474+
let (schema_id, schema_json) = anoncreds::issuer_create_schema(ISSUER_DID_V1, GVT_SCHEMA_NAME, SCHEMA_VERSION, GVT_SCHEMA_ATTRIBUTES).unwrap();
3475+
3476+
assert_eq!(anoncreds::gvt_schema_id(), anoncreds::to_unqualified(&schema_id).unwrap());
3477+
3478+
let schema_json_un = anoncreds::to_unqualified(&schema_json).unwrap();
3479+
let schema: SchemaV1 = ::serde_json::from_str(&schema_json_un).unwrap();
3480+
assert_eq!(anoncreds::gvt_schema_id(), schema.id.0);
3481+
3482+
let (cred_def_id, cred_def_json) = anoncreds::issuer_create_credential_definition(setup.wallet_handle, ISSUER_DID_V1, &schema_json, TAG_1, None, None).unwrap();
3483+
3484+
assert_eq!(anoncreds::local_gvt_cred_def_id(), anoncreds::to_unqualified(&cred_def_id).unwrap());
3485+
3486+
let cred_def_json_un = anoncreds::to_unqualified(&cred_def_json).unwrap();
3487+
let cred_def: CredentialDefinitionV1 = ::serde_json::from_str(&cred_def_json_un).unwrap();
3488+
assert_eq!(anoncreds::local_gvt_cred_def_id(), cred_def.id.0);
3489+
assert_eq!(anoncreds::gvt_schema_id(), cred_def.schema_id.0);
3490+
3491+
let cred_offer_json = anoncreds::issuer_create_credential_offer(setup.wallet_handle, &cred_def_id).unwrap();
3492+
3493+
let cred_offer_json_un = anoncreds::to_unqualified(&cred_offer_json).unwrap();
3494+
let cred_offer: CredentialOffer = ::serde_json::from_str(&cred_offer_json_un).unwrap();
3495+
assert_eq!(anoncreds::local_gvt_cred_def_id(), cred_offer.cred_def_id.0);
3496+
assert_eq!(anoncreds::gvt_schema_id(), cred_offer.schema_id.0);
3497+
3498+
anoncreds::prover_create_master_secret(setup.wallet_handle, COMMON_MASTER_SECRET).unwrap();
3499+
3500+
let (cred_req_json, _) = anoncreds::prover_create_credential_req(setup.wallet_handle, DID_MY1_V1, &cred_offer_json, &cred_def_json_un, COMMON_MASTER_SECRET).unwrap();
3501+
3502+
let cred_req_json_un = anoncreds::to_unqualified(&cred_req_json).unwrap();
3503+
let cred_req: CredentialRequest = ::serde_json::from_str(&cred_req_json_un).unwrap();
3504+
assert_eq!(DID_MY1.to_string(), cred_req.prover_did.0);
3505+
assert_eq!(anoncreds::local_gvt_cred_def_id(), cred_req.cred_def_id.0);
34633506
}
34643507
}
34653508
}

vcx/libvcx/debian/changelog

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ libvcx (0.4.2) unstable; urgency=medium
33
[ Hyperledger ]
44

55
## 0.4.2
6-
* Extended provisioning config to accept optional `did_method` filed. This field should be used to create fully qualified DIDs.
6+
* *EXPERIMENTAL*
7+
Extended provisioning config to accept optional `did_method` filed. This field should be used to create fully qualified DIDs.
78
The format of identifiers used on CredentialIssuance and ProofPresentation will determine based on the type of remote DID.
89
* Bugfixes
910

wrappers/ios/libindy-pod/Indy/Wrapper/IndyAnoncreds.h

+10-6
Original file line numberDiff line numberDiff line change
@@ -1106,12 +1106,16 @@ And is documented in this HIPE:
11061106
11071107
@param entity: utarget entity to disqualify.
11081108
Can be one of:
1109-
Did
1110-
SchemaId
1111-
CredentialDefinitionId
1112-
RevocationRegistryId
1113-
CredentialOffer
1114-
ProofRequest
1109+
Did
1110+
SchemaId
1111+
CredentialDefinitionId
1112+
RevocationRegistryId
1113+
Schema
1114+
CredentialDefinition
1115+
RevocationRegistryDefinition
1116+
CredentialOffer
1117+
CredentialRequest
1118+
ProofRequest
11151119
11161120
Returns entity either in unqualified form or original if casting isn't possible
11171121
*/

wrappers/java/src/main/java/org/hyperledger/indy/sdk/anoncreds/Anoncreds.java

+4
Original file line numberDiff line numberDiff line change
@@ -1555,7 +1555,11 @@ public static CompletableFuture<String> generateNonce() throws IndyException {
15551555
* SchemaId
15561556
* CredentialDefinitionId
15571557
* RevocationRegistryId
1558+
* Schema
1559+
* CredentialDefinition
1560+
* RevocationRegistryDefinition
15581561
* CredentialOffer
1562+
* CredentialRequest
15591563
* ProofRequest
15601564
* @return A future that resolves to entity either in unqualified form or original if casting isn't possible
15611565
* @throws IndyException Thrown if an error occurs when calling the underlying SDK.

wrappers/nodejs/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ This function should be used to the proper casting of fully qualified entity to
931931
2) Verifier prepares a Proof Request based on fully qualified identifiers or Prover, which doesn't support fully qualified identifiers.
932932
3) another case when casting to unqualified form needed
933933
934-
* `entity`: String - target entity to disqualify. Can be one of: Did, SchemaId, CredentialDefinitionId, RevocationRegistryId, CredentialOffer.
934+
* `entity`: String - target entity to disqualify. Can be one of: Did, SchemaId, CredentialDefinitionId, RevocationRegistryId, Schema, CredentialDefinition, RevocationRegistryDefinition, CredentialOffer, CredentialRequest, ProofRequest.
935935
* __->__ `res`: Json - entity either in unqualified form or original if casting isn't possible
936936
937937
### blob_storage

wrappers/python/indy/anoncreds.py

+4
Original file line numberDiff line numberDiff line change
@@ -1873,7 +1873,11 @@ async def to_unqualified(entity: str) -> str:
18731873
SchemaId
18741874
CredentialDefinitionId
18751875
RevocationRegistryId
1876+
Schema
1877+
CredentialDefinition
1878+
RevocationRegistryDefinition
18761879
CredentialOffer
1880+
CredentialRequest
18771881
ProofRequest
18781882
18791883
:return: entity either in unqualified form or original if casting isn't possible

0 commit comments

Comments
 (0)