Skip to content

Commit 17efba4

Browse files
authored
Merge branch 'master' into feature/contributor-resources
2 parents b0ccf90 + 8672a6e commit 17efba4

File tree

4 files changed

+112
-34
lines changed

4 files changed

+112
-34
lines changed

doc/windows-build.md

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44

55
1. Setup a windows virtual machine. Free images are available at [here](https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/)
66
1. Launch the virtual machine
7-
1. Download Visual Studio Community Edition 2017
7+
1. Download Visual Studio Community Edition 2017 (these instructions also work with Visual Studio Professional 2017)
88
1. Check the boxes for the _Desktop development with C++_ and _Linux Development with C++_
99
1. In the summary portion on the right hand side also check _C++/CLI support_
1010
1. Click install
1111
1. Download git-scm for windows [here](https://git-scm.com/downloads/win)
1212
1. Install git for windows using:
13-
1. _Use Git from Git Bash Only_ so it doesn't change any path settings of the command prompt
14-
1. _Checkout as is, commit Unix-style line endings_. You shouldn't be commiting anything anyway but just in case
15-
1. _Use MinTTY_
16-
1. Check all the boxes for:
17-
1. Enable file system caching
18-
1. Enable Git Credential Manager
19-
1. Enable symbolic links
13+
1. _Use Git from Git Bash Only_ so it doesn't change any path settings of the command prompt
14+
1. _Checkout as is, commit Unix-style line endings_. You shouldn't be commiting anything anyway but just in case
15+
1. _Use MinTTY_
16+
1. Check all the boxes for:
17+
1. Enable file system caching
18+
1. Enable Git Credential Manager
19+
1. Enable symbolic links
2020
1. Download rust for windows [here](https://www.rust-lang.org/en-US/install.html)
21-
1. Choose installation option *1*
21+
1. Choose installation option *1*
2222

2323
## Get/build dependencies
2424

@@ -56,19 +56,19 @@ git clone https://github.com/hyperledger/indy-sdk.git
5656

5757
Download http://www.sqlite.org/2017/sqlite-amalgamation-3180000.zip
5858

59-
Create empty static library project and add sqlite.c file and 2 headers from extracted
59+
Create an empty static library project in Visual Studio and add `sqlite.c` file and 2 headers from extracted
6060
archive. Then just build it.
6161

6262
### Build libzmq
6363

64-
Follow to https://http://zeromq.org/intro.
64+
Follow to http://zeromq.org/intro.
6565
- Download sources from last stable release for Windows.
66-
- launch zeromq-x.x.x/builds/msvc/vs2015/libzmq.sln.
67-
- if necessary change solution platforms on x64(if you are working on x64 arch).
68-
- on main menu bar choose build->build libzmq.
69-
- if build project was succeed, in path zeromq-x.x.x/bin/x64/Debug/vXXX/dynamic has appeared
70-
two files libzmq.dll and libzmq.lib.
71-
- rename libzmq.lib to zmq.lib.
66+
- Open `zeromq-x.x.x/builds/msvc/vs2015/libzmq.sln` with Visual Studio
67+
- If necessary change solution platforms on x64(if you are working on x64 arch).
68+
- On main menu bar choose build->build libzmq.
69+
- If build project was successful, two files `libzmq.dll` and `libzmq.lib` should appear
70+
in path `zeromq-x.x.x/bin/x64/Debug/vXXX/dynamic`.
71+
- rename `libzmq.lib` to `zmq.lib`.
7272

7373
## Build
7474

@@ -82,18 +82,19 @@ Follow to https://http://zeromq.org/intro.
8282
```
8383

8484
Note that depending on the version of Visual Studio placement of vcvars64.bat can be different. For example, it can be
85-
`C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat`
86-
- execute "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
85+
`"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat"`
86+
- Execute `"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"`
8787
- Point path to this directory using environment variables:
88-
- set INDY_PREBUILT_DEPS_DIR=C:\BIN\x64
89-
- set INDY_CRYPTO_PREBUILT_DEPS_DIR=C:\BIN\x64
90-
- set MILAGRO_DIR=C:\BIN\x64
91-
- set LIBZMQ_PREFIX=C:\BIN\x64
92-
- set SODIUM_LIB_DIR=C:\BIN\x64
93-
- set OPENSSL_DIR=C:\BIN\x64
94-
- set PATH to find .dlls:
95-
- set PATH=C:\BIN\x64\lib;%PATH%
96-
- change dir to indy-sdk/libindy and run cargo (you may want to add --release --target x86_64-pc-windows-msvc keys to cargo)
88+
- `set INDY_PREBUILT_DEPS_DIR=C:\BIN\x64`
89+
- `set INDY_CRYPTO_PREBUILT_DEPS_DIR=C:\BIN\x64`
90+
- `set MILAGRO_DIR=C:\BIN\x64`
91+
- `set LIBZMQ_PREFIX=C:\BIN\x64`
92+
- `set SODIUM_LIB_DIR=C:\BIN\x64`
93+
- `set OPENSSL_DIR=C:\BIN\x64`
94+
- Set PATH to find .dlls:
95+
- `set PATH=C:\BIN\x64\lib;%PATH%`
96+
- change dir to `indy-sdk/libindy` and run `cargo build` (you may want to add `--release --target x86_64-pc-windows-msvc`
97+
keys to cargo)
9798

9899
## openssl-sys workaround
99100

@@ -109,7 +110,7 @@ and add
109110
println!("cargo:rustc-link-lib=dylib=gdi32");
110111
```
111112

112-
to the end of main() function.
113+
to the end of `main()` function.
113114

114115
Then try to rebuild whole project.
115116

libindy/src/services/anoncreds/prover.rs

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,19 @@ impl Prover {
297297
match restrictions.as_ref() {
298298
// Convert old restrictions format to valid wql
299299
Some(&serde_json::Value::Array(ref array)) => {
300-
query.insert("$or".to_string(), serde_json::Value::Array(array.to_vec()));
300+
// skip Null's
301+
let mut res: Vec<serde_json::Value> = Vec::new();
302+
for sub_query in array {
303+
let sub_query = sub_query.as_object()
304+
.ok_or(CommonError::InvalidStructure("Restriction is invalid".to_string()))?
305+
.clone()
306+
.into_iter()
307+
.filter(|&(_, ref v)| !v.is_null())
308+
.collect();
309+
res.push(serde_json::Value::Object(sub_query));
310+
}
311+
312+
query.insert("$or".to_string(), serde_json::Value::Array(res));
301313
}
302314
Some(&serde_json::Value::Object(ref object)) => {
303315
query.extend(object.clone());
@@ -389,7 +401,7 @@ impl Prover {
389401
}
390402

391403
for predicate in req_predicates_for_credential {
392-
sub_proof_request_builder.add_predicate(&attr_common_view(&predicate.predicate_info.name), "GE", predicate.predicate_info.p_value)?;
404+
sub_proof_request_builder.add_predicate(&attr_common_view(&predicate.predicate_info.name), "GE", predicate.predicate_info.p_value)?;
393405
}
394406

395407
let sub_proof_request = sub_proof_request_builder.finalize()?;
@@ -573,6 +585,31 @@ mod tests {
573585
assert_eq!(expected_query, _value(&query));
574586
}
575587

588+
#[test]
589+
fn build_query_works_for_restriction_in_old_format_with_nulls() {
590+
let ps = Prover::new();
591+
592+
let restriction_1 = json!({"schema_id": SCHEMA_ID, "issuer_did": serde_json::Value::Null});
593+
let restriction_2 = json!({"schema_id": serde_json::Value::Null, "cred_def_id": CRED_DEF_ID});
594+
let restirctions = serde_json::Value::Array(vec![restriction_1, restriction_2]);
595+
596+
let query = ps.build_query(ATTR_NAME, ATTR_REFERENT, &Some(restirctions), &None).unwrap();
597+
598+
let expected_query = json!({
599+
"attr::name::marker": ATTRIBUTE_EXISTENCE_MARKER,
600+
"$or": vec![
601+
json!({
602+
"schema_id": SCHEMA_ID,
603+
}),
604+
json!({
605+
"cred_def_id": CRED_DEF_ID,
606+
})
607+
],
608+
});
609+
610+
assert_eq!(expected_query, _value(&query));
611+
}
612+
576613
#[test]
577614
fn build_query_works_for_extra_query_with_other_referent() {
578615
let ps = Prover::new();
@@ -597,8 +634,8 @@ mod tests {
597634
mod attribute_satisfy_predicate {
598635
use super::*;
599636

600-
fn predicate_info() -> PredicateInfo{
601-
PredicateInfo{
637+
fn predicate_info() -> PredicateInfo {
638+
PredicateInfo {
602639
name: "age".to_string(),
603640
p_type: PredicateTypes::GE,
604641
p_value: 8,

libindy/tests/anoncreds.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,46 @@ mod high_cases {
11531153

11541154
WalletUtils::close_wallet(wallet_handle).unwrap();
11551155
}
1156+
1157+
#[test]
1158+
fn prover_get_credentials_for_proof_req_works_for_null_restrictions() {
1159+
AnoncredsUtils::init_common_wallet();
1160+
1161+
let wallet_handle = WalletUtils::open_wallet(ANONCREDS_WALLET_CONFIG, WALLET_CREDENTIALS).unwrap();
1162+
1163+
let proof_req = r#"{
1164+
"nonce":"123432421212",
1165+
"name":"proof_req_1",
1166+
"version":"0.1",
1167+
"requested_attributes":{
1168+
"attr1_referent":{
1169+
"name":"name",
1170+
"restrictions":[
1171+
{
1172+
"schema_id":null,
1173+
"schema_issuer_did":null,
1174+
"schema_name":null,
1175+
"schema_version":null,
1176+
"issuer_did":"NcYxiDXkpYi6ov5FcYDi1e",
1177+
"cred_def_id":null
1178+
}
1179+
]
1180+
}
1181+
},
1182+
"requested_predicates":{
1183+
}
1184+
}"#;
1185+
1186+
let credentials_json = AnoncredsUtils::prover_get_credentials_for_proof_req(wallet_handle, &proof_req).unwrap();
1187+
1188+
let credentials: CredentialsForProofRequest = serde_json::from_str(&credentials_json).unwrap();
1189+
assert_eq!(credentials.attrs.len(), 1);
1190+
1191+
let credentials_for_attr_1 = credentials.attrs.get("attr1_referent").unwrap();
1192+
assert_eq!(credentials_for_attr_1.len(), 1);
1193+
1194+
WalletUtils::close_wallet(wallet_handle).unwrap();
1195+
}
11561196
}
11571197

11581198
mod attribute_restrictions_wql_format {

wrappers/python/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Pull requests welcome!
1212
pip install python3-indy
1313

1414
Note that before you can use python wrapper you must install c-callable SDK.
15-
See the section "How-to-install" in [Indy SDK](README.md)
15+
See the section "Installing the SDK" in the [Indy SDK documentation](../../README.md#installing-the-sdk)
1616

1717
### How to build
1818

0 commit comments

Comments
 (0)