Skip to content

Commit eefb74e

Browse files
authored
Merge branch 'master' into master
2 parents 0927873 + 0586874 commit eefb74e

File tree

14 files changed

+952
-712
lines changed

14 files changed

+952
-712
lines changed

doc/contributor-resources.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Contributing to Indy SDK
2+
3+
4+
Before contributing to Indy SDK, there are a couple steps that will help your process go much more smoothly.
5+
6+
First, please take a look at our contributing guidelines: [how to contribute to Hyperledger Indy](http://bit.ly/2ugd0bq).
7+
8+
If you are looking for how to sign current or previous commits, go here: [signing your commits](signing-commits.md)
9+
10+
## Connect with the Community
11+
12+
Hyperledger Indy has a vibrant and active community of developers willing to help you answer questions, learn more about self-sovereign identity, and get involved.
13+
14+
You will find the best and most update resources on chat board here: [Hyperledger Rocket Chat](https://chat.hyperledger.org/home)
15+
16+
\#indy-sdk, \#indy-node, and \#indy are the some of the best channels to get started. Please introduce yourself and let us know what you want to accomplish!
17+
18+
## How to Start Working with the Code
19+
20+
1. Fork the indy-sdk repository on Github to your personal account.
21+
22+
1. Add the hyperledger/indy-sdk as the remote upstream:
23+
`git remote add upstream https://github.com/hyperledger/indy-sdk.git`
24+
25+
1. Set up Developer Certificate of Origin and learn how to [sign your commits](signing-commits.md)
26+
27+
1. Take a look at our [release workflow](release-workflow.md)
28+
29+
## How to send a PR
30+
31+
- Do not create big PRs; send a PR for one feature or bug fix only.
32+
If a feature is too big, consider splitting a big PR to a number of small ones.
33+
- Consider sending a design doc into `design` folder (as markdown or PlantUML diagram) for a new feature before implementing it
34+
- Make sure that a new feature or fix is covered by tests (try following TDD)
35+
- Make sure that documentation is updated according to your changes
36+
- Provide a full description of changes in the PR including Jira ticket number if any
37+
- Make sure that all your commits have a DCO sign-off from the author. (add the `-s` flag to all commits)
38+
- Put the link to the PR into `#indy-pr-review` channel in Rocket.Chat
39+
- A reviewer needs to start your tests first (add `test this please` comment to the PR)
40+
- You need to make sure that all the tests pass
41+
- A reviewer needs to review the code and approve the PR. If there are review comments, they will be put into the PR itself.
42+
- You must process them (feel free to reply in the PR threads, or have a discussion in Rocket.Chat if needed)
43+
- A reviewer or maintainer will merge the PR
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# TROUBLE SHOOTING Getting - Started Guide (GSG)
2+
3+
If you setup the demo and encounter a 307 error recommend to take the following steps to cleanup and start over. The communication with the ledger is affected and it is not possible to run the demo. Here are some recommendations for other errors.
4+
* 306: you already have a configured ledger. Perform clean start.
5+
* 301: you are trying to create a ledger but it is already configured. A single failure will cause a problem when opening the ledger. Perform clean install.
6+
* 212: wallet is not found. When this occur stop and start container: Ctrl-C, docker-compose down, docker-compose up
7+
8+
## Overview steps for clean start
9+
10+
1. Remove existing instances
11+
1. Reset source files
12+
1. Perform a new build
13+
1. Start demo
14+
15+
## Steps in detail
16+
17+
1. Make sure containers are closed
18+
19+
```
20+
docker-compose down # to make sure containers are closed
21+
docker image ls # find image names that need to be removed in next step
22+
docker image rm getting-started
23+
docker image rm indy_pool
24+
docker volume ls # find volume name that needs to be removed in next step
25+
docker volume rm gettingstarted_sandbox
26+
```
27+
28+
2. Reset source files
29+
30+
```git tag # choose the latest version and use it as <branch_name>
31+
git checkout <branch_name>
32+
git reset --hard **WARNING** : make copies of any changes you want to keep prior to taking this step
33+
git fetch --all
34+
git pull
35+
```
36+
37+
3. Perform a new build
38+
39+
```
40+
docker-compose build --no-cache # adding no cache to make clean build
41+
```
42+
43+
4. Start demo
44+
45+
```
46+
docker-compose up
47+
```

doc/getting-started/getting-started.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 68DB5E88 \
3030

3131
USER indy
3232

33-
EXPOSE 8888
33+
EXPOSE 8888

doc/getting-started/getting-started.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,3 +921,5 @@ Now that you've had a chance to see how the Libindy implementation works from th
921921
If so, please run [Simulating Getting Started in the Jupiter](run-getting-started.md).
922922
You may need to be signed into GitHub to view this link.
923923
Also you can find the source code [here](https://github.com/hyperledger/indy-sdk/blob/master/samples/python/src/getting_started.py)
924+
925+
If demo gives an error when executing check [Trouble Shooting Guide](Trouble_shoot_GSG.md).

doc/getting-started/run-getting-started.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ To get Jupyter click on the link in output (it must have following format: http:
1818

1919
`docker-compose down`
2020
The command above will stop and delete created network and containers.
21+
22+
### Trouble Shooting
23+
24+
If demo gives an error when executing in Jupyter check [Trouble Shooting Guide](Trouble_shoot_GSG.md).

doc/signing-commits.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Signing commits
2+
3+
If you are here because you forgot to sign your commits, fear not. Check out [how to sign previous commits](#how-to-sign-previous-commits)
4+
5+
We use developer certificate of origin (DCO) in all hyperledger repositories, so to get your pull requests accepted, you must certify your commits by signing off on each commit.
6+
7+
## Signing your current commit
8+
- `$ git commit -s -m "your commit message"`
9+
- To see if your commits have been signed off, run `$ git log --show-signature`
10+
- If you need to re-sign the most current commit, use `$ git commit --amend --no-edit -s`.
11+
12+
The `-s` flag signs the commit message with your name and email.
13+
14+
## How to Sign Previous Commits
15+
1. Use `git log --show-signature` to see which commits need to be signed.
16+
1. Go into interactive rebase mode using `$ git rebase -i HEAD~X` where X is the number of commits up to the most current commit you would like to see.
17+
1. You will see a list of the commits in a text file. **On the line after each commit you need to sign**, add `exec git commit --amend --no-edit -s` with the lowercase `-s` adding a text signature in the commit body. Example that signs both commits:
18+
```
19+
pick 12345 commit message
20+
exec git commit --amend --no-edit -s
21+
pick 67890 commit message
22+
exec git commit --amend --no-edit -s
23+
```
24+
1. If you need to re-sign a bunch of previous commits at once, find the earliest unsigned commit using `git log --show-signature` and use that the HASH of the commit before it in this command: `git rebase --exec 'git commit --amend --no-edit -n -s' -i HASH`. This will sign every commit from most recent to right before the HASH.
25+
1. You will probably need to do a force push `git push -f` if you had previously pushed unsigned commits to remote.

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 {

0 commit comments

Comments
 (0)