diff --git a/CHANGELOG.md b/CHANGELOG.md index e483a363cd..77e27942d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## 1.14.2 - 2020-01-31 +* LibVCX Aries support: + * Implemented Basic Message RFC (IS-1189) +* Indy-CLI changes: + * Added new command `pool set-protocol-version` to set a protocol version that will be used for ledger requests (IS-1391). + * Added new command `payment-address new` that does exactly the same work as the existing `payment-address create` command. + The new command was added to match the naming of `did new` command. The `payment-address create` command will be removed in future releases (IS-1415). +* Bugfixes + * Updated behavior of `indy_store_their_did` function to allow updating of existing `theirDID` record`. It can be used to rotate a pairwise key (IS-1166). + * Enhanced validation of `schema_json`: added check that `id` is consistent with `name` and `version` values (IS-1430). + * Updated Vcx library to support "names" parameter in Proof Request Revealed Attributes (IS-1381) + * Added support of the additional format of `rev_states_json` which is used for proof creation. Both `rev_reg_def_id` and `credential_id` can be used as map keys. + `credential_id` must be used in case of proving that two credentials matching the same `rev_reg_def_id` are not revoked at the same timestamp (IS-1447). + * others minor bugfixes + ## 1.14.1 - 2019-12-30 * Bugfixes diff --git a/Jenkinsfile.cd b/Jenkinsfile.cd index 600a31d649..1e572acfa4 100644 --- a/Jenkinsfile.cd +++ b/Jenkinsfile.cd @@ -356,8 +356,15 @@ def linuxLibindyBuild(file, env_name, network_name, full_testing) { libindyBuildFinished[env_name] = true - echo "${env_name} Libindy Test: Test" testEnv.inside("--network=${network_name}") { + echo "${env_name} Libindy Test: Test Libindy submodules" + + for (component in ["libindy/indy-api-types", "libindy/indy-utils", "libindy/indy-wallet"]) { + testLibindyComponent(component) + } + + echo "${env_name} Libindy Test: Test" + def features_args = full_testing ? "--features sodium_static" : "--features \"sodium_static only_high_cases\"" sh """ @@ -382,6 +389,14 @@ def linuxLibindyBuild(file, env_name, network_name, full_testing) { } } +def testLibindyComponent(directory) { + sh """ + cd ${directory} + RUST_BACKTRACE=1 cargo test --release --no-run + RUST_BACKTRACE=1 RUST_LOG=indy::=debug,zmq=trace RUST_TEST_THREADS=1 TEST_POOL_IP=10.0.0.2 cargo test --release + """ +} + def linuxVcxBuild(file, env_name, network_name) { def poolInst try { @@ -900,13 +915,13 @@ def macosTesting() { } } -def macosRunPool(pool_name){ +def macosRunPool(pool_name) { sh "docker rm -f ${pool_name} || true" sh "docker build -f ci/indy-pool.dockerfile -t ${pool_name} ci" sh "docker run -d --name ${pool_name} -p 9701-9708:9701-9708 ${pool_name}" } -def macosStopPool(pool_name){ +def macosStopPool(pool_name) { try { sh "docker stop ${pool_name}" } catch (ignore) { @@ -1025,7 +1040,7 @@ def linuxPublishing(file, env_name, build_wrappers) { libindyDebPublishing(testEnv, libindyVersion, env_name) libnullpayDebPublishing(testEnv, env_name) libvcxDebPublishing(testEnv, env_name) - libindyCliDebPublishing(testEnv, libindyVersion, env_name) + libindyCliDebPublishing(testEnv, libindyVersion, env_name) // Note that last deb publishing should pass resetCache = true inside if (build_wrappers) { pythonWrapperPublishing(testEnv, false, 'wrappers/python', 'libindy') @@ -1271,7 +1286,7 @@ def libindyCliDebPublishing(testEnv, version, env_name) { setLibindyDependencyVersion("cli/debian/control") - debPublishing(testEnv, "cli", "indy-cli", version, "IndyCliBuildResult${env_name}", "libindyCliDebs${env_name}", env_name) + debPublishing(testEnv, "cli", "indy-cli", version, "IndyCliBuildResult${env_name}", "libindyCliDebs${env_name}", env_name, true) } def libnullpayDebPublishing(testEnv, env_name) { @@ -1301,7 +1316,7 @@ def setLibindyDependencyVersion(file) { sh "sed -i -e \"s/^\\(Depends: .*libindy\\)\\(\\s*[,]\\{,1\\}.*\\)/\\1 (= $replaceVersion)\\2/\" $file" } -def debPublishing(testEnv, directory, packageName, version, inStashName, outStashName, env_name) { +def debPublishing(testEnv, directory, packageName, version, inStashName, outStashName, env_name, resetCache = false) { dir("$directory/sovrin-packaging") { downloadPackagingUtils() } @@ -1314,8 +1329,10 @@ def debPublishing(testEnv, directory, packageName, version, inStashName, outStas unstash name: inStashName + def extraFlags = resetCache ? "" : "--no-reset-cache" + withCredentials([file(credentialsId: 'SovrinRepoSSHKey', variable: 'sovrin_key')]) { - sh "cd $directory && ./deb-build-and-upload.sh $packageName $version $env.BRANCH_NAME $suffix $SOVRIN_SDK_REPO_NAME $SOVRIN_REPO_HOST $sovrin_key $package_type" + sh "cd $directory && ./deb-build-and-upload.sh $packageName $version $env.BRANCH_NAME $suffix $SOVRIN_SDK_REPO_NAME $SOVRIN_REPO_HOST $sovrin_key $package_type $extraFlags" if (env.BRANCH_NAME == 'rc') { stash includes: "$directory/debs/*", name: outStashName @@ -1474,7 +1491,7 @@ def publishingRCtoStable() { publishLibVCXWindowsFilesRCtoStable(libvcxVersion) echo "Moving ${env_name} RC artifacts to Stable: libvcx" - publishLibvcxDebRCtoStable(testEnv, env_name) + publishLibvcxDebRCtoStable(testEnv, env_name) // Note that last deb publishing should pass resetCache = true inside echo 'Moving Ubuntu RC artifacts to Stable: vcx java wrapper' vcxJavaWrapperPublishing(testEnv, true) @@ -1682,10 +1699,10 @@ def publishLibnullpayDebRCtoStable(testEnv, env_name) { def publishLibvcxDebRCtoStable(testEnv, env_name) { def libvcxVersion = getSrcVersion("vcx/libvcx") - publishDebRCtoStable(testEnv, "libvcx", "vcx/libvcx", libvcxVersion, "libvcxDebs", false, env_name) + publishDebRCtoStable(testEnv, "libvcx", "vcx/libvcx", libvcxVersion, "libvcxDebs", false, env_name, true) } -def publishDebRCtoStable(testEnv, packageName, folder, version, stashName, moveDevArtifacts, env_name) { +def publishDebRCtoStable(testEnv, packageName, folder, version, stashName, moveDevArtifacts, env_name, resetCache = false) { testEnv.inside { def rcFullVersion = "${version}~${env.BUILD_NUMBER}" def package_type = ubuntuPakageTypes[env_name] @@ -1703,15 +1720,17 @@ def publishDebRCtoStable(testEnv, packageName, folder, version, stashName, moveD sh "fakeroot deb-reversion -v $version $folder/debs/\"$packageName\"-dev_\"$rcFullVersion\"_amd64.deb" } + def extraFlags = resetCache ? "" : "--no-reset-cache" + withCredentials([file(credentialsId: 'SovrinRepoSSHKey', variable: 'sovrin_key')]) { path = sh(returnStdout: true, script: 'pwd').trim() - sh "./sovrin-packaging/upload_debs.py $path $SOVRIN_SDK_REPO_NAME stable --distro=${package_type} --host $SOVRIN_REPO_HOST --ssh-key $sovrin_key" + sh "./sovrin-packaging/upload_debs.py $path $SOVRIN_SDK_REPO_NAME stable --distro=${package_type} --host $SOVRIN_REPO_HOST --ssh-key $sovrin_key $extraFlags" } } } -def buildTestEnv(file, env_name, name="libindy", prebuilt_images=[:]) { +def buildTestEnv(file, env_name, name = "libindy", prebuilt_images = [:]) { dir('libindy') { echo "${env_name} Build test environment" for (entry in mapToList(prebuilt_images)) { @@ -1840,7 +1859,7 @@ def linuxModuleTesting(file, env_name, network_name, module_tester) { linuxModuleTesting(file, env_name, network_name, module_tester, 'ubuntu') } -def linuxModuleTesting(file, env_name, network_name, module_tester, node_label, image_name="libindy", prebuilt_images = [:]) { +def linuxModuleTesting(file, env_name, network_name, module_tester, node_label, image_name = "libindy", prebuilt_images = [:]) { node(node_label) { cleanWs() def poolInst diff --git a/Jenkinsfile.ci b/Jenkinsfile.ci index e9f0130f5f..2bc2902338 100644 --- a/Jenkinsfile.ci +++ b/Jenkinsfile.ci @@ -480,8 +480,15 @@ def linuxLibindyBuild(file, env_name, network_name, full_testing) { libindyBuildFinished[env_name] = true - echo "${env_name} Libindy Test: Test" testEnv.inside("--network=${network_name}") { + echo "${env_name} Libindy Test: Test Libindy submodules" + + for (component in ["libindy/indy-api-types", "libindy/indy-utils", "libindy/indy-wallet"]) { + testLibindyComponent(component) + } + + echo "${env_name} Libindy Test: Test" + def features_args = full_testing ? "--features sodium_static" : "--features \"sodium_static only_high_cases\"" sh """ @@ -506,6 +513,14 @@ def linuxLibindyBuild(file, env_name, network_name, full_testing) { } } +def testLibindyComponent(directory) { + sh """ + cd ${directory} + RUST_BACKTRACE=1 cargo test --no-run + RUST_BACKTRACE=1 RUST_LOG=indy::=debug,zmq=trace RUST_TEST_THREADS=1 TEST_POOL_IP=10.0.0.2 cargo test + """ +} + def linuxVcxBuild(file, env_name, network_name) { def poolInst try { diff --git a/README.md b/README.md index 4ac8c74584..1f442779e7 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,9 @@ If you have just started learning about self-sovereign identity, here are some r * This extended tutorial introduces Indy, explains how the whole ecosystem works, and how the functions in the SDK can be used to construct rich clients: [Indy-SDK Getting-Started Guide](docs/getting-started/indy-walkthrough.md) + * **Please take note** that this tutorial doesn't cover how sides set up a connection and exchange messages. + How this communication channel can be built you can find at [Aries](https://github.com/hyperledger/aries) project which describes it in great details. + * Hyperledger Indy Working Group calls happen every Thursday at 8amPT, 9amMT, 11amET, 4pmBST. Add to your calendar and join from any device: https://zoom.us/j/232861185 * A recent webinar explaining self-sovereign identity using Hyperledger Indy and Sovrin: [SSI Meetup Webinar](https://youtu.be/RllH91rcFdE?t=4m30s) diff --git a/Specs/libindy/1.14.2/libindy.podspec.json b/Specs/libindy/1.14.2/libindy.podspec.json new file mode 100644 index 0000000000..b7e4697243 --- /dev/null +++ b/Specs/libindy/1.14.2/libindy.podspec.json @@ -0,0 +1,23 @@ +{ + "name": "libindy", + "version": "1.14.2", + "summary": "Summary TODO.", + "description": "Description TODO.", + "homepage": "TODO", + "license": { + "type": "Apache License 2.0", + "file": "LICENSE" + }, + "authors": { + "Daniel Hardman": "daniel.hardman@evernym.com" + }, + "platforms": { + "ios": "10.0" + }, + "source": { + "http": "https://repo.sovrin.org/ios/libindy/stable/libindy-core/1.14.2/libindy.tar.gz" + }, + "source_files": "*.h", + "vendored_libraries": "*.a", + "requires_arc": false +} diff --git a/ci/acceptance/ubuntu_acceptance.dockerfile b/ci/acceptance/ubuntu_acceptance.dockerfile index cacf10d91c..e613b1de07 100755 --- a/ci/acceptance/ubuntu_acceptance.dockerfile +++ b/ci/acceptance/ubuntu_acceptance.dockerfile @@ -11,7 +11,6 @@ RUN apt-get update && \ apt-get install -y \ software-properties-common -RUN add-apt-repository ppa:jonathonf/python-3.6 RUN apt-get update && \ apt-get install -y \ python3.5 \ diff --git a/ci/deb-build-and-upload.sh b/ci/deb-build-and-upload.sh index c88eb7b35c..614872c9c5 100644 --- a/ci/deb-build-and-upload.sh +++ b/ci/deb-build-and-upload.sh @@ -4,7 +4,7 @@ set -e set -x if [ "$1" = "--help" ] ; then - echo "Usage: " + echo "Usage: " return fi @@ -16,6 +16,7 @@ repo="$5" host="$6" key="$7" package_type="$8" +extra_flags="$9" [ -z $package ] && exit 1 [ -z $version ] && exit 2 @@ -32,4 +33,4 @@ dpkg-buildpackage -tc mkdir debs && mv ../*.deb ./debs/ -./sovrin-packaging/upload_debs.py ./debs $repo $type --distro=$package_type --host $host --ssh-key $key +./sovrin-packaging/upload_debs.py ./debs $repo $type --distro=$package_type --host $host --ssh-key $key $extra_flags diff --git a/cli/Cargo.lock b/cli/Cargo.lock index 91081624e8..2146beee2a 100644 --- a/cli/Cargo.lock +++ b/cli/Cargo.lock @@ -10,7 +10,7 @@ name = "aho-corasick" version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "memchr 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -48,7 +48,7 @@ name = "atty" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -60,7 +60,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -70,8 +70,8 @@ name = "backtrace-sys" version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -100,12 +100,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "byteorder" -version = "1.2.7" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cc" -version = "1.0.27" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -154,7 +154,7 @@ name = "csv" version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -164,7 +164,7 @@ name = "dirs" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "redox_users 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -181,22 +181,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "failure" -version = "0.1.3" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "failure_derive" -version = "0.1.3" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.23 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -205,7 +205,7 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crc32fast 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "miniz-sys 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "miniz_oxide_c_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -236,7 +236,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "humantime" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -244,41 +244,41 @@ dependencies = [ [[package]] name = "indy" -version = "1.14.1" +version = "1.14.2" dependencies = [ - "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "indy-sys 1.14.1", + "indy-sys 1.14.2", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "num-derive 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "indy-cli" -version = "1.14.1" +version = "1.14.2" dependencies = [ "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "dirs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "indy 1.14.1", + "indy 1.14.2", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "linefeed 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "log4rs 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "prettytable-rs 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "rpassword 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "unescape 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -286,11 +286,13 @@ dependencies = [ [[package]] name = "indy-sys" -version = "1.14.1" +version = "1.14.2" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -320,7 +322,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.60" +version = "0.2.66" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -328,7 +330,7 @@ name = "libloading" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -338,7 +340,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "nix 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "ole32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "shell32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -354,11 +356,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "log" -version = "0.4.6" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -376,13 +378,13 @@ dependencies = [ "crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "log-mdc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde-value 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_yaml 0.8.8 (registry+https://github.com/rust-lang/crates.io-index)", "thread-id 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -395,26 +397,21 @@ name = "memchr" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "memchr" -version = "2.1.2" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "miniz-sys" version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -430,9 +427,9 @@ name = "miniz_oxide_c_api" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", "crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "miniz_oxide 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -443,7 +440,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -521,6 +518,14 @@ dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "proc-macro2" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "quick-error" version = "1.2.2" @@ -534,13 +539,21 @@ dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "quote" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -563,7 +576,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -574,7 +587,7 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -586,7 +599,7 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -614,7 +627,7 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rprompt 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -659,7 +672,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.97" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -668,17 +681,17 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ordered-float 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" -version = "1.0.97" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.23 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -688,7 +701,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -698,7 +711,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "yaml-rust 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -721,15 +734,25 @@ dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "syn" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "synstructure" -version = "0.10.1" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.23 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -746,7 +769,7 @@ name = "termion" version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -756,7 +779,7 @@ name = "thread-id" version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -774,7 +797,7 @@ name = "time" version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -817,6 +840,11 @@ name = "unicode-xid" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "unicode-xid" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "unsafe-any" version = "0.4.2" @@ -835,11 +863,6 @@ name = "vcpkg" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "version_check" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "void" version = "1.0.2" @@ -896,8 +919,8 @@ dependencies = [ "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" "checksum build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39092a32794787acd8525ee150305ff051b0aa6cc2abaf193924f5ab05425f39" -"checksum byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "94f88df23a25417badc922ab0f5716cc1330e87f71ddd9203b3a3ccd9cedf75d" -"checksum cc 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)" = "155ed195f7bd722d1dfeb30365b9d0c1f6a078fa7ca4014497e5935d90993d6f" +"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" +"checksum cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "8dae9c4b8fedcae85592ba623c4fd08cfdab3e3b72d6df780c6ead964a69bfff" "checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" "checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878" "checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" @@ -908,27 +931,27 @@ dependencies = [ "checksum dirs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "88972de891f6118092b643d85a0b28e0678e0f948d7f879aa32f2d5aafe97d2a" "checksum dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6d301140eb411af13d3115f9a562c85cc6b541ade9dfa314132244aaee7489dd" "checksum encode_unicode 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "90b2c9496c001e8cb61827acdefad780795c42264c137744cae6f7d9e3450abd" -"checksum failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6dd377bcc1b1b7ce911967e3ec24fa19c3224394ec05b54aa7b083d498341ac7" -"checksum failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "64c2d913fe8ed3b6c6518eedf4538255b989945c14c2a7d5cbff62a5e2120596" +"checksum failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" +"checksum failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" "checksum flate2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2291c165c8e703ee54ef3055ad6188e3d51108e2ded18e9f2476e774fc5ad3d4" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)" = "49e7653e374fe0d0c12de4250f0bdb60680b8c80eed558c5c7538eec9c89e21b" -"checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" +"checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -"checksum libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "d44e80633f007889c7eff624b709ab43c92d708caad982295768a7b13ca3b5eb" +"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" "checksum libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3ad660d7cb8c5822cd83d10897b0f1f1526792737a179e73896152f85b88c2" "checksum linefeed 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67deb656cfb06a63e4cb31e49609174db253fabaf019476ad505fc52a3302226" "checksum linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "70fb39025bc7cdd76305867c4eccf2f2dcf6e9a57f5b21a93e1c2d86cd03ec9e" -"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" +"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum log-mdc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a94d21414c1f4a51209ad204c1776a3d0765002c76c6abcb602a6f09f1e881c7" "checksum log4rs 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "25e0fc8737a634116a2deb38d821e4400ed16ce9dcb0d628a978d399260f5902" "checksum memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "148fab2e51b4f1cfc66da2a7c32981d1d3c083a803978268bb11fe4b86925e7a" -"checksum memchr 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "db4c41318937f6e76648f42826b1d9ade5c09cafb5aef7e351240a70f39206e9" +"checksum memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3197e20c7edb283f87c071ddfc7a2cca8f8e0b888c242959846a6fce03c72223" "checksum miniz-sys 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "0300eafb20369952951699b68243ab4334f4b10a88f411c221d444b36c40e649" "checksum miniz_oxide 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5ad30a47319c16cde58d0314f5d98202a80c9083b5f61178457403dfb14e509c" "checksum miniz_oxide_c_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "28edaef377517fd9fe3e085c37d892ce7acd1fbeab9239c5a36eec352d8a8b7e" @@ -942,8 +965,10 @@ dependencies = [ "checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" "checksum prettytable-rs 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "34dc1f4f6dddab3bf008ecfd4fd2a631b585fbf0af123f34c1324f51a034ff5f" "checksum proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)" = "77619697826f31a02ae974457af0b29b723e5619e113e9397b8b82c6bd253f09" +"checksum proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "53fa22a1994bd0f9372d7a816207d8a2677ad0325b073f5c5332760f0fb62b5c" +"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" "checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd" "checksum redox_syscall 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)" = "a84bcd297b87a545980a2d25a0beb72a1f490c31f0a9fde52fca35bfbb1ceb70" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" @@ -960,14 +985,15 @@ dependencies = [ "checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" "checksum scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8" "checksum semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "d4f410fedcf71af0345d7607d246e7ad15faaadd49d240ee3b24e5dc21a820ac" -"checksum serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)" = "d46b3dfedb19360a74316866cef04687cd4d6a70df8e6a506c63512790769b72" +"checksum serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" "checksum serde-value 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7a663f873dedc4eac1a559d4c6bc0d0b2c34dc5ac4702e105014b8281489e44f" -"checksum serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)" = "c22a0820adfe2f257b098714323563dd06426502abbbce4f51b72ef544c5027f" +"checksum serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" "checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" "checksum serde_yaml 0.8.8 (registry+https://github.com/rust-lang/crates.io-index)" = "0887a8e097a69559b56aa2526bf7aff7c3048cf627dff781f0b56a6001534593" "checksum shell32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9ee04b46101f57121c9da2b151988283b6beb79b34f5bb29a58ee48cb695122c" "checksum syn 0.15.23 (registry+https://github.com/rust-lang/crates.io-index)" = "9545a6a093a3f0bd59adb472700acc08cad3776f860f16a897dfce8c88721cbc" -"checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" +"checksum syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5" +"checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" "checksum term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fa63644f74ce96fbeb9b794f66aff2a52d601cbd5e80f4b97123e3899f4570f1" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum thread-id 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c7fbf4c9d56b320106cd64fd024dadfa0be7cb4706725fc44a7d7ce952d820c1" @@ -980,10 +1006,10 @@ dependencies = [ "checksum unicode-normalization 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "6a0180bc61fc5a987082bfa111f4cc95c4caff7f9799f3e46df09163a937aa25" "checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" +"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" "checksum unsafe-any 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f30360d7979f5e9c6e6cea48af192ea8fab4afb3cf72597154b8f08935bc9c7f" "checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737" "checksum vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "def296d3eb3b12371b2c7d0e83bfe1403e4db2d7a0bba324a12b21c4ee13143d" -"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 139ba6ce12..ab891a85da 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "indy-cli" -version = "1.14.1" +version = "1.14.2" authors = ["Hyperledger Indy Contributors "] edition = "2018" @@ -29,4 +29,4 @@ serde_json = "1.0.40" serde_derive = "1.0.97" term = "0.4.6" rpassword = "1.0.0" -indy = { version = "1.14.1", path = "../wrappers/rust/" } +indy = { version = "1.14.2", path = "../wrappers/rust/" } diff --git a/cli/debian/changelog b/cli/debian/changelog index 79b6f31333..4437b625fb 100644 --- a/cli/debian/changelog +++ b/cli/debian/changelog @@ -1,7 +1,12 @@ -indy-cli (1.14.1) unstable; urgency=medium +indy-cli (1.14.2) unstable; urgency=medium [ Hyperledger ] +## 1.14.2 +* Added new command `pool set-protocol-version` to set a protocol version that will be used for ledger requests (IS-1391). +* Added new command `payment-address new` that does exactly the same work as the existing `payment-address create` command. + The new command was added to match the naming of `did new` command. The `payment-address create` command will be removed in future releases (IS-1415). + ## 1.14.1 * Bugfixes diff --git a/cli/src/commands/did.rs b/cli/src/commands/did.rs index 063687f6d0..986d7e30d5 100644 --- a/cli/src/commands/did.rs +++ b/cli/src/commands/did.rs @@ -2,7 +2,7 @@ use crate::command_executor::{Command, CommandContext, CommandMetadata, CommandP use crate::commands::*; use crate::utils::table::print_list_table; -use indy::ErrorCode; +use indy::{WalletHandle, PoolHandle, ErrorCode}; use crate::libindy::did::Did; use crate::libindy::ledger::Ledger; @@ -386,7 +386,7 @@ pub mod rotate_key_command { } } -fn _get_current_verkey(pool_handle: i32, pool_name: &str, wallet_handle: i32, wallet_name: &str, did: &str) -> Result, ()> { +fn _get_current_verkey(pool_handle: PoolHandle, pool_name: &str, wallet_handle: WalletHandle, wallet_name: &str, did: &str) -> Result, ()> { //TODO: There nym is requested. Due to freshness issues response might be stale or outdated. Something should be done with it let response_json = Ledger::build_get_nym_request(Some(did), did) .and_then(|request| Ledger::sign_and_submit_request(pool_handle, wallet_handle, did, &request)) diff --git a/cli/src/commands/ledger.rs b/cli/src/commands/ledger.rs index c44e2116d9..9c94d7f769 100644 --- a/cli/src/commands/ledger.rs +++ b/cli/src/commands/ledger.rs @@ -5,7 +5,7 @@ use crate::command_executor::{Command, CommandContext, CommandMetadata, CommandP use crate::commands::*; use crate::commands::payment_address::handle_payment_error; -use indy::{ErrorCode, IndyError}; +use indy::{ErrorCode, IndyError, WalletHandle, PoolHandle, INVALID_WALLET_HANDLE}; use crate::libindy::ledger::Ledger; use crate::libindy::payment::Payment; @@ -901,7 +901,7 @@ pub mod pool_restart_command { } } -fn sign_and_submit_action(wallet_handle: i32, pool_handle: i32, submitter_did: &str, request: &str, nodes: Option>, timeout: Option) -> Result { +fn sign_and_submit_action(wallet_handle: WalletHandle, pool_handle: PoolHandle, submitter_did: &str, request: &str, nodes: Option>, timeout: Option) -> Result { let nodes = match nodes { Some(n) => Some(serde_json::to_string(&n) @@ -1105,7 +1105,7 @@ pub mod get_payment_sources_command { fn execute(ctx: &CommandContext, params: &CommandParams) -> Result<(), ()> { trace!("execute >> ctx {:?} params {:?}", ctx, params); - let wallet_handle = get_opened_wallet_handle(&ctx).unwrap_or(-1); + let wallet_handle = get_opened_wallet_handle(&ctx).unwrap_or(INVALID_WALLET_HANDLE); let submitter_did = get_active_did(&ctx); let payment_address = get_str_param("payment_address", params).map_err(error_err!())?; @@ -1229,7 +1229,7 @@ pub mod get_fees_command { fn execute(ctx: &CommandContext, params: &CommandParams) -> Result<(), ()> { trace!("execute >> ctx {:?} params {:?}", ctx, params); - let wallet_handle = get_opened_wallet_handle(&ctx).unwrap_or(-1); + let wallet_handle = get_opened_wallet_handle(&ctx).unwrap_or(INVALID_WALLET_HANDLE); let submitter_did = get_active_did(&ctx); let payment_method = get_str_param("payment_method", params).map_err(error_err!())?; @@ -1287,7 +1287,7 @@ pub mod mint_prepare_command { fn execute(ctx: &CommandContext, params: &CommandParams) -> Result<(), ()> { trace!("execute >> ctx {:?} params {:?}", ctx, params); - let wallet_handle = get_opened_wallet_handle(&ctx).unwrap_or(-1); + let wallet_handle = get_opened_wallet_handle(&ctx).unwrap_or(INVALID_WALLET_HANDLE); let submitter_did = get_active_did(&ctx); let outputs = get_str_tuple_array_param("outputs", params).map_err(error_err!())?; @@ -1326,7 +1326,7 @@ pub mod set_fees_prepare_command { fn execute(ctx: &CommandContext, params: &CommandParams) -> Result<(), ()> { trace!("execute >> ctx {:?} params {:?}", ctx, params); - let wallet_handle = get_opened_wallet_handle(&ctx).unwrap_or(-1); + let wallet_handle = get_opened_wallet_handle(&ctx).unwrap_or(INVALID_WALLET_HANDLE); let submitter_did = get_active_did(&ctx); let payment_method = get_str_param("payment_method", params).map_err(error_err!())?; @@ -1360,7 +1360,7 @@ pub mod verify_payment_receipt_command { fn execute(ctx: &CommandContext, params: &CommandParams) -> Result<(), ()> { trace!("execute >> ctx {:?} params {:?}", ctx, params); - let wallet_handle = get_opened_wallet_handle(&ctx).unwrap_or(-1); + let wallet_handle = get_opened_wallet_handle(&ctx).unwrap_or(INVALID_WALLET_HANDLE); let submitter_did = get_active_did(&ctx); let receipt = get_str_param("receipt", params).map_err(error_err!())?; @@ -2279,7 +2279,7 @@ fn timestamp_to_datetime(_time: i64) -> String { NaiveDateTime::from_timestamp(_time, 0).to_string() } -pub fn get_active_transaction_author_agreement(_pool_handle: i32) -> Result)>, ()> { +pub fn get_active_transaction_author_agreement(_pool_handle: PoolHandle) -> Result)>, ()> { let response = Ledger::build_get_txn_author_agreement_request(None, None) .and_then(|request| Ledger::submit_request(_pool_handle, &request)) .map_err(|err| handle_indy_error(err, None, None, None))?; @@ -2335,7 +2335,7 @@ fn get_payment_sources(ctx: &CommandContext, payment_address: &str) -> Result, request: &mut String, - wallet_handle: i32, + wallet_handle: WalletHandle, submitter_did: Option<&str>) -> Result, ()> { let source_payment_address = get_opt_str_param("source_payment_address", params).map_err(error_err!())?; let fee = get_opt_number_param::("fee", params).map_err(error_err!())?; @@ -2801,6 +2801,36 @@ pub mod tests { assert!(transaction["signature"].is_null()); tear_down_with_wallet_and_pool(&ctx); } + + #[test] + pub fn nym_works_for_disconnected_pool_and_specific_protocol_version() { + let ctx = setup_with_wallet(); + use_trustee(&ctx); + let (did, _) = create_new_did(&ctx); + // Set Custom Pool protocol version + { + let cmd = pool::set_protocol_version_command::new(); + let mut params = CommandParams::new(); + params.insert("protocol-version", "1".to_string()); + cmd.execute(&ctx, ¶ms).unwrap(); + } + // Build NYM request + { + let cmd = nym_command::new(); + let mut params = CommandParams::new(); + params.insert("did", did.clone()); + params.insert("send", "false".to_string()); + cmd.execute(&ctx, ¶ms).unwrap(); + } + // Reset Custom Pool protocol version + { + let cmd = pool::set_protocol_version_command::new(); + let mut params = CommandParams::new(); + params.insert("protocol-version", DEFAULT_POOL_PROTOCOL_VERSION.to_string()); + cmd.execute(&ctx, ¶ms).unwrap(); + } + tear_down_with_wallet(&ctx); + } } mod get_nym { diff --git a/cli/src/commands/mod.rs b/cli/src/commands/mod.rs index 83469a2638..34f237c4e8 100644 --- a/cli/src/commands/mod.rs +++ b/cli/src/commands/mod.rs @@ -11,7 +11,7 @@ pub mod payment_address; use self::regex::Regex; use crate::command_executor::{CommandContext, CommandParams}; -use indy::{ErrorCode, IndyError}; +use indy::{ErrorCode, IndyError, WalletHandle, PoolHandle}; use std; @@ -58,11 +58,23 @@ pub fn _get_int_param(name: &str, params: &CommandParams) -> Result } } +pub fn get_number_param(key: &str, params: &CommandParams) -> Result + where T: std::str::FromStr, ::Err: std::fmt::Display { + match params.get(key) { + Some(value) => value.parse::().map_err(|err| + println_err!("Can't parse number parameter \"{}\": value: \"{}\", err \"{}\"", key, value, err)), + None => { + println_err!("No required \"{}\" parameter present", key); + Err(()) + } + } +} + pub fn get_opt_number_param(key: &str, params: &CommandParams) -> Result, ()> where T: std::str::FromStr, ::Err: std::fmt::Display { let res = match params.get(key) { Some(value) => Some(value.parse::().map_err(|err| - println_err!("Can't parse integer parameter \"{}\": err {}", key, err))?), + println_err!("Can't parse number parameter \"{}\": value: \"{}\", err \"{}\"", key, value, err))?), None => None }; Ok(res) @@ -185,9 +197,9 @@ pub fn set_active_did(ctx: &CommandContext, did: Option) { ctx.set_sub_prompt(3, did.map(|did| format!("did({}...{})", &did[..3], &did[did.len() - 3..]))); } -pub fn ensure_opened_wallet_handle(ctx: &CommandContext) -> Result { +pub fn ensure_opened_wallet_handle(ctx: &CommandContext) -> Result { match ctx.get_int_value("OPENED_WALLET_HANDLE") { - Some(wallet_handle) => Ok(wallet_handle), + Some(wallet_handle) => Ok(WalletHandle(wallet_handle)), None => { println_err!("There is no opened wallet now"); Err(()) @@ -195,12 +207,12 @@ pub fn ensure_opened_wallet_handle(ctx: &CommandContext) -> Result { } } -pub fn ensure_opened_wallet(ctx: &CommandContext) -> Result<(i32, String), ()> { +pub fn ensure_opened_wallet(ctx: &CommandContext) -> Result<(WalletHandle, String), ()> { let handle = ctx.get_int_value("OPENED_WALLET_HANDLE"); let name = ctx.get_string_value("OPENED_WALLET_NAME"); match (handle, name) { - (Some(handle), Some(name)) => Ok((handle, name)), + (Some(handle), Some(name)) => Ok((WalletHandle(handle), name)), _ => { println_err!("There is no opened wallet now"); Err(()) @@ -208,28 +220,37 @@ pub fn ensure_opened_wallet(ctx: &CommandContext) -> Result<(i32, String), ()> { } } -pub fn get_opened_wallet(ctx: &CommandContext) -> Option<(i32, String)> { +pub fn get_opened_wallet(ctx: &CommandContext) -> Option<(WalletHandle, String)> { let handle = ctx.get_int_value("OPENED_WALLET_HANDLE"); let name = ctx.get_string_value("OPENED_WALLET_NAME"); if let (Some(handle), Some(name)) = (handle, name) { - Some((handle, name)) + Some((WalletHandle(handle), name)) } else { None } } -pub fn get_opened_wallet_handle(ctx: &CommandContext) -> Option { - ctx.get_int_value("OPENED_WALLET_HANDLE") +pub fn get_opened_wallet_handle(ctx: &CommandContext) -> Option { + ctx.get_int_value("OPENED_WALLET_HANDLE").map(|val| WalletHandle(val)) } -pub fn set_opened_wallet(ctx: &CommandContext, value: Option<(i32, String)>) { - ctx.set_int_value("OPENED_WALLET_HANDLE", value.as_ref().map(|value| value.0.to_owned())); - ctx.set_string_value("OPENED_WALLET_NAME", value.as_ref().map(|value| value.1.to_owned())); - ctx.set_sub_prompt(2, value.map(|value| format!("wallet({})", value.1))); +pub fn set_opened_wallet(ctx: &CommandContext, value: Option<(WalletHandle, String)>) { + match value { + Some((wallet_handle, wallet_name)) => { + ctx.set_int_value("OPENED_WALLET_HANDLE", Some(wallet_handle.0)); + ctx.set_string_value("OPENED_WALLET_NAME", Some(wallet_name.to_owned())); + ctx.set_sub_prompt(2, Some(wallet_name)); + }, + None => { + ctx.set_int_value("OPENED_WALLET_HANDLE", None); + ctx.set_string_value("OPENED_WALLET_NAME", None); + ctx.set_sub_prompt(2, None); + } + } } -pub fn ensure_connected_pool_handle(ctx: &CommandContext) -> Result { +pub fn ensure_connected_pool_handle(ctx: &CommandContext) -> Result { match ctx.get_int_value("CONNECTED_POOL_HANDLE") { Some(pool_handle) => Ok(pool_handle), None => { @@ -239,7 +260,7 @@ pub fn ensure_connected_pool_handle(ctx: &CommandContext) -> Result { } } -pub fn ensure_connected_pool(ctx: &CommandContext) -> Result<(i32, String), ()> { +pub fn ensure_connected_pool(ctx: &CommandContext) -> Result<(PoolHandle, String), ()> { let handle = ctx.get_int_value("CONNECTED_POOL_HANDLE"); let name = ctx.get_string_value("CONNECTED_POOL_NAME"); @@ -252,7 +273,7 @@ pub fn ensure_connected_pool(ctx: &CommandContext) -> Result<(i32, String), ()> } } -pub fn get_connected_pool(ctx: &CommandContext) -> Option<(i32, String)> { +pub fn get_connected_pool(ctx: &CommandContext) -> Option<(PoolHandle, String)> { let handle = ctx.get_int_value("CONNECTED_POOL_HANDLE"); let name = ctx.get_string_value("CONNECTED_POOL_NAME"); @@ -263,7 +284,7 @@ pub fn get_connected_pool(ctx: &CommandContext) -> Option<(i32, String)> { } } -pub fn set_connected_pool(ctx: &CommandContext, value: Option<(i32, String)>) { +pub fn set_connected_pool(ctx: &CommandContext, value: Option<(PoolHandle, String)>) { ctx.set_int_value("CONNECTED_POOL_HANDLE", value.as_ref().map(|value| value.0.to_owned())); ctx.set_string_value("CONNECTED_POOL_NAME", value.as_ref().map(|value| value.1.to_owned())); ctx.set_sub_prompt(1, value.map(|value| format!("pool({})", value.1))); @@ -300,13 +321,26 @@ pub fn get_transaction_author_info(ctx: &CommandContext) -> Option<(String, Stri let acc_mech_type = ctx.get_taa_acceptance_mechanism(); let time_of_acceptance = ctx.get_uint_value("AGREEMENT_TIME_OF_ACCEPTANCE"); - if let (Some(text), Some(version),Some(time_of_acceptance)) = (text, version, time_of_acceptance) { + if let (Some(text), Some(version), Some(time_of_acceptance)) = (text, version, time_of_acceptance) { Some((text, version, acc_mech_type, time_of_acceptance)) } else { None } } +const DEFAULT_POOL_PROTOCOL_VERSION: usize = 2; + +pub fn set_pool_protocol_version(ctx: &CommandContext, protocol_version: usize) { + ctx.set_uint_value("POOL_PROTOCOL_VERSION", Some(protocol_version as u64)); +} + +pub fn get_pool_protocol_version(ctx: &CommandContext) -> usize { + match ctx.get_uint_value("POOL_PROTOCOL_VERSION") { + Some(protocol_version) => protocol_version as usize, + None => DEFAULT_POOL_PROTOCOL_VERSION + } +} + pub fn handle_indy_error(err: IndyError, submitter_did: Option<&str>, pool_name: Option<&str>, wallet_name: Option<&str>) { match err.error_code { ErrorCode::WalletAlreadyExistsError => println_err!("Wallet \"{}\" already exists", wallet_name.unwrap_or("")), @@ -393,4 +427,4 @@ fn tear_down_with_wallet(ctx: &CommandContext) { #[cfg(test)] fn tear_down() { TestUtils::cleanup_storage(); -} \ No newline at end of file +} diff --git a/cli/src/commands/payment_address.rs b/cli/src/commands/payment_address.rs index 57149c9c32..9c6483b6a9 100644 --- a/cli/src/commands/payment_address.rs +++ b/cli/src/commands/payment_address.rs @@ -19,18 +19,18 @@ pub mod group { command_group!(CommandGroupMetadata::new("payment-address", "Payment address management commands")); } -pub mod create_command { +pub mod new_command { use super::*; - command!(CommandMetadata::build("create", "Create the payment address for specified payment method.") + command!(CommandMetadata::build("new", "Create the payment address for specified payment method.") .add_required_param("payment_method", "Payment method to use") .add_optional_param("seed", "Seed for creating payment address") - .add_example("payment-address create payment_method=sov") - .add_example("payment-address create payment_method=sov seed=000000000000000000000000000Seed1") + .add_example("payment-address new payment_method=sov") + .add_example("payment-address new payment_method=sov seed=000000000000000000000000000Seed1") .finalize() ); - fn execute(ctx: &CommandContext, params: &CommandParams) -> Result<(), ()> { + pub(super) fn execute(ctx: &CommandContext, params: &CommandParams) -> Result<(), ()> { trace!("execute >> ctx {:?} params {:?}", ctx, params); let wallet_handle = ensure_opened_wallet_handle(&ctx)?; @@ -60,6 +60,22 @@ pub mod create_command { } } +pub mod create_command { + use super::*; + + command!(CommandMetadata::build("create", r#"Create the payment address for specified payment method. TAKE NOTE that this command will be removed in one of the future releases in favor `payment-address new` command."#) + .add_required_param("payment_method", "Payment method to use") + .add_optional_param("seed", "Seed for creating payment address") + .add_example("payment-address create payment_method=sov") + .add_example("payment-address create payment_method=sov seed=000000000000000000000000000Seed1") + .finalize() + ); + + fn execute(ctx: &CommandContext, params: &CommandParams) -> Result<(), ()> { + new_command::execute(ctx, params) + } +} + pub mod list_command { use super::*; @@ -89,7 +105,7 @@ pub mod list_command { print_list_table(&list_addresses, &[("address", "Payment Address"), - ("method", "Payment Method")], + ("method", "Payment Method")], "There are no payment addresses"); Ok(()) } @@ -236,15 +252,15 @@ pub mod tests { pub const INPUT: &str = "123456789"; - mod create { + mod new { use super::*; #[test] - pub fn create_works() { + pub fn new_works() { let ctx = setup_with_wallet(); load_null_payment_plugin(&ctx); { - let cmd = create_command::new(); + let cmd = new_command::new(); let mut params = CommandParams::new(); params.insert("payment_method", NULL_PAYMENT_METHOD.to_string()); cmd.execute(&ctx, ¶ms).unwrap(); @@ -257,11 +273,11 @@ pub mod tests { } #[test] - pub fn create_works_for_seed() { + pub fn new_works_for_seed() { let ctx = setup_with_wallet(); load_null_payment_plugin(&ctx); { - let cmd = create_command::new(); + let cmd = new_command::new(); let mut params = CommandParams::new(); params.insert("payment_method", NULL_PAYMENT_METHOD.to_string()); params.insert("seed", SEED_MY1.to_string()); @@ -275,10 +291,10 @@ pub mod tests { } #[test] - pub fn create_works_for_unknown_payment_method() { + pub fn new_works_for_unknown_payment_method() { let ctx = setup_with_wallet(); { - let cmd = create_command::new(); + let cmd = new_command::new(); let mut params = CommandParams::new(); params.insert("payment_method", "unknown_payment_method".to_string()); cmd.execute(&ctx, ¶ms).unwrap_err(); @@ -287,11 +303,11 @@ pub mod tests { } #[test] - pub fn create_works_for_no_opened_wallet() { + pub fn new_works_for_no_opened_wallet() { let ctx = setup(); load_null_payment_plugin(&ctx); { - let cmd = create_command::new(); + let cmd = new_command::new(); let mut params = CommandParams::new(); params.insert("payment_method", NULL_PAYMENT_METHOD.to_string()); cmd.execute(&ctx, ¶ms).unwrap_err(); diff --git a/cli/src/commands/pool.rs b/cli/src/commands/pool.rs index c414aec4c7..4a2e220a99 100644 --- a/cli/src/commands/pool.rs +++ b/cli/src/commands/pool.rs @@ -12,8 +12,6 @@ use self::chrono::prelude::*; use serde_json::Value as JSONValue; use serde_json::Map as JSONMap; -const PROTOCOL_VERSION: usize = 2; - pub mod group { use super::*; @@ -94,7 +92,7 @@ pub mod connect_command { trace!("execute >> ctx {:?} params {:?}", ctx, params); let name = get_str_param("name", params).map_err(error_err!())?; - let protocol_version = get_opt_number_param::("protocol-version", params).map_err(error_err!())?.unwrap_or(PROTOCOL_VERSION); + let protocol_version = get_opt_number_param::("protocol-version", params).map_err(error_err!())?.unwrap_or(get_pool_protocol_version(ctx)); let timeout = get_opt_number_param::("timeout", params).map_err(error_err!())?; let extended_timeout = get_opt_number_param::("extended-timeout", params).map_err(error_err!())?; let pre_ordered_nodes = get_opt_str_array_param("pre-ordered-nodes", params).map_err(error_err!())?; @@ -128,20 +126,7 @@ pub mod connect_command { Ok(()) } }) - .and_then(|_| { - match Pool::set_protocol_version(protocol_version) { - Ok(_) => Ok(()), - Err(IndyError { error_code: ErrorCode::PoolIncompatibleProtocolVersion, .. }) => - { - println_err!("Unsupported Protocol Version has been specified \"{}\".", protocol_version); - Err(()) - }, - Err(err) => { - handle_indy_error(err, None, Some(&name), None); - Err(()) - }, - } - }) + .and_then(|_| set_protocol_version(protocol_version)) .and_then(|_| { match Pool::open_pool_ledger(name, Some(&config)) { Ok(handle) => { @@ -293,6 +278,50 @@ pub mod refresh_command { } } +pub mod set_protocol_version_command { + use super::*; + + command!(CommandMetadata::build("set-protocol-version", "Set protocol version that will be used for ledger requests. One of: 1, 2. \ + Unless command is called the default protocol version 2 is used.") + .add_main_param("protocol-version", "Protocol version to use") + .add_example("pool set-protocol-version 2") + .finalize() + ); + + fn execute(ctx: &CommandContext, params: &CommandParams) -> Result<(), ()> { + trace!("execute >> ctx {:?} params {:?}", ctx, params); + + let protocol_version = get_number_param::("protocol-version", params).map_err(error_err!())?; + + let res = match set_protocol_version(protocol_version) { + Ok(_) => { + set_pool_protocol_version(ctx, protocol_version); + println_succ!("Protocol Version has been set: \"{}\".", protocol_version); + Ok(()) + } + err => err + }; + + trace!("execute << {:?}", res); + res + } +} + +fn set_protocol_version(protocol_version: usize) -> Result<(), ()> { + match Pool::set_protocol_version(protocol_version) { + Ok(_) => Ok(()), + Err(IndyError { error_code: ErrorCode::PoolIncompatibleProtocolVersion, .. }) => + { + println_err!("Unsupported Protocol Version has been specified \"{}\".", protocol_version); + Err(()) + } + Err(err) => { + handle_indy_error(err, None, None, None); + Err(()) + } + } +} + pub mod disconnect_command { use super::*; @@ -315,15 +344,15 @@ pub mod disconnect_command { fn close_pool(ctx: &CommandContext, handle: i32, name: &str) -> Result<(), ()> { match Pool::close(handle) { - Ok(()) => { - set_connected_pool(ctx, None); - set_transaction_author_info(ctx, None); - Ok(()) - } - Err(err) => { - handle_indy_error(err, None, Some(&name), None); - Err(()) - } + Ok(()) => { + set_connected_pool(ctx, None); + set_transaction_author_info(ctx, None); + Ok(()) + } + Err(err) => { + handle_indy_error(err, None, Some(&name), None); + Err(()) + } } } @@ -784,6 +813,30 @@ pub mod tests { } } + mod set_protocol_version { + use super::*; + + #[test] + pub fn set_protocol_version_works() { + let ctx = setup(); + create_pool(&ctx); + { + let cmd = set_protocol_version_command::new(); + let mut params = CommandParams::new(); + params.insert("protocol-version", DEFAULT_POOL_PROTOCOL_VERSION.to_string()); + cmd.execute(&ctx, ¶ms).unwrap(); + } + { + let cmd = set_protocol_version_command::new(); + let mut params = CommandParams::new(); + params.insert("protocol-version", "invalid".to_string()); + cmd.execute(&ctx, ¶ms).unwrap_err(); + } + + tear_down(); + } + } + pub fn create_pool(ctx: &CommandContext) { let cmd = create_command::new(); let mut params = CommandParams::new(); diff --git a/cli/src/commands/wallet.rs b/cli/src/commands/wallet.rs index 22190f4789..2c2c929af8 100644 --- a/cli/src/commands/wallet.rs +++ b/cli/src/commands/wallet.rs @@ -1428,7 +1428,7 @@ pub mod tests { create_cmd.execute(&ctx, ¶ms).unwrap(); } - pub fn create_and_open_wallet(ctx: &CommandContext) -> i32 { + pub fn create_and_open_wallet(ctx: &CommandContext) -> WalletHandle { { let create_cmd = create_command::new(); let mut params = CommandParams::new(); @@ -1449,7 +1449,7 @@ pub mod tests { ensure_opened_wallet_handle(&ctx).unwrap() } - pub fn open_wallet(ctx: &CommandContext) -> i32 { + pub fn open_wallet(ctx: &CommandContext) -> WalletHandle { { let cmd = open_command::new(); let mut params = CommandParams::new(); diff --git a/cli/src/libindy/did.rs b/cli/src/libindy/did.rs index 72dfebc94b..93404eda34 100644 --- a/cli/src/libindy/did.rs +++ b/cli/src/libindy/did.rs @@ -1,7 +1,7 @@ -use indy::WalletHandle; use indy::did; use indy::IndyError; use indy::future::Future; +use indy::WalletHandle; pub struct Did {} @@ -37,4 +37,4 @@ impl Did { pub fn qualify_did(wallet_handle: WalletHandle, did: &str, method: &str) -> Result { did::qualify_did(wallet_handle, did, method).wait() } -} \ No newline at end of file +} diff --git a/cli/src/libindy/ledger.rs b/cli/src/libindy/ledger.rs index 31da92a0f0..dfca1c03ae 100644 --- a/cli/src/libindy/ledger.rs +++ b/cli/src/libindy/ledger.rs @@ -1,27 +1,28 @@ use indy::IndyError; use indy::future::Future; use indy::ledger; +use indy::{PoolHandle, WalletHandle}; pub struct Ledger {} impl Ledger { - pub fn sign_and_submit_request(pool_handle: i32, wallet_handle: i32, submitter_did: &str, request_json: &str) -> Result { + pub fn sign_and_submit_request(pool_handle: PoolHandle, wallet_handle: WalletHandle, submitter_did: &str, request_json: &str) -> Result { ledger::sign_and_submit_request(pool_handle, wallet_handle, submitter_did, request_json).wait() } - pub fn submit_request(pool_handle: i32, request_json: &str) -> Result { + pub fn submit_request(pool_handle: PoolHandle, request_json: &str) -> Result { ledger::submit_request(pool_handle, request_json).wait() } - pub fn submit_action(pool_handle: i32, request_json: &str, nodes: Option<&str>, timeout: Option) -> Result { + pub fn submit_action(pool_handle: PoolHandle, request_json: &str, nodes: Option<&str>, timeout: Option) -> Result { ledger::submit_action(pool_handle, request_json, nodes, timeout).wait() } - pub fn sign_request(wallet_handle: i32, submitter_did: &str, request_json: &str) -> Result { + pub fn sign_request(wallet_handle: WalletHandle, submitter_did: &str, request_json: &str) -> Result { ledger::sign_request(wallet_handle, submitter_did, request_json).wait() } - pub fn multi_sign_request(wallet_handle: i32, submitter_did: &str, request_json: &str) -> Result { + pub fn multi_sign_request(wallet_handle: WalletHandle, submitter_did: &str, request_json: &str) -> Result { ledger::multi_sign_request(wallet_handle, submitter_did, request_json).wait() } diff --git a/cli/src/libindy/mod.rs b/cli/src/libindy/mod.rs index 3646c5530c..ffaf7ebffe 100644 --- a/cli/src/libindy/mod.rs +++ b/cli/src/libindy/mod.rs @@ -3,4 +3,3 @@ pub mod pool; pub mod wallet; pub mod ledger; pub mod payment; - diff --git a/cli/src/libindy/payment.rs b/cli/src/libindy/payment.rs index bcba2c8901..3491fcf4b5 100644 --- a/cli/src/libindy/payment.rs +++ b/cli/src/libindy/payment.rs @@ -2,22 +2,24 @@ use indy::IndyError; use indy::payments; use indy::future::Future; +use indy::WalletHandle; + pub struct Payment {} impl Payment { - pub fn create_payment_address(wallet_handle: i32, payment_method: &str, config: &str) -> Result { + pub fn create_payment_address(wallet_handle: WalletHandle, payment_method: &str, config: &str) -> Result { payments::create_payment_address(wallet_handle, payment_method, config).wait() } - pub fn list_payment_addresses(wallet_handle: i32) -> Result { + pub fn list_payment_addresses(wallet_handle: WalletHandle) -> Result { payments::list_payment_addresses(wallet_handle).wait() } - pub fn add_request_fees(wallet_handle: i32, submitter_did: Option<&str>, req_json: &str, inputs_json: &str, outputs_json: &str, extra: Option<&str>) -> Result<(String, String), IndyError> { + pub fn add_request_fees(wallet_handle: WalletHandle, submitter_did: Option<&str>, req_json: &str, inputs_json: &str, outputs_json: &str, extra: Option<&str>) -> Result<(String, String), IndyError> { payments::add_request_fees(wallet_handle, submitter_did, req_json, inputs_json, outputs_json, extra).wait() } - pub fn build_get_payment_sources_request(wallet_handle: i32, submitter_did: Option<&str>, payment_address: &str) -> Result<(String, String), IndyError> { + pub fn build_get_payment_sources_request(wallet_handle: WalletHandle, submitter_did: Option<&str>, payment_address: &str) -> Result<(String, String), IndyError> { payments::build_get_payment_sources_with_from_request(wallet_handle, submitter_did, payment_address, None).wait() } @@ -25,7 +27,7 @@ impl Payment { payments::parse_get_payment_sources_with_from_response(payment_method, resp_json).wait().map(|(s, _)| s) } - pub fn build_payment_req(wallet_handle: i32, submitter_did: Option<&str>, inputs: &str, outputs: &str, extra: Option<&str>) -> Result<(String, String), IndyError> { + pub fn build_payment_req(wallet_handle: WalletHandle, submitter_did: Option<&str>, inputs: &str, outputs: &str, extra: Option<&str>) -> Result<(String, String), IndyError> { payments::build_payment_req(wallet_handle, submitter_did, inputs, outputs, extra).wait() } @@ -33,15 +35,15 @@ impl Payment { payments::parse_payment_response(payment_method, resp_json).wait() } - pub fn build_mint_req(wallet_handle: i32, submitter_did: Option<&str>, outputs_json: &str, extra: Option<&str>) -> Result<(String, String), IndyError> { + pub fn build_mint_req(wallet_handle: WalletHandle, submitter_did: Option<&str>, outputs_json: &str, extra: Option<&str>) -> Result<(String, String), IndyError> { payments::build_mint_req(wallet_handle, submitter_did, outputs_json, extra).wait() } - pub fn build_set_txn_fees_req(wallet_handle: i32, submitter_did: Option<&str>, payment_method: &str, fees_json: &str) -> Result { + pub fn build_set_txn_fees_req(wallet_handle: WalletHandle, submitter_did: Option<&str>, payment_method: &str, fees_json: &str) -> Result { payments::build_set_txn_fees_req(wallet_handle, submitter_did, payment_method, fees_json).wait() } - pub fn build_get_txn_fees_req(wallet_handle: i32, submitter_did: Option<&str>, payment_method: &str) -> Result { + pub fn build_get_txn_fees_req(wallet_handle: WalletHandle, submitter_did: Option<&str>, payment_method: &str) -> Result { payments::build_get_txn_fees_req(wallet_handle, submitter_did, payment_method).wait() } @@ -53,7 +55,7 @@ impl Payment { payments::parse_response_with_fees(payment_method, resp_json).wait() } - pub fn build_verify_payment_req(wallet_handle: i32, submitter_did: Option<&str>, receipt: &str) -> Result<(String, String), IndyError> { + pub fn build_verify_payment_req(wallet_handle: WalletHandle, submitter_did: Option<&str>, receipt: &str) -> Result<(String, String), IndyError> { payments::build_verify_payment_req(wallet_handle, submitter_did, receipt).wait() } @@ -66,7 +68,7 @@ impl Payment { payments::prepare_extra_with_acceptance_data(extra_json, text, version, taa_digest, mechanism, time).wait() } - pub fn sign_with_address(wallet_handle: i32, address: &str, input: &str) -> Result, IndyError> { + pub fn sign_with_address(wallet_handle: WalletHandle, address: &str, input: &str) -> Result, IndyError> { payments::sign_with_address(wallet_handle, address, input.as_bytes()).wait() } diff --git a/cli/src/libindy/pool.rs b/cli/src/libindy/pool.rs index 4529389258..2701b9e1c1 100644 --- a/cli/src/libindy/pool.rs +++ b/cli/src/libindy/pool.rs @@ -1,6 +1,7 @@ use indy::IndyError; use indy::pool; use indy::future::Future; +use indy::PoolHandle; pub struct Pool {} @@ -13,7 +14,7 @@ impl Pool { pool::open_pool_ledger(pool_name, config).wait() } - pub fn refresh(pool_handle: i32) -> Result<(), IndyError> { + pub fn refresh(pool_handle: PoolHandle) -> Result<(), IndyError> { pool::refresh_pool_ledger(pool_handle).wait() } @@ -21,7 +22,7 @@ impl Pool { pool::list_pools().wait() } - pub fn close(pool_handle: i32) -> Result<(), IndyError> { + pub fn close(pool_handle: PoolHandle) -> Result<(), IndyError> { pool::close_pool_ledger(pool_handle).wait() } diff --git a/cli/src/libindy/wallet.rs b/cli/src/libindy/wallet.rs index 5c32b85f56..21c3ec47e3 100644 --- a/cli/src/libindy/wallet.rs +++ b/cli/src/libindy/wallet.rs @@ -1,6 +1,7 @@ use indy::IndyError; use indy::wallet; use indy::future::Future; +use indy::WalletHandle; pub struct Wallet {} @@ -9,7 +10,7 @@ impl Wallet { wallet::create_wallet(config, credentials).wait() } - pub fn open_wallet(config: &str, credentials: &str) -> Result { + pub fn open_wallet(config: &str, credentials: &str) -> Result { wallet::open_wallet(config, credentials).wait() } @@ -17,11 +18,11 @@ impl Wallet { wallet::delete_wallet(wallet_name, credentials).wait() } - pub fn close_wallet(wallet_handle: i32) -> Result<(), IndyError> { + pub fn close_wallet(wallet_handle: WalletHandle) -> Result<(), IndyError> { wallet::close_wallet(wallet_handle).wait() } - pub fn export_wallet(wallet_handle: i32, export_config_json: &str) -> Result<(), IndyError> { + pub fn export_wallet(wallet_handle: WalletHandle, export_config_json: &str) -> Result<(), IndyError> { wallet::export_wallet(wallet_handle, export_config_json).wait() } diff --git a/cli/src/main.rs b/cli/src/main.rs index ddfc19893d..9881c49844 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -143,6 +143,7 @@ fn build_executor() -> CommandExecutor { .add_command(pool::disconnect_command::new()) .add_command(pool::delete_command::new()) .add_command(pool::show_taa_command::new()) + .add_command(pool::set_protocol_version_command::new()) .finalize_group() .add_group(wallet::group::new()) .add_command(wallet::create_command::new()) @@ -189,6 +190,7 @@ fn build_executor() -> CommandExecutor { .add_command(ledger::taa_disable_all_command::new()) .finalize_group() .add_group(payment_address::group::new()) + .add_command(payment_address::new_command::new()) .add_command(payment_address::create_command::new()) .add_command(payment_address::list_command::new()) .add_command(payment_address::sign_command::new()) diff --git a/docs/configuration.md b/docs/configuration.md index ba2febcb99..6b14f5f755 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -12,17 +12,21 @@ This document contains information on how Indy-SDK components can be configured. * [Payment](#payment) * [Logging](#logging) * [Error Handling](#error-handling) - * [Runtime](#runtime) - * [Transaction Endorser](#eransaction-endorser) + * [Runtime Configuration](#runtime-configuration) + * [Transaction Endorser](#transaction-endorser) * [Transaction Author Agreement](#transaction-author-agreement) - * [Fully-Qualified Identifiers](#fully-qualified-Identifiers) + * [Fully-Qualified Identifiers](#fully-qualified-identifiers) -* [Indy-CLI](#indy-cLI) +* [Indy-CLI](#indy-cli) * [Options](#options) * [Config](#config) * [Execution mode](#execution-mode) * [Transaction Author Agreement](#transaction-author-agreement) +* [Vcx](#vcx) + * [Configuration options](#configuration-options) + * [Logging](#logging) + ## Libindy #### Pool @@ -44,10 +48,18 @@ This function accepts a `config` parameter that defines the behavior of the clie { "timeout": int (optional) - specifies the maximum number of seconds to wait for pool response (ACK, REPLY). "extended_timeout": int (optional), an additional number of seconds to wait for REPLY in case ACK has been received. + "number_read_nodes": int (optional) - the number of nodes to send read requests (2 by default). + Libindy sends write transactions (like `NYM)` to all nodes in the ledger. + In case of read request (like `GET_NYM`) it's enough to receive a reply with valid `state proof` only from one node. + By default Libindy sends a read requests to 2 (`number_read_nodes`) nodes in the pool. + If Reply isn't received or response `state proof` is invalid Libindy sends the request again but to 2 (`number_read_nodes`) * 2 = 4 nodes and so far until completion. + So using `number_read_nodes` parameter you can set the number of nodes to send read requests. "preordered_nodes": array - (optional), names of nodes which will have priority during request sending. This can be useful if a user prefers querying specific nodes. + Assume that `Node1` and `Node2` nodes reply faster. + If you pass them to `preordered_nodes` parameter Libindy always sends a read request to these nodes first and only then (if not enough) to others. Note: Nodes not specified will be placed randomly. - "number_read_nodes": int (optional) - the number of nodes to send read requests (2 by default) + } ``` diff --git a/docs/design/001-cli/README.md b/docs/design/001-cli/README.md index 2d4f8432c2..3ee16d6212 100644 --- a/docs/design/001-cli/README.md +++ b/docs/design/001-cli/README.md @@ -204,6 +204,12 @@ Refresh a local copy of a pool ledger and updates pool nodes connections. indy> pool refresh ``` +#### Set Protocol Version +Set protocol version that will be used for ledger requests. One of: 1, 2. Unless command is called the default protocol version 2 is used. +``` +indy> pool set-protocol-version [protocol-version=] +``` + #### Disconnect Disconnect from Indy nodes pool ``` @@ -435,8 +441,17 @@ ledger get-acceptance-mechanisms [timestamp=] [version=] [se indy> payment-address ``` +#### New +Create the payment address for specified payment method. Requires opened wallet. +``` +payment-address new payment_method= [seed=] +``` + #### Create Create the payment address for specified payment method. Requires opened wallet. + +Take note that this command will be removed in one of the future releases in favor `payment-address new` command. + ``` payment-address create payment_method= [seed=] ``` diff --git a/docs/getting-started/getting-started.ipynb b/docs/getting-started/getting-started.ipynb index feeb1c9b4e..d42e90b807 100644 --- a/docs/getting-started/getting-started.ipynb +++ b/docs/getting-started/getting-started.ipynb @@ -8,10 +8,9 @@ "source": [ "import asyncio\n", "import time\n", - "from indy import anoncreds, crypto, did, ledger, pool, wallet\n", + "from indy import anoncreds, did, ledger, pool, wallet, IndyError\n", "\n", "import json\n", - "from typing import Optional\n", "\n", "\n", "async def run():\n", @@ -19,7 +18,7 @@ "\n", " # Set protocol version 2 to work with Indy Node 1.4\n", " await pool.set_protocol_version(2)\n", - " \n", + "\n", " pool_ = {\n", " 'name': 'pool1',\n", " 'config': json.dumps({\"genesis_txn\": '/home/indy/sandbox/pool_transactions_genesis'})\n", @@ -37,7 +36,6 @@ " print(\"=== Getting Trust Anchor credentials for Faber, Acme, Thrift and Government ==\")\n", " print(\"------------------------------\")\n", "\n", - " print(\"\\\"Sovrin Steward\\\" -> Create wallet\")\n", " steward = {\n", " 'name': \"Sovrin Steward\",\n", " 'wallet_config': json.dumps({'id': 'sovrin_steward_wallet'}),\n", @@ -46,20 +44,14 @@ " 'seed': '000000000000000000000000Steward1'\n", " }\n", "\n", - " try:\n", - " await wallet.create_wallet(steward['wallet_config'], steward['wallet_credentials'])\n", - " except IndyError as ex:\n", - " if ex.error_code == ErrorCode.WalletAlreadyExistsError:\n", - " pass\n", - "\n", - " steward['wallet'] = await wallet.open_wallet(steward['wallet_config'], steward['wallet_credentials'])\n", + " await create_wallet(steward)\n", "\n", " print(\"\\\"Sovrin Steward\\\" -> Create and store in Wallet DID from seed\")\n", " steward['did_info'] = json.dumps({'seed': steward['seed']})\n", " steward['did'], steward['key'] = await did.create_and_store_my_did(steward['wallet'], steward['did_info'])\n", "\n", " print(\"==============================\")\n", - " print(\"== Getting Trust Anchor credentials - Government Onboarding ==\")\n", + " print(\"== Getting Trust Anchor credentials - Government getting Verinym ==\")\n", " print(\"------------------------------\")\n", "\n", " government = {\n", @@ -69,18 +61,11 @@ " 'pool': pool_['handle'],\n", " 'role': 'TRUST_ANCHOR'\n", " }\n", - " steward['did_for_government'], steward['key_for_government'], government['did_for_steward'], \\\n", - " government['key_for_steward'], _ = await onboarding(steward, government)\n", "\n", - " print(\"==============================\")\n", - " print(\"== Getting Trust Anchor credentials - Government getting Verinym ==\")\n", - " print(\"------------------------------\")\n", - "\n", - " government['did'] = await get_verinym(steward, steward['did_for_government'], steward['key_for_government'],\n", - " government, government['did_for_steward'], government['key_for_steward'])\n", + " await getting_verinym(steward, government)\n", "\n", " print(\"==============================\")\n", - " print(\"== Getting Trust Anchor credentials - Faber Onboarding ==\")\n", + " print(\"== Getting Trust Anchor credentials - Faber getting Verinym ==\")\n", " print(\"------------------------------\")\n", "\n", " faber = {\n", @@ -90,19 +75,11 @@ " 'pool': pool_['handle'],\n", " 'role': 'TRUST_ANCHOR'\n", " }\n", - " steward['did_for_faber'], steward['key_for_faber'], faber['did_for_steward'], faber['key_for_steward'], _ = \\\n", - " await onboarding(steward, faber)\n", "\n", - " print(\"==============================\")\n", - " print(\"== Getting Trust Anchor credentials - Faber getting Verinym ==\")\n", - " print(\"------------------------------\")\n", - "\n", - " faber['did'] = \\\n", - " await get_verinym(steward, steward['did_for_faber'], steward['key_for_faber'],\n", - " faber, faber['did_for_steward'], faber['key_for_steward'])\n", + " await getting_verinym(steward, faber)\n", "\n", " print(\"==============================\")\n", - " print(\"== Getting Trust Anchor credentials - Acme Onboarding ==\")\n", + " print(\"== Getting Trust Anchor credentials - Acme getting Verinym ==\")\n", " print(\"------------------------------\")\n", "\n", " acme = {\n", @@ -112,18 +89,11 @@ " 'pool': pool_['handle'],\n", " 'role': 'TRUST_ANCHOR'\n", " }\n", - " steward['did_for_acme'], steward['key_for_acme'], acme['did_for_steward'], acme['key_for_steward'], _ = \\\n", - " await onboarding(steward, acme)\n", "\n", - " print(\"==============================\")\n", - " print(\"== Getting Trust Anchor credentials - Acme getting Verinym ==\")\n", - " print(\"------------------------------\")\n", - "\n", - " acme['did'] = await get_verinym(steward, steward['did_for_acme'], steward['key_for_acme'],\n", - " acme, acme['did_for_steward'], acme['key_for_steward'])\n", + " await getting_verinym(steward, acme)\n", "\n", " print(\"==============================\")\n", - " print(\"== Getting Trust Anchor credentials - Thrift Onboarding ==\")\n", + " print(\"== Getting Trust Anchor credentials - Thrift getting Verinym ==\")\n", " print(\"------------------------------\")\n", "\n", " thrift = {\n", @@ -133,15 +103,8 @@ " 'pool': pool_['handle'],\n", " 'role': 'TRUST_ANCHOR'\n", " }\n", - " steward['did_for_thrift'], steward['key_for_thrift'], thrift['did_for_steward'], thrift['key_for_steward'], _ = \\\n", - " await onboarding(steward, thrift)\n", "\n", - " print(\"==============================\")\n", - " print(\"== Getting Trust Anchor credentials - Thrift getting Verinym ==\")\n", - " print(\"------------------------------\")\n", - "\n", - " thrift['did'] = await get_verinym(steward, steward['did_for_thrift'], steward['key_for_thrift'],\n", - " thrift, thrift['did_for_steward'], thrift['key_for_steward'])\n", + " await getting_verinym(steward, thrift)\n", "\n", " print(\"==============================\")\n", " print(\"=== Credential Schemas Setup ==\")\n", @@ -227,8 +190,8 @@ " print(\"==============================\")\n", " print(\"=== Getting Transcript with Faber ==\")\n", " print(\"==============================\")\n", - " print(\"== Getting Transcript with Faber - Onboarding ==\")\n", - " print(\"------------------------------\")\n", + " print(\"== Alice setup ==\")\n", + " print(\"==============================\")\n", "\n", " alice = {\n", " 'name': 'Alice',\n", @@ -236,8 +199,8 @@ " 'wallet_credentials': json.dumps({'key': 'alice_wallet_key'}),\n", " 'pool': pool_['handle'],\n", " }\n", - " faber['did_for_alice'], faber['key_for_alice'], alice['did_for_faber'], alice['key_for_faber'], \\\n", - " faber['alice_connection_response'] = await onboarding(faber, alice)\n", + " await create_wallet(alice)\n", + " (alice['did'], alice['key']) = await did.create_and_store_my_did(alice['wallet'], \"{}\")\n", "\n", " print(\"==============================\")\n", " print(\"== Getting Transcript with Faber - Getting Transcript Credential ==\")\n", @@ -247,43 +210,29 @@ " faber['transcript_cred_offer'] = \\\n", " await anoncreds.issuer_create_credential_offer(faber['wallet'], faber['transcript_cred_def_id'])\n", "\n", - " print(\"\\\"Faber\\\" -> Get key for Alice did\")\n", - " faber['alic_key_for_faber'] = \\\n", - " await did.key_for_did(faber['pool'], faber['wallet'], faber['alice_connection_response']['did'])\n", + " print(\"\\\"Faber\\\" -> Send \\\"Transcript\\\" Credential Offer to Alice\")\n", + " alice['transcript_cred_offer'] = faber['transcript_cred_offer']\n", + " transcript_cred_offer_object = json.loads(alice['transcript_cred_offer'])\n", "\n", - " print(\"\\\"Faber\\\" -> Authcrypt \\\"Transcript\\\" Credential Offer for Alice\")\n", - " faber['authcrypted_transcript_cred_offer'] = \\\n", - " await crypto.auth_crypt(faber['wallet'], faber['key_for_alice'], faber['alic_key_for_faber'],\n", - " faber['transcript_cred_offer'].encode('utf-8'))\n", - "\n", - " print(\"\\\"Faber\\\" -> Send authcrypted \\\"Transcript\\\" Credential Offer to Alice\")\n", - " alice['authcrypted_transcript_cred_offer'] = faber['authcrypted_transcript_cred_offer']\n", - "\n", - " print(\"\\\"Alice\\\" -> Authdecrypted \\\"Transcript\\\" Credential Offer from Faber\")\n", - " alice['faber_key_for_alice'], alice['transcript_cred_offer'], authdecrypted_transcript_cred_offer = \\\n", - " await auth_decrypt(alice['wallet'], alice['key_for_faber'], alice['authcrypted_transcript_cred_offer'])\n", - " alice['transcript_schema_id'] = authdecrypted_transcript_cred_offer['schema_id']\n", - " alice['transcript_cred_def_id'] = authdecrypted_transcript_cred_offer['cred_def_id']\n", + " alice['transcript_schema_id'] = transcript_cred_offer_object['schema_id']\n", + " alice['transcript_cred_def_id'] = transcript_cred_offer_object['cred_def_id']\n", "\n", " print(\"\\\"Alice\\\" -> Create and store \\\"Alice\\\" Master Secret in Wallet\")\n", " alice['master_secret_id'] = await anoncreds.prover_create_master_secret(alice['wallet'], None)\n", "\n", " print(\"\\\"Alice\\\" -> Get \\\"Faber Transcript\\\" Credential Definition from Ledger\")\n", " (alice['faber_transcript_cred_def_id'], alice['faber_transcript_cred_def']) = \\\n", - " await get_cred_def(alice['pool'], alice['did_for_faber'], authdecrypted_transcript_cred_offer['cred_def_id'])\n", + " await get_cred_def(alice['pool'], alice['did'], alice['transcript_cred_def_id'])\n", "\n", " print(\"\\\"Alice\\\" -> Create \\\"Transcript\\\" Credential Request for Faber\")\n", " (alice['transcript_cred_request'], alice['transcript_cred_request_metadata']) = \\\n", - " await anoncreds.prover_create_credential_req(alice['wallet'], alice['did_for_faber'],\n", + " await anoncreds.prover_create_credential_req(alice['wallet'], alice['did'],\n", " alice['transcript_cred_offer'], alice['faber_transcript_cred_def'],\n", " alice['master_secret_id'])\n", "\n", - " print(\"\\\"Alice\\\" -> Authcrypt \\\"Transcript\\\" Credential Request for Faber\")\n", - " alice['authcrypted_transcript_cred_request'] = \\\n", - " await crypto.auth_crypt(alice['wallet'], alice['key_for_faber'], alice['faber_key_for_alice'],\n", - " alice['transcript_cred_request'].encode('utf-8'))\n", + " print(\"\\\"Alice\\\" -> Send \\\"Transcript\\\" Credential Request to Faber\")\n", + " faber['transcript_cred_request'] = alice['transcript_cred_request']\n", "\n", - " print(\"\\\"Alice\\\" -> Send authcrypted \\\"Transcript\\\" Credential Request to Faber\")\n", " alice['transcript_cred_values'] = json.dumps({\n", " \"first_name\": {\"raw\": \"Alice\", \"encoded\": \"1139481716457488690172217916278103335\"},\n", " \"last_name\": {\"raw\": \"Garcia\", \"encoded\": \"5321642780241790123587902456789123452\"},\n", @@ -293,13 +242,8 @@ " \"year\": {\"raw\": \"2015\", \"encoded\": \"2015\"},\n", " \"average\": {\"raw\": \"5\", \"encoded\": \"5\"}\n", " })\n", - " faber['authcrypted_transcript_cred_request'] = alice['authcrypted_transcript_cred_request']\n", " faber['alice_transcript_cred_values'] = alice['transcript_cred_values']\n", "\n", - " print(\"\\\"Faber\\\" -> Authdecrypt \\\"Transcript\\\" Credential Request from Alice\")\n", - " faber['alice_key_for_faber'], faber['transcript_cred_request'], _ = \\\n", - " await auth_decrypt(faber['wallet'], faber['key_for_alice'], faber['authcrypted_transcript_cred_request'])\n", - "\n", " print(\"\\\"Faber\\\" -> Create \\\"Transcript\\\" Credential for Alice\")\n", "\n", " faber['transcript_cred'], _, _ = \\\n", @@ -307,35 +251,17 @@ " faber['transcript_cred_request'],\n", " faber['alice_transcript_cred_values'], None, None)\n", "\n", - " print(\"\\\"Faber\\\" -> Authcrypt \\\"Transcript\\\" Credential for Alice\")\n", - " faber['authcrypted_transcript_cred'] = \\\n", - " await crypto.auth_crypt(faber['wallet'], faber['key_for_alice'], faber['alice_key_for_faber'],\n", - " faber['transcript_cred'].encode('utf-8'))\n", - "\n", - " print(\"\\\"Faber\\\" -> Send authcrypted \\\"Transcript\\\" Credential to Alice\")\n", - " alice['authcrypted_transcript_cred'] = faber['authcrypted_transcript_cred']\n", - "\n", - " print(\"\\\"Alice\\\" -> Authdecrypted \\\"Transcript\\\" Credential from Faber\")\n", - " _, alice['transcript_cred'], _ = \\\n", - " await auth_decrypt(alice['wallet'], alice['key_for_faber'], alice['authcrypted_transcript_cred'])\n", + " print(\"\\\"Faber\\\" -> Send \\\"Transcript\\\" Credential to Alice\")\n", + " alice['transcript_cred'] = faber['transcript_cred']\n", "\n", " print(\"\\\"Alice\\\" -> Store \\\"Transcript\\\" Credential from Faber\")\n", - " _, alice['transcript_cred_def'] = await get_cred_def(alice['pool'], alice['did_for_faber'],\n", + " _, alice['transcript_cred_def'] = await get_cred_def(alice['pool'], alice['did'],\n", " alice['transcript_cred_def_id'])\n", "\n", " await anoncreds.prover_store_credential(alice['wallet'], None, alice['transcript_cred_request_metadata'],\n", " alice['transcript_cred'], alice['transcript_cred_def'], None)\n", "\n", " print(\"==============================\")\n", - " print(\"=== Apply for the job with Acme ==\")\n", - " print(\"==============================\")\n", - " print(\"== Apply for the job with Acme - Onboarding ==\")\n", - " print(\"------------------------------\")\n", - "\n", - " acme['did_for_alice'], acme['key_for_alice'], alice['did_for_acme'], alice['key_for_acme'], \\\n", - " acme['alice_connection_response'] = await onboarding(acme, alice)\n", - "\n", - " print(\"==============================\")\n", " print(\"== Apply for the job with Acme - Transcript proving ==\")\n", " print(\"------------------------------\")\n", "\n", @@ -378,21 +304,8 @@ " }\n", " })\n", "\n", - " print(\"\\\"Acme\\\" -> Get key for Alice did\")\n", - " acme['alice_key_for_acme'] = \\\n", - " await did.key_for_did(acme['pool'], acme['wallet'], acme['alice_connection_response']['did'])\n", - "\n", - " print(\"\\\"Acme\\\" -> Authcrypt \\\"Job-Application\\\" Proof Request for Alice\")\n", - " acme['authcrypted_job_application_proof_request'] = \\\n", - " await crypto.auth_crypt(acme['wallet'], acme['key_for_alice'], acme['alice_key_for_acme'],\n", - " acme['job_application_proof_request'].encode('utf-8'))\n", - "\n", - " print(\"\\\"Acme\\\" -> Send authcrypted \\\"Job-Application\\\" Proof Request to Alice\")\n", - " alice['authcrypted_job_application_proof_request'] = acme['authcrypted_job_application_proof_request']\n", - "\n", - " print(\"\\\"Alice\\\" -> Authdecrypt \\\"Job-Application\\\" Proof Request from Acme\")\n", - " alice['acme_key_for_alice'], alice['job_application_proof_request'], _ = \\\n", - " await auth_decrypt(alice['wallet'], alice['key_for_acme'], alice['authcrypted_job_application_proof_request'])\n", + " print(\"\\\"Acme\\\" -> Send \\\"Job-Application\\\" Proof Request to Alice\")\n", + " alice['job_application_proof_request'] = acme['job_application_proof_request']\n", "\n", " print(\"\\\"Alice\\\" -> Get credentials for \\\"Job-Application\\\" Proof Request\")\n", "\n", @@ -418,7 +331,7 @@ " cred_for_predicate1['referent']: cred_for_predicate1}\n", "\n", " alice['schemas'], alice['cred_defs'], alice['revoc_states'] = \\\n", - " await prover_get_entities_from_ledger(alice['pool'], alice['did_for_acme'],\n", + " await prover_get_entities_from_ledger(alice['pool'], alice['did'],\n", " alice['creds_for_job_application_proof'], alice['name'])\n", "\n", " print(\"\\\"Alice\\\" -> Create \\\"Job-Application\\\" Proof\")\n", @@ -441,37 +354,32 @@ " alice['job_application_requested_creds'], alice['master_secret_id'],\n", " alice['schemas'], alice['cred_defs'], alice['revoc_states'])\n", "\n", - " print(\"\\\"Alice\\\" -> Authcrypt \\\"Job-Application\\\" Proof for Acme\")\n", - " alice['authcrypted_job_application_proof'] = \\\n", - " await crypto.auth_crypt(alice['wallet'], alice['key_for_acme'], alice['acme_key_for_alice'],\n", - " alice['job_application_proof'].encode('utf-8'))\n", - "\n", - " print(\"\\\"Alice\\\" -> Send authcrypted \\\"Job-Application\\\" Proof to Acme\")\n", - " acme['authcrypted_job_application_proof'] = alice['authcrypted_job_application_proof']\n", - "\n", - " print(\"\\\"Acme\\\" -> Authdecrypted \\\"Job-Application\\\" Proof from Alice\")\n", - " _, acme['job_application_proof'], decrypted_job_application_proof = \\\n", - " await auth_decrypt(acme['wallet'], acme['key_for_alice'], acme['authcrypted_job_application_proof'])\n", + " print(\"\\\"Alice\\\" -> Send \\\"Job-Application\\\" Proof to Acme\")\n", + " acme['job_application_proof'] = alice['job_application_proof']\n", + " job_application_proof_object = json.loads(acme['job_application_proof'])\n", "\n", - " acme['schemas'], acme['cred_defs'], acme['revoc_ref_defs'], acme['revoc_regs'] = \\\n", + " acme['schemas_for_job_application'], acme['cred_defs_for_job_application'], \\\n", + " acme['revoc_ref_defs_for_job_application'], acme['revoc_regs_for_job_application'] = \\\n", " await verifier_get_entities_from_ledger(acme['pool'], acme['did'],\n", - " decrypted_job_application_proof['identifiers'], acme['name'])\n", + " job_application_proof_object['identifiers'], acme['name'])\n", "\n", " print(\"\\\"Acme\\\" -> Verify \\\"Job-Application\\\" Proof from Alice\")\n", " assert 'Bachelor of Science, Marketing' == \\\n", - " decrypted_job_application_proof['requested_proof']['revealed_attrs']['attr3_referent']['raw']\n", + " job_application_proof_object['requested_proof']['revealed_attrs']['attr3_referent']['raw']\n", " assert 'graduated' == \\\n", - " decrypted_job_application_proof['requested_proof']['revealed_attrs']['attr4_referent']['raw']\n", + " job_application_proof_object['requested_proof']['revealed_attrs']['attr4_referent']['raw']\n", " assert '123-45-6789' == \\\n", - " decrypted_job_application_proof['requested_proof']['revealed_attrs']['attr5_referent']['raw']\n", + " job_application_proof_object['requested_proof']['revealed_attrs']['attr5_referent']['raw']\n", "\n", - " assert 'Alice' == decrypted_job_application_proof['requested_proof']['self_attested_attrs']['attr1_referent']\n", - " assert 'Garcia' == decrypted_job_application_proof['requested_proof']['self_attested_attrs']['attr2_referent']\n", - " assert '123-45-6789' == decrypted_job_application_proof['requested_proof']['self_attested_attrs']['attr6_referent']\n", + " assert 'Alice' == job_application_proof_object['requested_proof']['self_attested_attrs']['attr1_referent']\n", + " assert 'Garcia' == job_application_proof_object['requested_proof']['self_attested_attrs']['attr2_referent']\n", + " assert '123-45-6789' == job_application_proof_object['requested_proof']['self_attested_attrs']['attr6_referent']\n", "\n", " assert await anoncreds.verifier_verify_proof(acme['job_application_proof_request'], acme['job_application_proof'],\n", - " acme['schemas'], acme['cred_defs'], acme['revoc_ref_defs'],\n", - " acme['revoc_regs'])\n", + " acme['schemas_for_job_application'],\n", + " acme['cred_defs_for_job_application'],\n", + " acme['revoc_ref_defs_for_job_application'],\n", + " acme['revoc_regs_for_job_application'])\n", "\n", " print(\"==============================\")\n", " print(\"== Apply for the job with Acme - Getting Job-Certificate Credential ==\")\n", @@ -481,38 +389,23 @@ " acme['job_certificate_cred_offer'] = \\\n", " await anoncreds.issuer_create_credential_offer(acme['wallet'], acme['job_certificate_cred_def_id'])\n", "\n", - " print(\"\\\"Acme\\\" -> Get key for Alice did\")\n", - " acme['alice_key_for_acme'] = \\\n", - " await did.key_for_did(acme['pool'], acme['wallet'], acme['alice_connection_response']['did'])\n", - "\n", - " print(\"\\\"Acme\\\" -> Authcrypt \\\"Job-Certificate\\\" Credential Offer for Alice\")\n", - " acme['authcrypted_job_certificate_cred_offer'] = \\\n", - " await crypto.auth_crypt(acme['wallet'], acme['key_for_alice'], acme['alice_key_for_acme'],\n", - " acme['job_certificate_cred_offer'].encode('utf-8'))\n", - "\n", - " print(\"\\\"Acme\\\" -> Send authcrypted \\\"Job-Certificate\\\" Credential Offer to Alice\")\n", - " alice['authcrypted_job_certificate_cred_offer'] = acme['authcrypted_job_certificate_cred_offer']\n", - "\n", - " print(\"\\\"Alice\\\" -> Authdecrypted \\\"Job-Certificate\\\" Credential Offer from Acme\")\n", - " alice['acme_key_for_alice_alice'], alice['job_certificate_cred_offer'], job_certificate_cred_offer = \\\n", - " await auth_decrypt(alice['wallet'], alice['key_for_acme'], alice['authcrypted_job_certificate_cred_offer'])\n", + " print(\"\\\"Acme\\\" -> Send \\\"Job-Certificate\\\" Credential Offer to Alice\")\n", + " alice['job_certificate_cred_offer'] = acme['job_certificate_cred_offer']\n", + " job_certificate_cred_offer_object = json.loads(alice['job_certificate_cred_offer'])\n", "\n", " print(\"\\\"Alice\\\" -> Get \\\"Acme Job-Certificate\\\" Credential Definition from Ledger\")\n", " (alice['acme_job_certificate_cred_def_id'], alice['acme_job_certificate_cred_def']) = \\\n", - " await get_cred_def(alice['pool'], alice['did_for_acme'], job_certificate_cred_offer['cred_def_id'])\n", + " await get_cred_def(alice['pool'], alice['did'], job_certificate_cred_offer_object['cred_def_id'])\n", "\n", " print(\"\\\"Alice\\\" -> Create and store in Wallet \\\"Job-Certificate\\\" Credential Request for Acme\")\n", " (alice['job_certificate_cred_request'], alice['job_certificate_cred_request_metadata']) = \\\n", - " await anoncreds.prover_create_credential_req(alice['wallet'], alice['did_for_acme'],\n", + " await anoncreds.prover_create_credential_req(alice['wallet'], alice['did'],\n", " alice['job_certificate_cred_offer'],\n", " alice['acme_job_certificate_cred_def'], alice['master_secret_id'])\n", "\n", - " print(\"\\\"Alice\\\" -> Authcrypt \\\"Job-Certificate\\\" Credential Request for Acme\")\n", - " alice['authcrypted_job_certificate_cred_request'] = \\\n", - " await crypto.auth_crypt(alice['wallet'], alice['key_for_acme'], alice['acme_key_for_alice'],\n", - " alice['job_certificate_cred_request'].encode('utf-8'))\n", + " print(\"\\\"Alice\\\" -> Send \\\"Job-Certificate\\\" Credential Request to Acme\")\n", + " acme['job_certificate_cred_request'] = alice['job_certificate_cred_request']\n", "\n", - " print(\"\\\"Alice\\\" -> Send authcrypted \\\"Job-Certificate\\\" Credential Request to Acme\")\n", " alice['job_certificate_cred_values'] = json.dumps({\n", " \"first_name\": {\"raw\": \"Alice\", \"encoded\": \"245712572474217942457235975012103335\"},\n", " \"last_name\": {\"raw\": \"Garcia\", \"encoded\": \"312643218496194691632153761283356127\"},\n", @@ -520,13 +413,8 @@ " \"salary\": {\"raw\": \"2400\", \"encoded\": \"2400\"},\n", " \"experience\": {\"raw\": \"10\", \"encoded\": \"10\"}\n", " })\n", - " acme['authcrypted_job_certificate_cred_request'] = alice['authcrypted_job_certificate_cred_request']\n", " acme['job_certificate_cred_values'] = alice['job_certificate_cred_values']\n", "\n", - " print(\"\\\"Acme\\\" -> Authdecrypt \\\"Job-Certificate\\\" Credential Request from Alice\")\n", - " acme['alice_key_for_acme'], acme['job_certificate_cred_request'], _ = \\\n", - " await auth_decrypt(acme['wallet'], acme['key_for_alice'], acme['authcrypted_job_certificate_cred_request'])\n", - "\n", " print(\"\\\"Acme\\\" -> Create \\\"Job-Certificate\\\" Credential for Alice\")\n", "\n", " acme['job_certificate_cred'], _, _ = \\\n", @@ -534,17 +422,8 @@ " acme['job_certificate_cred_request'],\n", " acme['job_certificate_cred_values'], None, None)\n", "\n", - " print(\"\\\"Acme\\\" -> Authcrypt \\\"Job-Certificate\\\" Credential for Alice\")\n", - " acme['authcrypted_job_certificate_cred'] = \\\n", - " await crypto.auth_crypt(acme['wallet'], acme['key_for_alice'], acme['alice_key_for_acme'],\n", - " acme['job_certificate_cred'].encode('utf-8'))\n", - "\n", - " print(\"\\\"Acme\\\" -> Send authcrypted \\\"Job-Certificate\\\" Credential to Alice\")\n", - " alice['authcrypted_job_certificate_cred'] = acme['authcrypted_job_certificate_cred']\n", - "\n", - " print(\"\\\"Alice\\\" -> Authdecrypted \\\"Job-Certificate\\\" Credential from Acme\")\n", - " _, alice['job_certificate_cred'], _ = \\\n", - " await auth_decrypt(alice['wallet'], alice['key_for_acme'], alice['authcrypted_job_certificate_cred'])\n", + " print(\"\\\"Acme\\\" -> Send \\\"Job-Certificate\\\" Credential to Alice\")\n", + " alice['job_certificate_cred'] = acme['job_certificate_cred']\n", "\n", " print(\"\\\"Alice\\\" -> Store \\\"Job-Certificate\\\" Credential\")\n", " await anoncreds.prover_store_credential(alice['wallet'], None, alice['job_certificate_cred_request_metadata'],\n", @@ -552,15 +431,6 @@ " alice['acme_job_certificate_cred_def'], None)\n", "\n", " print(\"==============================\")\n", - " print(\"=== Apply for the loan with Thrift ==\")\n", - " print(\"==============================\")\n", - " print(\"== Apply for the loan with Thrift - Onboarding ==\")\n", - " print(\"------------------------------\")\n", - "\n", - " thrift['did_for_alice'], thrift['key_for_alice'], alice['did_for_thrift'], alice['key_for_thrift'], \\\n", - " thrift['alice_connection_response'] = await onboarding(thrift, alice)\n", - "\n", - " print(\"==============================\")\n", " print(\"== Apply for the loan with Thrift - Job-Certificate proving ==\")\n", " print(\"------------------------------\")\n", "\n", @@ -592,21 +462,8 @@ " }\n", " })\n", "\n", - " print(\"\\\"Thrift\\\" -> Get key for Alice did\")\n", - " thrift['alice_key_for_thrift'] = \\\n", - " await did.key_for_did(thrift['pool'], thrift['wallet'], thrift['alice_connection_response']['did'])\n", - "\n", - " print(\"\\\"Thrift\\\" -> Authcrypt \\\"Loan-Application-Basic\\\" Proof Request for Alice\")\n", - " thrift['authcrypted_apply_loan_proof_request'] = \\\n", - " await crypto.auth_crypt(thrift['wallet'], thrift['key_for_alice'], thrift['alice_key_for_thrift'],\n", - " thrift['apply_loan_proof_request'].encode('utf-8'))\n", - "\n", - " print(\"\\\"Thrift\\\" -> Send authcrypted \\\"Loan-Application-Basic\\\" Proof Request to Alice\")\n", - " alice['authcrypted_apply_loan_proof_request'] = thrift['authcrypted_apply_loan_proof_request']\n", - "\n", - " print(\"\\\"Alice\\\" -> Authdecrypt \\\"Loan-Application-Basic\\\" Proof Request from Thrift\")\n", - " alice['thrift_key_for_alice'], alice['apply_loan_proof_request'], _ = \\\n", - " await auth_decrypt(alice['wallet'], alice['key_for_thrift'], alice['authcrypted_apply_loan_proof_request'])\n", + " print(\"\\\"Thrift\\\" -> Send \\\"Loan-Application-Basic\\\" Proof Request to Alice\")\n", + " alice['apply_loan_proof_request'] = thrift['apply_loan_proof_request']\n", "\n", " print(\"\\\"Alice\\\" -> Get credentials for \\\"Loan-Application-Basic\\\" Proof Request\")\n", "\n", @@ -625,7 +482,7 @@ " cred_for_predicate2['referent']: cred_for_predicate2}\n", "\n", " alice['schemas'], alice['cred_defs'], alice['revoc_states'] = \\\n", - " await prover_get_entities_from_ledger(alice['pool'], alice['did_for_thrift'],\n", + " await prover_get_entities_from_ledger(alice['pool'], alice['did'],\n", " alice['creds_for_apply_loan_proof'],\n", " alice['name'])\n", "\n", @@ -645,30 +502,22 @@ " alice['apply_loan_requested_creds'], alice['master_secret_id'],\n", " alice['schemas'], alice['cred_defs'], alice['revoc_states'])\n", "\n", - " print(\"\\\"Alice\\\" -> Authcrypt \\\"Loan-Application-Basic\\\" Proof for Thrift\")\n", - " alice['authcrypted_alice_apply_loan_proof'] = \\\n", - " await crypto.auth_crypt(alice['wallet'], alice['key_for_thrift'], alice['thrift_key_for_alice'],\n", - " alice['apply_loan_proof'].encode('utf-8'))\n", - "\n", - " print(\"\\\"Alice\\\" -> Send authcrypted \\\"Loan-Application-Basic\\\" Proof to Thrift\")\n", - " thrift['authcrypted_alice_apply_loan_proof'] = alice['authcrypted_alice_apply_loan_proof']\n", - "\n", - " print(\"\\\"Thrift\\\" -> Authdecrypted \\\"Loan-Application-Basic\\\" Proof from Alice\")\n", - " _, thrift['alice_apply_loan_proof'], authdecrypted_alice_apply_loan_proof = \\\n", - " await auth_decrypt(thrift['wallet'], thrift['key_for_alice'], thrift['authcrypted_alice_apply_loan_proof'])\n", + " print(\"\\\"Alice\\\" -> Send \\\"Loan-Application-Basic\\\" Proof to Thrift\")\n", + " thrift['apply_loan_proof'] = alice['apply_loan_proof']\n", + " apply_loan_proof_object = json.loads(thrift['apply_loan_proof'])\n", "\n", " print(\"\\\"Thrift\\\" -> Get Schemas, Credential Definitions and Revocation Registries from Ledger\"\n", - " \" required for Proof verifying\")\n", + " \" required for Proof verifying\")\n", "\n", " thrift['schemas'], thrift['cred_defs'], thrift['revoc_defs'], thrift['revoc_regs'] = \\\n", " await verifier_get_entities_from_ledger(thrift['pool'], thrift['did'],\n", - " authdecrypted_alice_apply_loan_proof['identifiers'], thrift['name'])\n", + " apply_loan_proof_object['identifiers'], thrift['name'])\n", "\n", " print(\"\\\"Thrift\\\" -> Verify \\\"Loan-Application-Basic\\\" Proof from Alice\")\n", " assert 'Permanent' == \\\n", - " authdecrypted_alice_apply_loan_proof['requested_proof']['revealed_attrs']['attr1_referent']['raw']\n", + " apply_loan_proof_object['requested_proof']['revealed_attrs']['attr1_referent']['raw']\n", "\n", - " assert await anoncreds.verifier_verify_proof(thrift['apply_loan_proof_request'], thrift['alice_apply_loan_proof'],\n", + " assert await anoncreds.verifier_verify_proof(thrift['apply_loan_proof_request'], thrift['apply_loan_proof'],\n", " thrift['schemas'], thrift['cred_defs'], thrift['revoc_defs'],\n", " thrift['revoc_regs'])\n", "\n", @@ -692,21 +541,8 @@ " 'requested_predicates': {}\n", " })\n", "\n", - " print(\"\\\"Thrift\\\" -> Get key for Alice did\")\n", - " thrift['alice_key_for_thrift'] = await did.key_for_did(thrift['pool'], thrift['wallet'],\n", - " thrift['alice_connection_response']['did'])\n", - "\n", - " print(\"\\\"Thrift\\\" -> Authcrypt \\\"Loan-Application-KYC\\\" Proof Request for Alice\")\n", - " thrift['authcrypted_apply_loan_kyc_proof_request'] = \\\n", - " await crypto.auth_crypt(thrift['wallet'], thrift['key_for_alice'], thrift['alice_key_for_thrift'],\n", - " thrift['apply_loan_kyc_proof_request'].encode('utf-8'))\n", - "\n", - " print(\"\\\"Thrift\\\" -> Send authcrypted \\\"Loan-Application-KYC\\\" Proof Request to Alice\")\n", - " alice['authcrypted_apply_loan_kyc_proof_request'] = thrift['authcrypted_apply_loan_kyc_proof_request']\n", - "\n", - " print(\"\\\"Alice\\\" -> Authdecrypt \\\"Loan-Application-KYC\\\" Proof Request from Thrift\")\n", - " alice['thrift_key_for_alice'], alice['apply_loan_kyc_proof_request'], _ = \\\n", - " await auth_decrypt(alice['wallet'], alice['key_for_thrift'], alice['authcrypted_apply_loan_kyc_proof_request'])\n", + " print(\"\\\"Thrift\\\" -> Send \\\"Loan-Application-KYC\\\" Proof Request to Alice\")\n", + " alice['apply_loan_kyc_proof_request'] = thrift['apply_loan_kyc_proof_request']\n", "\n", " print(\"\\\"Alice\\\" -> Get credentials for \\\"Loan-Application-KYC\\\" Proof Request\")\n", "\n", @@ -725,7 +561,7 @@ " cred_for_attr3['referent']: cred_for_attr3}\n", "\n", " alice['schemas'], alice['cred_defs'], alice['revoc_states'] = \\\n", - " await prover_get_entities_from_ledger(alice['pool'], alice['did_for_thrift'],\n", + " await prover_get_entities_from_ledger(alice['pool'], alice['did'],\n", " alice['creds_for_apply_loan_kyc_proof'], 'Alice')\n", "\n", " print(\"\\\"Alice\\\" -> Create \\\"Loan-Application-KYC\\\" Proof\")\n", @@ -745,35 +581,27 @@ " alice['apply_loan_kyc_requested_creds'], alice['master_secret_id'],\n", " alice['schemas'], alice['cred_defs'], alice['revoc_states'])\n", "\n", - " print(\"\\\"Alice\\\" -> Authcrypt \\\"Loan-Application-KYC\\\" Proof for Thrift\")\n", - " alice['authcrypted_alice_apply_loan_kyc_proof'] = \\\n", - " await crypto.auth_crypt(alice['wallet'], alice['key_for_thrift'], alice['thrift_key_for_alice'],\n", - " alice['apply_loan_kyc_proof'].encode('utf-8'))\n", - "\n", - " print(\"\\\"Alice\\\" -> Send authcrypted \\\"Loan-Application-KYC\\\" Proof to Thrift\")\n", - " thrift['authcrypted_alice_apply_loan_kyc_proof'] = alice['authcrypted_alice_apply_loan_kyc_proof']\n", - "\n", - " print(\"\\\"Thrift\\\" -> Authdecrypted \\\"Loan-Application-KYC\\\" Proof from Alice\")\n", - " _, thrift['alice_apply_loan_kyc_proof'], alice_apply_loan_kyc_proof = \\\n", - " await auth_decrypt(thrift['wallet'], thrift['key_for_alice'], thrift['authcrypted_alice_apply_loan_kyc_proof'])\n", + " print(\"\\\"Alice\\\" -> Send \\\"Loan-Application-KYC\\\" Proof to Thrift\")\n", + " thrift['apply_loan_kyc_proof'] = alice['apply_loan_kyc_proof']\n", + " apply_loan_kyc_proof_object = json.loads(thrift['apply_loan_kyc_proof'])\n", "\n", " print(\"\\\"Thrift\\\" -> Get Schemas, Credential Definitions and Revocation Registries from Ledger\"\n", - " \" required for Proof verifying\")\n", + " \" required for Proof verifying\")\n", "\n", " thrift['schemas'], thrift['cred_defs'], thrift['revoc_defs'], thrift['revoc_regs'] = \\\n", " await verifier_get_entities_from_ledger(thrift['pool'], thrift['did'],\n", - " alice_apply_loan_kyc_proof['identifiers'], 'Thrift')\n", + " apply_loan_kyc_proof_object['identifiers'], 'Thrift')\n", "\n", " print(\"\\\"Thrift\\\" -> Verify \\\"Loan-Application-KYC\\\" Proof from Alice\")\n", " assert 'Alice' == \\\n", - " alice_apply_loan_kyc_proof['requested_proof']['revealed_attrs']['attr1_referent']['raw']\n", + " apply_loan_kyc_proof_object['requested_proof']['revealed_attrs']['attr1_referent']['raw']\n", " assert 'Garcia' == \\\n", - " alice_apply_loan_kyc_proof['requested_proof']['revealed_attrs']['attr2_referent']['raw']\n", + " apply_loan_kyc_proof_object['requested_proof']['revealed_attrs']['attr2_referent']['raw']\n", " assert '123-45-6789' == \\\n", - " alice_apply_loan_kyc_proof['requested_proof']['revealed_attrs']['attr3_referent']['raw']\n", + " apply_loan_kyc_proof_object['requested_proof']['revealed_attrs']['attr3_referent']['raw']\n", "\n", " assert await anoncreds.verifier_verify_proof(thrift['apply_loan_kyc_proof_request'],\n", - " thrift['alice_apply_loan_kyc_proof'],\n", + " thrift['apply_loan_kyc_proof'],\n", " thrift['schemas'], thrift['cred_defs'], thrift['revoc_defs'],\n", " thrift['revoc_regs'])\n", "\n", @@ -810,89 +638,29 @@ " print(\"Getting started -> done\")\n", "\n", "\n", - "async def onboarding(_from, to):\n", - " print(\"\\\"{}\\\" -> Create and store in Wallet \\\"{} {}\\\" DID\".format(_from['name'], _from['name'], to['name']))\n", - " (from_to_did, from_to_key) = await did.create_and_store_my_did(_from['wallet'], \"{}\")\n", - "\n", - " print(\"\\\"{}\\\" -> Send Nym to Ledger for \\\"{} {}\\\" DID\".format(_from['name'], _from['name'], to['name']))\n", - " await send_nym(_from['pool'], _from['wallet'], _from['did'], from_to_did, from_to_key, None)\n", - "\n", - " print(\"\\\"{}\\\" -> Send connection request to {} with \\\"{} {}\\\" DID and nonce\"\n", - " .format(_from['name'], to['name'], _from['name'], to['name']))\n", - " connection_request = {\n", - " 'did': from_to_did,\n", - " 'nonce': 123456789\n", - " }\n", - "\n", - " if 'wallet' not in to:\n", - " print(\"\\\"{}\\\" -> Create wallet\".format(to['name']))\n", - " try:\n", - " await wallet.create_wallet(to['wallet_config'], to['wallet_credentials'])\n", - " except IndyError as ex:\n", - " if ex.error_code == ErrorCode.PoolLedgerConfigAlreadyExistsError:\n", - " pass\n", - " to['wallet'] = await wallet.open_wallet(to['wallet_config'], to['wallet_credentials'])\n", - "\n", - " print(\"\\\"{}\\\" -> Create and store in Wallet \\\"{} {}\\\" DID\".format(to['name'], to['name'], _from['name']))\n", - " (to_from_did, to_from_key) = await did.create_and_store_my_did(to['wallet'], \"{}\")\n", - "\n", - " print(\"\\\"{}\\\" -> Get key for did from \\\"{}\\\" connection request\".format(to['name'], _from['name']))\n", - " from_to_verkey = await did.key_for_did(_from['pool'], to['wallet'], connection_request['did'])\n", - "\n", - " print(\"\\\"{}\\\" -> Anoncrypt connection response for \\\"{}\\\" with \\\"{} {}\\\" DID, verkey and nonce\"\n", - " .format(to['name'], _from['name'], to['name'], _from['name']))\n", - " to['connection_response'] = json.dumps({\n", - " 'did': to_from_did,\n", - " 'verkey': to_from_key,\n", - " 'nonce': connection_request['nonce']\n", - " })\n", - " to['anoncrypted_connection_response'] = \\\n", - " await crypto.anon_crypt(from_to_verkey, to['connection_response'].encode('utf-8'))\n", - "\n", - " print(\"\\\"{}\\\" -> Send anoncrypted connection response to \\\"{}\\\"\".format(to['name'], _from['name']))\n", - " _from['anoncrypted_connection_response'] = to['anoncrypted_connection_response']\n", - "\n", - " print(\"\\\"{}\\\" -> Anondecrypt connection response from \\\"{}\\\"\".format(_from['name'], to['name']))\n", - " _from['connection_response'] = \\\n", - " json.loads((await crypto.anon_decrypt(_from['wallet'], from_to_key,\n", - " _from['anoncrypted_connection_response'])).decode(\"utf-8\"))\n", - "\n", - " print(\"\\\"{}\\\" -> Authenticates \\\"{}\\\" by comparision of Nonce\".format(_from['name'], to['name']))\n", - " assert connection_request['nonce'] == _from['connection_response']['nonce']\n", - "\n", - " print(\"\\\"{}\\\" -> Send Nym to Ledger for \\\"{} {}\\\" DID\".format(_from['name'], to['name'], _from['name']))\n", - " await send_nym(_from['pool'], _from['wallet'], _from['did'], to_from_did, to_from_key, None)\n", - "\n", - " return from_to_did, from_to_key, to_from_did, to_from_key, _from['connection_response']\n", - "\n", - "\n", - "async def get_verinym(_from, from_to_did, from_to_key, to, to_from_did, to_from_key):\n", - " print(\"\\\"{}\\\" -> Create and store in Wallet \\\"{}\\\" new DID\".format(to['name'], to['name']))\n", - " (to_did, to_key) = await did.create_and_store_my_did(to['wallet'], \"{}\")\n", - "\n", - " print(\"\\\"{}\\\" -> Authcrypt \\\"{} DID info\\\" for \\\"{}\\\"\".format(to['name'], to['name'], _from['name']))\n", - " to['did_info'] = json.dumps({\n", - " 'did': to_did,\n", - " 'verkey': to_key\n", - " })\n", - " to['authcrypted_did_info'] = \\\n", - " await crypto.auth_crypt(to['wallet'], to_from_key, from_to_key, to['did_info'].encode('utf-8'))\n", + "async def create_wallet(identity):\n", + " print(\"\\\"{}\\\" -> Create wallet\".format(identity['name']))\n", + " try:\n", + " await wallet.create_wallet(identity['wallet_config'], identity['wallet_credentials'])\n", + " except IndyError as ex:\n", + " if ex.error_code == ErrorCode.PoolLedgerConfigAlreadyExistsError:\n", + " pass\n", + " identity['wallet'] = await wallet.open_wallet(identity['wallet_config'], identity['wallet_credentials'])\n", "\n", - " print(\"\\\"{}\\\" -> Send authcrypted \\\"{} DID info\\\" to {}\".format(to['name'], to['name'], _from['name']))\n", "\n", - " print(\"\\\"{}\\\" -> Authdecrypted \\\"{} DID info\\\" from {}\".format(_from['name'], to['name'], to['name']))\n", - " sender_verkey, authdecrypted_did_info_json, authdecrypted_did_info = \\\n", - " await auth_decrypt(_from['wallet'], from_to_key, to['authcrypted_did_info'])\n", + "async def getting_verinym(from_, to):\n", + " await create_wallet(to)\n", "\n", - " print(\"\\\"{}\\\" -> Authenticate {} by comparision of Verkeys\".format(_from['name'], to['name'], ))\n", - " assert sender_verkey == await did.key_for_did(_from['pool'], _from['wallet'], to_from_did)\n", + " (to['did'], to['key']) = await did.create_and_store_my_did(to['wallet'], \"{}\")\n", "\n", - " print(\"\\\"{}\\\" -> Send Nym to Ledger for \\\"{} DID\\\" with {} Role\"\n", - " .format(_from['name'], to['name'], to['role']))\n", - " await send_nym(_from['pool'], _from['wallet'], _from['did'], authdecrypted_did_info['did'],\n", - " authdecrypted_did_info['verkey'], to['role'])\n", + " from_['info'] = {\n", + " 'did': to['did'],\n", + " 'verkey': to['key'],\n", + " 'role': to['role'] or None\n", + " }\n", "\n", - " return to_did\n", + " await send_nym(from_['pool'], from_['wallet'], from_['did'], from_['info']['did'],\n", + " from_['info']['verkey'], from_['info']['role'])\n", "\n", "\n", "async def send_nym(pool_handle, wallet_handle, _did, new_did, new_key, role):\n", @@ -967,13 +735,6 @@ " return json.dumps(schemas), json.dumps(cred_defs), json.dumps(rev_reg_defs), json.dumps(rev_regs)\n", "\n", "\n", - "async def auth_decrypt(wallet_handle, key, message):\n", - " from_verkey, decrypted_message_json = await crypto.auth_decrypt(wallet_handle, key, message)\n", - " decrypted_message_json = decrypted_message_json.decode(\"utf-8\")\n", - " decrypted_message = json.loads(decrypted_message_json)\n", - " return from_verkey, decrypted_message_json, decrypted_message\n", - "\n", - "\n", "if __name__ == '__main__':\n", " loop = asyncio.new_event_loop()\n", " asyncio.set_event_loop(loop)\n", diff --git a/docs/getting-started/indy-walkthrough.md b/docs/getting-started/indy-walkthrough.md index 97526c75a0..359cbd8e3b 100644 --- a/docs/getting-started/indy-walkthrough.md +++ b/docs/getting-started/indy-walkthrough.md @@ -35,9 +35,17 @@ If the concepts of cryptography and blockchain details feel mysterious, fear not Our goal is to introduce you to many of the concepts of Indy and give you some idea of what happens behind the scenes to make it all work. -We're going to frame the exploration with a story. Alice, a graduate of the fictional Faber College, wants to apply for a job at the fictional company Acme Corp. As soon as she has the job, she wants to apply for a loan in Thrift Bank so she can buy a car. She would like to use her college transcript as proof of her education on the job application and once hired, Alice would like to use the fact of employment as evidence of her creditworthiness for the loan. +**Please take note** that we are not going to cover how sides set up connection and interact with each other as part of this tutorial. +We assume that already there is established some communication channel between each pair and this channel can be used for message exchange. +Instead of message sending we will just use construction like: +``` + faber['alice_reply'] = alice['reply'] + alice['faber_response'] = faber['response'] +``` -The sorts of identity and trust interactions required to pull this off are messy in the world today; they are slow, they violate privacy, and they are susceptible to fraud. We’ll show you how Indy is a quantum leap forward. +How this communication channel can be built you can find at [Aries](https://github.com/hyperledger/aries) project which describes it in great details. + +We're going to frame the exploration with a story. Alice, a graduate of the fictional Faber College, wants to apply for a job at the fictional company Acme Corp. As soon as she has the job, she wants to apply for a loan in Thrift Bank so she can buy a car. She would like to use her college transcript as proof of her education on the job application and once hired, Alice would like to use the fact of employment as evidence of her creditworthiness for the loan. Ready? @@ -63,7 +71,7 @@ Faber College and other actors have done some preparation to offer this service The ledger is intended to store **Identity Records** that describe a **Ledger Entity**. Identity Records are public data and may include Public Keys, Service Endpoints, Credential Schemas, and Credential Definitions. Every **Identity Record** is associated with exactly one **DID** (Decentralized Identifier) that is globally unique and resolvable (via a ledger) without requiring any centralized resolution authority. To maintain privacy each **Identity Owner** can own multiple DIDs. -In this tutorial we will use two types of DIDs. The first one is a **Verinym**. A **Verinym** is associated with the **Legal Identity** of the **Identity Owner**. For example, all parties should be able to verify that some DID is used by a Government to publish schemas for some document type. The second type is a **Pseudonym** - a **Blinded Identifier** used to maintain privacy in the context of an ongoing digital relationship (**Connection**). If the Pseudonym is used to maintain only one digital relationship we will call it a Pairwise-Unique Identifier. We will use Pairwise-Unique Identifiers to maintain secure connections between actors in this tutorial. +In this tutorial we will use a **Verinym** as DIDs. A **Verinym** is associated with the **Legal Identity** of the **Identity Owner**. For example, all parties should be able to verify that some DID is used by a Government to publish schemas for some document type. The creation of a DID known to the Ledger is an **Identity Record** itself (NYM transaction). The NYM transaction can be used for creation of new DIDs that is known to that ledger, the setting and rotation of a verification key, and the setting and changing of roles. The most important fields of this transaction are `dest` (target DID), `role` (role of a user NYM record being created for) and the `verkey` (target verification key). See [Requests](https://github.com/hyperledger/indy-node/blob/master/docs/source/requests.md) to get more information about supported ledger transactions. @@ -128,128 +136,25 @@ After the wallet is opened we can create a DID record in this wallet by calling **Please note:** We provided only information about the seed to ``did.create_and_store_my_did``, but not any information about the Steward's DID. By default DID's are generated as the first 16 bytes of the verkey. For such DID's, when dealing with operations that require both a DID and the verkey we can use the verkey in an abbreviated form. In this form the verkey starts with a tilde '~' followed by 22 or 23 characters. The tilde indicates that the DID itself represents the first 16 bytes of the verkey and the string following the tilde represents the second 16 bytes of the verkey, both using base58Check encoding. -### Step 4: Onboarding Faber, Acme, Thrift and Government by Steward - -**Faber, Acme, Thrift and Government should now establish a Connection with the Steward.** - -Each connection is actually a pair of Pairwise-Unique Identifiers (DIDs). The one DID is owned by one party to the connection and the second by another. - -Both parties know both DIDs and understand what connection this pair describes. - -The relationship between them is not shareable with others; it is unique to those two parties in that each pairwise relationship uses different DIDs. - -We call the process of establish a connection **Onboarding**. - -In this tutorial we will describe the simple version of onboarding process. -In our case, one party will always be the Trust Anchor. Real enterprise scenarios can use a more complex version. +### Step 4: Getting Verinym for Faber, Acme, Thrift and Government by Steward -#### Connecting the Establishment -Let's look the process of connection establishment between **Steward** and **Faber College**. +Remind that in this tutorial we assume that already there is established some communication channel between each pair and this channel can be used for message exchange. +How this communication channel can be built you can find at [Aries](https://github.com/hyperledger/aries) project which describes it in great details. -1. **Faber** and **Steward** contact in some way to initiate onboarding process. - It can be filling the form on web site or a phone call. - -2. **Steward** creates a new DID record in the wallet by calling ``did.create_and_store_my_did`` that he will use for secure interactions only with **Faber**. - ```python - # Steward Agent - (steward['did_for_faber'], steward['key_for_faber']) = await did.create_and_store_my_did(steward['wallet'], "{}") - ``` - -3. **Steward** sends the corresponding `NYM` transaction to the Ledger by consistently calling ``ledger.build_nym_request`` to build the NYM request and ``ledger.sign_and_submit_request`` to send the created request. - ```python - # Steward Agent - nym_request = await ledger.build_nym_request(steward['did'], steward['did_for_faber'], steward['key_for_faber'], None, role) - await ledger.sign_and_submit_request(steward['pool'], steward['wallet'], steward['did'], nym_request) - ``` - -4. **Steward** creates the connection request which contains the created `DID` and `Nonce`. - This nonce is just a big random number generated to track the unique connection request. A nonce is a random arbitrary number that can only be used one time. When a connection request is accepted, the invitee digitally signs the nonce so that the inviter can match the response with a prior request. - ```python - # Steward Agent - connection_request = { - 'did': steward['did_for_faber'], - 'nonce': 123456789 - } - ``` +**Faber, Acme, Thrift and Government should now establish a Connection with the Steward.** -5. **Steward** sends the connection request to **Faber**. +#### Getting Verinym -6. **Faber** accepts the connection request from **Steward**. +After the connection is established **Faber** must create a new DID record that he will use as Verinym in the Ledger. -7. **Faber** creates a wallet if it does not exist yet. +1. **Faber** creates a wallet if it does not exist yet. ```python # Faber Agent await wallet.create_wallet(faber['wallet_config'], faber['wallet_credentials']) faber['wallet'] = await wallet.open_wallet(faber['wallet_config'], faber['wallet_credentials']) ``` - -8. **Faber** creates a new DID record in its wallet by calling ``did.create_and_store_my_did`` that it will use only for secure interactions with the **Steward**. - ```python - # Faber Agent - (faber['did_for_steward'], faber['key_for_steward']) = await did.create_and_store_my_did(faber['wallet'], "{}") - ``` - -9. **Faber** creates the connection response which contains the created `DID`, `Verkey` and `Nonce` from the received connection request. - ```python - # Faber Agent - connection_response = json.dumps({ - 'did': faber['did_for_steward'], - 'verkey': faber['key_for_steward'], - 'nonce': connection_request['nonce'] - }) - ``` - -10. **Faber** asks the ledger for the Verification key of the **Steward's** DID by calling ``did.key_for_did``. - ```python - # Faber Agent - faber['steward_key_for_faber'] = await did.key_for_did(faber['pool'], faber['wallet'], connection_request['did']) - ``` - -11. **Faber** anonymously encrypts the connection response by calling ``crypto.anon_crypt`` with the **Steward** verkey. - The Anonymous-encryption schema is designed for the sending of messages to a Recipient which has been given its public key. Only the Recipient can decrypt these messages, using its private key. While the Recipient can verify the integrity of the message, it cannot verify the identity of the Sender. - ```python - # Faber Agent - anoncrypted_connection_response = await crypto.anon_crypt(faber['steward_key_for_faber'], connection_response.encode('utf-8')) - ``` - -12. **Faber** sends the anonymously encrypted connection response to the **Steward**. - -13. **Steward** anonymously decrypts the connection response by calling ``crypto.anon_decrypt``. - ```python - # Steward Agent - decrypted_connection_response = \ - (await crypto.anon_decrypt(steward['wallet'], steward['key_for_faber'], anoncrypted_connection_response)).decode("utf-8") - ``` - -14. **Steward** authenticates **Faber** by the comparison of Nonce. - ```python - # Steward Agent - assert connection_request['nonce'] == decrypted_connection_response['nonce'] - ``` - -15. **Steward** sends the `NYM` transaction for **Faber's** DID to the Ledger. -Please note that despite the fact that the Steward is the sender of this transaction the owner of the DID will be Faber as it uses the verkey as provided by Faber. - ```python - # Steward Agent - nym_request = await ledger.build_nym_request(steward['did'], decrypted_connection_response['did'], decrypted_connection_response['verkey'], None, role) - await ledger.sign_and_submit_request(steward['pool'], steward['wallet'], steward['did'], nym_request) - ``` - -At this point **Faber** is connected to the **Steward** and can interact in a secure peer-to-peer way. **Faber** can trust the response is from **Steward** because: - -* it connects to the current endpoint -* no replay - attack is possible, due to her random challenge -* it knows the verification key used to verify **Steward** digital signature is the correct one because it just confirmed it on the ledger - -**Note:** All parties must not use the same DID's to establish other relationships. -By having independent pairwise relationships, you're reducing the ability for others to correlate your activities across multiple interactions. - -#### Getting Verinym - -It is important to understand that earlier created **Faber** DID is not, in and of itself, the same thing as self-sovereign identity. This DID must be used only for secure interaction with the **Steward**. -After the connection is established **Faber** must create a new DID record that he will use as Verinym in the Ledger. - -1. **Faber** creates a new DID in its wallet by calling ``did.create_and_store_my_did``. + +2. **Faber** creates a new DID in its wallet by calling ``did.create_and_store_my_did``. ```python # Faber Agent (faber['did'], faber['key']) = await did.create_and_store_my_did(faber['wallet'], "{}") @@ -264,46 +169,22 @@ After the connection is established **Faber** must create a new DID record that }) ``` -3. **Faber** authenticates and encrypts the message by calling ``crypto.auth_crypt`` function, which is an implementation of the authenticated-encryption schema. Authenticated encryption is designed for sending of a confidential message specifically for the Recipient. The Sender can compute a shared secret key using the Recipient's public key (verkey) and his secret (signing) key. The Recipient can compute exactly the same shared secret key using the Sender's public key (verkey) and his secret (signing) key. That shared secret key can be used to verify that the encrypted message was not tampered with, before eventually decrypting it. - ```python - # Faber Agent - authcrypted_faber_did_info_json = \ - await crypto.auth_crypt(faber['wallet'], faber['key_for_steward'], faber['steward_key_for_faber, faber['did_info'].encode('utf-8')) - ``` - -4. **Faber** sends the encrypted message to the **Steward**. - -5. **Steward** decrypts the received message by calling ``crypto.auth_decrypt``. - ```python - # Steward Agent - sender['faber_key_for_steward'], authdecrypted_faber_did_info_json = \ - await crypto.auth_decrypt(steward['wallet'], steward['key_for_faber'], authcrypted_faber_did_info_json) - faber_did_info = json.loads(authdecrypted_faber_did_info_json) - ``` - -6. **Steward** asks the ledger for the Verification key of **Faber's** DID by calling ``did.key_for_did``. - ```python - # Steward Agent - steward['faber_key_for_steward'] = await did.key_for_did(steward['pool'], steward['wallet'], ['faber_did_for_steward']) - ``` - -7. **Steward** authenticates **Faber** by comparison of the Message Sender Verkey and the **Faber** Verkey received from the Ledger. - ```python - # Steward Agent - assert sender_verkey == steward['faber_key_for_steward'] +3. **Faber** sends the message to the **Steward**. + ```python + steward['faber_info'] = faber['did_info'] ``` -8. **Steward** sends the corresponded NYM transaction to the Ledger with `TRUST ANCHOR` role. +4. **Steward** sends the corresponded NYM transaction to the Ledger with `TRUST ANCHOR` role. Please note that despite the fact that the Steward is the sender of this transaction the owner of DID will be Faber as it uses Verkey provided by Faber. ```python # Steward Agent - nym_request = await ledger.build_nym_request(steward['did'], decrypted_faber_did_info_json['did'], - decrypted_faber_did_info_json['verkey'], None, 'TRUST_ANCHOR') + nym_request = await ledger.build_nym_request(steward['did'], steward['faber_info']['did'], + steward['faber_info']['verkey'], None, 'TRUST_ANCHOR') await ledger.sign_and_submit_request(steward['pool'], steward['wallet'], steward['did'], nym_request) ``` At this point **Faber** has a DID related to his identity in the Ledger. -**Acme**, **Thrift Bank**, and **Government** must pass the same Onboarding process connection establishment with **Steward**. +**Acme**, **Thrift Bank**, and **Government** must pass the same process of getting Verinym. ### Step 5: Credential Schemas Setup @@ -462,10 +343,10 @@ After **Faber College** had established a connection with Alice, it created for ```python # Faber Agent faber['transcript_cred_offer'] = await anoncreds.issuer_create_credential_offer(faber['wallet'], faber['transcript_cred_def_id']) + + alice['transcript_cred_offer'] = faber['transcript_cred_offer'] ``` -**Note:** All messages sent between actors are encrypted using `Authenticated-encryption` scheme. - The value of this **Transcript** Credential is that it is provably issued by **Faber College**. **Alice** wants to see the attributes that the **Transcript** Credential contains. @@ -510,6 +391,8 @@ Now Alice has everything to create a Credential Request of the issuance of the * (alice['transcript_cred_request'], alice['transcript_cred_request_metadata']) = \ await anoncreds.prover_create_credential_req(alice['wallet'], alice['did_for_faber'], alice['transcript_cred_offer'], alice['transcript_cred_def'], alice['master_secret_id']) + + faber['transcript_cred_request'] = alice['transcript_cred_request'] ``` **Faber** prepares both raw and encoded values for each attribute in the **Transcript** Credential Schema. @@ -527,9 +410,11 @@ Now Alice has everything to create a Credential Request of the issuance of the * "average": {"raw": "5", "encoded": "5"} }) - faber['transcript_cred_def'], _, _ = \ + faber['transcript_cred'], _, _ = \ await anoncreds.issuer_create_credential(faber['wallet'], faber['transcript_cred_offer'], faber['transcript_cred_request'], transcript_cred_values, None, None) + + alice['transcript_cred'] = faber['transcript_cred'] ``` Now the **Transcript** Credential has been issued. Alice stores it in her wallet. @@ -594,6 +479,8 @@ In this case, **Job-Application** Proof Request looks like: } } }) + + alice['job_application_proof_request'] = acme['transcript_cred'] ``` Notice that some attributes are verifiable and some are not. @@ -662,6 +549,8 @@ Now Alice has everything to create the Proof for **Acme Job-Application** Proof alice['apply_job_proof'] = \ await anoncreds.prover_create_proof(alice['wallet'], alice['job_application_proof_request'], alice['job_application_requested_creds'], alice['master_secret_id'], alice['schemas'], alice['cred_defs'], alice['revoc_states']) + + acme['apply_job_proof'] = alice['apply_job_proof'] ``` When **Acme** inspects the received Proof he will see following structure: @@ -710,6 +599,8 @@ Here, we’ll assume the application is accepted and Alice ends up getting the j ```python # Acme Agent acme['job_certificate_cred_offer'] = await anoncreds.issuer_create_credential_offer(acme['wallet'], acme['job_certificate_cred_def_id']) + + alice['job_certificate_cred_offer'] = acme['job_certificate_cred_offer'] ``` When Alice inspects her connection with Acme, she sees that a new Credential Offer is available. @@ -723,9 +614,11 @@ Alice goes through a familiar sequence of interactions. 1. First she creates a Credential Request. ```python # Alice Agent - (alice['job_certificate_cred_request'], alice['job_certificate_cred_request_metadata']) = \ + (alice['job_certificate_cred_request'], alice['job_certificate_cred_request_metadata']) = \ await anoncreds.prover_create_credential_req(alice['wallet'], alice['did_for_acme'], alice['job_certificate_cred_offer'], alice['acme_job_certificate_cred_def'], alice['master_secret_id']) + + acme['job_certificate_cred_request'] = alice['job_certificate_cred_request'] ``` 2. Acme issues a **Job-Certificate** Credential for Alice. @@ -752,6 +645,8 @@ One difference with the ussuance of the Transcript by Faber here is that a **Job acme['job_certificate_cred_values'], acme['revoc_reg_id'], acme['blob_storage_reader_cfg_handle']) + + alice['job_certificate_cred'] = acme['job_certificate_cred'] ``` Furthermore **Acme** must publish a revocation registry entry on the Ledger so other parties can verify later the revocation state of the credential. @@ -818,6 +713,8 @@ Alice gets a **Loan-Application-Basic** Proof Request from Thrift Bank that look }, 'non_revoked': {'to': int(time.time())} }) + + alice['apply_loan_proof_request'] = thrift['apply_loan_proof_request'] ``` The last line indicates that the *Job-Certificate* provided should not be revoked by the application time. @@ -866,6 +763,8 @@ Alice creates the Proof for the **Loan-Application-Basic** Proof Request. alice['apply_loan_requested_creds'], alice['master_secret_id'], alice['schemas_for_loan_app'], alice['cred_defs_for_loan_app'], alice['revoc_states_for_loan_app']) + + thrift['apply_loan_proof'] = alice['apply_loan_proof'] ``` Alice sends just the **Loan-Application-Basic** proof to the bank. @@ -921,6 +820,8 @@ Thrift Bank sends the second Proof Request where Alice needs to share her person }, 'requested_predicates': {} }) + + alice['apply_loan_kyc_proof_request'] = thrift['apply_loan_kyc_proof_request'] ``` Alice has two credentials that meets the proof requirements for this **Loan-Application-KYC** Proof Request. @@ -978,6 +879,8 @@ Alice creates the Proof for **Loan-Application-KYC** Proof Request. alice['apply_loan_kyc_proof'] = \ await anoncreds.prover_create_proof(alice['wallet'], alice['apply_loan_kyc_proof_request'], alice['apply_loan_kyc_requested_creds'], alice['alice_master_secret_id'], alice['schemas'], alice['cred_defs'], alice['revoc_states']) + + thrift['apply_loan_kyc_proof'] = alice['apply_loan_kyc_proof'] ``` When **Thrift** inspects the received Proof he will see following structure: diff --git a/docs/migration-guides/migration-guide-1.13.0-1.14.0.md b/docs/migration-guides/migration-guide-1.13.0-1.14.0.md index 600b789786..b7e61465c9 100644 --- a/docs/migration-guides/migration-guide-1.13.0-1.14.0.md +++ b/docs/migration-guides/migration-guide-1.13.0-1.14.0.md @@ -22,7 +22,9 @@ version you can check migration guides history: * [Notes](#notes) * [Libindy 1.13 to 1.14 migration](#libindy-113-to-114-migration) * [Ledger API](#ledger-api) - +* [Libindy 1.13.0 to 1.13.1 migration](#libindy-1130-to-1131-migration-guide) +* [Libindy 1.13.1 to 1.13.2 migration](#libindy-1131-to-1132-migration-guide) + ## Libindy 1.13 to 1.14 migration #### Ledger API @@ -45,4 +47,75 @@ There are two changes related to Libindy Ledger API: * added a new function `indy_build_disable_all_txn_author_agreements_request` to build DISABLE_ALL_TXN_AUTHR_AGRMTS request. Request to disable all Transaction Author Agreement on the ledger. -More details regarding updated transaction author agreement workflow you can find in this [file](../how-tos/transaction-author-agreement.md). \ No newline at end of file +More details regarding updated transaction author agreement workflow you can find in this [file](../how-tos/transaction-author-agreement.md). + +## Libindy 1.14.0 to 1.14.1 migration Guide + +The Libindy 1.14.1 release contains fixes that don't affect API functions. + +## Libindy 1.14.1 to 1.14.2 migration Guide + +The Libindy 1.14.1 release contains fixes that don't affect API functions. + +##### Changes +* Updated behavior of `indy_store_their_did` function to allow updating of existing `theirDID` record. +It can be used to rotate a pairwise key (IS-1166). + + This example works now but threw `WalletItemAlreadyExists` error in previous versions: + ``` + let identity_json = json!({"did": DID, "verkey": VERKEY}).to_string(); + did::store_their_did(setup.wallet_handle, &identity_json).unwrap(); + + let identity_json = json!({"did": DID, "verkey": VERKEY_TRUSTEE}).to_string(); + did::store_their_did(setup.wallet_handle, &identity_json).unwrap(); + + let verkey = did::key_for_local_did(setup.wallet_handle, DID).unwrap(); + assert_eq!(VERKEY_TRUSTEE, verkey); + ``` + + +* Enhanced validation of `schema_json`: added check that `id` is consistent with `name` and `version` values (IS-1430). + ``` + valid: + { + "id":"schema:sov:did:sov:NcYxiDXkpYi6ov5FcYDi1e:2:gvt:1.0", + "name":"gvt", + "version":"1.0", + "attrNames":["aaa","bbb","ccc"], + "ver":"1.0" + } + invalid: + { + "id":"schema:sov:did:sov:NcYxiDXkpYi6ov5FcYDi1e:2:gvt:1.0", + "name":"other_name", + "version":"1111.0", + "attrNames":["aaa","bbb","ccc"], + "ver":"1.0" + } + ``` + + +* Added support of the additional format of `rev_states_json` which is used for proof creation. +Both `rev_reg_def_id` and `credential_id` can be used as map keys. + ``` + 1) + { + rev_reg_id: { + timestamp: rev_reg_state, + .. + }, + ... + } + 2) + { + credential_id: { + timestamp: rev_reg_state, + ... + }, + ... + } + ``` + +`credential_id` must be used in case of proving that two credentials matching the same `rev_reg_id` are not revoked at the same timestamp (IS-1447). + +* others minor bugfixes \ No newline at end of file diff --git a/experimental/plugins/postgres_storage/src/lib.rs b/experimental/plugins/postgres_storage/src/lib.rs index 8cd71b2f18..bf7589124b 100644 --- a/experimental/plugins/postgres_storage/src/lib.rs +++ b/experimental/plugins/postgres_storage/src/lib.rs @@ -276,7 +276,10 @@ impl PostgresWallet { Err(err) => { match err { WalletStorageError::ItemAlreadyExists => ErrorCode::WalletItemAlreadyExists, - _ => ErrorCode::WalletStorageError + _ => { + error!("Error adding a record. Error details: {:?}", err); + ErrorCode::WalletStorageError + } } } } @@ -311,7 +314,10 @@ impl PostgresWallet { Err(err) => { match err { WalletStorageError::ItemNotFound => ErrorCode::WalletItemNotFound, - _ => ErrorCode::WalletStorageError + _ => { + error!("Error updating a record. Error details: {:?}", err); + ErrorCode::WalletStorageError + } } } } @@ -353,7 +359,10 @@ impl PostgresWallet { Err(err) => { match err { WalletStorageError::ItemNotFound => ErrorCode::WalletItemNotFound, - _ => ErrorCode::WalletStorageError + _ => { + error!("Error getting a record. Error details: {:?}", err); + ErrorCode::WalletStorageError + } } } } @@ -500,7 +509,10 @@ impl PostgresWallet { Err(err) => { match err { WalletStorageError::ItemAlreadyExists => ErrorCode::WalletItemAlreadyExists, - _ => ErrorCode::WalletStorageError + _ => { + error!("Error adding record tags. Error details: {:?}", err); + ErrorCode::WalletStorageError + } } } } @@ -534,7 +546,10 @@ impl PostgresWallet { Err(err) => { match err { WalletStorageError::ItemAlreadyExists => ErrorCode::WalletItemAlreadyExists, - _ => ErrorCode::WalletStorageError + _ => { + error!("Error updating record tags. Error details: {:?}", err); + ErrorCode::WalletStorageError + } } } } @@ -569,7 +584,10 @@ impl PostgresWallet { Err(err) => { match err { WalletStorageError::ItemAlreadyExists => ErrorCode::WalletItemAlreadyExists, - _ => ErrorCode::WalletStorageError + _ => { + error!("Error deleting record tags. Error details: {:?}", err); + ErrorCode::WalletStorageError + } } } } @@ -599,7 +617,10 @@ impl PostgresWallet { Err(err) => { match err { WalletStorageError::ItemNotFound => ErrorCode::WalletItemNotFound, - _ => ErrorCode::WalletStorageError + _ => { + error!("Error deleting record. Error details: {:?}", err); + ErrorCode::WalletStorageError + } } } } @@ -634,7 +655,8 @@ impl PostgresWallet { ErrorCode::Success }, - Err(_err) => { + Err(err) => { + error!("Error getting storage metadata. Error details: {:?}", err); ErrorCode::CommonInvalidState } } @@ -661,7 +683,10 @@ impl PostgresWallet { Err(err) => { match err { WalletStorageError::ItemAlreadyExists => ErrorCode::WalletItemAlreadyExists, - _ => ErrorCode::WalletStorageError + _ => { + error!("Error setting storage metadata. Error details: {:?}", err); + ErrorCode::WalletStorageError + } } } } @@ -703,7 +728,7 @@ impl PostgresWallet { let storage = &*wallet_box; let res = storage.search(&type_.as_bytes(), &query, Some(&options_json)); - + match res { Ok(iter) => { // iter: Box @@ -755,7 +780,7 @@ impl PostgresWallet { let storage = &*wallet_box; let res = storage.get_all(); - + match res { Ok(iter) => { // iter: Box @@ -1023,10 +1048,11 @@ fn _tag_names_from_json(json: &str) -> Result, WalletStorageError> #[cfg(test)] mod tests { use super::*; - use std::env; + use std::{env, thread}; use std::ffi::{CString, CStr}; use std::{slice, ptr}; use wql::storage::ENCRYPTED_KEY_LEN; + use rand::{thread_rng, Rng}; #[test] fn postgres_wallet_crud_works() { @@ -1035,35 +1061,35 @@ mod tests { let id = _wallet_id(); let config = _wallet_config(); let credentials = _wallet_credentials(); - let metadata = _metadata(); + let metadata = _metadata_cstring(); // open wallet - should return error let mut handle: i32 = -1; - let err = PostgresWallet::open(id.as_ptr(), - config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), - credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + let err = PostgresWallet::open(id.as_ptr(), + config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr()), &mut handle); assert_eq!(err, ErrorCode::WalletNotFoundError); - + // create wallet - let err = PostgresWallet::create(id.as_ptr(), - config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), - credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + let err = PostgresWallet::create(id.as_ptr(), + config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr()), metadata.as_ptr()); assert_eq!(err, ErrorCode::Success); // open wallet - let err = PostgresWallet::open(id.as_ptr(), - config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), - credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + let err = PostgresWallet::open(id.as_ptr(), + config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr()), &mut handle); assert_eq!(err, ErrorCode::Success); // ensure we can fetch metadata let mut metadata_handle: i32 = -1; let mut metadata_ptr: *const c_char = ptr::null_mut(); - let err = PostgresWallet::get_storage_metadata(handle, - &mut metadata_ptr, + let err = PostgresWallet::get_storage_metadata(handle, + &mut metadata_ptr, &mut metadata_handle); assert_eq!(err, ErrorCode::Success); let _metadata = unsafe { CStr::from_ptr(metadata_ptr).to_bytes() }; @@ -1080,8 +1106,8 @@ mod tests { let mut metadata_handle2: i32 = -1; let mut metadata_ptr2: *const c_char = ptr::null_mut(); - let err = PostgresWallet::get_storage_metadata(handle, - &mut metadata_ptr2, + let err = PostgresWallet::get_storage_metadata(handle, + &mut metadata_ptr2, &mut metadata_handle2); assert_eq!(err, ErrorCode::Success); let _metadata2 = unsafe { CStr::from_ptr(metadata_ptr2).to_bytes() }; @@ -1096,15 +1122,15 @@ mod tests { assert_eq!(err, ErrorCode::Success); // delete wallet - let err = PostgresWallet::delete(id.as_ptr(), - config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + let err = PostgresWallet::delete(id.as_ptr(), + config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr())); assert_eq!(err, ErrorCode::Success); // open wallet - should return error - let err = PostgresWallet::open(id.as_ptr(), - config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), - credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + let err = PostgresWallet::open(id.as_ptr(), + config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr()), &mut handle); assert_eq!(err, ErrorCode::WalletNotFoundError); } @@ -1198,7 +1224,7 @@ mod tests { let err = PostgresWallet::get_record(handle, type1_.as_ptr(), id1.as_ptr(), - get_options.as_ptr() as *const i8, + get_options.as_ptr(), &mut rec_handle); assert_match!(ErrorCode::Success, err); @@ -1296,7 +1322,7 @@ mod tests { let err = PostgresWallet::get_record(handle, type1_.as_ptr(), id1.as_ptr(), - get_options.as_ptr() as *const i8, + get_options.as_ptr(), &mut rec_handle); assert_match!(ErrorCode::Success, err); @@ -1373,7 +1399,7 @@ mod tests { let err = PostgresWallet::get_record(handle, type1_.as_ptr(), id1.as_ptr(), - get_options.as_ptr() as *const i8, + get_options.as_ptr(), &mut rec_handle); assert_match!(ErrorCode::Success, err); @@ -1392,7 +1418,7 @@ mod tests { let err = PostgresWallet::get_record(handle, type1_.as_ptr(), id1.as_ptr(), - get_options.as_ptr() as *const i8, + get_options.as_ptr(), &mut rec_handle); assert_match!(ErrorCode::WalletItemNotFound, err); @@ -1428,7 +1454,7 @@ mod tests { let err = PostgresWallet::get_record(handle, type1_.as_ptr(), id1.as_ptr(), - get_options.as_ptr() as *const i8, + get_options.as_ptr(), &mut rec_handle); assert_match!(ErrorCode::Success, err); @@ -1450,7 +1476,7 @@ mod tests { let err = PostgresWallet::get_record(handle, type1_.as_ptr(), id1.as_ptr(), - get_options.as_ptr() as *const i8, + get_options.as_ptr(), &mut rec_handle); assert_match!(ErrorCode::Success, err); @@ -1516,7 +1542,7 @@ mod tests { let mut search_handle: i32 = -1; let err = PostgresWallet::search_all_records(handle, &mut search_handle); assert_match!(ErrorCode::Success, err); - + let mut rec_count: i32 = 0; let mut search_continue: bool = true; while search_continue { @@ -1611,13 +1637,13 @@ mod tests { println!("query_json {:?}", query_json); let options_json = _search_options(true, true, true, true, true); println!("Options {:?}", options_json); - let err = PostgresWallet::search_records(handle, - type1_.as_ptr(), - query_json.as_ptr(), - options_json.as_ptr() as *const i8, + let err = PostgresWallet::search_records(handle, + type1_.as_ptr(), + query_json.as_ptr(), + options_json.as_ptr() as *const i8, &mut search_handle); assert_match!(ErrorCode::Success, err); - + let mut rec_count: i32 = 0; let mut search_continue: bool = true; while search_continue { @@ -1667,20 +1693,20 @@ mod tests { let id = _wallet_id(); let config = _wallet_config(); let credentials = _wallet_credentials(); - let metadata = _metadata(); + let metadata = _metadata_cstring(); // create wallet - let err = PostgresWallet::create(id.as_ptr(), - config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), - credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + let err = PostgresWallet::create(id.as_ptr(), + config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr()), metadata.as_ptr()); assert_eq!(err, ErrorCode::Success); // open wallet let mut handle: i32 = -1; - let err = PostgresWallet::open(id.as_ptr(), - config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), - credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + let err = PostgresWallet::open(id.as_ptr(), + config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr()), &mut handle); assert_eq!(err, ErrorCode::Success); @@ -1697,30 +1723,39 @@ mod tests { assert_eq!(err, ErrorCode::Success); // delete wallet - let err = PostgresWallet::delete(id.as_ptr(), - config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + let err = PostgresWallet::delete(id.as_ptr(), + config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr())); assert_eq!(err, ErrorCode::Success); } fn _cleanup() { + let ten_millis = std::time::Duration::from_millis(1); + let now = time::now(); + thread::sleep(ten_millis); + let id = _wallet_id(); let config = _wallet_config(); let credentials = _wallet_credentials(); - let err = PostgresWallet::init(config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + let err = PostgresWallet::init(config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr())); assert_eq!(err, ErrorCode::Success); - let _err = PostgresWallet::delete(id.as_ptr(), - config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + let _err = PostgresWallet::delete(id.as_ptr(), + config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr())); } + fn _random_string(len: usize) -> String { + thread_rng().gen_ascii_chars().take(len).collect() + } + fn _wallet_id() -> CString { - CString::new("my_walle1").unwrap() + CString::new("walle1").unwrap() } + fn _wallet_config() -> Option { let wallet_scheme = env::var("WALLET_SCHEME"); match wallet_scheme { @@ -1758,7 +1793,7 @@ mod tests { .map_or(Ok(None), |r| r.map(Some)).unwrap() } - fn _metadata() -> Vec { + fn _metadata() -> Vec { return vec![ 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, @@ -1771,6 +1806,11 @@ mod tests { ]; } + fn _metadata_cstring() -> CString { + let foo = _metadata(); + CString::new(foo).unwrap() + } + fn _metadata2() -> Vec { return vec![ 2, 3, 4, 5, 6, 7, 8, 9, @@ -1881,12 +1921,13 @@ mod tests { v } - fn _fetch_options(type_: bool, value: bool, tags: bool) -> String { - json!({ + fn _fetch_options(type_: bool, value: bool, tags: bool) -> CString { + let get_options_string = json!({ "retrieveType": type_, "retrieveValue": value, "retrieveTags": tags, - }).to_string() + }).to_string(); + CString::new(get_options_string).unwrap() } fn _search_options(retrieve_records: bool, retrieve_total_count: bool, retrieve_value: bool, retrieve_tags: bool, retrieve_type: bool) -> String { diff --git a/experimental/plugins/postgres_storage/src/postgres_storage.rs b/experimental/plugins/postgres_storage/src/postgres_storage.rs index 9f1d82d27b..d6044c5545 100644 --- a/experimental/plugins/postgres_storage/src/postgres_storage.rs +++ b/experimental/plugins/postgres_storage/src/postgres_storage.rs @@ -956,7 +956,6 @@ impl WalletStorage for PostgresStorage { } Some(tags) } else { None }; - Ok(StorageRecord::new(id.to_vec(), value, type_.map(|val| val.to_vec()), tags)) } diff --git a/libindy/Cargo.lock b/libindy/Cargo.lock index 6436ccab3c..16a29541f6 100644 --- a/libindy/Cargo.lock +++ b/libindy/Cargo.lock @@ -1,11 +1,60 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +[[package]] +name = "aead" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "aes" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aes-soft 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "aesni 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "aes-gcm" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aead 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "aes 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ghash 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "aes-soft" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "aesni" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "aho-corasick" version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -13,6 +62,22 @@ name = "amcl" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "amcl_wrapper" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "miracl_amcl 3.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", + "sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "android_log-sys" version = "0.1.2" @@ -35,24 +100,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "arrayvec" -version = "0.4.11" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "atty" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "hermit-abi 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "autocfg" -version = "0.1.6" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "autocfg" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -60,20 +128,20 @@ name = "backtrace" version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace-sys 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "backtrace-sys" -version = "0.1.30" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -86,7 +154,7 @@ dependencies = [ [[package]] name = "bitflags" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -102,12 +170,12 @@ dependencies = [ [[package]] name = "blake2b_simd" -version = "0.5.8" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", - "constant_time_eq 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "constant_time_eq 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -115,15 +183,32 @@ name = "block-buffer" version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "block-padding 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "block-cipher-trait" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "block-modes" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "block-padding" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -131,18 +216,18 @@ dependencies = [ [[package]] name = "bstr" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex-automata 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "bumpalo" -version = "2.6.0" +version = "3.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -157,21 +242,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "c2-chacha" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cast" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "cc" -version = "1.0.26" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -179,14 +266,35 @@ name = "cfg-if" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "chacha20" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "salsa20-core 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "stream-cipher 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "chacha20poly1305" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aead 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "chacha20 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "poly1305 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "clap" version = "2.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -194,7 +302,7 @@ name = "clear_on_drop" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -202,12 +310,12 @@ name = "cloudabi" version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "constant_time_eq" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -215,25 +323,25 @@ name = "criterion" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", + "cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "criterion-plot 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "csv 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "csv 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xoshiro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon-core 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "tinytemplate 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon-core 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", + "tinytemplate 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -242,38 +350,39 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossbeam-deque" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-epoch 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossbeam-epoch" -version = "0.7.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memoffset 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossbeam-queue" -version = "0.1.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -285,6 +394,16 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "crossbeam-utils" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "crypto-mac" version = "0.7.0" @@ -296,14 +415,14 @@ dependencies = [ [[package]] name = "csv" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bstr 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "bstr 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "csv-core 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -311,7 +430,7 @@ name = "csv-core" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -323,39 +442,39 @@ dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "darling" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "darling_core 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "darling_macro 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "darling_core 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", + "darling_macro 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "darling_core" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "ident_case 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "strsim 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "strsim 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "darling_macro" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "darling_core 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "darling_core 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -391,21 +510,22 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "redox_users 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "ed25519-dalek" -version = "1.0.0-pre.1" +version = "1.0.0-pre.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -420,26 +540,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "env_logger" -version = "0.5.13" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "env_logger" -version = "0.6.2" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -454,33 +574,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "etcommon-rlp" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "elastic-array-plus 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "etcommon-hexutil 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "failure" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "failure_derive" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -534,13 +654,37 @@ dependencies = [ "typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "generic-array" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "getrandom" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "ghash" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "polyval 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "hermit-abi" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -548,12 +692,26 @@ name = "hex" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "hex" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "hmac" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crypto-mac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "humantime" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -563,47 +721,49 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "indy" -version = "1.14.1" +version = "1.14.2" dependencies = [ - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "indy-sys 1.14.1", + "indy-sys 1.14.2", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "num-derive 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "indy-api-types" version = "0.1.0" dependencies = [ - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "ed25519-dalek 1.0.0-pre.2 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl 0.10.24 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl 0.10.26 (registry+https://github.com/rust-lang/crates.io-index)", "rusqlite 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "rust-base58 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "ursa 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", + "ursa 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "zmq 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "indy-sys" -version = "1.14.1" +version = "1.14.2" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "vcpkg 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -612,40 +772,37 @@ version = "0.1.0" dependencies = [ "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "indy-api-types 0.1.0", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl 0.10.24 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl 0.10.26 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "sodiumoxide 0.0.16 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "ursa 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "indy-wallet" version = "0.1.0" dependencies = [ - "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "indy-api-types 0.1.0", "indy-utils 0.1.0", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "named_type 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rmp-serde 0.13.7 (registry+https://github.com/rust-lang/crates.io-index)", "rusqlite 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "rust-base58 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "sodiumoxide 0.0.16 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -655,7 +812,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "itertools" -version = "0.8.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -671,11 +828,6 @@ name = "keccak" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "lazy_static" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "lazy_static" version = "1.4.0" @@ -683,54 +835,51 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.60" +version = "0.2.66" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libindy" -version = "1.14.1" +version = "1.14.2" dependencies = [ "android_logger 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", - "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "derivative 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ed25519-dalek 1.0.0-pre.2 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "etcommon-rlp 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "etcommon-rlp 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "indy 1.14.1", + "indy 1.14.2", "indy-api-types 0.1.0", - "indy-sys 1.14.1", + "indy-sys 1.14.2", "indy-utils 0.1.0", "indy-wallet 0.1.0", - "int_traits 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "log-derive 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log-derive 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "log-panics 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "named_type 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "named_type_derive 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl 0.10.24 (registry+https://github.com/rust-lang/crates.io-index)", - "owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl 0.10.26 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "rmp-serde 0.13.7 (registry+https://github.com/rust-lang/crates.io-index)", - "rusqlite 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "rust-base58 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "sodiumoxide 0.0.16 (registry+https://github.com/rust-lang/crates.io-index)", "threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "ursa 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ursa 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", "zeroize 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", "zmq 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -741,8 +890,8 @@ name = "libsodium-sys" version = "0.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -750,9 +899,9 @@ name = "libsqlite3-sys" version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", - "vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", + "vcpkg 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -770,14 +919,14 @@ dependencies = [ [[package]] name = "log-derive" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "darling 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "darling 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -798,15 +947,15 @@ dependencies = [ [[package]] name = "memchr" -version = "2.2.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "memoffset" -version = "0.5.1" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -818,10 +967,15 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "miracl_amcl" +version = "3.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "named_type" version = "0.1.6" @@ -842,41 +996,36 @@ dependencies = [ "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "nodrop" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "num" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num-bigint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "num-complex 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", - "num-iter 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", - "num-rational 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "num-bigint 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "num-complex 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "num-integer 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "num-iter 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "num-rational 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num-bigint" -version = "0.2.3" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num-integer 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num-complex" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -891,48 +1040,49 @@ dependencies = [ [[package]] name = "num-integer" -version = "0.1.41" +version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num-iter" -version = "0.1.39" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num-integer 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num-rational" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "num-bigint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num-bigint 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "num-integer 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num-traits" -version = "0.2.8" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num_cpus" -version = "1.10.1" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "hermit-abi 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -942,27 +1092,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "openssl" -version = "0.10.24" +version = "0.10.26" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.49 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.53 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "openssl-sys" -version = "0.9.49" +version = "0.9.53" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", - "vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", + "vcpkg 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -975,12 +1125,29 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "poly1305" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "universal-hash 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "polyval" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "universal-hash 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "ppv-lite86" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -993,7 +1160,7 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.4" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1001,7 +1168,7 @@ dependencies = [ [[package]] name = "quick-error" -version = "1.2.2" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1022,19 +1189,7 @@ name = "quote" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1042,8 +1197,8 @@ name = "rand" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1057,11 +1212,11 @@ dependencies = [ [[package]] name = "rand" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1072,7 +1227,7 @@ name = "rand_chacha" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1081,7 +1236,7 @@ name = "rand_chacha" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1135,7 +1290,7 @@ name = "rand_jitter" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1147,10 +1302,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1159,7 +1314,7 @@ name = "rand_pcg" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1182,24 +1337,24 @@ dependencies = [ [[package]] name = "rayon" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon-core 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon-core 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rayon-core" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-queue 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1220,7 +1375,7 @@ name = "redox_users" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "rust-argon2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1228,13 +1383,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.3.1" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1247,16 +1402,16 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.12" +version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "rmp" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1265,8 +1420,8 @@ version = "0.13.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rmp 0.8.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", + "rmp 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1274,12 +1429,12 @@ name = "rusqlite" version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "fallible-streaming-iterator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "libsqlite3-sys 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1289,7 +1444,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "blake2b_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", + "blake2b_simd 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1298,7 +1453,7 @@ name = "rust-base58" version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1316,15 +1471,24 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "salsa20-core" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "stream-cipher 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "same-file" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1334,12 +1498,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "secp256k1" -version = "0.12.2" +version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1357,32 +1521,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.101" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde_derive" -version = "1.0.101" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_json" -version = "1.0.40" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "sha2" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1408,9 +1572,9 @@ name = "sodiumoxide" version = "0.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "libsodium-sys 0.0.16 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1418,9 +1582,17 @@ name = "stable_deref_trait" version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "stream-cipher" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "strsim" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1430,7 +1602,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "subtle" -version = "2.2.1" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1455,10 +1627,10 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.5" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1482,12 +1654,23 @@ dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "synstructure" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "termcolor" -version = "1.0.5" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "wincolor 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1495,12 +1678,12 @@ name = "textwrap" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "thread_local" -version = "0.3.6" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1511,7 +1694,7 @@ name = "threadpool" version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1519,18 +1702,18 @@ name = "time" version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tinytemplate" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1545,7 +1728,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "unicode-width" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1563,32 +1746,51 @@ name = "unicode-xid" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "universal-hash" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "ursa" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "aead 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "aes 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "aes-gcm 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "amcl 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "amcl_wrapper 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "blake2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "block-modes 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "chacha20poly1305 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ed25519-dalek 1.0.0-pre.2 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "generic-array 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)", + "hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hmac 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "int_traits 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl 0.10.24 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl 0.10.26 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "secp256k1 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "secp256k1 0.15.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1601,66 +1803,66 @@ dependencies = [ [[package]] name = "vcpkg" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "walkdir" -version = "2.2.9" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen" -version = "0.2.51" +version = "0.2.58" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.51" +version = "0.2.58" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bumpalo 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bumpalo 3.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.51" +version = "0.2.58" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro-support 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro-support 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.51" +version = "0.2.58" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-backend 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.51" +version = "0.2.58" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1679,7 +1881,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "winapi-util" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1691,25 +1893,19 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "wincolor" -version = "1.0.2" +name = "zeroize" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize_derive 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "zeroize" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "zeroize" -version = "0.9.3" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "zeroize_derive 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize_derive 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1723,13 +1919,24 @@ dependencies = [ "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "zeroize_derive" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "zmq" version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "zmq-sys 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1739,66 +1946,78 @@ name = "zmq-sys" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "metadeps 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [metadata] +"checksum aead 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "529ae27769da55d955d190396e67896f49b440aff94a5b2f50900e091d168b77" +"checksum aes 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "54eb1d8fe354e5fc611daf4f2ea97dd45a765f4f1e4512306ec183ae2e8f20c9" +"checksum aes-gcm 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3c6e030ead0fe69f0346091ed4b5b01c9610d42bf6d2a283036132485094793c" +"checksum aes-soft 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" +"checksum aesni 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" "checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" "checksum amcl 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee5cca1ddc8b9dceb55b7f1272a9d1e643d73006f350a20ab4926d24e33f0f0d" +"checksum amcl_wrapper 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1197ef8bc569ac81c685ec1a655cc412eeca3b69b0784f3202cfc31f9089fcfe" "checksum android_log-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b8052e2d8aabbb8d556d6abbcce2a22b9590996c5f849b9c7ce4544a2e3b984e" "checksum android_logger 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86983875e7c3a202e31471cc6d60fcc18f30e194f1729cfff3bfb43d646ffced" "checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" -"checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" -"checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" -"checksum autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b671c8fb71b457dd4ae18c4ba1e59aa81793daacc361d82fcd410cef0d491875" +"checksum arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" +"checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +"checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" +"checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" "checksum backtrace 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "18b65ea1161bfb2dd6da6fade5edd4dbd08fba85012123dd333d2fd1b90b2782" -"checksum backtrace-sys 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)" = "5b3a000b9c543553af61bc01cbfc403b04b5caa9e421033866f2e98061eb3e61" +"checksum backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491" "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" -"checksum bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8a606a02debe2813760609f57a64a2ffd27d9fdf5b2f133eaca0b248dd92cdd2" +"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum blake2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "94cb07b0da6a73955f8fb85d24c466778e70cda767a568229b104f0264089330" -"checksum blake2b_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)" = "5850aeee1552f495dd0250014cf64b82b7c8879a89d83b33bbdace2cc4f63182" +"checksum blake2b_simd 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d8fb2d74254a3a0b5cac33ac9f8ed0e44aa50378d9dbb2e5d83bd21ed1dc2c8a" "checksum block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" -"checksum block-padding 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6d4dc3af3ee2e12f3e5d224e5e1e3d73668abbeb69e566d361f7d5563a4fdf09" -"checksum bstr 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8d6c2c5b58ab920a4f5aeaaca34b4488074e8cc7596af94e6f8c6ff247c60245" -"checksum bumpalo 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad807f2fc2bf185eeb98ff3a901bd46dc5ad58163d0fa4577ba0d25674d71708" +"checksum block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" +"checksum block-modes 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "31aa8410095e39fdb732909fb5730a48d5bd7c2e3cd76bd1b07b3dbea130c529" +"checksum block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +"checksum bstr 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3ede750122d9d1f87919570cb2cccee38c84fbc8c5599b25c289af40625b7030" +"checksum bumpalo 3.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5fb8038c1ddc0a5f73787b130f4cc75151e96ed33e417fde765eb5a81e3532f4" "checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" -"checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" -"checksum cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "926013f2860c46252efceabb19f4a6b308197505082c609025aa6706c011d427" -"checksum cc 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)" = "389803e36973d242e7fecb092b2de44a3d35ac62524b3b9339e51d577d668e02" +"checksum c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb" +"checksum cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0" +"checksum cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "8dae9c4b8fedcae85592ba623c4fd08cfdab3e3b72d6df780c6ead964a69bfff" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +"checksum chacha20 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "600b18f1de4dbea5ffa2902f259038364e48420d0d6e6a60ed5a3e075c7d4efb" +"checksum chacha20poly1305 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c5934c9a6ea3dc783dd2d38ae9d6e535856d80078af077b8bc4dbca0ff7f17a" "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" "checksum clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "97276801e127ffb46b66ce23f35cc96bd454fa311294bced4bbace7baa8b1d17" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -"checksum constant_time_eq 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "995a44c877f9212528ccc74b21a232f66ad69001e40ede5bcee2ac9ef2657120" +"checksum constant_time_eq 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" "checksum criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "0363053954f3e679645fc443321ca128b7b950a6fe288cf5f9335cc22ee58394" "checksum criterion-plot 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "76f9212ddf2f4a9eb2d401635190600656a1f88a932ef53d06e7fa4c7e02fb8e" -"checksum crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b18cd2e169ad86297e6bc0ad9aa679aee9daa4f19e8163860faf7c164e4f5a71" -"checksum crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9" -"checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" +"checksum crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3aa945d63861bfe624b55d153a39684da1e8c0bc8fba932f7ee3a3c16cea3ca" +"checksum crossbeam-epoch 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5064ebdbf05ce3cb95e45c8b086f72263f4166b29b97f6baff7ef7fe047b55ac" +"checksum crossbeam-queue 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c695eeca1e7173472a32221542ae469b3e9aac3a4fc81f7696bcad82029493db" "checksum crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" +"checksum crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce446db02cdc3165b94ae73111e570793400d0794e46125cc4056c81cbb039f4" "checksum crypto-mac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" -"checksum csv 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "37519ccdfd73a75821cac9319d4fce15a81b9fcf75f951df5b9988aa3a0af87d" +"checksum csv 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "11f8cbd084b9a431d52dfac0b8428a26b68f1061138a7bea18aa56b9cdf55266" "checksum csv-core 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9b5cadb6b25c77aeff80ba701712494213f4a8418fcda2ee11b6560c3ad0bf4c" "checksum curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8b7dcd30ba50cdf88b55b033456138b7c0ac4afdc436d82e1b79f370f24cc66d" -"checksum darling 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe629a532efad5526454efb0700f86d5ad7ff001acb37e431c8bf017a432a8e" -"checksum darling_core 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ee54512bec54b41cf2337a22ddfadb53c7d4c738494dc2a186d7b037ad683b85" -"checksum darling_macro 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0cd3e432e52c0810b72898296a69d66b1d78d1517dff6cde7a130557a55a62c1" +"checksum darling 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0d706e75d87e35569db781a9b5e2416cff1236a47ed380831f959382ccd5f858" +"checksum darling_core 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b" +"checksum darling_macro 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" "checksum derivative 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "942ca430eef7a3806595a6737bc388bf51adb888d3fc0dd1b50f1c170167ee3a" "checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" "checksum dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3" "checksum dirs-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "afa0b23de8fd801745c471deffa6e12d248f962c9fd4b4c33787b055599bde7b" -"checksum ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)" = "81956bcf7ef761fb4e1d88de3fa181358a0d26cbcb9755b587a08f9119824b86" +"checksum ed25519-dalek 1.0.0-pre.2 (registry+https://github.com/rust-lang/crates.io-index)" = "845aaacc16f01178f33349e7c992ecd0cee095aa5e577f0f4dee35971bd36455" "checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" "checksum elastic-array-plus 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "562cc8504a01eb20c10fb154abd7c4baeb9beba2329cf85838ee2bd48a468b18" -"checksum env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)" = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38" "checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" +"checksum env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" "checksum error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9435d864e017c3c6afeac1654189b06cdb491cf2ff73dbf0d73b0f292f42ff8" "checksum etcommon-hexutil 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "20b4d1933bf88b806ba2d9189880b1b4ef205e42df9573b65716f2a50818024c" -"checksum etcommon-rlp 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "804a932fed78022b8ec25c06576c57f683a6646dfae22f93dcc5d23470aafe85" -"checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" -"checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" +"checksum etcommon-rlp 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8c978ef454cd97da44a3a15d55cc312313be04b9692e39fa4cd3c00401f39bcb" +"checksum failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" +"checksum failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" "checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" "checksum fallible-streaming-iterator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" @@ -1808,55 +2027,60 @@ dependencies = [ "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" "checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" +"checksum generic-array 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0ed1e761351b56f54eb9dcd0cfaca9fd0daecf93918e1cfc01c8a3d26ee7adcd" "checksum getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "34f33de6f0ae7c9cb5e574502a562e2b512799e32abb801cd1e79ad952b62b49" +"checksum ghash 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9f0930ed19a7184089ea46d2fedead2f6dc2b674c5db4276b7da336c7cd83252" +"checksum hermit-abi 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eff2656d88f158ce120947499e971d743c05dbcbed62e5bd2f38f1698bbc3772" "checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" +"checksum hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "023b39be39e3a2da62a94feb433e91e8bcd37676fbc8bea371daf52b7a769a3e" +"checksum hmac 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" "checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" "checksum ident_case 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" "checksum int_traits 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b33c9a5c599d67d051c4dc25eb1b6b4ef715d1763c20c85c688717a1734f204e" -"checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358" +"checksum itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum keccak 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" -"checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -"checksum libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "d44e80633f007889c7eff624b709ab43c92d708caad982295768a7b13ca3b5eb" +"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" "checksum libsodium-sys 0.0.16 (registry+https://github.com/rust-lang/crates.io-index)" = "fcbd1beeed8d44caa8a669ebaa697c313976e242c03cc9fb23d88bf1656f5542" "checksum libsqlite3-sys 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5e5b95e89c330291768dc840238db7f9e204fd208511ab6319b56193a7f2ae25" "checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" -"checksum log-derive 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "af5ac4192220bd122fe6589742bf3873f7207ef5f39d82d036b424448f3434c7" +"checksum log-derive 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2c7f436d3b5b51857b145075009f3a0d88dd37d2e93f42bb227045f4562a131e" "checksum log-panics 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ae0136257df209261daa18d6c16394757c63e032e27aafd8b07788b051082bef" "checksum lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" -"checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" -"checksum memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ce6075db033bbbb7ee5a0bbd3a3186bbae616f57fb001c485c7ff77955f8177f" +"checksum memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3197e20c7edb283f87c071ddfc7a2cca8f8e0b888c242959846a6fce03c72223" +"checksum memoffset 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "75189eb85871ea5c2e2c15abbdd541185f63b408415e5051f5cac122d8c774b9" "checksum metadeps 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "73b122901b3a675fac8cecf68dcb2f0d3036193bc861d1ac0e1c337f7d5254c2" +"checksum miracl_amcl 3.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "89d10a1ea3ffe41d318ccd9f21a1f2366c8103b95e1deaa9449793f4b10cefe8" "checksum named_type 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c39ac6c5ee13bf558879a82198b0afe84989cf3f7fb7592b56d73eb1a50c9e66" "checksum named_type 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a9b45469f7e8314cd4a0791e914c5b65c02ba6451c0662eeb29ccc1714013d7" "checksum named_type_derive 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c13c91ae49fb502a04f2e993e63e06a28fc5a1ecff01eaa09448735c7ad1243b" -"checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" -"checksum num 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cf4825417e1e1406b3782a8ce92f4d53f26ec055e3622e1881ca8e9f5f9e08db" -"checksum num-bigint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f9c3f34cdd24f334cb265d9bf8bfa8a241920d026916785747a92f0e55541a1a" -"checksum num-complex 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fcb0cf31fb3ff77e6d2a6ebd6800df7fdcd106f2ad89113c9130bcd07f93dffc" +"checksum num 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b8536030f9fea7127f841b45bb6243b27255787fb4eb83958aa1ef9d2fdc0c36" +"checksum num-bigint 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f115de20ad793e857f76da2563ff4a09fbcfd6fe93cca0c5d996ab5f3ee38d" +"checksum num-complex 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95" "checksum num-derive 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "eafd0b45c5537c3ba526f79d3e75120036502bebacbb3f3220914067ce39dbf2" -"checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" -"checksum num-iter 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "76bd5272412d173d6bf9afdf98db8612bbabc9a7a830b7bfc9c188911716132e" -"checksum num-rational 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2885278d5fe2adc2f75ced642d52d879bffaceb5a2e0b1d4309ffdfb239b454" -"checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" -"checksum num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bcef43580c035376c0705c42792c294b66974abbfd2789b511784023f71f3273" +"checksum num-integer 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "3f6ea62e9d81a77cd3ee9a2a5b9b609447857f3d358704331e4ef39eb247fcba" +"checksum num-iter 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "dfb0800a0291891dd9f4fe7bd9c19384f98f7fbe0cd0f39a2c6b88b9868bbc00" +"checksum num-rational 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "da4dc79f9e6c81bef96148c8f6b8e72ad4541caa4a24373e900a36da07de03a3" +"checksum num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" +"checksum num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "76dac5ed2a876980778b8b85f75a71b6cbf0db0b1232ee12f826bccb00d09d72" "checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" -"checksum openssl 0.10.24 (registry+https://github.com/rust-lang/crates.io-index)" = "8152bb5a9b5b721538462336e3bef9a539f892715e5037fda0f984577311af15" -"checksum openssl-sys 0.9.49 (registry+https://github.com/rust-lang/crates.io-index)" = "f4fad9e54bd23bd4cbbe48fdc08a1b8091707ac869ef8508edea2fec77dcc884" +"checksum openssl 0.10.26 (registry+https://github.com/rust-lang/crates.io-index)" = "3a3cc5799d98e1088141b8e01ff760112bbd9f19d850c124500566ca6901a585" +"checksum openssl-sys 0.9.53 (registry+https://github.com/rust-lang/crates.io-index)" = "465d16ae7fc0e313318f7de5cecf57b2fbe7511fd213978b457e1c96ff46736f" "checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13" -"checksum pkg-config 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "72d5370d90f49f70bd033c3d75e87fc529fbfff9d6f7cccef07d6170079d91ea" -"checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" +"checksum pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" +"checksum poly1305 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b5829f50f48e9ddb79f3f7c3097029d0caee30f8286accb241416df603b080b8" +"checksum polyval 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7ec3341498978de3bfd12d1b22f1af1de22818f5473a11e8a6ef997989e3a212" +"checksum ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -"checksum proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "afdc77cc74ec70ed262262942ebb7dac3d479e9e5cfa2da1841c0806f6cdabcc" -"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" +"checksum proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0319972dcae462681daf4da1adeeaa066e3ebd29c69be96c6abb1259d2ee2bcc" +"checksum quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" "checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" -"checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -"checksum rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3ae1b169243eaf61759b8475a998f0a385e42042370f3a7dbaf35246eacc8412" +"checksum rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" "checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" @@ -1870,70 +2094,74 @@ dependencies = [ "checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" "checksum rand_xoshiro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "03b418169fb9c46533f326efd6eed2576699c44ca92d3052a066214a8d828929" -"checksum rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "83a27732a533a1be0a0035a111fe76db89ad312f6f0347004c220c57f209a123" -"checksum rayon-core 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "98dcf634205083b17d0861252431eb2acbfb698ab7478a2d20de07954f47ec7b" +"checksum rayon 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "db6ce3297f9c85e16621bb8cca38a06779ffc31bb8184e1be4bed2be4678a098" +"checksum rayon-core 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "08a89b46efaf957e52b18062fb2f4660f8b8a4dde1807ca002690868ef2c85a9" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" "checksum redox_users 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ecedbca3bf205f8d8f5c2b44d83cd0690e39ee84b951ed649e9f1841132b66d" -"checksum regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dc220bd33bdce8f093101afe22a037b8eb0e5af33592e6a9caafff0d4cb81cbd" +"checksum regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b5508c1941e4e7cb19965abef075d35a9a8b5cdf0846f30b4050e9b55dc55e87" "checksum regex-automata 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "92b73c2a1770c255c240eaa4ee600df1704a38dc3feaa6e949e7fcd4f8dc09f9" -"checksum regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716" -"checksum rmp 0.8.8 (registry+https://github.com/rust-lang/crates.io-index)" = "0f594cb7ff8f1c5a7907f6be91f15795c8301e0d5718eb007fb5832723dd716e" +"checksum regex-syntax 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "e734e891f5b408a29efbf8309e656876276f49ab6a6ac208600b4419bd893d90" +"checksum rmp 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)" = "0f10b46df14cf1ee1ac7baa4d2fbc2c52c0622a4b82fa8740e37bc452ac0184f" "checksum rmp-serde 0.13.7 (registry+https://github.com/rust-lang/crates.io-index)" = "011e1d58446e9fa3af7cdc1fb91295b10621d3ac4cb3a85cc86385ee9ca50cd3" "checksum rusqlite 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2a194373ef527035645a1bc21b10dc2125f73497e6e155771233eb187aedd051" "checksum rust-argon2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ca4eaef519b494d1f2848fc602d18816fed808a981aedf4f1f00ceb7c9d32cf" "checksum rust-base58 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b313b91fcdc6719ad41fa2dad2b7e810b03833fae4bf911950e15529a5f04439" "checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" -"checksum same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585e8ddcedc187886a30fa705c47985c3fa88d06624095856b36ca0b82ff4421" +"checksum ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8" +"checksum salsa20-core 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2fe6cc1b9f5a5867853ade63099de70f042f7679e408d1ffe52821c9248e6e69" +"checksum same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" "checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" -"checksum secp256k1 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfaccd3a23619349e0878d9a241f34b1982343cdf67367058cd7d078d326b63e" +"checksum secp256k1 0.15.5 (registry+https://github.com/rust-lang/crates.io-index)" = "4d311229f403d64002e9eed9964dfa5a0a0c1ac443344f7546bf48e916c6053a" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)" = "9796c9b7ba2ffe7a9ce53c2287dfc48080f4b2b362fcc245a259b3a7201119dd" -"checksum serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)" = "4b133a43a1ecd55d4086bd5b4dc6c1751c68b1bfbeba7a5040442022c7e7c02e" -"checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" -"checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d" +"checksum serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" +"checksum serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" +"checksum serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)" = "48c575e0cc52bdd09b47f330f646cf59afc586e9c4e3ccd6fc1f625b8ea1dad7" +"checksum sha2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "27044adfd2e1f077f649f59deb9490d3941d674002f7d062870a60ebe9bd47a0" "checksum sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd26bc0e7a2e3a7c959bc494caf58b72ee0c71d67704e9520f736ca7e4853ecf" "checksum sodiumoxide 0.0.16 (registry+https://github.com/rust-lang/crates.io-index)" = "eb5cb2f14f9a51352ad65e59257a0a9459d5a36a3615f3d53a974c82fdaaa00a" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" -"checksum strsim 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "032c03039aae92b350aad2e3779c352e104d919cb192ba2fabbd7b831ce4f0f6" +"checksum stream-cipher 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8131256a5896cabcf5eb04f4d6dacbe1aefda854b0d9896e09cb58829ec5638c" +"checksum strsim 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" "checksum subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" -"checksum subtle 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab3af2eb31c42e8f0ccf43548232556c42737e01a96db6e1777b0be108e79799" +"checksum subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941" "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" "checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" -"checksum syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf" +"checksum syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1e4ff033220a41d1a57d8125eab57bf5263783dfdcc18688b1dacc6ce9651ef8" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" -"checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" +"checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" +"checksum termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" +"checksum thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" "checksum threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" -"checksum tinytemplate 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4574b75faccaacddb9b284faecdf0b544b80b6b294f3d062d325c5726a209c20" +"checksum tinytemplate 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "57a3c6667d3e65eb1bc3aed6fd14011c6cbc3a0665218ab7f5daf040b9ec371a" "checksum toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "736b60249cb25337bc196faa43ee12c705e426f3d55c214d73a4e7be06f92cb4" "checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" -"checksum unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7007dbd421b92cc6e28410fe7362e2e0a2503394908f417b68ec8d1c364c4e20" +"checksum unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" "checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" -"checksum ursa 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ecc333b243fef89ac678341a0133dddb4c60cb138aa2e0bf1b5a34052afc8942" +"checksum universal-hash 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df0c900f2f9b4116803415878ff48b63da9edb268668e08cf9292d7503114a01" +"checksum ursa 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2bd2d9c71c3c63b02444a844ad7eece929ef394481388f7bed3f6632da1943f1" "checksum uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" -"checksum vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "33dd455d0f96e90a75803cfeb7f948768c08d70a6de9a8d2362461935698bf95" -"checksum walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9658c94fa8b940eab2250bd5a457f9c48b748420d71293b165c8cdbe2f55f71e" -"checksum wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "cd34c5ba0d228317ce388e87724633c57edca3e7531feb4e25e35aaa07a656af" -"checksum wasm-bindgen-backend 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "927196b315c23eed2748442ba675a4c54a1a079d90d9bdc5ad16ce31cf90b15b" -"checksum wasm-bindgen-macro 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "92c2442bf04d89792816650820c3fb407af8da987a9f10028d5317f5b04c2b4a" -"checksum wasm-bindgen-macro-support 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "9c075d27b7991c68ca0f77fe628c3513e64f8c477d422b859e03f28751b46fc5" -"checksum wasm-bindgen-shared 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "83d61fe986a7af038dd8b5ec660e5849cbd9f38e7492b9404cc48b2b4df731d1" +"checksum vcpkg 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3fc439f2794e98976c88a2a2dafce96b930fe8010b0a256b3c2199a773933168" +"checksum walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d" +"checksum wasm-bindgen 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)" = "5205e9afdf42282b192e2310a5b463a6d1c1d774e30dc3c791ac37ab42d2616c" +"checksum wasm-bindgen-backend 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)" = "11cdb95816290b525b32587d76419facd99662a07e59d3cdb560488a819d9a45" +"checksum wasm-bindgen-macro 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)" = "574094772ce6921576fb6f2e3f7497b8a76273b6db092be18fc48a082de09dc3" +"checksum wasm-bindgen-macro-support 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)" = "e85031354f25eaebe78bb7db1c3d86140312a911a106b2e29f9cc440ce3e7668" +"checksum wasm-bindgen-shared 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)" = "f5e7e61fc929f4c0dddb748b102ebf9f632e2b8d739f2016542b4de2965a9601" "checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -"checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" +"checksum winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4ccfbf554c6ad11084fb7517daca16cfdcaccbdadba4fc336f032a8b12c2ad80" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -"checksum wincolor 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "96f5016b18804d24db43cebf3c77269e7569b8954a8464501c216cc5e070eaa9" -"checksum zeroize 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8ddfeb6eee2fb3b262ef6e0898a52b7563bb8e0d5955a313b3cf2f808246ea14" "checksum zeroize 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "45af6a010d13e4cf5b54c94ba5a2b2eba5596b9e46bf5875612d332a1f2b3f86" +"checksum zeroize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3cbac2ed2ba24cc90f5e06485ac8c7c1e5449fe8911aef4d8877218af021a5b8" "checksum zeroize_derive 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "080616bd0e31f36095288bb0acdf1f78ef02c2fa15527d7e993f2a6c7591643e" +"checksum zeroize_derive 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de251eec69fc7c1bc3923403d18ececb929380e016afe103da75f396704f8ca2" "checksum zmq 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aad98a7a617d608cd9e1127147f630d24af07c7cd95ba1533246d96cbdd76c66" "checksum zmq-sys 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d33a2c51dde24d5b451a2ed4b488266df221a5eaee2ee519933dc46b9a9b3648" diff --git a/libindy/Cargo.toml b/libindy/Cargo.toml index 55c5743fbd..0c2eaa6443 100644 --- a/libindy/Cargo.toml +++ b/libindy/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libindy" -version = "1.14.1" +version = "1.14.2" authors = ["Hyperledger Indy Contributors "] edition = "2018" @@ -14,55 +14,36 @@ path = "src/lib.rs" crate-type = ["staticlib", "rlib", "cdylib"] [features] -default = ["bn_openssl", "ed25519_sign_sodium", "ed25519_box_sodium", "sealedbox_sodium", "base58_rust_base58", "base64_rust_base64", "xsalsa20_sodium", "chacha20poly1305_ietf_sodium", "pair_amcl", "hash_openssl", "local_nodes_pool", "revocation_tests", "pwhash_argon2i13_sodium", "hmacsha256_sodium", "memzero_sodium", "randombytes_sodium"] -bn_openssl = ["openssl", "int_traits"] -ed25519_sign_sodium = ["sodiumoxide"] -ed25519_box_sodium = ["sodiumoxide"] -sealedbox_sodium = ["sodiumoxide"] +default = ["base58_rust_base58", "pair_amcl", "local_nodes_pool", "revocation_tests"] base58_rust_base58 = ["rust-base58"] -base64_rust_base64 = ["base64"] -xsalsa20_sodium = ["sodiumoxide"] -chacha20poly1305_ietf_sodium = ["sodiumoxide"] -pwhash_argon2i13_sodium = ["sodiumoxide"] pair_amcl = ["ursa"] -hash_openssl = ["openssl"] local_nodes_pool = [] revocation_tests = [] force_full_interaction_tests = [] sodium_static = [] -hmacsha256_sodium = ["sodiumoxide"] -memzero_sodium = ["sodiumoxide"] -randombytes_sodium = ["sodiumoxide"] only_high_cases = [] # Causes the build to fail on all warnings fatal_warnings = [] [dependencies] -int_traits = { version = "0.1.1", optional = true } env_logger = "0.6.2" etcommon-rlp = "0.2.4" failure = "0.1.5" hex = "0.3.2" -libc = "0.2.60" +libc = "0.2.66" log = "0.4.8" log-derive = "0.3.0" derivative = "1.0.2" -dirs = "2.0.2" -openssl = { version = "0.10", optional = true } backtrace = "=0.3.11" -owning_ref = "0.4" rand = "0.7.0" -rusqlite = "0.20" # Make sure rusqlite for android is also bumped with this. Rusqlite for android is at the bottom of this document. rust-base58 = {version = "0.0.4", optional = true} -base64 = {version = "0.10.1", optional = true} serde = "1.0.99" serde_json = "1.0.40" serde_derive = "1.0.99" sha2 = "0.8" sha3 = "0.8" rmp-serde = "0.13.7" -sodiumoxide = {version = "0.0.16", optional = true} time = "0.1.42" threadpool = "1.7.1" zmq = "0.9.1" @@ -73,26 +54,33 @@ byteorder = "1.3.2" log-panics = "2.0.0" zeroize = "0.9.3" regex = "1.2.1" -ursa = { version = "0.2.0", optional = true } indy-api-types = { path = "./indy-api-types"} indy-utils = { path = "./indy-utils"} indy-wallet = { path = "./indy-wallet"} +ed25519-dalek = "=1.0.0-pre.2" # TODO: it shouldn't be fixed here [dependencies.uuid] version = "0.7.4" default-features = false features = ["v4"] +[dependencies.ursa] +version = "0.3.0" +optional = true +default-features = false +features = ["bn_openssl", "pair_amcl", "serialization", "native_secp256k1", "cl", "bls", "std", "encryption"] + [target.'cfg(target_os = "android")'.dependencies] android_logger = "0.5" -[target.'cfg(any(target_os = "android", target_os = "ios"))'.dependencies] -rusqlite = { version = "0.20", features=["bundled"] } [dev-dependencies] criterion = "0.2" indy = { path = "../wrappers/rust" } indy-sys = { path = "../wrappers/rust/indy-sys" } futures = "0.1.28" +sodiumoxide = {version = "0.0.16"} +openssl = "0.10" +dirs = "2.0.2" [[bench]] name = "wallet" diff --git a/libindy/ci/centos.dockerfile b/libindy/ci/centos.dockerfile index cb759fe42a..65f96c1ed6 100755 --- a/libindy/ci/centos.dockerfile +++ b/libindy/ci/centos.dockerfile @@ -22,12 +22,12 @@ RUN curl --silent --location https://rpm.nodesource.com/setup_8.x | bash - RUN yum -y install nodejs RUN cd /tmp && \ - curl https://download.libsodium.org/libsodium/releases/old/unsupported/libsodium-1.0.14.tar.gz | tar -xz && \ - cd /tmp/libsodium-1.0.14 && \ + curl https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz | tar -xz && \ + cd /tmp/libsodium-1.0.18 && \ ./configure && \ make && \ make install && \ - rm -rf /tmp/libsodium-1.0.14 + rm -rf /tmp/libsodium-1.0.18 ENV PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib diff --git a/libindy/ci/ubuntu.dockerfile b/libindy/ci/ubuntu.dockerfile index fdc9b7fb60..2d3e942be3 100755 --- a/libindy/ci/ubuntu.dockerfile +++ b/libindy/ci/ubuntu.dockerfile @@ -39,12 +39,12 @@ RUN pip3 install -U \ deb-pkg-tools RUN cd /tmp && \ - curl https://download.libsodium.org/libsodium/releases/old/unsupported/libsodium-1.0.14.tar.gz | tar -xz && \ - cd /tmp/libsodium-1.0.14 && \ - ./configure --disable-shared && \ + curl https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz | tar -xz && \ + cd /tmp/libsodium-1.0.18 && \ + ./configure && \ make && \ make install && \ - rm -rf /tmp/libsodium-1.0.14 + rm -rf /tmp/libsodium-1.0.18 RUN apt-get update && apt-get install openjdk-8-jdk -y ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64 diff --git a/libindy/debian/changelog b/libindy/debian/changelog index 14f08c8620..73ff0f1ff4 100644 --- a/libindy/debian/changelog +++ b/libindy/debian/changelog @@ -1,7 +1,15 @@ -libindy (1.14.1) unstable; urgency=medium +libindy (1.14.2) unstable; urgency=medium [ Hyperledger ] +## 1.14.2 +* Bugfixes + * Updated behavior of `indy_store_their_did` function to allow updating of existing `theirDID record`. It can be used to rotate a pairwise key (IS-1166). + * Enhanced validation of `schema_json`: added check that `id` is consistent with `name` and `version` values (IS-1430). + * Added support of the additional format of `rev_states_json` which is used for proof creation. Both `rev_reg_def_id` and `credential_id` can be used as map keys. + `credential_id` must be used in case of proving that two credentials matching the same `rev_reg_def_id` are not revoked at the same timestamp (IS-1447). + * others minor bugfixes + ## 1.14.1 * Bugfixes diff --git a/libindy/include/indy_did.h b/libindy/include/indy_did.h index 2f38358705..e3db97dfcd 100644 --- a/libindy/include/indy_did.h +++ b/libindy/include/indy_did.h @@ -126,7 +126,9 @@ extern "C" { /// identity_json: Identity information as json. Example: /// { /// "did": string, (required) - /// "verkey": string (optional, can be avoided if did is cryptonym: did == verkey), + /// "verkey": string + /// - optional is case of adding a new DID, and DID is cryptonym: did == verkey, + /// - mandatory in case of updating an existing DID /// } /// cb: Callback that takes command result as parameter. /// diff --git a/libindy/indy-api-types/Cargo.toml b/libindy/indy-api-types/Cargo.toml index 59d686a2b8..b2b030abcb 100644 --- a/libindy/indy-api-types/Cargo.toml +++ b/libindy/indy-api-types/Cargo.toml @@ -6,19 +6,28 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[features] +default = ["casting_errors"] +casting_errors = ["openssl", "rust-base58", "rusqlite", "zmq", "ed25519-dalek", "ursa", "rusqlite"] + [dependencies] failure = "0.1.5" -lazy_static = "1.3" -libc = "0.2.60" +libc = "0.2.66" log = "0.4.8" -openssl = { version = "0.10"} -rust-base58 = "0.0.4" -rusqlite = "0.20" # Make sure rusqlite for android is also bumped with this. Rusqlite for android is at the bottom of this document. +openssl = {version = "0.10", optional = true} +rust-base58 = {version = "0.0.4", optional = true} +rusqlite = {version = "0.20", optional = true} # Make sure rusqlite for android is also bumped with this. Rusqlite for android is at the bottom of this document. serde = "1.0.99" serde_json = "1.0.40" serde_derive = "1.0.99" -ursa = "0.2.0" -zmq = "0.9.1" +zmq = {version = "0.9.1", optional = true} +ed25519-dalek = {version = "=1.0.0-pre.2", optional = true} # TODO: it shouldn't be fixed here + +[dependencies.ursa] +version = "0.3.0" +optional = true +default-features = false +features = ["bn_openssl", "pair_amcl", "serialization", "native_secp256k1", "cl", "bls", "std", "encryption"] [target.'cfg(any(target_os = "android", target_os = "ios"))'.dependencies] -rusqlite = { version = "0.20", features=["bundled"] } +rusqlite = { version = "0.20", features=["bundled"], optional = true } diff --git a/libindy/indy-api-types/src/errors.rs b/libindy/indy-api-types/src/errors.rs index 43948fd0e4..14dd87dfec 100644 --- a/libindy/indy-api-types/src/errors.rs +++ b/libindy/indy-api-types/src/errors.rs @@ -8,7 +8,11 @@ use std::ptr; use failure::{Backtrace, Context, Fail}; + +#[cfg(feature = "casting_errors")] use ursa::errors::{UrsaCryptoError, UrsaCryptoErrorKind}; + +#[cfg(feature = "casting_errors")] use log; use libc::c_char; @@ -193,6 +197,7 @@ impl From for IndyError { } } +#[cfg(feature = "casting_errors")] impl From for IndyError { fn from(err: zmq::Error) -> Self { err.context(IndyErrorKind::IOError).into() @@ -211,12 +216,14 @@ impl From for IndyError { } } +#[cfg(feature = "casting_errors")] impl From for IndyError { fn from(err: log::SetLoggerError) -> IndyError { err.context(IndyErrorKind::InvalidState).into() } } +#[cfg(feature = "casting_errors")] impl From for IndyError { fn from(err: UrsaCryptoError) -> Self { let message = format!("UrsaCryptoError: {}", Fail::iter_causes(&err).map(|e| e.to_string()).collect::()); @@ -234,12 +241,14 @@ impl From for IndyError { } } +#[cfg(feature = "casting_errors")] impl From for IndyError { fn from(_err: rust_base58::base58::FromBase58Error) -> Self { IndyError::from_msg(IndyErrorKind::InvalidStructure, "The base58 input contained a character not part of the base58 alphabet") } } +#[cfg(feature = "casting_errors")] impl From for IndyError { fn from(err: openssl::error::ErrorStack) -> IndyError { // TODO: FIXME: Analyze ErrorStack and split invalid structure errors from other errors @@ -253,6 +262,7 @@ impl From for IndyError { } } +#[cfg(feature = "casting_errors")] impl From for IndyError { fn from(err: rusqlite::Error) -> IndyError { match err { diff --git a/libindy/indy-api-types/src/lib.rs b/libindy/indy-api-types/src/lib.rs index 4aae4a82e7..1c5b2c7831 100644 --- a/libindy/indy-api-types/src/lib.rs +++ b/libindy/indy-api-types/src/lib.rs @@ -1,5 +1,3 @@ -extern crate lazy_static; - #[macro_use] extern crate log; @@ -11,12 +9,15 @@ extern crate serde_derive; #[macro_use] extern crate serde_json; +#[cfg(feature = "casting_errors")] extern crate zmq; pub type IndyHandle = i32; -pub type WalletHandle = i32; -pub const INVALID_WALLET_HANDLE : WalletHandle = 0; +#[repr(transparent)] +#[derive(Debug, Hash, PartialEq, Eq, Copy, Clone, Serialize, Deserialize)] +pub struct WalletHandle(pub i32); +pub const INVALID_WALLET_HANDLE : WalletHandle = WalletHandle(0); pub type CallbackHandle = i32; @@ -28,6 +29,7 @@ pub const INVALID_COMMAND_HANDLE : CommandHandle = 0; pub type StorageHandle = i32; pub type SearchHandle = i32; +pub const INVALID_SEARCH_HANDLE : SearchHandle = 0; pub mod domain; diff --git a/libindy/indy-utils/Cargo.toml b/libindy/indy-utils/Cargo.toml index 08ce99aa95..a10e026692 100644 --- a/libindy/indy-utils/Cargo.toml +++ b/libindy/indy-utils/Cargo.toml @@ -6,12 +6,17 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] -default = ["base64_rust_base64", "chacha20poly1305_ietf_sodium", "pwhash_argon2i13_sodium", "hmacsha256_sodium", "hash_openssl"] +default = ["base64_rust_base64", "ed25519_sign_sodium", "ed25519_box_sodium", "sealedbox_sodium", "base64_rust_base64", "xsalsa20_sodium", "chacha20poly1305_ietf_sodium", "hash_openssl", "pwhash_argon2i13_sodium", "hmacsha256_sodium", "randombytes_sodium"] base64_rust_base64 = [] +ed25519_sign_sodium = [] +ed25519_box_sodium = [] +sealedbox_sodium = [] +xsalsa20_sodium = [] chacha20poly1305_ietf_sodium = [] pwhash_argon2i13_sodium = [] hmacsha256_sodium = [] hash_openssl = [] +randombytes_sodium = [] [dependencies] base64 = {version = "0.10.1"} @@ -19,12 +24,15 @@ dirs = "2.0.2" failure = "0.1.5" indy-api-types = { path = "../indy-api-types"} lazy_static = "1.3" -libc = "0.2.60" +libc = "0.2.66" log = "0.4.8" openssl = { version = "0.10" } serde = "1.0.99" serde_json = "1.0.40" serde_derive = "1.0.99" sodiumoxide = {version = "0.0.16"} -time = "0.1.42" -ursa = "0.2.0" +zeroize = "0.9.3" + +[dev-dependencies] +rmp-serde = "0.13.7" +rand = "0.7.0" \ No newline at end of file diff --git a/libindy/indy-utils/src/crypto/base64/rust_base64.rs b/libindy/indy-utils/src/crypto/base64/rust_base64.rs index 01f47a4b30..ec3d0852fc 100644 --- a/libindy/indy-utils/src/crypto/base64/rust_base64.rs +++ b/libindy/indy-utils/src/crypto/base64/rust_base64.rs @@ -13,11 +13,11 @@ pub fn decode(doc: &str) -> Result, IndyError> { } pub fn encode_urlsafe(doc: &[u8]) -> String { - base64::encode_config(doc, base64::URL_SAFE) + base64::encode_config(doc, base64::URL_SAFE) //TODO switch to URL_SAFE_NO_PAD } pub fn decode_urlsafe(doc: &str) -> Result, IndyError> { - base64::decode_config(doc, base64::URL_SAFE) + base64::decode_config(doc, base64::URL_SAFE_NO_PAD) .context("Invalid base64URL_SAFE sequence") .context(IndyErrorKind::InvalidStructure) .map_err(|err| err.into()) @@ -54,4 +54,19 @@ mod tests { assert!(result.is_ok(), "Got error"); assert_eq!(&[1, 2, 3], &result.unwrap()[..]); } -} \ No newline at end of file + + #[test] // aries-396 + fn encode_base64_urlsafe_and_urlsafe_no_pad_compatible() { + let data = "Hello World"; + { + let encoded = base64::encode_config(data, base64::URL_SAFE); + let decoded_data = base64::decode_config(&encoded, base64::URL_SAFE_NO_PAD).unwrap(); + assert_eq!(data.as_bytes().to_vec(), decoded_data); + } + { + let encoded = base64::encode_config(data, base64::URL_SAFE_NO_PAD); + let decoded_data = base64::decode_config(&encoded, base64::URL_SAFE).unwrap(); + assert_eq!(data.as_bytes().to_vec(), decoded_data); + } + } +} diff --git a/libindy/indy-utils/src/crypto/chacha20poly1305_ietf/sodium.rs b/libindy/indy-utils/src/crypto/chacha20poly1305_ietf/sodium.rs index 93aa0ad800..0cef9c71f4 100644 --- a/libindy/indy-utils/src/crypto/chacha20poly1305_ietf/sodium.rs +++ b/libindy/indy-utils/src/crypto/chacha20poly1305_ietf/sodium.rs @@ -239,7 +239,7 @@ mod tests { extern crate rmp_serde; use super::*; - use crate::utils::crypto::randombytes::randombytes; + use crate::crypto::randombytes::randombytes; #[test] fn derivation_argon2i_mod_produces_expected_result() { diff --git a/libindy/src/utils/crypto/ed25519_box/sodium.rs b/libindy/indy-utils/src/crypto/ed25519_box/sodium.rs similarity index 96% rename from libindy/src/utils/crypto/ed25519_box/sodium.rs rename to libindy/indy-utils/src/crypto/ed25519_box/sodium.rs index b15d543bce..c6738c94f8 100644 --- a/libindy/src/utils/crypto/ed25519_box/sodium.rs +++ b/libindy/indy-utils/src/crypto/ed25519_box/sodium.rs @@ -39,8 +39,8 @@ pub fn gen_nonce() -> Nonce { #[cfg(test)] mod tests { use super::*; - use crate::utils::crypto::ed25519_sign; - use crate::utils::crypto::randombytes::randombytes; + use crate::crypto::ed25519_sign; + use crate::crypto::randombytes::randombytes; #[test] fn encrypt_decrypt_works() { diff --git a/libindy/src/utils/crypto/ed25519_sign/sodium.rs b/libindy/indy-utils/src/crypto/ed25519_sign/sodium.rs similarity index 99% rename from libindy/src/utils/crypto/ed25519_sign/sodium.rs rename to libindy/indy-utils/src/crypto/ed25519_sign/sodium.rs index 97ab80b8bd..fced4fb488 100644 --- a/libindy/src/utils/crypto/ed25519_sign/sodium.rs +++ b/libindy/indy-utils/src/crypto/ed25519_sign/sodium.rs @@ -78,7 +78,7 @@ pub fn vk_to_curve25519(pk: &PublicKey) -> Result WalletHandle { sequence::get_next_id() } +pub fn next_wallet_handle() -> WalletHandle { WalletHandle(sequence::get_next_id()) } pub fn next_pool_handle() -> PoolHandle { sequence::get_next_id() diff --git a/libindy/indy-wallet/Cargo.toml b/libindy/indy-wallet/Cargo.toml index e98c58f909..d57ed5e15a 100644 --- a/libindy/indy-wallet/Cargo.toml +++ b/libindy/indy-wallet/Cargo.toml @@ -7,7 +7,6 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -base64 = "*" byteorder = "1.3.2" indy-api-types = { path = "../indy-api-types"} indy-utils = { path = "../indy-utils"} @@ -21,8 +20,11 @@ rust-base58 = "0.0.4" serde = "1.0.99" serde_json = "1.0.40" serde_derive = "1.0.99" -sodiumoxide = {version = "0.0.16"} zeroize = "*" +[dev-dependencies] +rand = "0.7.0" +lazy_static = "1.3" + [target.'cfg(any(target_os = "android", target_os = "ios"))'.dependencies] rusqlite = { version = "0.20", features=["bundled"] } diff --git a/libindy/indy-wallet/src/encryption.rs b/libindy/indy-wallet/src/encryption.rs index ae6859e6e8..b7f54606d4 100644 --- a/libindy/indy-wallet/src/encryption.rs +++ b/libindy/indy-wallet/src/encryption.rs @@ -209,9 +209,9 @@ pub(super) fn decrypt_storage_record(record: &StorageRecord, keys: &Keys) -> Ind #[cfg(test)] mod tests { - use indy_wallet::wallet::EncryptedValue; - use indy_wallet::wallet::Keys; - use crate::utils::crypto::hmacsha256; + use crate::wallet::EncryptedValue; + use crate::wallet::Keys; + use indy_utils::crypto::hmacsha256; use super::*; diff --git a/libindy/indy-wallet/src/export_import.rs b/libindy/indy-wallet/src/export_import.rs index 9202768a84..c73fe0a87c 100644 --- a/libindy/indy-wallet/src/export_import.rs +++ b/libindy/indy-wallet/src/export_import.rs @@ -245,13 +245,13 @@ mod tests { use serde_json; - use indy_api_types::domain::wallet::{Metadata, MetadataArgon}; - use indy_wallet::encryption; - use indy_wallet::storage::default::SQLiteStorageType; - use indy_wallet::storage::WalletStorageType; - use indy_wallet::wallet::{Keys, Wallet}; - use crate::utils::crypto::pwhash_argon2i13; - use crate::utils::test; + use crate::{Metadata, MetadataArgon}; + use crate::encryption; + use crate::storage::default::SQLiteStorageType; + use crate::storage::WalletStorageType; + use crate::wallet::{Keys, Wallet}; + use indy_utils::crypto::pwhash_argon2i13; + use indy_utils::test; use super::*; diff --git a/libindy/indy-wallet/src/lib.rs b/libindy/indy-wallet/src/lib.rs index 52fa71843b..f9e76d9557 100644 --- a/libindy/indy-wallet/src/lib.rs +++ b/libindy/indy-wallet/src/lib.rs @@ -11,8 +11,6 @@ extern crate serde; #[macro_use] extern crate serde_derive; -extern crate serde_json; - use std::cell::RefCell; use std::collections::HashMap; use std::fs; @@ -781,6 +779,14 @@ impl Default for SearchOptions { } } +#[cfg(test)] +#[macro_use] +extern crate lazy_static; + +#[cfg(test)] +#[macro_use] +extern crate serde_json; + #[cfg(test)] mod tests { use std::collections::HashMap; @@ -790,9 +796,10 @@ mod tests { use indy_api_types::INVALID_WALLET_HANDLE; use indy_api_types::domain::wallet::KeyDerivationMethod; - use crate::utils::environment; + use indy_utils::environment; use indy_utils::inmem_wallet::InmemWallet; - use crate::utils::test; + use indy_utils::test; + use indy_utils::next_wallet_handle; use super::*; diff --git a/libindy/indy-wallet/src/storage/default/mod.rs b/libindy/indy-wallet/src/storage/default/mod.rs index 42abe0b74b..2d90a6d1a4 100644 --- a/libindy/indy-wallet/src/storage/default/mod.rs +++ b/libindy/indy-wallet/src/storage/default/mod.rs @@ -1,5 +1,4 @@ extern crate owning_ref; -extern crate sodiumoxide; use std; use std::fs; @@ -744,7 +743,7 @@ impl WalletStorageType for SQLiteStorageType { #[cfg(test)] mod tests { - use crate::utils::test; + use indy_utils::test; use super::*; use super::super::Tag; diff --git a/libindy/indy-wallet/src/storage/plugged/mod.rs b/libindy/indy-wallet/src/storage/plugged/mod.rs index b8ab2983a4..de509ab49f 100644 --- a/libindy/indy-wallet/src/storage/plugged/mod.rs +++ b/libindy/indy-wallet/src/storage/plugged/mod.rs @@ -6,7 +6,7 @@ use std::ptr; use libc::c_char; use serde_json; -use indy_api_types::ErrorCode; +use indy_api_types::{ErrorCode, SearchHandle, INVALID_SEARCH_HANDLE}; use indy_api_types::wallet::*; use indy_api_types::errors::prelude::*; use crate::language; @@ -57,7 +57,7 @@ impl Drop for ResourceGuard { #[derive(PartialEq, Debug)] struct PluggedStorageIterator { storage_handle: i32, - search_handle: i32, + search_handle: SearchHandle, options: SearchOptions, fetch_search_next_record_handler: WalletFetchSearchNextRecord, get_search_total_count_handler: WalletGetSearchTotalCount, @@ -70,7 +70,7 @@ struct PluggedStorageIterator { } impl PluggedStorageIterator { - fn new(storage: &PluggedStorage, search_handle: i32, options: SearchOptions) -> Self { + fn new(storage: &PluggedStorage, search_handle: SearchHandle, options: SearchOptions) -> Self { Self { storage_handle: storage.handle, search_handle, @@ -554,7 +554,7 @@ impl WalletStorage for PluggedStorage { } fn get_all(&self) -> IndyResult> { - let mut search_handle: i32 = -1; + let mut search_handle: SearchHandle = INVALID_SEARCH_HANDLE; let err = (self.search_all_records_handler)(self.handle, &mut search_handle); diff --git a/libindy/indy-wallet/src/wallet.rs b/libindy/indy-wallet/src/wallet.rs index 093b44c0f2..8688ec4df4 100644 --- a/libindy/indy-wallet/src/wallet.rs +++ b/libindy/indy-wallet/src/wallet.rs @@ -222,13 +222,13 @@ mod tests { use std::rc::Rc; use std::collections::HashMap; - use indy_api_types::domain::wallet::{Metadata, MetadataArgon}; - use indy_wallet::encryption; - use indy_wallet::wallet::Wallet; - use indy_wallet::storage::WalletStorageType; - use indy_wallet::storage::default::SQLiteStorageType; - use indy_wallet::language::*; - use crate::utils::test; + use crate::{Metadata, MetadataArgon}; + use crate::encryption; + use crate::wallet::Wallet; + use crate::storage::WalletStorageType; + use crate::storage::default::SQLiteStorageType; + use crate::language::*; + use indy_utils::test; macro_rules! jsonstr { ($($x:tt)+) => { diff --git a/libindy/src/api/anoncreds.rs b/libindy/src/api/anoncreds.rs index 25d6d9500c..8af9465afe 100644 --- a/libindy/src/api/anoncreds.rs +++ b/libindy/src/api/anoncreds.rs @@ -1526,8 +1526,10 @@ pub extern fn indy_prover_close_credentials_search(command_handle: CommandHandl /// attr_referent: Proof-request local identifier of requested attribute /// attr_info: Describes requested attribute /// { -/// "name": string, // attribute name, (case insensitive and ignore spaces) -/// "names": [string, string], // attribute names, (case insensitive and ignore spaces) -- should either be "name" or "names", not both and not none of them. +/// "name": Optional, // attribute name, (case insensitive and ignore spaces) +/// "names": Optional<[string, string]>, // attribute names, (case insensitive and ignore spaces) +/// // NOTE: should either be "name" or "names", not both and not none of them. +/// // Use "names" to specify several attributes that have to match a single credential. /// "restrictions": Optional, // see below /// "non_revoked": Optional<>, // see below, /// // If specified prover must proof non-revocation @@ -1652,8 +1654,10 @@ pub extern fn indy_prover_get_credentials_for_proof_req(command_handle: CommandH /// where /// attr_info: Describes requested attribute /// { -/// "name": string, // attribute name, (case insensitive and ignore spaces) -/// "names": [string, string], // attribute names, (case insensitive and ignore spaces) -- should either be "name" or "names", not both and not none of them. +/// "name": Optional, // attribute name, (case insensitive and ignore spaces) +/// "names": Optional<[string, string]>, // attribute names, (case insensitive and ignore spaces) +/// // NOTE: should either be "name" or "names", not both and not none of them. +/// // Use "names" to specify several attributes that have to match a single credential. /// "restrictions": Optional, // see below /// "non_revoked": Optional<>, // see below, /// // If specified prover must proof non-revocation @@ -1906,25 +1910,28 @@ pub extern fn indy_prover_close_credentials_search_for_proof_req(command_handle /// } /// rev_states_json: all revocation states participating in the proof request /// { -/// "rev_reg_def1_id": { +/// "rev_reg_def1_id or credential_1_id": { /// "timestamp1": , /// "timestamp2": , /// }, -/// "rev_reg_def2_id": { +/// "rev_reg_def2_id or credential_1_id"": { /// "timestamp3": /// }, -/// "rev_reg_def3_id": { +/// "rev_reg_def3_id or credential_1_id"": { /// "timestamp4": /// }, /// } +/// Note: use credential_id instead rev_reg_id in case proving several credentials from the same revocation registry. /// cb: Callback that takes command result as parameter. /// /// where /// attr_referent: Proof-request local identifier of requested attribute /// attr_info: Describes requested attribute /// { -/// "name": string, // attribute name, (case insensitive and ignore spaces) -/// "names": [string, string], // attribute names, (case insensitive and ignore spaces) -- should either be "name" or "names", not both and not none of them. +/// "name": Optional, // attribute name, (case insensitive and ignore spaces) +/// "names": Optional<[string, string]>, // attribute names, (case insensitive and ignore spaces) +/// // NOTE: should either be "name" or "names", not both and not none of them. +/// // Use "names" to specify several attributes that have to match a single credential. /// "restrictions": Optional, // see below /// "non_revoked": Optional<>, // see below, /// // If specified prover must proof non-revocation @@ -1973,12 +1980,13 @@ pub extern fn indy_prover_close_credentials_search_for_proof_req(command_handle /// "revealed_attr_groups": { /// "requested_attr5_id": { /// "sub_proof_index": number, -/// "values": [ -/// { +/// "values": { +/// "attribute_name": { /// "raw": string, /// "encoded": string /// } -/// ], // NOTE: check that `encoded` value match to `raw` value on application level +/// }, +/// } /// }, /// "unrevealed_attrs": { /// "requested_attr3_id": {sub_proof_index: number} @@ -2089,12 +2097,13 @@ pub extern fn indy_prover_create_proof(command_handle: CommandHandle, /// "revealed_attr_groups": { /// "requested_attr5_id": { /// "sub_proof_index": number, -/// "values": [ -/// { +/// "values": { +/// "attribute_name": { /// "raw": string, /// "encoded": string /// } -/// ], // NOTE: check that `encoded` value match to `raw` value on application level +/// }, // NOTE: check that `encoded` value match to `raw` value on application level +/// } /// }, /// "unrevealed_attrs": { /// "requested_attr3_id": {sub_proof_index: number} @@ -2148,8 +2157,10 @@ pub extern fn indy_prover_create_proof(command_handle: CommandHandle, /// attr_referent: Proof-request local identifier of requested attribute /// attr_info: Describes requested attribute /// { -/// "name": string, // attribute name, (case insensitive and ignore spaces) -/// "names": [string, string], // attribute names, (case insensitive and ignore spaces) -- should either be "name" or "names", not both and not none of them. +/// "name": Optional, // attribute name, (case insensitive and ignore spaces) +/// "names": Optional<[string, string]>, // attribute names, (case insensitive and ignore spaces) +/// // NOTE: should either be "name" or "names", not both and not none of them. +/// // Use "names" to specify several attributes that have to match a single credential. /// "restrictions": Optional, // see below /// "non_revoked": Optional<>, // see below, /// // If specified prover must proof non-revocation @@ -2239,13 +2250,20 @@ pub extern fn indy_verifier_verify_proof(command_handle: CommandHandle, res } -/// Create revocation state for a credential in the particular time moment. +/// Create revocation state for a credential that corresponds to a particular time. +/// +/// Note that revocation delta must cover the whole registry existence time. +/// You can use `from`: `0` and `to`: `needed_time` as parameters for building request to get correct revocation delta. +/// +/// The resulting revocation state and provided timestamp can be saved and reused later with applying a new +/// revocation delta with `indy_update_revocation_state` function. +/// This new delta should be received with parameters: `from`: `timestamp` and `to`: `needed_time`. /// /// #Params /// command_handle: command handle to map callback to user context /// blob_storage_reader_handle: configuration of blob storage reader handle that will allow to read revocation tails (returned by `indy_open_blob_storage_reader`) /// rev_reg_def_json: revocation registry definition json related to `rev_reg_id` in a credential -/// rev_reg_delta_json: revocation registry definition delta json +/// rev_reg_delta_json: revocation registry delta which covers the whole registry existence time /// timestamp: time represented as a total number of seconds from Unix Epoch. /// cred_rev_id: user credential revocation id in revocation registry (match to `cred_rev_id` in a credential) /// cb: Callback that takes command result as parameter @@ -2301,15 +2319,20 @@ pub extern fn indy_create_revocation_state(command_handle: CommandHandle, res } -/// Create new revocation state for a credential based on existed state -/// at the particular time moment (to reduce calculation time). +/// Create a new revocation state for a credential based on a revocation state created before. +/// Note that provided revocation delta must cover the registry gap from based state creation until the specified time +/// (this new delta should be received with parameters: `from`: `state_timestamp` and `to`: `needed_time`). +/// +/// This function reduces the calculation time. +/// +/// The resulting revocation state and provided timestamp can be saved and reused later by applying a new revocation delta again. /// /// #Params /// command_handle: command handle to map callback to user context /// blob_storage_reader_handle: configuration of blob storage reader handle that will allow to read revocation tails (returned by `indy_open_blob_storage_reader`) /// rev_state_json: revocation registry state json /// rev_reg_def_json: revocation registry definition json related to `rev_reg_id` in a credential -/// rev_reg_delta_json: revocation registry definition delta json +/// rev_reg_delta_json: revocation registry definition delta which covers the gap form original `rev_state_json` creation till the requested timestamp /// timestamp: time represented as a total number of seconds from Unix Epoch /// cred_rev_id: user credential revocation id in revocation registry (match to `cred_rev_id` in a credential) /// cb: Callback that takes command result as parameter diff --git a/libindy/src/api/did.rs b/libindy/src/api/did.rs index 5550333ce9..e13124d7d6 100644 --- a/libindy/src/api/did.rs +++ b/libindy/src/api/did.rs @@ -196,6 +196,7 @@ pub extern fn indy_replace_keys_apply(command_handle: CommandHandle, /// Saves their DID for a pairwise connection in a secured Wallet, /// so that it can be used to verify transaction. +/// Updates DID associated verkey in case DID already exists in the Wallet. /// /// #Params /// wallet_handle: wallet handler (created by open_wallet). @@ -203,7 +204,9 @@ pub extern fn indy_replace_keys_apply(command_handle: CommandHandle, /// identity_json: Identity information as json. Example: /// { /// "did": string, (required) -/// "verkey": string (optional, can be avoided if did is cryptonym: did == verkey), +/// "verkey": string +/// - optional is case of adding a new DID, and DID is cryptonym: did == verkey, +/// - mandatory in case of updating an existing DID /// } /// cb: Callback that takes command result as parameter. /// diff --git a/libindy/src/api/payments.rs b/libindy/src/api/payments.rs index f181e610c7..225a5c0371 100644 --- a/libindy/src/api/payments.rs +++ b/libindy/src/api/payments.rs @@ -326,10 +326,10 @@ pub type ParseVerifyPaymentResponseCB = extern fn(command_handle: CommandHandle, /// /// # Return /// a signature byte array -pub type SignWithAddressCB = extern fn (command_handle: i32, wallet_handle: i32, +pub type SignWithAddressCB = extern fn (command_handle: CommandHandle, wallet_handle: WalletHandle, address: *const c_char, message_raw: *const u8, message_len: u32, - cb: Option ErrorCode>) -> ErrorCode; + cb: Option ErrorCode>) -> ErrorCode; /// Verify a signature with a public payment address. /// @@ -344,10 +344,10 @@ pub type SignWithAddressCB = extern fn (command_handle: i32, wallet_handle: i32, /// /// # Returns /// valid: true - if signature is valid, false - otherwise -pub type VerifyWithAddressCB = extern fn (command_handle: i32, address: *const c_char, +pub type VerifyWithAddressCB = extern fn (command_handle: CommandHandle, address: *const c_char, message_raw: *const u8, message_len: u32, signature_raw: *const u8, signature_len: u32, - cb: Option ErrorCode>) -> ErrorCode; + cb: Option ErrorCode>) -> ErrorCode; /// Register custom payment implementation. /// diff --git a/libindy/src/api/pool.rs b/libindy/src/api/pool.rs index dd3542a47e..ad87251cff 100755 --- a/libindy/src/api/pool.rs +++ b/libindy/src/api/pool.rs @@ -72,8 +72,13 @@ pub extern fn indy_create_pool_ledger_config(command_handle: CommandHandle, /// "extended_timeout": int (optional), extended timeout for network request (in sec). /// "preordered_nodes": array - (optional), names of nodes which will have a priority during request sending: /// ["name_of_1st_prior_node", "name_of_2nd_prior_node", .... ] -/// Note: Not specified nodes will be placed in a random way. +/// This can be useful if a user prefers querying specific nodes. +/// Assume that `Node1` and `Node2` nodes reply faster. +/// If you pass them Libindy always sends a read request to these nodes first and only then (if not enough) to others. +/// Note: Nodes not specified will be placed randomly. /// "number_read_nodes": int (optional) - the number of nodes to send read requests (2 by default) +/// By default Libindy sends a read requests to 2 nodes in the pool. +/// If response isn't received or `state proof` is invalid Libindy sends the request again but to 2 (`number_read_nodes`) * 2 = 4 nodes and so far until completion. /// } /// /// #Returns diff --git a/libindy/src/commands/anoncreds/prover.rs b/libindy/src/commands/anoncreds/prover.rs index 8b3ed93fe3..34cb894c75 100644 --- a/libindy/src/commands/anoncreds/prover.rs +++ b/libindy/src/commands/anoncreds/prover.rs @@ -30,7 +30,7 @@ use indy_utils::sequence; use crate::utils::wql::Query; use super::tails::SDKTailsAccessor; -use indy_api_types::WalletHandle; +use indy_api_types::{WalletHandle, SearchHandle}; use crate::commands::BoxedCallbackStringStringSend; pub enum ProverCommand { @@ -152,8 +152,8 @@ pub struct ProverCommandExecutor { wallet_service: Rc, crypto_service: Rc, blob_storage_service: Rc, - searches: RefCell>>, - searches_for_proof_requests: RefCell>>>, + searches: RefCell>>, + searches_for_proof_requests: RefCell>>>, } impl ProverCommandExecutor { @@ -480,7 +480,7 @@ impl ProverCommandExecutor { } fn fetch_credentials(&self, - search_handle: i32, + search_handle: SearchHandle, count: usize, ) -> IndyResult { trace!("fetch_credentials >>> search_handle: {:?}, count: {:?}", search_handle, count); diff --git a/libindy/src/commands/crypto.rs b/libindy/src/commands/crypto.rs index 6ff64b1381..d7ffa08ccf 100644 --- a/libindy/src/commands/crypto.rs +++ b/libindy/src/commands/crypto.rs @@ -8,8 +8,8 @@ use indy_wallet::{RecordOptions, WalletService}; use std::rc::Rc; use std::str; -use crate::utils::crypto::base64; -use crate::utils::crypto::chacha20poly1305_ietf; +use indy_utils::crypto::base64; +use indy_utils::crypto::chacha20poly1305_ietf; use crate::domain::crypto::combo_box::ComboBox; use indy_api_types::WalletHandle; diff --git a/libindy/src/commands/did.rs b/libindy/src/commands/did.rs index 877cdd66ad..66a76e6241 100644 --- a/libindy/src/commands/did.rs +++ b/libindy/src/commands/did.rs @@ -275,7 +275,7 @@ impl DidCommandExecutor { let their_did = self.crypto_service.create_their_did(their_did_info)?; - self.wallet_service.add_indy_object(wallet_handle, &their_did.did.0, &their_did, &HashMap::new())?; + self.wallet_service.upsert_indy_object(wallet_handle, &their_did.did.0, &their_did)?; debug!("store_their_did <<<"); diff --git a/libindy/src/commands/non_secrets.rs b/libindy/src/commands/non_secrets.rs index 7d0b499f6f..dbc360ad78 100644 --- a/libindy/src/commands/non_secrets.rs +++ b/libindy/src/commands/non_secrets.rs @@ -6,7 +6,7 @@ use indy_api_types::domain::wallet::Tags; use indy_api_types::errors::prelude::*; use indy_wallet::{RecordOptions, SearchOptions, WalletRecord, WalletSearch, WalletService}; use indy_utils::sequence; -use indy_api_types::WalletHandle; +use indy_api_types::{WalletHandle, SearchHandle}; pub enum NonSecretsCommand { @@ -49,18 +49,18 @@ pub enum NonSecretsCommand { String, // type String, // query json String, // options json - Box) + Send>), + Box) + Send>), FetchSearchNextRecords(WalletHandle, - i32, // wallet search handle + SearchHandle, // wallet search handle usize, // count Box) + Send>), - CloseSearch(i32, // wallet search handle + CloseSearch(SearchHandle, // wallet search handle Box) + Send>), } pub struct NonSecretsCommandExecutor { wallet_service: Rc, - searches: RefCell>>, + searches: RefCell>>, } impl NonSecretsCommandExecutor { @@ -241,7 +241,7 @@ impl NonSecretsCommandExecutor { wallet_handle: WalletHandle, type_: &str, query_json: &str, - options_json: &str) -> IndyResult { + options_json: &str) -> IndyResult { trace!("open_search >>> wallet_handle: {:?}, type_: {:?}, query_json: {:?}, options_json: {:?}", wallet_handle, type_, query_json, options_json); self._check_type(type_)?; @@ -262,7 +262,7 @@ impl NonSecretsCommandExecutor { fn fetch_search_next_records(&self, wallet_handle: WalletHandle, - wallet_search_handle: i32, + wallet_search_handle: SearchHandle, count: usize) -> IndyResult { trace!("fetch_search_next_records >>> wallet_handle: {:?}, wallet_search_handle: {:?}, count: {:?}", wallet_handle, wallet_search_handle, count); @@ -291,7 +291,7 @@ impl NonSecretsCommandExecutor { } fn close_search(&self, - wallet_search_handle: i32) -> IndyResult<()> { + wallet_search_handle: SearchHandle) -> IndyResult<()> { trace!("close_search >>> wallet_search_handle: {:?}", wallet_search_handle); match self.searches.borrow_mut().remove(&wallet_search_handle) { diff --git a/libindy/src/commands/wallet.rs b/libindy/src/commands/wallet.rs index 73f73a6c56..6521e4b7e1 100644 --- a/libindy/src/commands/wallet.rs +++ b/libindy/src/commands/wallet.rs @@ -8,8 +8,8 @@ use indy_api_types::domain::wallet::{Config, Credentials, ExportConfig, KeyConfi use indy_api_types::errors::prelude::*; use crate::services::crypto::CryptoService; use indy_wallet::{KeyDerivationData, WalletService, Metadata}; -use crate::utils::crypto::{chacha20poly1305_ietf, randombytes}; -use crate::utils::crypto::chacha20poly1305_ietf::Key as MasterKey; +use indy_utils::crypto::{chacha20poly1305_ietf, randombytes}; +use indy_utils::crypto::chacha20poly1305_ietf::Key as MasterKey; use indy_api_types::{WalletHandle, CallbackHandle}; use rust_base58::ToBase58; diff --git a/libindy/src/domain/anoncreds/proof.rs b/libindy/src/domain/anoncreds/proof.rs index 2350bb9b8f..622f401527 100644 --- a/libindy/src/domain/anoncreds/proof.rs +++ b/libindy/src/domain/anoncreds/proof.rs @@ -20,8 +20,11 @@ pub struct RequestedProof { #[serde(skip_serializing_if="HashMap::is_empty")] #[serde(default)] pub revealed_attr_groups: HashMap, + #[serde(default)] pub self_attested_attrs: HashMap, + #[serde(default)] pub unrevealed_attrs: HashMap, + #[serde(default)] pub predicates: HashMap } diff --git a/libindy/src/domain/anoncreds/proof_request.rs b/libindy/src/domain/anoncreds/proof_request.rs index 6eae4d41a5..105429fef7 100644 --- a/libindy/src/domain/anoncreds/proof_request.rs +++ b/libindy/src/domain/anoncreds/proof_request.rs @@ -20,7 +20,9 @@ pub struct ProofRequestPayload { pub nonce: Nonce, pub name: String, pub version: String, + #[serde(default)] pub requested_attributes: HashMap, + #[serde(default)] pub requested_predicates: HashMap, pub non_revoked: Option } diff --git a/libindy/src/domain/anoncreds/revocation_state.rs b/libindy/src/domain/anoncreds/revocation_state.rs index bfafcc9340..1d43a6ccbe 100644 --- a/libindy/src/domain/anoncreds/revocation_state.rs +++ b/libindy/src/domain/anoncreds/revocation_state.rs @@ -5,8 +5,6 @@ use named_type::NamedType; use indy_api_types::validation::Validatable; -use super::revocation_registry_definition::RevocationRegistryId; - #[derive(Clone, Debug, Serialize, Deserialize, NamedType)] pub struct RevocationState { pub witness: Witness, @@ -23,4 +21,4 @@ impl Validatable for RevocationState { } } -pub type RevocationStates = HashMap>; +pub type RevocationStates = HashMap>; diff --git a/libindy/src/domain/anoncreds/schema.rs b/libindy/src/domain/anoncreds/schema.rs index a4201aa42e..8f973033a2 100644 --- a/libindy/src/domain/anoncreds/schema.rs +++ b/libindy/src/domain/anoncreds/schema.rs @@ -86,6 +86,14 @@ impl Validatable for Schema { Schema::SchemaV1(schema) => { schema.attr_names.validate()?; schema.id.validate()?; + if let Some((_, name, version)) = schema.id.parts() { + if name != schema.name { + return Err(format!("Inconsistent Schema Id and Schema Name: {:?} and {}", schema.id, schema.name)) + } + if version != schema.version { + return Err(format!("Inconsistent Schema Id and Schema Version: {:?} and {}", schema.id, schema.version)) + } + } Ok(()) } } @@ -284,4 +292,56 @@ mod tests { id.validate().unwrap_err(); } } + + mod test_schema_validation { + use super::*; + + #[test] + fn test_valid_schema() { + let schema_json = json!({ + "id": _schema_id_qualified(), + "name": "gvt", + "ver": "1.0", + "version": "1.0", + "attrNames": ["aaa", "bbb", "ccc"], + }).to_string(); + + let schema: Schema = serde_json::from_str(&schema_json).unwrap(); + schema.validate().unwrap(); + match schema { + Schema::SchemaV1(schema) => { + assert_eq!(schema.name, "gvt"); + assert_eq!(schema.version, "1.0"); + } + } + } + + #[test] + fn test_invalid_name_schema() { + let schema_json = json!({ + "id": _schema_id_qualified(), + "name": "gvt1", + "ver": "1.0", + "version": "1.0", + "attrNames": ["aaa", "bbb", "ccc"], + }).to_string(); + + let schema: Schema = serde_json::from_str(&schema_json).unwrap(); + schema.validate().unwrap_err(); + } + + #[test] + fn test_invalid_version_schema() { + let schema_json = json!({ + "id": _schema_id_qualified(), + "name": "gvt", + "ver": "1.0", + "version": "1.1", + "attrNames": ["aaa", "bbb", "ccc"], + }).to_string(); + + let schema: Schema = serde_json::from_str(&schema_json).unwrap(); + schema.validate().unwrap_err(); + } + } } \ No newline at end of file diff --git a/libindy/src/lib.rs b/libindy/src/lib.rs index 5341e5de4a..c4d6fb1478 100644 --- a/libindy/src/lib.rs +++ b/libindy/src/lib.rs @@ -1,6 +1,5 @@ #![cfg_attr(feature = "fatal_warnings", deny(warnings))] -extern crate base64; extern crate byteorder; extern crate failure; @@ -30,12 +29,10 @@ extern crate rlp; extern crate time; extern crate libc; extern crate rand; -extern crate rusqlite; extern crate uuid; #[macro_use] extern crate derivative; -extern crate sodiumoxide; extern crate core; extern crate hex; @@ -55,6 +52,8 @@ extern crate indy_api_types; #[macro_use] extern crate indy_utils; +extern crate indy_wallet; + // Note that to use macroses from util inside of other modules it must be loaded first! #[macro_use] mod utils; diff --git a/libindy/src/services/anoncreds/prover.rs b/libindy/src/services/anoncreds/prover.rs index 92a7c1a589..4fca319a07 100644 --- a/libindy/src/services/anoncreds/prover.rs +++ b/libindy/src/services/anoncreds/prover.rs @@ -22,7 +22,7 @@ use crate::domain::anoncreds::proof::{Identifier, Proof, RequestedProof, Reveale use crate::domain::anoncreds::proof_request::{PredicateInfo, PredicateTypes, ProofRequest, ProofRequestPayload, ProofRequestsVersion, RequestedAttributeInfo, RequestedPredicateInfo, ProofRequestExtraQuery}; use crate::domain::anoncreds::requested_credential::ProvingCredentialKey; use crate::domain::anoncreds::requested_credential::RequestedCredentials; -use crate::domain::anoncreds::revocation_registry_definition::{RevocationRegistryDefinitionV1, RevocationRegistryId}; +use crate::domain::anoncreds::revocation_registry_definition::RevocationRegistryDefinitionV1; use crate::domain::anoncreds::revocation_state::RevocationState; use crate::domain::anoncreds::schema::{SchemaV1, SchemaId}; use indy_api_types::errors::prelude::*; @@ -108,7 +108,7 @@ impl Prover { master_secret: &MasterSecret, schemas: &HashMap, cred_defs: &HashMap, - rev_states: &HashMap>) -> IndyResult { + rev_states: &HashMap>) -> IndyResult { trace!("create_proof >>> credentials: {:?}, proof_req: {:?}, requested_credentials: {:?}, master_secret: {:?}, schemas: {:?}, cred_defs: {:?}, rev_states: {:?}", credentials, proof_req, requested_credentials, secret!(&master_secret), schemas, cred_defs, rev_states); @@ -140,7 +140,8 @@ impl Prover { .clone() .ok_or_else(|| err_msg(IndyErrorKind::InvalidStructure, "Revocation Registry Id not found"))?; - let rev_states_for_timestamp = rev_states.get(&rev_reg_id) + let rev_states_for_timestamp = rev_states.get(&rev_reg_id.0) + .or(rev_states.get(cred_key.cred_id.as_str())) .ok_or_else(|| err_msg(IndyErrorKind::InvalidStructure, format!("RevocationState not found by id: {:?}", rev_reg_id)))?; Some(rev_states_for_timestamp.get(×tamp) @@ -384,7 +385,7 @@ impl Prover { } requested_proof.revealed_attr_groups.insert(attr_info.attr_referent.clone(), RevealedAttributeGroupInfo { sub_proof_index, - values: value_map + values: value_map, }); } } else { @@ -443,7 +444,9 @@ impl Prover { extra_query: &Option<&ProofRequestExtraQuery>) -> IndyResult { info!("name: {:?}, names: {:?}", name, names); - let mut queries: Vec = if let Some(names) = names.as_ref().or(name.as_ref().map(|s| vec![s.clone()]).as_ref()) { + let mut queries: Vec = Vec::new(); + + let mut attr_queries: Vec = if let Some(names) = names.as_ref().or(name.as_ref().map(|s| vec![s.clone()]).as_ref()) { names.iter().map(|name| { Query::Eq(format!("attr::{}::marker", &attr_common_view(name)), ATTRIBUTE_EXISTENCE_MARKER.to_string()) }).collect() @@ -466,6 +469,10 @@ impl Prover { queries.push(extra_query_.clone()) } + // put attr_queries last as this results in a better performing query with large datasets + // ref IS-1470 + queries.append(&mut attr_queries); + Ok(Query::And(queries)) } @@ -546,6 +553,7 @@ mod tests { mod build_credential_tags { use super::*; + use crate::domain::anoncreds::revocation_registry_definition::RevocationRegistryId; fn _credential() -> Credential { // note that encoding is not standardized by Indy except that 32-bit integers are encoded as themselves. IS-786 @@ -1022,11 +1030,11 @@ mod tests { &None).unwrap(); let expected_query = Query::And(vec![ - Query::Eq("attr::name::marker".to_string(), ATTRIBUTE_EXISTENCE_MARKER.to_string()), Query::And(vec![ Query::Eq("schema_id".to_string(), SCHEMA_ID.to_string()), Query::Eq("cred_def_id".to_string(), CRED_DEF_ID.to_string()), - ]) + ]), + Query::Eq("attr::name::marker".to_string(), ATTRIBUTE_EXISTENCE_MARKER.to_string()), ]); assert_eq!(expected_query, query); @@ -1048,8 +1056,8 @@ mod tests { &Some(&extra_query)).unwrap(); let expected_query = Query::And(vec![ - Query::Eq("attr::name::marker".to_string(), ATTRIBUTE_EXISTENCE_MARKER.to_string()), Query::Eq("name".to_string(), "Alex".to_string()), + Query::Eq("attr::name::marker".to_string(), ATTRIBUTE_EXISTENCE_MARKER.to_string()), ]); assert_eq!(expected_query, query); @@ -1076,12 +1084,12 @@ mod tests { &Some(&extra_query)).unwrap(); let expected_query = Query::And(vec![ - Query::Eq("attr::name::marker".to_string(), ATTRIBUTE_EXISTENCE_MARKER.to_string()), Query::And(vec![ Query::Eq("schema_id".to_string(), SCHEMA_ID.to_string()), Query::Eq("cred_def_id".to_string(), CRED_DEF_ID.to_string()), ]), Query::Eq("name".to_string(), "Alex".to_string()), + Query::Eq("attr::name::marker".to_string(), ATTRIBUTE_EXISTENCE_MARKER.to_string()), ]); assert_eq!(expected_query, query); @@ -1134,7 +1142,6 @@ mod tests { &Some(&extra_query)).unwrap(); let expected_query = Query::And(vec![ - Query::Eq("attr::name::marker".to_string(), ATTRIBUTE_EXISTENCE_MARKER.to_string()), Query::Or(vec![ Query::Eq("schema_id".to_string(), SCHEMA_ID.to_string()), Query::Eq("schema_id".to_string(), "schema_id_2".to_string()), @@ -1142,7 +1149,8 @@ mod tests { Query::Or(vec![ Query::Eq("name".to_string(), "Alex".to_string()), Query::Eq("name".to_string(), "Alexander".to_string()), - ]) + ]), + Query::Eq("attr::name::marker".to_string(), ATTRIBUTE_EXISTENCE_MARKER.to_string()), ]); assert_eq!(expected_query, query); diff --git a/libindy/src/services/crypto/ed25519.rs b/libindy/src/services/crypto/ed25519.rs index 8d44c0063a..b1bbd053a4 100644 --- a/libindy/src/services/crypto/ed25519.rs +++ b/libindy/src/services/crypto/ed25519.rs @@ -1,8 +1,8 @@ use indy_api_types::errors::IndyError; use super::CryptoType; -use crate::utils::crypto::ed25519_box; -use crate::utils::crypto::ed25519_sign; -use crate::utils::crypto::sealedbox; +use indy_utils::crypto::ed25519_box; +use indy_utils::crypto::ed25519_sign; +use indy_utils::crypto::sealedbox; pub struct ED25519CryptoType {} diff --git a/libindy/src/services/crypto/mod.rs b/libindy/src/services/crypto/mod.rs index d82873b164..97ad449ecb 100644 --- a/libindy/src/services/crypto/mod.rs +++ b/libindy/src/services/crypto/mod.rs @@ -7,11 +7,11 @@ use crate::domain::crypto::combo_box::ComboBox; use crate::domain::crypto::did::{Did, DidValue, MyDidInfo, TheirDid, TheirDidInfo}; use crate::domain::crypto::key::{Key, KeyInfo}; use indy_api_types::errors::prelude::*; -use crate::utils::crypto::base64; -use crate::utils::crypto::ed25519_box; -use crate::utils::crypto::chacha20poly1305_ietf; -use crate::utils::crypto::chacha20poly1305_ietf::gen_nonce_and_encrypt_detached; -use crate::utils::crypto::ed25519_sign; +use indy_utils::crypto::base64; +use indy_utils::crypto::ed25519_box; +use indy_utils::crypto::chacha20poly1305_ietf; +use indy_utils::crypto::chacha20poly1305_ietf::gen_nonce_and_encrypt_detached; +use indy_utils::crypto::ed25519_sign; use crate::utils::crypto::verkey_builder::{build_full_verkey, split_verkey, verkey_get_cryptoname}; use self::ed25519::ED25519CryptoType; @@ -446,7 +446,7 @@ impl CryptoService { #[cfg(test)] mod tests { use crate::domain::crypto::did::MyDidInfo; - use crate::utils::crypto::chacha20poly1305_ietf::gen_key; + use indy_utils::crypto::chacha20poly1305_ietf::gen_key; use super::*; diff --git a/libindy/src/services/mod.rs b/libindy/src/services/mod.rs index 3d068ab5ab..ff1648b68c 100644 --- a/libindy/src/services/mod.rs +++ b/libindy/src/services/mod.rs @@ -3,5 +3,4 @@ pub mod blob_storage; pub mod crypto; pub mod ledger; pub mod payments; -pub mod pool; -pub use indy_wallet; \ No newline at end of file +pub mod pool; \ No newline at end of file diff --git a/libindy/src/services/pool/mod.rs b/libindy/src/services/pool/mod.rs index 7e25165b7b..f5540569cf 100644 --- a/libindy/src/services/pool/mod.rs +++ b/libindy/src/services/pool/mod.rs @@ -605,10 +605,8 @@ mod tests { } pub mod nodes_emulator { - extern crate sodiumoxide; - use rust_base58::{ToBase58, FromBase58}; - use crate::utils::crypto::ed25519_sign; + use indy_utils::crypto::ed25519_sign; use super::*; @@ -686,8 +684,7 @@ mod tests { } pub fn start(gt: &mut NodeTransactionV1) -> zmq::Socket { - let (vk, sk) = sodiumoxide::crypto::sign::ed25519::gen_keypair(); - let (vk, sk) = (ed25519_sign::PublicKey::from_slice(&vk[..]).unwrap(), ed25519_sign::SecretKey::from_slice(&sk[..]).unwrap()); + let (vk, sk) = ed25519_sign::create_key_pair_for_signature(None).unwrap(); let pkc = ed25519_sign::vk_to_curve25519(&vk).expect("Invalid pkc"); let skc = ed25519_sign::sk_to_curve25519(&sk).expect("Invalid skc"); let ctx = zmq::Context::new(); diff --git a/libindy/src/services/pool/networker.rs b/libindy/src/services/pool/networker.rs index d9f4b7a7b4..74f6278bf5 100644 --- a/libindy/src/services/pool/networker.rs +++ b/libindy/src/services/pool/networker.rs @@ -9,6 +9,7 @@ use indy_api_types::errors::prelude::*; use crate::services::pool::events::*; use crate::services::pool::types::*; use indy_utils::sequence; +use indy_utils::crypto::base64; use super::time::Duration; @@ -391,7 +392,7 @@ pub mod networker_tests { use crate::domain::pool::{MAX_REQ_PER_POOL_CON, POOL_ACK_TIMEOUT, POOL_CON_ACTIVE_TO, POOL_REPLY_TIMEOUT}; use crate::services::pool::tests::nodes_emulator; - use crate::utils::crypto::ed25519_sign; + use indy_utils::crypto::ed25519_sign; use super::*; use rust_base58::base58::FromBase58; diff --git a/libindy/src/services/pool/pool.rs b/libindy/src/services/pool/pool.rs index 38b47a820e..9ebdb857bf 100644 --- a/libindy/src/services/pool/pool.rs +++ b/libindy/src/services/pool/pool.rs @@ -23,7 +23,7 @@ use crate::services::pool::networker::{Networker, ZMQNetworker}; use crate::services::pool::request_handler::{RequestHandler, RequestHandlerImpl}; use rust_base58::{FromBase58, ToBase58}; use crate::services::pool::types::{LedgerStatus, RemoteNode}; -use crate::utils::crypto::ed25519_sign; +use indy_utils::crypto::ed25519_sign; use super::ursa::bls::VerKey; use super::zmq; @@ -698,7 +698,7 @@ fn _get_nodes_and_remotes(merkle: &MerkleTree) -> IndyResult<(Nodes, Vec { - error!("Error during retrieving nodes: {:?}", e); + debug!("Error during retrieving nodes: {:?}", e); } Ok(((alias, verkey), remote)) => { map.insert(alias.clone(), verkey); diff --git a/libindy/src/services/pool/request_handler.rs b/libindy/src/services/pool/request_handler.rs index faa075b9de..dea84c4f94 100644 --- a/libindy/src/services/pool/request_handler.rs +++ b/libindy/src/services/pool/request_handler.rs @@ -64,6 +64,10 @@ enum RequestState { Finish(FinishState), } +/* + The Generator is used for multi-signature verification. + It must be the same as on the Ledger side otherwise signatures verification will fail. +*/ pub const DEFAULT_GENERATOR: &str = "3LHpUjiyFC2q2hD7MnwwNmVXiuaFbQx2XkAFJWzswCjgN1utjsCeLzHsKk1nJvFEaS4fcrUmVAkdhtPCYbrVyATZcmzwJReTcJqwqBCPTmTQ9uWPwz6rEncKb2pYYYFcdHa8N17HzVyTqKfgPi4X9pMetfT3A5xCHq54R2pDNYWVLDX"; impl RequestSM { diff --git a/libindy/src/services/pool/state_proof/mod.rs b/libindy/src/services/pool/state_proof/mod.rs index 292140727b..5861596983 100644 --- a/libindy/src/services/pool/state_proof/mod.rs +++ b/libindy/src/services/pool/state_proof/mod.rs @@ -6,7 +6,7 @@ use std::ffi::{CStr, CString}; use indy_utils::crypto::hash::{Hash}; use rust_base58::ToBase58; -use base64; +use indy_utils::crypto::base64; use rlp::UntrustedRlp; use serde_json; use serde_json::Value as SJsonValue; @@ -406,7 +406,7 @@ fn _parse_reply_for_sp(json_msg: &SJsonValue, data: Option<&str>, parsed_data: & let proof = if let Some(path) = parsed_data["auditPath"].as_array() { let path_str = json!(path).to_string(); trace!("TransactionHandler::parse_reply_for_builtin_sp: proof: {:?}", path); - base64::encode(&path_str) + base64::encode(path_str.as_bytes()) } else { return Err("No proof".to_string()); }; @@ -894,7 +894,7 @@ mod tests { "25KLEkkyCEPSBj4qMFE3AcH87mFocyJEuPJ5xzPGwDgz" ] ).to_string(); - let kvs = vec![(base64::encode("3"), Some(r#"{"3":"3"}"#.to_string()))]; + let kvs = vec![(base64::encode("3".as_bytes()), Some(r#"{"3":"3"}"#.to_string()))]; let node_bytes = &nodes; let root_hash = "CrA5sqYe3ruf2uY7d8re7ePmyHqptHqANtMZcfZd4BvK".from_base58().unwrap(); assert!(_verify_merkle_tree(node_bytes.as_bytes(), root_hash.as_slice(), kvs.as_slice(), 5)); @@ -909,7 +909,7 @@ mod tests { "25KLEkkyCEPSBj4qMFE3AcH87mFocyJEuPJ5xzPGwDgz" ] ).to_string(); - let kvs = vec![(base64::encode("3"), Some(r#"{"3":"3"}"#.to_string()))]; + let kvs = vec![(base64::encode("3".as_bytes()), Some(r#"{"3":"3"}"#.to_string()))]; let node_bytes = &nodes; let root_hash = "CrA5sqYe3ruf2uY7d8re7ePmyHqptHqANtMZcfZd4BvK".from_base58().unwrap(); assert!(!_verify_merkle_tree(node_bytes.as_bytes(), root_hash.as_slice(), kvs.as_slice(), 5)); @@ -924,7 +924,7 @@ mod tests { "25KLEkkyCEPSBj4qMFE3AcH87mFocyJEuPJ5xzPGwDgz" ] ).to_string(); - let kvs = vec![(base64::encode("3"), Some(r#"{"3":"3"}"#.to_string()))]; + let kvs = vec![(base64::encode("3".as_bytes()), Some(r#"{"3":"3"}"#.to_string()))]; let node_bytes = &nodes; let root_hash = "G9QooEDKSmEtLGNyTwafQiPfGHMqw3A3Fjcj2eLRG4G1".from_base58().unwrap(); assert!(!_verify_merkle_tree(node_bytes.as_bytes(), root_hash.as_slice(), kvs.as_slice(), 5)); @@ -939,7 +939,7 @@ mod tests { "25KLEkkyCEPSBj4qMFE3AcH87mFocyJEuPJ5xzPGwDgz" ] ).to_string(); - let kvs = vec![(base64::encode("3"), Some(r#"{"3":"3"}"#.to_string()))]; + let kvs = vec![(base64::encode("3".as_bytes()), Some(r#"{"3":"3"}"#.to_string()))]; let node_bytes = &nodes; let root_hash = "CrA5sqYe3ruf2uY7d8re7ePmyHqptHqANtMZcfZd4BvK".from_base58().unwrap(); assert!(!_verify_merkle_tree(node_bytes.as_bytes(), root_hash.as_slice(), kvs.as_slice(), 9)); @@ -954,7 +954,7 @@ mod tests { "25KLEkkyCEPSBj4qMFE3AcH87mFocyJEuPJ5xzPGwDgz" ] ).to_string(); - let kvs = vec![(base64::encode("3"), Some(r#"{"4":"4"}"#.to_string()))]; + let kvs = vec![(base64::encode("3".as_bytes()), Some(r#"{"4":"4"}"#.to_string()))]; let node_bytes = &nodes; let root_hash = "CrA5sqYe3ruf2uY7d8re7ePmyHqptHqANtMZcfZd4BvK".from_base58().unwrap(); assert!(!_verify_merkle_tree(node_bytes.as_bytes(), root_hash.as_slice(), kvs.as_slice(), 5)); @@ -969,7 +969,7 @@ mod tests { "25KLEkkyCEPSBj4qMFE3AcH87mFocyJEuPJ5xzPGwDgz" ] ).to_string(); - let kvs = vec![(base64::encode("4"), Some(r#"{"3":"3"}"#.to_string()))]; + let kvs = vec![(base64::encode("4".as_bytes()), Some(r#"{"3":"3"}"#.to_string()))]; let node_bytes = &nodes; let root_hash = "CrA5sqYe3ruf2uY7d8re7ePmyHqptHqANtMZcfZd4BvK".from_base58().unwrap(); assert!(!_verify_merkle_tree(node_bytes.as_bytes(), root_hash.as_slice(), kvs.as_slice(), 5)); @@ -1479,7 +1479,7 @@ mod tests { } }); - let nodes_str = base64::encode(&json!(["1", "2"]).to_string()); + let nodes_str = base64::encode(json!(["1", "2"]).to_string().as_bytes()); let mut parsed_sps = super::parse_generic_reply_for_proof_checking(json_msg, "", @@ -1493,7 +1493,7 @@ mod tests { assert_eq!(parsed_sp.proof_nodes, nodes_str); assert_eq!(parsed_sp.kvs_to_verify, KeyValuesInSP::Simple(KeyValueSimpleData { - kvs: vec![(base64::encode("2"), Some(json!({"txn":{"test1": "test2", "seqNo": 2}}).to_string()))], + kvs: vec![(base64::encode("2".as_bytes()), Some(json!({"txn":{"test1": "test2", "seqNo": 2}}).to_string()))], verification_type: KeyValueSimpleDataVerificationType::MerkleTree(2), })); } @@ -1512,7 +1512,7 @@ mod tests { } }); - let nodes_str = base64::encode(&json!(["1", "2"]).to_string()); + let nodes_str = base64::encode(json!(["1", "2"]).to_string().as_bytes()); let mut parsed_sps = super::parse_generic_reply_for_proof_checking(json_msg, "", @@ -1526,7 +1526,7 @@ mod tests { assert_eq!(parsed_sp.proof_nodes, nodes_str); assert_eq!(parsed_sp.kvs_to_verify, KeyValuesInSP::Simple(KeyValueSimpleData { - kvs: vec![(base64::encode("2"), Some(json!({"txn":{"test1": "test2", "seqNo": 2}}).to_string()))], + kvs: vec![(base64::encode("2".as_bytes()), Some(json!({"txn":{"test1": "test2", "seqNo": 2}}).to_string()))], verification_type: KeyValueSimpleDataVerificationType::MerkleTree(2), })); } @@ -1566,7 +1566,7 @@ mod tests { } }); - let nodes_str = base64::encode(&json!(["1", "2"]).to_string()); + let nodes_str = base64::encode(json!(["1", "2"]).to_string().as_bytes()); let mut parsed_sps = super::parse_generic_reply_for_proof_checking(json_msg, "", @@ -1580,7 +1580,7 @@ mod tests { assert_eq!(parsed_sp.proof_nodes, nodes_str); assert_eq!(parsed_sp.kvs_to_verify, KeyValuesInSP::Simple(KeyValueSimpleData { - kvs: vec![(base64::encode("2"), None)], + kvs: vec![(base64::encode("2".as_bytes()), None)], verification_type: KeyValueSimpleDataVerificationType::MerkleTree(2), })); } diff --git a/libindy/src/services/pool/state_proof/node.rs b/libindy/src/services/pool/state_proof/node.rs index f8129e7508..a29a44ef81 100644 --- a/libindy/src/services/pool/state_proof/node.rs +++ b/libindy/src/services/pool/state_proof/node.rs @@ -407,6 +407,7 @@ impl Node { #[cfg(test)] mod tests { use super::*; + use indy_utils::crypto::base64; #[test] fn node_deserialize_works_for_emtpy() { @@ -419,4 +420,4 @@ mod tests { assert_eq!(base64::encode(&rlp::encode_list(&vec![Node::Blank])), "wYA="); } -} \ No newline at end of file +} diff --git a/libindy/src/utils/crypto/mod.rs b/libindy/src/utils/crypto/mod.rs index aab98ddf21..ba0a6b8dfa 100644 --- a/libindy/src/utils/crypto/mod.rs +++ b/libindy/src/utils/crypto/mod.rs @@ -1,29 +1,2 @@ -#[cfg(feature = "ed25519_sign_sodium")] -#[path = "ed25519_sign/sodium.rs"] -pub mod ed25519_sign; - -#[cfg(feature = "ed25519_box_sodium")] -#[path = "ed25519_box/sodium.rs"] -// TODO: The name is misleading as the operations do not happen over ed25519 curve -pub mod ed25519_box; - -pub use indy_utils::crypto::base64; - -#[allow(dead_code)] /* FIXME Do we really need this module? */ -#[cfg(feature = "xsalsa20_sodium")] -#[path = "xsalsa20/sodium.rs"] -pub mod xsalsa20; - -pub use indy_utils::crypto::chacha20poly1305_ietf; - -pub mod signature_serializer; - pub mod verkey_builder; - -#[cfg(feature = "sealedbox_sodium")] -#[path = "sealedbox/sodium.rs"] -pub mod sealedbox; - -#[cfg(feature = "randombytes_sodium")] -#[path = "randombytes/sodium.rs"] -pub mod randombytes; +pub mod signature_serializer; diff --git a/libindy/tests/anoncreds.rs b/libindy/tests/anoncreds.rs index 44ca56ed28..209f53040d 100644 --- a/libindy/tests/anoncreds.rs +++ b/libindy/tests/anoncreds.rs @@ -19,6 +19,8 @@ use crate::utils::domain::anoncreds::credential_for_proof_request::{CredentialsF use crate::utils::domain::anoncreds::proof::Proof; use crate::utils::domain::crypto::did::DidValue; +use indy::INVALID_WALLET_HANDLE; + mod high_cases { use super::*; @@ -243,7 +245,7 @@ mod high_cases { let wallet_handle = wallet::open_wallet(ANONCREDS_WALLET_CONFIG, WALLET_CREDENTIALS).unwrap(); - let invalid_wallet_handle = wallet_handle + 100; + let invalid_wallet_handle = INVALID_WALLET_HANDLE; let res = anoncreds::prover_get_credentials(invalid_wallet_handle, r#"{}"#); assert_code!(ErrorCode::WalletInvalidHandle, res); @@ -2357,12 +2359,59 @@ mod high_cases { let wallet_handle = wallet::open_wallet(ANONCREDS_WALLET_CONFIG, WALLET_CREDENTIALS).unwrap(); - let invalid_wallet_handle = wallet_handle + 100; + let invalid_wallet_handle = INVALID_WALLET_HANDLE; let res = anoncreds::prover_get_credentials_for_proof_req(invalid_wallet_handle, &anoncreds::proof_request_attr()); assert_code!(ErrorCode::WalletInvalidHandle, res); wallet::close_wallet(wallet_handle).unwrap(); } + + #[test] + fn prover_get_credentials_for_proof_req_works_for_omitting_attributes_or_predicates_field() { + anoncreds::init_common_wallet(); + + let wallet_handle = wallet::open_wallet(ANONCREDS_WALLET_CONFIG, WALLET_CREDENTIALS).unwrap(); + + { + // specify requested_attributes only + let proof_req = json!({ + "nonce":"123432421212", + "name":"proof_req_1", + "version":"0.1", + "requested_attributes": { + "attr1_referent": { + "name":"name" + } + } + }).to_string(); + + let credentials_json = anoncreds::prover_get_credentials_for_proof_req(wallet_handle, &proof_req).unwrap(); + + let credentials: CredentialsForProofRequest = serde_json::from_str(&credentials_json).unwrap(); + + credentials.attrs.get("attr1_referent").unwrap(); + } + + { + // specify requested_predicates only + let proof_req = json!({ + "nonce":"123432421212", + "name":"proof_req_1", + "version":"0.1", + "requested_predicates": { + "predicate1_referent": { "name":"age", "p_type":">=", "p_value":18 }, + } + }).to_string(); + + let credentials_json = anoncreds::prover_get_credentials_for_proof_req(wallet_handle, &proof_req).unwrap(); + + let credentials: CredentialsForProofRequest = serde_json::from_str(&credentials_json).unwrap(); + + credentials.predicates.get("predicate1_referent").unwrap(); + } + + wallet::close_wallet(wallet_handle).unwrap(); + } } mod prover_search_credentials_for_proof_req { @@ -3793,7 +3842,6 @@ mod medium_cases { mod issuer_create_and_store_credential_def { use super::*; - use indy_sys::INVALID_WALLET_HANDLE; #[test] fn issuer_create_and_store_credential_def_works_for_invalid_schema() { @@ -3968,7 +4016,7 @@ mod medium_cases { let wallet_handle = wallet::open_wallet(ANONCREDS_WALLET_CONFIG, WALLET_CREDENTIALS).unwrap(); - let invalid_wallet_handle = wallet_handle + 100; + let invalid_wallet_handle = INVALID_WALLET_HANDLE; let res = anoncreds::issuer_create_credential_offer(invalid_wallet_handle, &anoncreds::issuer_1_gvt_cred_def_id()); assert_code!(ErrorCode::WalletInvalidHandle, res); @@ -3998,7 +4046,7 @@ mod medium_cases { let wallet_handle = wallet::open_wallet(ANONCREDS_WALLET_CONFIG, WALLET_CREDENTIALS).unwrap(); - let invalid_wallet_handle = wallet_handle + 100; + let invalid_wallet_handle = INVALID_WALLET_HANDLE; let res = anoncreds::prover_create_master_secret(invalid_wallet_handle, COMMON_MASTER_SECRET); assert_code!(ErrorCode::WalletInvalidHandle, res); @@ -4071,7 +4119,7 @@ mod medium_cases { let wallet_handle = wallet::open_wallet(ANONCREDS_WALLET_CONFIG, WALLET_CREDENTIALS).unwrap(); - let invalid_wallet_handle = wallet_handle + 100; + let invalid_wallet_handle = INVALID_WALLET_HANDLE; let res = anoncreds::prover_create_credential_req(invalid_wallet_handle, DID_MY1, &credential_offer, @@ -4130,7 +4178,7 @@ mod medium_cases { let wallet_handle = wallet::open_wallet(ANONCREDS_WALLET_CONFIG, WALLET_CREDENTIALS).unwrap(); - let invalid_wallet_handle = wallet_handle + 100; + let invalid_wallet_handle = INVALID_WALLET_HANDLE; let res = anoncreds::issuer_create_credential(invalid_wallet_handle, &credential_offer, &credential_req, @@ -4214,7 +4262,7 @@ mod medium_cases { None, None).unwrap(); - let invalid_wallet_handle = wallet_handle + 100; + let invalid_wallet_handle = INVALID_WALLET_HANDLE; let res = anoncreds::prover_store_credential(invalid_wallet_handle, CREDENTIAL1_ID, &credential_req_meta, @@ -4455,7 +4503,7 @@ mod medium_cases { "requested_predicates": json!({}) }).to_string(); - let invalid_wallet_handle = wallet_handle + 100; + let invalid_wallet_handle = INVALID_WALLET_HANDLE; let res = anoncreds::prover_create_proof(invalid_wallet_handle, &anoncreds::proof_request_attr(), &requested_credentials_json, diff --git a/libindy/tests/anoncreds_demos.rs b/libindy/tests/anoncreds_demos.rs index de7e592495..0238d68568 100644 --- a/libindy/tests/anoncreds_demos.rs +++ b/libindy/tests/anoncreds_demos.rs @@ -69,7 +69,10 @@ mod demos { "attr2_referent":{ "name":"sex" }, - "attr3_referent":{"name":"phone"} + "attr3_referent":{"name":"phone"}, + "attr4_referent":{ + "names": ["name", "height"] + } }, "requested_predicates":{ "predicate1_referent":{"name":"age","p_type":">=","p_value":18} @@ -86,12 +89,13 @@ mod demos { "self_attested_attributes":{{"attr3_referent":"{}"}}, "requested_attributes":{{ "attr1_referent":{{ "cred_id":"{}", "revealed":true }}, - "attr2_referent":{{ "cred_id":"{}", "revealed":false }} + "attr2_referent":{{ "cred_id":"{}", "revealed":false }}, + "attr4_referent":{{ "cred_id":"{}", "revealed":true }} }}, "requested_predicates":{{ "predicate1_referent":{{ "cred_id":"{}" }} }} - }}"#, self_attested_value, credential.referent, credential.referent, credential.referent); + }}"#, self_attested_value, credential.referent, credential.referent, credential.referent, credential.referent); let schemas_json = json!({schema_id: serde_json::from_str::(&schema_json).unwrap()}).to_string(); let cred_defs_json = json!({cred_def_id: serde_json::from_str::(&cred_def_json).unwrap()}).to_string(); @@ -111,6 +115,9 @@ mod demos { assert_eq!("Alex", proof.requested_proof.revealed_attrs.get("attr1_referent").unwrap().raw); assert_eq!(0, proof.requested_proof.unrevealed_attrs.get("attr2_referent").unwrap().sub_proof_index); assert_eq!(self_attested_value, proof.requested_proof.self_attested_attrs.get("attr3_referent").unwrap()); + let revealed_attr_groups = proof.requested_proof.revealed_attr_groups.get("attr4_referent").unwrap(); + assert_eq!("Alex", revealed_attr_groups.values.get("name").unwrap().raw); + assert_eq!("175", revealed_attr_groups.values.get("height").unwrap().raw); let rev_reg_defs_json = json!({}).to_string(); let rev_regs_json = json!({}).to_string(); @@ -3453,4 +3460,146 @@ mod demos { wallet::close_and_delete_wallet(issuer_gvt_wallet_handle, &issuer_gvt_wallet_config).unwrap(); wallet::close_and_delete_wallet(issuer_xyz_wallet_handle, &issuer_xyz_wallet_config).unwrap(); } + + #[cfg(feature = "revocation_tests")] + #[test] + fn anoncreds_works_for_revocation_proof_using_two_credentials_from_same_revocation_registry() { // IS-1477 + Setup::empty(); + + //1. Issuer creates wallet, gets wallet handle + let (issuer_wallet_handle, issuer_wallet_config) = wallet::create_and_open_default_wallet("anoncreds_works_for_revocation_proof_issuance_by_default").unwrap(); + + //2. Prover creates wallet, gets wallet handle + let (prover_wallet_handle, prover_wallet_config) = wallet::create_and_open_default_wallet("anoncreds_works_for_revocation_proof_issuance_by_default").unwrap(); + + //3 Issuer creates Schema, Credential Definition and Revocation Registry + let (schema_id, schema_json, + cred_def_id, cred_def_json, + rev_reg_id, revoc_reg_def_json, revoc_reg_entry_json, + blob_storage_reader_handle) = anoncreds::multi_steps_issuer_revocation_preparation(issuer_wallet_handle, + ISSUER_DID, + GVT_SCHEMA_NAME, + GVT_SCHEMA_ATTRIBUTES, + r#"{"max_cred_num":5, "issuance_type":"ISSUANCE_BY_DEFAULT"}"#); + + //4. Prover creates Master Secret + anoncreds::prover_create_master_secret(prover_wallet_handle, COMMON_MASTER_SECRET).unwrap(); + + let (cred_rev_id, _) = anoncreds::multi_steps_create_revocation_credential( + COMMON_MASTER_SECRET, + prover_wallet_handle, + issuer_wallet_handle, + CREDENTIAL1_ID, + &anoncreds::gvt_credential_values_json(), + &cred_def_id, + &cred_def_json, + &rev_reg_id, + &revoc_reg_def_json, + blob_storage_reader_handle, + ); + + let (cred_rev_id_2, _) = anoncreds::multi_steps_create_revocation_credential( + COMMON_MASTER_SECRET, + prover_wallet_handle, + issuer_wallet_handle, + CREDENTIAL2_ID, + &anoncreds::gvt_credential_values_json(), + &cred_def_id, + &cred_def_json, + &rev_reg_id, + &revoc_reg_def_json, + blob_storage_reader_handle, + ); + + let timestamp = time::get_time().sec as u64; + + //5. Proof Request + let proof_request = json!({ + "nonce":"123432421212", + "name":"proof_req_1", + "version":"0.1", + "requested_attributes": { + "attr1_referent": { + "name":"name" + }, + "attr2_referent": { + "name":"age" + } + }, + "requested_predicates": {}, + "non_revoked": { "from":timestamp - 100, "to":timestamp + 100 } + }).to_string(); + + //6. Prover creates Revocation State + let rev_state_json = anoncreds::create_revocation_state(blob_storage_reader_handle, + &revoc_reg_def_json, + &revoc_reg_entry_json, + timestamp, + &cred_rev_id).unwrap(); + + let rev_state_json_2 = anoncreds::create_revocation_state(blob_storage_reader_handle, + &revoc_reg_def_json, + &revoc_reg_entry_json, + timestamp, + &cred_rev_id_2).unwrap(); + + //8. Prover creates Proof + let requested_credentials_json = json!({ + "self_attested_attributes": json!({}), + "requested_attributes": { + "attr1_referent": { "cred_id": CREDENTIAL1_ID, "timestamp": timestamp, "revealed":true }, + "attr2_referent": { "cred_id": CREDENTIAL2_ID, "timestamp": timestamp, "revealed":true } + }, + "requested_predicates": json!({}) + }).to_string(); + + let schemas_json = json!({ + schema_id.clone(): serde_json::from_str::(&schema_json).unwrap() + }).to_string(); + + let credential_defs_json = json!({ + cred_def_id.clone(): serde_json::from_str::(&cred_def_json).unwrap() + }).to_string(); + + let rev_states_json = json!({ + CREDENTIAL1_ID: json!({ + timestamp.to_string(): serde_json::from_str::(&rev_state_json).unwrap() + }), + CREDENTIAL2_ID: json!({ + timestamp.to_string(): serde_json::from_str::(&rev_state_json_2).unwrap() + }) + }).to_string(); + + let proof_json = anoncreds::prover_create_proof(prover_wallet_handle, + &proof_request, + &requested_credentials_json, + COMMON_MASTER_SECRET, + &schemas_json, + &credential_defs_json, + &rev_states_json).unwrap(); + let _proof: Proof = serde_json::from_str(&proof_json).unwrap(); + + //9. Verifier verifies proof + let rev_reg_defs_json = json!({ + rev_reg_id.clone(): serde_json::from_str::(&revoc_reg_def_json).unwrap() + }).to_string(); + + let rev_regs_json = json!({ + rev_reg_id.clone(): json!({ + timestamp.to_string(): serde_json::from_str::(&revoc_reg_entry_json).unwrap() + }) + }).to_string(); + + let valid = anoncreds::verifier_verify_proof(&proof_request, + &proof_json, + &schemas_json, + &credential_defs_json, + &rev_reg_defs_json, + &rev_regs_json).unwrap(); + assert!(valid); + + wallet::close_and_delete_wallet(issuer_wallet_handle, &issuer_wallet_config).unwrap(); + wallet::close_and_delete_wallet(prover_wallet_handle, &prover_wallet_config).unwrap(); + } + } diff --git a/libindy/tests/crypto.rs b/libindy/tests/crypto.rs index ae541da73f..5e196dfaa7 100644 --- a/libindy/tests/crypto.rs +++ b/libindy/tests/crypto.rs @@ -246,7 +246,7 @@ mod high_cases { pub struct UnpackMessage { pub message: String, pub sender_verkey: String, - pub recipient_verkey: String + pub recipient_verkey: String, } #[test] @@ -292,7 +292,7 @@ mod high_cases { #[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)] pub struct UnpackMessage { pub message: String, - pub recipient_verkey: String + pub recipient_verkey: String, } #[test] @@ -682,3 +682,30 @@ mod load { time_diff_max, agent_cnt * operations_cnt, time_sum_diff, total_duration); } } + +#[test] // aries-396 +fn crypto_unpack_data_with_and_without_padding_works() { + let setup_trustee = Setup::trustee(); + + let actual_message = "Hello World"; + + // With padding + { + let jwe = json!({ "protected": "eyJlbmMiOiJ4Y2hhY2hhMjBwb2x5MTMwNV9pZXRmIiwidHlwIjoiSldNLzEuMCIsImFsZyI6IkF1dGhjcnlwdCIsInJlY2lwaWVudHMiOlt7ImVuY3J5cHRlZF9rZXkiOiIxamlhNk4zOUhYQVZvQzUzT2xpVE14T0ZobjVKVE1jLXlwOGVXcjVERndJM1psN01HNW5IcFF2ejNMUVJjMUpvIiwiaGVhZGVyIjp7ImtpZCI6IkdKMVN6b1d6YXZRWWZOTDlYa2FKZHJRZWpmenRONFhxZHNpVjRjdDNMWEtMIiwiaXYiOiJGTS1MUktQV1hEQjRGdVVvc1RDQWxYcHR5M2ZCWVZpTCIsInNlbmRlciI6IjQ4Q2l5UXZTWWNmcEdCbzQtSTlkeGpmOW8yamZsQ1ZYVzY0TnFETEVDSFVPVXNnY2ZDLTFWaHQyMzNHZmNqTWYyVWxiNDZzd2pDVjJoUGFCUlNOMDB5YTNCVzBETC11V3FQMXd3NEVET0dBdk1HQUNzeThHY0w5NEhRcz0ifX1dfQ==", "iv": "Q6Nv06ZdUXQ53woe", "ciphertext": "rFsCeJO8mHLwVU4=", "tag": "wt4oAZ74LCW40xRqfdc6Bg==" }); + let jwe = serde_json::to_vec(&jwe).unwrap(); + + let res = crypto::unpack_message(setup_trustee.wallet_handle, &jwe).unwrap(); + let res = serde_json::from_slice::<::serde_json::Value>(res.as_slice()).unwrap(); + assert_eq!(actual_message, res["message"].as_str().unwrap()); + } + + // Without padding + { + let jwe = json!({ "protected": "eyJlbmMiOiJ4Y2hhY2hhMjBwb2x5MTMwNV9pZXRmIiwidHlwIjoiSldNLzEuMCIsImFsZyI6IkF1dGhjcnlwdCIsInJlY2lwaWVudHMiOlt7ImVuY3J5cHRlZF9rZXkiOiJMZENfMzZzRHBFeXI5dGlKOHZLVENhMUFkcExXYWtoUzMxbWtsdk9oQlF3QnFKSVpvV0FrWlZzazRVYUg2VDJXIiwiaGVhZGVyIjp7ImtpZCI6IkdKMVN6b1d6YXZRWWZOTDlYa2FKZHJRZWpmenRONFhxZHNpVjRjdDNMWEtMIiwiaXYiOiJjZjY0LUlHRUh4R09MWXRtRlVSU3F3NWQ2U05fN0xxTCIsInNlbmRlciI6Il9ITDlWUDIxZmtiX2R3QmdTLS1OaVRJY2FjZVVTTGR3UDFtSFRURmJEWEk0MkFLblZDd0tHcXY0bmxHTk5qSHVVampPRUV1cGZYR3drWjZBTGJiNGFtTzJsbHpNQzZLYm9BTVNob19UckpaTVdXbGN2dnljc3VrMlRxYyJ9fV19", "iv": "fzGusjZNVbCo17dT", "ciphertext": "4xrn1rPkpDx4eEg", "tag": "ff3cppEUYi-6yC_ZvWhjoQ" }); + let jwe = serde_json::to_vec(&jwe).unwrap(); + + let res = crypto::unpack_message(setup_trustee.wallet_handle, &jwe).unwrap(); + let res = serde_json::from_slice::<::serde_json::Value>(res.as_slice()).unwrap(); + assert_eq!(actual_message, res["message"].as_str().unwrap()); + } +} \ No newline at end of file diff --git a/libindy/tests/demo.rs b/libindy/tests/demo.rs index 9006ef2801..0baacc7654 100644 --- a/libindy/tests/demo.rs +++ b/libindy/tests/demo.rs @@ -37,8 +37,8 @@ fn anoncreds_demo_works() { let (issuer_create_wallet_receiver, issuer_create_wallet_command_handle, issuer_create_wallet_callback) = callback::_closure_to_cb_ec(); let (prover_create_wallet_receiver, prover_create_wallet_command_handle, prover_create_wallet_callback) = callback::_closure_to_cb_ec(); - let (issuer_open_wallet_receiver, issuer_open_wallet_command_handle, issuer_open_wallet_callback) = callback::_closure_to_cb_ec_i32(); - let (prover_open_wallet_receiver, prover_open_wallet_command_handle, prover_open_wallet_callback) = callback::_closure_to_cb_ec_i32(); + let (issuer_open_wallet_receiver, issuer_open_wallet_command_handle, issuer_open_wallet_callback) = callback::_closure_to_cb_ec_wallethandle(); + let (prover_open_wallet_receiver, prover_open_wallet_command_handle, prover_open_wallet_callback) = callback::_closure_to_cb_ec_wallethandle(); let (issuer_create_schema_receiver, issuer_create_schema_command_handle, issuer_create_schema_callback) = callback::_closure_to_cb_ec_string_string(); let (issuer_create_credential_definition_receiver, issuer_create_credential_definition_command_handle, issuer_create_credential_definition_callback) = callback::_closure_to_cb_ec_string_string(); let (issuer_create_credential_offer_receiver, issuer_create_credential_offer_command_handle, issuer_create_credential_offer_callback) = callback::_closure_to_cb_ec_string(); @@ -489,8 +489,8 @@ fn ledger_demo_works() { let (get_nym_receiver, get_nym_command_handle, get_nym_callback) = callback::_closure_to_cb_ec_string(); let (create_my_wallet_receiver, create_my_wallet_command_handle, create_my_wallet_callback) = callback::_closure_to_cb_ec(); let (create_their_wallet_receiver, create_their_wallet_command_handle, create_their_wallet_callback) = callback::_closure_to_cb_ec(); - let (open_my_wallet_receiver, open_my_wallet_command_handle, open_my_wallet_callback) = callback::_closure_to_cb_ec_i32(); - let (open_their_wallet_receiver, open_their_wallet_command_handle, open_their_wallet_callback) = callback::_closure_to_cb_ec_i32(); + let (open_my_wallet_receiver, open_my_wallet_command_handle, open_my_wallet_callback) = callback::_closure_to_cb_ec_wallethandle(); + let (open_their_wallet_receiver, open_their_wallet_command_handle, open_their_wallet_callback) = callback::_closure_to_cb_ec_wallethandle(); let (create_and_store_my_did_receiver, create_and_store_my_did_command_handle, create_and_store_my_did_callback) = callback::_closure_to_cb_ec_string_string(); let (create_and_store_their_did_receiver, create_and_store_their_did_command_handle, create_and_store_their_did_callback) = callback::_closure_to_cb_ec_string_string(); let (store_their_did_receiver, store_their_did_command_handle, store_their_did_callback) = callback::_closure_to_cb_ec(); @@ -745,13 +745,14 @@ fn crypto_demo_works() { Setup::empty(); let (create_wallet_receiver, create_wallet_command_handle, create_wallet_callback) = callback::_closure_to_cb_ec(); - let (open_wallet_receiver, open_wallet_command_handle, open_wallet_callback) = callback::_closure_to_cb_ec_i32(); + let (open_wallet_receiver, open_wallet_command_handle, open_wallet_callback) = callback::_closure_to_cb_ec_wallethandle(); let (create_and_store_did_receiver, create_and_store_did_command_handle, create_and_store_did_callback) = callback::_closure_to_cb_ec_string_string(); let (sign_receiver, sign_command_handle, sign_callback) = callback::_closure_to_cb_ec_vec_u8(); let (verify_receiver, verify_command_handle, verify_callback) = callback::_closure_to_cb_ec_bool(); let (close_wallet_receiver, close_wallet_command_handle, close_wallet_callback) = callback::_closure_to_cb_ec(); - let wallet_config = json!({"id": "wallet_1"}).to_string(); + let wallet_name = "wallet_crypto_demo_works"; + let wallet_config = json!({"id": wallet_name}).to_string(); // 1. Create Wallet let err = @@ -843,5 +844,5 @@ fn crypto_demo_works() { let res = close_wallet_receiver.recv_timeout(timeout::medium_timeout()).unwrap(); assert_eq!(ErrorCode::from(res), ErrorCode::Success); - utils::test::cleanup_storage("wallet_1"); + utils::test::cleanup_storage(wallet_name); } diff --git a/libindy/tests/did.rs b/libindy/tests/did.rs index 4bc8f9dfed..6e19070d90 100644 --- a/libindy/tests/did.rs +++ b/libindy/tests/did.rs @@ -575,11 +575,14 @@ mod high_cases { fn indy_store_their_did_works_twice() { let setup = Setup::wallet(); - let identity_json = json!({"did": DID}).to_string(); + let identity_json = json!({"did": DID, "verkey": VERKEY}).to_string(); did::store_their_did(setup.wallet_handle, &identity_json).unwrap(); - let res = did::store_their_did(setup.wallet_handle, &identity_json); - assert_code!(ErrorCode::WalletItemAlreadyExists, res); + let identity_json = json!({"did": DID, "verkey": VERKEY_TRUSTEE}).to_string(); + did::store_their_did(setup.wallet_handle, &identity_json).unwrap(); + + let verkey = did::key_for_local_did(setup.wallet_handle, DID).unwrap(); + assert_eq!(VERKEY_TRUSTEE, verkey); } } @@ -973,24 +976,25 @@ mod medium_cases { } #[test] - fn indy_store_their_did_works_for_is_802() { + fn indy_store_my_did_works_for_is_802() { let setup = Setup::wallet(); - let identity_json = json!({"did": DID, "verkey": VERKEY}).to_string(); + let identity_json = json!({"did": DID}).to_string(); - // 1. Try 'storeTheirDid' operation with say did1 and verkey1 - did::store_their_did(setup.wallet_handle, &identity_json).unwrap(); + // 1. Try 'createAndStoreMyDid' operation with say did1 and verkey1 + did::create_my_did(setup.wallet_handle, &identity_json).unwrap(); // 2. Repeat above operation (with same did and ver key used in #1) // but this time catch and swallow the exception (it will throw the exception WalletItemAlreadyExistsException) - let res = did::store_their_did(setup.wallet_handle, &identity_json); - assert_code!(ErrorCode::WalletItemAlreadyExists, res); + let res = did::create_my_did(setup.wallet_handle, &identity_json); + assert_code!(ErrorCode::DidAlreadyExistsError, res); - // 3. Then, now if you try 'storeTheirDid' operation + // 3. Then, now if you try 'createAndStoreMyDid' operation // (either with same did and verkey or you can choose different did and verkey), // in IS-802 it fails with error 'Storage error occurred during wallet operation.' - let res = did::store_their_did(setup.wallet_handle, &identity_json); - assert_code!(ErrorCode::WalletItemAlreadyExists, res); + let res = did::create_my_did + (setup.wallet_handle, &identity_json); + assert_code!(ErrorCode::DidAlreadyExistsError, res); } } diff --git a/libindy/tests/error.rs b/libindy/tests/error.rs index e2703ad243..eec65bc0f3 100644 --- a/libindy/tests/error.rs +++ b/libindy/tests/error.rs @@ -6,6 +6,7 @@ use std::ffi::CStr; use std::str::Utf8Error; use self::libc::c_char; +use indy::CommandHandle; #[test] fn get_current_error_works_for_no_error() { @@ -27,7 +28,7 @@ fn get_current_error_works_for_sync_error_occurred() { #[test] fn get_current_error_works_for_async_error_occurred() { - extern fn cb(_command_handle_: i32, + extern fn cb(_command_handle_: CommandHandle, _err: u32, _verkey: *const c_char) { let mut error_json_p: *const c_char = ptr::null(); @@ -49,8 +50,8 @@ extern { pub fn indy_get_current_error(error_json: *mut *const c_char); #[no_mangle] - pub fn indy_abbreviate_verkey(command_handle: i32, did: *const c_char, full_verkey: *const c_char, - cb: Option) -> i32; } diff --git a/libindy/tests/interaction.rs b/libindy/tests/interaction.rs index 4b84ccb5ed..712c18bcf1 100644 --- a/libindy/tests/interaction.rs +++ b/libindy/tests/interaction.rs @@ -6,6 +6,7 @@ inject_indy_dependencies!(); extern crate indyrs as indy; extern crate indyrs as api; extern crate core; +extern crate indy_sys; use crate::utils::{wallet, anoncreds, blob_storage, pool, ledger, did}; use crate::utils::anoncreds::{COMMON_MASTER_SECRET, CREDENTIAL1_ID}; @@ -30,15 +31,16 @@ use std::thread; use serde_json::Value; use core::borrow::Borrow; +use indy::{PoolHandle, WalletHandle}; struct Pool { - pool_handle: i32 + pool_handle: PoolHandle } struct Issuer { - issuer_wallet_handle: i32, + issuer_wallet_handle: WalletHandle, issuer_wallet_config: String, issuer_did: String, @@ -53,7 +55,7 @@ struct Issuer { struct Prover { - wallet_handle: i32, + wallet_handle: WalletHandle, wallet_config: String, did: String, verkey: String, @@ -81,13 +83,13 @@ impl Pool { } - pub fn submit_nym(&self, issuer_did: &str, issuer_wallet_handle: i32, prover_did: &str, prover_verkey: Option<&str>) + pub fn submit_nym(&self, issuer_did: &str, issuer_wallet_handle: WalletHandle, prover_did: &str, prover_verkey: Option<&str>) { let nym_request = ledger::build_nym_request(issuer_did, prover_did, prover_verkey, None, None).unwrap(); ledger::sign_and_submit_request(self.pool_handle, issuer_wallet_handle, &issuer_did, &nym_request).unwrap(); } - pub fn submit_schema(&self, issuer_did: &str, issuer_wallet_handle: i32, schema_json: &str) -> String { + pub fn submit_schema(&self, issuer_did: &str, issuer_wallet_handle: WalletHandle, schema_json: &str) -> String { let schema_request = ledger::build_schema_request(issuer_did, schema_json).unwrap(); ledger::sign_and_submit_request(self.pool_handle, issuer_wallet_handle, issuer_did, &schema_request).unwrap() } @@ -99,7 +101,7 @@ impl Pool { } - pub fn submit_cred_def(&self, issuer_did: &str, issuer_wallet_handle: i32, cred_def_json: &str) -> String { + pub fn submit_cred_def(&self, issuer_did: &str, issuer_wallet_handle: WalletHandle, cred_def_json: &str) -> String { let cred_def_request = ledger::build_cred_def_txn(issuer_did, cred_def_json).unwrap(); ledger::sign_and_submit_request(self.pool_handle, issuer_wallet_handle, issuer_did, &cred_def_request).unwrap() @@ -111,7 +113,7 @@ impl Pool { ledger::parse_get_cred_def_response(&get_cred_def_response).unwrap() } - pub fn submit_revoc_reg_def(&self, issuer_did: &str, issuer_wallet_handle: i32, rev_reg_def_json: &str) -> String { + pub fn submit_revoc_reg_def(&self, issuer_did: &str, issuer_wallet_handle: WalletHandle, rev_reg_def_json: &str) -> String { let rev_reg_def_request = ledger::build_revoc_reg_def_request(issuer_did, rev_reg_def_json).unwrap(); ledger::sign_and_submit_request(self.pool_handle, issuer_wallet_handle, issuer_did, &rev_reg_def_request).unwrap() } @@ -122,7 +124,7 @@ impl Pool { ledger::parse_get_revoc_reg_def_response(&get_rev_reg_def_response).unwrap() } - pub fn submit_revoc_reg_entry(&self, issuer_did: &str, issuer_wallet_handle: i32, rev_reg_id: &str, rev_reg_entry_json: &str) -> String { + pub fn submit_revoc_reg_entry(&self, issuer_did: &str, issuer_wallet_handle: WalletHandle, rev_reg_id: &str, rev_reg_entry_json: &str) -> String { let rev_reg_entry_request = ledger::build_revoc_reg_entry_request(issuer_did, rev_reg_id, REVOC_REG_TYPE, rev_reg_entry_json).unwrap(); ledger::sign_and_submit_request(self.pool_handle, issuer_wallet_handle, issuer_did, &rev_reg_entry_request).unwrap() diff --git a/libindy/tests/ledger.rs b/libindy/tests/ledger.rs index ccaf0977de..ef3437f915 100644 --- a/libindy/tests/ledger.rs +++ b/libindy/tests/ledger.rs @@ -4,8 +4,6 @@ extern crate indyrs as api; use std::collections::HashMap; use std::thread; -use crate::api::INVALID_POOL_HANDLE; -use crate::api::INVALID_WALLET_HANDLE; #[cfg(feature = "local_nodes_pool")] use crate::utils::{anoncreds, did, ledger, pool}; use crate::utils::constants::*; @@ -24,6 +22,7 @@ use crate::utils::types::*; use self::indy::ErrorCode; use self::rand::distributions::Alphanumeric; +use crate::api::{PoolHandle, WalletHandle, INVALID_WALLET_HANDLE, INVALID_POOL_HANDLE}; #[macro_use] mod utils; @@ -2077,7 +2076,7 @@ mod high_cases { constants::NYM, FIELD, Some("0"), Some("2"), &default_constraint_json); } - fn _change_constraint(pool_handle: i32, wallet_handle: i32, trustee_did: &str, action: &str, txn_type: &str, field: &str, + fn _change_constraint(pool_handle: PoolHandle, wallet_handle: WalletHandle, trustee_did: &str, action: &str, txn_type: &str, field: &str, old_value: Option<&str>, new_value: Option<&str>, constraint: &str) { let auth_rule_request = ledger::build_auth_rule_request(&trustee_did, txn_type, @@ -2090,7 +2089,7 @@ mod high_cases { pool::check_response_type(&response, ResponseType::REPLY); } - fn _get_constraint(pool_handle: i32, action: &str, txn_type: &str, field: &str, + fn _get_constraint(pool_handle: PoolHandle, action: &str, txn_type: &str, field: &str, old_value: Option<&str>, new_value: Option<&str>) -> (serde_json::Value, String) { let get_auth_rule_request = ledger::build_get_auth_rule_request(None, Some(txn_type), @@ -2569,26 +2568,26 @@ mod high_cases { (text, version, digest, ratification_ts) } - fn _send_taa(pool_handle: i32, wallet_handle: i32, trustee_did: &str, taa_text: &str, taa_version: &str, ratification_ts: u64) -> String { + fn _send_taa(pool_handle: PoolHandle, wallet_handle: WalletHandle, trustee_did: &str, taa_text: &str, taa_version: &str, ratification_ts: u64) -> String { let request = ledger::build_txn_author_agreement_request(&trustee_did, Some(taa_text), &taa_version, Some(ratification_ts), None).unwrap(); let response = ledger::sign_and_submit_request(pool_handle, wallet_handle, &trustee_did, &request).unwrap(); pool::check_response_type(&response, ResponseType::REPLY); response } - fn _set_taa(pool_handle: i32, wallet_handle: i32, trustee_did: &str) -> (String, String, String, u64) { + fn _set_taa(pool_handle: PoolHandle, wallet_handle: WalletHandle, trustee_did: &str) -> (String, String, String, u64) { let (taa_text, taa_version, taa_digest, ratification_ts) = _gen_taa_data(); _send_taa(pool_handle, wallet_handle, trustee_did, &taa_text, &taa_version, ratification_ts); (taa_text, taa_version, taa_digest, ratification_ts) } - fn _disable_taa(pool_handle: i32, wallet_handle: i32, trustee_did: &str) { + fn _disable_taa(pool_handle: PoolHandle, wallet_handle: WalletHandle, trustee_did: &str) { let request = ledger::build_disable_all_txn_author_agreements_request(&trustee_did).unwrap(); let response = ledger::sign_and_submit_request(pool_handle, wallet_handle, &trustee_did, &request).unwrap(); pool::check_response_type(&response, ResponseType::REPLY); } - fn _set_aml(pool_handle: i32, wallet_handle: i32, trustee_did: &str) -> (String, String, String, String) { + fn _set_aml(pool_handle: PoolHandle, wallet_handle: WalletHandle, trustee_did: &str) -> (String, String, String, String) { let (aml, aml_label, aml_version, aml_context) = _gen_aml_data(); let request = ledger::build_acceptance_mechanisms_request(trustee_did, &aml.to_string(), &aml_version, Some(&aml_context)).unwrap(); let response = ledger::sign_and_submit_request(pool_handle, wallet_handle, trustee_did, &request).unwrap(); @@ -2680,7 +2679,7 @@ mod high_cases { let setup = Setup::trustee(); _set_aml(setup.pool_handle, setup.wallet_handle, &setup.did); - let (_, taa_version, _, _) = _set_taa(setup.pool_handle, setup.wallet_handle, &setup.did); + let (_, _taa_version, _, _) = _set_taa(setup.pool_handle, setup.wallet_handle, &setup.did); let (did_, verkey_) = did::create_and_store_my_did(setup.wallet_handle, None).unwrap(); @@ -2705,7 +2704,7 @@ mod high_cases { let setup = Setup::trustee(); let (_, aml_label, _, _) = _set_aml(setup.pool_handle, setup.wallet_handle, &setup.did); - let (_, taa_version, _, _) = _set_taa(setup.pool_handle, setup.wallet_handle, &setup.did); + let (_, _taa_version, _, _) = _set_taa(setup.pool_handle, setup.wallet_handle, &setup.did); let (did_, verkey_) = did::create_and_store_my_did(setup.wallet_handle, None).unwrap(); @@ -2731,7 +2730,7 @@ mod high_cases { let setup = Setup::trustee(); _set_aml(setup.pool_handle, setup.wallet_handle, &setup.did); - let (taa_text, taa_version, taa_digest, _) = _set_taa(setup.pool_handle, setup.wallet_handle, &setup.did); + let (taa_text, taa_version, _taa_digest, _) = _set_taa(setup.pool_handle, setup.wallet_handle, &setup.did); let (did_, verkey_) = did::create_and_store_my_did(setup.wallet_handle, None).unwrap(); @@ -2907,7 +2906,7 @@ mod high_cases { mod append_request_endorser { use super::*; - fn _setup_new_identity(wallet_handle: i32, pool_handle: i32) -> String { + fn _setup_new_identity(wallet_handle: WalletHandle, pool_handle: PoolHandle) -> String { let (my_did, my_vk) = did::create_and_store_my_did(wallet_handle, None).unwrap(); let nym = ledger::build_nym_request(DID_TRUSTEE, &my_did, Some(&my_vk), None, None).unwrap(); let response = ledger::sign_and_submit_request(pool_handle, wallet_handle, DID_TRUSTEE, &nym).unwrap(); diff --git a/libindy/tests/non_secrets.rs b/libindy/tests/non_secrets.rs index b6d3017888..9e5963ef88 100644 --- a/libindy/tests/non_secrets.rs +++ b/libindy/tests/non_secrets.rs @@ -17,6 +17,7 @@ use self::indy::ErrorCode; pub const FORBIDDEN_TYPE: &'static str = "Indy::Test"; +use indy::WalletHandle; use crate::utils::test::cleanup_wallet; use crate::utils::Setup; @@ -346,13 +347,14 @@ mod high_cases { mod search { use super::*; + use indy::{WalletHandle, SearchHandle}; - fn setup(name: &str, wallet_config: &str) -> i32{ + fn setup(name: &str, wallet_config: &str) -> WalletHandle { init_non_secret_test_wallet(name, wallet_config); wallet::open_wallet(wallet_config, WALLET_CREDENTIALS).unwrap() } - fn tear_down(wallet_handle: i32, search_handle: i32){ + fn tear_down(wallet_handle: WalletHandle, search_handle: SearchHandle) { close_wallet_search(search_handle).unwrap(); wallet::close_wallet(wallet_handle).unwrap(); } @@ -1143,13 +1145,14 @@ mod medium_cases { mod search { use super::*; + use indy::{WalletHandle, SearchHandle}; - fn setup(name: &str, wallet_config: &str) -> i32{ + fn setup(name: &str, wallet_config: &str) -> WalletHandle { init_non_secret_test_wallet(name, wallet_config); wallet::open_wallet(wallet_config, WALLET_CREDENTIALS).unwrap() } - fn tear_down(wallet_handle: i32, search_handle: i32){ + fn tear_down(wallet_handle: WalletHandle, search_handle: SearchHandle) { close_wallet_search(search_handle).unwrap(); wallet::close_wallet(wallet_handle).unwrap(); } @@ -1266,7 +1269,7 @@ mod medium_cases { } } -fn check_record_field(wallet_handle: i32, type_: &str, id: &str, field: &str, expected_value: &str) { +fn check_record_field(wallet_handle: WalletHandle, type_: &str, id: &str, field: &str, expected_value: &str) { let record = get_wallet_record(wallet_handle, type_, id, OPTIONS_FULL).unwrap(); let record = serde_json::from_str::(&record).unwrap(); diff --git a/libindy/tests/utils/anoncreds.rs b/libindy/tests/utils/anoncreds.rs index d4ba030469..397a880cc8 100644 --- a/libindy/tests/utils/anoncreds.rs +++ b/libindy/tests/utils/anoncreds.rs @@ -21,6 +21,8 @@ use crate::utils::domain::anoncreds::credential::{AttributeValues, CredentialInf use crate::utils::domain::anoncreds::credential_for_proof_request::CredentialsForProofRequest; use crate::utils::domain::crypto::did::DidValue; +use indy::WalletHandle; + pub static mut CREDENTIAL_DEF_JSON: &'static str = ""; pub static mut CREDENTIAL_OFFER_JSON: &'static str = ""; pub static mut CREDENTIAL_REQUEST_JSON: &'static str = ""; @@ -50,35 +52,35 @@ pub fn issuer_create_schema(issuer_did: &str, name: &str, version: &str, attr_na anoncreds::issuer_create_schema(issuer_did, name, version, attr_names).wait() } -pub fn issuer_create_credential_definition(wallet_handle: i32, issuer_did: &str, schema: &str, tag: &str, +pub fn issuer_create_credential_definition(wallet_handle: WalletHandle, issuer_did: &str, schema: &str, tag: &str, signature_type: Option<&str>, config: Option<&str>) -> Result<(String, String), IndyError> { anoncreds::issuer_create_and_store_credential_def(wallet_handle, issuer_did, schema, tag, signature_type, config.unwrap_or("{}")).wait() // TODO: FIXME OPTIONAL CONFIG } -pub fn issuer_rotate_credential_def_start(wallet_handle: i32, cred_def_id: &str, config_json: Option<&str>) -> Result { +pub fn issuer_rotate_credential_def_start(wallet_handle: WalletHandle, cred_def_id: &str, config_json: Option<&str>) -> Result { anoncreds::issuer_rotate_credential_def_start(wallet_handle, cred_def_id, config_json).wait() } -pub fn issuer_rotate_credential_def_apply(wallet_handle: i32, cred_def_id: &str) -> Result<(), IndyError> { +pub fn issuer_rotate_credential_def_apply(wallet_handle: WalletHandle, cred_def_id: &str) -> Result<(), IndyError> { anoncreds::issuer_rotate_credential_def_apply(wallet_handle, cred_def_id).wait() } -pub fn issuer_create_and_store_revoc_reg(wallet_handle: i32, issuer_did: &str, type_: Option<&str>, tag: &str, +pub fn issuer_create_and_store_revoc_reg(wallet_handle: WalletHandle, issuer_did: &str, type_: Option<&str>, tag: &str, cred_def_id: &str, config_json: &str, tails_writer_handle: i32) -> Result<(String, String, String), IndyError> { anoncreds::issuer_create_and_store_revoc_reg(wallet_handle, issuer_did, type_, tag, cred_def_id, config_json, tails_writer_handle).wait() } -pub fn issuer_create_credential_offer(wallet_handle: i32, cred_def_id: &str) -> Result { +pub fn issuer_create_credential_offer(wallet_handle: WalletHandle, cred_def_id: &str) -> Result { anoncreds::issuer_create_credential_offer(wallet_handle, cred_def_id).wait() } -pub fn issuer_create_credential(wallet_handle: i32, cred_offer_json: &str, cred_req_json: &str, cred_values_json: &str, +pub fn issuer_create_credential(wallet_handle: WalletHandle, cred_offer_json: &str, cred_req_json: &str, cred_values_json: &str, rev_reg_id: Option<&str>, blob_storage_reader_handle: Option) -> Result<(String, Option, Option), IndyError> { anoncreds::issuer_create_credential(wallet_handle, cred_offer_json, cred_req_json, cred_values_json, rev_reg_id, blob_storage_reader_handle.unwrap_or(-1)).wait() // TODO OPTIONAL blob_storage_reader_handle } -pub fn issuer_revoke_credential(wallet_handle: i32, blob_storage_reader_handle: i32, rev_reg_id: &str, cred_revoc_id: &str) -> Result { +pub fn issuer_revoke_credential(wallet_handle: WalletHandle, blob_storage_reader_handle: i32, rev_reg_id: &str, cred_revoc_id: &str) -> Result { anoncreds::issuer_revoke_credential(wallet_handle, blob_storage_reader_handle, rev_reg_id, cred_revoc_id).wait() } @@ -86,43 +88,43 @@ pub fn issuer_merge_revocation_registry_deltas(rev_reg_delta: &str, other_rev_re anoncreds::issuer_merge_revocation_registry_deltas(rev_reg_delta, other_rev_reg_delta).wait() } -pub fn prover_create_master_secret(wallet_handle: i32, master_secret_id: &str) -> Result { +pub fn prover_create_master_secret(wallet_handle: WalletHandle, master_secret_id: &str) -> Result { anoncreds::prover_create_master_secret(wallet_handle, Some(master_secret_id)).wait() } -pub fn prover_create_credential_req(wallet_handle: i32, prover_did: &str, cred_offer_json: &str, +pub fn prover_create_credential_req(wallet_handle: WalletHandle, prover_did: &str, cred_offer_json: &str, cred_def_json: &str, master_secret_id: &str) -> Result<(String, String), IndyError> { anoncreds::prover_create_credential_req(wallet_handle, prover_did, cred_offer_json, cred_def_json, master_secret_id).wait() } -pub fn prover_set_credential_attr_tag_policy(wallet_handle: i32, cred_def_id: &str, tag_attrs_json: Option<&str>, +pub fn prover_set_credential_attr_tag_policy(wallet_handle: WalletHandle, cred_def_id: &str, tag_attrs_json: Option<&str>, retroactive: bool) -> Result<(), IndyError> { anoncreds::prover_set_credential_attr_tag_policy(wallet_handle, cred_def_id, tag_attrs_json, retroactive).wait() } -pub fn prover_get_credential_attr_tag_policy(wallet_handle: i32, cred_def_id: &str) -> Result { +pub fn prover_get_credential_attr_tag_policy(wallet_handle: WalletHandle, cred_def_id: &str) -> Result { anoncreds::prover_get_credential_attr_tag_policy(wallet_handle, cred_def_id).wait() } -pub fn prover_store_credential(wallet_handle: i32, cred_id: &str, cred_req_metadata_json: &str, cred_json: &str, +pub fn prover_store_credential(wallet_handle: WalletHandle, cred_id: &str, cred_req_metadata_json: &str, cred_json: &str, cred_def_json: &str, rev_reg_def_json: Option<&str>) -> Result { anoncreds::prover_store_credential(wallet_handle, Some(cred_id), cred_req_metadata_json, cred_json, cred_def_json, rev_reg_def_json).wait() } -pub fn prover_delete_credential(wallet_handle: i32, cred_id: &str) -> Result<(), IndyError> { +pub fn prover_delete_credential(wallet_handle: WalletHandle, cred_id: &str) -> Result<(), IndyError> { anoncreds::prover_delete_credential(wallet_handle, cred_id).wait() } //TODO mark as deprecated and use only in target tests -pub fn prover_get_credentials(wallet_handle: i32, filter_json: &str) -> Result { +pub fn prover_get_credentials(wallet_handle: WalletHandle, filter_json: &str) -> Result { anoncreds::prover_get_credentials(wallet_handle, Some(filter_json)).wait() } -pub fn prover_get_credential(wallet_handle: i32, cred_id: &str) -> Result { +pub fn prover_get_credential(wallet_handle: WalletHandle, cred_id: &str) -> Result { anoncreds::prover_get_credential(wallet_handle, cred_id).wait() } -pub fn prover_search_credentials(wallet_handle: i32, filter_json: &str) -> Result<(i32, usize), IndyError> { +pub fn prover_search_credentials(wallet_handle: WalletHandle, filter_json: &str) -> Result<(i32, usize), IndyError> { anoncreds::prover_search_credentials(wallet_handle, Some(filter_json)).wait() } @@ -135,11 +137,11 @@ pub fn prover_close_credentials_search(search_handle: i32) -> Result<(), IndyErr } //TODO mark as deprecated and use only in target tests -pub fn prover_get_credentials_for_proof_req(wallet_handle: i32, proof_request_json: &str) -> Result { +pub fn prover_get_credentials_for_proof_req(wallet_handle: WalletHandle, proof_request_json: &str) -> Result { anoncreds::prover_get_credentials_for_proof_req(wallet_handle, proof_request_json).wait() } -pub fn prover_search_credentials_for_proof_req(wallet_handle: i32, proof_request_json: &str, extra_query_json: Option<&str>) -> Result { +pub fn prover_search_credentials_for_proof_req(wallet_handle: WalletHandle, proof_request_json: &str, extra_query_json: Option<&str>) -> Result { anoncreds::prover_search_credentials_for_proof_req(wallet_handle, proof_request_json, extra_query_json).wait() } @@ -151,7 +153,7 @@ pub fn prover_close_credentials_search_for_proof_req(search_handle: i32) -> Resu anoncreds::prover_close_credentials_search_for_proof_req(search_handle).wait() } -pub fn prover_create_proof(wallet_handle: i32, proof_req_json: &str, requested_credentials_json: &str, +pub fn prover_create_proof(wallet_handle: WalletHandle, proof_req_json: &str, requested_credentials_json: &str, master_secret_name: &str, schemas_json: &str, cred_defs_json: &str, rev_states_json: &str) -> Result { anoncreds::prover_create_proof(wallet_handle, proof_req_json, requested_credentials_json, @@ -1124,7 +1126,7 @@ pub fn init_common_wallet() -> (&'static str, &'static str, &'static str, &'stat } } -pub fn multi_steps_issuer_preparation(wallet_handle: i32, +pub fn multi_steps_issuer_preparation(wallet_handle: WalletHandle, did: &str, schema_name: &str, schema_attrs: &str) -> (String, String, String, String) { @@ -1143,7 +1145,7 @@ pub fn multi_steps_issuer_preparation(wallet_handle: i32, (schema_id, schema_json, cred_def_id, cred_def_json) } -pub fn multi_steps_issuer_revocation_preparation(wallet_handle: i32, +pub fn multi_steps_issuer_revocation_preparation(wallet_handle: WalletHandle, did: &str, schema_name: &str, schema_attrs: &str, @@ -1181,8 +1183,8 @@ pub fn multi_steps_issuer_revocation_preparation(wallet_handle: i32, } pub fn multi_steps_create_credential(prover_master_secret_id: &str, - prover_wallet_handle: i32, - issuer_wallet_handle: i32, + prover_wallet_handle: WalletHandle, + issuer_wallet_handle: WalletHandle, cred_id: &str, cred_values: &str, cred_def_id: &str, @@ -1215,8 +1217,8 @@ pub fn multi_steps_create_credential(prover_master_secret_id: &str, } pub fn multi_steps_create_revocation_credential(prover_master_secret_id: &str, - prover_wallet_handle: i32, - issuer_wallet_handle: i32, + prover_wallet_handle: WalletHandle, + issuer_wallet_handle: WalletHandle, credential_id: &str, cred_values: &str, cred_def_id: &str, diff --git a/libindy/tests/utils/cache.rs b/libindy/tests/utils/cache.rs index 6b33b6d3eb..9e3d072c39 100644 --- a/libindy/tests/utils/cache.rs +++ b/libindy/tests/utils/cache.rs @@ -4,20 +4,21 @@ use indy::IndyError; use self::futures::Future; use indy::cache; +use indy::{WalletHandle, PoolHandle}; -pub fn get_schema_cache(pool_handle: i32, wallet_handle: i32, submitter_did: &str, id: &str, options_json: &str) -> Result { +pub fn get_schema_cache(pool_handle: PoolHandle, wallet_handle: WalletHandle, submitter_did: &str, id: &str, options_json: &str) -> Result { cache::get_schema(pool_handle, wallet_handle, submitter_did, id, options_json).wait() } -pub fn get_cred_def_cache(pool_handle: i32, wallet_handle: i32, submitter_did: &str, id: &str, options_json: &str) -> Result { +pub fn get_cred_def_cache(pool_handle: PoolHandle, wallet_handle: WalletHandle, submitter_did: &str, id: &str, options_json: &str) -> Result { cache::get_cred_def(pool_handle, wallet_handle, submitter_did, id, options_json).wait() } -pub fn purge_schema_cache(wallet_handle: i32, options_json: &str) -> Result<(), IndyError> { +pub fn purge_schema_cache(wallet_handle: WalletHandle, options_json: &str) -> Result<(), IndyError> { cache::purge_schema_cache(wallet_handle, options_json).wait() } -pub fn purge_cred_def_cache(wallet_handle: i32, options_json: &str) -> Result<(), IndyError> { +pub fn purge_cred_def_cache(wallet_handle: WalletHandle, options_json: &str) -> Result<(), IndyError> { cache::purge_cred_def_cache(wallet_handle, options_json).wait() } \ No newline at end of file diff --git a/libindy/tests/utils/callback.rs b/libindy/tests/utils/callback.rs index 21c8921a26..a2853bc76c 100644 --- a/libindy/tests/utils/callback.rs +++ b/libindy/tests/utils/callback.rs @@ -1,6 +1,8 @@ extern crate indy_sys; -use self::indy_sys::Error as ErrorCode; +use self::indy_sys::{Error as ErrorCode}; + +use indy::{WalletHandle, CommandHandle}; use super::libc::c_char; use std::ffi::CStr; @@ -15,7 +17,7 @@ lazy_static! { } pub fn _closure_to_cb_ec() -> (Receiver, i32, - Option) { let (sender, receiver) = channel(); @@ -27,7 +29,7 @@ pub fn _closure_to_cb_ec() -> (Receiver, i32, sender.send(err).unwrap(); }); - extern "C" fn _callback(command_handle: i32, err: ErrorCode) { + extern "C" fn _callback(command_handle: CommandHandle, err: ErrorCode) { let mut callbacks = CALLBACKS.lock().unwrap(); let mut cb = callbacks.remove(&command_handle).unwrap(); cb(err) @@ -41,7 +43,7 @@ pub fn _closure_to_cb_ec() -> (Receiver, i32, } pub fn _closure_to_cb_ec_i32() -> (Receiver<(ErrorCode, i32)>, i32, - Option) { let (sender, receiver) = channel(); @@ -53,7 +55,7 @@ pub fn _closure_to_cb_ec_i32() -> (Receiver<(ErrorCode, i32)>, i32, sender.send((err, val)).unwrap(); }); - extern "C" fn _callback(command_handle: i32, err: ErrorCode, c_i32: i32) { + extern "C" fn _callback(command_handle: CommandHandle, err: ErrorCode, c_i32: i32) { let mut callbacks = CALLBACKS.lock().unwrap(); let mut cb = callbacks.remove(&command_handle).unwrap(); cb(err, c_i32) @@ -66,8 +68,34 @@ pub fn _closure_to_cb_ec_i32() -> (Receiver<(ErrorCode, i32)>, i32, (receiver, command_handle, Some(_callback)) } +pub fn _closure_to_cb_ec_wallethandle() -> (Receiver<(ErrorCode, WalletHandle)>, CommandHandle, + Option) { + let (sender, receiver) = channel(); + + lazy_static! { + static ref CALLBACKS: Mutex>> = Default::default(); + } + + let closure = Box::new(move |err, val| { + sender.send((err, val)).unwrap(); + }); + + extern "C" fn _callback(command_handle: CommandHandle, err: ErrorCode, c_i32: WalletHandle) { + let mut callbacks = CALLBACKS.lock().unwrap(); + let mut cb = callbacks.remove(&command_handle).unwrap(); + cb(err, c_i32) + } + + let mut callbacks = CALLBACKS.lock().unwrap(); + let command_handle: CommandHandle = (COMMAND_HANDLE_COUNTER.fetch_add(1, Ordering::SeqCst) + 1) as i32; + callbacks.insert(command_handle, closure); + + (receiver, command_handle, Some(_callback)) +} + pub fn _closure_to_cb_ec_i32_usize() -> (Receiver<(ErrorCode, i32, usize)>, i32, - Option) { let (sender, receiver) = channel(); @@ -79,7 +107,7 @@ pub fn _closure_to_cb_ec_i32_usize() -> (Receiver<(ErrorCode, i32, usize)>, i32, sender.send((err, val, val_2)).unwrap(); }); - extern "C" fn _callback(command_handle: i32, err: ErrorCode, c_i32: i32, c_usize: usize) { + extern "C" fn _callback(command_handle: CommandHandle, err: ErrorCode, c_i32: i32, c_usize: usize) { let mut callbacks = CALLBACKS.lock().unwrap(); let mut cb = callbacks.remove(&command_handle).unwrap(); cb(err, c_i32, c_usize) @@ -93,7 +121,7 @@ pub fn _closure_to_cb_ec_i32_usize() -> (Receiver<(ErrorCode, i32, usize)>, i32, } pub fn _closure_to_cb_ec_bool() -> (Receiver<(ErrorCode, bool)>, i32, - Option) { let (sender, receiver) = channel(); @@ -105,7 +133,7 @@ pub fn _closure_to_cb_ec_bool() -> (Receiver<(ErrorCode, bool)>, i32, sender.send((err, val)).unwrap(); }); - extern "C" fn _callback(command_handle: i32, err: ErrorCode, valid: bool) { + extern "C" fn _callback(command_handle: CommandHandle, err: ErrorCode, valid: bool) { let mut callbacks = CALLBACKS.lock().unwrap(); let mut cb = callbacks.remove(&command_handle).unwrap(); cb(err, valid) @@ -119,7 +147,7 @@ pub fn _closure_to_cb_ec_bool() -> (Receiver<(ErrorCode, bool)>, i32, } pub fn _closure_to_cb_ec_string() -> (Receiver<(ErrorCode, String)>, i32, - Option) { let (sender, receiver) = channel(); @@ -132,7 +160,7 @@ pub fn _closure_to_cb_ec_string() -> (Receiver<(ErrorCode, String)>, i32, sender.send((err, val)).unwrap(); }); - extern "C" fn _callback(command_handle: i32, err: ErrorCode, c_str: *const c_char) { + extern "C" fn _callback(command_handle: CommandHandle, err: ErrorCode, c_str: *const c_char) { let mut callbacks = CALLBACKS.lock().unwrap(); let mut cb = callbacks.remove(&command_handle).unwrap(); let metadata = unsafe { CStr::from_ptr(c_str).to_str().unwrap().to_string() }; @@ -147,7 +175,7 @@ pub fn _closure_to_cb_ec_string() -> (Receiver<(ErrorCode, String)>, i32, } pub fn _closure_to_cb_ec_string_string() -> (Receiver<(ErrorCode, String, String)>, i32, - Option) { @@ -161,7 +189,7 @@ pub fn _closure_to_cb_ec_string_string() -> (Receiver<(ErrorCode, String, String sender.send((err, val1, val2)).unwrap(); }); - extern "C" fn _callback(command_handle: i32, err: ErrorCode, str1: *const c_char, str2: *const c_char) { + extern "C" fn _callback(command_handle: CommandHandle, err: ErrorCode, str1: *const c_char, str2: *const c_char) { let mut callbacks = CALLBACKS.lock().unwrap(); let mut cb = callbacks.remove(&command_handle).unwrap(); let str1 = unsafe { CStr::from_ptr(str1).to_str().unwrap().to_string() }; @@ -177,7 +205,7 @@ pub fn _closure_to_cb_ec_string_string() -> (Receiver<(ErrorCode, String, String } pub fn _closure_to_cb_ec_string_string_string() -> (Receiver<(ErrorCode, String, String, String)>, i32, - Option (Receiver<(ErrorCode, String, sender.send((err, val1, val2, val3)).unwrap(); }); - extern "C" fn _callback(command_handle: i32, err: ErrorCode, str1: *const c_char, str2: *const c_char, str3: *const c_char) { + extern "C" fn _callback(command_handle: CommandHandle, err: ErrorCode, str1: *const c_char, str2: *const c_char, str3: *const c_char) { let mut callbacks = CALLBACKS.lock().unwrap(); let mut cb = callbacks.remove(&command_handle).unwrap(); let str1 = unsafe { CStr::from_ptr(str1).to_str().unwrap().to_string() }; @@ -209,7 +237,7 @@ pub fn _closure_to_cb_ec_string_string_string() -> (Receiver<(ErrorCode, String, } pub fn _closure_to_cb_ec_opt_string() -> (Receiver<(ErrorCode, Option)>, i32, - Option) { let (sender, receiver) = channel(); @@ -222,7 +250,7 @@ pub fn _closure_to_cb_ec_opt_string() -> (Receiver<(ErrorCode, Option)>, sender.send((err, val1)).unwrap(); }); - extern "C" fn _callback(command_handle: i32, err: ErrorCode, str1: *const c_char) { + extern "C" fn _callback(command_handle: CommandHandle, err: ErrorCode, str1: *const c_char) { let mut callbacks = CALLBACKS.lock().unwrap(); let mut cb = callbacks.remove(&command_handle).unwrap(); let str1 = if !str1.is_null() { @@ -239,7 +267,7 @@ pub fn _closure_to_cb_ec_opt_string() -> (Receiver<(ErrorCode, Option)>, } pub fn _closure_to_cb_ec_string_opt_string() -> (Receiver<(ErrorCode, String, Option)>, i32, - Option) { @@ -253,7 +281,7 @@ pub fn _closure_to_cb_ec_string_opt_string() -> (Receiver<(ErrorCode, String, Op sender.send((err, val1, val2)).unwrap(); }); - extern "C" fn _callback(command_handle: i32, err: ErrorCode, str1: *const c_char, str2: *const c_char) { + extern "C" fn _callback(command_handle: CommandHandle, err: ErrorCode, str1: *const c_char, str2: *const c_char) { let mut callbacks = CALLBACKS.lock().unwrap(); let mut cb = callbacks.remove(&command_handle).unwrap(); let str1 = unsafe { CStr::from_ptr(str1).to_str().unwrap().to_string() }; @@ -271,7 +299,7 @@ pub fn _closure_to_cb_ec_string_opt_string() -> (Receiver<(ErrorCode, String, Op } pub fn _closure_to_cb_ec_string_opt_string_opt_string() -> (Receiver<(ErrorCode, String, Option, Option)>, i32, - Option (Receiver<(ErrorCode, sender.send((err, val1, val2, val3)).unwrap(); }); - extern "C" fn _callback(command_handle: i32, err: ErrorCode, str1: *const c_char, str2: *const c_char, str3: *const c_char) { + extern "C" fn _callback(command_handle: CommandHandle, err: ErrorCode, str1: *const c_char, str2: *const c_char, str3: *const c_char) { let mut callbacks = CALLBACKS.lock().unwrap(); let mut cb = callbacks.remove(&command_handle).unwrap(); let str1 = unsafe { CStr::from_ptr(str1).to_str().unwrap().to_string() }; @@ -307,7 +335,7 @@ pub fn _closure_to_cb_ec_string_opt_string_opt_string() -> (Receiver<(ErrorCode, } pub fn _closure_to_cb_ec_vec_u8() -> (Receiver<(ErrorCode, Vec)>, i32, - Option) { @@ -321,7 +349,7 @@ pub fn _closure_to_cb_ec_vec_u8() -> (Receiver<(ErrorCode, Vec)>, i32, sender.send((err, val1)).unwrap(); }); - extern "C" fn _callback(command_handle: i32, err: ErrorCode, raw: *const u8, len: u32) { + extern "C" fn _callback(command_handle: CommandHandle, err: ErrorCode, raw: *const u8, len: u32) { let mut callbacks = CALLBACKS.lock().unwrap(); let mut cb = callbacks.remove(&command_handle).unwrap(); let vec = unsafe { slice::from_raw_parts(raw, len as usize) }; @@ -336,7 +364,7 @@ pub fn _closure_to_cb_ec_vec_u8() -> (Receiver<(ErrorCode, Vec)>, i32, } pub fn _closure_to_cb_ec_string_vec_u8() -> (Receiver<(ErrorCode, String, Vec)>, i32, - Option (Receiver<(ErrorCode, String, Vec (Receiver<(ErrorCode, String, Vec (Receiver<(ErrorCode, String, String, u64)>, i32, - Option (Receiver<(ErrorCode, String, St sender.send((err, val1, val2, val3)).unwrap(); }); - extern "C" fn _callback(command_handle: i32, err: ErrorCode, str1: *const c_char, str2: *const c_char, val: u64) { + extern "C" fn _callback(command_handle: CommandHandle, err: ErrorCode, str1: *const c_char, str2: *const c_char, val: u64) { let mut callbacks = CALLBACKS.lock().unwrap(); let mut cb = callbacks.remove(&command_handle).unwrap(); let str1 = unsafe { CStr::from_ptr(str1).to_str().unwrap().to_string() }; diff --git a/libindy/tests/utils/crypto.rs b/libindy/tests/utils/crypto.rs index 4e72a8da7a..32434fcdac 100644 --- a/libindy/tests/utils/crypto.rs +++ b/libindy/tests/utils/crypto.rs @@ -4,20 +4,22 @@ use indy::IndyError; use indy::crypto; use self::futures::Future; -pub fn create_key(wallet_handle: i32, seed: Option<&str>) -> Result { +use indy::WalletHandle; + +pub fn create_key(wallet_handle: WalletHandle, seed: Option<&str>) -> Result { let key_json = json!({"seed": seed}).to_string(); crypto::create_key(wallet_handle, Some(&key_json)).wait() } -pub fn set_key_metadata(wallet_handle: i32, verkey: &str, metadata: &str) -> Result<(), IndyError> { +pub fn set_key_metadata(wallet_handle: WalletHandle, verkey: &str, metadata: &str) -> Result<(), IndyError> { crypto::set_key_metadata(wallet_handle, verkey, metadata).wait() } -pub fn get_key_metadata(wallet_handle: i32, verkey: &str) -> Result { +pub fn get_key_metadata(wallet_handle: WalletHandle, verkey: &str) -> Result { crypto::get_key_metadata(wallet_handle, verkey).wait() } -pub fn sign(wallet_handle: i32, my_vk: &str, msg: &[u8]) -> Result, IndyError> { +pub fn sign(wallet_handle: WalletHandle, my_vk: &str, msg: &[u8]) -> Result, IndyError> { crypto::sign(wallet_handle, my_vk, msg).wait() } @@ -25,11 +27,11 @@ pub fn verify(their_vk: &str, msg: &[u8], signature: &[u8]) -> Result Result, IndyError> { +pub fn auth_crypt(wallet_handle: WalletHandle, my_vk: &str, their_vk: &str, msg: &[u8]) -> Result, IndyError> { crypto::auth_crypt(wallet_handle, my_vk, their_vk, msg).wait() } -pub fn auth_decrypt(wallet_handle: i32, my_vk: &str, msg: &[u8]) -> Result<(String, Vec), IndyError> { +pub fn auth_decrypt(wallet_handle: WalletHandle, my_vk: &str, msg: &[u8]) -> Result<(String, Vec), IndyError> { crypto::auth_decrypt(wallet_handle, my_vk, msg).wait() } @@ -37,14 +39,14 @@ pub fn anon_crypt(their_vk: &str, msg: &[u8]) -> Result, IndyError> { crypto::anon_crypt(their_vk, msg).wait() } -pub fn anon_decrypt(wallet_handle: i32, my_vk: &str, encrypted_msg: &[u8]) -> Result, IndyError> { +pub fn anon_decrypt(wallet_handle: WalletHandle, my_vk: &str, encrypted_msg: &[u8]) -> Result, IndyError> { crypto::anon_decrypt(wallet_handle, my_vk, encrypted_msg).wait() } -pub fn pack_message(wallet_handle: i32, message: &[u8], receiver_keys: &str, sender: Option<&str>) -> Result, IndyError> { +pub fn pack_message(wallet_handle: WalletHandle, message: &[u8], receiver_keys: &str, sender: Option<&str>) -> Result, IndyError> { crypto::pack_message(wallet_handle, message, receiver_keys, sender).wait() } -pub fn unpack_message(wallet_handle: i32, jwe: &[u8]) -> Result, IndyError> { +pub fn unpack_message(wallet_handle: WalletHandle, jwe: &[u8]) -> Result, IndyError> { crypto::unpack_message(wallet_handle, jwe).wait() } \ No newline at end of file diff --git a/libindy/tests/utils/did.rs b/libindy/tests/utils/did.rs index 8747dcf8d7..ec5fb42353 100644 --- a/libindy/tests/utils/did.rs +++ b/libindy/tests/utils/did.rs @@ -6,11 +6,10 @@ use self::futures::Future; use crate::utils::{ledger, pool}; use crate::utils::types::ResponseType; -use crate::api::PoolHandle; use crate::utils::constants::DEFAULT_METHOD_NAME; +use indy::{WalletHandle, PoolHandle}; - -pub fn create_store_and_publish_did(wallet_handle: i32, pool_handle: PoolHandle, role: &str, method_name: Option<&str>) -> Result<(String, String), IndyError> { +pub fn create_store_and_publish_did(wallet_handle: WalletHandle, pool_handle: PoolHandle, role: &str, method_name: Option<&str>) -> Result<(String, String), IndyError> { let my_did_json = json!({"method_name": method_name, "seed": crate::utils::constants::TRUSTEE_SEED}).to_string(); let (trustee_did, _) = create_my_did(wallet_handle, &my_did_json)?; let my_did_json = json!({"method_name": method_name}).to_string(); @@ -21,50 +20,50 @@ pub fn create_store_and_publish_did(wallet_handle: i32, pool_handle: PoolHandle, Ok((did, vk)) } -pub fn create_store_and_publish_my_did_from_trustee(wallet_handle: i32, pool_handle: PoolHandle) -> Result<(String, String), IndyError> { +pub fn create_store_and_publish_my_did_from_trustee(wallet_handle: WalletHandle, pool_handle: PoolHandle) -> Result<(String, String), IndyError> { create_store_and_publish_did(wallet_handle, pool_handle, "TRUSTEE", None) } -pub fn create_store_and_publish_my_did_from_trustee_v1(wallet_handle: i32, pool_handle: PoolHandle) -> Result<(String, String), IndyError> { +pub fn create_store_and_publish_my_did_from_trustee_v1(wallet_handle: WalletHandle, pool_handle: PoolHandle) -> Result<(String, String), IndyError> { create_store_and_publish_did(wallet_handle, pool_handle, "TRUSTEE", Some("sov")) } -pub fn create_store_and_publish_my_did_from_steward(wallet_handle: i32, pool_handle: PoolHandle) -> Result<(String, String), IndyError> { +pub fn create_store_and_publish_my_did_from_steward(wallet_handle: WalletHandle, pool_handle: PoolHandle) -> Result<(String, String), IndyError> { create_store_and_publish_did(wallet_handle, pool_handle, "STEWARD", None) } -pub fn create_and_store_my_did(wallet_handle: i32, seed: Option<&str>) -> Result<(String, String), IndyError> { +pub fn create_and_store_my_did(wallet_handle: WalletHandle, seed: Option<&str>) -> Result<(String, String), IndyError> { let my_did_json = json!({"seed": seed}).to_string(); did::create_and_store_my_did(wallet_handle, &my_did_json).wait() } -pub fn create_and_store_my_did_v1(wallet_handle: i32, seed: Option<&str>) -> Result<(String, String), IndyError> { +pub fn create_and_store_my_did_v1(wallet_handle: WalletHandle, seed: Option<&str>) -> Result<(String, String), IndyError> { let my_did_json = json!({"seed": seed, "method_name": DEFAULT_METHOD_NAME}).to_string(); did::create_and_store_my_did(wallet_handle, &my_did_json).wait() } -pub fn create_my_did(wallet_handle: i32, my_did_json: &str) -> Result<(String, String), IndyError> { +pub fn create_my_did(wallet_handle: WalletHandle, my_did_json: &str) -> Result<(String, String), IndyError> { did::create_and_store_my_did(wallet_handle, my_did_json).wait() } -pub fn store_their_did(wallet_handle: i32, identity_json: &str) -> Result<(), IndyError> { +pub fn store_their_did(wallet_handle: WalletHandle, identity_json: &str) -> Result<(), IndyError> { did::store_their_did(wallet_handle, identity_json).wait() } -pub fn store_their_did_from_parts(wallet_handle: i32, their_did: &str, their_verkey: &str) -> Result<(), IndyError> { +pub fn store_their_did_from_parts(wallet_handle: WalletHandle, their_did: &str, their_verkey: &str) -> Result<(), IndyError> { let their_identity_json = json!({"did": their_did, "verkey": their_verkey}).to_string(); did::store_their_did(wallet_handle, &their_identity_json).wait() } -pub fn replace_keys_start(wallet_handle: i32, did: &str, identity_json: &str) -> Result { +pub fn replace_keys_start(wallet_handle: WalletHandle, did: &str, identity_json: &str) -> Result { did::replace_keys_start(wallet_handle, did, identity_json).wait() } -pub fn replace_keys_apply(wallet_handle: i32, did: &str) -> Result<(), IndyError> { +pub fn replace_keys_apply(wallet_handle: WalletHandle, did: &str) -> Result<(), IndyError> { did::replace_keys_apply(wallet_handle, did).wait() } -pub fn replace_keys(pool_handle: PoolHandle, wallet_handle: i32, did: &str) -> Result { +pub fn replace_keys(pool_handle: PoolHandle, wallet_handle: WalletHandle, did: &str) -> Result { let verkey = did::replace_keys_start(wallet_handle, did, "{}").wait().unwrap(); let nym_request = ledger::build_nym_request(did, did, Some(&verkey), None, None).unwrap(); @@ -75,31 +74,31 @@ pub fn replace_keys(pool_handle: PoolHandle, wallet_handle: i32, did: &str) -> R Ok(verkey) } -pub fn key_for_did(pool_handle: PoolHandle, wallet_handle: i32, did: &str) -> Result { +pub fn key_for_did(pool_handle: PoolHandle, wallet_handle: WalletHandle, did: &str) -> Result { did::key_for_did(pool_handle, wallet_handle, did).wait() } -pub fn key_for_local_did(wallet_handle: PoolHandle, did: &str) -> Result { +pub fn key_for_local_did(wallet_handle: WalletHandle, did: &str) -> Result { did::key_for_local_did(wallet_handle, did).wait() } -pub fn set_endpoint_for_did(wallet_handle: i32, did: &str, address: &str, transport_key: &str) -> Result<(), IndyError> { +pub fn set_endpoint_for_did(wallet_handle: WalletHandle, did: &str, address: &str, transport_key: &str) -> Result<(), IndyError> { did::set_endpoint_for_did(wallet_handle, did, address, transport_key).wait() } -pub fn get_endpoint_for_did(wallet_handle: i32, pool_handle: PoolHandle, did: &str) -> Result<(String, Option), IndyError> { +pub fn get_endpoint_for_did(wallet_handle: WalletHandle, pool_handle: PoolHandle, did: &str) -> Result<(String, Option), IndyError> { did::get_endpoint_for_did(wallet_handle, pool_handle, did).wait() } -pub fn set_did_metadata(wallet_handle: i32, did: &str, metadata: &str) -> Result<(), IndyError> { +pub fn set_did_metadata(wallet_handle: WalletHandle, did: &str, metadata: &str) -> Result<(), IndyError> { did::set_did_metadata(wallet_handle, did, metadata).wait() } -pub fn get_did_metadata(wallet_handle: i32, did: &str) -> Result { +pub fn get_did_metadata(wallet_handle: WalletHandle, did: &str) -> Result { did::get_did_metadata(wallet_handle, did).wait() } -pub fn get_my_did_with_metadata(wallet_handle: i32, did: &str) -> Result { +pub fn get_my_did_with_metadata(wallet_handle: WalletHandle, did: &str) -> Result { did::get_my_did_with_metadata(wallet_handle, did).wait() } @@ -107,6 +106,6 @@ pub fn abbreviate_verkey(did: &str, verkey: &str) -> Result { did::abbreviate_verkey(did, verkey).wait() } -pub fn qualify_did(wallet_handle: i32, did: &str, prefix: &str) -> Result { +pub fn qualify_did(wallet_handle: WalletHandle, did: &str, prefix: &str) -> Result { did::qualify_did(wallet_handle, did, prefix).wait() -} \ No newline at end of file +} diff --git a/libindy/tests/utils/ledger.rs b/libindy/tests/utils/ledger.rs index 780a92dbeb..bc28b6e69d 100644 --- a/libindy/tests/utils/ledger.rs +++ b/libindy/tests/utils/ledger.rs @@ -14,6 +14,8 @@ use std::sync::{Once}; use std::mem; use std::ffi::CString; +use indy::{WalletHandle, PoolHandle}; + pub static mut SCHEMA_ID: &'static str = ""; pub static mut SCHEMA_ID_V2: &'static str = ""; pub static mut CRED_DEF_ID: &'static str = ""; @@ -23,29 +25,29 @@ pub const SCHEMA_DATA: &'static str = r#"{"id":"id","name":"gvt","version":"1.0" const SUBMIT_RETRY_CNT: usize = 3; -pub fn sign_and_submit_request(pool_handle: i32, wallet_handle: i32, submitter_did: &str, request_json: &str) -> Result { +pub fn sign_and_submit_request(pool_handle: PoolHandle, wallet_handle: WalletHandle, submitter_did: &str, request_json: &str) -> Result { ledger::sign_and_submit_request(pool_handle, wallet_handle, submitter_did, request_json).wait() } -pub fn submit_request_with_retries(pool_handle: i32, request_json: &str, previous_response: &str) -> Result { +pub fn submit_request_with_retries(pool_handle: PoolHandle, request_json: &str, previous_response: &str) -> Result { _submit_retry(extract_seq_no_from_reply(previous_response).unwrap(), || { submit_request(pool_handle, request_json) }) } -pub fn submit_request(pool_handle: i32, request_json: &str) -> Result { +pub fn submit_request(pool_handle: PoolHandle, request_json: &str) -> Result { ledger::submit_request(pool_handle, request_json).wait() } -pub fn submit_action(pool_handle: i32, request_json: &str, nodes: Option<&str>, timeout: Option) -> Result { +pub fn submit_action(pool_handle: PoolHandle, request_json: &str, nodes: Option<&str>, timeout: Option) -> Result { ledger::submit_action(pool_handle, request_json, nodes, timeout).wait() } -pub fn sign_request(wallet_handle: i32, submitter_did: &str, request_json: &str) -> Result { +pub fn sign_request(wallet_handle: WalletHandle, submitter_did: &str, request_json: &str) -> Result { ledger::sign_request(wallet_handle, submitter_did, request_json).wait() } -pub fn multi_sign_request(wallet_handle: i32, submitter_did: &str, request_json: &str) -> Result { +pub fn multi_sign_request(wallet_handle: WalletHandle, submitter_did: &str, request_json: &str) -> Result { ledger::multi_sign_request(wallet_handle, submitter_did, request_json).wait() } diff --git a/libindy/tests/utils/mod.rs b/libindy/tests/utils/mod.rs index 7490832b5b..aa0e3bdc14 100644 --- a/libindy/tests/utils/mod.rs +++ b/libindy/tests/utils/mod.rs @@ -3,6 +3,8 @@ extern crate libc; extern crate indyrs as indy; +use indy::{WalletHandle, PoolHandle, INVALID_WALLET_HANDLE, INVALID_POOL_HANDLE}; + pub mod callback; #[path = "../../indy-utils/src/environment.rs"] @@ -45,6 +47,7 @@ pub mod ctypes; pub mod qualifier; pub(crate) use indy::ErrorCode; + #[path = "../../indy-utils/src/inmem_wallet.rs"] pub mod inmem_wallet; @@ -90,6 +93,7 @@ macro_rules! inject_indy_dependencies { extern crate regex; extern crate time; extern crate libc; + extern crate dirs; } } @@ -107,8 +111,8 @@ fn tear_down(name: &str) { pub struct Setup { pub name: String, pub wallet_config: String, - pub wallet_handle: i32, - pub pool_handle: i32, + pub wallet_handle: WalletHandle, + pub pool_handle: PoolHandle, pub did: String, pub verkey: String } @@ -116,25 +120,25 @@ pub struct Setup { impl Setup { pub fn empty() -> Setup { let name = setup(); - Setup { name, wallet_config: String::new(), wallet_handle: 0, pool_handle: 0, did: String::new(), verkey: String::new() } + Setup { name, wallet_config: String::new(), wallet_handle: INVALID_WALLET_HANDLE, pool_handle: INVALID_POOL_HANDLE, did: String::new(), verkey: String::new() } } pub fn wallet() -> Setup { let name = setup(); let (wallet_handle, wallet_config) = wallet::create_and_open_default_wallet(&name).unwrap(); - Setup { name, wallet_config, wallet_handle, pool_handle: 0, did: String::new(), verkey: String::new() } + Setup { name, wallet_config, wallet_handle, pool_handle: INVALID_POOL_HANDLE, did: String::new(), verkey: String::new() } } pub fn plugged_wallet() -> Setup { let name = setup(); let (wallet_handle, wallet_config) = wallet::create_and_open_plugged_wallet().unwrap(); - Setup { name, wallet_config, wallet_handle, pool_handle: 0, did: String::new(), verkey: String::new() } + Setup { name, wallet_config, wallet_handle, pool_handle: INVALID_POOL_HANDLE, did: String::new(), verkey: String::new() } } pub fn pool() -> Setup { let name = setup(); let pool_handle = pool::create_and_open_pool_ledger(&name).unwrap(); - Setup { name, wallet_config: String::new(), wallet_handle: 0, pool_handle, did: String::new(), verkey: String::new() } + Setup { name, wallet_config: String::new(), wallet_handle: INVALID_WALLET_HANDLE, pool_handle, did: String::new(), verkey: String::new() } } pub fn wallet_and_pool() -> Setup { @@ -202,29 +206,29 @@ impl Setup { let name = setup(); let (wallet_handle, wallet_config) = wallet::create_and_open_default_wallet(&name).unwrap(); let verkey = crypto::create_key(wallet_handle, None).unwrap(); - Setup { name, wallet_config, wallet_handle, pool_handle: 0, did: String::new(), verkey } + Setup { name, wallet_config, wallet_handle, pool_handle: INVALID_POOL_HANDLE, did: String::new(), verkey } } pub fn payment() -> Setup { let name = setup(); payments::mock_method::init(); - Setup { name, wallet_config: String::new(), wallet_handle: 0, pool_handle: 0, did: String::new(), verkey: String::new() } + Setup { name, wallet_config: String::new(), wallet_handle: INVALID_WALLET_HANDLE, pool_handle: INVALID_POOL_HANDLE, did: String::new(), verkey: String::new() } } pub fn payment_wallet() -> Setup { let name = setup(); let (wallet_handle, wallet_config) = wallet::create_and_open_default_wallet(&name).unwrap(); payments::mock_method::init(); - Setup { name, wallet_config, wallet_handle, pool_handle: 0, did: String::new(), verkey: String::new() } + Setup { name, wallet_config, wallet_handle, pool_handle: INVALID_POOL_HANDLE, did: String::new(), verkey: String::new() } } } impl Drop for Setup { fn drop(&mut self) { - if self.wallet_handle != 0 { + if self.wallet_handle != INVALID_WALLET_HANDLE { wallet::close_and_delete_wallet(self.wallet_handle, &self.wallet_config).unwrap(); } - if self.pool_handle != 0 { + if self.pool_handle != INVALID_POOL_HANDLE { pool::close(self.pool_handle).unwrap(); } tear_down(&self.name); diff --git a/libindy/tests/utils/non_secrets.rs b/libindy/tests/utils/non_secrets.rs index 917dff77be..55547971cd 100644 --- a/libindy/tests/utils/non_secrets.rs +++ b/libindy/tests/utils/non_secrets.rs @@ -12,6 +12,8 @@ use crate::utils::types::WalletRecord; use std::sync::Once; use std::collections::HashMap; +use indy::WalletHandle; + pub const SEARCH_COMMON_WALLET_CONFIG: &'static str = r#"{"id":"search_common"}"#; pub const TYPE: &'static str = "TestType"; pub const TYPE_2: &'static str = "TestType2"; @@ -36,39 +38,39 @@ pub const TAGS_3: &'static str = r#"{"tagName1":"str1","tagName2":"str2","tagNam pub const TAGS_4: &'static str = r#"{"tagName1":"somestr","~tagName2":"4","~tagName3":"5"}"#; pub const TAGS_5: &'static str = r#"{"tagName1":"prefix_str2","~tagName2":"str3","~tagName3":"6"}"#; -pub fn add_wallet_record(wallet_handle: i32, type_: &str, id: &str, value: &str, tags_json: Option<&str>) -> Result<(), IndyError> { +pub fn add_wallet_record(wallet_handle: WalletHandle, type_: &str, id: &str, value: &str, tags_json: Option<&str>) -> Result<(), IndyError> { wallet::add_wallet_record(wallet_handle, type_, id, value, tags_json).wait() } -pub fn update_wallet_record_value(wallet_handle: i32, type_: &str, id: &str, value: &str) -> Result<(), IndyError> { +pub fn update_wallet_record_value(wallet_handle: WalletHandle, type_: &str, id: &str, value: &str) -> Result<(), IndyError> { wallet::update_wallet_record_value(wallet_handle, type_, id, value).wait() } -pub fn update_wallet_record_tags(wallet_handle: i32, type_: &str, id: &str, tags_json: &str) -> Result<(), IndyError> { +pub fn update_wallet_record_tags(wallet_handle: WalletHandle, type_: &str, id: &str, tags_json: &str) -> Result<(), IndyError> { wallet::update_wallet_record_tags(wallet_handle, type_, id, tags_json).wait() } -pub fn add_wallet_record_tags(wallet_handle: i32, type_: &str, id: &str, tags_json: &str) -> Result<(), IndyError> { +pub fn add_wallet_record_tags(wallet_handle: WalletHandle, type_: &str, id: &str, tags_json: &str) -> Result<(), IndyError> { wallet::add_wallet_record_tags(wallet_handle, type_, id, tags_json).wait() } -pub fn delete_wallet_record_tags(wallet_handle: i32, type_: &str, id: &str, tag_names_json: &str) -> Result<(), IndyError> { +pub fn delete_wallet_record_tags(wallet_handle: WalletHandle, type_: &str, id: &str, tag_names_json: &str) -> Result<(), IndyError> { wallet::delete_wallet_record_tags(wallet_handle, type_, id, tag_names_json).wait() } -pub fn delete_wallet_record(wallet_handle: i32, type_: &str, id: &str) -> Result<(), IndyError> { +pub fn delete_wallet_record(wallet_handle: WalletHandle, type_: &str, id: &str) -> Result<(), IndyError> { wallet::delete_wallet_record(wallet_handle, type_, id).wait() } -pub fn get_wallet_record(wallet_handle: i32, type_: &str, id: &str, options_json: &str) -> Result { +pub fn get_wallet_record(wallet_handle: WalletHandle, type_: &str, id: &str, options_json: &str) -> Result { wallet::get_wallet_record(wallet_handle, type_, id, options_json).wait() } -pub fn open_wallet_search(wallet_handle: i32, type_: &str, query_json: &str, options_json: &str) -> Result { +pub fn open_wallet_search(wallet_handle: WalletHandle, type_: &str, query_json: &str, options_json: &str) -> Result { wallet::open_wallet_search(wallet_handle, type_, query_json, options_json).wait() } -pub fn fetch_wallet_search_next_records(wallet_handle: i32, wallet_search_handle: i32, count: usize) -> Result { +pub fn fetch_wallet_search_next_records(wallet_handle: WalletHandle, wallet_search_handle: i32, count: usize) -> Result { wallet::fetch_wallet_search_next_records(wallet_handle, wallet_search_handle, count).wait() } diff --git a/libindy/tests/utils/pairwise.rs b/libindy/tests/utils/pairwise.rs index 1db5d430b3..b8442600b4 100644 --- a/libindy/tests/utils/pairwise.rs +++ b/libindy/tests/utils/pairwise.rs @@ -4,22 +4,24 @@ use indy::IndyError; use indy::pairwise; use self::futures::Future; -pub fn pairwise_exists(wallet_handle: i32, their_did: &str) -> Result { +use indy::WalletHandle; + +pub fn pairwise_exists(wallet_handle: WalletHandle, their_did: &str) -> Result { pairwise::is_pairwise_exists(wallet_handle, their_did).wait() } -pub fn create_pairwise(wallet_handle: i32, their_did: &str, my_did: &str, metadata: Option<&str>) -> Result<(), IndyError> { +pub fn create_pairwise(wallet_handle: WalletHandle, their_did: &str, my_did: &str, metadata: Option<&str>) -> Result<(), IndyError> { pairwise::create_pairwise(wallet_handle, their_did, my_did, metadata).wait() } -pub fn list_pairwise(wallet_handle: i32) -> Result { +pub fn list_pairwise(wallet_handle: WalletHandle) -> Result { pairwise::list_pairwise(wallet_handle).wait() } -pub fn get_pairwise(wallet_handle: i32, their_did: &str) -> Result { +pub fn get_pairwise(wallet_handle: WalletHandle, their_did: &str) -> Result { pairwise::get_pairwise(wallet_handle, their_did).wait() } -pub fn set_pairwise_metadata(wallet_handle: i32, their_did: &str, metadata: Option<&str>) -> Result<(), IndyError> { +pub fn set_pairwise_metadata(wallet_handle: WalletHandle, their_did: &str, metadata: Option<&str>) -> Result<(), IndyError> { pairwise::set_pairwise_metadata(wallet_handle, their_did, metadata).wait() } \ No newline at end of file diff --git a/libindy/tests/utils/payments.rs b/libindy/tests/utils/payments.rs index c56b718339..5c9d46b9b5 100644 --- a/libindy/tests/utils/payments.rs +++ b/libindy/tests/utils/payments.rs @@ -11,6 +11,7 @@ use std::ffi::CString; use super::libc::c_char; use std::sync::{Once, Mutex}; +use indy::{WalletHandle, CommandHandle}; use crate::utils::callback; #[macro_export] @@ -22,7 +23,7 @@ macro_rules! mocked_handler { static ref INJECTIONS: Mutex> = Default::default(); } - pub extern fn handle(cmd_handle: i32, + pub extern fn handle(cmd_handle: CommandHandle, $first_param_name: $first_param_type, $($param_name: $param_type,)* cb: Option) -> i32 { @@ -69,10 +70,10 @@ macro_rules! mocked_handler_slice { static ref INJECTIONS: Mutex)>> = Default::default(); } - pub extern fn handle(cmd_handle: i32, + pub extern fn handle(cmd_handle: CommandHandle, $first_param_name: $first_param_type, $($param_name: $param_type,)* - cb: Option) -> i32 { + cb: Option) -> i32 { let cb = cb.unwrap_or_else(|| { panic!("Null passed as callback!") @@ -116,10 +117,10 @@ macro_rules! mocked_handler_bool { static ref INJECTIONS: Mutex> = Default::default(); } - pub extern fn handle(cmd_handle: i32, + pub extern fn handle(cmd_handle: CommandHandle, $first_param_name: $first_param_type, $($param_name: $param_type,)* - cb: Option) -> i32 { + cb: Option) -> i32 { let cb = cb.unwrap_or_else(|| { panic!("Null passed as callback!") @@ -155,11 +156,11 @@ macro_rules! mocked_handler_bool { ) } -type IndyPaymentCallback = extern fn(command_handle_: i32, +type IndyPaymentCallback = extern fn(command_handle_: CommandHandle, err: i32, payment_address: *const c_char) -> i32; -type ParsePaymentSourcesCallback = extern fn(command_handle_: i32, +type ParsePaymentSourcesCallback = extern fn(command_handle_: CommandHandle, err: i32, payment_address: *const c_char, next: i64) -> i32; @@ -202,11 +203,11 @@ pub mod mock_method { } pub mod create_payment_address { - mocked_handler!(_wallet_handle: i32, _config: *const c_char); + mocked_handler!(_wallet_handle: WalletHandle, _config: *const c_char); } pub mod add_request_fees { - mocked_handler!(_wallet_handle: i32, _submitter_did: *const c_char, _req_json: *const c_char, _inputs_json: *const c_char, _outputs_json: *const c_char, _extra: *const c_char); + mocked_handler!(_wallet_handle: WalletHandle, _submitter_did: *const c_char, _req_json: *const c_char, _inputs_json: *const c_char, _outputs_json: *const c_char, _extra: *const c_char); } pub mod parse_response_with_fees { @@ -214,7 +215,7 @@ pub mod mock_method { } pub mod build_get_payment_sources_request { - mocked_handler!(_wallet_handle: i32, _submitter_did: *const c_char, _payment_address: *const c_char, _from: i64); + mocked_handler!(_wallet_handle: WalletHandle, _submitter_did: *const c_char, _payment_address: *const c_char, _from: i64); } pub mod parse_get_payment_sources_response { @@ -224,7 +225,7 @@ pub mod mock_method { static ref INJECTIONS: Mutex> = Default::default(); } - pub extern fn handle(cmd_handle: i32, + pub extern fn handle(cmd_handle: CommandHandle, _response: *const c_char, cb: Option) -> i32 { let cb = cb.unwrap_or_else(|| { @@ -261,7 +262,7 @@ pub mod mock_method { } pub mod build_payment_req { - mocked_handler!(_wallet_handle: i32, _submitter_did: *const c_char, _inputs_json: *const c_char, _outputs_json: *const c_char, _extra: *const c_char); + mocked_handler!(_wallet_handle: WalletHandle, _submitter_did: *const c_char, _inputs_json: *const c_char, _outputs_json: *const c_char, _extra: *const c_char); } pub mod parse_payment_response { @@ -269,15 +270,15 @@ pub mod mock_method { } pub mod build_mint_req { - mocked_handler!(_wallet_handle: i32, _submitter_did: *const c_char, _outputs_json: *const c_char, _extra: *const c_char); + mocked_handler!(_wallet_handle: WalletHandle, _submitter_did: *const c_char, _outputs_json: *const c_char, _extra: *const c_char); } pub mod build_set_txn_fees_req { - mocked_handler!(_wallet_handle: i32, _submitter_did: *const c_char, _fees_json: *const c_char); + mocked_handler!(_wallet_handle: WalletHandle, _submitter_did: *const c_char, _fees_json: *const c_char); } pub mod build_get_txn_fees_req { - mocked_handler!(_wallet_handle: i32, _submitter_did: *const c_char); + mocked_handler!(_wallet_handle: WalletHandle, _submitter_did: *const c_char); } pub mod parse_get_txn_fees_response { @@ -285,7 +286,7 @@ pub mod mock_method { } pub mod build_verify_payment_req { - mocked_handler!(_wallet_handle: i32, _submitter_did: *const c_char, _receipt: *const c_char); + mocked_handler!(_wallet_handle: WalletHandle, _submitter_did: *const c_char, _receipt: *const c_char); } pub mod parse_verify_payment_response { @@ -293,7 +294,7 @@ pub mod mock_method { } pub mod sign_with_address { - mocked_handler_slice!(_wallet_handle: i32, _address: *const c_char, _message_raw: *const u8, _message_len: u32); + mocked_handler_slice!(_wallet_handle: WalletHandle, _address: *const c_char, _message_raw: *const u8, _message_len: u32); } pub mod verify_with_address { @@ -347,28 +348,28 @@ pub fn register_payment_method(payment_method_name: &str, super::results::result_to_empty(err, receiver) } -pub fn create_payment_address(wallet_handle: i32, config: &str, payment_method: &str) -> Result { +pub fn create_payment_address(wallet_handle: WalletHandle, config: &str, payment_method: &str) -> Result { payments::create_payment_address(wallet_handle, payment_method, config).wait() } -pub fn list_payment_addresses(wallet_handle: i32) -> Result { +pub fn list_payment_addresses(wallet_handle: WalletHandle) -> Result { payments::list_payment_addresses(wallet_handle).wait() } -pub fn add_request_fees(wallet_handle: i32, submitter_did: Option<&str>, req_json: &str, inputs_json: &str, outputs_json: &str, extra: Option<&str>) -> Result<(String, String), IndyError> { +pub fn add_request_fees(wallet_handle: WalletHandle, submitter_did: Option<&str>, req_json: &str, inputs_json: &str, outputs_json: &str, extra: Option<&str>) -> Result<(String, String), IndyError> { payments::add_request_fees(wallet_handle, submitter_did, req_json, inputs_json, outputs_json, extra).wait() } #[allow(deprecated)] -pub fn build_get_payment_sources_request(wallet_handle: i32, submitter_did: Option<&str>, payment_address: &str) -> Result<(String, String), IndyError> { +pub fn build_get_payment_sources_request(wallet_handle: WalletHandle, submitter_did: Option<&str>, payment_address: &str) -> Result<(String, String), IndyError> { payments::build_get_payment_sources_request(wallet_handle, submitter_did, payment_address).wait() } -pub fn build_get_payment_sources_with_from_request(wallet_handle: i32, submitter_did: Option<&str>, payment_address: &str, from: Option) -> Result<(String, String), IndyError> { +pub fn build_get_payment_sources_with_from_request(wallet_handle: WalletHandle, submitter_did: Option<&str>, payment_address: &str, from: Option) -> Result<(String, String), IndyError> { payments::build_get_payment_sources_with_from_request(wallet_handle, submitter_did, payment_address, from).wait() } -pub fn build_payment_req(wallet_handle: i32, submitter_did: Option<&str>, inputs_json: &str, outputs_json: &str, extra: Option<&str>) -> Result<(String, String), IndyError> { +pub fn build_payment_req(wallet_handle: WalletHandle, submitter_did: Option<&str>, inputs_json: &str, outputs_json: &str, extra: Option<&str>) -> Result<(String, String), IndyError> { payments::build_payment_req(wallet_handle, submitter_did, inputs_json, outputs_json, extra).wait() } @@ -398,15 +399,15 @@ pub fn prepare_extra_with_acceptance_data(extra: Option<&str>, payments::prepare_extra_with_acceptance_data(extra, text, version, taa_digest, acc_mech_type, time_of_acceptance).wait() } -pub fn build_mint_req(wallet_handle: i32, submitter_did: Option<&str>, outputs_json: &str, extra: Option<&str>) -> Result<(String, String), IndyError> { +pub fn build_mint_req(wallet_handle: WalletHandle, submitter_did: Option<&str>, outputs_json: &str, extra: Option<&str>) -> Result<(String, String), IndyError> { payments::build_mint_req(wallet_handle, submitter_did, outputs_json, extra).wait() } -pub fn build_set_txn_fees_req(wallet_handle: i32, submitter_did: Option<&str>, payment_method: &str, fees_json: &str) -> Result { +pub fn build_set_txn_fees_req(wallet_handle: WalletHandle, submitter_did: Option<&str>, payment_method: &str, fees_json: &str) -> Result { payments::build_set_txn_fees_req(wallet_handle, submitter_did, payment_method, fees_json).wait() } -pub fn build_get_txn_fees_req(wallet_handle: i32, submitter_did: Option<&str>, payment_method: &str) -> Result { +pub fn build_get_txn_fees_req(wallet_handle: WalletHandle, submitter_did: Option<&str>, payment_method: &str) -> Result { payments::build_get_txn_fees_req(wallet_handle, submitter_did, payment_method).wait() } @@ -414,7 +415,7 @@ pub fn parse_get_txn_fees_response(payment_method: &str, resp_json: &str) -> Res payments::parse_get_txn_fees_response(payment_method, resp_json).wait() } -pub fn build_verify_payment_req(wallet_handle: i32, submitter_did: Option<&str>, receipt: &str) -> Result<(String, String), IndyError> { +pub fn build_verify_payment_req(wallet_handle: WalletHandle, submitter_did: Option<&str>, receipt: &str) -> Result<(String, String), IndyError> { payments::build_verify_payment_req(wallet_handle, submitter_did, receipt).wait() } @@ -426,10 +427,10 @@ pub fn get_request_info(get_auth_rule_resp_json: &str, requester_info_json: &str payments::get_request_info(get_auth_rule_resp_json, requester_info_json, fees_json).wait() } -pub fn sign_with_address(wallet_handle: i32, address: &str, message: &[u8]) -> Result, IndyError> { +pub fn sign_with_address(wallet_handle: WalletHandle, address: &str, message: &[u8]) -> Result, IndyError> { payments::sign_with_address(wallet_handle, address, message).wait() } pub fn verify_with_address(address: &str, message: &[u8], signature: &[u8]) -> Result { payments::verify_with_address(address, message, signature).wait() -} \ No newline at end of file +} diff --git a/libindy/tests/utils/wallet.rs b/libindy/tests/utils/wallet.rs index 68526a3abf..fffc765047 100644 --- a/libindy/tests/utils/wallet.rs +++ b/libindy/tests/utils/wallet.rs @@ -18,7 +18,7 @@ use super::libc::c_char; use crate::utils::constants::{TYPE, INMEM_TYPE, WALLET_CREDENTIALS}; use std::path::{Path, PathBuf}; -use indy_api_types::{WalletHandle, CommandHandle}; +use indy::{WalletHandle, CommandHandle}; pub fn register_wallet_storage(xtype: &str, force_create: bool) -> Result<(), ErrorCode> { lazy_static! { diff --git a/libnullpay/Cargo.lock b/libnullpay/Cargo.lock index 5fd424bd78..122b769833 100644 --- a/libnullpay/Cargo.lock +++ b/libnullpay/Cargo.lock @@ -5,7 +5,7 @@ name = "aho-corasick" version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "memchr 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -20,7 +20,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "android_log-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -45,7 +45,7 @@ name = "atty" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -62,7 +62,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -72,8 +72,8 @@ name = "backtrace-sys" version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -130,7 +130,7 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.27" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -164,7 +164,7 @@ name = "dirs" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "redox_users 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -175,30 +175,30 @@ version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "failure" -version = "0.1.3" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "failure_derive" -version = "0.1.3" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.23 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -245,13 +245,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "humantime" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -259,28 +259,30 @@ dependencies = [ [[package]] name = "indy" -version = "1.14.1" +version = "1.14.2" dependencies = [ - "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "indy-sys 1.14.1", + "indy-sys 1.14.2", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "num-derive 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "indy-sys" -version = "1.14.1" +version = "1.14.2" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -296,12 +298,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.60" +version = "0.2.66" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "log" -version = "0.4.6" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -312,18 +314,13 @@ name = "log-panics" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "memchr" -version = "2.1.2" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "nodrop" @@ -332,19 +329,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "null-payment-method" -version = "1.14.1" +version = "1.14.2" dependencies = [ "android_logger 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "dirs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", - "indy 1.14.1", + "indy 1.14.2", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "log-panics 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -388,6 +385,14 @@ dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "proc-macro2" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "quick-error" version = "1.2.2" @@ -401,13 +406,21 @@ dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "quote" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -417,7 +430,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "getrandom 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -468,7 +481,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -479,7 +492,7 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -510,17 +523,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.97" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde_derive" -version = "1.0.97" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.23 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -530,7 +543,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -554,15 +567,25 @@ dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "syn" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "synstructure" -version = "0.10.1" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.23 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -578,7 +601,7 @@ name = "termion" version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -606,6 +629,11 @@ name = "unicode-xid" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "unicode-xid" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "utf8-ranges" version = "1.0.2" @@ -616,11 +644,6 @@ name = "vcpkg" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "version_check" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "winapi" version = "0.3.6" @@ -674,15 +697,15 @@ dependencies = [ "checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" -"checksum cc 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)" = "155ed195f7bd722d1dfeb30365b9d0c1f6a078fa7ca4014497e5935d90993d6f" +"checksum cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "8dae9c4b8fedcae85592ba623c4fd08cfdab3e3b72d6df780c6ead964a69bfff" "checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" "checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" "checksum dirs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "88972de891f6118092b643d85a0b28e0678e0f948d7f879aa32f2d5aafe97d2a" "checksum env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)" = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38" -"checksum failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6dd377bcc1b1b7ce911967e3ec24fa19c3224394ec05b54aa7b083d498341ac7" -"checksum failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "64c2d913fe8ed3b6c6518eedf4538255b989945c14c2a7d5cbff62a5e2120596" +"checksum failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" +"checksum failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" @@ -690,13 +713,13 @@ dependencies = [ "checksum futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)" = "49e7653e374fe0d0c12de4250f0bdb60680b8c80eed558c5c7538eec9c89e21b" "checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" "checksum getrandom 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e738b1f02e4d17217cae7648e774c03a19cd9de18bc294c538cc3e780f8c3bbd" -"checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" +"checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -"checksum libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "d44e80633f007889c7eff624b709ab43c92d708caad982295768a7b13ca3b5eb" -"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" +"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" +"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum log-panics 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ae0136257df209261daa18d6c16394757c63e032e27aafd8b07788b051082bef" -"checksum memchr 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "db4c41318937f6e76648f42826b1d9ade5c09cafb5aef7e351240a70f39206e9" +"checksum memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3197e20c7edb283f87c071ddfc7a2cca8f8e0b888c242959846a6fce03c72223" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum num-derive 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8af1847c907c2f04d7bfd572fb25bbb4385c637fe5be163cf2f8c5d778fe1e7d" "checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1" @@ -704,8 +727,10 @@ dependencies = [ "checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" "checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" "checksum proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)" = "77619697826f31a02ae974457af0b29b723e5619e113e9397b8b82c6bd253f09" +"checksum proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "53fa22a1994bd0f9372d7a816207d8a2677ad0325b073f5c5332760f0fb62b5c" +"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" "checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd" "checksum rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c" "checksum rand_chacha 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e193067942ef6f485a349a113329140d0ab9e2168ce92274499bb0e9a4190d9d" @@ -719,21 +744,22 @@ dependencies = [ "checksum rustc-demangle 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "01b90379b8664dd83460d59bdc5dd1fd3172b8913788db483ed1325171eab2f7" "checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" "checksum scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8" -"checksum serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)" = "d46b3dfedb19360a74316866cef04687cd4d6a70df8e6a506c63512790769b72" -"checksum serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)" = "c22a0820adfe2f257b098714323563dd06426502abbbce4f51b72ef544c5027f" +"checksum serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" +"checksum serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" "checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" "checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d" "checksum syn 0.15.23 (registry+https://github.com/rust-lang/crates.io-index)" = "9545a6a093a3f0bd59adb472700acc08cad3776f860f16a897dfce8c88721cbc" -"checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" +"checksum syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5" +"checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" +"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" "checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737" "checksum vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "def296d3eb3b12371b2c7d0e83bfe1403e4db2d7a0bba324a12b21c4ee13143d" -"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" "checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "afc5508759c5bf4285e61feb862b6083c8480aec864fa17a81fdec6f69b461ab" diff --git a/libnullpay/Cargo.toml b/libnullpay/Cargo.toml index aeffa16708..afb049af5c 100644 --- a/libnullpay/Cargo.toml +++ b/libnullpay/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "null-payment-method" -version = "1.14.1" +version = "1.14.2" authors = ["Hyperledger Indy Contributors "] build = "build.rs" @@ -14,7 +14,7 @@ fatal_warnings = [] [dependencies] lazy_static = "1.3" -libc = "0.2.60" +libc = "0.2.66" env_logger = "0.5.10" log = "0.4.1" log-panics = "2.0.0" @@ -26,7 +26,7 @@ serde_derive = "1.0.97" [dev-dependencies] dirs = "1.0.4" -indy = { version="1.14.1", path="../wrappers/rust" } +indy = { version="1.14.2", path="../wrappers/rust" } [target.'cfg(target_os = "android")'.dependencies] android_logger = "0.5" diff --git a/libnullpay/debian/changelog b/libnullpay/debian/changelog index 4b3f18eab3..1f7cb687bf 100644 --- a/libnullpay/debian/changelog +++ b/libnullpay/debian/changelog @@ -1,4 +1,4 @@ -libnullpay (1.14.1) unstable; urgency=medium +libnullpay (1.14.2) unstable; urgency=medium [ Hyperledger ] * Initial release diff --git a/libnullpay/tests/utils/did.rs b/libnullpay/tests/utils/did.rs index bd216e4fc4..5dbef91cf9 100644 --- a/libnullpay/tests/utils/did.rs +++ b/libnullpay/tests/utils/did.rs @@ -1,8 +1,9 @@ use indy::did; use indy::IndyError; use indy::future::Future; +use indy::WalletHandle; -pub fn create_and_store_my_did(wallet_handle: i32, seed: Option<&str>) -> Result<(String, String), IndyError> { +pub fn create_and_store_my_did(wallet_handle: WalletHandle, seed: Option<&str>) -> Result<(String, String), IndyError> { let my_did_json = seed.map_or("{}".to_string(), |seed| format!("{{\"seed\":\"{}\" }}", seed)); did::create_and_store_my_did(wallet_handle, &my_did_json).wait() } \ No newline at end of file diff --git a/libnullpay/tests/utils/ledger.rs b/libnullpay/tests/utils/ledger.rs index 509d1519e3..9d1df0d7ec 100644 --- a/libnullpay/tests/utils/ledger.rs +++ b/libnullpay/tests/utils/ledger.rs @@ -1,12 +1,14 @@ use indy::ledger; use indy::IndyError; use indy::future::Future; +use indy::WalletHandle; +use indy::PoolHandle; -pub fn submit_request(pool_handle: i32, request_json: &str) -> Result { +pub fn submit_request(pool_handle: PoolHandle, request_json: &str) -> Result { ledger::submit_request(pool_handle, request_json).wait() } -pub fn sign_and_submit_request(pool_handle: i32, wallet_handle: i32, submitter_did: &str, request_json: &str) -> Result { +pub fn sign_and_submit_request(pool_handle: PoolHandle, wallet_handle: WalletHandle, submitter_did: &str, request_json: &str) -> Result { ledger::sign_and_submit_request(pool_handle, wallet_handle, submitter_did, request_json).wait() } diff --git a/libnullpay/tests/utils/payments.rs b/libnullpay/tests/utils/payments.rs index 1bc073256f..156bb17a44 100644 --- a/libnullpay/tests/utils/payments.rs +++ b/libnullpay/tests/utils/payments.rs @@ -1,16 +1,17 @@ use indy::IndyError; use indy::payments; use indy::future::Future; +use indy::WalletHandle; -pub fn create_payment_address(wallet_handle: i32, payment_method: &str, config: &str) -> Result { +pub fn create_payment_address(wallet_handle: WalletHandle, payment_method: &str, config: &str) -> Result { payments::create_payment_address(wallet_handle, payment_method, config).wait() } -pub fn list_payment_addresses(wallet_handle: i32) -> Result { +pub fn list_payment_addresses(wallet_handle: WalletHandle) -> Result { payments::list_payment_addresses(wallet_handle).wait() } -pub fn add_request_fees(wallet_handle: i32, submitter_did: &str, req_json: &str, inputs_json: &str, outputs_json: &str, extra: Option<&str>) -> Result<(String, String), IndyError> { +pub fn add_request_fees(wallet_handle: WalletHandle, submitter_did: &str, req_json: &str, inputs_json: &str, outputs_json: &str, extra: Option<&str>) -> Result<(String, String), IndyError> { payments::add_request_fees(wallet_handle, Some(submitter_did), req_json, inputs_json, outputs_json, extra).wait() } @@ -18,7 +19,7 @@ pub fn parse_response_with_fees(payment_method: &str, resp_json: &str) -> Result payments::parse_response_with_fees(payment_method, resp_json).wait() } -pub fn build_get_payment_sources_request(wallet_handle: i32, submitter_did: &str, payment_address: &str) -> Result<(String, String), IndyError> { +pub fn build_get_payment_sources_request(wallet_handle: WalletHandle, submitter_did: &str, payment_address: &str) -> Result<(String, String), IndyError> { payments::build_get_payment_sources_request(wallet_handle, Some(submitter_did), payment_address).wait() } @@ -27,7 +28,7 @@ pub fn parse_get_payment_sources_response(payment_method: &str, resp_json: &str) payments::parse_get_payment_sources_response(payment_method, resp_json).wait() } -pub fn build_payment_req(wallet_handle: i32, submitter_did: &str, inputs: &str, outputs: &str, extra: Option<&str>) -> Result<(String, String), IndyError> { +pub fn build_payment_req(wallet_handle: WalletHandle, submitter_did: &str, inputs: &str, outputs: &str, extra: Option<&str>) -> Result<(String, String), IndyError> { payments::build_payment_req(wallet_handle, Some(submitter_did), inputs, outputs, extra).wait() } @@ -35,15 +36,15 @@ pub fn parse_payment_response(payment_method: &str, resp_json: &str) -> Result) -> Result<(String, String), IndyError> { +pub fn build_mint_req(wallet_handle: WalletHandle, submitter_did: &str, outputs_json: &str, extra: Option<&str>) -> Result<(String, String), IndyError> { payments::build_mint_req(wallet_handle, Some(submitter_did), outputs_json, extra).wait() } -pub fn build_set_txn_fees_req(wallet_handle: i32, submitter_did: &str, payment_method: &str, fees_json: &str) -> Result { +pub fn build_set_txn_fees_req(wallet_handle: WalletHandle, submitter_did: &str, payment_method: &str, fees_json: &str) -> Result { payments::build_set_txn_fees_req(wallet_handle, Some(submitter_did), payment_method, fees_json).wait() } -pub fn build_get_txn_fees_req(wallet_handle: i32, submitter_did: &str, payment_method: &str) -> Result { +pub fn build_get_txn_fees_req(wallet_handle: WalletHandle, submitter_did: &str, payment_method: &str) -> Result { payments::build_get_txn_fees_req(wallet_handle, Some(submitter_did), payment_method).wait() } @@ -51,7 +52,7 @@ pub fn parse_get_txn_fees_response(payment_method: &str, resp_json: &str) -> Res payments::parse_get_txn_fees_response(payment_method, resp_json).wait() } -pub fn build_verify_payment_req(wallet_handle: i32, submitter_did: &str, receipt: &str) -> Result<(String, String), IndyError> { +pub fn build_verify_payment_req(wallet_handle: WalletHandle, submitter_did: &str, receipt: &str) -> Result<(String, String), IndyError> { payments::build_verify_payment_req(wallet_handle, Some(submitter_did), receipt).wait() } @@ -59,7 +60,7 @@ pub fn parse_verify_payment_response(payment_method: &str, resp_json: &str) -> R payments::parse_verify_payment_response(payment_method, resp_json).wait() } -pub fn sign_with_address(wallet_handle: i32, address: &str, message: &[u8]) -> Result, IndyError> { +pub fn sign_with_address(wallet_handle: WalletHandle, address: &str, message: &[u8]) -> Result, IndyError> { payments::sign_with_address(wallet_handle, address, message).wait() } diff --git a/libnullpay/tests/utils/payments_utils.rs b/libnullpay/tests/utils/payments_utils.rs index f3cafdba10..6d035d2f87 100644 --- a/libnullpay/tests/utils/payments_utils.rs +++ b/libnullpay/tests/utils/payments_utils.rs @@ -5,13 +5,16 @@ use serde_json; use utils::ledger; use std::collections::HashMap; -pub fn create_addresses(cfgs: Vec<&str>, wallet_handle: i32, payment_method: &str) -> Vec { +use indy::WalletHandle; +use indy::PoolHandle; + +pub fn create_addresses(cfgs: Vec<&str>, wallet_handle: WalletHandle, payment_method: &str) -> Vec { cfgs.into_iter().map(|cfg| { payments::create_payment_address(wallet_handle, payment_method, cfg).unwrap() }).collect() } -pub fn mint_sources(addresses: Vec<(String, i32)>, extra: Option<&str>, wallet_handle: i32, pool_handle: i32, submitter_did: &str) { +pub fn mint_sources(addresses: Vec<(String, i32)>, extra: Option<&str>, wallet_handle: WalletHandle, pool_handle: PoolHandle, submitter_did: &str) { let mint: Vec = addresses.into_iter().map(|(recipient, amount)| { Output { recipient, @@ -25,7 +28,7 @@ pub fn mint_sources(addresses: Vec<(String, i32)>, extra: Option<&str>, wallet_h ledger::submit_request(pool_handle, req.as_str()).unwrap(); } -pub fn get_sources_with_balance(payment_addresses: Vec, wallet_handle: i32, pool_handle: i32, submitter_did: &str) -> HashMap> { +pub fn get_sources_with_balance(payment_addresses: Vec, wallet_handle: WalletHandle, pool_handle: PoolHandle, submitter_did: &str) -> HashMap> { payment_addresses.into_iter().map(|addr| { let (req_sources, payment_method) = payments::build_get_payment_sources_request(wallet_handle, submitter_did, addr.as_str()).unwrap(); let resp_sources = ledger::submit_request(pool_handle, req_sources.as_str()).unwrap(); @@ -35,12 +38,12 @@ pub fn get_sources_with_balance(payment_addresses: Vec, wallet_handle: i }).collect() } -pub fn set_request_fees(wallet_handle: i32, pool_handle: i32, submitter_did: &str, payment_method: &str, fees: &str) { +pub fn set_request_fees(wallet_handle: WalletHandle, pool_handle: PoolHandle, submitter_did: &str, payment_method: &str, fees: &str) { let req = payments::build_set_txn_fees_req(wallet_handle, submitter_did, payment_method, fees).unwrap(); ledger::submit_request(pool_handle, req.as_str()).unwrap(); } -pub fn get_request_fees(wallet_handle: i32, pool_handle: i32, submitter_did: &str, payment_method: &str) -> HashMap { +pub fn get_request_fees(wallet_handle: WalletHandle, pool_handle: PoolHandle, submitter_did: &str, payment_method: &str) -> HashMap { let req = payments::build_get_txn_fees_req(wallet_handle, submitter_did, payment_method).unwrap(); let resp = ledger::submit_request(pool_handle, req.as_str()).unwrap(); let resp = payments::parse_get_payment_sources_response(payment_method, resp.as_str()).unwrap(); diff --git a/libnullpay/tests/utils/pool.rs b/libnullpay/tests/utils/pool.rs index 5ad6a022cb..0adf059c57 100644 --- a/libnullpay/tests/utils/pool.rs +++ b/libnullpay/tests/utils/pool.rs @@ -1,6 +1,7 @@ use indy::IndyError; use indy::pool; use indy::future::Future; +use indy::PoolHandle; use serde_json::to_string; use std::io::Write; @@ -15,7 +16,7 @@ pub struct PoolConfig { const PROTOCOL_VERSION: usize = 2; -pub fn create_and_open_pool_ledger(pool_name: &str) -> Result { +pub fn create_and_open_pool_ledger(pool_name: &str) -> Result { set_protocol_version(PROTOCOL_VERSION).unwrap(); let txn_file_path = _create_genesis_txn_file_for_test_pool(pool_name, None, None); let pool_config = _pool_config_json(txn_file_path.as_path()); @@ -23,7 +24,7 @@ pub fn create_and_open_pool_ledger(pool_name: &str) -> Result { _open_pool_ledger(pool_name, None) } -pub fn close(pool_handle: i32) -> Result<(), IndyError> { +pub fn close(pool_handle: PoolHandle) -> Result<(), IndyError> { pool::close_pool_ledger(pool_handle).wait() } diff --git a/libnullpay/tests/utils/wallet.rs b/libnullpay/tests/utils/wallet.rs index 2d3a952b41..1cad6047d8 100644 --- a/libnullpay/tests/utils/wallet.rs +++ b/libnullpay/tests/utils/wallet.rs @@ -1,5 +1,6 @@ use indy::IndyError; use indy::wallet; +use indy::WalletHandle; use indy::future::Future; pub const DEFAULT_WALLET_CREDENTIALS: &'static str = r#"{"key":"8dvfYSt5d1taSd6yJdpjq4emkwsPDDLYxkNFysFD2cZY", "key_derivation_method":"RAW"}"#; @@ -8,11 +9,11 @@ pub fn create_wallet(config: &str) -> Result<(), IndyError> { wallet::create_wallet(config, DEFAULT_WALLET_CREDENTIALS).wait() } -pub fn open_wallet(config: &str) -> Result { +pub fn open_wallet(config: &str) -> Result { wallet::open_wallet(config, DEFAULT_WALLET_CREDENTIALS).wait() } -pub fn create_and_open_wallet() -> Result { +pub fn create_and_open_wallet() -> Result { let wallet_name = format!("default-wallet-name-{}", super::sequence::get_next_id()); let config = format!(r#"{{"id":"{}"}}"#, wallet_name); @@ -20,6 +21,6 @@ pub fn create_and_open_wallet() -> Result { open_wallet(&config) } -pub fn close_wallet(wallet_handle: i32) -> Result<(), IndyError> { +pub fn close_wallet(wallet_handle: WalletHandle) -> Result<(), IndyError> { wallet::close_wallet(wallet_handle).wait() } \ No newline at end of file diff --git a/samples/java/pom.xml b/samples/java/pom.xml index 1578980ae4..d3a79e335c 100644 --- a/samples/java/pom.xml +++ b/samples/java/pom.xml @@ -109,7 +109,7 @@ org.hyperledger indy - 1.10.1-dev-1219 + 1.14.1-rc-120 diff --git a/samples/python/setup.py b/samples/python/setup.py index cd7743dd3e..913351ab3b 100644 --- a/samples/python/setup.py +++ b/samples/python/setup.py @@ -8,5 +8,5 @@ author='Hyperledger Indy Contributors', author_email='hyperledger-indy@lists.hyperledger.org', description='This is the sample of usage python wrapper for Hyperledger Indy SDK.', - install_requires=['python3-indy==1.11.0'] + install_requires=['python3-indy==1.14.1'] ) diff --git a/samples/python/src/getting_started.py b/samples/python/src/getting_started.py index a236946fc5..df8be42f6f 100644 --- a/samples/python/src/getting_started.py +++ b/samples/python/src/getting_started.py @@ -1,6 +1,6 @@ import time -from indy import anoncreds, crypto, did, ledger, pool, wallet, blob_storage +from indy import anoncreds, did, ledger, pool, wallet, blob_storage import json import logging @@ -14,6 +14,7 @@ from src.utils import get_pool_genesis_txn_path, run_coroutine, PROTOCOL_VERSION + logger = logging.getLogger(__name__) logging.basicConfig(level=logging.INFO) @@ -26,7 +27,6 @@ args = parser.parse_args() - # check if we need to dyna-load a custom wallet storage plug-in if args.storage_type: if not (args.library and args.entrypoint): @@ -38,7 +38,7 @@ print("Error unable to load wallet storage", result) parser.print_help() sys.exit(0) - + # for postgres storage, also call the storage init (non-standard) if args.storage_type == "postgres_storage": try: @@ -78,7 +78,6 @@ async def run(): logger.info("=== Getting Trust Anchor credentials for Faber, Acme, Thrift and Government ==") logger.info("------------------------------") - logger.info("\"Sovrin Steward\" -> Create wallet") steward = { 'name': "Sovrin Steward", 'wallet_config': json.dumps({'id': 'sovrin_steward_wallet'}), @@ -87,20 +86,14 @@ async def run(): 'seed': '000000000000000000000000Steward1' } - try: - await wallet.create_wallet(steward['wallet_config'], steward['wallet_credentials']) - except IndyError as ex: - if ex.error_code == ErrorCode.WalletAlreadyExistsError: - pass - - steward['wallet'] = await wallet.open_wallet(steward['wallet_config'], steward['wallet_credentials']) + await create_wallet(steward) logger.info("\"Sovrin Steward\" -> Create and store in Wallet DID from seed") steward['did_info'] = json.dumps({'seed': steward['seed']}) steward['did'], steward['key'] = await did.create_and_store_my_did(steward['wallet'], steward['did_info']) logger.info("==============================") - logger.info("== Getting Trust Anchor credentials - Government Onboarding ==") + logger.info("== Getting Trust Anchor credentials - Government getting Verinym ==") logger.info("------------------------------") government = { @@ -110,18 +103,11 @@ async def run(): 'pool': pool_['handle'], 'role': 'TRUST_ANCHOR' } - steward['did_for_government'], steward['key_for_government'], government['did_for_steward'], \ - government['key_for_steward'], _ = await onboarding(steward, government) - logger.info("==============================") - logger.info("== Getting Trust Anchor credentials - Government getting Verinym ==") - logger.info("------------------------------") - - government['did'] = await get_verinym(steward, steward['did_for_government'], steward['key_for_government'], - government, government['did_for_steward'], government['key_for_steward']) + await getting_verinym(steward, government) logger.info("==============================") - logger.info("== Getting Trust Anchor credentials - Faber Onboarding ==") + logger.info("== Getting Trust Anchor credentials - Faber getting Verinym ==") logger.info("------------------------------") faber = { @@ -131,19 +117,11 @@ async def run(): 'pool': pool_['handle'], 'role': 'TRUST_ANCHOR' } - steward['did_for_faber'], steward['key_for_faber'], faber['did_for_steward'], faber['key_for_steward'], _ = \ - await onboarding(steward, faber) - - logger.info("==============================") - logger.info("== Getting Trust Anchor credentials - Faber getting Verinym ==") - logger.info("------------------------------") - faber['did'] = \ - await get_verinym(steward, steward['did_for_faber'], steward['key_for_faber'], - faber, faber['did_for_steward'], faber['key_for_steward']) + await getting_verinym(steward, faber) logger.info("==============================") - logger.info("== Getting Trust Anchor credentials - Acme Onboarding ==") + logger.info("== Getting Trust Anchor credentials - Acme getting Verinym ==") logger.info("------------------------------") acme = { @@ -153,18 +131,11 @@ async def run(): 'pool': pool_['handle'], 'role': 'TRUST_ANCHOR' } - steward['did_for_acme'], steward['key_for_acme'], acme['did_for_steward'], acme['key_for_steward'], _ = \ - await onboarding(steward, acme) - - logger.info("==============================") - logger.info("== Getting Trust Anchor credentials - Acme getting Verinym ==") - logger.info("------------------------------") - acme['did'] = await get_verinym(steward, steward['did_for_acme'], steward['key_for_acme'], - acme, acme['did_for_steward'], acme['key_for_steward']) + await getting_verinym(steward, acme) logger.info("==============================") - logger.info("== Getting Trust Anchor credentials - Thrift Onboarding ==") + logger.info("== Getting Trust Anchor credentials - Thrift getting Verinym ==") logger.info("------------------------------") thrift = { @@ -174,15 +145,8 @@ async def run(): 'pool': pool_['handle'], 'role': 'TRUST_ANCHOR' } - steward['did_for_thrift'], steward['key_for_thrift'], thrift['did_for_steward'], thrift['key_for_steward'], _ = \ - await onboarding(steward, thrift) - - logger.info("==============================") - logger.info("== Getting Trust Anchor credentials - Thrift getting Verinym ==") - logger.info("------------------------------") - thrift['did'] = await get_verinym(steward, steward['did_for_thrift'], steward['key_for_thrift'], - thrift, thrift['did_for_steward'], thrift['key_for_steward']) + await getting_verinym(steward, thrift) logger.info("==============================") logger.info("=== Credential Schemas Setup ==") @@ -288,7 +252,7 @@ async def run(): logger.info("==============================") logger.info("=== Getting Transcript with Faber ==") logger.info("==============================") - logger.info("== Getting Transcript with Faber - Onboarding ==") + logger.info("== Alice setup ==") logger.info("------------------------------") alice = { @@ -297,8 +261,8 @@ async def run(): 'wallet_credentials': json.dumps({'key': 'alice_wallet_key'}), 'pool': pool_['handle'], } - faber['did_for_alice'], faber['key_for_alice'], alice['did_for_faber'], alice['key_for_faber'], \ - faber['alice_connection_response'] = await onboarding(faber, alice) + await create_wallet(alice) + (alice['did'], alice['key']) = await did.create_and_store_my_did(alice['wallet'], "{}") logger.info("==============================") logger.info("== Getting Transcript with Faber - Getting Transcript Credential ==") @@ -308,48 +272,28 @@ async def run(): faber['transcript_cred_offer'] = \ await anoncreds.issuer_create_credential_offer(faber['wallet'], faber['transcript_cred_def_id']) - logger.info("\"Faber\" -> Get key for Alice did") - faber['alice_key_for_faber'] = \ - await did.key_for_did(faber['pool'], faber['wallet'], faber['alice_connection_response']['did']) + logger.info("\"Faber\" -> Send \"Transcript\" Credential Offer to Alice") + alice['transcript_cred_offer'] = faber['transcript_cred_offer'] + transcript_cred_offer_object = json.loads(alice['transcript_cred_offer']) - logger.info("\"Faber\" -> Authcrypt \"Transcript\" Credential Offer for Alice") - faber['authcrypted_transcript_cred_offer'] = \ - await crypto.auth_crypt(faber['wallet'], faber['key_for_alice'], faber['alice_key_for_faber'], - faber['transcript_cred_offer'].encode('utf-8')) - - logger.info("\"Faber\" -> Send authcrypted \"Transcript\" Credential Offer to Alice") - alice['authcrypted_transcript_cred_offer'] = faber['authcrypted_transcript_cred_offer'] - - logger.info("\"Alice\" -> Authdecrypted \"Transcript\" Credential Offer from Faber") - alice['faber_key_for_alice'], alice['transcript_cred_offer'], authdecrypted_transcript_cred_offer = \ - await auth_decrypt(alice['wallet'], alice['key_for_faber'], alice['authcrypted_transcript_cred_offer']) - alice['transcript_schema_id'] = authdecrypted_transcript_cred_offer['schema_id'] - alice['transcript_cred_def_id'] = authdecrypted_transcript_cred_offer['cred_def_id'] + alice['transcript_schema_id'] = transcript_cred_offer_object['schema_id'] + alice['transcript_cred_def_id'] = transcript_cred_offer_object['cred_def_id'] logger.info("\"Alice\" -> Create and store \"Alice\" Master Secret in Wallet") alice['master_secret_id'] = await anoncreds.prover_create_master_secret(alice['wallet'], None) logger.info("\"Alice\" -> Get \"Faber Transcript\" Credential Definition from Ledger") (alice['faber_transcript_cred_def_id'], alice['faber_transcript_cred_def']) = \ - await get_cred_def(alice['pool'], alice['did_for_faber'], alice['transcript_cred_def_id']) + await get_cred_def(alice['pool'], alice['did'], alice['transcript_cred_def_id']) logger.info("\"Alice\" -> Create \"Transcript\" Credential Request for Faber") (alice['transcript_cred_request'], alice['transcript_cred_request_metadata']) = \ - await anoncreds.prover_create_credential_req(alice['wallet'], alice['did_for_faber'], + await anoncreds.prover_create_credential_req(alice['wallet'], alice['did'], alice['transcript_cred_offer'], alice['faber_transcript_cred_def'], alice['master_secret_id']) - logger.info("\"Alice\" -> Authcrypt \"Transcript\" Credential Request for Faber") - alice['authcrypted_transcript_cred_request'] = \ - await crypto.auth_crypt(alice['wallet'], alice['key_for_faber'], alice['faber_key_for_alice'], - alice['transcript_cred_request'].encode('utf-8')) - - logger.info("\"Alice\" -> Send authcrypted \"Transcript\" Credential Request to Faber") - faber['authcrypted_transcript_cred_request'] = alice['authcrypted_transcript_cred_request'] - - logger.info("\"Faber\" -> Authdecrypt \"Transcript\" Credential Request from Alice") - faber['alice_key_for_faber'], faber['transcript_cred_request'], _ = \ - await auth_decrypt(faber['wallet'], faber['key_for_alice'], faber['authcrypted_transcript_cred_request']) + logger.info("\"Alice\" -> Send \"Transcript\" Credential Request to Faber") + faber['transcript_cred_request'] = alice['transcript_cred_request'] logger.info("\"Faber\" -> Create \"Transcript\" Credential for Alice") faber['alice_transcript_cred_values'] = json.dumps({ @@ -366,34 +310,16 @@ async def run(): faber['transcript_cred_request'], faber['alice_transcript_cred_values'], None, None) - logger.info("\"Faber\" -> Authcrypt \"Transcript\" Credential for Alice") - faber['authcrypted_transcript_cred'] = \ - await crypto.auth_crypt(faber['wallet'], faber['key_for_alice'], faber['alice_key_for_faber'], - faber['transcript_cred'].encode('utf-8')) - - logger.info("\"Faber\" -> Send authcrypted \"Transcript\" Credential to Alice") - alice['authcrypted_transcript_cred'] = faber['authcrypted_transcript_cred'] - - logger.info("\"Alice\" -> Authdecrypted \"Transcript\" Credential from Faber") - _, alice['transcript_cred'], _ = \ - await auth_decrypt(alice['wallet'], alice['key_for_faber'], alice['authcrypted_transcript_cred']) + logger.info("\"Faber\" -> Send \"Transcript\" Credential to Alice") + alice['transcript_cred'] = faber['transcript_cred'] logger.info("\"Alice\" -> Store \"Transcript\" Credential from Faber") - _, alice['transcript_cred_def'] = await get_cred_def(alice['pool'], alice['did_for_faber'], + _, alice['transcript_cred_def'] = await get_cred_def(alice['pool'], alice['did'], alice['transcript_cred_def_id']) await anoncreds.prover_store_credential(alice['wallet'], None, alice['transcript_cred_request_metadata'], alice['transcript_cred'], alice['transcript_cred_def'], None) - logger.info("==============================") - logger.info("=== Apply for the job with Acme ==") - logger.info("==============================") - logger.info("== Apply for the job with Acme - Onboarding ==") - logger.info("------------------------------") - - acme['did_for_alice'], acme['key_for_alice'], alice['did_for_acme'], alice['key_for_acme'], \ - acme['alice_connection_response'] = await onboarding(acme, alice) - logger.info("==============================") logger.info("== Apply for the job with Acme - Transcript proving ==") logger.info("------------------------------") @@ -437,21 +363,8 @@ async def run(): } }) - logger.info("\"Acme\" -> Get key for Alice did") - acme['alice_key_for_acme'] = \ - await did.key_for_did(acme['pool'], acme['wallet'], acme['alice_connection_response']['did']) - - logger.info("\"Acme\" -> Authcrypt \"Job-Application\" Proof Request for Alice") - acme['authcrypted_job_application_proof_request'] = \ - await crypto.auth_crypt(acme['wallet'], acme['key_for_alice'], acme['alice_key_for_acme'], - acme['job_application_proof_request'].encode('utf-8')) - - logger.info("\"Acme\" -> Send authcrypted \"Job-Application\" Proof Request to Alice") - alice['authcrypted_job_application_proof_request'] = acme['authcrypted_job_application_proof_request'] - - logger.info("\"Alice\" -> Authdecrypt \"Job-Application\" Proof Request from Acme") - alice['acme_key_for_alice'], alice['job_application_proof_request'], _ = \ - await auth_decrypt(alice['wallet'], alice['key_for_acme'], alice['authcrypted_job_application_proof_request']) + logger.info("\"Acme\" -> Send \"Job-Application\" Proof Request to Alice") + alice['job_application_proof_request'] = acme['job_application_proof_request'] logger.info("\"Alice\" -> Get credentials for \"Job-Application\" Proof Request") @@ -478,7 +391,7 @@ async def run(): alice['schemas_for_job_application'], alice['cred_defs_for_job_application'], \ alice['revoc_states_for_job_application'] = \ - await prover_get_entities_from_ledger(alice['pool'], alice['did_for_acme'], + await prover_get_entities_from_ledger(alice['pool'], alice['did'], alice['creds_for_job_application_proof'], alice['name']) logger.info("\"Alice\" -> Create \"Job-Application\" Proof") @@ -503,34 +416,27 @@ async def run(): alice['cred_defs_for_job_application'], alice['revoc_states_for_job_application']) - logger.info("\"Alice\" -> Authcrypt \"Job-Application\" Proof for Acme") - alice['authcrypted_job_application_proof'] = \ - await crypto.auth_crypt(alice['wallet'], alice['key_for_acme'], alice['acme_key_for_alice'], - alice['job_application_proof'].encode('utf-8')) - - logger.info("\"Alice\" -> Send authcrypted \"Job-Application\" Proof to Acme") - acme['authcrypted_job_application_proof'] = alice['authcrypted_job_application_proof'] + logger.info("\"Alice\" -> Send \"Job-Application\" Proof to Acme") + acme['job_application_proof'] = alice['job_application_proof'] - logger.info("\"Acme\" -> Authdecrypted \"Job-Application\" Proof from Alice") - _, acme['job_application_proof'], decrypted_job_application_proof = \ - await auth_decrypt(acme['wallet'], acme['key_for_alice'], acme['authcrypted_job_application_proof']) + job_application_proof_object = json.loads(acme['job_application_proof']) acme['schemas_for_job_application'], acme['cred_defs_for_job_application'], \ acme['revoc_ref_defs_for_job_application'], acme['revoc_regs_for_job_application'] = \ await verifier_get_entities_from_ledger(acme['pool'], acme['did'], - decrypted_job_application_proof['identifiers'], acme['name']) + job_application_proof_object['identifiers'], acme['name']) logger.info("\"Acme\" -> Verify \"Job-Application\" Proof from Alice") assert 'Bachelor of Science, Marketing' == \ - decrypted_job_application_proof['requested_proof']['revealed_attrs']['attr3_referent']['raw'] + job_application_proof_object['requested_proof']['revealed_attrs']['attr3_referent']['raw'] assert 'graduated' == \ - decrypted_job_application_proof['requested_proof']['revealed_attrs']['attr4_referent']['raw'] + job_application_proof_object['requested_proof']['revealed_attrs']['attr4_referent']['raw'] assert '123-45-6789' == \ - decrypted_job_application_proof['requested_proof']['revealed_attrs']['attr5_referent']['raw'] + job_application_proof_object['requested_proof']['revealed_attrs']['attr5_referent']['raw'] - assert 'Alice' == decrypted_job_application_proof['requested_proof']['self_attested_attrs']['attr1_referent'] - assert 'Garcia' == decrypted_job_application_proof['requested_proof']['self_attested_attrs']['attr2_referent'] - assert '123-45-6789' == decrypted_job_application_proof['requested_proof']['self_attested_attrs']['attr6_referent'] + assert 'Alice' == job_application_proof_object['requested_proof']['self_attested_attrs']['attr1_referent'] + assert 'Garcia' == job_application_proof_object['requested_proof']['self_attested_attrs']['attr2_referent'] + assert '123-45-6789' == job_application_proof_object['requested_proof']['self_attested_attrs']['attr6_referent'] assert await anoncreds.verifier_verify_proof(acme['job_application_proof_request'], acme['job_application_proof'], acme['schemas_for_job_application'], @@ -546,38 +452,22 @@ async def run(): acme['job_certificate_cred_offer'] = \ await anoncreds.issuer_create_credential_offer(acme['wallet'], acme['job_certificate_cred_def_id']) - logger.info("\"Acme\" -> Get key for Alice did") - acme['alice_key_for_acme'] = \ - await did.key_for_did(acme['pool'], acme['wallet'], acme['alice_connection_response']['did']) + logger.info("\"Acme\" -> Send \"Job-Certificate\" Credential Offer to Alice") + alice['job_certificate_cred_offer'] = acme['job_certificate_cred_offer'] - logger.info("\"Acme\" -> Authcrypt \"Job-Certificate\" Credential Offer for Alice") - acme['authcrypted_job_certificate_cred_offer'] = \ - await crypto.auth_crypt(acme['wallet'], acme['key_for_alice'], acme['alice_key_for_acme'], - acme['job_certificate_cred_offer'].encode('utf-8')) - - logger.info("\"Acme\" -> Send authcrypted \"Job-Certificate\" Credential Offer to Alice") - alice['authcrypted_job_certificate_cred_offer'] = acme['authcrypted_job_certificate_cred_offer'] - - logger.info("\"Alice\" -> Authdecrypted \"Job-Certificate\" Credential Offer from Acme") - alice['acme_key_for_alice_alice'], alice['job_certificate_cred_offer'], job_certificate_cred_offer = \ - await auth_decrypt(alice['wallet'], alice['key_for_acme'], alice['authcrypted_job_certificate_cred_offer']) + job_certificate_cred_offer_object = json.loads(alice['job_certificate_cred_offer']) logger.info("\"Alice\" -> Get \"Acme Job-Certificate\" Credential Definition from Ledger") (alice['acme_job_certificate_cred_def_id'], alice['acme_job_certificate_cred_def']) = \ - await get_cred_def(alice['pool'], alice['did_for_acme'], job_certificate_cred_offer['cred_def_id']) + await get_cred_def(alice['pool'], alice['did'], job_certificate_cred_offer_object['cred_def_id']) logger.info("\"Alice\" -> Create and store in Wallet \"Job-Certificate\" Credential Request for Acme") (alice['job_certificate_cred_request'], alice['job_certificate_cred_request_metadata']) = \ - await anoncreds.prover_create_credential_req(alice['wallet'], alice['did_for_acme'], + await anoncreds.prover_create_credential_req(alice['wallet'], alice['did'], alice['job_certificate_cred_offer'], alice['acme_job_certificate_cred_def'], alice['master_secret_id']) - logger.info("\"Alice\" -> Authcrypt \"Job-Certificate\" Credential Request for Acme") - alice['authcrypted_job_certificate_cred_request'] = \ - await crypto.auth_crypt(alice['wallet'], alice['key_for_acme'], alice['acme_key_for_alice'], - alice['job_certificate_cred_request'].encode('utf-8')) - - logger.info("\"Alice\" -> Send authcrypted \"Job-Certificate\" Credential Request to Acme") + logger.info("\"Alice\" -> Send \"Job-Certificate\" Credential Request to Acme") alice['job_certificate_cred_values'] = json.dumps({ "first_name": {"raw": "Alice", "encoded": "245712572474217942457235975012103335"}, "last_name": {"raw": "Garcia", "encoded": "312643218496194691632153761283356127"}, @@ -585,13 +475,9 @@ async def run(): "salary": {"raw": "2400", "encoded": "2400"}, "experience": {"raw": "10", "encoded": "10"} }) - acme['authcrypted_job_certificate_cred_request'] = alice['authcrypted_job_certificate_cred_request'] + acme['job_certificate_cred_request'] = alice['job_certificate_cred_request'] acme['job_certificate_cred_values'] = alice['job_certificate_cred_values'] - logger.info("\"Acme\" -> Authdecrypt \"Job-Certificate\" Credential Request from Alice") - acme['alice_key_for_acme'], acme['job_certificate_cred_request'], _ = \ - await auth_decrypt(acme['wallet'], acme['key_for_alice'], acme['authcrypted_job_certificate_cred_request']) - logger.info("\"Acme\" -> Create \"Job-Certificate\" Credential for Alice") acme['blob_storage_reader_cfg_handle'] = await blob_storage.open_reader('default', acme['tails_writer_config']) acme['job_certificate_cred'], acme['job_certificate_cred_rev_id'], acme['alice_cert_rev_reg_delta'] = \ @@ -607,22 +493,14 @@ async def run(): acme['alice_cert_rev_reg_delta']) await ledger.sign_and_submit_request(acme['pool'], acme['wallet'], acme['did'], acme['revoc_reg_entry_req']) - logger.info("\"Acme\" -> Authcrypt \"Job-Certificate\" Credential for Alice") - acme['authcrypted_job_certificate_cred'] = \ - await crypto.auth_crypt(acme['wallet'], acme['key_for_alice'], acme['alice_key_for_acme'], - acme['job_certificate_cred'].encode('utf-8')) - - logger.info("\"Acme\" -> Send authcrypted \"Job-Certificate\" Credential to Alice") - alice['authcrypted_job_certificate_cred'] = acme['authcrypted_job_certificate_cred'] - - logger.info("\"Alice\" -> Authdecrypted \"Job-Certificate\" Credential from Acme") - _, alice['job_certificate_cred'], alice_job_certificate_cred = \ - await auth_decrypt(alice['wallet'], alice['key_for_acme'], alice['authcrypted_job_certificate_cred']) + logger.info("\"Acme\" -> Send \"Job-Certificate\" Credential to Alice") + alice['job_certificate_cred'] = acme['job_certificate_cred'] + job_certificate_cred_object = json.loads(alice['job_certificate_cred']) logger.info("\"Alice\" -> Gets RevocationRegistryDefinition for \"Job-Certificate\" Credential from Acme") alice['acme_revoc_reg_des_req'] = \ - await ledger.build_get_revoc_reg_def_request(alice['did_for_acme'], - alice_job_certificate_cred['rev_reg_id']) + await ledger.build_get_revoc_reg_def_request(alice['did'], + job_certificate_cred_object['rev_reg_id']) alice['acme_revoc_reg_des_resp'] = await ledger.submit_request(alice['pool'], alice['acme_revoc_reg_des_req']) (alice['acme_revoc_reg_def_id'], alice['acme_revoc_reg_def_json']) = \ await ledger.parse_get_revoc_reg_def_response(alice['acme_revoc_reg_des_resp']) @@ -635,11 +513,6 @@ async def run(): logger.info("==============================") logger.info("=== Apply for the loan with Thrift ==") logger.info("==============================") - logger.info("== Apply for the loan with Thrift - Onboarding ==") - logger.info("------------------------------") - - thrift['did_for_alice'], thrift['key_for_alice'], alice['did_for_thrift'], alice['key_for_thrift'], \ - thrift['alice_connection_response'] = await onboarding(thrift, alice) async def apply_loan_basic(): # This method will be called twice: once with a valid Job-Certificate and @@ -677,21 +550,8 @@ async def apply_loan_basic(): 'non_revoked': {'to': int(time.time())} }) - logger.info("\"Thrift\" -> Get key for Alice did") - thrift['alice_key_for_thrift'] = \ - await did.key_for_did(thrift['pool'], thrift['wallet'], thrift['alice_connection_response']['did']) - - logger.info("\"Thrift\" -> Authcrypt \"Loan-Application-Basic\" Proof Request for Alice") - thrift['authcrypted_apply_loan_proof_request'] = \ - await crypto.auth_crypt(thrift['wallet'], thrift['key_for_alice'], thrift['alice_key_for_thrift'], - thrift['apply_loan_proof_request'].encode('utf-8')) - - logger.info("\"Thrift\" -> Send authcrypted \"Loan-Application-Basic\" Proof Request to Alice") - alice['authcrypted_apply_loan_proof_request'] = thrift['authcrypted_apply_loan_proof_request'] - - logger.info("\"Alice\" -> Authdecrypt \"Loan-Application-Basic\" Proof Request from Thrift") - alice['thrift_key_for_alice'], alice['apply_loan_proof_request'], _ = \ - await auth_decrypt(alice['wallet'], alice['key_for_thrift'], alice['authcrypted_apply_loan_proof_request']) + logger.info("\"Thrift\" -> Send \"Loan-Application-Basic\" Proof Request to Alice") + alice['apply_loan_proof_request'] = thrift['apply_loan_proof_request'] logger.info("\"Alice\" -> Get credentials for \"Loan-Application-Basic\" Proof Request") @@ -700,8 +560,10 @@ async def apply_loan_basic(): alice['apply_loan_proof_request'], None) cred_for_attr1 = await get_credential_for_referent(search_for_apply_loan_proof_request, 'attr1_referent') - cred_for_predicate1 = await get_credential_for_referent(search_for_apply_loan_proof_request, 'predicate1_referent') - cred_for_predicate2 = await get_credential_for_referent(search_for_apply_loan_proof_request, 'predicate2_referent') + cred_for_predicate1 = await get_credential_for_referent(search_for_apply_loan_proof_request, + 'predicate1_referent') + cred_for_predicate2 = await get_credential_for_referent(search_for_apply_loan_proof_request, + 'predicate2_referent') await anoncreds.prover_close_credentials_search_for_proof_req(search_for_apply_loan_proof_request) @@ -711,7 +573,7 @@ async def apply_loan_basic(): requested_timestamp = int(json.loads(thrift['apply_loan_proof_request'])['non_revoked']['to']) alice['schemas_for_loan_app'], alice['cred_defs_for_loan_app'], alice['revoc_states_for_loan_app'] = \ - await prover_get_entities_from_ledger(alice['pool'], alice['did_for_thrift'], + await prover_get_entities_from_ledger(alice['pool'], alice['did'], alice['creds_for_apply_loan_proof'], alice['name'], None, requested_timestamp) @@ -723,11 +585,14 @@ async def apply_loan_basic(): alice['apply_loan_requested_creds'] = json.dumps({ 'self_attested_attributes': {}, 'requested_attributes': { - 'attr1_referent': {'cred_id': cred_for_attr1['referent'], 'revealed': True, 'timestamp': timestamp_for_attr1} + 'attr1_referent': {'cred_id': cred_for_attr1['referent'], 'revealed': True, + 'timestamp': timestamp_for_attr1} }, 'requested_predicates': { - 'predicate1_referent': {'cred_id': cred_for_predicate1['referent'], 'timestamp': timestamp_for_predicate1}, - 'predicate2_referent': {'cred_id': cred_for_predicate2['referent'], 'timestamp': timestamp_for_predicate2} + 'predicate1_referent': {'cred_id': cred_for_predicate1['referent'], + 'timestamp': timestamp_for_predicate1}, + 'predicate2_referent': {'cred_id': cred_for_predicate2['referent'], + 'timestamp': timestamp_for_predicate2} } }) alice['apply_loan_proof'] = \ @@ -736,17 +601,9 @@ async def apply_loan_basic(): alice['schemas_for_loan_app'], alice['cred_defs_for_loan_app'], alice['revoc_states_for_loan_app']) - logger.info("\"Alice\" -> Authcrypt \"Loan-Application-Basic\" Proof for Thrift") - alice['authcrypted_alice_apply_loan_proof'] = \ - await crypto.auth_crypt(alice['wallet'], alice['key_for_thrift'], alice['thrift_key_for_alice'], - alice['apply_loan_proof'].encode('utf-8')) - - logger.info("\"Alice\" -> Send authcrypted \"Loan-Application-Basic\" Proof to Thrift") - thrift['authcrypted_alice_apply_loan_proof'] = alice['authcrypted_alice_apply_loan_proof'] - - logger.info("\"Thrift\" -> Authdecrypted \"Loan-Application-Basic\" Proof from Alice") - _, thrift['alice_apply_loan_proof'], authdecrypted_alice_apply_loan_proof = \ - await auth_decrypt(thrift['wallet'], thrift['key_for_alice'], thrift['authcrypted_alice_apply_loan_proof']) + logger.info("\"Alice\" -> Send \"Loan-Application-Basic\" Proof to Thrift") + thrift['apply_loan_proof'] = alice['apply_loan_proof'] + apply_loan_proof_object = json.loads(thrift['apply_loan_proof']) logger.info("\"Thrift\" -> Get Schemas, Credential Definitions and Revocation Registries from Ledger" " required for Proof verifying") @@ -754,17 +611,18 @@ async def apply_loan_basic(): thrift['schemas_for_loan_app'], thrift['cred_defs_for_loan_app'], thrift['revoc_defs_for_loan_app'], \ thrift['revoc_regs_for_loan_app'] = \ await verifier_get_entities_from_ledger(thrift['pool'], thrift['did'], - authdecrypted_alice_apply_loan_proof['identifiers'], + apply_loan_proof_object['identifiers'], thrift['name'], requested_timestamp) logger.info("\"Thrift\" -> Verify \"Loan-Application-Basic\" Proof from Alice") assert 'Permanent' == \ - authdecrypted_alice_apply_loan_proof['requested_proof']['revealed_attrs']['attr1_referent']['raw'] + apply_loan_proof_object['requested_proof']['revealed_attrs']['attr1_referent']['raw'] + await apply_loan_basic() assert await anoncreds.verifier_verify_proof(thrift['apply_loan_proof_request'], - thrift['alice_apply_loan_proof'], + thrift['apply_loan_proof'], thrift['schemas_for_loan_app'], thrift['cred_defs_for_loan_app'], thrift['revoc_defs_for_loan_app'], @@ -788,21 +646,8 @@ async def apply_loan_basic(): 'requested_predicates': {} }) - logger.info("\"Thrift\" -> Get key for Alice did") - thrift['alice_key_for_thrift'] = await did.key_for_did(thrift['pool'], thrift['wallet'], - thrift['alice_connection_response']['did']) - - logger.info("\"Thrift\" -> Authcrypt \"Loan-Application-KYC\" Proof Request for Alice") - thrift['authcrypted_apply_loan_kyc_proof_request'] = \ - await crypto.auth_crypt(thrift['wallet'], thrift['key_for_alice'], thrift['alice_key_for_thrift'], - thrift['apply_loan_kyc_proof_request'].encode('utf-8')) - - logger.info("\"Thrift\" -> Send authcrypted \"Loan-Application-KYC\" Proof Request to Alice") - alice['authcrypted_apply_loan_kyc_proof_request'] = thrift['authcrypted_apply_loan_kyc_proof_request'] - - logger.info("\"Alice\" -> Authdecrypt \"Loan-Application-KYC\" Proof Request from Thrift") - alice['thrift_key_for_alice'], alice['apply_loan_kyc_proof_request'], _ = \ - await auth_decrypt(alice['wallet'], alice['key_for_thrift'], alice['authcrypted_apply_loan_kyc_proof_request']) + logger.info("\"Thrift\" -> Send \"Loan-Application-KYC\" Proof Request to Alice") + alice['apply_loan_kyc_proof_request'] = thrift['apply_loan_kyc_proof_request'] logger.info("\"Alice\" -> Get credentials for \"Loan-Application-KYC\" Proof Request") @@ -821,8 +666,8 @@ async def apply_loan_basic(): cred_for_attr3['referent']: cred_for_attr3} alice['schemas_for_loan_kyc_app'], alice['cred_defs_for_loan_kyc_app'], alice['revoc_states_for_loan_kyc_app'] = \ - await prover_get_entities_from_ledger(alice['pool'], alice['did_for_thrift'], - alice['creds_for_apply_loan_kyc_proof'], alice['name'],) + await prover_get_entities_from_ledger(alice['pool'], alice['did'], + alice['creds_for_apply_loan_kyc_proof'], alice['name'], ) logger.info("\"Alice\" -> Create \"Loan-Application-KYC\" Proof") revoc_states_for_loan_app = json.loads(alice['revoc_states_for_loan_kyc_app']) @@ -832,9 +677,12 @@ async def apply_loan_basic(): alice['apply_loan_kyc_requested_creds'] = json.dumps({ 'self_attested_attributes': {}, 'requested_attributes': { - 'attr1_referent': {'cred_id': cred_for_attr1['referent'], 'revealed': True, 'timestamp': timestamp_for_attr1}, - 'attr2_referent': {'cred_id': cred_for_attr2['referent'], 'revealed': True, 'timestamp': timestamp_for_attr2}, - 'attr3_referent': {'cred_id': cred_for_attr3['referent'], 'revealed': True, 'timestamp': timestamp_for_attr3} + 'attr1_referent': {'cred_id': cred_for_attr1['referent'], 'revealed': True, + 'timestamp': timestamp_for_attr1}, + 'attr2_referent': {'cred_id': cred_for_attr2['referent'], 'revealed': True, + 'timestamp': timestamp_for_attr2}, + 'attr3_referent': {'cred_id': cred_for_attr3['referent'], 'revealed': True, + 'timestamp': timestamp_for_attr3} }, 'requested_predicates': {} }) @@ -845,17 +693,9 @@ async def apply_loan_basic(): alice['schemas_for_loan_kyc_app'], alice['cred_defs_for_loan_kyc_app'], alice['revoc_states_for_loan_kyc_app']) - logger.info("\"Alice\" -> Authcrypt \"Loan-Application-KYC\" Proof for Thrift") - alice['authcrypted_alice_apply_loan_kyc_proof'] = \ - await crypto.auth_crypt(alice['wallet'], alice['key_for_thrift'], alice['thrift_key_for_alice'], - alice['apply_loan_kyc_proof'].encode('utf-8')) - - logger.info("\"Alice\" -> Send authcrypted \"Loan-Application-KYC\" Proof to Thrift") - thrift['authcrypted_alice_apply_loan_kyc_proof'] = alice['authcrypted_alice_apply_loan_kyc_proof'] - - logger.info("\"Thrift\" -> Authdecrypted \"Loan-Application-KYC\" Proof from Alice") - _, thrift['alice_apply_loan_kyc_proof'], alice_apply_loan_kyc_proof = \ - await auth_decrypt(thrift['wallet'], thrift['key_for_alice'], thrift['authcrypted_alice_apply_loan_kyc_proof']) + logger.info("\"Alice\" -> Send \"Loan-Application-KYC\" Proof to Thrift") + thrift['apply_loan_kyc_proof'] = alice['apply_loan_kyc_proof'] + apply_loan_kyc_proof_object = json.loads(thrift['apply_loan_kyc_proof']) logger.info("\"Thrift\" -> Get Schemas, Credential Definitions and Revocation Registries from Ledger" " required for Proof verifying") @@ -863,19 +703,20 @@ async def apply_loan_basic(): thrift['schemas_for_loan_kyc_app'], thrift['cred_defs_for_loan_kyc_app'], thrift['revoc_defs_for_loan_kyc_app'], \ thrift['revoc_regs_for_loan_kyc_app'] = \ await verifier_get_entities_from_ledger(thrift['pool'], thrift['did'], - alice_apply_loan_kyc_proof['identifiers'], thrift['name']) + apply_loan_kyc_proof_object['identifiers'], thrift['name']) logger.info("\"Thrift\" -> Verify \"Loan-Application-KYC\" Proof from Alice") assert 'Alice' == \ - alice_apply_loan_kyc_proof['requested_proof']['revealed_attrs']['attr1_referent']['raw'] + apply_loan_kyc_proof_object['requested_proof']['revealed_attrs']['attr1_referent']['raw'] assert 'Garcia' == \ - alice_apply_loan_kyc_proof['requested_proof']['revealed_attrs']['attr2_referent']['raw'] + apply_loan_kyc_proof_object['requested_proof']['revealed_attrs']['attr2_referent']['raw'] assert '123-45-6789' == \ - alice_apply_loan_kyc_proof['requested_proof']['revealed_attrs']['attr3_referent']['raw'] + apply_loan_kyc_proof_object['requested_proof']['revealed_attrs']['attr3_referent']['raw'] assert await anoncreds.verifier_verify_proof(thrift['apply_loan_kyc_proof_request'], - thrift['alice_apply_loan_kyc_proof'], - thrift['schemas_for_loan_kyc_app'], thrift['cred_defs_for_loan_kyc_app'], + thrift['apply_loan_kyc_proof'], + thrift['schemas_for_loan_kyc_app'], + thrift['cred_defs_for_loan_kyc_app'], thrift['revoc_defs_for_loan_kyc_app'], thrift['revoc_regs_for_loan_kyc_app']) @@ -907,7 +748,7 @@ async def apply_loan_basic(): await apply_loan_basic() assert not await anoncreds.verifier_verify_proof(thrift['apply_loan_proof_request'], - thrift['alice_apply_loan_proof'], + thrift['apply_loan_proof'], thrift['schemas_for_loan_app'], thrift['cred_defs_for_loan_app'], thrift['revoc_defs_for_loan_app'], @@ -921,23 +762,28 @@ async def apply_loan_basic(): logger.info("\"Government\" -> Close and Delete wallet") await wallet.close_wallet(government['wallet']) - await wallet.delete_wallet(wallet_config("delete", government['wallet_config']), wallet_credentials("delete", government['wallet_credentials'])) + await wallet.delete_wallet(wallet_config("delete", government['wallet_config']), + wallet_credentials("delete", government['wallet_credentials'])) logger.info("\"Faber\" -> Close and Delete wallet") await wallet.close_wallet(faber['wallet']) - await wallet.delete_wallet(wallet_config("delete", faber['wallet_config']), wallet_credentials("delete", faber['wallet_credentials'])) + await wallet.delete_wallet(wallet_config("delete", faber['wallet_config']), + wallet_credentials("delete", faber['wallet_credentials'])) logger.info("\"Acme\" -> Close and Delete wallet") await wallet.close_wallet(acme['wallet']) - await wallet.delete_wallet(wallet_config("delete", acme['wallet_config']), wallet_credentials("delete", acme['wallet_credentials'])) + await wallet.delete_wallet(wallet_config("delete", acme['wallet_config']), + wallet_credentials("delete", acme['wallet_credentials'])) logger.info("\"Thrift\" -> Close and Delete wallet") await wallet.close_wallet(thrift['wallet']) - await wallet.delete_wallet(wallet_config("delete", thrift['wallet_config']), wallet_credentials("delete", thrift['wallet_credentials'])) + await wallet.delete_wallet(wallet_config("delete", thrift['wallet_config']), + wallet_credentials("delete", thrift['wallet_credentials'])) logger.info("\"Alice\" -> Close and Delete wallet") await wallet.close_wallet(alice['wallet']) - await wallet.delete_wallet(wallet_config("delete", alice['wallet_config']), wallet_credentials("delete", alice['wallet_credentials'])) + await wallet.delete_wallet(wallet_config("delete", alice['wallet_config']), + wallet_credentials("delete", alice['wallet_credentials'])) logger.info("Close and Delete pool") await pool.close_pool_ledger(pool_['handle']) @@ -946,62 +792,6 @@ async def apply_loan_basic(): logger.info("Getting started -> done") -async def onboarding(_from, to): - logger.info("\"{}\" -> Create and store in Wallet \"{} {}\" DID".format(_from['name'], _from['name'], to['name'])) - (from_to_did, from_to_key) = await did.create_and_store_my_did(_from['wallet'], "{}") - - logger.info("\"{}\" -> Send Nym to Ledger for \"{} {}\" DID".format(_from['name'], _from['name'], to['name'])) - await send_nym(_from['pool'], _from['wallet'], _from['did'], from_to_did, from_to_key, None) - - logger.info("\"{}\" -> Send connection request to {} with \"{} {}\" DID and nonce" - .format(_from['name'], to['name'], _from['name'], to['name'])) - connection_request = { - 'did': from_to_did, - 'nonce': 123456789 - } - - if 'wallet' not in to: - logger.info("\"{}\" -> Create wallet".format(to['name'])) - try: - await wallet.create_wallet(wallet_config("create", to['wallet_config']), wallet_credentials("create", to['wallet_credentials'])) - except IndyError as ex: - if ex.error_code == ErrorCode.PoolLedgerConfigAlreadyExistsError: - pass - to['wallet'] = await wallet.open_wallet(wallet_config("open", to['wallet_config']), wallet_credentials("open", to['wallet_credentials'])) - - logger.info("\"{}\" -> Create and store in Wallet \"{} {}\" DID".format(to['name'], to['name'], _from['name'])) - (to_from_did, to_from_key) = await did.create_and_store_my_did(to['wallet'], "{}") - - logger.info("\"{}\" -> Get key for did from \"{}\" connection request".format(to['name'], _from['name'])) - from_to_verkey = await did.key_for_did(_from['pool'], to['wallet'], connection_request['did']) - - logger.info("\"{}\" -> Anoncrypt connection response for \"{}\" with \"{} {}\" DID, verkey and nonce" - .format(to['name'], _from['name'], to['name'], _from['name'])) - to['connection_response'] = json.dumps({ - 'did': to_from_did, - 'verkey': to_from_key, - 'nonce': connection_request['nonce'] - }) - to['anoncrypted_connection_response'] = \ - await crypto.anon_crypt(from_to_verkey, to['connection_response'].encode('utf-8')) - - logger.info("\"{}\" -> Send anoncrypted connection response to \"{}\"".format(to['name'], _from['name'])) - _from['anoncrypted_connection_response'] = to['anoncrypted_connection_response'] - - logger.info("\"{}\" -> Anondecrypt connection response from \"{}\"".format(_from['name'], to['name'])) - _from['connection_response'] = \ - json.loads((await crypto.anon_decrypt(_from['wallet'], from_to_key, - _from['anoncrypted_connection_response'])).decode("utf-8")) - - logger.info("\"{}\" -> Authenticates \"{}\" by comparision of Nonce".format(_from['name'], to['name'])) - assert connection_request['nonce'] == _from['connection_response']['nonce'] - - logger.info("\"{}\" -> Send Nym to Ledger for \"{} {}\" DID".format(_from['name'], to['name'], _from['name'])) - await send_nym(_from['pool'], _from['wallet'], _from['did'], to_from_did, to_from_key, None) - - return from_to_did, from_to_key, to_from_did, to_from_key, _from['connection_response'] - - def wallet_config(operation, wallet_config_str): if not args.storage_type: return wallet_config_str @@ -1009,7 +799,7 @@ def wallet_config(operation, wallet_config_str): wallet_config_json['storage_type'] = args.storage_type if args.config: wallet_config_json['storage_config'] = json.loads(args.config) - #print(operation, json.dumps(wallet_config_json)) + # print(operation, json.dumps(wallet_config_json)) return json.dumps(wallet_config_json) @@ -1019,37 +809,35 @@ def wallet_credentials(operation, wallet_credentials_str): wallet_credentials_json = json.loads(wallet_credentials_str) if args.creds: wallet_credentials_json['storage_credentials'] = json.loads(args.creds) - #print(operation, json.dumps(wallet_credentials_json)) + # print(operation, json.dumps(wallet_credentials_json)) return json.dumps(wallet_credentials_json) -async def get_verinym(_from, from_to_did, from_to_key, to, to_from_did, to_from_key): - logger.info("\"{}\" -> Create and store in Wallet \"{}\" new DID".format(to['name'], to['name'])) - (to_did, to_key) = await did.create_and_store_my_did(to['wallet'], "{}") - - logger.info("\"{}\" -> Authcrypt \"{} DID info\" for \"{}\"".format(to['name'], to['name'], _from['name'])) - to['did_info'] = json.dumps({ - 'did': to_did, - 'verkey': to_key - }) - to['authcrypted_did_info'] = \ - await crypto.auth_crypt(to['wallet'], to_from_key, from_to_key, to['did_info'].encode('utf-8')) +async def create_wallet(identity): + logger.info("\"{}\" -> Create wallet".format(identity['name'])) + try: + await wallet.create_wallet(wallet_config("create", identity['wallet_config']), + wallet_credentials("create", identity['wallet_credentials'])) + except IndyError as ex: + if ex.error_code == ErrorCode.PoolLedgerConfigAlreadyExistsError: + pass + identity['wallet'] = await wallet.open_wallet(wallet_config("open", identity['wallet_config']), + wallet_credentials("open", identity['wallet_credentials'])) - logger.info("\"{}\" -> Send authcrypted \"{} DID info\" to {}".format(to['name'], to['name'], _from['name'])) - logger.info("\"{}\" -> Authdecrypted \"{} DID info\" from {}".format(_from['name'], to['name'], to['name'])) - sender_verkey, authdecrypted_did_info_json, authdecrypted_did_info = \ - await auth_decrypt(_from['wallet'], from_to_key, to['authcrypted_did_info']) +async def getting_verinym(from_, to): + await create_wallet(to) - logger.info("\"{}\" -> Authenticate {} by comparision of Verkeys".format(_from['name'], to['name'], )) - assert sender_verkey == await did.key_for_did(_from['pool'], _from['wallet'], to_from_did) + (to['did'], to['key']) = await did.create_and_store_my_did(to['wallet'], "{}") - logger.info("\"{}\" -> Send Nym to Ledger for \"{} DID\" with {} Role" - .format(_from['name'], to['name'], to['role'])) - await send_nym(_from['pool'], _from['wallet'], _from['did'], authdecrypted_did_info['did'], - authdecrypted_did_info['verkey'], to['role']) + from_['info'] = { + 'did': to['did'], + 'verkey': to['key'], + 'role': to['role'] or None + } - return to_did + await send_nym(from_['pool'], from_['wallet'], from_['did'], from_['info']['did'], + from_['info']['verkey'], from_['info']['role']) async def send_nym(pool_handle, wallet_handle, _did, new_did, new_key, role): @@ -1092,7 +880,8 @@ def get_timestamp_for_attribute(cred_for_attribute, revoc_states): return None -async def prover_get_entities_from_ledger(pool_handle, _did, identifiers, actor, timestamp_from=None, timestamp_to=None): +async def prover_get_entities_from_ledger(pool_handle, _did, identifiers, actor, timestamp_from=None, + timestamp_to=None): schemas = {} cred_defs = {} rev_states = {} @@ -1171,13 +960,6 @@ async def verifier_get_entities_from_ledger(pool_handle, _did, identifiers, acto return json.dumps(schemas), json.dumps(cred_defs), json.dumps(rev_reg_defs), json.dumps(rev_regs) -async def auth_decrypt(wallet_handle, key, message): - from_verkey, decrypted_message_json = await crypto.auth_decrypt(wallet_handle, key, message) - decrypted_message_json = decrypted_message_json.decode("utf-8") - decrypted_message = json.loads(decrypted_message_json) - return from_verkey, decrypted_message_json, decrypted_message - - if __name__ == '__main__': run_coroutine(run) time.sleep(1) # FIXME waiting for libindy thread complete diff --git a/samples/python/src/txn_author_agreement.py b/samples/python/src/txn_author_agreement.py index 219ea7065d..71938ef3bd 100644 --- a/samples/python/src/txn_author_agreement.py +++ b/samples/python/src/txn_author_agreement.py @@ -64,7 +64,9 @@ async def demo(): txn_agreement_req = \ await ledger.build_txn_author_agreement_request(trustee['did'], trustee['txn_agreement']['text'], - trustee['txn_agreement']['version']) + trustee['txn_agreement']['version'], + int(time.time()), + None) await ledger.sign_and_submit_request(trustee['pool'], trustee['wallet'], trustee['did'], txn_agreement_req) # User initialization @@ -136,7 +138,7 @@ async def demo(): # Trustee reset Transaction Agreement txn_agreement_req = \ - await ledger.build_txn_author_agreement_request(trustee['did'], '', str(randint(0, 1000))) + await ledger.build_disable_all_txn_author_agreements_request(trustee['did']) await ledger.sign_and_submit_request(trustee['pool'], trustee['wallet'], trustee['did'], txn_agreement_req) # User sends ATTRIB transaction to Ledger without Transaction Agreement diff --git a/vcx/README.md b/vcx/README.md index a71d6d5e42..4aa429003e 100644 --- a/vcx/README.md +++ b/vcx/README.md @@ -190,12 +190,70 @@ The following wrappers are tested and complete. * [iOS](wrappers/ios/README.md) * [NodeJS](wrappers/node/README.md) +## Library initialization +Libvcx library must be initialized with one of the functions: +* `vcx_init_with_config` - initializes with passed as JSON string. +* `vcx_init` - initializes with a path to the file containing . +* `vcx_init_minimal` - initializes with the minimal (without any agency configuration). + +Each library function will use this data after the initialization. +The list of options can be find [here](../docs/configuration.md#vcx) +An example of file can be found [here](../vcx/libvcx/sample_config/config.json) + +If the library works with an agency `vcx_agent_provision` function must be called before initialization to populate configuration and wallet for this agent. +The result of this function is JSON which can be extended and used for initialization. + +To change a user must call `vcx_shutdown` and then call initialization function again. + ## Getting started guide [The tutorial](docs/getting-started/getting-started.md) which introduces Libvcx and explains how the whole ecosystem works, and how the functions in the SDK can be used to construct rich clients. ### Example use For the main workflow example check [demo](https://github.com/hyperledger/indy-sdk/tree/master/vcx/wrappers/python3/demo). +## Actors +Libvcx provides APIs for acting as different actors. +The actor states, transitions and messages depend on communication method is used. + +There are two communication methods: `proprietary` and `aries`. The default communication method is `proprietary`. +The communication method can be specified as a config option on one of *_init functions. + +* Connection: + * Inviter + * [API](https://github.com/hyperledger/indy-sdk/tree/master/vcx/libvcx/api/connection.rs) + * State diagram + * [proprietary](docs/states/proprietary/connection-inviter.puml) + * [aries](docs/states/aries/connection-inviter.puml) + * Invitee + * [API](https://github.com/hyperledger/indy-sdk/tree/master/vcx/libvcx/api/connection.rs) + * State diagram + * [proprietary](docs/states/proprietary/connection-invitee.puml) + * [aries](docs/states/aries/connection-invitee.puml) + +* Credential Issuance: + * Issuer + * [API](https://github.com/hyperledger/indy-sdk/tree/master/vcx/libvcx/api/issuer_credential.rs) + * State diagram + * [proprietary](docs/states/proprietary/issuer-credential.puml) + * [aries](docs/states/aries/issuer-credential.puml) + * Holder + * [API](https://github.com/hyperledger/indy-sdk/tree/master/vcx/libvcx/api/credential.rs) + * State diagram + * [proprietary](docs/states/proprietary/credential.puml) + * [aries](docs/states/aries/credential.puml) + +* Credential Presentation: + * Verifier + * [API](https://github.com/hyperledger/indy-sdk/tree/master/vcx/libvcx/api/proof.rs) + * State diagram + * [proprietary](docs/states/proprietary/proof.puml) + * [aries](docs/states/aries/proof.puml) + * Prover + * [API](https://github.com/hyperledger/indy-sdk/tree/master/vcx/libvcx/api/disclosed_proof.rs) + * State diagram + * [proprietary](docs/states/proprietary/disclosed-proof.puml) + * [aries](docs/states/aries/disclosed-proof.puml) + ## How to migrate The documents that provide necessary information for Libvcx migrations. @@ -203,3 +261,4 @@ The documents that provide necessary information for Libvcx migrations. * [v0.2.x → v0.3.0](docs/migration-guide-0.2.x-0.3.0.md) * [v0.3.x → v0.4.0](docs/migration-guide-0.3.x-0.4.0.md) * [v0.4.x → v0.5.0](docs/migration-guide-0.4.x-0.5.0.md) +* [v0.5.x → v0.6.0](docs/migration-guide-0.5.x-0.6.0.md) diff --git a/vcx/docs/connection-invitee.puml b/vcx/docs/aries/connection/connection-invitee.puml similarity index 100% rename from vcx/docs/connection-invitee.puml rename to vcx/docs/aries/connection/connection-invitee.puml diff --git a/vcx/docs/connection-invitee.svg b/vcx/docs/aries/connection/connection-invitee.svg similarity index 100% rename from vcx/docs/connection-invitee.svg rename to vcx/docs/aries/connection/connection-invitee.svg diff --git a/vcx/docs/connection-inviter.puml b/vcx/docs/aries/connection/connection-inviter.puml similarity index 100% rename from vcx/docs/connection-inviter.puml rename to vcx/docs/aries/connection/connection-inviter.puml diff --git a/vcx/docs/connection-inviter.svg b/vcx/docs/aries/connection/connection-inviter.svg similarity index 100% rename from vcx/docs/connection-inviter.svg rename to vcx/docs/aries/connection/connection-inviter.svg diff --git a/vcx/docs/migration-guide-0.2.x-0.3.0.md b/vcx/docs/migration-guide-0.2.x-0.3.0.md index cf1f59d39d..a794663b0a 100644 --- a/vcx/docs/migration-guide-0.2.x-0.3.0.md +++ b/vcx/docs/migration-guide-0.2.x-0.3.0.md @@ -104,7 +104,7 @@ These functions check the message any state change and update the state attribut - Checks the message any connection state change and updates the the state attribute. + Checks the message any connection state change and updates the state attribute. diff --git a/vcx/docs/migration-guide-0.3.x-0.4.0.md b/vcx/docs/migration-guide-0.3.x-0.4.0.md index b4c5137ffb..0bf62814b5 100644 --- a/vcx/docs/migration-guide-0.3.x-0.4.0.md +++ b/vcx/docs/migration-guide-0.3.x-0.4.0.md @@ -39,13 +39,13 @@ This removes the dependency on an agency/cloud-agent and allows the user of the #### Credential API `vcx_credential_get_request_msg` - Get the credential request message that can be sent to the specified connection. -`vcx_credential_update_state_with_message` - Checks for any state change from the given message and updates the the state attribute. +`vcx_credential_update_state_with_message` - Checks for any state change from the given message and updates the state attribute. #### Disclosed Proof API `vcx_disclosed_proof_get_proof_msg` - Get the proof message for sending. -`vcx_disclosed_proof_update_state_with_message` - Checks for any state change from the given message and updates the the state attribute. +`vcx_disclosed_proof_update_state_with_message` - Checks for any state change from the given message and updates the state attribute. #### Issuer Credential API diff --git a/vcx/docs/migration-guide-0.5.x-0.6.0.md b/vcx/docs/migration-guide-0.5.x-0.6.0.md index 6d8d24cd4c..8aeceff273 100644 --- a/vcx/docs/migration-guide-0.5.x-0.6.0.md +++ b/vcx/docs/migration-guide-0.5.x-0.6.0.md @@ -7,6 +7,8 @@ to simplify their transition to LibVCX 0.5 from LibVCX 0.6.x. * [API]() * [Vcx API](#vcx-api) +* [Libvcx 0.6.0 to 0.6.1 migration](#libvcx-060-to-061-migration-guide) +* [Libvcx 0.6.1 to 0.6.2 migration](#libvcx-061-to-062-migration-guide) #### Vcx API @@ -52,3 +54,43 @@ This setting is used within Discover Features protocol to specify the set of pro The following actors are implemented by default: `[inviter, invitee, issuer, holder, prover, verifier, sender, receiver]`. You need to edit this list in case application supports the less number of actors. + +## Libvcx 0.6.0 to 0.6.1 migration Guide + +The Libvcx 0.6.1 release contains fixes that don't affect API functions and behaviour. + +## Libvcx 0.6.1 to 0.6.2 migration Guide + + We extended the support for Aries protocols: + * Basic Message (https://github.com/hyperledger/aries-rfcs/tree/master/features/0095-basic-message) + * Updated `vcx_connection_send_message` function to send any kind of messages: + * if the message is matched to a known aries message - send as is. + * if the message isn't known - wrap and send as `basic` message. + * Accept incoming messages with `basicmessage` type. Use `download_message` to download messages from an agency. + + +Updated library to support "names" parameter in Proof Request Revealed Attributes (IS-1381). +Here is the current format of `revealed_attrs` parameter accepting by `vcx_proof_create` function: +``` +requested_attrs: Describes requested attribute + { + "name": Optional, // attribute name, (case insensitive and ignore spaces) + "names": Optional<[string, string]>, // attribute names, (case insensitive and ignore spaces) + // NOTE: should either be "name" or "names", not both and not none of them. + // Use "names" to specify several attributes that have to match a single credential. + "restrictions": (filter_json) { + "schema_id": string, (Optional) + "schema_issuer_did": string, (Optional) + "schema_name": string, (Optional) + "schema_version": string, (Optional) + "issuer_did": string, (Optional) + "cred_def_id": string, (Optional) + }, + "non_revoked": { + "from": Optional<(u64)> Requested time represented as a total number of seconds from Unix Epoch, Optional + "to": Optional<(u64)> + //Requested time represented as a total number of seconds from Unix Epoch, Optional + } + } +``` +Note: Use `names` to request from Prover several attributes that must correspond to a single credential. \ No newline at end of file diff --git a/vcx/docs/states/aries/connection-invitee.puml b/vcx/docs/states/aries/connection-invitee.puml new file mode 100644 index 0000000000..ca192a5f6c --- /dev/null +++ b/vcx/docs/states/aries/connection-invitee.puml @@ -0,0 +1,19 @@ +@startuml +title + Connection API as Invitee + + The diagram shows Connection object state transitions in case acting as an Invitee +end title + + +[*] --> VcxStateOfferSent: vcx_connection_create_with_invite(Invitation) + +VcxStateOfferSent --> VcxStateRequestReceived: vcx_connection_connect + +note left of VcxStateRequestReceived : use vcx_connection_update_state \n or vcx_connection_update_state_with_message \n for connection status updates + +VcxStateRequestReceived --> VcxStateAccepted: received `ConnectionResponse` message + +VcxStateRequestReceived --> VcxStateNone: received `ConnectionProblemReport` message + +@enduml \ No newline at end of file diff --git a/vcx/docs/states/aries/connection-inviter.puml b/vcx/docs/states/aries/connection-inviter.puml new file mode 100644 index 0000000000..97aec97fc7 --- /dev/null +++ b/vcx/docs/states/aries/connection-inviter.puml @@ -0,0 +1,23 @@ +@startuml +title + Connection API as Inviter + + The diagram shows Connection object state transitions in case acting as an Inviter +end title + +[*] --> VcxStateInitialized: vcx_connection_create + +VcxStateInitialized --> VcxStateOfferSent: vcx_connection_connect + +note left of VcxStateOfferSent : use vcx_connection_update_state \n or vcx_connection_update_state_with_message \n for connection status updates + +VcxStateOfferSent --> VcxStateRequestReceived: received `ConnectionRequest` message +VcxStateOfferSent --> VcxStateNone: received `ConnectionProblemReport` message + +note left of VcxStateRequestReceived : use vcx_connection_update_state \n or vcx_connection_update_state_with_message \n for connection status updates + +VcxStateRequestReceived --> VcxStateAccepted: received `Ack` message +VcxStateRequestReceived --> VcxStateAccepted: received `Ping` message +VcxStateRequestReceived --> VcxStateNone: received `ConnectionProblemReport` message + +@enduml \ No newline at end of file diff --git a/vcx/docs/states/aries/credential.puml b/vcx/docs/states/aries/credential.puml new file mode 100644 index 0000000000..28d687e263 --- /dev/null +++ b/vcx/docs/states/aries/credential.puml @@ -0,0 +1,17 @@ +@startuml +title + Credential API as Holder + + The diagram shows Credential object state transitions in case acting as a Holder. +end title + +[*] --> VcxStateRequestReceived: vcx_credential_create_with_offer(CredentialOffer) + +VcxStateRequestReceived --> VcxStateOfferSent: vcx_credential_send_request + +note left of VcxStateOfferSent : use vcx_credential_update_state \n or vcx_credential_update_state_with_message \n for connection status updates + +VcxStateOfferSent --> VcxStateAccepted: received `Credential` message +VcxStateOfferSent --> VcxStateNone: received `ProblemReport` message + +@enduml \ No newline at end of file diff --git a/vcx/docs/states/aries/disclosed-proof.puml b/vcx/docs/states/aries/disclosed-proof.puml new file mode 100644 index 0000000000..fd8be9aa6b --- /dev/null +++ b/vcx/docs/states/aries/disclosed-proof.puml @@ -0,0 +1,21 @@ +@startuml +title + DisclosedProof API as Prover + + The diagram shows DisclosedProof object state transitions in case acting as a Prover. +end title + +[*] --> VcxStateRequestReceived: vcx_disclosed_proof_create_with_request + +VcxStateRequestReceived --> VcxStateRequestReceived: vcx_disclosed_proof_generate_proof + +VcxStateRequestReceived --> VcxStateOfferSent: vcx_disclosed_proof_send_proof + +VcxStateRequestReceived --> VcxStateNone: vcx_disclosed_proof_decline_presentation_request + +note left of VcxStateOfferSent : use vcx_disclosed_proof_update_state \n or vcx_disclosed_proof_update_state_with_message \n for connection status updates + +VcxStateOfferSent --> VcxStateAccepted: received `Ack` message +VcxStateOfferSent --> VcxStateNone: received `ProblemReport` message + +@enduml \ No newline at end of file diff --git a/vcx/docs/states/aries/issuer-credential.puml b/vcx/docs/states/aries/issuer-credential.puml new file mode 100644 index 0000000000..93966f33f1 --- /dev/null +++ b/vcx/docs/states/aries/issuer-credential.puml @@ -0,0 +1,23 @@ +@startuml +title + IssuerCredential API as Issuer + + The diagram shows IssuerCredential object state transitions in case acting as an Issuer. +end title + +[*] --> VcxStateInitialized: vcx_issuer_create_credential + +VcxStateInitialized --> VcxStateOfferSent: vcx_issuer_send_credential_offer + +note left of VcxStateOfferSent : use vcx_issuer_credential_update_state \n or vcx_issuer_credential_update_state_with_message \n for connection status updates + +VcxStateOfferSent --> VcxStateRequestReceived: received `CredentialRequest` message +VcxStateOfferSent --> VcxStateNone: received `ProblemReport` message + +VcxStateRequestReceived --> VcxStateAccepted: vcx_issuer_send_credential + +note left of VcxStateAccepted : use vcx_issuer_credential_update_state \n or vcx_issuer_credential_update_state_with_message \n for connection status updates + +VcxStateAccepted --> VcxStateAccepted: received `Ack` message + +@enduml \ No newline at end of file diff --git a/vcx/docs/states/aries/proof.puml b/vcx/docs/states/aries/proof.puml new file mode 100644 index 0000000000..141da92478 --- /dev/null +++ b/vcx/docs/states/aries/proof.puml @@ -0,0 +1,18 @@ +@startuml +title + Proof API as Verifier + + The diagram shows Proof object state transitions in case acting as a Verifier. +end title + +[*] --> VcxStateInitialized: vcx_proof_create + +VcxStateInitialized --> VcxStateOfferSent: vcx_credential_send_request + +note left of VcxStateOfferSent : use vcx_proof_update_state \n or vcx_proof_update_state_with_message \n for connection status updates + +VcxStateOfferSent --> VcxStateAccepted: received `Presentation` message +VcxStateOfferSent --> VcxStateNone: received `PresentationProposal` message +VcxStateOfferSent --> VcxStateNone: received `ProblemReport` message + +@enduml \ No newline at end of file diff --git a/vcx/docs/states/proprietary/connection-invitee.puml b/vcx/docs/states/proprietary/connection-invitee.puml new file mode 100644 index 0000000000..d1191ee4b1 --- /dev/null +++ b/vcx/docs/states/proprietary/connection-invitee.puml @@ -0,0 +1,12 @@ +@startuml +title + Connection API as Invitee + + The diagram shows Connection object state transitions in case acting as an Invitee +end title + +[*] --> VcxStateRequestReceived: vcx_connection_create_with_invite(Invitation) + +VcxStateRequestReceived --> VcxStateAccepted: vcx_connection_connect + +@enduml \ No newline at end of file diff --git a/vcx/docs/states/proprietary/connection-inviter.puml b/vcx/docs/states/proprietary/connection-inviter.puml new file mode 100644 index 0000000000..3343049ccb --- /dev/null +++ b/vcx/docs/states/proprietary/connection-inviter.puml @@ -0,0 +1,16 @@ +@startuml +title + Connection API as Inviter + + The diagram shows Connection object state transitions in case acting as an Inviter +end title + +[*] --> VcxStateInitialized: vcx_connection_create + +VcxStateInitialized --> VcxStateOfferSent: vcx_connection_connect + +note left of VcxStateOfferSent : use vcx_connection_update_state \n or vcx_connection_update_state_with_message \n for connection status updates + +VcxStateOfferSent --> VcxStateAccepted: vcx_connection_update_state\n received `connReqAnswer` message + +@enduml \ No newline at end of file diff --git a/vcx/docs/states/proprietary/credential.puml b/vcx/docs/states/proprietary/credential.puml new file mode 100644 index 0000000000..02acde3a66 --- /dev/null +++ b/vcx/docs/states/proprietary/credential.puml @@ -0,0 +1,16 @@ +@startuml +title + Credential API as Holder + + The diagram shows Credential object state transitions in case acting as a Holder. +end title + +[*] --> VcxStateRequestReceived: vcx_credential_create_with_offer(CredentialOffer) + +VcxStateRequestReceived --> VcxStateOfferSent: vcx_credential_send_request + +note left of VcxStateOfferSent : use vcx_credential_update_state \n or vcx_credential_update_state_with_message \n for connection status updates + +VcxStateOfferSent --> VcxStateAccepted: received `CRED` message + +@enduml \ No newline at end of file diff --git a/vcx/docs/states/proprietary/disclosed-proof.puml b/vcx/docs/states/proprietary/disclosed-proof.puml new file mode 100644 index 0000000000..bcfd45956b --- /dev/null +++ b/vcx/docs/states/proprietary/disclosed-proof.puml @@ -0,0 +1,14 @@ +@startuml +title + DisclosedProof API as Prover + + The diagram shows DisclosedProof object state transitions in case acting as a Prover. +end title + +[*] --> VcxStateRequestReceived: vcx_disclosed_proof_create_with_request(ProofRequest) + +VcxStateRequestReceived --> VcxStateRequestReceived: vcx_disclosed_proof_generate_proof + +VcxStateRequestReceived --> VcxStateAccepted: vcx_disclosed_proof_send_proof + +@enduml \ No newline at end of file diff --git a/vcx/docs/states/proprietary/issuer-credential.puml b/vcx/docs/states/proprietary/issuer-credential.puml new file mode 100644 index 0000000000..76b73a40f5 --- /dev/null +++ b/vcx/docs/states/proprietary/issuer-credential.puml @@ -0,0 +1,18 @@ +@startuml +title + IssuerCredential API as Issuer + + The diagram shows IssuerCredential object state transitions in case acting as an Issuer. +end title + +[*] --> VcxStateInitialized: vcx_issuer_create_credential + +VcxStateInitialized --> VcxStateOfferSent: vcx_issuer_send_credential_offer + +note left of VcxStateOfferSent : use vcx_issuer_credential_update_state \n or vcx_issuer_credential_update_state_with_message \n for connection status updates + +VcxStateOfferSent --> VcxStateRequestReceived: received `CRED_REQ` message + +VcxStateRequestReceived --> VcxStateAccepted: vcx_issuer_send_credential + +@enduml \ No newline at end of file diff --git a/vcx/docs/states/proprietary/proof.puml b/vcx/docs/states/proprietary/proof.puml new file mode 100644 index 0000000000..bbd426d634 --- /dev/null +++ b/vcx/docs/states/proprietary/proof.puml @@ -0,0 +1,16 @@ +@startuml +title + Proof API as Verifier + + The diagram shows Proof object state transitions in case acting as a Verifier. +end title + +[*] --> VcxStateInitialized: vcx_proof_create + +VcxStateInitialized --> VcxStateOfferSent: vcx_credential_send_request + +note left of VcxStateOfferSent : use vcx_proof_update_state \n or vcx_proof_update_state_with_message \n for connection status updates + +VcxStateOfferSent --> VcxStateAccepted: received `PROOF` message + +@enduml \ No newline at end of file diff --git a/vcx/dummy-cloud-agent/Cargo.lock b/vcx/dummy-cloud-agent/Cargo.lock index 77275c2c72..6bbdd4a706 100644 --- a/vcx/dummy-cloud-agent/Cargo.lock +++ b/vcx/dummy-cloud-agent/Cargo.lock @@ -318,7 +318,7 @@ name = "atty" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -356,7 +356,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -365,8 +365,8 @@ name = "backtrace-sys" version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -406,8 +406,8 @@ name = "brotli-sys" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -416,7 +416,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "brotli-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -444,7 +444,7 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.48" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -530,7 +530,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -632,7 +632,7 @@ name = "dirs" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "redox_users 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -712,7 +712,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -774,7 +774,7 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -813,7 +813,7 @@ name = "hermit-abi" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -821,7 +821,7 @@ name = "hostname" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "winutil 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -930,13 +930,13 @@ dependencies = [ [[package]] name = "indy" -version = "1.14.0" +version = "1.14.2" dependencies = [ "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "indy-sys 1.14.0", + "indy-sys 1.14.2", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "num-derive 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -957,9 +957,9 @@ dependencies = [ "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.12.35 (registry+https://github.com/rust-lang/crates.io-index)", - "indy 1.14.0", + "indy 1.14.2", "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_env_logger 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -977,11 +977,13 @@ dependencies = [ [[package]] name = "indy-sys" -version = "1.14.0" +version = "1.14.2" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "vcpkg 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -990,7 +992,7 @@ name = "iovec" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1035,7 +1037,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.60" +version = "0.2.66" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1043,7 +1045,7 @@ name = "libloading" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1126,8 +1128,8 @@ name = "miniz-sys" version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1148,7 +1150,7 @@ dependencies = [ "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1162,7 +1164,7 @@ version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1183,7 +1185,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "openssl 0.10.26 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1200,7 +1202,7 @@ version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1290,7 +1292,7 @@ version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "hermit-abi 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1302,7 +1304,7 @@ dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.9.53 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1317,8 +1319,8 @@ version = "0.9.53" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", "vcpkg 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1350,7 +1352,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1365,7 +1367,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1467,7 +1469,7 @@ name = "rand" version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1477,7 +1479,7 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1489,7 +1491,7 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1507,7 +1509,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1581,7 +1583,7 @@ name = "rand_jitter" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1593,7 +1595,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1792,7 +1794,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "security-framework-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1877,7 +1879,7 @@ name = "signal-hook" version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "signal-hook-registry 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1887,7 +1889,7 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arc-swap 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1914,7 +1916,7 @@ version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1964,7 +1966,7 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2000,7 +2002,7 @@ name = "time" version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2128,7 +2130,7 @@ version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", "signal-hook 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2209,7 +2211,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2473,7 +2475,7 @@ dependencies = [ "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" "checksum c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb" -"checksum cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)" = "f52a465a666ca3d838ebbf08b241383421412fe7ebb463527bba275526d89f76" +"checksum cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "8dae9c4b8fedcae85592ba623c4fd08cfdab3e3b72d6df780c6ead964a69bfff" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" "checksum chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "31850b4a4d6bae316f7a09e691c944c28299298837edc0a03f755618c23cbc01" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" @@ -2534,7 +2536,7 @@ dependencies = [ "checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" "checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -"checksum libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "d44e80633f007889c7eff624b709ab43c92d708caad982295768a7b13ca3b5eb" +"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" "checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" "checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" "checksum lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff" diff --git a/vcx/dummy-cloud-agent/Cargo.toml b/vcx/dummy-cloud-agent/Cargo.toml index 2964b212c5..0ab19430af 100644 --- a/vcx/dummy-cloud-agent/Cargo.toml +++ b/vcx/dummy-cloud-agent/Cargo.toml @@ -3,12 +3,13 @@ name = "indy-dummy-agent" version = "0.1.0" authors = ["Hyperledger Indy Contributors "] exclude = ['config/*'] +edition = '2018' [dependencies] actix = "0.8.3" actix-web = "1.0.7" bytes = "0.4.10" -failure = "0.1.2" +failure = "0.1.5" futures = "0.1.24" hyper = "0.12.12" lazy_static = "0.2" @@ -26,7 +27,7 @@ reqwest = "0.9.20" uuid = "0.7.4" indy = { path = "../../wrappers/rust" } libloading = "0.5.0" -libc = "0.2.60" +libc = "0.2.66" [dev-dependencies] dirs = "1.0.4" diff --git a/vcx/dummy-cloud-agent/config/pgsql-config.json b/vcx/dummy-cloud-agent/config/pgsql-config.json index 51159e3dce..f56913741a 100644 --- a/vcx/dummy-cloud-agent/config/pgsql-config.json +++ b/vcx/dummy-cloud-agent/config/pgsql-config.json @@ -1,7 +1,6 @@ { "app": { - "prefix": "/agency", - "enable_admin_api": true + "prefix": "/agency" }, "forward_agent": { "did": "VsKV7grR1BUE29mG2Fm2kX", @@ -16,6 +15,12 @@ ], "workers": 1 }, + "server_admin": { + "enabled": false, + "addresses": [ + "127.0.0.1:8090" + ] + }, "wallet_storage": { "config": { "url": "localhost:5432", @@ -34,5 +39,8 @@ "plugin_init_function": null, "plugin_library_path": null }, + "indy_runtime": { + "crypto_thread_pool_size": 4 + }, "protocol_type": "1.0" } \ No newline at end of file diff --git a/vcx/dummy-cloud-agent/config/sample-config.json b/vcx/dummy-cloud-agent/config/sample-config.json index e9c540d0d1..1608ac8409 100644 --- a/vcx/dummy-cloud-agent/config/sample-config.json +++ b/vcx/dummy-cloud-agent/config/sample-config.json @@ -1,7 +1,6 @@ { "app": { - "prefix": "/agency", - "enable_admin_api": false + "prefix": "/agency" }, "forward_agent": { "did": "VsKV7grR1BUE29mG2Fm2kX", @@ -17,6 +16,12 @@ ], "workers": 2 }, + "server_admin": { + "enabled": false, + "addresses": [ + "127.0.0.1:8090" + ] + }, "wallet_storage": { "config": null, "credentials": null, diff --git a/vcx/dummy-cloud-agent/src/actors/admin.rs b/vcx/dummy-cloud-agent/src/actors/admin.rs index 4086c76cd8..e0df15cb59 100644 --- a/vcx/dummy-cloud-agent/src/actors/admin.rs +++ b/vcx/dummy-cloud-agent/src/actors/admin.rs @@ -1,12 +1,14 @@ -use actix::prelude::*; -use actors::{HandleAdminMessage, AdminRegisterForwardAgent, AdminRegisterRouter, AdminRegisterForwardAgentConnection, AdminRegisterAgent, AdminRegisterAgentConnection}; -use failure::{Error, err_msg}; use std::collections::HashMap; -use domain::admin_message::{AdminQuery, ResAdminQuery, ResQueryAdmin}; -use utils::futures::FutureExt; -use futures::{Future}; + +use actix::prelude::*; +use failure::{err_msg, Error}; +use futures::Future; use futures::future::ok; +use crate::actors::{AdminRegisterAgent, AdminRegisterAgentConnection, AdminRegisterForwardAgent, AdminRegisterForwardAgentConnection, AdminRegisterRouter, HandleAdminMessage}; +use crate::domain::admin_message::{AdminQuery, ResAdminQuery, ResQueryAdmin}; +use crate::utils::futures::FutureExt; + pub struct Admin { forward_agent: Option>, forward_agent_connections: HashMap>, @@ -27,7 +29,7 @@ impl Admin { } pub fn handle_admin_message(&self, admin_msg: &AdminQuery) - -> Box> { + -> Box> { match admin_msg { AdminQuery::GetDetailForwardAgents => { if let Some(addr) = self.forward_agent.as_ref() { @@ -95,7 +97,7 @@ impl Actor for Admin { } impl Handler for Admin { - type Result = Box>; + type Result = Box>; fn handle(&mut self, msg: HandleAdminMessage, _cnxt: &mut Self::Context) -> Self::Result { trace!("Admin Handler::handle"); @@ -151,3 +153,124 @@ impl Handler for Admin { Ok(()) } } + +#[cfg(test)] +mod tests { + use regex::Regex; + + use crate::domain::admin_message::{GetDetailAgentConnParams, GetDetailAgentParams}; + use crate::utils::tests::*; + + use super::*; + + #[test] + fn get_actor_overview_returns_info() { + let legacy_or_qualified_did_regex = Regex::new("^[a-z0-9]+:([a-z0-9]+):(.*)$|[a-zA-Z0-9]{21,}").unwrap(); + + run_admin_test(|(e_wallet_handle, _, _, _, _, _, admin)| { + admin + .send(HandleAdminMessage(AdminQuery::GetActorOverview)) + .from_err() + .map(move |res| { + if let Ok(ResAdminQuery::Admin(details)) = res { + assert_eq!(details.forward_agent_connections.len(), 1); + assert!(legacy_or_qualified_did_regex.is_match(&details.forward_agent_connections[0])); + assert_eq!(details.agents.len(), 1); + assert!(legacy_or_qualified_did_regex.is_match(&details.agents[0])); + assert_eq!(details.agent_connections.len(), 1); + assert!(legacy_or_qualified_did_regex.is_match(&details.agent_connections[0])); + } else { + panic!("Response was expected to be AdminQuery::GetActorOverview variant, but got {:?}", res); + } + e_wallet_handle + }) + }); + } + + #[test] + fn get_agent_detail_returns_info() { + let legacy_or_qualified_did_regex = Regex::new("^[a-z0-9]+:([a-z0-9]+):(.*)$|[a-zA-Z0-9]{21,}").unwrap(); + let verkey_regex = Regex::new("[a-zA-Z0-9]{42,46}").unwrap(); + + run_admin_test(|(e_wallet_handle, _, _, _, _, _, admin)| { + admin.clone() + .send(HandleAdminMessage(AdminQuery::GetActorOverview)) + .from_err() + .map(move |res| { + if let Ok(ResAdminQuery::Admin(details)) = res { + details.agents[0].to_owned() + } else { + panic!("Response was expected to be ResAdminQuery::Admin variant."); + } + }) + .and_then(move |agent_did| { + admin + .send(HandleAdminMessage(AdminQuery::GetDetailAgent(GetDetailAgentParams { agent_did: agent_did.clone() }))) + .from_err() + .map(move |res| { + if let Ok(ResAdminQuery::Agent(res_query_agent)) = res { + assert!(legacy_or_qualified_did_regex.is_match(&res_query_agent.owner_did)); + assert!(legacy_or_qualified_did_regex.is_match(&res_query_agent.did)); + assert!(verkey_regex.is_match(&res_query_agent.owner_verkey)); + assert!(verkey_regex.is_match(&res_query_agent.verkey)); + assert_eq!(res_query_agent.configs.len(), 0); + assert_eq!(res_query_agent.did, agent_did); + } else { + panic!("Response was expected to be AdminQuery::GetDetailAgent variant, but got {:?}", res); + } + }) + }) + .map(move |_| { + e_wallet_handle + }) + }) + } + + + #[test] + fn get_agent_connection_detail_returns_info() { + let legacy_or_qualified_did_regex = Regex::new("^[a-z0-9]+:([a-z0-9]+):(.*)$|[a-zA-Z0-9]{21,}").unwrap(); + let verkey_regex = Regex::new("[a-zA-Z0-9]{42,46}").unwrap(); + + run_admin_test(|(e_wallet_handle, _, _, _, _, _, admin)| { + admin.clone() + .send(HandleAdminMessage(AdminQuery::GetActorOverview)) + .from_err() + .map(move |res| { + if let Ok(ResAdminQuery::Admin(details)) = res { + details.agent_connections[0].to_owned() + } else { + panic!("Response was expected to be ResAdminQuery::Admin variant."); + } + }) + .and_then(move |agent_did| { + admin + .send(HandleAdminMessage(AdminQuery::GetDetailAgentConnection(GetDetailAgentConnParams { agent_pairwise_did: agent_did.clone() }))) + .from_err() + .map(move |res| { + if let Ok(ResAdminQuery::AgentConn(res_query_agent_conn)) = res { + assert!(legacy_or_qualified_did_regex.is_match(&res_query_agent_conn.owner_did)); + assert!(legacy_or_qualified_did_regex.is_match(&res_query_agent_conn.user_pairwise_did)); + assert!(legacy_or_qualified_did_regex.is_match(&res_query_agent_conn.agent_pairwise_did)); + assert!(verkey_regex.is_match(&res_query_agent_conn.owner_verkey)); + assert!(verkey_regex.is_match(&res_query_agent_conn.user_pairwise_verkey)); + assert!(verkey_regex.is_match(&res_query_agent_conn.agent_pairwise_verkey)); + assert_eq!(res_query_agent_conn.name, "unknown"); + assert_eq!(res_query_agent_conn.logo, "unknown"); + assert_eq!(res_query_agent_conn.agent_configs.len(), 0); + assert_eq!(res_query_agent_conn.remote_agent_detail_verkey, "unknown"); + assert_eq!(res_query_agent_conn.remote_agent_detail_did, "unknown"); + assert_eq!(res_query_agent_conn.remote_forward_agent_detail_verkey, "unknown"); + assert_eq!(res_query_agent_conn.remote_forward_agent_detail_did, "unknown"); + assert_eq!(res_query_agent_conn.remote_forward_agent_detail_endpoint, "unknown"); + } else { + panic!("Response was expected to be AdminQuery::GetDetailAgentConnection variant, but got {:?}", res); + } + }) + }) + .map(move |_| { + e_wallet_handle + }) + }) + } +} \ No newline at end of file diff --git a/vcx/dummy-cloud-agent/src/actors/agent.rs b/vcx/dummy-cloud-agent/src/actors/agent.rs index 7fe6c0f747..ecc6f51cdc 100644 --- a/vcx/dummy-cloud-agent/src/actors/agent.rs +++ b/vcx/dummy-cloud-agent/src/actors/agent.rs @@ -1,32 +1,35 @@ +use std::collections::HashMap; +use std::convert::Into; + use actix::prelude::*; -use actors::{AddA2ARoute, HandleA2AMsg, RouteA2AMsg, RouteA2ConnMsg, AdminRegisterAgent, HandleAdminMessage}; -use actors::agent_connection::{AgentConnection, AgentConnectionConfig}; -use actors::router::Router; -use domain::a2a::*; -use domain::a2connection::*; -use domain::config::WalletStorageConfig; -use domain::invite::ForwardAgentDetail; use failure::{err_msg, Error, Fail}; use futures::*; -use indy::{did, pairwise, wallet, pairwise::Pairwise, ErrorCode, IndyError}; -use std::convert::Into; -use std::collections::HashMap; -use utils::futures::*; -use utils::rand; +use futures::future::Either; use serde_json; -use actors::admin::Admin; -use domain::admin_message::{ResAdminQuery, ResQueryAgent}; + +use crate::actors::{AddA2ARoute, AdminRegisterAgent, HandleA2AMsg, HandleAdminMessage, RouteA2AMsg, RouteA2ConnMsg}; +use crate::actors::admin::Admin; +use crate::actors::agent_connection::{AgentConnection, AgentConnectionConfig}; +use crate::actors::router::Router; +use crate::domain::a2a::*; +use crate::domain::a2connection::*; +use crate::domain::admin_message::{ResAdminQuery, ResQueryAgent}; +use crate::domain::config::WalletStorageConfig; +use crate::domain::invite::ForwardAgentDetail; +use crate::indy::{did, ErrorCode, IndyError, pairwise, pairwise::Pairwise, wallet, WalletHandle}; +use crate::utils::futures::*; +use crate::utils::rand; #[allow(unused)] //FIXME: pub struct Agent { - wallet_handle: i32, + wallet_handle: WalletHandle, owner_did: String, owner_verkey: String, did: String, verkey: String, forward_agent_detail: ForwardAgentDetail, router: Addr, - admin: Addr, + admin: Option>, configs: HashMap, } @@ -36,7 +39,7 @@ impl Agent { router: Addr, forward_agent_detail: ForwardAgentDetail, wallet_storage_config: WalletStorageConfig, - admin: Addr) -> BoxedFuture<(String, String, String, String), Error> { + admin: Option>) -> BoxedFuture<(String, String, String, String), Error> { debug!("Agent::create >> {:?}, {:?}, {:?}, {:?}", owner_did, owner_verkey, forward_agent_detail, wallet_storage_config); @@ -94,10 +97,14 @@ impl Agent { .map_err(|err: Error| err.context("Can't add route for Agent").into()) }) .and_then(move |(wallet_id, wallet_key, did, verkey, admin, agent)| { - admin.send(AdminRegisterAgent(did.clone(), agent.clone().recipient())) - .from_err() - .map(move |_| (wallet_id, wallet_key, did, verkey)) - .map_err(|err: Error| err.context("Can't register Forward Agent Connection in Admin").into()) + match admin { + Some(admin) => + Either::A(admin.send(AdminRegisterAgent(did.clone(), agent.clone().recipient())) + .from_err() + .map(move |_| (wallet_id, wallet_key, did, verkey)) + .map_err(|err: Error| err.context("Can't register Forward Agent Connection in Admin").into())), + None => Either::B(future::ok((wallet_id, wallet_key, did, verkey))) + } }) .into_box() } @@ -110,7 +117,7 @@ impl Agent { router: Addr, forward_agent_detail: ForwardAgentDetail, wallet_storage_config: WalletStorageConfig, - admin: Addr) -> BoxedFuture<(), Error> { + admin: Option>) -> BoxedFuture<(), Error> { debug!("Agent::restore >> {:?}, {:?}, {:?}, {:?}, {:?}, {:?}", wallet_id, did, owner_did, owner_verkey, forward_agent_detail, wallet_storage_config); @@ -187,20 +194,24 @@ impl Agent { .map_err(|err: Error| err.context("Can't add route for Agent.").into()) }) .and_then(move |(admin, agent, agent_did)| { - admin.send(AdminRegisterAgent(agent_did.clone(), agent.clone().recipient())) - .from_err() - .map(|_| ()) - .map_err(|err: Error| err.context("Can't register Agent in Admin").into()) + match admin { + Some(admin) => Either::A( + admin.send(AdminRegisterAgent(agent_did.clone(), agent.clone().recipient())) + .from_err() + .map(|_| ()) + .map_err(|err: Error| err.context("Can't register Agent in Admin").into())), + None => Either::B(future::ok(())) + } }) .into_box() } - fn _restore_connections(wallet_handle: i32, + fn _restore_connections(wallet_handle: WalletHandle, owner_did: &str, owner_verkey: &str, forward_agent_detail: &ForwardAgentDetail, router: Addr, - admin: Addr, + admin: Option>, agent_configs: HashMap) -> ResponseFuture<(), Error> { trace!("Agent::_restore_connections >> {:?}, {:?}, {:?}, {:?}", wallet_handle, owner_did, owner_verkey, forward_agent_detail); @@ -479,7 +490,7 @@ impl Agent { .into_box() } - fn get_pairwise_list(wallet_handle: i32) -> ResponseFuture, Error> { + fn get_pairwise_list(wallet_handle: WalletHandle) -> ResponseFuture, Error> { future::ok(()) .and_then(move |_| { pairwise::list_pairwise(wallet_handle) @@ -731,15 +742,16 @@ impl Handler for Agent { #[cfg(test)] mod tests { - use actors::ForwardA2AMsg; + use crate::actors::ForwardA2AMsg; + use crate::domain::status::MessageStatusCode; + use crate::utils::tests::*; + use crate::utils::to_i8; + use super::*; - use utils::to_i8; - use utils::tests::*; - use domain::status::MessageStatusCode; #[test] fn agent_create_key_works() { - run_test(|forward_agent| { + run_test(|forward_agent, _| { future::ok(()) .and_then(|()| { setup_agent(forward_agent) @@ -813,7 +825,7 @@ mod tests { type_: RemoteMessageType::CredOffer, payload: Some(MessageDetailPayload::V1(to_i8(&PAYLOAD.to_vec()))), ref_msg_id: None, - }] + }], }; assert_eq!(expected_message, messages[0]); e_wallet_handle @@ -823,7 +835,7 @@ mod tests { #[test] fn agent_configs_happy_path() { - run_test(|forward_agent| { + run_test(|forward_agent, _| { future::ok(()) .and_then(|()| { setup_agent(forward_agent) @@ -885,4 +897,4 @@ mod tests { }) }); } -} \ No newline at end of file +} diff --git a/vcx/dummy-cloud-agent/src/actors/agent_connection.rs b/vcx/dummy-cloud-agent/src/actors/agent_connection.rs index ac892e9f19..3fb5c299a5 100644 --- a/vcx/dummy-cloud-agent/src/actors/agent_connection.rs +++ b/vcx/dummy-cloud-agent/src/actors/agent_connection.rs @@ -1,28 +1,30 @@ -use actix::prelude::*; -use actors::{AddA2ARoute, AddA2ConnRoute, HandleA2AMsg, HandleA2ConnMsg, RemoteMsg, HandleAdminMessage, AdminRegisterAgentConnection, requester}; -use actors::router::Router; -use domain::a2a::*; -use domain::a2connection::*; -use domain::status::{ConnectionStatus, MessageStatusCode}; -use domain::invite::{ForwardAgentDetail, InviteDetail, SenderDetail, AgentDetail}; -use domain::internal_message::InternalMessage; -use domain::key_deligation_proof::KeyDlgProof; -use domain::payload::{PayloadV1, PayloadV2, PayloadTypes, PayloadKinds, Thread}; -use domain::protocol_type::{ProtocolType, ProtocolTypes}; -use failure::{err_msg, Error, Fail}; -use futures::*; -use indy::{did, crypto, pairwise, ErrorCode, IndyError}; -use std::convert::Into; use std::collections::HashMap; -use utils::futures::*; -use utils::to_i8; +use actix::prelude::*; use base64; +use failure::{err_msg, Error, Fail}; +use futures::*; +use futures::future::Either; +use futures::future::ok; use rmp_serde; use serde_json; -use actors::admin::Admin; -use domain::admin_message::{ResAdminQuery, ResQueryAgentConn}; -use futures::future::ok; +use uuid::Uuid; + +use crate::actors::{AddA2ARoute, AddA2ConnRoute, AdminRegisterAgentConnection, HandleA2AMsg, HandleA2ConnMsg, HandleAdminMessage, RemoteMsg, requester}; +use crate::actors::admin::Admin; +use crate::actors::router::Router; +use crate::domain::a2a::*; +use crate::domain::a2connection::*; +use crate::domain::admin_message::{ResAdminQuery, ResQueryAgentConn}; +use crate::domain::internal_message::InternalMessage; +use crate::domain::invite::{AgentDetail, ForwardAgentDetail, InviteDetail, SenderDetail}; +use crate::domain::key_deligation_proof::KeyDlgProof; +use crate::domain::payload::{PayloadKinds, PayloadTypes, PayloadV1, PayloadV2, Thread}; +use crate::domain::protocol_type::{ProtocolType, ProtocolTypes}; +use crate::domain::status::{ConnectionStatus, MessageStatusCode}; +use crate::indy::{crypto, did, ErrorCode, IndyError, pairwise, WalletHandle}; +use crate::utils::futures::*; +use crate::utils::to_i8; #[derive(Clone, Debug, Serialize, Deserialize)] struct RemoteConnectionDetail { @@ -34,10 +36,10 @@ struct RemoteConnectionDetail { agent_key_dlg_proof: KeyDlgProof, } -#[derive(Clone, Debug, Deserialize)] +#[derive(Clone, Debug)] pub struct AgentConnectionConfig { // Agent wallet handle - pub wallet_handle: i32, + pub wallet_handle: WalletHandle, // Agent Owner DID pub owner_did: String, // Agent Owner Verkey @@ -59,7 +61,7 @@ pub struct AgentConnectionConfig { #[allow(unused)] //FIXME: pub struct AgentConnection { // Agent wallet handle - wallet_handle: i32, + wallet_handle: WalletHandle, // Agent Owner DID owner_did: String, // Agent Owner Verkey @@ -81,7 +83,7 @@ pub struct AgentConnection { // Address of router agent router: Addr, // Address of admin agent - admin: Addr + admin: Option> } #[derive(Clone, Debug, Serialize)] @@ -112,7 +114,7 @@ struct AgentConnectionState { impl AgentConnection { pub fn create(config: AgentConnectionConfig, router: Addr, - admin: Addr) -> ResponseFuture<(), Error> { + admin: Option>) -> ResponseFuture<(), Error> { trace!("AgentConnection::create >> {:?}", config); future::ok(()) .and_then(move |_| { @@ -153,15 +155,18 @@ impl AgentConnection { .map_err(|err: Error| err.context("Can't add route for Agent Connection.").into()) }) .and_then(move |(admin, agent_pairwise_did, agent_connection)| { - admin.send(AdminRegisterAgentConnection(agent_pairwise_did, agent_connection.clone().recipient())) - .from_err() - .map(|_| ()) - .map_err(|err: Error| err.context("Can't register Agent Connection in Admin").into()) + match admin { + Some(admin) => Either::A(admin.send(AdminRegisterAgentConnection(agent_pairwise_did, agent_connection.clone().recipient())) + .from_err() + .map(|_| ()) + .map_err(|err: Error| err.context("Can't register Agent Connection in Admin").into())), + None => Either::B(future::ok(())) + } }) .into_box() } - pub fn restore(wallet_handle: i32, + pub fn restore(wallet_handle: WalletHandle, owner_did: &str, owner_verkey: &str, agent_pairwise_did: &str, @@ -169,7 +174,7 @@ impl AgentConnection { state: &str, forward_agent_detail: &ForwardAgentDetail, router: Addr, - admin: Addr, + admin: Option>, agent_configs: HashMap) -> BoxedFuture<(), Error> { trace!("AgentConnection::restore >> {:?}", wallet_handle); @@ -233,10 +238,13 @@ impl AgentConnection { .map_err(|err: Error| err.context("Can't add route for Agent Connection.").into()) }) .and_then(move |(admin, agent_pairwise_did, agent_connection)| { - admin.send(AdminRegisterAgentConnection(agent_pairwise_did.clone(), agent_connection.clone().recipient())) - .from_err() - .map(|_| ()) - .map_err(|err: Error| err.context("Can't register Agent Connection in Admin").into()) + match admin { + Some(admin) => Either::A(admin.send(AdminRegisterAgentConnection(agent_pairwise_did.clone(), agent_connection.clone().recipient())) + .from_err() + .map(|_| ()) + .map_err(|err: Error| err.context("Can't register Agent Connection in Admin").into())), + None => Either::B(future::ok(())) + } }) .into_box() } @@ -890,7 +898,7 @@ impl AgentConnection { their_pw_did: msg.sender_did.clone(), msg_status_code: msg.status_code.clone(), pw_did: self.user_pairwise_did.clone(), - notification_id: uuid::Uuid::new_v4().to_string(), + notification_id: Uuid::new_v4().to_string(), }; self.send_webhook_notification(webhook_url, msg_notification) } @@ -1240,7 +1248,6 @@ impl AgentConnection { let remote_connection_detail = self.state.remote_connection_detail.as_ref() .ok_or(err_msg("Missed Remote Connection Details."))?; - let remote_forward_agent_detail = &remote_connection_detail.forward_agent_detail; let remote_agent_pairwise_detail = &remote_connection_detail.agent_key_dlg_proof; @@ -1263,7 +1270,6 @@ impl AgentConnection { match ProtocolType::get() { ProtocolTypes::V1 => { let msg = ftry!(rmp_serde::to_vec_named(&msg)); - ; let payload_msg = PayloadV1 { type_: PayloadTypes::build_v1(PayloadKinds::from(type_), "json"), @@ -1278,7 +1284,6 @@ impl AgentConnection { } ProtocolTypes::V2 => { let msg = ftry!(serde_json::to_string(&msg)); - ; let payload_msg = PayloadV2 { type_: PayloadTypes::build_v2(PayloadKinds::from(type_)), @@ -1508,29 +1513,28 @@ impl Handler for AgentConnection { fn handle(&mut self, _msg: HandleAdminMessage, _cnxt: &mut Self::Context) -> Self::Result { trace!("Agent Connection Handler::handle >>"); - let res = match &self.state.remote_connection_detail { - Some(m) => { - ResQueryAgentConn { - agent_detail_verkey: m.agent_detail.verkey.clone(), - agent_detail_did: m.agent_detail.did.clone(), - forward_agent_detail_verkey: m.forward_agent_detail.verkey.clone(), - forward_agent_detail_did: m.forward_agent_detail.did.clone(), - forward_agent_detail_endpoint: m.forward_agent_detail.endpoint.clone(), - agent_configs: self.agent_configs.iter().map(|(key, value)| (key.clone(), value.clone())).collect(), - logo: self.agent_configs.get("logoUrl").map_or_else(|| String::from("unknown"), |v| v.clone()), - name: self.agent_configs.get("name").map_or_else(|| String::from("unknown"), |v| v.clone()), - } - } - None => ResQueryAgentConn { - agent_detail_verkey: "unknown".into(), - agent_detail_did: "unknown".into(), - forward_agent_detail_verkey: "unknown".into(), - forward_agent_detail_did: "unknown".into(), - forward_agent_detail_endpoint: "unknown".into(), - agent_configs: self.agent_configs.iter().map(|(key, value)| (key.clone(), value.clone())).collect(), - logo: self.agent_configs.get("logoUrl").map_or_else(|| String::from("unknown"), |v| v.clone()), - name: self.agent_configs.get("name").map_or_else(|| String::from("unknown"), |v| v.clone()), - } + let res = ResQueryAgentConn { + owner_did: self.owner_did.clone(), + owner_verkey: self.owner_verkey.clone(), + user_pairwise_did: self.user_pairwise_did.clone(), + user_pairwise_verkey: self.user_pairwise_verkey.clone(), + agent_pairwise_did: self.agent_pairwise_did.clone(), + agent_pairwise_verkey: self.agent_pairwise_verkey.clone(), + + logo: self.agent_configs.get("logoUrl").map_or_else(|| String::from("unknown"), |v| v.clone()), + name: self.agent_configs.get("name").map_or_else(|| String::from("unknown"), |v| v.clone()), + agent_configs: self.agent_configs.iter().map(|(key, value)| (key.clone(), value.clone())).collect(), + + remote_agent_detail_did: self.state.remote_connection_detail + .as_ref().map_or_else(|| "unknown".into(), |r| r.agent_detail.did.clone()), + remote_agent_detail_verkey: self.state.remote_connection_detail + .as_ref().map_or_else(|| "unknown".into(), |r| r.agent_detail.verkey.clone()), + remote_forward_agent_detail_did: self.state.remote_connection_detail + .as_ref().map_or_else(|| "unknown".into(), |r| r.forward_agent_detail.did.clone()), + remote_forward_agent_detail_verkey: self.state.remote_connection_detail + .as_ref().map_or_else(|| "unknown".into(), |r| r.forward_agent_detail.verkey.clone()), + remote_forward_agent_detail_endpoint: self.state.remote_connection_detail + .as_ref().map_or_else(|| "unknown".into(), |r| r.forward_agent_detail.endpoint.clone()), }; Ok(ResAdminQuery::AgentConn(res)) } @@ -1543,9 +1547,12 @@ enum MessageHandlerRole { #[cfg(test)] mod tests { - use actors::ForwardA2AMsg; + use crate::actors::ForwardA2AMsg; + use crate::utils::tests::*; + use crate::utils::tests::*; + use crate::utils::tests::compose_create_general_message; + use super::*; - use utils::tests::*; #[test] fn agent_create_connection_request_works() { @@ -1776,4 +1783,4 @@ mod tests { }) }); } -} \ No newline at end of file +} diff --git a/vcx/dummy-cloud-agent/src/actors/forward_agent.rs b/vcx/dummy-cloud-agent/src/actors/forward_agent.rs index 4bd164b2ae..7647be1a37 100644 --- a/vcx/dummy-cloud-agent/src/actors/forward_agent.rs +++ b/vcx/dummy-cloud-agent/src/actors/forward_agent.rs @@ -1,36 +1,38 @@ +use std::convert::Into; + use actix::prelude::*; -use actors::{AddA2ARoute, Endpoint, ForwardA2AMsg, GetEndpoint, HandleA2AMsg, RouteA2AMsg, AdminRegisterForwardAgent, HandleAdminMessage}; -use actors::forward_agent_connection::ForwardAgentConnection; -use actors::router::Router; -use domain::a2a::*; -use domain::config::{ForwardAgentConfig, WalletStorageConfig}; -use domain::invite::ForwardAgentDetail; use failure::{err_msg, Error, Fail}; use futures::*; -use indy::{did, ErrorCode, IndyError, pairwise, pairwise::Pairwise, wallet}; +use futures::future::{Either, ok}; use serde_json; -use std::convert::Into; -use utils::futures::*; -use actors::admin::Admin; -use domain::admin_message::{ResAdminQuery, ResQueryForwardAgent}; + +use crate::actors::{AddA2ARoute, AdminRegisterForwardAgent, Endpoint, ForwardA2AMsg, GetEndpoint, HandleA2AMsg, HandleAdminMessage, RouteA2AMsg}; +use crate::actors::admin::Admin; +use crate::actors::forward_agent_connection::ForwardAgentConnection; +use crate::actors::router::Router; +use crate::domain::a2a::*; +use crate::domain::admin_message::{ResAdminQuery, ResQueryForwardAgent}; +use crate::domain::config::{ForwardAgentConfig, WalletStorageConfig}; +use crate::domain::invite::ForwardAgentDetail; +use crate::indy::{did, ErrorCode, IndyError, pairwise, pairwise::Pairwise, wallet, WalletHandle}; +use crate::utils::futures::*; pub struct ForwardAgent { - wallet_handle: i32, + wallet_handle: WalletHandle, did: String, verkey: String, router: Addr, forward_agent_detail: ForwardAgentDetail, wallet_storage_config: WalletStorageConfig, - admin: Addr, + admin: Option>, } impl ForwardAgent { pub fn create_or_restore(config: ForwardAgentConfig, wallet_storage_config: WalletStorageConfig, - admin: Addr) -> ResponseFuture, Error> { + admin: Option>) -> ResponseFuture, Error> { debug!("ForwardAgent::create_or_restore >> {:?} {:?}", config, wallet_storage_config); let admin1 = admin.clone(); - let admin2 = admin.clone(); future::ok(()) .and_then(move |_| { // Ensure Forward Agent wallet created @@ -64,7 +66,7 @@ impl ForwardAgent { .and_then(move |(wallet_handle, config, wallet_storage_config)| { #[cfg(test)] unsafe { - ::utils::tests::FORWARD_AGENT_WALLET_HANDLE = wallet_handle; + crate::utils::tests::FORWARD_AGENT_WALLET_HANDLE = wallet_handle; } // Ensure Forward Agent DID created @@ -90,12 +92,12 @@ impl ForwardAgent { .map(move |verkey| (wallet_handle, config.did, verkey, config.endpoint, wallet_storage_config)) .map_err(|err| err.context("Can't get Forward Agent did key").into()) }) - .and_then(|(wallet_handle, did, verkey, endpoint, wallet_storage_config)| { + .and_then(move |(wallet_handle, did, verkey, endpoint, wallet_storage_config)| { Router::new(admin1) - .map(move |router| (wallet_handle, did, verkey, endpoint, wallet_storage_config, router)) + .map(move |router| (wallet_handle, did, verkey, endpoint, wallet_storage_config, router, admin)) .map_err(|err| err.context("Can't create Router.").into()) }) - .and_then(move |(wallet_handle, did, verkey, endpoint, wallet_storage_config, router)| { + .and_then(move |(wallet_handle, did, verkey, endpoint, wallet_storage_config, router, admin)| { // Resolve information about existing connections from the wallet // and start Forward Agent Connection actor for each exists connection @@ -131,23 +133,27 @@ impl ForwardAgent { router .send(AddA2ARoute(did, verkey, forward_agent.clone().recipient())) .from_err() - .map(move |_| forward_agent) + .map(move |_| (forward_agent, admin)) .map_err(|err: Error| err.context("Can't add route for Forward Agent").into()) }) - .and_then(move |forward_agent| { - admin2.send(AdminRegisterForwardAgent(forward_agent.clone().recipient())) - .from_err() - .map(move |_| forward_agent) - .map_err(|err: Error| err.context("Can't register Forward Agent in Admin").into()) + .and_then(move |(forward_agent, admin)| { + if let Some(admin) = admin { + Either::A(admin.send(AdminRegisterForwardAgent(forward_agent.clone().recipient())) + .from_err() + .map(move |_| forward_agent) + .map_err(|err: Error| err.context("Can't register Forward Agent in Admin").into())) + } else { + Either::B(ok(forward_agent)) + } }) .into_box() } - fn _restore_connections(wallet_handle: i32, + fn _restore_connections(wallet_handle: WalletHandle, forward_agent_detail: ForwardAgentDetail, wallet_storage_config: WalletStorageConfig, router: Addr, - admin: Addr) -> ResponseFuture<(), Error> { + admin: Option>) -> ResponseFuture<(), Error> { debug!("ForwardAgent::_restore_connections >> {:?}", wallet_handle); future::ok(()) @@ -185,7 +191,7 @@ impl ForwardAgent { future::join_all(futures) .map(|_| ()) -// .map_err(|err| err.context("Can't restore Forward Agent connections").into()) + .map_err(|err| err.context("Can't restore Forward Agent connections").into()) }) .into_box() } @@ -195,7 +201,7 @@ impl ForwardAgent { (self.did.clone(), self.verkey.clone()) } - fn _get_forward_agent_details(&self) -> (String, Vec, i32) { + fn _get_forward_agent_details(&self) -> (String, Vec, WalletHandle) { trace!("ForwardAgent::_get_forward_agent_details >>"); let endpoint = self.forward_agent_detail.endpoint.clone(); let wallet_handle = self.wallet_handle.clone(); @@ -383,19 +389,20 @@ impl Handler for ForwardAgent { #[cfg(test)] mod tests { + use crate::utils::tests::*; + use super::*; - use utils::tests::*; #[test] fn forward_agent_create_or_restore_works() { - run_test(|_| { + run_test(|_, _| { Ok(()) }); } #[test] fn forward_agent_get_endpoint_works() { - run_test(|forward_agent| { + run_test(|forward_agent, _| { forward_agent .send(GetEndpoint {}) .from_err() @@ -411,7 +418,7 @@ mod tests { #[test] fn forward_agent_connect_works() { - run_test(|forward_agent| { + run_test(|forward_agent, _| { future::ok(()) .map(|_| { let e_wallet_handle = edge_wallet_setup().wait().unwrap(); @@ -432,7 +439,7 @@ mod tests { assert!(!pairwise_verkey.is_empty()); e_wallet_handle }) - .map(|e_wallet_handle| ::indy::wallet::close_wallet(e_wallet_handle).wait().unwrap()) + .map(|e_wallet_handle| crate::indy::wallet::close_wallet(e_wallet_handle).wait().unwrap()) }); } } diff --git a/vcx/dummy-cloud-agent/src/actors/forward_agent_connection.rs b/vcx/dummy-cloud-agent/src/actors/forward_agent_connection.rs index 2cca59c087..ede8e60fa9 100644 --- a/vcx/dummy-cloud-agent/src/actors/forward_agent_connection.rs +++ b/vcx/dummy-cloud-agent/src/actors/forward_agent_connection.rs @@ -1,18 +1,21 @@ +use std::convert::Into; + use actix::prelude::*; -use actors::{AddA2ARoute, HandleA2AMsg, AdminRegisterForwardAgentConnection, HandleAdminMessage}; -use actors::agent::Agent; -use actors::router::Router; -use domain::a2a::*; -use domain::config::WalletStorageConfig; -use domain::invite::ForwardAgentDetail; use failure::{err_msg, Error, Fail}; use futures::*; -use indy::{did, pairwise, pairwise::PairwiseInfo}; +use futures::future::Either; use serde_json; -use std::convert::Into; -use utils::futures::*; -use actors::admin::Admin; -use domain::admin_message::{ResAdminQuery}; + +use crate::actors::{AddA2ARoute, AdminRegisterForwardAgentConnection, HandleA2AMsg, HandleAdminMessage}; +use crate::actors::admin::Admin; +use crate::actors::agent::Agent; +use crate::actors::router::Router; +use crate::domain::a2a::*; +use crate::domain::admin_message::ResAdminQuery; +use crate::domain::config::WalletStorageConfig; +use crate::domain::invite::ForwardAgentDetail; +use crate::indy::{did, pairwise, pairwise::PairwiseInfo, WalletHandle}; +use crate::utils::futures::*; #[derive(Deserialize, Serialize, Debug)] pub struct ForwardAgentConnectionState { @@ -22,25 +25,25 @@ pub struct ForwardAgentConnectionState { } pub struct ForwardAgentConnection { - wallet_handle: i32, + wallet_handle: WalletHandle, their_did: String, their_verkey: String, my_verkey: String, state: ForwardAgentConnectionState, router: Addr, - admin: Addr, + admin: Option>, forward_agent_detail: ForwardAgentDetail, wallet_storage_config: WalletStorageConfig, } impl ForwardAgentConnection { - pub fn create(wallet_handle: i32, + pub fn create(wallet_handle: WalletHandle, their_did: String, their_verkey: String, router: Addr, forward_agent_detail: ForwardAgentDetail, wallet_storage_config: WalletStorageConfig, - admin: Addr) -> BoxedFuture<(String, String), Error> { + admin: Option>) -> BoxedFuture<(String, String), Error> { debug!("ForwardAgentConnection::create >> {:?}, {:?}, {:?}, {:?}, {:?}", wallet_handle, their_did, their_verkey, forward_agent_detail, wallet_storage_config); @@ -99,20 +102,24 @@ impl ForwardAgentConnection { .map_err(|err: Error| err.context("Can't add route for Forward Agent Connection").into()) }) .and_then(move |(my_did, my_verkey, forward_agent_connection, admin)| { - admin.send(AdminRegisterForwardAgentConnection(my_did.clone(), forward_agent_connection.clone().recipient())) - .from_err() - .map(move |_| (my_did, my_verkey)) - .map_err(|err: Error| err.context("Can't register Forward Agent in Admin").into()) + if let Some(admin) = admin { + Either::A(admin.send(AdminRegisterForwardAgentConnection(my_did.clone(), forward_agent_connection.clone().recipient())) + .from_err() + .map(move |_| (my_did, my_verkey)) + .map_err(|err: Error| err.context("Can't register Forward Agent in Admin").into())) + } else { + Either::B(future::ok( (my_did, my_verkey))) + } }) .into_box() } - pub fn restore(wallet_handle: i32, + pub fn restore(wallet_handle: WalletHandle, their_did: String, forward_agent_detail: ForwardAgentDetail, wallet_storage_config: WalletStorageConfig, router: Addr, - admin: Addr) -> BoxedFuture<(), Error> { + admin: Option>) -> BoxedFuture<(), Error> { debug!("ForwardAgentConnection::restore >> {:?}, {:?}, {:?}, {:?}", wallet_handle, their_did, forward_agent_detail, wallet_storage_config); @@ -155,7 +162,7 @@ impl ForwardAgentConnection { router.clone(), forward_agent_detail.clone(), wallet_storage_config.clone(), - admin.clone()) + admin.clone()) .into_box() } else { ok!(()) @@ -187,10 +194,15 @@ impl ForwardAgentConnection { .map_err(|err: Error| err.context("Can't add route for Forward Agent Connection").into()) }) .and_then(move |(forward_agent_connection, my_did, admin )| { - admin.send(AdminRegisterForwardAgentConnection(my_did.clone(), forward_agent_connection.clone().recipient())) - .from_err() - .map(|_| ()) - .map_err(|err: Error| err.context("Can't register Forward Agent Connection in Admin").into()) + match admin { + Some(admin) => { + Either::A(admin.send(AdminRegisterForwardAgentConnection(my_did.clone(), forward_agent_connection.clone().recipient())) + .from_err() + .map(|_| ()) + .map_err(|err: Error| err.context("Can't register Forward Agent Connection in Admin").into())) + }, + None => Either::B(future::ok(())) + } }) .into_box() } @@ -403,13 +415,14 @@ impl Handler for ForwardAgentConnection { #[cfg(test)] mod tests { - use actors::ForwardA2AMsg; + use crate::actors::ForwardA2AMsg; + use crate::utils::tests::*; + use super::*; - use utils::tests::*; #[test] fn forward_agent_connection_signup_works() { - run_test(|forward_agent| { + run_test(|forward_agent, _| { future::ok(()) .and_then(|()| { let e_wallet_handle = edge_wallet_setup().wait().unwrap(); @@ -437,13 +450,14 @@ mod tests { assert_eq!(sender_verkey, pairwise_verkey); e_wallet_handle }) - .map(|e_wallet_handle| ::indy::wallet::close_wallet(e_wallet_handle).wait().unwrap()) + .map(|e_wallet_handle| + crate::indy::wallet::close_wallet(e_wallet_handle).wait().unwrap()) }); } #[test] fn forward_agent_connection_create_agent_works() { - run_test(|forward_agent| { + run_test(|forward_agent, _| { future::ok(()) .and_then(|()| { let e_wallet_handle = edge_wallet_setup().wait().unwrap(); @@ -485,7 +499,7 @@ mod tests { e_wallet_handle }) }) - .map(|e_wallet_handle| ::indy::wallet::close_wallet(e_wallet_handle).wait().unwrap()) + .map(|e_wallet_handle| crate::indy::wallet::close_wallet(e_wallet_handle).wait().unwrap()) }); } -} \ No newline at end of file +} diff --git a/vcx/dummy-cloud-agent/src/actors/mod.rs b/vcx/dummy-cloud-agent/src/actors/mod.rs index d75923a625..bd457edae2 100644 --- a/vcx/dummy-cloud-agent/src/actors/mod.rs +++ b/vcx/dummy-cloud-agent/src/actors/mod.rs @@ -1,6 +1,9 @@ use actix::prelude::*; use failure::*; +use crate::domain::a2connection::A2ConnMessage; +use crate::domain::admin_message::{AdminQuery, ResAdminQuery}; + pub mod router; pub mod forward_agent; pub mod admin; @@ -9,9 +12,6 @@ pub mod agent; pub mod agent_connection; pub mod requester; -use domain::a2connection::A2ConnMessage; -use domain::admin_message::{AdminQuery, ResAdminQuery}; - pub struct AdminRegisterRouter(pub Recipient); impl Message for AdminRegisterRouter { diff --git a/vcx/dummy-cloud-agent/src/actors/requester.rs b/vcx/dummy-cloud-agent/src/actors/requester.rs index d96e2e8125..cffe20e5ef 100644 --- a/vcx/dummy-cloud-agent/src/actors/requester.rs +++ b/vcx/dummy-cloud-agent/src/actors/requester.rs @@ -1,14 +1,13 @@ +use actix::prelude::*; use failure::{err_msg, Error}; +use futures::*; +use hyper::{Body, header, Method, Request}; use hyper::Client; use hyper::client::connect::HttpConnector; use hyper::rt::Future; -use hyper::{Body, Method, Request, header}; -use actix::prelude::*; -use actors::RemoteMsg; - -use futures::*; -use utils::futures::*; +use crate::actors::RemoteMsg; +use crate::utils::futures::*; lazy_static! { pub static ref REQWEST_CLIENT : reqwest::r#async::Client = reqwest::r#async::Client::new(); diff --git a/vcx/dummy-cloud-agent/src/actors/router.rs b/vcx/dummy-cloud-agent/src/actors/router.rs index 9ba68b7ab2..32c91ff249 100644 --- a/vcx/dummy-cloud-agent/src/actors/router.rs +++ b/vcx/dummy-cloud-agent/src/actors/router.rs @@ -1,13 +1,16 @@ +use std::collections::HashMap; + use actix::prelude::*; -use actors::{AddA2ARoute, AddA2ConnRoute, HandleA2AMsg, HandleA2ConnMsg, RouteA2AMsg, RouteA2ConnMsg, RemoteMsg, AdminRegisterRouter, HandleAdminMessage}; -use actors::requester::Requester; -use domain::a2connection::A2ConnMessage; +use failure::{err_msg, Error}; use futures::*; -use failure::{Error, err_msg}; -use std::collections::HashMap; -use utils::futures::*; -use actors::admin::Admin; -use domain::admin_message::{ResAdminQuery}; +use futures::future::Either; + +use crate::actors::{AddA2ARoute, AddA2ConnRoute, AdminRegisterRouter, HandleA2AMsg, HandleA2ConnMsg, HandleAdminMessage, RemoteMsg, RouteA2AMsg, RouteA2ConnMsg}; +use crate::actors::admin::Admin; +use crate::actors::requester::Requester; +use crate::domain::a2connection::A2ConnMessage; +use crate::domain::admin_message::ResAdminQuery; +use crate::utils::futures::*; pub struct Router { routes: HashMap>, @@ -16,7 +19,7 @@ pub struct Router { } impl Router { - pub fn new(admin: Addr) -> ResponseFuture, Error> { + pub fn new(admin: Option>) -> ResponseFuture, Error> { trace!("Router::new >>"); future::ok(()) .and_then(move |_| { @@ -27,10 +30,15 @@ impl Router { requester, }; let router= router.start(); - admin.send(AdminRegisterRouter(router.clone().recipient())) - .from_err() - .map(move |_| router) - .map_err(|err: Error| err.context("Can't register Router in Admin").into()) + if let Some(admin) = admin { + Either::A(admin.send(AdminRegisterRouter(router.clone().recipient())) + .from_err() + .map(move |_| router) + .map_err(|err: Error| err.context("Can't register Router in Admin").into()) + ) + } else { + Either::B(future::ok(router)) + } }) .into_box() } diff --git a/vcx/dummy-cloud-agent/src/api_agent.rs b/vcx/dummy-cloud-agent/src/api_agent.rs index 38f28883c8..c14713f4d9 100644 --- a/vcx/dummy-cloud-agent/src/api_agent.rs +++ b/vcx/dummy-cloud-agent/src/api_agent.rs @@ -1,8 +1,9 @@ use actix::prelude::*; use actix_web::*; -use actors::{ForwardA2AMsg, GetEndpoint}; use bytes::Bytes; -use app::AppData; + +use crate::actors::{ForwardA2AMsg, GetEndpoint}; +use crate::app::AppData; const MAX_PAYLOAD_SIZE: usize = 105_906_176; diff --git a/vcx/dummy-cloud-agent/src/app.rs b/vcx/dummy-cloud-agent/src/app.rs index e110204179..53de3b5309 100644 --- a/vcx/dummy-cloud-agent/src/app.rs +++ b/vcx/dummy-cloud-agent/src/app.rs @@ -1,62 +1,33 @@ use actix::prelude::*; use actix_web::*; -use actors::{ForwardA2AMsg, GetEndpoint, HandleAdminMessage}; -use actors::forward_agent::ForwardAgent; -use actors::admin::Admin; +use actix_web::web::Data; use bytes::Bytes; -use domain::config::{AppConfig, ServerConfig}; -use domain::admin_message::{AdminQuery, GetDetailAgentParams, GetDetailAgentConnParams}; -use actix_web::web::{Data}; + +use crate::actors::{ForwardA2AMsg, GetEndpoint}; +use crate::actors::admin::Admin; +use crate::actors::forward_agent::ForwardAgent; +use crate::domain::config::{AppConfig, ServerConfig}; pub struct AppData { pub forward_agent: Addr, - pub admin_agent: Addr, - pub sometext: String, -} - -#[derive(Deserialize)] -struct AgentParams { - did: String, + pub admin_agent: Option>, } -pub fn start_app_server(server_config: ServerConfig, app_config: AppConfig, forward_agent: Addr, admin_agent: Addr) { - info!("Forward Agent started"); - info!("Starting Server with config: {:?}", server_config); +pub fn start_app_server(server_config: ServerConfig, app_config: AppConfig, forward_agent: Addr, admin_agent: Option>) { + info!("Creating HttpServer with config: {:?}", server_config); let mut server = HttpServer::new(move || { info!("Starting App with config: {:?}", app_config); - let app = App::new() - .data(AppData { admin_agent: admin_agent.clone(), forward_agent: forward_agent.clone(), sometext: "Footext".to_string() }) + App::new() + .data(AppData { admin_agent: admin_agent.clone(), forward_agent: forward_agent.clone() }) .wrap(middleware::Logger::default()) .service( - web::resource("/agency") + web::resource(&app_config.prefix) .route(web::get().to(_get_endpoint_details)) ) .service( - web::resource("/agency/msg") + web::resource(&format!("{}/msg", app_config.prefix)) .route(web::post().to(_forward_message)) - ); - match app_config.enable_admin_api { - Some(enable_admin_api) if enable_admin_api => { - app - .service( - web::resource("/admin") - .route(web::get().to(_get_actor_overview)) - ) - .service( - web::resource("/admin/forward-agent") - .route(web::get().to(_get_forward_agent_details)) - ) - .service( - web::resource("/admin/agent/{did}") - .route(web::get().to(_get_agent_details)) - ) - .service( - web::resource("/admin/agent-connection/{did}") - .route(web::get().to(_get_agent_connection_details)) - ) - } - _ => app - } + ) }); if let Some(workers) = server_config.workers { server = server.workers(workers); @@ -71,7 +42,7 @@ pub fn start_app_server(server_config: ServerConfig, app_config: AppConfig, forw } -fn _get_endpoint_details(state: Data) -> Box> { +fn _get_endpoint_details(state: Data) -> Box> { let f = state.forward_agent .send(GetEndpoint {}) .from_err() @@ -82,38 +53,7 @@ fn _get_endpoint_details(state: Data) -> Box, admin_msg: HandleAdminMessage) -> Box> { - let f = state.admin_agent - .send(admin_msg) - .from_err() - .map(|res| match res { - Ok(agent_details) => HttpResponse::Ok().json(&agent_details), - Err(err) => HttpResponse::InternalServerError().body(format!("{:?}", err)).into(), // FIXME: Better error - }); - Box::new(f) -} -// -fn _get_agent_connection_details(state: Data, info: web::Path) -> Box> { - let msg = HandleAdminMessage(AdminQuery::GetDetailAgentConnection(GetDetailAgentConnParams { agent_pairwise_did: info.did.clone() })); - _send_admin_message(state, msg) -} - -fn _get_agent_details(state: Data, info: web::Path) -> Box> { - let msg = HandleAdminMessage(AdminQuery::GetDetailAgent(GetDetailAgentParams { agent_did: info.did.clone() })); - _send_admin_message(state, msg) -} - -fn _get_actor_overview(state: Data) -> Box> { - let msg = HandleAdminMessage(AdminQuery::GetActorOverview); - _send_admin_message(state, msg) -} - -fn _get_forward_agent_details(state: Data) -> Box> { - let msg = HandleAdminMessage(AdminQuery::GetDetailForwardAgents); - _send_admin_message(state, msg) -} - -fn _forward_message(state: Data, stream: web::Payload) -> Box> { +fn _forward_message(state: Data, stream: web::Payload) -> Box> { let f = stream.map_err(Error::from) .fold(web::BytesMut::new(), move |mut body, chunk| { body.extend_from_slice(&chunk); diff --git a/vcx/dummy-cloud-agent/src/app_admin.rs b/vcx/dummy-cloud-agent/src/app_admin.rs new file mode 100644 index 0000000000..34c5557cd8 --- /dev/null +++ b/vcx/dummy-cloud-agent/src/app_admin.rs @@ -0,0 +1,81 @@ +use actix::prelude::*; +use actix_web::*; +use actix_web::web::Data; + +use crate::actors::admin::Admin; +use crate::actors::HandleAdminMessage; +use crate::domain::admin_message::{AdminQuery, GetDetailAgentConnParams, GetDetailAgentParams}; +use crate::domain::config::ServerAdminConfig; + +pub struct AdminAppData { + pub admin_agent: Addr, +} + +#[derive(Deserialize)] +struct AgentParams { + did: String, +} + +pub fn start_app_admin_server(server_admin_config: &ServerAdminConfig, admin_agent: Addr) { + info!("Creating Admin HttpServer using config {:?}", server_admin_config); + let mut server = HttpServer::new(move || { + App::new() + .data(AdminAppData { admin_agent: admin_agent.clone() }) + .wrap(middleware::Logger::default()) + .service( + web::resource("/admin") + .route(web::get().to(_get_actor_overview)) + ) + .service( + web::resource("/admin/forward-agent") + .route(web::get().to(_get_forward_agent_details)) + ) + .service( + web::resource("/admin/agent/{did}") + .route(web::get().to(_get_agent_details)) + ) + .service( + web::resource("/admin/agent-connection/{did}") + .route(web::get().to(_get_agent_connection_details)) + ) + }); + for address in &server_admin_config.addresses { + server = server + .bind(address) + .expect(&format!("Can't bind to address {}.", address)); + } + server.start(); + info!("Admin Server started at addresses: {:?}.", server_admin_config.addresses); +} + +fn _send_admin_message(state: Data, admin_msg: HandleAdminMessage) -> Box> { + let f = state.admin_agent + .send(admin_msg) + .from_err() + .map(|res| match res { + Ok(agent_details) => HttpResponse::Ok().json(&agent_details), + Err(err) => HttpResponse::InternalServerError().body(format!("{:?}", err)).into(), + }); + Box::new(f) +} + +fn _get_agent_connection_details(state: Data, info: web::Path) -> Box> { + let msg = HandleAdminMessage(AdminQuery::GetDetailAgentConnection(GetDetailAgentConnParams { agent_pairwise_did: info.did.clone() })); + _send_admin_message(state, msg) +} + +fn _get_agent_details(state: Data, info: web::Path) -> Box> { + let msg = HandleAdminMessage(AdminQuery::GetDetailAgent(GetDetailAgentParams { agent_did: info.did.clone() })); + _send_admin_message(state, msg) +} + +fn _get_actor_overview(state: Data) -> Box> { + let msg = HandleAdminMessage(AdminQuery::GetActorOverview); + _send_admin_message(state, msg) +} + +fn _get_forward_agent_details(state: Data) -> Box> { + let msg = HandleAdminMessage(AdminQuery::GetDetailForwardAgents); + _send_admin_message(state, msg) +} + diff --git a/vcx/dummy-cloud-agent/src/domain/a2a.rs b/vcx/dummy-cloud-agent/src/domain/a2a.rs index ff279772d3..74c6967470 100644 --- a/vcx/dummy-cloud-agent/src/domain/a2a.rs +++ b/vcx/dummy-cloud-agent/src/domain/a2a.rs @@ -1,18 +1,18 @@ use failure::*; use futures::*; -use indy::crypto; use rmp_serde; use serde::{de, Deserialize, Deserializer, ser, Serialize, Serializer}; use serde_json::{self, Value}; -use utils::futures::*; -use domain::a2connection::*; -use domain::invite::{InviteDetail, SenderDetail, ForwardAgentDetail}; -use domain::key_deligation_proof::KeyDlgProof; -use domain::status::{MessageStatusCode, ConnectionStatus}; -use domain::message_type::*; -use domain::protocol_type::{ProtocolType, ProtocolTypes}; -use domain::payload::Thread; +use crate::domain::a2connection::*; +use crate::domain::invite::{ForwardAgentDetail, InviteDetail, SenderDetail}; +use crate::domain::key_deligation_proof::KeyDlgProof; +use crate::domain::message_type::*; +use crate::domain::payload::Thread; +use crate::domain::protocol_type::{ProtocolType, ProtocolTypes}; +use crate::domain::status::{ConnectionStatus, MessageStatusCode}; +use crate::indy::{crypto, WalletHandle}; +use crate::utils::futures::*; #[derive(Debug)] pub enum A2AMessageV1 { @@ -1228,7 +1228,7 @@ impl A2AMessage { .map_err(|err| err.context("Can't bundle messages").into()) } - pub fn prepare_authcrypted(wallet_handle: i32, + pub fn prepare_authcrypted(wallet_handle: WalletHandle, sender_vk: &str, recipient_vk: &str, msgs: &[A2AMessage]) -> BoxedFuture, Error> { @@ -1239,14 +1239,14 @@ impl A2AMessage { } - pub fn prepare_anoncrypted(wallet_handle: i32, recipient_vk: &str, message: &[A2AMessage]) -> BoxedFuture, Error> { + pub fn prepare_anoncrypted(wallet_handle: WalletHandle, recipient_vk: &str, message: &[A2AMessage]) -> BoxedFuture, Error> { match ProtocolType::get() { ProtocolTypes::V1 => A2AMessage::bundle_anoncrypted(recipient_vk, message), ProtocolTypes::V2 => A2AMessage::pack(wallet_handle, None, recipient_vk, message) } } - pub fn bundle_authcrypted(wallet_handle: i32, + pub fn bundle_authcrypted(wallet_handle: WalletHandle, sender_vk: &str, recipient_vk: &str, msgs: &[A2AMessage]) -> BoxedFuture, Error> { @@ -1266,7 +1266,7 @@ impl A2AMessage { .into_box() } - pub fn pack(wallet_handle: i32, sender_vk: Option<&str>, recipient_vk: &str, msgs: &[A2AMessage]) -> BoxedFuture, Error> { + pub fn pack(wallet_handle: WalletHandle, sender_vk: Option<&str>, recipient_vk: &str, msgs: &[A2AMessage]) -> BoxedFuture, Error> { if msgs.len() != 1 { return err!(err_msg("Invalid messages count.")); } @@ -1279,7 +1279,7 @@ impl A2AMessage { .into_box() } - pub fn pack_v2(wallet_handle: i32, sender_vk: Option<&str>, recipient_vk: &str, msg: &A2AMessageV2) -> BoxedFuture, Error> { + pub fn pack_v2(wallet_handle: WalletHandle, sender_vk: Option<&str>, recipient_vk: &str, msg: &A2AMessageV2) -> BoxedFuture, Error> { let message = ftry!(serde_json::to_string(msg)); let receiver_keys = ftry!(serde_json::to_string(&vec![&recipient_vk])); @@ -1299,7 +1299,7 @@ impl A2AMessage { .map_err(|err| err.context("Can't unbundle messages").into()) } - pub fn parse_anoncrypted(wallet_handle: i32, + pub fn parse_anoncrypted(wallet_handle: WalletHandle, recipient_vk: &str, bundle: &[u8]) -> BoxedFuture, Error> { match ProtocolType::get() { @@ -1311,7 +1311,7 @@ impl A2AMessage { } } - pub fn parse_authcrypted(wallet_handle: i32, + pub fn parse_authcrypted(wallet_handle: WalletHandle, recipient_vk: &str, message: &[u8]) -> BoxedFuture<(String, Vec), Error> { match ProtocolType::get() { @@ -1323,7 +1323,7 @@ impl A2AMessage { } } - pub fn unbundle_anoncrypted(wallet_handle: i32, + pub fn unbundle_anoncrypted(wallet_handle: WalletHandle, recipient_vk: &str, message: &[u8]) -> BoxedFuture, Error> { crypto::anon_decrypt(wallet_handle, recipient_vk, message) @@ -1334,7 +1334,7 @@ impl A2AMessage { .into_box() } - pub fn unbundle_authcrypted(wallet_handle: i32, + pub fn unbundle_authcrypted(wallet_handle: WalletHandle, recipient_vk: &str, bundle: &[u8]) -> BoxedFuture<(String, Vec), Error> { crypto::auth_decrypt(wallet_handle, recipient_vk, bundle) @@ -1345,7 +1345,7 @@ impl A2AMessage { .into_box() } - pub fn unpack(wallet_handle: i32, message: &[u8]) -> BoxedFuture<(Option, Vec), Error> { + pub fn unpack(wallet_handle: WalletHandle, message: &[u8]) -> BoxedFuture<(Option, Vec), Error> { crypto::unpack_message(wallet_handle, message) .from_err() .and_then(|message| { diff --git a/vcx/dummy-cloud-agent/src/domain/a2connection.rs b/vcx/dummy-cloud-agent/src/domain/a2connection.rs index 682a479f7d..3f7298a52a 100644 --- a/vcx/dummy-cloud-agent/src/domain/a2connection.rs +++ b/vcx/dummy-cloud-agent/src/domain/a2connection.rs @@ -1,6 +1,7 @@ -use domain::a2a::*; use std::convert::Into; +use crate::domain::a2a::*; + #[derive(Debug)] pub enum A2ConnMessage { GetMessages(GetMessages), diff --git a/vcx/dummy-cloud-agent/src/domain/admin_message.rs b/vcx/dummy-cloud-agent/src/domain/admin_message.rs index 67a142cf0a..604878a7e3 100644 --- a/vcx/dummy-cloud-agent/src/domain/admin_message.rs +++ b/vcx/dummy-cloud-agent/src/domain/admin_message.rs @@ -1,3 +1,5 @@ +use indyrs::WalletHandle; + // -------- // Requests // -------- @@ -37,30 +39,26 @@ pub enum ResAdminQuery { // -------- #[derive(Serialize, Deserialize, Debug, Clone)] +#[serde(rename_all = "camelCase")] pub struct ResQueryAdmin { - #[serde(rename = "forwardAgentConnections")] pub forward_agent_connections: Vec, - #[serde(rename = "agents")] pub agents: Vec, - #[serde(rename = "agentConnections")] pub agent_connections: Vec, } #[derive(Serialize, Deserialize, Debug, Clone)] +#[serde(rename_all = "camelCase")] pub struct ResQueryForwardAgent { - #[serde(rename = "walletHandle")] - pub wallet_handle: i32, + pub wallet_handle: WalletHandle, #[serde(rename = "forwardAgentEndpoint")] pub endpoint: String, - #[serde(rename = "pairwiseList")] pub pairwise_list:Vec } #[derive(Serialize, Deserialize, Debug, Clone)] +#[serde(rename_all = "camelCase")] pub struct ResQueryAgent { - #[serde(rename = "ownerDid")] pub owner_did: String, - #[serde(rename = "ownerVerkey")] pub owner_verkey: String, pub did: String, pub verkey: String, @@ -68,19 +66,23 @@ pub struct ResQueryAgent { } #[derive(Serialize, Deserialize, Debug, Clone)] +#[serde(rename_all = "camelCase")] pub struct ResQueryAgentConn { - #[serde(rename = "agentDetailVerkey")] - pub agent_detail_verkey: String, - #[serde(rename = "agentDetailDid")] - pub agent_detail_did: String, - #[serde(rename = "forwardAgentDetailVerkey")] - pub forward_agent_detail_verkey: String, - #[serde(rename = "forwardAgentDetailDid")] - pub forward_agent_detail_did: String, - #[serde(rename = "forwardAgentDetailEndpoint")] - pub forward_agent_detail_endpoint: String, - #[serde(rename = "agentConfigs")] - pub agent_configs: Vec<(String, String)>, + pub owner_did: String, + pub owner_verkey: String, + pub user_pairwise_did: String, + pub user_pairwise_verkey: String, + pub agent_pairwise_did: String, + pub agent_pairwise_verkey: String, + pub name: String, - pub logo: String + pub logo: String, + pub agent_configs: Vec<(String, String)>, + + pub remote_agent_detail_verkey: String, + pub remote_agent_detail_did: String, + pub remote_forward_agent_detail_verkey: String, + pub remote_forward_agent_detail_did: String, + pub remote_forward_agent_detail_endpoint: String, + } \ No newline at end of file diff --git a/vcx/dummy-cloud-agent/src/domain/config.rs b/vcx/dummy-cloud-agent/src/domain/config.rs index 2866a7e33c..57896c3974 100644 --- a/vcx/dummy-cloud-agent/src/domain/config.rs +++ b/vcx/dummy-cloud-agent/src/domain/config.rs @@ -1,13 +1,16 @@ use serde_json::Value; -use domain::protocol_type::ProtocolTypes; + +use crate::domain::protocol_type::ProtocolTypes; #[derive(Clone, Debug, Deserialize)] pub struct Config { pub app: AppConfig, pub forward_agent: ForwardAgentConfig, pub server: ServerConfig, + pub server_admin: Option, pub wallet_storage: WalletStorageConfig, pub protocol_type: Option, + pub indy_runtime: Option } #[derive(Clone, Debug, Deserialize)] @@ -27,9 +30,7 @@ pub struct ForwardAgentConfig { #[derive(Clone, Debug, Deserialize)] pub struct AppConfig { // Http application prefix - pub prefix: String, - // enable or disable http api for fetching information about agency status - pub enable_admin_api: Option + pub prefix: String } #[derive(Clone, Debug, Deserialize)] @@ -40,6 +41,14 @@ pub struct ServerConfig { pub workers: Option, } +#[derive(Clone, Debug, Deserialize)] +pub struct ServerAdminConfig { + // enable or disable http api for fetching information about agency status + pub enabled: bool, + // List of ip:port to bind + pub addresses: Vec, +} + #[derive(Clone, Debug, Deserialize)] pub struct WalletStorageConfig { // Wallet storage type for agents wallets @@ -56,3 +65,9 @@ pub struct WalletStorageConfig { // Wallet storage credentials for agents wallets pub credentials: Option, } + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct IndyRuntimeConfig { + // size of thread pool for the most expensive crypto operations + pub crypto_thread_pool_size: usize +} \ No newline at end of file diff --git a/vcx/dummy-cloud-agent/src/domain/internal_message.rs b/vcx/dummy-cloud-agent/src/domain/internal_message.rs index 4bb83fd819..179c63edf3 100644 --- a/vcx/dummy-cloud-agent/src/domain/internal_message.rs +++ b/vcx/dummy-cloud-agent/src/domain/internal_message.rs @@ -1,11 +1,10 @@ -use domain::a2a::RemoteMessageType; -use domain::status::MessageStatusCode; -use domain::payload::Thread; - -use utils::rand::rand_string; - use std::collections::HashMap; +use crate::domain::a2a::RemoteMessageType; +use crate::domain::payload::Thread; +use crate::domain::status::MessageStatusCode; +use crate::utils::rand::rand_string; + #[derive(Debug, Clone, Serialize, Deserialize)] pub struct InternalMessage { pub uid: String, diff --git a/vcx/dummy-cloud-agent/src/domain/invite.rs b/vcx/dummy-cloud-agent/src/domain/invite.rs index 1b70b3968c..f37da8fadc 100644 --- a/vcx/dummy-cloud-agent/src/domain/invite.rs +++ b/vcx/dummy-cloud-agent/src/domain/invite.rs @@ -1,5 +1,5 @@ -use domain::status::MessageStatusCode; -use domain::key_deligation_proof::KeyDlgProof; +use crate::domain::key_deligation_proof::KeyDlgProof; +use crate::domain::status::MessageStatusCode; #[derive(Debug, Deserialize, Serialize)] pub struct InviteDetail { diff --git a/vcx/dummy-cloud-agent/src/domain/message_type.rs b/vcx/dummy-cloud-agent/src/domain/message_type.rs index ce63144bcd..dc2d00bc2f 100644 --- a/vcx/dummy-cloud-agent/src/domain/message_type.rs +++ b/vcx/dummy-cloud-agent/src/domain/message_type.rs @@ -1,8 +1,9 @@ -use serde::{de, Deserializer, Deserialize, Serializer, Serialize}; -use serde_json::Value; -use regex::{Regex, Match}; use failure::{err_msg, Error}; -use domain::a2a::A2AMessageKinds; +use regex::{Match, Regex}; +use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; +use serde_json::Value; + +use crate::domain::a2a::A2AMessageKinds; pub const DID: &str = "did:sov:123456789abcdefghi1234"; pub const MESSAGE_VERSION_V1: &str = "1.0"; diff --git a/vcx/dummy-cloud-agent/src/domain/payload.rs b/vcx/dummy-cloud-agent/src/domain/payload.rs index e669f700b5..b047785843 100644 --- a/vcx/dummy-cloud-agent/src/domain/payload.rs +++ b/vcx/dummy-cloud-agent/src/domain/payload.rs @@ -1,8 +1,9 @@ -use domain::message_type::{MessageTypeV2, MessageFamilies, MESSAGE_VERSION_V1, DID}; -use domain::a2a::RemoteMessageType; -use domain::protocol_type::{ProtocolType, ProtocolTypes}; use std::collections::HashMap; +use crate::domain::a2a::RemoteMessageType; +use crate::domain::message_type::{DID, MESSAGE_VERSION_V1, MessageFamilies, MessageTypeV2}; +use crate::domain::protocol_type::{ProtocolType, ProtocolTypes}; + #[derive(Deserialize, Serialize, Debug)] #[serde(untagged)] pub enum Payloads { diff --git a/vcx/dummy-cloud-agent/src/indy/crypto.rs b/vcx/dummy-cloud-agent/src/indy/crypto.rs index aa8bda3343..11b75cc2c2 100644 --- a/vcx/dummy-cloud-agent/src/indy/crypto.rs +++ b/vcx/dummy-cloud-agent/src/indy/crypto.rs @@ -1,56 +1,57 @@ -use indyrs::{crypto, IndyError}; use futures::*; -use utils::futures::*; +use indyrs::{crypto, IndyError, WalletHandle}; -pub fn auth_crypt(wallet_handle: i32, +use crate::utils::futures::*; + +pub fn auth_crypt(wallet_handle: WalletHandle, sender_vk: &str, recipient_vk: &str, - message: &[u8]) -> Box, Error=IndyError>> { + message: &[u8]) -> Box, Error=IndyError>> { crypto::auth_crypt(wallet_handle, sender_vk, recipient_vk, message) .into_box() } -pub fn auth_decrypt(wallet_handle: i32, +pub fn auth_decrypt(wallet_handle: WalletHandle, recipient_vk: &str, - encrypted_message: &[u8]) -> Box), Error=IndyError>> { + encrypted_message: &[u8]) -> Box), Error=IndyError>> { crypto::auth_decrypt(wallet_handle, recipient_vk, encrypted_message) .into_box() } pub fn anon_crypt(recipient_vk: &str, - message: &[u8]) -> Box, Error=IndyError>> { + message: &[u8]) -> Box, Error=IndyError>> { crypto::anon_crypt(recipient_vk, message) .into_box() } -pub fn anon_decrypt(wallet_handle: i32, +pub fn anon_decrypt(wallet_handle: WalletHandle, recipient_vk: &str, - encrypted_message: &[u8]) -> Box, Error=IndyError>> { + encrypted_message: &[u8]) -> Box, Error=IndyError>> { crypto::anon_decrypt(wallet_handle, recipient_vk, encrypted_message) .into_box() } #[cfg(test)] -pub fn sign(wallet_handle: i32, +pub fn sign(wallet_handle: WalletHandle, signer_vk: &str, - message: &[u8]) -> Box, Error=IndyError>> { + message: &[u8]) -> Box, Error=IndyError>> { crypto::sign(wallet_handle, signer_vk, message) .into_box() } pub fn verify(signer_vk: &str, message: &[u8], - signature: &[u8]) -> Box> { + signature: &[u8]) -> Box> { crypto::verify(signer_vk, message, signature) .into_box() } -pub fn pack_message(wallet_handle: i32, sender_vk: Option<&str>, receiver_keys: &str, msg: &[u8]) -> Box, Error=IndyError>> { +pub fn pack_message(wallet_handle: WalletHandle, sender_vk: Option<&str>, receiver_keys: &str, msg: &[u8]) -> Box, Error=IndyError>> { crypto::pack_message(wallet_handle, msg, receiver_keys, sender_vk) .into_box() } -pub fn unpack_message(wallet_handle: i32, msg: &[u8]) -> Box, Error=IndyError>> { +pub fn unpack_message(wallet_handle: WalletHandle, msg: &[u8]) -> Box, Error=IndyError>> { crypto::unpack_message(wallet_handle, msg) .into_box() } diff --git a/vcx/dummy-cloud-agent/src/indy/did.rs b/vcx/dummy-cloud-agent/src/indy/did.rs index 96bbd9ce79..a68ce147b6 100644 --- a/vcx/dummy-cloud-agent/src/indy/did.rs +++ b/vcx/dummy-cloud-agent/src/indy/did.rs @@ -1,28 +1,29 @@ use futures::*; -use utils::futures::*; -use indyrs::{did, IndyError}; +use indyrs::{did, IndyError, WalletHandle}; -pub fn create_and_store_my_did(wallet_handle: i32, did_info: &str) -> Box> { +use crate::utils::futures::*; + +pub fn create_and_store_my_did(wallet_handle: WalletHandle, did_info: &str) -> Box> { did::create_and_store_my_did(wallet_handle, did_info) .into_box() } -pub fn key_for_local_did(wallet_handle: i32, did: &str) -> Box> { +pub fn key_for_local_did(wallet_handle: WalletHandle, did: &str) -> Box> { did::key_for_local_did(wallet_handle, did) .into_box() } -pub fn store_their_did(wallet_handle: i32, did_info: &str) -> Box> { +pub fn store_their_did(wallet_handle: WalletHandle, did_info: &str) -> Box> { did::store_their_did(wallet_handle, did_info) .into_box() } -pub fn set_did_metadata(wallet_handle: i32, did: &str, metadata: &str) -> Box> { +pub fn set_did_metadata(wallet_handle: WalletHandle, did: &str, metadata: &str) -> Box> { did::set_did_metadata(wallet_handle, did, metadata) .into_box() } -pub fn get_did_metadata(wallet_handle: i32, did: &str) -> Box> { +pub fn get_did_metadata(wallet_handle: WalletHandle, did: &str) -> Box> { did::get_did_metadata(wallet_handle, did) .into_box() } \ No newline at end of file diff --git a/vcx/dummy-cloud-agent/src/indy/logger.rs b/vcx/dummy-cloud-agent/src/indy/logger.rs index 0e16a92181..8722628935 100644 --- a/vcx/dummy-cloud-agent/src/indy/logger.rs +++ b/vcx/dummy-cloud-agent/src/indy/logger.rs @@ -1,4 +1,4 @@ -use indyrs::{logger, IndyError}; +use indyrs::{IndyError, logger}; pub fn set_default_logger(pattern: Option<&str>) -> Result<(), IndyError> { logger::set_default_logger(pattern) diff --git a/vcx/dummy-cloud-agent/src/indy/mod.rs b/vcx/dummy-cloud-agent/src/indy/mod.rs index f10da79ad4..f4f957853c 100644 --- a/vcx/dummy-cloud-agent/src/indy/mod.rs +++ b/vcx/dummy-cloud-agent/src/indy/mod.rs @@ -4,5 +4,5 @@ pub mod logger; pub mod pairwise; pub mod wallet; pub mod wallet_plugin; -pub use indyrs::{ErrorCode, IndyError}; +pub use indyrs::{ErrorCode, IndyError, WalletHandle}; diff --git a/vcx/dummy-cloud-agent/src/indy/pairwise.rs b/vcx/dummy-cloud-agent/src/indy/pairwise.rs index 1b61d966fd..559bdabc55 100644 --- a/vcx/dummy-cloud-agent/src/indy/pairwise.rs +++ b/vcx/dummy-cloud-agent/src/indy/pairwise.rs @@ -1,6 +1,7 @@ use futures::*; -use utils::futures::*; -use indyrs::{pairwise, IndyError}; +use indyrs::{IndyError, pairwise, WalletHandle}; + +use crate::utils::futures::*; #[derive(Deserialize, Debug)] pub struct Pairwise { @@ -16,27 +17,27 @@ pub struct PairwiseInfo { } -pub fn is_pairwise_exists(wallet_handle: i32, their_did: &str) -> Box> { +pub fn is_pairwise_exists(wallet_handle: WalletHandle, their_did: &str) -> Box> { pairwise::is_pairwise_exists(wallet_handle, their_did) .into_box() } -pub fn create_pairwise(wallet_handle: i32, their_did: &str, my_did: &str, metadata: Option<&str>) -> Box> { +pub fn create_pairwise(wallet_handle: WalletHandle, their_did: &str, my_did: &str, metadata: Option<&str>) -> Box> { pairwise::create_pairwise(wallet_handle, their_did, my_did, metadata) .into_box() } -pub fn get_pairwise(wallet_handle: i32, their_did: &str) -> Box> { +pub fn get_pairwise(wallet_handle: WalletHandle, their_did: &str) -> Box> { pairwise::get_pairwise(wallet_handle, their_did) .into_box() } -pub fn list_pairwise(wallet_handle: i32) -> Box> { +pub fn list_pairwise(wallet_handle: WalletHandle) -> Box> { pairwise::list_pairwise(wallet_handle) .into_box() } -pub fn set_pairwise_metadata(wallet_handle: i32, their_did: &str, metadata: &str) -> Box> { +pub fn set_pairwise_metadata(wallet_handle: WalletHandle, their_did: &str, metadata: &str) -> Box> { pairwise::set_pairwise_metadata(wallet_handle, their_did, Some(metadata)) .into_box() } \ No newline at end of file diff --git a/vcx/dummy-cloud-agent/src/indy/wallet.rs b/vcx/dummy-cloud-agent/src/indy/wallet.rs index 5f44895835..2e74dca573 100644 --- a/vcx/dummy-cloud-agent/src/indy/wallet.rs +++ b/vcx/dummy-cloud-agent/src/indy/wallet.rs @@ -1,19 +1,21 @@ use futures::*; -use utils::futures::*; -use indyrs::{wallet, IndyError}; -pub fn create_wallet(config: &str, credentials: &str) -> Box> { +use indyrs::{IndyError, wallet, WalletHandle}; + +use crate::utils::futures::*; + +pub fn create_wallet(config: &str, credentials: &str) -> Box> { wallet::create_wallet(config, credentials) .into_box() } -pub fn open_wallet(config: &str, credentials: &str) -> Box> { +pub fn open_wallet(config: &str, credentials: &str) -> Box> { wallet::open_wallet(config, credentials) .into_box() } #[allow(unused)] // TODO: Use! -pub fn close_wallet(wallet_handle: i32) -> Box> { +pub fn close_wallet(wallet_handle: WalletHandle) -> Box> { wallet::close_wallet(wallet_handle) .into_box() } \ No newline at end of file diff --git a/vcx/dummy-cloud-agent/src/indy/wallet_plugin.rs b/vcx/dummy-cloud-agent/src/indy/wallet_plugin.rs index 29daf9bbb5..b719392a2f 100644 --- a/vcx/dummy-cloud-agent/src/indy/wallet_plugin.rs +++ b/vcx/dummy-cloud-agent/src/indy/wallet_plugin.rs @@ -1,8 +1,10 @@ -use indyrs::{ErrorCode}; use std::ffi::CString; + +use indyrs::ErrorCode; use libc::c_char; use serde_json::Value; -use utils::dyn_lib::load_lib; + +use crate::utils::dyn_lib::load_lib; pub fn load_storage_library(library: &str, initializer: &str) -> Result { debug!("Loading storage plugin '{:}' as dynamic library.", library); @@ -90,8 +92,9 @@ pub fn serialize_storage_plugin_configuration(storage_type: &str, #[cfg(test)] mod tests { + use crate::domain::config::WalletStorageConfig; + use super::*; - use domain::config::WalletStorageConfig; #[test] fn should_load_custom_storage_settings_from_config() { diff --git a/vcx/dummy-cloud-agent/src/main.rs b/vcx/dummy-cloud-agent/src/main.rs index 22f68fccc1..fe42b56f27 100644 --- a/vcx/dummy-cloud-agent/src/main.rs +++ b/vcx/dummy-cloud-agent/src/main.rs @@ -1,50 +1,41 @@ // `error_chain!` can recurse deeply #![recursion_limit = "1024"] -extern crate actix; -extern crate actix_web; -extern crate bytes; #[cfg(test)] extern crate dirs; -extern crate failure; -extern crate futures; +#[macro_use] +extern crate lazy_static; #[macro_use] extern crate log; extern crate pretty_env_logger as env_logger; -extern crate rmp_serde; -extern crate serde; #[macro_use] extern crate serde_derive; #[macro_use] extern crate serde_json; #[cfg(test)] extern crate tokio_core; -extern crate base64; -extern crate rand; -extern crate hyper; -extern crate indyrs; -extern crate regex; -#[macro_use] -extern crate lazy_static; -extern crate libc; -extern crate libloading; -use actix::prelude::*; -use actors::forward_agent::ForwardAgent; -use domain::config::{Config, WalletStorageConfig}; -use domain::protocol_type::ProtocolType; -use failure::*; use std::env; use std::fs::File; + +use actix::prelude::*; +use failure::*; + use actors::admin::Admin; -use app::start_app_server; -use indy::wallet_plugin::{load_storage_library, serialize_storage_plugin_configuration, finish_loading_postgres}; +use actors::forward_agent::ForwardAgent; +use indy::wallet_plugin::{finish_loading_postgres, load_storage_library, serialize_storage_plugin_configuration}; + +use crate::app::start_app_server; +use crate::app_admin::start_app_admin_server; +use crate::domain::config::{Config, WalletStorageConfig}; +use crate::domain::protocol_type::ProtocolType; #[macro_use] pub(crate) mod utils; - pub(crate) mod actors; pub(crate) mod app; +pub(crate) mod app_admin; +pub(crate) mod api_agent; pub(crate) mod domain; pub(crate) mod indy; @@ -101,19 +92,32 @@ fn _init_wallet(wallet_storage_config: &WalletStorageConfig) -> Result<(), Strin fn _start(config_path: &str) { info!("Starting Indy Dummy Agent with config: {}", config_path); - let Config { app: app_config, forward_agent: forward_agent_config, server: server_config, wallet_storage: wallet_storage_config, protocol_type: protocol_type_config, + indy_runtime, + server_admin: server_admin_config } = File::open(config_path) .context("Can't open config file") .and_then(|reader| serde_json::from_reader(reader) .context("Can't parse config file")) .expect("Invalid configuration file"); + match indy_runtime { + Some(x) => { + let runtime_config_str = serde_json::to_string(&x) + .expect("Failed to re-serialize indy_runtime."); + info!("Setting indy runtime configuration: {}", &runtime_config_str); + indyrs::set_runtime_config(&runtime_config_str); + } + None => { + info!("Will use IndySDK default number of threads for expensive crypto."); + } + } + match _init_wallet(&wallet_storage_config) { Err(err) => panic!("Failed to load and initialize storage library. {:}", err), Ok(()) => {} @@ -126,7 +130,14 @@ fn _start(config_path: &str) { ProtocolType::set(protocol_type_config); - let admin = Admin::create(); + let admin = match &server_admin_config { + Some(server_admin_config) if server_admin_config.enabled => { + let admin = Admin::create(); + start_app_admin_server(server_admin_config, admin.clone()); + Some(admin) + }, + _ => None + }; ForwardAgent::create_or_restore(forward_agent_config, wallet_storage_config, admin.clone()) .map(move |forward_agent| { start_app_server(server_config, app_config, forward_agent, admin) diff --git a/vcx/dummy-cloud-agent/src/utils/futures.rs b/vcx/dummy-cloud-agent/src/utils/futures.rs index bc2e2289e6..aa85c17e22 100644 --- a/vcx/dummy-cloud-agent/src/utils/futures.rs +++ b/vcx/dummy-cloud-agent/src/utils/futures.rs @@ -1,6 +1,8 @@ -use actix::fut::ActorFuture; use futures::Future; +use actix::prelude::*; +use actix::fut::ActorFuture; + /// This is the equivalent `try!` adapted to deal with futures. #[macro_export] macro_rules! ftry { @@ -63,7 +65,7 @@ macro_rules! err_act { }}; } -pub type BoxedFuture = Box>; +pub type BoxedFuture = Box>; pub trait FutureExt: Future + Sized { /// Box this future. Similar to `boxed` combinator, but does not require @@ -72,12 +74,12 @@ pub trait FutureExt: Future + Sized { } impl FutureExt for F { - fn into_box(self) -> Box> { + fn into_box(self) -> Box> { Box::new(self) } } -pub type BoxedActorFuture = Box>; +pub type BoxedActorFuture = Box>; pub trait ActorFutureExt: ActorFuture + Sized { /// Box this future. Similar to `boxed` combinator, but does not require @@ -86,7 +88,7 @@ pub trait ActorFutureExt: ActorFuture + Sized { } impl ActorFutureExt for F { - fn into_box(self) -> Box> { + fn into_box(self) -> Box> { Box::new(self) } } \ No newline at end of file diff --git a/vcx/dummy-cloud-agent/src/utils/rand.rs b/vcx/dummy-cloud-agent/src/utils/rand.rs index 9b2d14ddea..d19778e8c8 100644 --- a/vcx/dummy-cloud-agent/src/utils/rand.rs +++ b/vcx/dummy-cloud-agent/src/utils/rand.rs @@ -1,4 +1,4 @@ -use rand::{thread_rng, Rng}; +use rand::{Rng, thread_rng}; pub fn rand_string(len: usize) -> String { thread_rng().gen_ascii_chars().take(len).collect() diff --git a/vcx/dummy-cloud-agent/src/utils/tests.rs b/vcx/dummy-cloud-agent/src/utils/tests.rs index 432f032954..1554f20b87 100644 --- a/vcx/dummy-cloud-agent/src/utils/tests.rs +++ b/vcx/dummy-cloud-agent/src/utils/tests.rs @@ -1,25 +1,28 @@ +use std::env; +use std::fs; +use std::path::PathBuf; + use actix::prelude::*; -use actors::forward_agent::ForwardAgent; -use actors::ForwardA2AMsg; -use actors::agent::Agent; -use dirs; use base64; -use domain::a2a::*; -use domain::a2connection::*; -use domain::config::*; -use domain::key_deligation_proof::*; -use domain::invite::*; -use domain::status::*; +use dirs; use env_logger; use failure::{err_msg, Error, Fail}; use futures::*; -use indy::{self, did, wallet, crypto}; -use std::env; -use std::fs; -use std::path::PathBuf; use tokio_core::reactor::Core; -use utils::futures::*; -use actors::admin::Admin; + +use crate::actors::admin::Admin; +use crate::actors::agent::Agent; +use crate::actors::forward_agent::ForwardAgent; +use crate::actors::ForwardA2AMsg; +use crate::domain::a2a::*; +use crate::domain::a2connection::*; +use crate::domain::admin_message::AdminQuery; +use crate::domain::config::*; +use crate::domain::invite::*; +use crate::domain::key_deligation_proof::*; +use crate::domain::status::*; +use crate::indy::{crypto, did, wallet, WalletHandle}; +use crate::utils::futures::*; pub const EDGE_AGENT_WALLET_ID: &'static str = "edge_agent_wallet_id"; pub const EDGE_AGENT_WALLET_CONFIG: &'static str = "{\"id\": \"edge_agent_wallet_id\"}"; @@ -37,7 +40,7 @@ pub const EDGE_PAIRWISE_DID_2: &'static str = "WNnf2uJPZNmvMmA6LkdVAp"; pub const EDGE_PAIRWISE_DID_INFO_2: &'static str = "{\"did\": \"WNnf2uJPZNmvMmA6LkdVAp\", \"seed\": \"0000000000000000000EdgePairwise2\"}"; pub const EDGE_PAIRWISE_DID_VERKEY_2: &'static str = "H1d58X25s91rTXdd46hTfn7mhtPmohQFYRHD379UtytR"; -pub static mut FORWARD_AGENT_WALLET_HANDLE: i32 = 0; +pub static mut FORWARD_AGENT_WALLET_HANDLE: WalletHandle = WalletHandle(0); pub const FORWARD_AGENT_WALLET_ID: &'static str = "forward_agent_wallet_id"; pub const FORWARD_AGENT_WALLET_CONFIG: &'static str = "{\"id\": \"forward_agent_wallet_id\"}"; pub const FORWARD_AGENT_WALLET_PASSPHRASE: &'static str = "forward_agent_wallet_passphrase"; @@ -102,20 +105,24 @@ pub fn cleanup_storage() { pub fn run_test(f: F) where - F: FnOnce(Addr) -> B + 'static, + F: FnOnce(Addr, Addr) -> B + 'static, B: IntoFuture + 'static { - indy::logger::set_default_logger(None).ok(); + crate::indy::logger::set_default_logger(None).ok(); env_logger::try_init().ok(); cleanup_storage(); System::run(|| { Arbiter::spawn_fn(move || { + let admin = Admin::create(); + let admin_for_test = admin.clone(); future::ok(()) .and_then(move |_| { - let admin = Admin::create(); + let admin = Some(admin); ForwardAgent::create_or_restore(forward_agent_config(), wallet_storage_config(), admin) }) - .and_then(f) + .and_then(move |fw_agent| { + f(fw_agent, admin_for_test) + }) .and_then(|wallet_handle| unsafe { wallet::close_wallet(FORWARD_AGENT_WALLET_HANDLE) @@ -132,9 +139,9 @@ pub fn run_test(f: F) pub fn run_agent_test(f: F) where - F: FnOnce((i32, String, String, String, String, Addr)) -> B + 'static, - B: IntoFuture + 'static { - run_test(|forward_agent| { + F: FnOnce((WalletHandle, String, String, String, String, Addr)) -> B + 'static, + B: IntoFuture + 'static { + run_test(|forward_agent, admin| { future::ok(()) .and_then(|()| { setup_agent(forward_agent) @@ -144,7 +151,23 @@ pub fn run_agent_test(f: F) }) } -pub fn setup_agent(forward_agent: Addr) -> ResponseFuture<(i32, String, String, String, String, Addr), Error> { +pub fn run_admin_test(f: F) + where + F: FnOnce((WalletHandle, String, String, String, String, Addr, Addr)) -> B + 'static, + B: IntoFuture + 'static { + run_test(|forward_agent, admin| { + future::ok(()) + .and_then(|()| { + setup_agent(forward_agent) + }) + .and_then(move |(agent_wallet_handle, agent_did, agent_verkey, with_pairwise_did, with_pairwise_did_verkey, forward_agent)| { + f((agent_wallet_handle, agent_did, agent_verkey, with_pairwise_did, with_pairwise_did_verkey, forward_agent, admin)) + }) + .map(|wallet_handle| wallet::close_wallet(wallet_handle).wait().unwrap()) + }) +} + +pub fn setup_agent(forward_agent: Addr) -> ResponseFuture<(WalletHandle, String, String, String, String, Addr), Error> { future::ok(()) .and_then(|()| { let e_wallet_handle = edge_wallet_setup().wait().unwrap(); @@ -210,7 +233,7 @@ pub fn wallet_storage_config() -> WalletStorageConfig { } } -pub fn edge_wallet_setup() -> BoxedFuture { +pub fn edge_wallet_setup() -> BoxedFuture { future::ok(()) .and_then(|_| { wallet::create_wallet(EDGE_AGENT_WALLET_CONFIG, EDGE_AGENT_WALLET_CREDENTIALS) @@ -233,7 +256,7 @@ pub fn edge_wallet_setup() -> BoxedFuture { .into_box() } -pub fn compose_connect(wallet_handle: i32) -> BoxedFuture, Error> { +pub fn compose_connect(wallet_handle: WalletHandle) -> BoxedFuture, Error> { let msgs = [A2AMessage::Version1(A2AMessageV1::Connect( Connect { from_did: EDGE_AGENT_DID.into(), @@ -247,7 +270,7 @@ pub fn compose_connect(wallet_handle: i32) -> BoxedFuture, Error> { compose_forward(wallet_handle, FORWARD_AGENT_DID, FORWARD_AGENT_DID_VERKEY, msg) } -pub fn decompose_connected(wallet_handle: i32, msg: &[u8]) -> BoxedFuture<(String, String, String), Error> { +pub fn decompose_connected(wallet_handle: WalletHandle, msg: &[u8]) -> BoxedFuture<(String, String, String), Error> { A2AMessage::unbundle_authcrypted(wallet_handle, EDGE_AGENT_DID_VERKEY, &msg) .and_then(|(sender_verkey, mut msgs)| { if let Some(A2AMessage::Version1(A2AMessageV1::Connected(msg))) = msgs.pop() { @@ -260,17 +283,17 @@ pub fn decompose_connected(wallet_handle: i32, msg: &[u8]) -> BoxedFuture<(Strin .into_box() } -pub fn compose_signup(wallet_handle: i32, pairwise_did: &str, pairwise_verkey: &str) -> BoxedFuture, Error> { +pub fn compose_signup(wallet_handle: WalletHandle, pairwise_did: &str, pairwise_verkey: &str) -> BoxedFuture, Error> { let msgs = [A2AMessage::Version1(A2AMessageV1::SignUp(SignUp {}))]; let msg = A2AMessage::prepare_authcrypted(wallet_handle, EDGE_AGENT_DID_VERKEY, pairwise_verkey, &msgs).wait().unwrap(); - compose_forward(wallet_handle,&pairwise_did, FORWARD_AGENT_DID_VERKEY, msg) + compose_forward(wallet_handle, &pairwise_did, FORWARD_AGENT_DID_VERKEY, msg) } -pub fn decompose_signedup(wallet_handle: i32, msg: &[u8]) -> BoxedFuture { +pub fn decompose_signedup(wallet_handle: WalletHandle, msg: &[u8]) -> BoxedFuture { A2AMessage::unbundle_authcrypted(wallet_handle, EDGE_AGENT_DID_VERKEY, &msg) .and_then(|(sender_verkey, mut msgs)| { if let Some(A2AMessage::Version1(A2AMessageV1::SignedUp(_))) = msgs.pop() { @@ -282,17 +305,17 @@ pub fn decompose_signedup(wallet_handle: i32, msg: &[u8]) -> BoxedFuture BoxedFuture, Error> { +pub fn compose_create_agent(wallet_handle: WalletHandle, pairwise_did: &str, pairwise_verkey: &str) -> BoxedFuture, Error> { let msgs = vec![A2AMessage::Version1(A2AMessageV1::CreateAgent(CreateAgent {}))]; let msg = A2AMessage::prepare_authcrypted(wallet_handle, EDGE_AGENT_DID_VERKEY, pairwise_verkey, &msgs).wait().unwrap(); - compose_forward(wallet_handle,pairwise_did, FORWARD_AGENT_DID_VERKEY, msg) + compose_forward(wallet_handle, pairwise_did, FORWARD_AGENT_DID_VERKEY, msg) } -pub fn decompose_agent_created(wallet_handle: i32, msg: &[u8]) -> BoxedFuture<(String, String, String), Error> { +pub fn decompose_agent_created(wallet_handle: WalletHandle, msg: &[u8]) -> BoxedFuture<(String, String, String), Error> { A2AMessage::unbundle_authcrypted(wallet_handle, EDGE_AGENT_DID_VERKEY, &msg) .and_then(|(sender_verkey, mut msgs)| { if let Some(A2AMessage::Version1(A2AMessageV1::AgentCreated(agent_created))) = msgs.pop() { @@ -305,21 +328,21 @@ pub fn decompose_agent_created(wallet_handle: i32, msg: &[u8]) -> BoxedFuture<(S .into_box() } -pub fn compose_create_key(wallet_handle: i32, agent_did: &str, agent_verkey: &str, for_did: &str, for_verkey: &str) -> BoxedFuture, Error> { +pub fn compose_create_key(wallet_handle: WalletHandle, agent_did: &str, agent_verkey: &str, for_did: &str, for_verkey: &str) -> BoxedFuture, Error> { let msgs = [A2AMessage::Version1(A2AMessageV1::CreateKey( CreateKey { for_did: for_did.into(), - for_did_verkey: for_verkey.into() + for_did_verkey: for_verkey.into(), }))]; let msg = A2AMessage::prepare_authcrypted(wallet_handle, EDGE_AGENT_DID_VERKEY, agent_verkey, &msgs).wait().unwrap(); - compose_forward(wallet_handle,agent_did, FORWARD_AGENT_DID_VERKEY, msg) + compose_forward(wallet_handle, agent_did, FORWARD_AGENT_DID_VERKEY, msg) } -pub fn decompose_key_created(wallet_handle: i32, msg: &[u8]) -> BoxedFuture<(String, KeyCreated), Error> { +pub fn decompose_key_created(wallet_handle: WalletHandle, msg: &[u8]) -> BoxedFuture<(String, KeyCreated), Error> { A2AMessage::unbundle_authcrypted(wallet_handle, EDGE_AGENT_DID_VERKEY, &msg) .and_then(|(sender_verkey, mut msgs)| { if let Some(A2AMessage::Version1(A2AMessageV1::KeyCreated(key_created))) = msgs.pop() { @@ -331,7 +354,7 @@ pub fn decompose_key_created(wallet_handle: i32, msg: &[u8]) -> BoxedFuture<(Str .into_box() } -pub fn compose_create_connection_request(wallet_handle: i32, +pub fn compose_create_connection_request(wallet_handle: WalletHandle, agent_did: &str, agent_verkey: &str, agent_pairwise_did: &str, @@ -353,7 +376,7 @@ pub fn compose_create_connection_request(wallet_handle: i32, compose_message(wallet_handle, &msgs, agent_pairwise_did, agent_pairwise_verkey, agent_did, agent_verkey) } -pub fn decompose_connection_request_created(wallet_handle: i32, msg: &[u8]) -> BoxedFuture<(String, String, InviteDetail), Error> { +pub fn decompose_connection_request_created(wallet_handle: WalletHandle, msg: &[u8]) -> BoxedFuture<(String, String, InviteDetail), Error> { A2AMessage::unbundle_authcrypted(wallet_handle, EDGE_AGENT_DID_VERKEY, &msg) .and_then(|(sender_verkey, mut msgs)| { assert_eq!(2, msgs.len()); @@ -367,7 +390,7 @@ pub fn decompose_connection_request_created(wallet_handle: i32, msg: &[u8]) -> B .into_box() } -pub fn compose_create_connection_request_answer(wallet_handle: i32, +pub fn compose_create_connection_request_answer(wallet_handle: WalletHandle, agent_did: &str, agent_verkey: &str, agent_pairwise_did: &str, @@ -405,7 +428,7 @@ pub fn compose_create_connection_request_answer(wallet_handle: i32, compose_message(wallet_handle, &msgs, agent_pairwise_did, agent_pairwise_verkey, agent_did, agent_verkey) } -pub fn decompose_connection_request_answer_created(wallet_handle: i32, msg: &[u8]) -> BoxedFuture<(String, String), Error> { +pub fn decompose_connection_request_answer_created(wallet_handle: WalletHandle, msg: &[u8]) -> BoxedFuture<(String, String), Error> { A2AMessage::unbundle_authcrypted(wallet_handle, EDGE_AGENT_DID_VERKEY, &msg) .and_then(|(sender_verkey, mut msgs)| { assert_eq!(1, msgs.len()); @@ -417,7 +440,7 @@ pub fn decompose_connection_request_answer_created(wallet_handle: i32, msg: &[u8 .into_box() } -pub fn compose_create_general_message(wallet_handle: i32, +pub fn compose_create_general_message(wallet_handle: WalletHandle, agent_did: &str, agent_verkey: &str, agent_pairwise_did: &str, @@ -445,11 +468,11 @@ fn build_create_message_request(mtype: RemoteMessageType, reply_to_msg_id: Optio mtype, send_msg: false, uid: None, - reply_to_msg_id + reply_to_msg_id, })) } -pub fn decompose_general_message_created(wallet_handle: i32, msg: &[u8]) -> BoxedFuture<(String, String), Error> { +pub fn decompose_general_message_created(wallet_handle: WalletHandle, msg: &[u8]) -> BoxedFuture<(String, String), Error> { A2AMessage::unbundle_authcrypted(wallet_handle, EDGE_AGENT_DID_VERKEY, &msg) .and_then(|(sender_verkey, mut msgs)| { assert_eq!(1, msgs.len()); @@ -461,7 +484,7 @@ pub fn decompose_general_message_created(wallet_handle: i32, msg: &[u8]) -> Boxe .into_box() } -pub fn compose_get_messages(wallet_handle: i32, +pub fn compose_get_messages(wallet_handle: WalletHandle, agent_did: &str, agent_verkey: &str, agent_pairwise_did: &str, @@ -475,7 +498,7 @@ pub fn compose_get_messages(wallet_handle: i32, compose_message(wallet_handle, &msgs, agent_pairwise_did, agent_pairwise_verkey, agent_did, agent_verkey) } -pub fn decompose_get_messages(wallet_handle: i32, msg: &[u8]) -> BoxedFuture<(String, Vec), Error> { +pub fn decompose_get_messages(wallet_handle: WalletHandle, msg: &[u8]) -> BoxedFuture<(String, Vec), Error> { A2AMessage::unbundle_authcrypted(wallet_handle, EDGE_AGENT_DID_VERKEY, &msg) .and_then(|(sender_verkey, mut msgs)| { assert_eq!(1, msgs.len()); @@ -487,7 +510,7 @@ pub fn decompose_get_messages(wallet_handle: i32, msg: &[u8]) -> BoxedFuture<(St .into_box() } -pub fn compose_update_message_status_message(wallet_handle: i32, +pub fn compose_update_message_status_message(wallet_handle: WalletHandle, agent_did: &str, agent_verkey: &str, agent_pairwise_did: &str, @@ -496,13 +519,13 @@ pub fn compose_update_message_status_message(wallet_handle: i32, status_code: MessageStatusCode) -> BoxedFuture, Error> { let msgs = [A2AMessage::Version1(A2AMessageV1::UpdateMessageStatus(UpdateMessageStatus { uids: vec![uid.to_string()], - status_code + status_code, }))]; compose_message(wallet_handle, &msgs, agent_pairwise_did, agent_pairwise_verkey, agent_did, agent_verkey) } -pub fn decompose_message_status_updated(wallet_handle: i32, msg: &[u8]) -> BoxedFuture<(String, MessageStatusUpdated), Error> { +pub fn decompose_message_status_updated(wallet_handle: WalletHandle, msg: &[u8]) -> BoxedFuture<(String, MessageStatusUpdated), Error> { A2AMessage::unbundle_authcrypted(wallet_handle, EDGE_AGENT_DID_VERKEY, &msg) .and_then(|(sender_verkey, mut msgs)| { assert_eq!(1, msgs.len()); @@ -514,7 +537,7 @@ pub fn decompose_message_status_updated(wallet_handle: i32, msg: &[u8]) -> Boxed .into_box() } -pub fn compose_update_connection_status_message(wallet_handle: i32, +pub fn compose_update_connection_status_message(wallet_handle: WalletHandle, agent_did: &str, agent_verkey: &str, agent_pairwise_did: &str, @@ -526,7 +549,7 @@ pub fn compose_update_connection_status_message(wallet_handle: i32, compose_message(wallet_handle, &msgs, agent_pairwise_did, agent_pairwise_verkey, agent_did, agent_verkey) } -pub fn decompose_connection_status_updated(wallet_handle: i32, msg: &[u8]) -> BoxedFuture<(String, ConnectionStatusUpdated), Error> { +pub fn decompose_connection_status_updated(wallet_handle: WalletHandle, msg: &[u8]) -> BoxedFuture<(String, ConnectionStatusUpdated), Error> { A2AMessage::unbundle_authcrypted(wallet_handle, EDGE_AGENT_DID_VERKEY, &msg) .and_then(|(sender_verkey, mut msgs)| { assert_eq!(1, msgs.len()); @@ -538,7 +561,7 @@ pub fn decompose_connection_status_updated(wallet_handle: i32, msg: &[u8]) -> Bo .into_box() } -pub fn compose_get_messages_by_connection(wallet_handle: i32, +pub fn compose_get_messages_by_connection(wallet_handle: WalletHandle, agent_did: &str, agent_verkey: &str, agent_pairwise_did: &str, @@ -553,9 +576,10 @@ pub fn compose_get_messages_by_connection(wallet_handle: i32, EDGE_AGENT_DID_VERKEY, agent_verkey, &msgs).wait().unwrap(); - compose_forward(wallet_handle,agent_did, FORWARD_AGENT_DID_VERKEY, msg) + compose_forward(wallet_handle, agent_did, FORWARD_AGENT_DID_VERKEY, msg) } -pub fn decompose_get_messages_by_connection(wallet_handle: i32, msg: &[u8]) -> BoxedFuture<(String, Vec), Error> { + +pub fn decompose_get_messages_by_connection(wallet_handle: WalletHandle, msg: &[u8]) -> BoxedFuture<(String, Vec), Error> { A2AMessage::unbundle_authcrypted(wallet_handle, EDGE_AGENT_DID_VERKEY, &msg) .and_then(|(sender_verkey, mut msgs)| { assert_eq!(1, msgs.len()); @@ -567,13 +591,13 @@ pub fn decompose_get_messages_by_connection(wallet_handle: i32, msg: &[u8]) -> B .into_box() } -pub fn compose_update_configs(wallet_handle: i32, agent_did: &str, agent_verkey: &str) -> BoxedFuture, Error> { +pub fn compose_update_configs(wallet_handle: WalletHandle, agent_did: &str, agent_verkey: &str) -> BoxedFuture, Error> { let msgs = [A2AMessage::Version1(A2AMessageV1::UpdateConfigs( UpdateConfigs { configs: vec![ - ConfigOption {name: "zoom_zoom".to_string(), value: "value".to_string()}, - ConfigOption {name: "name".to_string(), value: "super agent".to_string()}, - ConfigOption {name: "logoUrl".to_string(), value: "http://logo.url".to_string()} + ConfigOption { name: "zoom_zoom".to_string(), value: "value".to_string() }, + ConfigOption { name: "name".to_string(), value: "super agent".to_string() }, + ConfigOption { name: "logoUrl".to_string(), value: "http://logo.url".to_string() } ] }))]; @@ -585,7 +609,7 @@ pub fn compose_update_configs(wallet_handle: i32, agent_did: &str, agent_verkey: compose_forward(wallet_handle, agent_did, FORWARD_AGENT_DID_VERKEY, msg) } -pub fn compose_get_configs(wallet_handle: i32, agent_did: &str, agent_verkey: &str) -> BoxedFuture, Error> { +pub fn compose_get_configs(wallet_handle: WalletHandle, agent_did: &str, agent_verkey: &str) -> BoxedFuture, Error> { let msgs = [A2AMessage::Version1(A2AMessageV1::GetConfigs( GetConfigs { configs: vec![String::from("name"), String::from("logoUrl")] @@ -599,7 +623,7 @@ pub fn compose_get_configs(wallet_handle: i32, agent_did: &str, agent_verkey: &s compose_forward(wallet_handle, agent_did, FORWARD_AGENT_DID_VERKEY, msg) } -pub fn decompose_configs(wallet_handle: i32, msg: &[u8]) -> BoxedFuture, Error> { +pub fn decompose_configs(wallet_handle: WalletHandle, msg: &[u8]) -> BoxedFuture, Error> { A2AMessage::unbundle_authcrypted(wallet_handle, EDGE_AGENT_DID_VERKEY, &msg) .and_then(|(sender_verkey, mut msgs)| { if let Some(A2AMessage::Version1(A2AMessageV1::Configs(configs))) = msgs.pop() { @@ -611,7 +635,7 @@ pub fn decompose_configs(wallet_handle: i32, msg: &[u8]) -> BoxedFuture BoxedFuture, Error> { +pub fn compose_remove_configs(wallet_handle: WalletHandle, agent_did: &str, agent_verkey: &str) -> BoxedFuture, Error> { let msgs = [A2AMessage::Version1(A2AMessageV1::RemoveConfigs( RemoveConfigs { configs: vec![String::from("name")] @@ -625,17 +649,17 @@ pub fn compose_remove_configs(wallet_handle: i32, agent_did: &str, agent_verkey: compose_forward(wallet_handle, agent_did, FORWARD_AGENT_DID_VERKEY, msg) } -pub fn compose_forward(wallet_handle: i32, recipient_did: &str, recipient_vk: &str, msg: Vec) -> BoxedFuture, Error> { +pub fn compose_forward(wallet_handle: WalletHandle, recipient_did: &str, recipient_vk: &str, msg: Vec) -> BoxedFuture, Error> { let msgs = [A2AMessage::Version1(A2AMessageV1::Forward( ForwardV1 { fwd: recipient_did.into(), msg, }))]; - A2AMessage::prepare_anoncrypted(wallet_handle,recipient_vk, &msgs) + A2AMessage::prepare_anoncrypted(wallet_handle, recipient_vk, &msgs) } -pub fn compose_authcrypted_forward(wallet_handle: i32, sender_vk: &str, recipient_did: &str, recipient_vk: &str, msg: Vec) -> BoxedFuture, Error> { +pub fn compose_authcrypted_forward(wallet_handle: WalletHandle, sender_vk: &str, recipient_did: &str, recipient_vk: &str, msg: Vec) -> BoxedFuture, Error> { let msgs = [A2AMessage::Version1(A2AMessageV1::Forward( ForwardV1 { fwd: recipient_did.into(), @@ -645,7 +669,7 @@ pub fn compose_authcrypted_forward(wallet_handle: i32, sender_vk: &str, recipien A2AMessage::prepare_authcrypted(wallet_handle, sender_vk, recipient_vk, &msgs) } -pub fn compose_message(wallet_handle: i32, +pub fn compose_message(wallet_handle: WalletHandle, msgs: &[A2AMessage], agent_pairwise_did: &str, agent_pairwise_verkey: &str, @@ -658,13 +682,13 @@ pub fn compose_message(wallet_handle: i32, compose_forward(wallet_handle, agent_did, FORWARD_AGENT_DID_VERKEY, msg) } -pub fn gen_key_delegated_proof(wallet_handle: i32, signer_vk: &str, did: &str, verkey: &str) -> KeyDlgProof { +pub fn gen_key_delegated_proof(wallet_handle: WalletHandle, signer_vk: &str, did: &str, verkey: &str) -> KeyDlgProof { let signature = format!("{}{}", did, verkey); let signature = crypto::sign(wallet_handle, signer_vk, signature.as_bytes()).wait().unwrap(); let signature = base64::encode(&signature); KeyDlgProof { agent_did: did.into(), agent_delegated_key: verkey.into(), - signature + signature, } } \ No newline at end of file diff --git a/vcx/libvcx/Cargo.lock b/vcx/libvcx/Cargo.lock index cbc9a6161a..aadb41a9f5 100644 --- a/vcx/libvcx/Cargo.lock +++ b/vcx/libvcx/Cargo.lock @@ -5,7 +5,7 @@ name = "MacTypes-sys" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -32,27 +32,8 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "android_log-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "antidote" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "arc-swap" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "argon2rs" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", - "scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -68,7 +49,7 @@ name = "atty" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -85,7 +66,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -96,7 +77,7 @@ version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -121,15 +102,6 @@ name = "bitflags" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "blake2-rfc" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "build_const" version = "0.2.1" @@ -177,11 +149,6 @@ dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "constant_time_eq" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "cookie" version = "0.11.1" @@ -197,13 +164,13 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cookie 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "publicsuffix 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "try_from 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -216,7 +183,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -224,7 +191,7 @@ name = "core-foundation-sys" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -260,7 +227,7 @@ dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -279,17 +246,7 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "dirs" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_users 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -311,8 +268,8 @@ version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -328,22 +285,22 @@ dependencies = [ [[package]] name = "failure" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "failure_derive" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -352,8 +309,7 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz-sys 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -419,7 +375,7 @@ dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -450,7 +406,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "humantime" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -469,7 +425,7 @@ dependencies = [ "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", @@ -512,28 +468,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "indy" -version = "1.14.1" +version = "1.14.2" dependencies = [ - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "indy-sys 1.14.1", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "indy-sys 1.14.2", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "num-derive 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "indy-sys" -version = "1.14.1" +version = "1.14.2" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -542,7 +500,7 @@ name = "iovec" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -567,12 +525,12 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.60" +version = "0.2.66" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -586,39 +544,33 @@ dependencies = [ [[package]] name = "libvcx" -version = "0.6.1" +version = "0.6.2" dependencies = [ "android_logger 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "indy 1.14.1", - "indy-sys 1.14.1", + "indy 1.14.2", + "indy-sys 1.14.2", "json 0.11.13 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "log-panics 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log4rs 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "openssl 0.10.22 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest 0.9.16 (registry+https://github.com/rust-lang/crates.io-index)", - "rmp 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)", "rmp-serde 0.13.7 (registry+https://github.com/rust-lang/crates.io-index)", - "rmpv 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rust-base58 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "strum 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "strum_macros 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tempfile 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -626,11 +578,6 @@ dependencies = [ "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "linked-hash-map" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "lock_api" version = "0.1.5" @@ -642,48 +589,10 @@ dependencies = [ [[package]] name = "log" -version = "0.4.6" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "log-mdc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "log-panics" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "log4rs" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "antidote 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "arc-swap 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", - "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "log-mdc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", - "serde-value 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)", - "thread-id 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "typemap 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -720,15 +629,6 @@ dependencies = [ "unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "miniz-sys" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "miniz_oxide" version = "0.2.1" @@ -744,7 +644,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", "crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "miniz_oxide 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -757,8 +657,8 @@ dependencies = [ "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -781,9 +681,9 @@ name = "native-tls" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "openssl 0.10.22 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.9.46 (registry+https://github.com/rust-lang/crates.io-index)", @@ -799,7 +699,7 @@ version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -893,7 +793,7 @@ name = "num_cpus" version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -909,8 +809,8 @@ dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.9.46 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -926,19 +826,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "ordered-float" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "owning_ref" version = "0.4.0" @@ -961,7 +853,7 @@ name = "parking_lot_core" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1036,7 +928,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1067,7 +959,7 @@ name = "rand" version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1077,7 +969,7 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1089,7 +981,7 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1144,7 +1036,7 @@ name = "rand_jitter" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1156,7 +1048,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1200,17 +1092,6 @@ dependencies = [ "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "redox_users" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "regex" version = "1.1.6" @@ -1254,11 +1135,11 @@ dependencies = [ "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.12.28 (registry+https://github.com/rust-lang/crates.io-index)", "hyper-tls 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "mime_guess 2.0.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", "native-tls 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1287,16 +1168,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rmp 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rmpv" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", - "rmp 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1335,15 +1207,10 @@ name = "schannel" version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "scoped_threadpool" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "scopeguard" version = "0.3.3" @@ -1356,7 +1223,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "security-framework-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1367,7 +1234,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "MacTypes-sys 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1385,26 +1252,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.97" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "serde-value" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "ordered-float 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "serde_derive" -version = "1.0.97" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1414,7 +1272,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1424,21 +1282,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "serde_yaml" -version = "0.8.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", - "yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "siphasher" version = "0.2.3" @@ -1502,25 +1349,13 @@ dependencies = [ [[package]] name = "synstructure" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tempfile" -version = "2.2.0" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1529,7 +1364,7 @@ version = "3.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1549,28 +1384,18 @@ name = "termion" version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "thread-id" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "thread_local" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1578,7 +1403,7 @@ name = "time" version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1627,7 +1452,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1637,8 +1462,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1679,7 +1504,7 @@ dependencies = [ "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1702,7 +1527,7 @@ name = "tokio-trace-core" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1710,14 +1535,9 @@ name = "toml" version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "traitobject" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "try-lock" version = "0.2.2" @@ -1731,14 +1551,6 @@ dependencies = [ "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "typemap" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unsafe-any 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "ucd-util" version = "0.1.3" @@ -1791,14 +1603,6 @@ name = "unicode-xid" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "unsafe-any" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "url" version = "1.7.2" @@ -1838,7 +1642,7 @@ version = "0.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1897,23 +1701,12 @@ dependencies = [ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "yaml-rust" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [metadata] "checksum MacTypes-sys 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7dbbe033994ae2198a18517c7132d952a29fb1db44249a1234779da7c50f4698" "checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c" "checksum aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e6f484ae0c99fec2e858eb6134949117399f222608d84cadb3f58c1f97c2364c" "checksum android_log-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b8052e2d8aabbb8d556d6abbcce2a22b9590996c5f849b9c7ce4544a2e3b984e" "checksum android_logger 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86983875e7c3a202e31471cc6d60fcc18f30e194f1729cfff3bfb43d646ffced" -"checksum antidote 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "34fde25430d87a9388dadbe6e34d7f72a462c8b43ac8d309b42b0a8505d7e2a5" -"checksum arc-swap 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "bc4662175ead9cd84451d5c35070517777949a2ed84551764129cedb88384841" -"checksum argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3f67b0b6a86dae6e67ff4ca2b6201396074996379fba2b92ff649126f37cb392" "checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" @@ -1922,7 +1715,6 @@ dependencies = [ "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" "checksum base64 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7c4a342b450b268e1be8036311e2c613d7f8a7ed31214dff1cc3b60852a3168d" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" -"checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" "checksum build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39092a32794787acd8525ee150305ff051b0aa6cc2abaf193924f5ab05425f39" "checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" "checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" @@ -1930,7 +1722,6 @@ dependencies = [ "checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4" "checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -"checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" "checksum cookie 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "99be24cfcf40d56ed37fd11c2123be833959bbc5bddecb46e1c2e442e15fa3e0" "checksum cookie_store 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b0d2f2ecb21dce00e2453268370312978af9b8024020c7a37ae2cc6dbbe64685" "checksum core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "286e0b41c3a20da26536c6000a280585d519fd07b3956b43aed8a79e9edce980" @@ -1941,13 +1732,12 @@ dependencies = [ "checksum crossbeam-epoch 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "04c9e3102cc2d69cd681412141b390abd55a362afc1540965dad0ad4d34280b4" "checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" "checksum crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f8306fcef4a7b563b76b7dd949ca48f52bc1141aa067d2ea09565f3e2652aa5c" -"checksum dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" "checksum dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ea57b42383d091c85abcc2706240b94ab2a8fa1fc81c10ff23c4de06e2a90b5e" "checksum encoding_rs 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)" = "4155785c79f2f6701f185eb2e6b4caf0555ec03477cb4c70db67b465311620ed" "checksum env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)" = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38" "checksum error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3ab49e9dcb602294bc42f9a7dfc9bc6e936fca4418ea300dbfb84fe16de0b7d9" -"checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" -"checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" +"checksum failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" +"checksum failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" "checksum flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f87e68aa82b2de08a6e037f1385455759df6e445a8df5e005b4297191dbf18aa" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" "checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" @@ -1961,7 +1751,7 @@ dependencies = [ "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "eed324f0f0daf6ec10c474f150505af2c143f251722bf9dbd1261bd1f2ee2c1a" "checksum httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e8734b0cfd3bc3e101ec59100e101c2eecd19282202e87808b3037b442777a83" -"checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" +"checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" "checksum hyper 0.12.28 (registry+https://github.com/rust-lang/crates.io-index)" = "e8e4606fed1c162e3a63d408c07584429f49a4f34c7176cb6cbee60e78f2372c" "checksum hyper-tls 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3a800d6aa50af4b5850b2b0f659625ce9504df908e9733b635720483be26174f" "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" @@ -1970,21 +1760,16 @@ dependencies = [ "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum json 0.11.13 (registry+https://github.com/rust-lang/crates.io-index)" = "9ad0485404155f45cce53a40d4b2d6ac356418300daed05273d9e26f91c390be" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" -"checksum libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "d44e80633f007889c7eff624b709ab43c92d708caad982295768a7b13ca3b5eb" +"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" "checksum libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3ad660d7cb8c5822cd83d10897b0f1f1526792737a179e73896152f85b88c2" -"checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" -"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" -"checksum log-mdc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a94d21414c1f4a51209ad204c1776a3d0765002c76c6abcb602a6f09f1e881c7" -"checksum log-panics 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ae0136257df209261daa18d6c16394757c63e032e27aafd8b07788b051082bef" -"checksum log4rs 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "100052474df98158c0738a7d3f4249c99978490178b5f9f68cd835ac57adbd1b" +"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" "checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" "checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" "checksum mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "3e27ca21f40a310bd06d9031785f4801710d566c184a6e15bad4f1d9b65f9425" "checksum mime_guess 2.0.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)" = "30de2e4613efcba1ec63d8133f344076952090c122992a903359be5a4f99c3ed" -"checksum miniz-sys 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "0300eafb20369952951699b68243ab4334f4b10a88f411c221d444b36c40e649" "checksum miniz_oxide 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c468f2369f07d651a5d0bb2c9079f8488a66d5466efe42d0c5c6466edcb7f71e" "checksum miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7fe927a42e3807ef71defb191dc87d4e24479b221e67015fe38ae2b7b447bab" "checksum mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" @@ -2006,7 +1791,6 @@ dependencies = [ "checksum openssl 0.10.22 (registry+https://github.com/rust-lang/crates.io-index)" = "a51f452b82d622fc8dd973d7266e9055ac64af25b957d9ced3989142dc61cb6b" "checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" "checksum openssl-sys 0.9.46 (registry+https://github.com/rust-lang/crates.io-index)" = "05636e06b4f8762d4b81d24a351f3966f38bd25ccbcfd235606c91fdb82cc60f" -"checksum ordered-float 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "18869315e81473c951eb56ad5558bbc56978562d3ecfb87abb7a1e944cea4518" "checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13" "checksum parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" "checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" @@ -2037,32 +1821,27 @@ dependencies = [ "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)" = "12229c14a0f65c4f1cb046a3b52047cdd9da1f4b30f8a39c5063c8bae515e252" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" -"checksum redox_users 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe5204c3a17e97dde73f285d49be585df59ed84b50a872baf416e73b62c3828" "checksum regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8f0a0bcab2fd7d1d7c54fa9eae6f43eddeb9ce2e7352f8518a814a4f65d60c58" "checksum regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum reqwest 0.9.16 (registry+https://github.com/rust-lang/crates.io-index)" = "ddcfd2c13c6af0f9c45a1086be3b9c68af79e4430b42790759e2d34cce2a6c60" "checksum rmp 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a3d45d7afc9b132b34a2479648863aa95c5c88e98b32285326a6ebadc80ec5c9" "checksum rmp-serde 0.13.7 (registry+https://github.com/rust-lang/crates.io-index)" = "011e1d58446e9fa3af7cdc1fb91295b10621d3ac4cb3a85cc86385ee9ca50cd3" -"checksum rmpv 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "29af0205707de955a396a1d3c657677c65f791ebabb63c0596c0b2fec0bf6325" "checksum rust-base58 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b313b91fcdc6719ad41fa2dad2b7e810b03833fae4bf911950e15529a5f04439" "checksum rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc78bfd5acd7bf3e89cffcf899e5cb1a52d6fafa8dec2739ad70c9577a57288" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" "checksum safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e27a8b19b835f7aea908818e871f5cc3a5a186550c30773be987e155e8163d8f" "checksum schannel 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "f2f6abf258d99c3c1c5c2131d99d064e94b7b3dd5f416483057f308fea253339" -"checksum scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" "checksum security-framework 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "697d3f3c23a618272ead9e1fb259c1411102b31c6af8b93f1d64cca9c3b0e8e0" "checksum security-framework-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "40d95f3d7da09612affe897f320d78264f0d2320f3e8eea27d12bd1bd94445e2" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)" = "d46b3dfedb19360a74316866cef04687cd4d6a70df8e6a506c63512790769b72" -"checksum serde-value 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7a663f873dedc4eac1a559d4c6bc0d0b2c34dc5ac4702e105014b8281489e44f" -"checksum serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)" = "c22a0820adfe2f257b098714323563dd06426502abbbce4f51b72ef544c5027f" +"checksum serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" +"checksum serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" "checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" "checksum serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "642dd69105886af2efd227f75a520ec9b44a820d65bc133a9131f7d229fd165a" -"checksum serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)" = "38b08a9a90e5260fe01c6480ec7c811606df6d3a660415808c3c3fa8ed95b582" "checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c4488ae950c49d403731982257768f48fada354a5203fe81f9bb6f43ca9002be" @@ -2072,12 +1851,10 @@ dependencies = [ "checksum strum_macros 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0054a7df764039a6cd8592b9de84be4bec368ff081d203a7d5371cbfa8e65c81" "checksum syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)" = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe" "checksum syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "dff0acdb207ae2fe6d5976617f887eb1e35a2ba52c13c7234c790960cdad9238" -"checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" -"checksum tempfile 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "11ce2fe9db64b842314052e2421ac61a73ce41b898dc8e3750398b219c5fc1e0" +"checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" "checksum tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b86c784c88d98c801132806dadd3819ed29d8600836c4088e855cdf3e178ed8a" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" "checksum termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dde0593aeb8d47accea5392b39350015b5eccb12c0d98044d856983d89548dea" -"checksum thread-id 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c7fbf4c9d56b320106cd64fd024dadfa0be7cb4706725fc44a7d7ce952d820c1" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" "checksum tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)" = "cec6c34409089be085de9403ba2010b80e36938c9ca992c4f67f407bb13db0b1" @@ -2091,10 +1868,8 @@ dependencies = [ "checksum tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2910970404ba6fa78c5539126a9ae2045d62e3713041e447f695f41405a120c6" "checksum tokio-trace-core 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "350c9edade9830dc185ae48ba45667a445ab59f6167ef6d0254ec9d2430d9dd3" "checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" -"checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" "checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" "checksum try_from 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "283d3b89e1368717881a9d51dad843cc435380d8109c9e47d38780a324698d8b" -"checksum typemap 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "653be63c80a3296da5551e1bfd2cca35227e13cdd08c6668903ae2f4f77aa1f6" "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" "checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" "checksum unicase 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a84e5511b2a947f3ae965dcb29b13b7b1691b6e7332cf5dbc1744138d5acb7f6" @@ -2103,7 +1878,6 @@ dependencies = [ "checksum unicode-segmentation 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" -"checksum unsafe-any 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f30360d7979f5e9c6e6cea48af192ea8fab4afb3cf72597154b8f08935bc9c7f" "checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" "checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737" "checksum uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" @@ -2118,4 +1892,3 @@ dependencies = [ "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" -"checksum yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "65923dd1784f44da1d2c3dbbc5e822045628c590ba72123e1c73d3c230c4434d" diff --git a/vcx/libvcx/Cargo.toml b/vcx/libvcx/Cargo.toml index 88196940b5..859d327f69 100644 --- a/vcx/libvcx/Cargo.toml +++ b/vcx/libvcx/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "libvcx" -version = "0.6.1" +version = "0.6.2" authors = ["Hyperledger Indy Contributors "] publish = false description = "This is the official SDK for Evernym's VCX" @@ -27,34 +27,29 @@ ci = [] [dependencies] env_logger = "0.5.10" log = "0.4" -log4rs = "0.8.0" chrono = "0.4" time = "0.1.36" lazy_static = "1.3" -libc = "=0.2.60" +libc = "=0.2.66" rand = "0.3" serde = "1.0.97" serde_json = "1.0.40" -json = "*" serde_derive = "1.0.97" url = "1.5.1" reqwest = "0.9.5" regex = "1.1.0" rust-base58 = "0.0.4" -rmpv = "0.4.0" -rmp = "0.8" rmp-serde = "0.13.7" base64 = "0.8.0" openssl = "0.10" num-traits = "0.2.0" -indy = { version = "1.14.1", path = "../../wrappers/rust/" } -indy-sys = { version = "1.14.1", path = "../../wrappers/rust/indy-sys/" } -log-panics = "2.0.0" +indy = { version = "1.14.2", path = "../../wrappers/rust/" } +indy-sys = { version = "1.14.2", path = "../../wrappers/rust/indy-sys/" } tokio-threadpool = "0.1.6" futures = "0.1.23" libloading = "0.5.0" uuid = {version = "0.7.1", default-features = false, features = ["v4"]} -failure = "0.1.3" +failure = "0.1.5" strum = "0.16.0" strum_macros = "0.16.0" @@ -68,10 +63,6 @@ toml = "0.4" serde_json = "1.0" serde_derive = "1.0" -[dev-dependencies] -tempfile = "2.2" -dirs = "1.0.4" - [package.metadata.deb] maintainer = "Evernym, Inc." copyright = "2018, Evernym Inc." diff --git a/vcx/libvcx/build_scripts/android/debug-device/debugvcx/src/main.rs b/vcx/libvcx/build_scripts/android/debug-device/debugvcx/src/main.rs index 8cab4daae6..689be57fc9 100644 --- a/vcx/libvcx/build_scripts/android/debug-device/debugvcx/src/main.rs +++ b/vcx/libvcx/build_scripts/android/debug-device/debugvcx/src/main.rs @@ -3,7 +3,7 @@ extern "C" { fn vcx_version() -> *const c_char; fn vcx_agent_provision_async(command_handle : u32, json: *const c_char, - cb: Option) -> u32; + cb: Option) -> u32; } //extern crate libloading as lib; @@ -54,7 +54,7 @@ fn get_version() -> &'static str { } } -extern "C" fn generic_cb(command_handle: u32, err: u32, config: *const c_char) { +extern "C" fn generic_cb(command_handle: CommandHandle, err: u32, config: *const c_char) { if err != 0 {panic!("generic_cb failed")} //check_useful_c_str!(config, ()); println!("successfully called generic_cb: {:?}", config); @@ -72,7 +72,7 @@ fn do_provision() -> u32 { //let vcx_agent_provision_async: lib::Symbol< // unsafe extern fn(command_handle : u32, // json: *const c_char, - // cb: Option) -> u32> + // cb: Option) -> u32> // = libvcxall.get(b"vcx_agent_provision_async")?; let json_string = r#"{"agency_url": "https://cagency.pdev.evernym.com", "agency_did": "dTLdJqRZLwMuWSogcKfBT","wallet_name":"wallet2","wallet_key":"wallet-key","agent_seed":null,"enterprise_seed":null, "agency_verkey": "LsPQTDHi294TexkFmZK9Q9vW4YGtQRuLV8wuyZi94yH"}"#; diff --git a/vcx/libvcx/debian/changelog b/vcx/libvcx/debian/changelog index ffc1b0ac42..da63657bc4 100644 --- a/vcx/libvcx/debian/changelog +++ b/vcx/libvcx/debian/changelog @@ -1,7 +1,12 @@ -libvcx (0.6.1) unstable; urgency=medium +libvcx (0.6.2) unstable; urgency=medium [ Hyperledger ] +## 0.6.2 +* Implemented Basic Message RFC (IS-1189) +* Updated library to support "names" parameter in Proof Request Revealed Attributes (IS-1381) +* others minor bugfixes + ## 0.6.1 * Bugfixes @@ -46,7 +51,7 @@ libvcx (0.6.1) unstable; urgency=medium This removes the dependency on an agency/cloud-agent and allows the user of the SDK to transport those messages themselves. There are two types of functions: * `vcx_*_get_request_msg` - gets a message that can be sent to the specified connection. - * `vcx_*_update_state_with_message` - checks for any state change from the given message and updates the the state attribute. + * `vcx_*_update_state_with_message` - checks for any state change from the given message and updates the state attribute. * Added new *EXPEREMENTAL* functions to get requirements and price for a ledger request. * `vcx_get_request_price` - returns request minimal request price for performing an action in case the requester can do it. * Updated Indy-SDK CI/CD pipelines to test, to build and to publish Android artifacts for Libvcx. diff --git a/vcx/libvcx/include/vcx.h b/vcx/libvcx/include/vcx.h index c0cea9f248..a31a6ff3c7 100644 --- a/vcx/libvcx/include/vcx.h +++ b/vcx/libvcx/include/vcx.h @@ -214,7 +214,7 @@ vcx_error_t vcx_connection_serialize(vcx_command_handle_t command_handle, vcx_connection_handle_t connection_handle, void (*cb)(vcx_command_handle_t, vcx_error_t, const char*)); -// Checks for any state change in the connection and updates the the state attribute +// Checks for any state change in the connection and updates the state attribute // // #Params // command_handle: command handle to map callback to user context. @@ -442,7 +442,7 @@ vcx_error_t vcx_credential_serialize(vcx_command_handle_t command_handle, vcx_credential_handle_t handle, void (*cb)(vcx_command_handle_t, vcx_error_t, const char*)); -// Checks for any state change in the credential and updates the the state attribute. If it detects a credential it +// Checks for any state change in the credential and updates the state attribute. If it detects a credential it // will store the credential in the wallet and update the state. // // #Params @@ -604,7 +604,7 @@ vcx_error_t vcx_credentialdef_serialize(vcx_command_handle_t command_handle, vcx_credential_handle_t credentialdef_handle, void (*cb)(vcx_command_handle_t, vcx_error_t, const char*)); -/// Checks if credential definition is published on the Ledger and updates the the state +/// Checks if credential definition is published on the Ledger and updates the state /// /// #Params /// command_handle: command handle to map callback to user context. @@ -869,7 +869,7 @@ vcx_error_t vcx_disclosed_proof_serialize(vcx_command_handle_t command_handle, vcx_disclosed_proof_handle_t proof_handle, void (*cb)(vcx_command_handle_t, vcx_error_t, const char*)); -// Checks for any state change in the disclosed proof and updates the the state attribute +// Checks for any state change in the disclosed proof and updates the state attribute // // #Params // command_handle: command handle to map callback to user context. @@ -1060,7 +1060,7 @@ vcx_error_t vcx_issuer_credential_serialize(vcx_command_handle_t command_handle, vcx_issuer_credential_handle_t credential_handle, void (*cb)(vcx_command_handle_t, vcx_error_t, const char*)); -// Checks for any state change in the credential and updates the the state attribute +// Checks for any state change in the credential and updates the state attribute // // #Params // command_handle: command handle to map callback to user context. @@ -1435,7 +1435,7 @@ vcx_error_t vcx_schema_serialize(vcx_command_handle_t command_handle, vcx_schema_handle_t schema_handle, void (*cb)(vcx_command_handle_t, vcx_error_t, const char*)); -/// Checks if schema is published on the Ledger and updates the the state +/// Checks if schema is published on the Ledger and updates the state /// /// #Params /// command_handle: command handle to map callback to user context. diff --git a/vcx/libvcx/src/api/connection.rs b/vcx/libvcx/src/api/connection.rs index 083f8b23cd..b75e42e5af 100644 --- a/vcx/libvcx/src/api/connection.rs +++ b/vcx/libvcx/src/api/connection.rs @@ -7,24 +7,147 @@ use connection::{get_source_id, create_connection, create_connection_with_invite use error::prelude::*; use messages::get_message::Message; +use indy_sys::CommandHandle; -/// Delete a Connection object and release its handle +/* + Tha API represents a pairwise connection with another identity owner. + Once the connection, is established communication can happen securely and privately. + Credentials and Presentations are exchanged using this object. + + # States + + The set of object states, messages and transitions depends on the communication method is used. + There are two communication methods: `proprietary` and `aries`. The default communication method is `proprietary`. + The communication method can be specified as a config option on one of *_init functions. + + proprietary: + Inviter: + VcxStateType::VcxStateInitialized - once `vcx_connection_create` (create Connection object) is called. + + VcxStateType::VcxStateOfferSent - once `vcx_connection_connect` (send Connection invite) is called. + + VcxStateType::VcxStateAccepted - once `connReqAnswer` messages is received. + use `vcx_connection_update_state` or `vcx_connection_update_state_with_message` functions for state updates. + VcxStateType::VcxStateNone - once `vcx_connection_delete_connection` (delete Connection object) is called. + + Invitee: + VcxStateType::VcxStateRequestReceived - once `vcx_connection_create_with_invite` (create Connection object with invite) is called. + + VcxStateType::VcxStateAccepted - once `vcx_connection_connect` (accept Connection invite) is called. + + VcxStateType::VcxStateNone - once `vcx_connection_delete_connection` (delete Connection object) is called. + + aries: + Inviter: + VcxStateType::VcxStateInitialized - once `vcx_connection_create` (create Connection object) is called. + + VcxStateType::VcxStateOfferSent - once `vcx_connection_connect` (prepared Connection invite) is called. + + VcxStateType::VcxStateRequestReceived - once `ConnectionRequest` messages is received. + accept `ConnectionRequest` and send `ConnectionResponse` message. + use `vcx_connection_update_state` or `vcx_connection_update_state_with_message` functions for state updates. + + VcxStateType::VcxStateAccepted - once `Ack` messages is received. + use `vcx_connection_update_state` or `vcx_connection_update_state_with_message` functions for state updates. + + VcxStateType::VcxStateNone - once `vcx_connection_delete_connection` (delete Connection object) is called + OR + `ConnectionProblemReport` messages is received on state updates. + + Invitee: + VcxStateType::VcxStateOfferSent - once `vcx_connection_create_with_invite` (create Connection object with invite) is called. + + VcxStateType::VcxStateRequestReceived - once `vcx_connection_connect` (accept `ConnectionInvite` and send `ConnectionRequest` message) is called. + + VcxStateType::VcxStateAccepted - once `ConnectionResponse` messages is received. + send `Ack` message if requested. + use `vcx_connection_update_state` or `vcx_connection_update_state_with_message` functions for state updates. + + VcxStateType::VcxStateNone - once `vcx_connection_delete_connection` (delete Connection object) is called + OR + `ConnectionProblemReport` messages is received on state updates. + + # Transitions + + proprietary: + Inviter: + VcxStateType::None - `vcx_connection_create` - VcxStateType::VcxStateInitialized + VcxStateType::VcxStateInitialized - `vcx_connection_connect` - VcxStateType::VcxStateOfferSent + VcxStateType::VcxStateOfferSent - received `connReqAnswer` - VcxStateType::VcxStateAccepted + any state - `vcx_connection_delete_connection` - `VcxStateType::VcxStateNone` + + Invitee: + VcxStateType::None - `vcx_connection_create_with_invite` - VcxStateType::VcxStateRequestReceived + VcxStateType::VcxStateRequestReceived - `vcx_connection_connect` - VcxStateType::VcxStateAccepted + any state - `vcx_connection_delete_connection` - `VcxStateType::VcxStateNone` + + aries - RFC: https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential + Inviter: + VcxStateType::None - `vcx_connection_create` - VcxStateType::VcxStateInitialized + + VcxStateType::VcxStateInitialized - `vcx_connection_connect` - VcxStateType::VcxStateOfferSent + + VcxStateType::VcxStateOfferSent - received `ConnectionRequest` - VcxStateType::VcxStateRequestReceived + VcxStateType::VcxStateOfferSent - received `ConnectionProblemReport` - VcxStateType::VcxStateNone + + VcxStateType::VcxStateRequestReceived - received `Ack` - VcxStateType::VcxStateAccepted + VcxStateType::VcxStateRequestReceived - received `ConnectionProblemReport` - VcxStateType::VcxStateNone + + VcxStateType::VcxStateAccepted - received `Ping`, `PingResponse`, `Query`, `Disclose` - VcxStateType::VcxStateAccepted + + any state - `vcx_connection_delete_connection` - VcxStateType::VcxStateNone + + + Invitee: + VcxStateType::None - `vcx_connection_create_with_invite` - VcxStateType::VcxStateOfferSent + + VcxStateType::VcxStateOfferSent - `vcx_connection_connect` - VcxStateType::VcxStateRequestReceived + VcxStateType::VcxStateOfferSent - received `ConnectionProblemReport` - VcxStateType::VcxStateNone + + VcxStateType::VcxStateRequestReceived - received `ConnectionResponse` - VcxStateType::VcxStateAccepted + VcxStateType::VcxStateRequestReceived - received `ConnectionProblemReport` - VcxStateType::VcxStateNone + + VcxStateType::VcxStateAccepted - received `Ping`, `PingResponse`, `Query`, `Disclose` - VcxStateType::VcxStateAccepted + + any state - `vcx_connection_delete_connection` - VcxStateType::VcxStateNone + + # Messages + + proprietary: + ConnectionRequest (`connReq`) + ConnectionRequestAnswer (`connReqAnswer`) + + aries: + Invitation - https://github.com/hyperledger/aries-rfcs/tree/master/features/0160-connection-protocol#0-invitation-to-connect + ConnectionRequest - https://github.com/hyperledger/aries-rfcs/tree/master/features/0160-connection-protocol#1-connection-request + ConnectionResponse - https://github.com/hyperledger/aries-rfcs/tree/master/features/0160-connection-protocol#2-connection-response + ConnectionProblemReport - https://github.com/hyperledger/aries-rfcs/tree/master/features/0160-connection-protocol#error-message-example + Ack - https://github.com/hyperledger/aries-rfcs/tree/master/features/0015-acks#explicit-acks + Ping - https://github.com/hyperledger/aries-rfcs/tree/master/features/0048-trust-ping#messages + PingResponse - https://github.com/hyperledger/aries-rfcs/tree/master/features/0048-trust-ping#messages + Query - https://github.com/hyperledger/aries-rfcs/tree/master/features/0031-discover-features#query-message-type + Disclose - https://github.com/hyperledger/aries-rfcs/tree/master/features/0031-discover-features#disclose-message-type +*/ + +/// Delete a Connection object from the agency and release its handle. /// -/// #Params +/// NOTE: This eliminates the connection and any ability to use it for any communication. +/// +/// # Params /// command_handle: command handle to map callback to user context. /// /// connection_handle: handle of the connection to delete. /// /// cb: Callback that provides feedback of the api call. /// -/// #Returns +/// # Returns /// Error code as a u32 #[no_mangle] #[allow(unused_assignments)] -pub extern fn vcx_connection_delete_connection(command_handle: u32, +pub extern fn vcx_connection_delete_connection(command_handle: CommandHandle, connection_handle: u32, cb: Option) -> u32 { info!("vcx_delete_connection >>>"); @@ -52,22 +175,22 @@ pub extern fn vcx_connection_delete_connection(command_handle: u32, error::SUCCESS.code_num } -/// -> Create a Connection object that provides a pairwise connection for an institution's user +/// Create a Connection object that provides a pairwise connection for an institution's user /// -/// #Params +/// # Params /// command_handle: command handle to map callback to user context. /// -/// source_id: institution's personal identification for the user +/// source_id: institution's personal identification for the connection /// /// cb: Callback that provides connection handle and error status of request /// -/// #Returns +/// # Returns /// Error code as a u32 #[no_mangle] #[allow(unused_assignments)] -pub extern fn vcx_connection_create(command_handle: u32, +pub extern fn vcx_connection_create(command_handle: CommandHandle, source_id: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_connection_create >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -97,22 +220,35 @@ pub extern fn vcx_connection_create(command_handle: u32, /// Create a Connection object from the given invite_details that provides a pairwise connection. /// -/// #Params +/// # Params /// command_handle: command handle to map callback to user context. /// -/// source_id: institution's personal identification for the user +/// source_id: institution's personal identification for the connection /// -/// invite_details: Provided via the other end of the connection calling "vcx_connection_connect" or "vcx_connection_invite_details" +/// invite_details: A string representing a json object which is provided by an entity that wishes to make a connection. /// /// cb: Callback that provides connection handle and error status of request /// -/// #Returns +/// # Examples +/// invite_details -> depends on communication method: +/// proprietary: +/// {"targetName": "", "statusMsg": "message created", "connReqId": "mugIkrWeMr", "statusCode": "MS-101", "threadId": null, "senderAgencyDetail": {"endpoint": "http://localhost:8080", "verKey": "key", "DID": "did"}, "senderDetail": {"agentKeyDlgProof": {"agentDID": "8f6gqnT13GGMNPWDa2TRQ7", "agentDelegatedKey": "5B3pGBYjDeZYSNk9CXvgoeAAACe2BeujaAkipEC7Yyd1", "signature": "TgGSvZ6+/SynT3VxAZDOMWNbHpdsSl8zlOfPlcfm87CjPTmC/7Cyteep7U3m9Gw6ilu8SOOW59YR1rft+D8ZDg=="}, "publicDID": "7YLxxEfHRiZkCMVNii1RCy", "name": "Faber", "logoUrl": "http://robohash.org/234", "verKey": "CoYZMV6GrWqoG9ybfH3npwH3FnWPcHmpWYUF8n172FUx", "DID": "Ney2FxHT4rdEyy6EDCCtxZ"}} +/// aries: https://github.com/hyperledger/aries-rfcs/tree/master/features/0160-connection-protocol#0-invitation-to-connect +/// { +/// "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/1.0/invitation", +/// "label": "Alice", +/// "recipientKeys": ["8HH5gYEeNc3z7PYXmd54d4x6qAfCNrqQqEB3nS7Zfu7K"], +/// "serviceEndpoint": "https://example.com/endpoint", +/// "routingKeys": ["8HH5gYEeNc3z7PYXmd54d4x6qAfCNrqQqEB3nS7Zfu7K"] +/// } +/// +/// # Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_connection_create_with_invite(command_handle: u32, +pub extern fn vcx_connection_create_with_invite(command_handle: CommandHandle, source_id: *const c_char, invite_details: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_connection_create_with_invite >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -141,24 +277,27 @@ pub extern fn vcx_connection_create_with_invite(command_handle: u32, /// Establishes connection between institution and its user /// -/// #Params +/// # Params /// command_handle: command handle to map callback to user context. /// /// connection_handle: Connection handle that identifies connection object /// /// connection_options: Provides details indicating if the connection will be established by text or QR Code /// -/// # Examples connection_options -> "{"connection_type":"SMS","phone":"123","use_public_did":true}" OR: "{"connection_type":"QR","phone":"","use_public_did":false}" +/// # Examples connection_options -> +/// "{"connection_type":"SMS","phone":"123","use_public_did":true}" +/// OR: +/// "{"connection_type":"QR","phone":"","use_public_did":false}" /// /// cb: Callback that provides error status of request /// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_connection_connect(command_handle: u32, +pub extern fn vcx_connection_connect(command_handle: CommandHandle, connection_handle: u32, connection_options: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_connection_connect >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -189,7 +328,7 @@ pub extern fn vcx_connection_connect(command_handle: u32, let msg = CStringUtils::string_to_cstring(x); cb(command_handle, error::SUCCESS.code_num, msg.as_ptr()); } - Err(e) => { + Err(_) => { warn!("vcx_connection_connect_cb(command_handle: {}, connection_handle: {}, rc: {}, details: {}), source_id: {:?}", command_handle, connection_handle, error::SUCCESS.message, "null", source_id); // TODO: why Success????? cb(command_handle, error::SUCCESS.code_num, ptr::null_mut()); @@ -211,7 +350,7 @@ pub extern fn vcx_connection_connect(command_handle: u32, /// Takes the Connection object and returns a json string of all its attributes /// -/// #Params +/// # Params /// command_handle: command handle to map callback to user context. /// /// connection_handle: Connection handle that identifies pairwise connection @@ -221,9 +360,9 @@ pub extern fn vcx_connection_connect(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_connection_serialize(command_handle: u32, +pub extern fn vcx_connection_serialize(command_handle: CommandHandle, connection_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_connection_serialize >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -263,16 +402,16 @@ pub extern fn vcx_connection_serialize(command_handle: u32, /// #Params /// command_handle: command handle to map callback to user context. /// -/// connection_data: json string representing a connection object +/// connection_data: json string representing a connection object. Is an output of `vcx_connection_serialize` function. /// /// cb: Callback that provides credential handle and provides error status /// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_connection_deserialize(command_handle: u32, +pub extern fn vcx_connection_deserialize(command_handle: CommandHandle, connection_data: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_connection_deserialize >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -303,8 +442,8 @@ pub extern fn vcx_connection_deserialize(command_handle: u32, error::SUCCESS.code_num } - -/// Checks for any state change in the connection and updates the the state attribute +/// Query the agency for the received messages. +/// Checks for any messages changing state in the connection and updates the state attribute. /// /// #Params /// command_handle: command handle to map callback to user context. @@ -312,13 +451,18 @@ pub extern fn vcx_connection_deserialize(command_handle: u32, /// connection_handle: was provided during creation. Used to identify connection object /// /// cb: Callback that provides most current state of the credential and error status of request +/// Connection states: +/// 1 - Initialized +/// 2 - Request Sent +/// 3 - Offer Received +/// 4 - Accepted /// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_connection_update_state(command_handle: u32, +pub extern fn vcx_connection_update_state(command_handle: CommandHandle, connection_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_connection_update_state >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -354,24 +498,24 @@ pub extern fn vcx_connection_update_state(command_handle: u32, error::SUCCESS.code_num } -/// Checks the message any state change and updates the the state attribute +/// Update the state of the connection based on the given message. /// /// #Params /// command_handle: command handle to map callback to user context. /// /// connection_handle: was provided during creation. Used to identify connection object /// -/// message: message to process +/// message: message to process. /// -/// cb: Callback that provides most current state of the credential and error status of request +/// cb: Callback that provides most current state of the connection and error status of request /// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_connection_update_state_with_message(command_handle: u32, +pub extern fn vcx_connection_update_state_with_message(command_handle: CommandHandle, connection_handle: u32, message: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_connection_update_state_with_message >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -413,20 +557,25 @@ pub extern fn vcx_connection_update_state_with_message(command_handle: u32, error::SUCCESS.code_num } -/// Get the current state of the connection object +/// Returns the current internal state of the connection. Does NOT query agency for state updates. +/// Possible states: +/// 1 - Initialized +/// 2 - Offer Sent +/// 3 - Request Received +/// 4 - Accepted /// /// #Params /// command_handle: command handle to map callback to user context. /// -/// proof_handle: Connection handle that was provided during creation. Used to access connection object +/// connection_handle: Connection handle that was provided during creation. Used to access connection object /// /// cb: Callback that provides most current state of the connection and error status of request /// /// #Returns #[no_mangle] -pub extern fn vcx_connection_get_state(command_handle: u32, +pub extern fn vcx_connection_get_state(command_handle: CommandHandle, connection_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_connection_get_state >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -451,24 +600,40 @@ pub extern fn vcx_connection_get_state(command_handle: u32, error::SUCCESS.code_num } -/// Gets the current connection details +/// Get the invite details that were sent or can be sent to the remote side. /// /// #Params /// command_handle: command handle to map callback to user context. /// /// connection_handle: was provided during creation. Used to identify connection object /// -/// abbreviated: abbreviated connection details for QR codes or not +/// abbreviated: abbreviated connection details for QR codes or not (applicable for `proprietary` communication method only) /// /// cb: Callback that provides the json string of details /// +/// # Example +/// details -> depends on communication method: +/// proprietary: +/// {"targetName": "", "statusMsg": "message created", "connReqId": "mugIkrWeMr", "statusCode": "MS-101", "threadId": null, "senderAgencyDetail": {"endpoint": "http://localhost:8080", "verKey": "key", "DID": "did"}, "senderDetail": {"agentKeyDlgProof": {"agentDID": "8f6gqnT13GGMNPWDa2TRQ7", "agentDelegatedKey": "5B3pGBYjDeZYSNk9CXvgoeAAACe2BeujaAkipEC7Yyd1", "signature": "TgGSvZ6+/SynT3VxAZDOMWNbHpdsSl8zlOfPlcfm87CjPTmC/7Cyteep7U3m9Gw6ilu8SOOW59YR1rft+D8ZDg=="}, "publicDID": "7YLxxEfHRiZkCMVNii1RCy", "name": "Faber", "logoUrl": "http://robohash.org/234", "verKey": "CoYZMV6GrWqoG9ybfH3npwH3FnWPcHmpWYUF8n172FUx", "DID": "Ney2FxHT4rdEyy6EDCCtxZ"}} +/// aries: +/// { +/// "label": "Alice", +/// "serviceEndpoint": "https://example.com/endpoint", +/// "recipientKeys": ["8HH5gYEeNc3z7PYXmd54d4x6qAfCNrqQqEB3nS7Zfu7K"], +/// "routingKeys": ["8HH5gYEeNc3z7PYXmd54d4x6qAfCNrqQqEB3nS7Zfu7K"], +/// "protocols": [ +/// {"pid": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/1.0", "roles": "Invitee"}, +/// ... +/// ] - optional array. The set of protocol supported by remote side. Is filled after DiscoveryFeatures process was completed. +///// } +/// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_connection_invite_details(command_handle: u32, +pub extern fn vcx_connection_invite_details(command_handle: CommandHandle, connection_handle: u32, abbreviated: bool, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_connection_invite_details >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -509,27 +674,54 @@ pub extern fn vcx_connection_invite_details(command_handle: u32, /// /// command_handle: command handle to map callback to user context. /// -/// connection_handle: connection to receive the message +/// connection_handle: connection to use to send the message. +/// Was provided during creation. Used to identify connection object. +/// Note that connection must be in Accepted state. /// /// msg: actual message to send /// -/// send_msg_options: +/// send_msg_options: (applicable for `proprietary` communication method only) /// { -/// msg_type: String, // type of message to send +/// msg_type: String, // type of message to send. can be any string. /// msg_title: String, // message title (user notification) /// ref_msg_id: Option, // If responding to a message, id of the message /// } /// -/// cb: Callback that provides array of matching messages retrieved +/// # Example: +/// msg -> +/// "HI" +/// OR +/// {"key": "value"} +/// OR +/// { +/// "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/trust_ping/1.0/ping", +/// "@id": "518be002-de8e-456e-b3d5-8fe472477a86", +/// "comment": "Hi. Are you listening?", +/// "response_requested": true +/// } +/// +/// send_msg_options -> +/// { +/// "msg_type":"Greeting", +/// "msg_title": "Hi There" +/// } +/// OR +/// { +/// "msg_type":"Greeting", +/// "msg_title": "Hi There", +/// "ref_msg_id" "as2d343sag" +/// } +/// +/// cb: Callback that provides id of retrieved response message /// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_connection_send_message(command_handle: u32, +pub extern fn vcx_connection_send_message(command_handle: CommandHandle, connection_handle: u32, msg: *const c_char, send_msg_options: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_message_send >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -571,7 +763,9 @@ pub extern fn vcx_connection_send_message(command_handle: u32, /// /// command_handle: command handle to map callback to user context. /// -/// connection_handle: connection to send message +/// connection_handle: connection to use to send ping message. +/// Was provided during creation. Used to identify connection object. +/// Note that connection must be in Accepted state. /// /// comment: (Optional) human-friendly description of the ping. /// @@ -613,28 +807,33 @@ pub extern fn vcx_connection_send_ping(command_handle: u32, error::SUCCESS.code_num } -/// Generate a signature for the specified data +/// Generate a signature for the specified data using connection pairwise keys /// /// #params /// /// command_handle: command handle to map callback to user context. /// -/// connection_handle: connection to receive the message +/// connection_handle: connection to use to sign the message. +/// Was provided during creation. Used to identify connection object. /// /// data_raw: raw data buffer for signature /// -/// data:len: length of data buffer +/// data_len: length of data buffer /// /// cb: Callback that provides the generated signature /// +/// # Example +/// data_raw -> [1, 2, 3, 4, 5, 6] +/// data_len -> 6 +/// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_connection_sign_data(command_handle: u32, +pub extern fn vcx_connection_sign_data(command_handle: CommandHandle, connection_handle: u32, data_raw: *const u8, data_len: u32, - cb: Option) -> u32 { @@ -680,13 +879,14 @@ pub extern fn vcx_connection_sign_data(command_handle: u32, error::SUCCESS.code_num } -/// Verify the signature is valid for the specified data +/// Verify the signature is valid for the specified data using connection pairwise keys /// /// #params /// /// command_handle: command handle to map callback to user context. /// -/// connection_handle: connection to receive the message +/// connection_handle: connection to use to verify signature. +/// Was provided during creation. Used to identify connection object. /// /// data_raw: raw data buffer for signature /// @@ -698,16 +898,22 @@ pub extern fn vcx_connection_sign_data(command_handle: u32, /// /// cb: Callback that specifies whether the signature was valid or not /// +/// # Example +/// data_raw -> [1, 2, 3, 4, 5, 6] +/// data_len -> 6 +/// signature_raw -> [2, 3, 4, 5, 6, 7] +/// signature_len -> 6 +/// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_connection_verify_signature(command_handle: u32, +pub extern fn vcx_connection_verify_signature(command_handle: CommandHandle, connection_handle: u32, data_raw: *const u8, data_len: u32, signature_raw: *const u8, signature_len: u32, - cb: Option) -> u32 { trace!("vcx_connection_verify_signature: >>> connection_handle: {}, data_raw: {:?}, data_len: {}, signature_raw: {:?}, signature_len: {}", @@ -765,7 +971,7 @@ pub extern fn vcx_connection_release(connection_handle: u32) -> u32 { let source_id = get_source_id(connection_handle).unwrap_or_default(); match release(connection_handle) { - Ok(_) => { + Ok(()) => { trace!("vcx_connection_release(connection_handle: {}, rc: {}), source_id: {:?}", connection_handle, error::SUCCESS.message, source_id); error::SUCCESS.code_num @@ -787,7 +993,9 @@ pub extern fn vcx_connection_release(connection_handle: u32) -> u32 { /// /// command_handle: command handle to map callback to user context. /// -/// connection_handle: connection to send message +/// connection_handle: connection to use to send message. +/// Was provided during creation. Used to identify connection object. +/// Note that connection must be in Accepted state. /// /// query: (Optional) query string to match against supported message types. /// @@ -795,6 +1003,11 @@ pub extern fn vcx_connection_release(connection_handle: u32) -> u32 { /// /// cb: Callback that provides success or failure of request /// +/// # Example +/// query -> `did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/` +/// +/// comment -> `share please` +/// /// #Returns /// Error code as a u32 #[no_mangle] @@ -968,7 +1181,7 @@ mod tests { let cb = return_types_u32::Return_U32_U32::new().unwrap(); connect(handle, None).unwrap(); httpclient::set_next_u8_response(GET_MESSAGES_RESPONSE.to_vec()); - let rc = vcx_connection_update_state(cb.command_handle, handle, Some(cb.get_callback())); + let _rc = vcx_connection_update_state(cb.command_handle, handle, Some(cb.get_callback())); assert_eq!(cb.receive(Some(Duration::from_secs(10))).unwrap(), VcxStateType::VcxStateAccepted as u32); let cb = return_types_u32::Return_U32_U32::new().unwrap(); let rc = vcx_connection_get_state(cb.command_handle, handle, Some(cb.get_callback())); @@ -999,7 +1212,7 @@ mod tests { cb.receive(Some(Duration::from_secs(10))).unwrap(); } - extern "C" fn test_sign_cb(command_handle: u32, error: u32, signature: *const u8, signature_length: u32) { + extern "C" fn test_sign_cb(_command_handle: CommandHandle, error: u32, _signature: *const u8, _signature_length: u32) { assert_eq!(error, error::SUCCESS.code_num); } @@ -1017,7 +1230,7 @@ mod tests { thread::sleep(Duration::from_secs(2)); } - extern "C" fn test_verify_cb(command_handle: u32, error: u32, valid: bool) { + extern "C" fn test_verify_cb(_command_handle: CommandHandle, _error: u32, valid: bool) { assert_eq!(valid, true); } diff --git a/vcx/libvcx/src/api/credential.rs b/vcx/libvcx/src/api/credential.rs index fdba286871..06ddc38766 100644 --- a/vcx/libvcx/src/api/credential.rs +++ b/vcx/libvcx/src/api/credential.rs @@ -7,8 +7,72 @@ use credential; use std::ptr; use utils::threadpool::spawn; use error::prelude::*; +use indy_sys::CommandHandle; -/// Retrieves Payment Info from a Credential +/* + The API represents a Holder side in credential issuance process. + Assumes that pairwise connection between Issuer and Holder is already established. + + # State + + The set of object states, messages and transitions depends on the communication method is used. + There are two communication methods: `proprietary` and `aries`. The default communication method is `proprietary`. + The communication method can be specified as a config option on one of *_init functions. + + proprietary: + VcxStateType::VcxStateRequestReceived - once `vcx_credential_create_with_offer` (create Credential object) is called. + + VcxStateType::VcxStateOfferSent - once `vcx_credential_send_request` (send `CRED_REQ` message) is called. + + VcxStateType::VcxStateAccepted - once `CRED` messages is received. + use `vcx_credential_update_state` or `vcx_credential_update_state_with_message` functions for state updates. + + aries: + VcxStateType::VcxStateRequestReceived - once `vcx_credential_create_with_offer` (create Credential object) is called. + + VcxStateType::VcxStateOfferSent - once `vcx_credential_send_request` (send `CredentialRequest` message) is called. + + VcxStateType::VcxStateAccepted - once `Credential` messages is received. + VcxStateType::None - once `ProblemReport` messages is received. + use `vcx_credential_update_state` or `vcx_credential_update_state_with_message` functions for state updates. + + # Transitions + + proprietary: + VcxStateType::None - `vcx_credential_create_with_offer` - VcxStateType::VcxStateRequestReceived + + VcxStateType::VcxStateRequestReceived - `vcx_credential_send_request` - VcxStateType::VcxStateOfferSent + + VcxStateType::VcxStateOfferSent - received `CRED` - VcxStateType::VcxStateAccepted + + aries: RFC - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential + VcxStateType::None - `vcx_credential_create_with_offer` - VcxStateType::VcxStateRequestReceived + + VcxStateType::VcxStateRequestReceived - `vcx_issuer_send_credential_offer` - VcxStateType::VcxStateOfferSent + + VcxStateType::VcxStateOfferSent - received `Credential` - VcxStateType::VcxStateAccepted + VcxStateType::VcxStateOfferSent - received `ProblemReport` - VcxStateType::None + + # Messages + + proprietary: + CredentialOffer (`CRED_OFFER`) + CredentialRequest (`CRED_REQ`) + Credential (`CRED`) + + aries: + CredentialProposal - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential#propose-credential + CredentialOffer - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential#offer-credential + CredentialRequest - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential#request-credential + Credential - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential#issue-credential + ProblemReport - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0035-report-problem#the-problem-report-message-type + Ack - https://github.com/hyperledger/aries-rfcs/tree/master/features/0015-acks#explicit-acks +*/ + +/// Retrieve Payment Transaction Information for this Credential. Typically this will include +/// how much payment is requried by the issuer, which needs to be provided by the prover, before the issuer will +/// issue the credential to the prover. Ideally a prover would want to know how much payment is being asked before +/// submitting the credential request (which triggers the payment to be made). /// /// #Params /// command_handle: command handle to map callback to user context. @@ -17,13 +81,21 @@ use error::prelude::*; /// /// cb: Callback that provides Payment Info of a Credential /// +/// # Example: +/// payment_info -> +/// { +/// "payment_required":"one-time", +/// "payment_addr":"pov:null:OsdjtGKavZDBuG2xFw2QunVwwGs5IB3j", +/// "price":1 +/// } +/// /// #Returns /// Error code as a u32 #[no_mangle] #[allow(unused_variables, unused_mut)] -pub extern fn vcx_credential_get_payment_info(command_handle: u32, +pub extern fn vcx_credential_get_payment_info(command_handle: CommandHandle, credential_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_credential_get_payment_info >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -66,7 +138,12 @@ pub extern fn vcx_credential_get_payment_info(command_handle: u32, /// /// offer: credential offer received via "vcx_credential_get_offers" /// -/// # Example offer -> "[{"msg_type": "CREDENTIAL_OFFER","version": "0.1","to_did": "...","from_did":"...","credential": {"account_num": ["...."],"name_on_account": ["Alice"]},"schema_seq_no": 48,"issuer_did": "...","credential_name": "Account Certificate","credential_id": "3675417066","msg_ref_id": "ymy5nth"}] +/// # Example +/// offer -> depends on communication method: +/// proprietary: +/// [{"msg_type": "CREDENTIAL_OFFER","version": "0.1","to_did": "...","from_did":"...","credential": {"account_num": ["...."],"name_on_account": ["Alice"]},"schema_seq_no": 48,"issuer_did": "...","credential_name": "Account Certificate","credential_id": "3675417066","msg_ref_id": "ymy5nth"}] +/// aries: +/// {"@type":"did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/issue-credential/1.0/offer-credential", "@id":"", "comment":"somecomment", "credential_preview":, "offers~attach":[{"@id":"libindy-cred-offer-0", "mime-type":"application/json", "data":{"base64":""}}]} /// /// cb: Callback that provides credential handle or error status /// @@ -74,10 +151,10 @@ pub extern fn vcx_credential_get_payment_info(command_handle: u32, /// Error code as a u32 #[no_mangle] #[allow(unused_variables, unused_mut)] -pub extern fn vcx_credential_create_with_offer(command_handle: u32, +pub extern fn vcx_credential_create_with_offer(command_handle: CommandHandle, source_id: *const c_char, offer: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_credential_create_with_offer >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -117,13 +194,20 @@ pub extern fn vcx_credential_create_with_offer(command_handle: u32, /// /// cb: Callback that provides error status of api call, or returns the credential in json format of "{uuid:credential}". /// +/// # Example +/// credential -> depends on communication method: +/// proprietary: +/// {"credential_id":"cred_id", "credential": {"libindy_cred":"{....}","rev_reg_def_json":"","cred_def_id":"cred_def_id","msg_type":"CLAIM","claim_offer_id":"1234","version":"0.1","from_did":"did"}} +/// aries: +/// https://github.com/hyperledger/aries-rfcs/tree/master/features/0036-issue-credential#issue-credential +/// /// #Returns /// Error code as a u32 #[no_mangle] #[allow(unused_variables, unused_mut)] -pub extern fn vcx_get_credential(command_handle: u32, +pub extern fn vcx_get_credential(command_handle: CommandHandle, credential_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_get_credential >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -156,7 +240,7 @@ pub extern fn vcx_get_credential(command_handle: u32, error::SUCCESS.code_num } -/// Create a Credential object that requests and receives a credential for an institution +/// Create a Credential object based off of a known message id for a given connection. /// /// #Params /// command_handle: command handle to map callback to user context. @@ -173,11 +257,11 @@ pub extern fn vcx_get_credential(command_handle: u32, /// Error code as a u32 #[no_mangle] #[allow(unused_variables, unused_mut)] -pub extern fn vcx_credential_create_with_msgid(command_handle: u32, +pub extern fn vcx_credential_create_with_msgid(command_handle: CommandHandle, source_id: *const c_char, connection_handle: u32, msg_id: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_credential_create_with_msgid >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -217,7 +301,7 @@ pub extern fn vcx_credential_create_with_msgid(command_handle: u32, error::SUCCESS.code_num } -/// Send a credential request to the connection, called after having received a credential offer +/// Approves the credential offer and submits a credential request. The result will be a credential stored in the prover's wallet. /// /// #params /// command_handle: command handle to map callback to user context @@ -231,11 +315,11 @@ pub extern fn vcx_credential_create_with_msgid(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_credential_send_request(command_handle: u32, +pub extern fn vcx_credential_send_request(command_handle: CommandHandle, credential_handle: u32, connection_handle: u32, - payment_handle: u32, - cb: Option) -> u32 { + _payment_handle: u32, + cb: Option) -> u32 { info!("vcx_credential_send_request >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -272,7 +356,7 @@ pub extern fn vcx_credential_send_request(command_handle: u32, error::SUCCESS.code_num } -/// Get the credential request message that can be sent to the specified connection +/// Approves the credential offer and gets the credential request message that can be sent to the specified connection /// /// #params /// command_handle: command handle to map callback to user context @@ -286,11 +370,11 @@ pub extern fn vcx_credential_send_request(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_credential_get_request_msg(command_handle: u32, +pub extern fn vcx_credential_get_request_msg(command_handle: CommandHandle, credential_handle: u32, connection_handle: u32, - payment_handle: u32, - cb: Option) -> u32 { + _payment_handle: u32, + cb: Option) -> u32 { info!("vcx_credential_get_request_msg >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -337,12 +421,14 @@ pub extern fn vcx_credential_get_request_msg(command_handle: u32, /// /// cb: Callback that provides any credential offers and error status of query /// +/// # Example offers -> "[[{"msg_type": "CREDENTIAL_OFFER","version": "0.1","to_did": "...","from_did":"...","credential": {"account_num": ["...."],"name_on_account": ["Alice"]},"schema_seq_no": 48,"issuer_did": "...","credential_name": "Account Certificate","credential_id": "3675417066","msg_ref_id": "ymy5nth"}]]" +/// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_credential_get_offers(command_handle: u32, +pub extern fn vcx_credential_get_offers(command_handle: CommandHandle, connection_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_credential_get_offers >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -375,8 +461,9 @@ pub extern fn vcx_credential_get_offers(command_handle: u32, error::SUCCESS.code_num } -/// Checks for any state change in the credential and updates the the state attribute. If it detects a credential it -/// will store the credential in the wallet and update the state. +/// Query the agency for the received messages. +/// Checks for any messages changing state in the credential object and updates the state attribute. +/// If it detects a credential it will store the credential in the wallet. /// /// #Params /// command_handle: command handle to map callback to user context. @@ -388,9 +475,9 @@ pub extern fn vcx_credential_get_offers(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_credential_update_state(command_handle: u32, +pub extern fn vcx_credential_update_state(command_handle: CommandHandle, credential_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_credential_update_state >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -413,7 +500,7 @@ pub extern fn vcx_credential_update_state(command_handle: u32, } } - let state = match credential::get_state(credential_handle) { + match credential::get_state(credential_handle) { Ok(s) => { trace!("vcx_credential_update_state_cb(command_handle: {}, rc: {}, state: {}), source_id: {:?}", command_handle, error::SUCCESS.message, s, source_id); @@ -432,25 +519,24 @@ pub extern fn vcx_credential_update_state(command_handle: u32, error::SUCCESS.code_num } -/// Checks for any state change from the given message and updates the the state attribute. If it detects a credential it -/// will store the credential in the wallet and update the state. +/// Update the state of the credential based on the given message. /// /// #Params /// command_handle: command handle to map callback to user context. /// /// credential_handle: Credential handle that was provided during creation. Used to identify credential object /// -/// message: string containing updated status +/// message: message to process for state changes /// /// cb: Callback that provides most current state of the credential and error status of request /// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_credential_update_state_with_message(command_handle: u32, +pub extern fn vcx_credential_update_state_with_message(command_handle: CommandHandle, credential_handle: u32, message: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_credential_update_state_with_message >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -474,7 +560,7 @@ pub extern fn vcx_credential_update_state_with_message(command_handle: u32, } } - let state = match credential::get_state(credential_handle) { + match credential::get_state(credential_handle) { Ok(s) => { trace!("vcx_credential_update_state_with_message_cb(command_handle: {}, rc: {}, state: {}), source_id: {:?}", command_handle, error::SUCCESS.message, s, source_id); @@ -501,12 +587,16 @@ pub extern fn vcx_credential_update_state_with_message(command_handle: u32, /// proof_handle: Credential handle that was provided during creation. /// /// cb: Callback that provides most current state of the credential and error status of request +/// Credential statuses: +/// 2 - Request Sent +/// 3 - Request Received +/// 4 - Accepted /// /// #Returns #[no_mangle] -pub extern fn vcx_credential_get_state(command_handle: u32, +pub extern fn vcx_credential_get_state(command_handle: CommandHandle, handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_credential_get_state >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -552,9 +642,9 @@ pub extern fn vcx_credential_get_state(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_credential_serialize(command_handle: u32, +pub extern fn vcx_credential_serialize(command_handle: CommandHandle, handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_credential_serialize >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -601,9 +691,9 @@ pub extern fn vcx_credential_serialize(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_credential_deserialize(command_handle: u32, +pub extern fn vcx_credential_deserialize(command_handle: CommandHandle, credential_data: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_credential_deserialize >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -646,7 +736,7 @@ pub extern fn vcx_credential_release(handle: u32) -> u32 { let source_id = credential::get_source_id(handle).unwrap_or_default(); match credential::release(handle) { - Ok(_) => { + Ok(()) => { trace!("vcx_credential_release(handle: {}, rc: {}), source_id: {:?}", handle, error::SUCCESS.message, source_id); error::SUCCESS.code_num @@ -660,7 +750,9 @@ pub extern fn vcx_credential_release(handle: u32) -> u32 { } } -/// Retrieve the txn associated with paying for the credential +/// Retrieve the payment transaction associated with this credential. This can be used to get the txn that +/// was used to pay the issuer from the prover. This could be considered a receipt of payment from the payer to +/// the issuer. /// /// #param /// handle: credential handle that was provided during creation. Used to access credential object. @@ -670,18 +762,16 @@ pub extern fn vcx_credential_release(handle: u32) -> u32 { /// example: { /// "amount":25, /// "inputs":[ -/// "pay:null:1_3FvPC7dzFbQKzfG", -/// "pay:null:1_lWVGKc07Pyc40m6" +/// "pay:null:1_3FvPC7dzFbQKzfG" /// ], /// "outputs":[ -/// {"recipient":"pay:null:FrSVC3IrirScyRh","amount":5,"extra":null}, -/// {"recipient":"pov:null:OsdjtGKavZDBuG2xFw2QunVwwGs5IB3j","amount":25,"extra":null} +/// {"recipient":"pay:null:FrSVC3IrirScyRh","amount":5,"extra":null} /// ] /// } #[no_mangle] -pub extern fn vcx_credential_get_payment_txn(command_handle: u32, +pub extern fn vcx_credential_get_payment_txn(command_handle: CommandHandle, handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_credential_get_payment_txn >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -862,7 +952,6 @@ mod tests { init!("true"); let handle = credential::from_string(FULL_CREDENTIAL_SERIALIZED).unwrap(); let bad_handle = 1123; - let command_handle = 1111; let cb = return_types_u32::Return_U32_STR::new().unwrap(); assert_eq!(vcx_get_credential(cb.command_handle, handle, Some(cb.get_callback())), error::SUCCESS.code_num); cb.receive(Some(Duration::from_secs(10))).unwrap().unwrap(); diff --git a/vcx/libvcx/src/api/credential_def.rs b/vcx/libvcx/src/api/credential_def.rs index 22bdabcaa3..4996b0785f 100644 --- a/vcx/libvcx/src/api/credential_def.rs +++ b/vcx/libvcx/src/api/credential_def.rs @@ -7,8 +7,9 @@ use credential_def; use settings; use utils::threadpool::spawn; use error::prelude::*; +use indy_sys::CommandHandle; -/// Create a new CredentialDef object that can create credential definitions on the ledger +/// Create a new CredentialDef object and publish correspondent record on the ledger /// /// #Params /// command_handle: command handle to map callback to user context. @@ -36,15 +37,15 @@ use error::prelude::*; /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_credentialdef_create(command_handle: u32, +pub extern fn vcx_credentialdef_create(command_handle: CommandHandle, source_id: *const c_char, credentialdef_name: *const c_char, schema_id: *const c_char, issuer_did: *const c_char, tag: *const c_char, revocation_details: *const c_char, - payment_handle: u32, - cb: Option) -> u32 { + _payment_handle: u32, + cb: Option) -> u32 { info!("vcx_credentialdef_create >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -101,6 +102,8 @@ pub extern fn vcx_credentialdef_create(command_handle: u32, /// Create a new CredentialDef object that will be published by Endorser later. /// +/// Note that CredentialDef can't be used for credential issuing until it will be published on the ledger. +/// /// #Params /// command_handle: command handle to map callback to user context. /// @@ -130,7 +133,7 @@ pub extern fn vcx_credentialdef_create(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_credentialdef_prepare_for_endorser(command_handle: u32, +pub extern fn vcx_credentialdef_prepare_for_endorser(command_handle: CommandHandle, source_id: *const c_char, credentialdef_name: *const c_char, schema_id: *const c_char, @@ -138,7 +141,7 @@ pub extern fn vcx_credentialdef_prepare_for_endorser(command_handle: u32, tag: *const c_char, revocation_details: *const c_char, endorser: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_credentialdef_serialize >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -265,9 +268,9 @@ pub extern fn vcx_credentialdef_serialize(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_credentialdef_deserialize(command_handle: u32, +pub extern fn vcx_credentialdef_deserialize(command_handle: CommandHandle, credentialdef_data: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_credentialdef_deserialize >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -306,9 +309,9 @@ pub extern fn vcx_credentialdef_deserialize(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_credentialdef_get_cred_def_id(command_handle: u32, +pub extern fn vcx_credentialdef_get_cred_def_id(command_handle: CommandHandle, cred_def_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_credentialdef_get_cred_def_id >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -340,7 +343,7 @@ pub extern fn vcx_credentialdef_get_cred_def_id(command_handle: u32, error::SUCCESS.code_num } -/// Retrieve the txn associated with paying for the credential_def +/// Get the payment transaction information generated when paying the ledger fee /// /// #param /// handle: credential_def handle that was provided during creation. Used to access credential_def object. @@ -350,18 +353,16 @@ pub extern fn vcx_credentialdef_get_cred_def_id(command_handle: u32, /// example: { /// "amount":25, /// "inputs":[ -/// "pay:null:1_3FvPC7dzFbQKzfG", -/// "pay:null:1_lWVGKc07Pyc40m6" +/// "pay:null:1_3FvPC7dzFbQKzfG" /// ], /// "outputs":[ -/// {"recipient":"pay:null:FrSVC3IrirScyRh","amount":5,"extra":null}, -/// {"recipient":"pov:null:OsdjtGKavZDBuG2xFw2QunVwwGs5IB3j","amount":25,"extra":null} +/// {"recipient":"pay:null:FrSVC3IrirScyRh","amount":5,"extra":null} /// ] /// } #[no_mangle] -pub extern fn vcx_credentialdef_get_payment_txn(command_handle: u32, +pub extern fn vcx_credentialdef_get_payment_txn(command_handle: CommandHandle, handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_credentialdef_get_payment_txn >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -414,7 +415,7 @@ pub extern fn vcx_credentialdef_release(credentialdef_handle: u32) -> u32 { let source_id = credential_def::get_source_id(credentialdef_handle).unwrap_or_default(); match credential_def::release(credentialdef_handle) { - Ok(_) => { + Ok(()) => { trace!("vcx_credentialdef_release(credentialdef_handle: {}, rc: {}), source_id: {}", credentialdef_handle, error::SUCCESS.message, source_id); error::SUCCESS.code_num @@ -428,7 +429,7 @@ pub extern fn vcx_credentialdef_release(credentialdef_handle: u32) -> u32 { } } -/// Checks if credential definition is published on the Ledger and updates the the state +/// Checks if credential definition is published on the Ledger and updates the state if it is. /// /// #Params /// command_handle: command handle to map callback to user context. @@ -436,13 +437,16 @@ pub extern fn vcx_credentialdef_release(credentialdef_handle: u32) -> u32 { /// credentialdef_handle: Credentialdef handle that was provided during creation. Used to access credentialdef object /// /// cb: Callback that provides most current state of the credential definition and error status of request +/// States: +/// 0 = Built +/// 1 = Published /// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_credentialdef_update_state(command_handle: u32, +pub extern fn vcx_credentialdef_update_state(command_handle: CommandHandle, credentialdef_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_credentialdef_update_state >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -483,13 +487,16 @@ pub extern fn vcx_credentialdef_update_state(command_handle: u32, /// credentialdef_handle: Credentialdef handle that was provided during creation. Used to access credentialdef object /// /// cb: Callback that provides most current state of the credential definition and error status of request +/// States: +/// 0 = Built +/// 1 = Published /// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_credentialdef_get_state(command_handle: u32, +pub extern fn vcx_credentialdef_get_state(command_handle: CommandHandle, credentialdef_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_credentialdef_get_state >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -668,7 +675,7 @@ mod tests { "tag".to_string(), "{}".to_string()).unwrap(); let cb = return_types_u32::Return_U32_STR::new().unwrap(); - let rc = vcx_credentialdef_get_payment_txn(cb.command_handle, handle, Some(cb.get_callback())); + let _rc = vcx_credentialdef_get_payment_txn(cb.command_handle, handle, Some(cb.get_callback())); cb.receive(Some(Duration::from_secs(10))).unwrap(); } @@ -686,7 +693,7 @@ mod tests { CString::new("{}").unwrap().into_raw(), CString::new("V4SGRU86Z58d6TV7PBUe6f").unwrap().into_raw(), Some(cb.get_callback())), error::SUCCESS.code_num); - let (handle, cred_def_transaction, rev_reg_def_transaction, rev_reg_delta_transaction) = cb.receive(Some(Duration::from_secs(2))).unwrap(); + let (_handle, cred_def_transaction, rev_reg_def_transaction, rev_reg_delta_transaction) = cb.receive(Some(Duration::from_secs(2))).unwrap(); let cred_def_transaction = cred_def_transaction.unwrap(); let cred_def_transaction: serde_json::Value = serde_json::from_str(&cred_def_transaction).unwrap(); let expected_cred_def_transaction: serde_json::Value = serde_json::from_str(::utils::constants::REQUEST_WITH_ENDORSER).unwrap(); @@ -709,7 +716,7 @@ mod tests { CString::new(credential_def::tests::revocation_details(true).to_string()).unwrap().into_raw(), CString::new("V4SGRU86Z58d6TV7PBUe6f").unwrap().into_raw(), Some(cb.get_callback())), error::SUCCESS.code_num); - let (handle, cred_def_transaction, rev_reg_def_transaction, rev_reg_delta_transaction) = cb.receive(Some(Duration::from_secs(2))).unwrap(); + let (_handle, cred_def_transaction, rev_reg_def_transaction, rev_reg_delta_transaction) = cb.receive(Some(Duration::from_secs(2))).unwrap(); let cred_def_transaction = cred_def_transaction.unwrap(); let cred_def_transaction: serde_json::Value = serde_json::from_str(&cred_def_transaction).unwrap(); let expected_cred_def_transaction: serde_json::Value = serde_json::from_str(::utils::constants::REQUEST_WITH_ENDORSER).unwrap(); @@ -721,7 +728,6 @@ mod tests { #[test] fn test_vcx_cred_def_get_state() { init!("true"); - let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); let (handle, _, _, _) = credential_def::prepare_credentialdef_for_endorser("testid".to_string(), "Test Credential Def".to_string(), "6vkhW3L28AophhA68SSzRS".to_string(), @@ -731,17 +737,17 @@ mod tests { "V4SGRU86Z58d6TV7PBUe6f".to_string()).unwrap(); { let cb = return_types_u32::Return_U32_U32::new().unwrap(); - let rc = vcx_credentialdef_get_state(cb.command_handle, handle, Some(cb.get_callback())); + let _rc = vcx_credentialdef_get_state(cb.command_handle, handle, Some(cb.get_callback())); assert_eq!(cb.receive(Some(Duration::from_secs(10))).unwrap(), ::api::PublicEntityStateType::Built as u32) } { let cb = return_types_u32::Return_U32_U32::new().unwrap(); - let rc = vcx_credentialdef_update_state(cb.command_handle, handle, Some(cb.get_callback())); + let _rc = vcx_credentialdef_update_state(cb.command_handle, handle, Some(cb.get_callback())); assert_eq!(cb.receive(Some(Duration::from_secs(10))).unwrap(), ::api::PublicEntityStateType::Published as u32); } { let cb = return_types_u32::Return_U32_U32::new().unwrap(); - let rc = vcx_credentialdef_get_state(cb.command_handle, handle, Some(cb.get_callback())); + let _rc = vcx_credentialdef_get_state(cb.command_handle, handle, Some(cb.get_callback())); assert_eq!(cb.receive(Some(Duration::from_secs(10))).unwrap(), ::api::PublicEntityStateType::Published as u32) } } diff --git a/vcx/libvcx/src/api/disclosed_proof.rs b/vcx/libvcx/src/api/disclosed_proof.rs index b5a4386f97..a8b3f6ee17 100644 --- a/vcx/libvcx/src/api/disclosed_proof.rs +++ b/vcx/libvcx/src/api/disclosed_proof.rs @@ -6,8 +6,70 @@ use disclosed_proof; use std::ptr; use utils::threadpool::spawn; use error::prelude::*; +use indy_sys::CommandHandle; -/// Create a proof for fulfilling a corresponding proof request +/* + The API represents an Prover side in credential presentation process. + Assumes that pairwise connection between Verifier and Prover is already established. + + # State + + The set of object states, messages and transitions depends on the communication method is used. + There are two communication methods: `proprietary` and `aries`. The default communication method is `proprietary`. + The communication method can be specified as a config option on one of *_init functions. + + proprietary: + VcxStateType::VcxStateRequestReceived - once `vcx_disclosed_proof_create_with_request` (create DisclosedProof object) is called. + + VcxStateType::VcxStateRequestReceived - once `vcx_disclosed_proof_generate_proof` is called. + + VcxStateType::VcxStateAccepted - once `vcx_disclosed_proof_send_proof` (send `PROOF` message) is called. + + aries: + VcxStateType::VcxStateRequestReceived - once `vcx_disclosed_proof_create_with_request` (create DisclosedProof object) is called. + + VcxStateType::VcxStateRequestReceived - once `vcx_disclosed_proof_generate_proof` is called. + + VcxStateType::VcxStateOfferSent - once `vcx_disclosed_proof_send_proof` (send `Presentation` message) is called. + VcxStateType::None - once `vcx_disclosed_proof_decline_presentation_request` (send `PresentationReject` or `PresentationProposal` message) is called. + + VcxStateType::VcxStateAccepted - once `Ack` messages is received. + VcxStateType::None - once `ProblemReport` messages is received. + + # Transitions + + proprietary: + VcxStateType::None - `vcx_disclosed_proof_create_with_request` - VcxStateType::VcxStateRequestReceived + + VcxStateType::VcxStateRequestReceived - `vcx_disclosed_proof_generate_proof` - VcxStateType::VcxStateRequestReceived + + VcxStateType::VcxStateRequestReceived - `vcx_disclosed_proof_send_proof` - VcxStateType::VcxStateAccepted + + aries: RFC - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0037-present-proof#propose-presentation + VcxStateType::None - `vcx_disclosed_proof_create_with_request` - VcxStateType::VcxStateRequestReceived + + VcxStateType::VcxStateRequestReceived - `vcx_disclosed_proof_generate_proof` - VcxStateType::VcxStateRequestReceived + + VcxStateType::VcxStateRequestReceived - `vcx_disclosed_proof_send_proof` - VcxStateType::VcxStateAccepted + VcxStateType::VcxStateRequestReceived - `vcx_disclosed_proof_decline_presentation_request` - VcxStateType::None + + VcxStateType::VcxStateOfferSent - received `Ack` - VcxStateType::VcxStateAccepted + VcxStateType::VcxStateOfferSent - received `ProblemReport` - VcxStateType::None + + # Messages + + proprietary: + ProofRequest (`PROOF_REQ`) + Proof (`PROOF`) + + aries: + PresentationRequest - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0037-present-proof#request-presentation + Presentation - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0037-present-proof#presentation + PresentationProposal - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0037-present-proof#propose-presentation + Ack - https://github.com/hyperledger/aries-rfcs/tree/master/features/0015-acks#explicit-acks +*/ + +/// Create a Proof object for fulfilling a corresponding proof request /// /// #Params /// command_handle: command handle to map callback to user context. @@ -18,14 +80,16 @@ use error::prelude::*; /// /// cb: Callback that provides proof handle or error status /// +/// # Example proof_req -> "{"@topic":{"mid":9,"tid":1},"@type":{"name":"PROOF_REQUEST","version":"1.0"},"msg_ref_id":"ymy5nth","proof_request_data":{"name":"AccountCertificate","nonce":"838186471541979035208225","requested_attributes":{"business_2":{"name":"business"},"email_1":{"name":"email"},"name_0":{"name":"name"}},"requested_predicates":{},"version":"0.1"}}" +/// /// #Returns /// Error code as u32 #[no_mangle] #[allow(unused_variables, unused_mut)] -pub extern fn vcx_disclosed_proof_create_with_request(command_handle: u32, +pub extern fn vcx_disclosed_proof_create_with_request(command_handle: CommandHandle, source_id: *const c_char, proof_req: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_disclosed_proof_create_with_request >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -56,7 +120,7 @@ pub extern fn vcx_disclosed_proof_create_with_request(command_handle: u32, } -/// Create a proof for fulfilling a corresponding proof request +/// Create a proof based off of a known message id for a given connection. /// /// #Params /// command_handle: command handle to map callback to user context. @@ -65,7 +129,7 @@ pub extern fn vcx_disclosed_proof_create_with_request(command_handle: u32, /// /// connection: connection to query for proof request /// -/// msg_id: msg_id that contains the proof request +/// msg_id: id of the message that contains the proof request /// /// cb: Callback that provides proof handle and proof request or error status /// @@ -73,11 +137,11 @@ pub extern fn vcx_disclosed_proof_create_with_request(command_handle: u32, /// Error code as a u32 #[no_mangle] #[allow(unused_variables, unused_mut)] -pub extern fn vcx_disclosed_proof_create_with_msgid(command_handle: u32, +pub extern fn vcx_disclosed_proof_create_with_msgid(command_handle: CommandHandle, source_id: *const c_char, connection_handle: u32, msg_id: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_disclosed_proof_create_with_msgid >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -128,10 +192,10 @@ pub extern fn vcx_disclosed_proof_create_with_msgid(command_handle: u32, /// #Returns /// Error code as u32 #[no_mangle] -pub extern fn vcx_disclosed_proof_send_proof(command_handle: u32, +pub extern fn vcx_disclosed_proof_send_proof(command_handle: CommandHandle, proof_handle: u32, connection_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_disclosed_proof_send_proof >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -145,8 +209,8 @@ pub extern fn vcx_disclosed_proof_send_proof(command_handle: u32, command_handle, proof_handle, connection_handle, source_id); spawn(move || { - let err = match disclosed_proof::send_proof(proof_handle, connection_handle) { - Ok(x) => { + match disclosed_proof::send_proof(proof_handle, connection_handle) { + Ok(_) => { trace!("vcx_disclosed_proof_send_proof_cb(command_handle: {}, rc: {}) source_id: {}", command_handle, error::SUCCESS.message, source_id); cb(command_handle, error::SUCCESS.code_num); @@ -176,9 +240,9 @@ pub extern fn vcx_disclosed_proof_send_proof(command_handle: u32, /// #Returns /// Error code as u32 #[no_mangle] -pub extern fn vcx_disclosed_proof_get_proof_msg(command_handle: u32, +pub extern fn vcx_disclosed_proof_get_proof_msg(command_handle: CommandHandle, proof_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_disclosed_proof_get_proof_msg >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -213,7 +277,7 @@ pub extern fn vcx_disclosed_proof_get_proof_msg(command_handle: u32, } -/// Queries agency for proof requests from the given connection. +/// Queries agency for all pending proof requests from the given connection. /// /// #Params /// command_handle: command handle to map callback to user context. @@ -221,13 +285,14 @@ pub extern fn vcx_disclosed_proof_get_proof_msg(command_handle: u32, /// connection_handle: Connection to query for proof requests. /// /// cb: Callback that provides any proof requests and error status of query +/// # Example requests -> "[{'@topic': {'tid': 0, 'mid': 0}, '@type': {'version': '1.0', 'name': 'PROOF_REQUEST'}, 'proof_request_data': {'name': 'proof_req', 'nonce': '118065925949165739229152', 'version': '0.1', 'requested_predicates': {}, 'non_revoked': None, 'requested_attributes': {'attribute_0': {'name': 'name', 'restrictions': {'$or': [{'issuer_did': 'did'}]}}}, 'ver': '1.0'}, 'thread_id': '40bdb5b2'}]" /// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_disclosed_proof_get_requests(command_handle: u32, +pub extern fn vcx_disclosed_proof_get_requests(command_handle: CommandHandle, connection_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_disclosed_proof_get_requests >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -268,13 +333,16 @@ pub extern fn vcx_disclosed_proof_get_requests(command_handle: u32, /// proof_handle: Proof handle that was provided during creation. Used to access disclosed proof object /// /// cb: Callback that provides most current state of the disclosed proof and error status of request +/// States: +/// 3 - Request Received +/// 4 - Accepted /// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_disclosed_proof_get_state(command_handle: u32, +pub extern fn vcx_disclosed_proof_get_state(command_handle: CommandHandle, proof_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_disclosed_proof_get_state >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -307,7 +375,7 @@ pub extern fn vcx_disclosed_proof_get_state(command_handle: u32, error::SUCCESS.code_num } -/// Checks for any state change in the disclosed proof and updates the the state attribute +/// Checks for any state change in the disclosed proof and updates the state attribute /// /// #Params /// command_handle: command handle to map callback to user context. @@ -319,9 +387,9 @@ pub extern fn vcx_disclosed_proof_get_state(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_disclosed_proof_update_state(command_handle: u32, +pub extern fn vcx_disclosed_proof_update_state(command_handle: CommandHandle, proof_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_disclosed_proof_update_state >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -354,24 +422,24 @@ pub extern fn vcx_disclosed_proof_update_state(command_handle: u32, error::SUCCESS.code_num } -/// Checks for any state change from the given message and updates the the state attribute +/// Checks for any state change from the given message and updates the state attribute /// /// #Params /// command_handle: command handle to map callback to user context. /// /// proof_handle: Credential handle that was provided during creation. Used to identify disclosed proof object /// -/// message: message to parse for state changes +/// message: message to process for state changes /// /// cb: Callback that provides most current state of the disclosed proof and error status of request /// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_disclosed_proof_update_state_with_message(command_handle: u32, +pub extern fn vcx_disclosed_proof_update_state_with_message(command_handle: CommandHandle, proof_handle: u32, message: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_disclosed_proof_update_state_with_message >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -417,9 +485,9 @@ pub extern fn vcx_disclosed_proof_update_state_with_message(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_disclosed_proof_serialize(command_handle: u32, +pub extern fn vcx_disclosed_proof_serialize(command_handle: CommandHandle, proof_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_disclosed_proof_serialize >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -466,9 +534,9 @@ pub extern fn vcx_disclosed_proof_serialize(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_disclosed_proof_deserialize(command_handle: u32, +pub extern fn vcx_disclosed_proof_deserialize(command_handle: CommandHandle, proof_data: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_disclosed_proof_deserialize >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -498,7 +566,7 @@ pub extern fn vcx_disclosed_proof_deserialize(command_handle: u32, error::SUCCESS.code_num } -/// Takes the disclosed proof object and returns a json string of all credentials matching associated proof request from wallet +/// Get credentials from wallet matching to the proof request associated with proof object /// /// #Params /// command_handle: command handle to map callback to user context. @@ -507,12 +575,15 @@ pub extern fn vcx_disclosed_proof_deserialize(command_handle: u32, /// /// cb: Callback that provides json string of the credentials in wallet associated with proof request /// +/// # Example +/// credentials -> "{'attrs': {'attribute_0': [{'cred_info': {'schema_id': 'id', 'cred_def_id': 'id', 'attrs': {'attr_name': 'attr_value', ...}, 'referent': '914c7e11'}}]}}" +/// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_disclosed_proof_retrieve_credentials(command_handle: u32, +pub extern fn vcx_disclosed_proof_retrieve_credentials(command_handle: CommandHandle, proof_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_disclosed_proof_retrieve_credentials >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -546,7 +617,7 @@ pub extern fn vcx_disclosed_proof_retrieve_credentials(command_handle: u32, error::SUCCESS.code_num } -/// Takes the disclosed proof object and generates a proof from the selected credentials and self attested attributes +/// Accept proof request associated with proof object and generates a proof from the selected credentials and self attested attributes /// /// #Params /// command_handle: command handle to map callback to user context. @@ -580,18 +651,19 @@ pub extern fn vcx_disclosed_proof_retrieve_credentials(command_handle: u32, /// // selected_credentials can be empty "{}" if the proof only contains self_attested_attrs /// /// self_attested_attrs: a json string with attributes self attested by user -/// # Examples self_attested_attrs -> "{"self_attested_attr_0":"attested_val"}" | "{}" -/// +/// # Examples +/// self_attested_attrs -> "{"self_attested_attr_0":"attested_val"}" | "{}" +/// selected_credentials -> "{'attrs': {'attribute_0': {'credential': {'cred_info': {'cred_def_id': 'od', 'schema_id': 'id', 'referent': '0c212108-9433-4199-a21f-336a44164f38', 'attrs': {'attr_name': 'attr_value', ...}}}}}}" /// cb: Callback that returns error status /// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_disclosed_proof_generate_proof(command_handle: u32, +pub extern fn vcx_disclosed_proof_generate_proof(command_handle: CommandHandle, proof_handle: u32, selected_credentials: *const c_char, self_attested_attrs: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_disclosed_proof_generate_proof >>>"); check_useful_c_str!(selected_credentials, VcxErrorKind::InvalidOption); @@ -747,7 +819,7 @@ pub extern fn vcx_disclosed_proof_release(handle: u32) -> u32 { let source_id = disclosed_proof::get_source_id(handle).unwrap_or_default(); match disclosed_proof::release(handle) { - Ok(_) => { + Ok(()) => { trace!("vcx_disclosed_proof_release(handle: {}, rc: {}), source_id: {:?}", handle, error::SUCCESS.message, source_id); error::SUCCESS.code_num @@ -816,7 +888,6 @@ mod tests { #[test] fn test_vcx_disclosed_proof_release() { init!("true"); - let cb = return_types_u32::Return_U32_STR::new().unwrap(); let handle = disclosed_proof::create_proof("1", ::utils::constants::PROOF_REQUEST_JSON).unwrap(); let unknown_handle = handle + 1; let err = vcx_disclosed_proof_release(unknown_handle); @@ -908,7 +979,7 @@ mod tests { handle, Some(cb.get_callback())), error::SUCCESS.code_num); - let credentials = cb.receive(None).unwrap().unwrap(); + let _credentials = cb.receive(None).unwrap().unwrap(); } #[test] diff --git a/vcx/libvcx/src/api/issuer_credential.rs b/vcx/libvcx/src/api/issuer_credential.rs index bc843aba65..30d3d4c096 100644 --- a/vcx/libvcx/src/api/issuer_credential.rs +++ b/vcx/libvcx/src/api/issuer_credential.rs @@ -8,9 +8,79 @@ use issuer_credential; use std::ptr; use utils::threadpool::spawn; use error::prelude::*; +use indy_sys::CommandHandle; + +/* + The API represents an Issuer side in credential issuance process. + Assumes that pairwise connection between Issuer and Holder is already established. + + # State + + The set of object states, messages and transitions depends on the communication method is used. + There are two communication methods: `proprietary` and `aries`. The default communication method is `proprietary`. + The communication method can be specified as a config option on one of *_init functions. + + proprietary: + VcxStateType::VcxStateInitialized - once `vcx_issuer_create_credential` (create IssuerCredential object) is called. + + VcxStateType::VcxStateOfferSent - once `vcx_issuer_send_credential_offer` (send `CRED_OFFER` message) is called. + + VcxStateType::VcxStateRequestReceived - once `CRED_REQ` messages is received. + use `vcx_issuer_credential_update_state` or `vcx_issuer_credential_update_state_with_message` functions for state updates. + VcxStateType::VcxStateAccepted - once `vcx_issuer_send_credential` (send `CRED` message) is called. + + aries: + VcxStateType::VcxStateInitialized - once `vcx_issuer_create_credential` (create IssuerCredential object) is called. + + VcxStateType::VcxStateOfferSent - once `vcx_issuer_send_credential_offer` (send `CredentialOffer` message) is called. + + VcxStateType::VcxStateRequestReceived - once `CredentialRequest` messages is received. + VcxStateType::None - once `ProblemReport` messages is received. + use `vcx_issuer_credential_update_state` or `vcx_issuer_credential_update_state_with_message` functions for state updates. + + VcxStateType::VcxStateAccepted - once `vcx_issuer_send_credential` (send `Credential` message) is called. + + # Transitions + + proprietary: + VcxStateType::None - `vcx_issuer_create_credential` - VcxStateType::VcxStateInitialized + + VcxStateType::VcxStateInitialized - `vcx_issuer_send_credential_offer` - VcxStateType::VcxStateOfferSent + + VcxStateType::VcxStateOfferSent - received `CRED_REQ` - VcxStateType::VcxStateRequestReceived + + VcxStateType::VcxStateRequestReceived - `vcx_issuer_send_credential` - VcxStateType::VcxStateAccepted + + aries: RFC - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential + VcxStateType::None - `vcx_issuer_create_credential` - VcxStateType::VcxStateInitialized + + VcxStateType::VcxStateInitialized - `vcx_issuer_send_credential_offer` - VcxStateType::VcxStateOfferSent + + VcxStateType::VcxStateOfferSent - received `CredentialRequest` - VcxStateType::VcxStateRequestReceived + VcxStateType::VcxStateOfferSent - received `ProblemReport` - VcxStateType::None + + VcxStateType::VcxStateRequestReceived - vcx_issuer_send_credential` - VcxStateType::VcxStateAccepted + + VcxStateType::VcxStateAccepted - received `Ack` - VcxStateType::VcxStateAccepted + + # Messages + + proprietary: + CredentialOffer (`CRED_OFFER`) + CredentialRequest (`CRED_REQ`) + Credential (`CRED`) + + aries: + CredentialProposal - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential#propose-credential + CredentialOffer - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential#offer-credential + CredentialRequest - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential#request-credential + Credential - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential#issue-credential + ProblemReport - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0035-report-problem#the-problem-report-message-type + Ack - https://github.com/hyperledger/aries-rfcs/tree/master/features/0015-acks#explicit-acks +*/ /// Create a Issuer Credential object that provides a credential for an enterprise's user -/// Assumes a credential definition has been written to the ledger. +/// Assumes a credential definition has been already written to the ledger. /// /// #Params /// command_handle: command handle to map callback to user context. @@ -37,14 +107,14 @@ use error::prelude::*; /// # Example credential_data -> "{"state":["UT"]}" please note: this format is deprecated #[no_mangle] #[allow(unused_variables, unused_mut)] -pub extern fn vcx_issuer_create_credential(command_handle: u32, +pub extern fn vcx_issuer_create_credential(command_handle: CommandHandle, source_id: *const c_char, cred_def_handle: u32, issuer_did: *const c_char, credential_data: *const c_char, credential_name: *const c_char, price: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_issuer_create_credential >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -120,10 +190,10 @@ pub extern fn vcx_issuer_create_credential(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_issuer_send_credential_offer(command_handle: u32, +pub extern fn vcx_issuer_send_credential_offer(command_handle: CommandHandle, credential_handle: u32, connection_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_issuer_send_credential_offer >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -162,7 +232,7 @@ pub extern fn vcx_issuer_send_credential_offer(command_handle: u32, error::SUCCESS.code_num } -/// Send a credential offer to user showing what will be included in the actual credential +/// Gets the offer message that can be sent to the specified connection /// /// #Params /// command_handle: command handle to map callback to user context. @@ -176,10 +246,10 @@ pub extern fn vcx_issuer_send_credential_offer(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_issuer_get_credential_offer_msg(command_handle: u32, +pub extern fn vcx_issuer_get_credential_offer_msg(command_handle: CommandHandle, credential_handle: u32, connection_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_issuer_get_credential_offer_msg >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -217,7 +287,8 @@ pub extern fn vcx_issuer_get_credential_offer_msg(command_handle: u32, error::SUCCESS.code_num } -/// Checks for any state change in the credential and updates the the state attribute +/// Query the agency for the received messages. +/// Checks for any messages changing state in the object and updates the state attribute. /// /// #Params /// command_handle: command handle to map callback to user context. @@ -225,13 +296,18 @@ pub extern fn vcx_issuer_get_credential_offer_msg(command_handle: u32, /// credential_handle: Credential handle that was provided during creation. Used to identify credential object /// /// cb: Callback that provides most current state of the credential and error status of request +/// States: +/// 1 - Initialized +/// 2 - Offer Sent +/// 3 - Request Received +/// 4 - Issued /// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_issuer_credential_update_state(command_handle: u32, +pub extern fn vcx_issuer_credential_update_state(command_handle: CommandHandle, credential_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_issuer_credential_update_state >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -264,24 +340,29 @@ pub extern fn vcx_issuer_credential_update_state(command_handle: u32, error::SUCCESS.code_num } -/// Checks and updates the state based on the given message +/// Update the state of the credential based on the given message. /// /// #Params /// command_handle: command handle to map callback to user context. /// /// credential_handle: Credential handle that was provided during creation. Used to identify credential object /// -/// message: message containing potential credential request from connection +/// message: message to process for state changes /// /// cb: Callback that provides most current state of the credential and error status of request +/// States: +/// 1 - Initialized +/// 2 - Offer Sent +/// 3 - Request Received +/// 4 - Issued /// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_issuer_credential_update_state_with_message(command_handle: u32, +pub extern fn vcx_issuer_credential_update_state_with_message(command_handle: CommandHandle, credential_handle: u32, message: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_issuer_credential_update_state_with_message >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -323,13 +404,18 @@ pub extern fn vcx_issuer_credential_update_state_with_message(command_handle: u3 /// proof_handle: Issuer Credential handle that was provided during creation. /// /// cb: Callback that provides most current state of the issuer credential and error status of request +/// States: +/// 1 - Initialized +/// 2 - Offer Sent +/// 3 - Request Received +/// 4 - Issued /// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_issuer_credential_get_state(command_handle: u32, +pub extern fn vcx_issuer_credential_get_state(command_handle: CommandHandle, credential_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_issuer_credential_get_state >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -374,7 +460,7 @@ pub extern fn vcx_issuer_accept_credential(credential_handle: u32) -> u32 { error::SUCCESS.code_num } -/// Send Credential that was requested by user +/// Sends the credential to the end user (holder). /// /// #Params /// command_handle: command handle to map callback to user context. @@ -388,10 +474,10 @@ pub extern fn vcx_issuer_accept_credential(credential_handle: u32) -> u32 { /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_issuer_send_credential(command_handle: u32, +pub extern fn vcx_issuer_send_credential(command_handle: CommandHandle, credential_handle: u32, connection_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_issuer_send_credential >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -429,7 +515,7 @@ pub extern fn vcx_issuer_send_credential(command_handle: u32, error::SUCCESS.code_num } -/// Send Credential that was requested by user +/// Gets the credential message that can be sent to the user /// /// #Params /// command_handle: command handle to map callback to user context. @@ -438,15 +524,15 @@ pub extern fn vcx_issuer_send_credential(command_handle: u32, /// /// connection_handle: Connection handle that identifies pairwise connection /// -/// cb: Callback that provides error status of sending the credential +/// cb: Callback that provides any error status of the credential /// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_issuer_get_credential_msg(command_handle: u32, +pub extern fn vcx_issuer_get_credential_msg(command_handle: CommandHandle, credential_handle: u32, connection_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_issuer_get_credential_msg >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -501,9 +587,9 @@ pub extern fn vcx_issuer_terminate_credential(credential_handle: u32, terminatio /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_issuer_credential_serialize(command_handle: u32, +pub extern fn vcx_issuer_credential_serialize(command_handle: CommandHandle, credential_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_issuer_credential_serialize >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -548,9 +634,9 @@ pub extern fn vcx_issuer_credential_serialize(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_issuer_credential_deserialize(command_handle: u32, +pub extern fn vcx_issuer_credential_deserialize(command_handle: CommandHandle, credential_data: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_issuer_credential_deserialize >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -592,7 +678,7 @@ pub extern fn vcx_issuer_credential_release(credential_handle: u32) -> u32 { info!("vcx_issuer_credential_release >>>"); let source_id = issuer_credential::get_source_id(credential_handle).unwrap_or_default(); match issuer_credential::release(credential_handle) { - Ok(_) => { + Ok(()) => { trace!("(vcx_issuer_credential_release credential_handle: {}, rc: {}), source_id: {}", credential_handle, error::SUCCESS.message, source_id); error::SUCCESS.code_num @@ -605,7 +691,9 @@ pub extern fn vcx_issuer_credential_release(credential_handle: u32) -> u32 { } } -/// Retrieve the txn associated with paying for the issuer_credential +/// Retrieve the payment transaction associated with this credential. This can be used to get the txn that +/// was used to pay the issuer from the holder. +/// This could be considered a receipt of payment from the payer to the issuer. /// /// #param /// handle: issuer_credential handle that was provided during creation. Used to access issuer_credential object. @@ -624,9 +712,9 @@ pub extern fn vcx_issuer_credential_release(credential_handle: u32) -> u32 { /// ] /// } #[no_mangle] -pub extern fn vcx_issuer_credential_get_payment_txn(command_handle: u32, +pub extern fn vcx_issuer_credential_get_payment_txn(command_handle: CommandHandle, handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_issuer_credential_get_payment_txn >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -673,14 +761,14 @@ pub extern fn vcx_issuer_credential_get_payment_txn(command_handle: u32, /// /// credential_handle: Credential handle that was provided during creation. Used to identify credential object /// -/// cb: Callback that provides error status of sending the credential +/// cb: Callback that provides error status of revoking the credential /// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_issuer_revoke_credential(command_handle: u32, +pub extern fn vcx_issuer_revoke_credential(command_handle: CommandHandle, credential_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); if !issuer_credential::is_valid_handle(credential_handle) { @@ -693,7 +781,7 @@ pub extern fn vcx_issuer_revoke_credential(command_handle: u32, spawn(move || { let err = match issuer_credential::revoke_credential(credential_handle) { - Ok(_) => { + Ok(()) => { info!("vcx_issuer_revoke_credential_cb(command_handle: {}, credential_handle: {}, rc: {}) source_id: {}", command_handle, credential_handle, error::SUCCESS.message, source_id); error::SUCCESS.code_num @@ -732,7 +820,6 @@ mod tests { static DEFAULT_CREDENTIAL_NAME: &str = "Credential Name Default"; static DEFAULT_DID: &str = "8XFh8yBzrpJQmNyZzgoTqB"; static DEFAULT_ATTR: &str = "{\"attr\":\"value\"}"; - static DEFAULT_SCHEMA_SEQ_NO: u32 = 32; fn issuer_credential_state_accepted() -> String { json!({ @@ -912,7 +999,6 @@ mod tests { fn test_vcx_issuer_send_a_credential() { init!("true"); settings::set_config_value(settings::CONFIG_INSTITUTION_DID, DEFAULT_DID); - let test_name = "test_vcx_issuer_send_a_credential"; let handle = issuer_credential::from_string(&issuer_credential_state_accepted()).unwrap(); // create connection @@ -933,7 +1019,6 @@ mod tests { fn test_vcx_issuer_get_credential_msg() { init!("true"); settings::set_config_value(settings::CONFIG_INSTITUTION_DID, DEFAULT_DID); - let test_name = "test_vcx_issuer_get_credential_msg"; let handle = issuer_credential::from_string(&issuer_credential_state_accepted()).unwrap(); // create connection diff --git a/vcx/libvcx/src/api/logger.rs b/vcx/libvcx/src/api/logger.rs index 8b1e659b06..725f263b2c 100644 --- a/vcx/libvcx/src/api/logger.rs +++ b/vcx/libvcx/src/api/logger.rs @@ -25,7 +25,7 @@ pub extern fn vcx_set_default_logger(pattern: *const c_char) -> u32 { trace!("vcx_set_default_logger(pattern: {:?})", pattern); match LibvcxDefaultLogger::init(pattern) { - Ok(_) => { + Ok(()) => { debug!("Logger Successfully Initialized"); SUCCESS.code_num } @@ -61,7 +61,7 @@ pub extern fn vcx_set_logger(context: *const CVoid, let res = LibvcxLogger::init(context, enabled, log, flush); match res { - Ok(_) => { + Ok(()) => { debug!("Logger Successfully Initialized"); SUCCESS.code_num } diff --git a/vcx/libvcx/src/api/proof.rs b/vcx/libvcx/src/api/proof.rs index 692568a6f5..6e1d138e28 100644 --- a/vcx/libvcx/src/api/proof.rs +++ b/vcx/libvcx/src/api/proof.rs @@ -6,6 +6,67 @@ use connection; use std::ptr; use utils::threadpool::spawn; use error::prelude::*; +use indy_sys::CommandHandle; + +/* + The API represents an Verifier side in credential presentation process. + Assumes that pairwise connection between Verifier and Prover is already established. + + # State + + The set of object states, messages and transitions depends on the communication method is used. + There are two communication methods: `proprietary` and `aries`. The default communication method is `proprietary`. + The communication method can be specified as a config option on one of *_init functions. + + proprietary: + VcxStateType::VcxStateInitialized - once `vcx_proof_create` (create Proof object) is called. + + VcxStateType::VcxStateOfferSent - once `vcx_credential_send_request` (send `PROOF_REQ` message) is called. + + VcxStateType::VcxStateAccepted - once `PROOF` messages is received. + use `vcx_proof_update_state` or `vcx_proof_update_state_with_message` functions for state updates. + + aries: + VcxStateType::VcxStateInitialized - once `vcx_proof_create` (create Proof object) is called. + + VcxStateType::VcxStateOfferSent - once `vcx_credential_send_request` (send `PresentationRequest` message) is called. + + VcxStateType::VcxStateAccepted - once `Presentation` messages is received. + VcxStateType::None - once `ProblemReport` messages is received. + VcxStateType::None - once `PresentationProposal` messages is received. + VcxStateType::None - on `Presentation` validation failed. + use `vcx_proof_update_state` or `vcx_proof_update_state_with_message` functions for state updates. + + # Transitions + + proprietary: + VcxStateType::None - `vcx_proof_create` - VcxStateType::VcxStateInitialized + + VcxStateType::VcxStateInitialized - `vcx_credential_send_request` - VcxStateType::VcxStateOfferSent + + VcxStateType::VcxStateOfferSent - received `PROOF` - VcxStateType::VcxStateAccepted + + aries: RFC - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0037-present-proof#propose-presentation + VcxStateType::None - `vcx_proof_create` - VcxStateType::VcxStateInitialized + + VcxStateType::VcxStateInitialized - `vcx_credential_send_request` - VcxStateType::VcxStateOfferSent + + VcxStateType::VcxStateOfferSent - received `Presentation` - VcxStateType::VcxStateAccepted + VcxStateType::VcxStateOfferSent - received `PresentationProposal` - VcxStateType::None + VcxStateType::VcxStateOfferSent - received `ProblemReport` - VcxStateType::None + + # Messages + + proprietary: + ProofRequest (`PROOF_REQ`) + Proof (`PROOF`) + + aries: + PresentationRequest - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0037-present-proof#request-presentation + Presentation - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0037-present-proof#presentation + PresentationProposal - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0037-present-proof#propose-presentation + Ack - https://github.com/hyperledger/aries-rfcs/tree/master/features/0015-acks#explicit-acks +*/ /// Create a new Proof object that requests a proof for an enterprise /// @@ -16,7 +77,10 @@ use error::prelude::*; /// /// requested_attrs: Describes requested attribute /// { -/// "name": string, // attribute name, (case insensitive and ignore spaces) +/// "name": Optional, // attribute name, (case insensitive and ignore spaces) +/// "names": Optional<[string, string]>, // attribute names, (case insensitive and ignore spaces) +/// // NOTE: should either be "name" or "names", not both and not none of them. +/// // Use "names" to specify several attributes that have to match a single credential. /// "restrictions": (filter_json) { /// "schema_id": string, (Optional) /// "schema_issuer_did": string, (Optional) @@ -65,13 +129,13 @@ use error::prelude::*; /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_proof_create(command_handle: u32, +pub extern fn vcx_proof_create(command_handle: CommandHandle, source_id: *const c_char, requested_attrs: *const c_char, requested_predicates: *const c_char, revocation_interval: *const c_char, name: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_proof_create >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -105,7 +169,8 @@ pub extern fn vcx_proof_create(command_handle: u32, error::SUCCESS.code_num } -/// Checks for any state change and updates the proof state attribute +/// Query the agency for the received messages. +/// Checks for any messages changing state in the object and updates the state attribute. /// /// #Params /// command_handle: command handle to map callback to user context. @@ -113,13 +178,18 @@ pub extern fn vcx_proof_create(command_handle: u32, /// proof_handle: Proof handle that was provided during creation. Used to access proof object /// /// cb: Callback that provides most current state of the proof and error status of request +/// States: +/// 1 - Initialized +/// 2 - Request Sent +/// 3 - Proof Received +/// 4 - Accepted /// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_proof_update_state(command_handle: u32, +pub extern fn vcx_proof_update_state(command_handle: CommandHandle, proof_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_proof_update_state >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -152,24 +222,29 @@ pub extern fn vcx_proof_update_state(command_handle: u32, error::SUCCESS.code_num } -/// Checks for any state change from the given message and updates the proof state attribute +/// Update the state of the proof based on the given message. /// /// #Params /// command_handle: command handle to map callback to user context. /// /// proof_handle: Proof handle that was provided during creation. Used to access proof object /// -/// message: String containing updated status +/// message: message to process for state changes /// /// cb: Callback that provides most current state of the proof and error status of request +/// States: +/// 1 - Initialized +/// 2 - Request Sent +/// 3 - Proof Received +/// 4 - Accepted /// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_proof_update_state_with_message(command_handle: u32, +pub extern fn vcx_proof_update_state_with_message(command_handle: CommandHandle, proof_handle: u32, message: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_proof_update_state_with_message >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -203,7 +278,7 @@ pub extern fn vcx_proof_update_state_with_message(command_handle: u32, error::SUCCESS.code_num } -/// Get the current state of the proof object from the given message +/// Get the current state of the proof object /// /// #Params /// command_handle: command handle to map callback to user context. @@ -211,13 +286,18 @@ pub extern fn vcx_proof_update_state_with_message(command_handle: u32, /// proof_handle: Proof handle that was provided during creation. Used to access proof object /// /// cb: Callback that provides most current state of the proof and error status of request +/// States: +/// 1 - Initialized +/// 2 - Request Sent +/// 3 - Proof Received +/// 4 - Accepted /// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_proof_get_state(command_handle: u32, +pub extern fn vcx_proof_get_state(command_handle: CommandHandle, proof_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_proof_get_state >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -262,9 +342,9 @@ pub extern fn vcx_proof_get_state(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_proof_serialize(command_handle: u32, +pub extern fn vcx_proof_serialize(command_handle: CommandHandle, proof_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_proof_serialize >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -309,9 +389,9 @@ pub extern fn vcx_proof_serialize(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_proof_deserialize(command_handle: u32, +pub extern fn vcx_proof_deserialize(command_handle: CommandHandle, proof_data: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_proof_deserialize >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -354,7 +434,7 @@ pub extern fn vcx_proof_release(proof_handle: u32) -> u32 { let source_id = proof::get_source_id(proof_handle).unwrap_or_default(); match proof::release(proof_handle) { - Ok(_) => { + Ok(()) => { trace!("vcx_proof_release(proof_handle: {}, rc: {}), source_id: {}", proof_handle, error::SUCCESS.message, source_id); error::SUCCESS.code_num @@ -381,10 +461,10 @@ pub extern fn vcx_proof_release(proof_handle: u32) -> u32 { /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_proof_send_request(command_handle: u32, +pub extern fn vcx_proof_send_request(command_handle: CommandHandle, proof_handle: u32, connection_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_proof_send_request >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -423,7 +503,7 @@ pub extern fn vcx_proof_send_request(command_handle: u32, } -/// Get the proof request message. +/// Get the proof request message that can be sent to the specified connection /// /// #Params /// command_handle: command handle to map callback to user context. @@ -434,12 +514,14 @@ pub extern fn vcx_proof_send_request(command_handle: u32, /// /// cb: provides any error status of the proof_request /// +/// # Example proof_request -> "{'@topic': {'tid': 0, 'mid': 0}, '@type': {'version': '1.0', 'name': 'PROOF_REQUEST'}, 'proof_request_data': {'name': 'proof_req', 'nonce': '118065925949165739229152', 'version': '0.1', 'requested_predicates': {}, 'non_revoked': None, 'requested_attributes': {'attribute_0': {'name': 'name', 'restrictions': {'$or': [{'issuer_did': 'did'}]}}}, 'ver': '1.0'}, 'thread_id': '40bdb5b2'}" +/// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_proof_get_request_msg(command_handle: u32, +pub extern fn vcx_proof_get_request_msg(command_handle: CommandHandle, proof_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_proof_get_request_msg >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -475,7 +557,7 @@ pub extern fn vcx_proof_get_request_msg(command_handle: u32, -/// Get Proof +/// Get Proof message /// /// #Params /// command_handle: command handle to map callback to user context. @@ -489,10 +571,10 @@ pub extern fn vcx_proof_get_request_msg(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_get_proof(command_handle: u32, +pub extern fn vcx_get_proof(command_handle: CommandHandle, proof_handle: u32, connection_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_get_proof >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -635,7 +717,6 @@ mod tests { fn test_vcx_proof_deserialize_succeeds() { init!("true"); let cb = return_types_u32::Return_U32_U32::new().unwrap(); - let original = r#"{"nonce":"123456","version":"1.0","handle":1,"msg_uid":"","ref_msg_id":"","name":"Name Data","prover_vk":"","agent_did":"","agent_vk":"","remote_did":"","remote_vk":"","prover_did":"8XFh8yBzrpJQmNyZzgoTqB","requested_attrs":"{\"attrs\":[{\"name\":\"person name\"},{\"schema_seq_no\":1,\"name\":\"address_1\"},{\"schema_seq_no\":2,\"issuer_did\":\"ISSUER_DID2\",\"name\":\"address_2\"},{\"schema_seq_no\":1,\"name\":\"city\"},{\"schema_seq_no\":1,\"name\":\"state\"},{\"schema_seq_no\":1,\"name\":\"zip\"}]}","requested_predicates":"{\"attr_name\":\"age\",\"p_type\":\"GE\",\"value\":18,\"schema_seq_no\":1,\"issuer_did\":\"DID1\"}","source_id":"source id","state":2,"proof_state":0,"proof":null,"proof_request":null,"revocation_interval":{}}"#; assert_eq!(vcx_proof_deserialize(cb.command_handle, CString::new(PROOF_OFFER_SENT).unwrap().into_raw(), Some(cb.get_callback())), @@ -687,7 +768,7 @@ mod tests { CString::new(PROOF_RESPONSE_STR).unwrap().into_raw(), Some(cb.get_callback())), error::SUCCESS.code_num); - let state = cb.receive(Some(Duration::from_secs(10))).unwrap(); + let _state = cb.receive(Some(Duration::from_secs(10))).unwrap(); assert_eq!(proof::get_state(proof_handle).unwrap(),VcxStateType::VcxStateAccepted as u32); } diff --git a/vcx/libvcx/src/api/return_types_u32.rs b/vcx/libvcx/src/api/return_types_u32.rs index f2001f10d2..8d25d7e742 100644 --- a/vcx/libvcx/src/api/return_types_u32.rs +++ b/vcx/libvcx/src/api/return_types_u32.rs @@ -1,7 +1,7 @@ use libc::c_char; use std::sync::mpsc::Receiver; use std::sync::mpsc::RecvTimeoutError; -use utils::libindy::next_u32_command_handle; +use utils::libindy::next_command_handle; use utils::libindy::callback_u32 as callback; use utils::libindy::callback::POISON_MSG; use utils::libindy::error_codes::map_indy_error; @@ -13,13 +13,14 @@ use std::time::Duration; use std::collections::HashMap; use std::sync::Mutex; use std::ops::Deref; +use indy_sys::CommandHandle; fn log_error(e: T) { warn!("Unable to send through libindy callback in vcx: {}", e); } -fn insert_closure(closure: T, map: &Mutex>) -> u32 { - let command_handle = next_u32_command_handle(); +fn insert_closure(closure: T, map: &Mutex>) -> CommandHandle { + let command_handle = next_command_handle(); { let mut callbacks = map.lock().expect(POISON_MSG); callbacks.insert(command_handle, closure); @@ -47,7 +48,7 @@ pub fn receive(receiver: &Receiver, timeout: Option) -> Result, } @@ -66,7 +67,7 @@ impl Return_U32 { }) } - pub fn get_callback(&self) -> extern fn(command_handle: u32, arg1: u32) { + pub fn get_callback(&self) -> extern fn(command_handle: CommandHandle, arg1: u32) { callback::call_cb_u32 } @@ -78,7 +79,7 @@ impl Return_U32 { #[allow(non_camel_case_types)] pub struct Return_U32_U32 { - pub command_handle: u32, + pub command_handle: CommandHandle, pub receiver: Receiver<(u32, u32)>, } impl Return_U32_U32 { @@ -96,7 +97,7 @@ impl Return_U32_U32 { }) } - pub fn get_callback(&self) -> extern fn (command_handle: u32, arg1: u32, arg2: u32) { + pub fn get_callback(&self) -> extern fn (command_handle: CommandHandle, arg1: u32, arg2: u32) { callback::call_cb_u32_u32 } @@ -109,7 +110,7 @@ impl Return_U32_U32 { #[allow(non_camel_case_types)] pub struct Return_U32_STR { - pub command_handle: u32, + pub command_handle: CommandHandle, receiver: Receiver<(u32, Option)>, } impl Return_U32_STR { @@ -127,7 +128,7 @@ impl Return_U32_STR { }) } - pub fn get_callback(&self) -> extern fn(command_handle: u32, arg1: u32, arg2: *const c_char) { + pub fn get_callback(&self) -> extern fn(command_handle: CommandHandle, arg1: u32, arg2: *const c_char) { callback::call_cb_u32_str } @@ -140,7 +141,7 @@ impl Return_U32_STR { #[allow(non_camel_case_types)] pub struct Return_U32_U32_STR { - pub command_handle: u32, + pub command_handle: CommandHandle, receiver: Receiver<(u32, u32, Option)>, } @@ -159,7 +160,7 @@ impl Return_U32_U32_STR { }) } - pub fn get_callback(&self) -> extern fn(command_handle: u32, arg1: u32, arg2: u32, arg3: *const c_char) { + pub fn get_callback(&self) -> extern fn(command_handle: CommandHandle, arg1: u32, arg2: u32, arg3: *const c_char) { callback::call_cb_u32_u32_str } @@ -172,7 +173,7 @@ impl Return_U32_U32_STR { #[allow(non_camel_case_types)] pub struct Return_U32_STR_STR { - pub command_handle: u32, + pub command_handle: CommandHandle, receiver: Receiver<(u32, Option, Option)>, } impl Return_U32_STR_STR { @@ -190,7 +191,7 @@ impl Return_U32_STR_STR { }) } - pub fn get_callback(&self) -> extern fn(command_handle: u32, + pub fn get_callback(&self) -> extern fn(command_handle: CommandHandle, arg1: u32, arg2: *const c_char, arg3: *const c_char) { @@ -208,7 +209,7 @@ impl Return_U32_STR_STR { #[allow(non_camel_case_types)] pub struct Return_U32_BOOL { - pub command_handle: u32, + pub command_handle: CommandHandle, receiver: Receiver<(u32, bool)>, } @@ -227,7 +228,7 @@ impl Return_U32_BOOL { }) } - pub fn get_callback(&self) -> extern fn (command_handle: u32, arg1: u32, arg2: bool) { + pub fn get_callback(&self) -> extern fn (command_handle: CommandHandle, arg1: u32, arg2: bool) { callback::call_cb_u32_bool } @@ -241,7 +242,7 @@ impl Return_U32_BOOL { #[allow(non_camel_case_types)] pub struct Return_U32_BIN { - pub command_handle: u32, + pub command_handle: CommandHandle, receiver: Receiver<(u32, Vec)>, } @@ -260,7 +261,7 @@ impl Return_U32_BIN { }) } - pub fn get_callback(&self) -> extern fn (command_handle: u32, arg1: u32, *const u8, u32) { + pub fn get_callback(&self) -> extern fn (command_handle: CommandHandle, arg1: u32, *const u8, u32) { callback::call_cb_u32_bin } @@ -273,7 +274,7 @@ impl Return_U32_BIN { #[allow(non_camel_case_types)] pub struct Return_U32_OPTSTR_BIN { - pub command_handle: u32, + pub command_handle: CommandHandle, receiver: Receiver<(u32, Option, Vec)>, } @@ -292,7 +293,7 @@ impl Return_U32_OPTSTR_BIN { }) } - pub fn get_callback(&self) -> extern fn (command_handle: u32, arg1: u32, arg2: *const c_char, arg3: *const u8, arg4: u32) { + pub fn get_callback(&self) -> extern fn (command_handle: CommandHandle, arg1: u32, arg2: *const c_char, arg3: *const u8, arg4: u32) { callback::call_cb_u32_str_bin } @@ -306,7 +307,7 @@ impl Return_U32_OPTSTR_BIN { #[allow(non_camel_case_types)] pub struct Return_U32_U32_STR_STR_STR { - pub command_handle: u32, + pub command_handle: CommandHandle, receiver: Receiver<(u32, u32, Option, Option, Option)>, } @@ -325,7 +326,7 @@ impl Return_U32_U32_STR_STR_STR { }) } - pub fn get_callback(&self) -> extern fn(command_handle: u32, arg1: u32, arg2: u32, arg3: *const c_char, arg4: *const c_char, arg5: *const c_char) { + pub fn get_callback(&self) -> extern fn(command_handle: CommandHandle, arg1: u32, arg2: u32, arg3: *const c_char, arg4: *const c_char, arg5: *const c_char) { callback::call_cb_u32_u32_str_str_str } diff --git a/vcx/libvcx/src/api/schema.rs b/vcx/libvcx/src/api/schema.rs index 340bd3278e..12dfc04f88 100644 --- a/vcx/libvcx/src/api/schema.rs +++ b/vcx/libvcx/src/api/schema.rs @@ -7,8 +7,9 @@ use schema; use settings; use utils::threadpool::spawn; use error::prelude::*; +use indy_sys::CommandHandle; -/// Create a new Schema object that can create or look up schemas on the ledger +/// Create a new Schema object and publish correspondent record on the ledger /// /// #Params /// command_handle: command handle to map callback to user context. @@ -30,13 +31,13 @@ use error::prelude::*; /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_schema_create(command_handle: u32, +pub extern fn vcx_schema_create(command_handle: CommandHandle, source_id: *const c_char, schema_name: *const c_char, version: *const c_char, schema_data: *const c_char, - payment_handle: u32, - cb: Option) -> u32 { + _payment_handle: u32, + cb: Option) -> u32 { info!("vcx_schema_create >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -78,6 +79,8 @@ pub extern fn vcx_schema_create(command_handle: u32, /// Create a new Schema object that will be published by Endorser later. /// +/// Note that Schema can't be used for credential issuing until it will be published on the ledger. +/// /// #Params /// command_handle: command handle to map callback to user context. /// @@ -98,13 +101,13 @@ pub extern fn vcx_schema_create(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_schema_prepare_for_endorser(command_handle: u32, +pub extern fn vcx_schema_prepare_for_endorser(command_handle: CommandHandle, source_id: *const c_char, schema_name: *const c_char, version: *const c_char, schema_data: *const c_char, endorser: *const c_char, - cb: Option) -> u32 { info!("vcx_schema_prepare_for_endorser >>>"); @@ -161,9 +164,9 @@ pub extern fn vcx_schema_prepare_for_endorser(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_schema_serialize(command_handle: u32, +pub extern fn vcx_schema_serialize(command_handle: CommandHandle, schema_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_schema_serialize >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -209,9 +212,9 @@ pub extern fn vcx_schema_serialize(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_schema_deserialize(command_handle: u32, +pub extern fn vcx_schema_deserialize(command_handle: CommandHandle, schema_data: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_schema_deserialize >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -251,7 +254,7 @@ pub extern fn vcx_schema_release(schema_handle: u32) -> u32 { let source_id = schema::get_source_id(schema_handle).unwrap_or_default(); match schema::release(schema_handle) { - Ok(_) => { + Ok(()) => { trace!("vcx_schema_release(schema_handle: {}, rc: {}), source_id: {}", schema_handle, error::SUCCESS.message, source_id); error::SUCCESS.code_num @@ -274,9 +277,9 @@ pub extern fn vcx_schema_release(schema_handle: u32) -> u32 { /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_schema_get_schema_id(command_handle: u32, +pub extern fn vcx_schema_get_schema_id(command_handle: CommandHandle, schema_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_schema_get_schema_id >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -318,13 +321,16 @@ pub extern fn vcx_schema_get_schema_id(command_handle: u32, /// and it will also contain a json string representing all of the data of a /// schema already on the ledger. /// +/// # Example +/// schema -> {"data":["height","name","sex","age"],"name":"test-licence","payment_txn":null,"schema_id":"2hoqvcwupRTUNkXn6ArYzs:2:test-licence:4.4.4","source_id":"Test Source ID","state":1,"version":"4.4.4"} +/// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_schema_get_attributes(command_handle: u32, +pub extern fn vcx_schema_get_attributes(command_handle: CommandHandle, source_id: *const c_char, schema_id: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_schema_get_attributes >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -375,9 +381,9 @@ pub extern fn vcx_schema_get_attributes(command_handle: u32, /// ] /// } #[no_mangle] -pub extern fn vcx_schema_get_payment_txn(command_handle: u32, +pub extern fn vcx_schema_get_payment_txn(command_handle: CommandHandle, handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_schema_get_payment_txn >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -416,7 +422,7 @@ pub extern fn vcx_schema_get_payment_txn(command_handle: u32, error::SUCCESS.code_num } -/// Checks if schema is published on the Ledger and updates the the state +/// Checks if schema is published on the Ledger and updates the state /// /// #Params /// command_handle: command handle to map callback to user context. @@ -424,13 +430,16 @@ pub extern fn vcx_schema_get_payment_txn(command_handle: u32, /// schema_handle: Schema handle that was provided during creation. Used to access schema object /// /// cb: Callback that provides most current state of the schema and error status of request +/// States: +/// 0 = Built +/// 1 = Published /// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_schema_update_state(command_handle: u32, +pub extern fn vcx_schema_update_state(command_handle: CommandHandle, schema_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_schema_update_state >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -471,13 +480,16 @@ pub extern fn vcx_schema_update_state(command_handle: u32, /// schema_handle: Schema handle that was provided during creation. Used to access schema object /// /// cb: Callback that provides most current state of the schema and error status of request +/// States: +/// 0 = Built +/// 1 = Published /// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_schema_get_state(command_handle: u32, +pub extern fn vcx_schema_get_state(command_handle: CommandHandle, schema_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_schema_get_state >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -560,7 +572,7 @@ mod tests { 0, Some(cb.get_callback())), error::SUCCESS.code_num); - let handle = cb.receive(Some(Duration::from_secs(5))).unwrap(); + let _handle = cb.receive(Some(Duration::from_secs(5))).unwrap(); } #[cfg(feature = "pool_tests")] @@ -575,7 +587,7 @@ mod tests { CString::new(schema_id).unwrap().into_raw(), Some(cb.get_callback())), error::SUCCESS.code_num); - let (err, attrs) = cb.receive(Some(Duration::from_secs(2))).unwrap(); + let (_err, attrs) = cb.receive(Some(Duration::from_secs(2))).unwrap(); let mut result_vec = vec!(attrs.clone().unwrap()); let mut expected_vec = vec!(DEFAULT_SCHEMA_ATTRS); assert_eq!(result_vec.sort(), expected_vec.sort()); @@ -636,7 +648,7 @@ mod tests { CString::new("Test Source ID").unwrap().into_raw(), CString::new(SCHEMA_ID).unwrap().into_raw(), Some(cb.get_callback())), error::SUCCESS.code_num); - let (handle, schema_data_as_string) = cb.receive(Some(Duration::from_secs(2))).unwrap(); + let (_handle, schema_data_as_string) = cb.receive(Some(Duration::from_secs(2))).unwrap(); let schema_data_as_string = schema_data_as_string.unwrap(); let schema_as_json: serde_json::Value = serde_json::from_str(&schema_data_as_string).unwrap(); assert_eq!(schema_as_json["data"].to_string(), data); @@ -648,7 +660,7 @@ mod tests { let cb = return_types_u32::Return_U32_STR::new().unwrap(); let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); let handle = schema::create_and_publish_schema("testid", did, "name".to_string(), "1.0".to_string(), "[\"name\":\"male\"]".to_string()).unwrap(); - let rc = vcx_schema_get_payment_txn(cb.command_handle, handle, Some(cb.get_callback())); + let _rc = vcx_schema_get_payment_txn(cb.command_handle, handle, Some(cb.get_callback())); let txn = cb.receive(Some(Duration::from_secs(2))).unwrap(); assert!(txn.is_some()); } @@ -703,7 +715,7 @@ mod tests { CString::new("[att1, att2]").unwrap().into_raw(), CString::new("V4SGRU86Z58d6TV7PBUe6f").unwrap().into_raw(), Some(cb.get_callback())), error::SUCCESS.code_num); - let (handle, schema_transaction) = cb.receive(Some(Duration::from_secs(2))).unwrap(); + let (_handle, schema_transaction) = cb.receive(Some(Duration::from_secs(2))).unwrap(); let schema_transaction = schema_transaction.unwrap(); let schema_transaction: serde_json::Value = serde_json::from_str(&schema_transaction).unwrap(); let expected_schema_transaction: serde_json::Value = serde_json::from_str(::utils::constants::REQUEST_WITH_ENDORSER).unwrap(); @@ -717,17 +729,17 @@ mod tests { let (handle, _) = schema::prepare_schema_for_endorser("testid", did, "name".to_string(), "1.0".to_string(), "[\"name\":\"male\"]".to_string(), "V4SGRU86Z58d6TV7PBUe6f".to_string()).unwrap(); { let cb = return_types_u32::Return_U32_U32::new().unwrap(); - let rc = vcx_schema_get_state(cb.command_handle, handle, Some(cb.get_callback())); + let _rc = vcx_schema_get_state(cb.command_handle, handle, Some(cb.get_callback())); assert_eq!(cb.receive(Some(Duration::from_secs(10))).unwrap(), ::api::PublicEntityStateType::Built as u32) } { let cb = return_types_u32::Return_U32_U32::new().unwrap(); - let rc = vcx_schema_update_state(cb.command_handle, handle, Some(cb.get_callback())); + let _rc = vcx_schema_update_state(cb.command_handle, handle, Some(cb.get_callback())); assert_eq!(cb.receive(Some(Duration::from_secs(10))).unwrap(), ::api::PublicEntityStateType::Published as u32); } { let cb = return_types_u32::Return_U32_U32::new().unwrap(); - let rc = vcx_schema_get_state(cb.command_handle, handle, Some(cb.get_callback())); + let _rc = vcx_schema_get_state(cb.command_handle, handle, Some(cb.get_callback())); assert_eq!(cb.receive(Some(Duration::from_secs(10))).unwrap(), ::api::PublicEntityStateType::Published as u32) } } diff --git a/vcx/libvcx/src/api/utils.rs b/vcx/libvcx/src/api/utils.rs index 1065e893bb..d897aec826 100644 --- a/vcx/libvcx/src/api/utils.rs +++ b/vcx/libvcx/src/api/utils.rs @@ -10,6 +10,7 @@ use utils::threadpool::spawn; use utils::libindy::payments; use std::thread; use error::prelude::*; +use indy_sys::CommandHandle; #[derive(Deserialize, Debug, Clone)] pub struct UpdateAgentInfo { @@ -67,9 +68,9 @@ pub extern fn vcx_provision_agent(config: *const c_char) -> *mut c_char { /// #Returns /// Configuration (wallet also populated), on error returns NULL #[no_mangle] -pub extern fn vcx_agent_provision_async(command_handle: u32, +pub extern fn vcx_agent_provision_async(command_handle: CommandHandle, config: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_agent_provision_async >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -105,12 +106,14 @@ pub extern fn vcx_agent_provision_async(command_handle: u32, /// /// cb: Callback that provides configuration or error status /// +/// # Example json -> "{"id":"123","value":"value"}" +/// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_agent_update_info(command_handle: u32, +pub extern fn vcx_agent_update_info(command_handle: CommandHandle, json: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_agent_update_info >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -128,7 +131,7 @@ pub extern fn vcx_agent_update_info(command_handle: u32, spawn(move || { match messages::agent_utils::update_agent_info(&agent_info.id, &agent_info.value) { - Ok(x) => { + Ok(()) => { trace!("vcx_agent_update_info_cb(command_handle: {}, rc: {})", command_handle, error::SUCCESS.message); cb(command_handle, error::SUCCESS.code_num); @@ -146,18 +149,20 @@ pub extern fn vcx_agent_update_info(command_handle: u32, error::SUCCESS.code_num } -/// Get ledger fees from the sovrin network +/// Get ledger fees from the network /// /// #Params /// command_handle: command handle to map callback to user context. /// /// cb: Callback that provides the fee structure for the sovrin network /// +/// # Example fees -> "{ "txnType1": amount1, "txnType2": amount2, ..., "txnTypeN": amountN }" +/// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_ledger_get_fees(command_handle: u32, - cb: Option) -> u32 { +pub extern fn vcx_ledger_get_fees(command_handle: CommandHandle, + cb: Option) -> u32 { info!("vcx_ledger_get_fees >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -207,26 +212,43 @@ pub extern fn vcx_set_next_agency_response(message_index: u32) { httpclient::set_next_u8_response(message); } -/// Retrieve messages from the specified connection +/// Retrieve messages from the agent /// /// #params /// /// command_handle: command handle to map callback to user context. /// -/// message_status: optional - query for messages with the specified status +/// message_status: optional, comma separated - - query for messages with the specified status. +/// Statuses: +/// MS-101 - Created +/// MS-102 - Sent +/// MS-103 - Received +/// MS-104 - Accepted +/// MS-105 - Rejected +/// MS-106 - Reviewed /// /// uids: optional, comma separated - query for messages with the specified uids /// +/// pw_dids: optional, comma separated - DID's pointing to specific connection +/// /// cb: Callback that provides array of matching messages retrieved /// +/// # Example message_status -> MS-103, MS-106 +/// +/// # Example uids -> s82g63, a2h587 +/// +/// # Example pw_dids -> did1, did2 +/// +/// # Example messages -> "[{"pairwiseDID":"did","msgs":[{"statusCode":"MS-106","payload":null,"senderDID":"","uid":"6BDkgc3z0E","type":"aries","refMsgId":null,"deliveryDetails":[],"decryptedPayload":"{"@msg":".....","@type":{"fmt":"json","name":"aries","ver":"1.0"}}"}]}]" +/// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_messages_download(command_handle: u32, +pub extern fn vcx_messages_download(command_handle: CommandHandle, message_status: *const c_char, uids: *const c_char, pw_dids: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_messages_download >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -301,7 +323,14 @@ pub extern fn vcx_messages_download(command_handle: u32, /// /// command_handle: command handle to map callback to user context. /// -/// message_status: updated status +/// message_status: target message status +/// Statuses: +/// MS-101 - Created +/// MS-102 - Sent +/// MS-103 - Received +/// MS-104 - Accepted +/// MS-105 - Rejected +/// MS-106 - Reviewed /// /// msg_json: messages to update: [{"pairwiseDID":"QSrw8hebcvQxiwBETmAaRs","uids":["mgrmngq"]},...] /// @@ -310,10 +339,10 @@ pub extern fn vcx_messages_download(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_messages_update_status(command_handle: u32, +pub extern fn vcx_messages_update_status(command_handle: CommandHandle, message_status: *const c_char, msg_json: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_messages_update_status >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -325,7 +354,7 @@ pub extern fn vcx_messages_update_status(command_handle: u32, spawn(move || { match ::messages::update_message::update_agency_messages(&message_status, &msg_json) { - Ok(_) => { + Ok(()) => { trace!("vcx_messages_set_status_cb(command_handle: {}, rc: {})", command_handle, error::SUCCESS.message); @@ -380,10 +409,10 @@ pub extern fn vcx_pool_set_handle(handle: i32) -> i32 { /// # Return /// "price": u64 - tokens amount required for action performing #[no_mangle] -pub extern fn vcx_get_request_price(command_handle: u32, +pub extern fn vcx_get_request_price(command_handle: CommandHandle, action_json: *const c_char, requester_info_json: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_get_request_price >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -424,9 +453,9 @@ pub extern fn vcx_get_request_price(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_endorse_transaction(command_handle: u32, +pub extern fn vcx_endorse_transaction(command_handle: CommandHandle, transaction: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_endorse_transaction >>>"); check_useful_c_str!(transaction, VcxErrorKind::InvalidOption); @@ -436,7 +465,7 @@ pub extern fn vcx_endorse_transaction(command_handle: u32, spawn(move || { match ::utils::libindy::ledger::endorse_transaction(&transaction) { - Ok(x) => { + Ok(()) => { trace!("vcx_endorse_transaction(command_handle: {}, rc: {})", command_handle, error::SUCCESS.message); @@ -534,7 +563,7 @@ mod tests { let c_json = CString::new(json_string).unwrap().into_raw(); let cb = return_types_u32::Return_U32::new().unwrap(); - let result = vcx_agent_update_info(cb.command_handle, c_json, Some(cb.get_callback())); + let _result = vcx_agent_update_info(cb.command_handle, c_json, Some(cb.get_callback())); cb.receive(Some(Duration::from_secs(10))).unwrap(); } diff --git a/vcx/libvcx/src/api/vcx.rs b/vcx/libvcx/src/api/vcx.rs index 4dd9192b8f..b7a03cc6f4 100644 --- a/vcx/libvcx/src/api/vcx.rs +++ b/vcx/libvcx/src/api/vcx.rs @@ -7,6 +7,7 @@ use settings; use std::ffi::CString; use utils::threadpool::spawn; use error::prelude::*; +use indy::{INVALID_WALLET_HANDLE, CommandHandle}; /// Initializes VCX with config settings /// @@ -15,16 +16,17 @@ use error::prelude::*; /// #Params /// command_handle: command handle to map callback to user context. /// -/// config_path: path to a config file to populate config attributes +/// config: config as json. +/// The list of available options see here: https://github.com/hyperledger/indy-sdk/blob/master/docs/configuration.md /// /// cb: Callback that provides error status of initialization /// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_init_with_config(command_handle: u32, +pub extern fn vcx_init_with_config(command_handle: CommandHandle, config: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_init_with_config >>>"); check_useful_c_str!(config,VcxErrorKind::InvalidOption); @@ -52,6 +54,7 @@ pub extern fn vcx_init_with_config(command_handle: u32, /// Initializes VCX with config file /// /// An example file is at libvcx/sample_config/config.json +/// The list of available options see here: https://github.com/hyperledger/indy-sdk/blob/master/docs/configuration.md /// /// #Params /// command_handle: command handle to map callback to user context. @@ -63,9 +66,9 @@ pub extern fn vcx_init_with_config(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_init(command_handle: u32, +pub extern fn vcx_init(command_handle: CommandHandle, config_path: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_init >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -82,7 +85,7 @@ pub extern fn vcx_init(command_handle: u32, settings::set_defaults(); } else { match settings::process_config_file(&config_path) { - Err(e) => { + Err(_) => { return VcxError::from_msg(VcxErrorKind::InvalidConfiguration, "Cannot initialize with given config path.").into(); } Ok(_) => { @@ -101,12 +104,12 @@ pub extern fn vcx_init(command_handle: u32, _finish_init(command_handle, cb) } -fn _finish_init(command_handle: u32, cb: extern fn(xcommand_handle: u32, err: u32)) -> u32 { +fn _finish_init(command_handle: CommandHandle, cb: extern fn(xcommand_handle: CommandHandle, err: u32)) -> u32 { ::utils::threadpool::init(); settings::log_settings(); - if wallet::get_wallet_handle() > 0 { + if wallet::get_wallet_handle() != INVALID_WALLET_HANDLE { error!("Library was already initialized"); return VcxError::from_msg(VcxErrorKind::AlreadyInitialized, "Library was already initialized").into(); } @@ -129,7 +132,7 @@ fn _finish_init(command_handle: u32, cb: extern fn(xcommand_handle: u32, err: u3 spawn(move || { if settings::get_config_value(settings::CONFIG_GENESIS_PATH).is_ok() { match ::utils::libindy::init_pool() { - Ok(_) => (), + Ok(()) => (), Err(e) => { error!("Init Pool Error {}.", e); cb(command_handle, e.into()); @@ -158,10 +161,9 @@ fn _finish_init(command_handle: u32, cb: extern fn(xcommand_handle: u32, err: u3 /// Initialize vcx with the minimal configuration (wallet, pool must already be set with /// vcx_wallet_set_handle() and vcx_pool_set_handle()) and without any agency configuration /// -/// #Example: -/// -/// vcx_init_minimal('{"institution_name":"faber","institution_did":"44x8p4HubxzUK1dwxcc5FU",\ -// "institution_verkey":"444MFrZjXDoi2Vc8Mm14Ys112tEZdDegBZZoembFEATE"}') +/// # Example: +/// vcx_init_minimal -> '{"institution_name":"faber","institution_did":"44x8p4HubxzUK1dwxcc5FU",\ +// "institution_verkey":"444MFrZjXDoi2Vc8Mm14Ys112tEZdDegBZZoembFEATE"}' /// /// #Params /// @@ -188,7 +190,7 @@ pub extern fn vcx_init_minimal(config: *const c_char) -> u32 { } }; - if wallet::get_wallet_handle() <= 0 || pool::get_pool_handle().is_err() { + if wallet::get_wallet_handle() == INVALID_WALLET_HANDLE || pool::get_pool_handle().is_err() { error!("Library cannot be initialized without wallet/pool"); return error::INVALID_STATE.code_num; } @@ -227,12 +229,12 @@ pub extern fn vcx_shutdown(delete: bool) -> u32 { trace!("vcx_shutdown(delete: {})", delete); match wallet::close_wallet() { - Ok(_) => {} + Ok(()) => {} Err(_) => {} }; match pool::close() { - Ok(_) => {} + Ok(()) => {} Err(_) => {} }; @@ -254,12 +256,12 @@ pub extern fn vcx_shutdown(delete: bool) -> u32 { let wallet_type = settings::get_config_value(settings::CONFIG_WALLET_TYPE).ok(); match wallet::delete_wallet(&wallet_name, wallet_type.as_ref().map(String::as_str), None, None) { - Ok(_) => (), + Ok(()) => (), Err(_) => (), }; match pool::delete(&pool_name) { - Ok(_) => (), + Ok(()) => (), Err(_) => (), }; } @@ -269,6 +271,13 @@ pub extern fn vcx_shutdown(delete: bool) -> u32 { error::SUCCESS.code_num } +/// Get the message corresponding to an error code +/// +/// #Params +/// error_code: code of error +/// +/// #Returns +/// Error message #[no_mangle] pub extern fn vcx_error_c_message(error_code: u32) -> *const c_char { info!("vcx_error_c_message >>>"); @@ -276,6 +285,14 @@ pub extern fn vcx_error_c_message(error_code: u32) -> *const c_char { error::error_c_message(&error_code).as_ptr() } +/// Update setting to set new local institution information +/// +/// #Params +/// name: institution name +/// logo_url: url containing institution logo +/// +/// #Returns +/// Error code as u32 #[no_mangle] pub extern fn vcx_update_institution_info(name: *const c_char, logo_url: *const c_char) -> u32 { info!("vcx_update_institution_info >>>"); @@ -310,11 +327,13 @@ pub extern fn vcx_update_webhook_url(notification_webhook_url: *const c_char) -> /// /// cb: Callback that provides array of matching messages retrieved /// +/// # Example author_agreement -> "{"text":"Default agreement", "version":"1.0.0", "aml": {"label1": "description"}}" +/// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_get_ledger_author_agreement(command_handle: u32, - cb: Option) -> u32 { +pub extern fn vcx_get_ledger_author_agreement(command_handle: CommandHandle, + cb: Option) -> u32 { info!("vcx_get_ledger_author_agreement >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -346,7 +365,7 @@ pub extern fn vcx_get_ledger_author_agreement(command_handle: u32, /// Set some accepted agreement as active. /// -/// As result of succesfull call of this funciton appropriate metadata will be appended to each write request by `indy_append_txn_author_agreement_meta_to_request` libindy call. +/// As result of successful call of this function appropriate metadata will be appended to each write request. /// /// #Params /// text and version - (optional) raw data about TAA from ledger. @@ -375,7 +394,7 @@ pub extern fn vcx_set_active_txn_author_agreement_meta(text: *const c_char, text, version, hash, acc_mech_type, time_of_acceptance); match ::utils::author_agreement::set_txn_author_agreement(text, version, hash, acc_mech_type, time_of_acceptance) { - Ok(x) => error::SUCCESS.code_num, + Ok(()) => error::SUCCESS.code_num, Err(err) => err.into() } } @@ -451,8 +470,10 @@ mod tests { use api::VcxStateType; use api::return_types_u32; use api::connection::vcx_connection_create; + use indy::{WalletHandle}; - fn create_config_util(logging: Option<&str>) -> String { + #[cfg(any(feature = "agency", feature = "pool_tests"))] + fn create_config_util(_logging: Option<&str>) -> String { json!({"agency_did" : "72x8p4HubxzUK1dwxcc5FU", "remote_to_sdk_did" : "UJGjM6Cea2YVixjWwHN9wq", "sdk_to_remote_did" : "AB3JM851T4EQmhh8CdagSP", @@ -563,7 +584,7 @@ mod tests { thread::sleep(Duration::from_secs(1)); assert!(rc.is_err()); assert_eq!(get_pool_handle().unwrap_err().kind(), VcxErrorKind::NoPoolOpen); - assert_eq!(wallet::get_wallet_handle(), 0); + assert_eq!(wallet::get_wallet_handle(), INVALID_WALLET_HANDLE); wallet::delete_wallet(wallet_name, None, None, None).unwrap(); } @@ -620,7 +641,7 @@ mod tests { CString::new(content).unwrap().into_raw(), Some(cb.get_callback())), error::SUCCESS.code_num); - let err = cb.receive(Some(Duration::from_secs(10))); + let _err = cb.receive(Some(Duration::from_secs(10))); // Assert default wallet name assert_eq!(settings::get_config_value(settings::CONFIG_WALLET_NAME).unwrap(), settings::DEFAULT_WALLET_NAME); } @@ -839,7 +860,7 @@ mod tests { error::INVALID_OPTION.code_num); match get_pool_handle() { - Ok(h) => { pool::close().unwrap(); } + Ok(_h) => { pool::close().unwrap(); } Err(_) => {} }; } @@ -882,7 +903,7 @@ mod tests { assert_eq!(::credential_def::release(credentialdef).unwrap_err().kind(), VcxErrorKind::InvalidCredDefHandle); assert_eq!(::credential::release(credential).unwrap_err().kind(), VcxErrorKind::InvalidCredentialHandle); assert_eq!(::disclosed_proof::release(disclosed_proof).unwrap_err().kind(), VcxErrorKind::InvalidDisclosedProofHandle); - assert_eq!(wallet::get_wallet_handle(), 0); + assert_eq!(wallet::get_wallet_handle(), INVALID_WALLET_HANDLE); } #[test] @@ -978,9 +999,9 @@ mod tests { #[test] fn get_current_error_works_for_async_error() { - extern fn cb(storage_handle: u32, - err: u32, - config: *const c_char) { + extern fn cb(_storage_handle: i32, + _err: u32, + _config: *const c_char) { let mut error_json_p: *const c_char = ptr::null(); vcx_get_current_error(&mut error_json_p); assert!(CStringUtils::c_str_to_string(error_json_p).unwrap().is_some()); @@ -1032,6 +1053,7 @@ mod tests { assert_eq!(::utils::constants::DEFAULT_AUTHOR_AGREEMENT, agreement.unwrap()); } + #[cfg(feature = "pool_tests")] fn get_settings() -> String { json!({ settings::CONFIG_AGENCY_DID: settings::get_config_value(settings::CONFIG_AGENCY_DID).unwrap(), @@ -1051,6 +1073,7 @@ mod tests { #[cfg(feature = "pool_tests")] #[test] fn test_init_minimal() { + use indy_sys::INVALID_POOL_HANDLE; init!("ledger"); let content = get_settings(); settings::clear_config(); @@ -1058,11 +1081,11 @@ mod tests { let config = CString::new(content).unwrap().into_raw(); let wallet_handle = ::utils::libindy::wallet::get_wallet_handle(); let pool_handle = ::utils::libindy::pool::get_pool_handle().unwrap(); - assert!(wallet_handle > 0); - assert!(pool_handle > 0); + assert_ne!(wallet_handle, INVALID_WALLET_HANDLE); + assert_ne!(pool_handle, INVALID_POOL_HANDLE); // Reset handles to 0 - assert_eq!(::api::utils::vcx_pool_set_handle(0), 0); - assert_eq!(::api::wallet::vcx_wallet_set_handle(0), 0); + assert_eq!(::api::utils::vcx_pool_set_handle(INVALID_POOL_HANDLE), INVALID_POOL_HANDLE); + assert_eq!(::api::wallet::vcx_wallet_set_handle(INVALID_WALLET_HANDLE), INVALID_WALLET_HANDLE); // Test for errors when handles not set assert_ne!(error::SUCCESS.code_num, vcx_init_minimal(config)); ::api::wallet::vcx_wallet_set_handle(wallet_handle); @@ -1082,7 +1105,7 @@ mod tests { "institution_did": "44x8p4HubxzUK1dwxcc5FU", "institution_verkey": "444MFrZjXDoi2Vc8Mm14Ys112tEZdDegBZZoembFEATE"}).to_string(); let config = CString::new(config).unwrap().into_raw(); - ::api::wallet::vcx_wallet_set_handle(1); + ::api::wallet::vcx_wallet_set_handle(WalletHandle(1)); ::api::utils::vcx_pool_set_handle(1); assert_eq!(vcx_init_minimal(config), error::SUCCESS.code_num); @@ -1104,7 +1127,7 @@ mod tests { "institution_did": "44x8p4HubxzUK1dwxcc5FU", "institution_verkey": "444MFrZjXDoi2Vc8Mm14Ys112tEZdDegBZZoembFEATE"}).to_string(); let config = CString::new(config).unwrap().into_raw(); - ::api::wallet::vcx_wallet_set_handle(1); + ::api::wallet::vcx_wallet_set_handle(WalletHandle(1)); ::api::utils::vcx_pool_set_handle(1); assert_eq!(vcx_init_minimal(config), error::SUCCESS.code_num); let rc = vcx_connection_create(0, diff --git a/vcx/libvcx/src/api/wallet.rs b/vcx/libvcx/src/api/wallet.rs index 963605a418..3618f084e6 100644 --- a/vcx/libvcx/src/api/wallet.rs +++ b/vcx/libvcx/src/api/wallet.rs @@ -9,6 +9,7 @@ use utils::threadpool::spawn; use std::thread; use std::ptr::null; use error::prelude::*; +use indy::{CommandHandle, SearchHandle, WalletHandle}; /// Get the total balance from all addresses contained in the configured wallet /// @@ -20,12 +21,14 @@ use error::prelude::*; /// /// cb: Callback that provides wallet balance /// +/// # Example info -> "{"balance":6,"balance_str":"6","addresses":[{"address":"pay:null:9UFgyjuJxi1i1HD","balance":3,"utxo":[{"source":"pay:null:1","paymentAddress":"pay:null:zR3GN9lfbCVtHjp","amount":1,"extra":"yqeiv5SisTeUGkw"}]}]}" +/// /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_wallet_get_token_info(command_handle: u32, +pub extern fn vcx_wallet_get_token_info(command_handle: CommandHandle, payment_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_wallet_get_token_info >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -62,12 +65,14 @@ pub extern fn vcx_wallet_get_token_info(command_handle: u32, /// /// cb: Callback that provides payment address info /// +/// # Example payment_address -> "pay:null:9UFgyjuJxi1i1HD" +/// /// #Returns /// Error code as u32 #[no_mangle] -pub extern fn vcx_wallet_create_payment_address(command_handle: u32, +pub extern fn vcx_wallet_create_payment_address(command_handle: CommandHandle, seed: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_wallet_create_payment_address >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -118,11 +123,11 @@ pub extern fn vcx_wallet_create_payment_address(command_handle: u32, /// # Returns: /// a signature string #[no_mangle] -pub extern fn vcx_wallet_sign_with_address(command_handle: u32, +pub extern fn vcx_wallet_sign_with_address(command_handle: CommandHandle, payment_address: *const c_char, message_raw: *const u8, message_len: u32, - cb: Option) -> u32 { info!("vcx_wallet_sign_with_address >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -171,13 +176,13 @@ pub extern fn vcx_wallet_sign_with_address(command_handle: u32, /// #Returns /// valid: true - if signature is valid, false - otherwise #[no_mangle] -pub extern fn vcx_wallet_verify_with_address(command_handle: u32, +pub extern fn vcx_wallet_verify_with_address(command_handle: CommandHandle, payment_address: *const c_char, message_raw: *const u8, message_len: u32, signature_raw: *const u8, signature_len: u32, - cb: Option) -> u32 { info!("vcx_wallet_sign_with_address >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -238,12 +243,12 @@ pub extern fn vcx_wallet_verify_with_address(command_handle: u32, /// Error code as a u32 /// #[no_mangle] -pub extern fn vcx_wallet_add_record(command_handle: u32, +pub extern fn vcx_wallet_add_record(command_handle: CommandHandle, type_: *const c_char, id: *const c_char, value: *const c_char, tags_json: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_wallet_add_record >>>"); check_useful_c_str!(type_, VcxErrorKind::InvalidOption); @@ -257,7 +262,7 @@ pub extern fn vcx_wallet_add_record(command_handle: u32, spawn(move || { match wallet::add_record(&type_, &id, &value, Some(&tags_json)) { - Ok(x) => { + Ok(()) => { trace!("vcx_wallet_add_record(command_handle: {}, rc: {})", command_handle, error::SUCCESS.message); @@ -295,11 +300,11 @@ pub extern fn vcx_wallet_add_record(command_handle: u32, /// Error code as a u32 /// #[no_mangle] -pub extern fn vcx_wallet_update_record_value(command_handle: u32, +pub extern fn vcx_wallet_update_record_value(command_handle: CommandHandle, type_: *const c_char, id: *const c_char, value: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_wallet_update_record_value >>>"); check_useful_c_str!(type_, VcxErrorKind::InvalidOption); @@ -312,7 +317,7 @@ pub extern fn vcx_wallet_update_record_value(command_handle: u32, spawn(move || { match wallet::update_record_value(&type_, &id, &value) { - Ok(x) => { + Ok(()) => { trace!("vcx_wallet_update_record_value(command_handle: {}, rc: {})", command_handle, error::SUCCESS.message); @@ -350,11 +355,11 @@ pub extern fn vcx_wallet_update_record_value(command_handle: u32, /// Error code as a u32 /// #[no_mangle] -pub extern fn vcx_wallet_update_record_tags(command_handle: u32, +pub extern fn vcx_wallet_update_record_tags(command_handle: CommandHandle, type_: *const c_char, id: *const c_char, tags: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_wallet_update_record_tags >>>"); check_useful_c_str!(type_, VcxErrorKind::InvalidOption); @@ -392,11 +397,11 @@ pub extern fn vcx_wallet_update_record_tags(command_handle: u32, /// Error code as a u32 /// #[no_mangle] -pub extern fn vcx_wallet_add_record_tags(command_handle: u32, +pub extern fn vcx_wallet_add_record_tags(command_handle: CommandHandle, type_: *const c_char, id: *const c_char, tags: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_wallet_add_record_tags >>>"); check_useful_c_str!(type_, VcxErrorKind::InvalidOption); @@ -433,11 +438,11 @@ pub extern fn vcx_wallet_add_record_tags(command_handle: u32, /// Error code as a u32 /// #[no_mangle] -pub extern fn vcx_wallet_delete_record_tags(command_handle: u32, +pub extern fn vcx_wallet_delete_record_tags(command_handle: CommandHandle, type_: *const c_char, id: *const c_char, tags: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_wallet_delete_record_tags >>>"); check_useful_c_str!(type_, VcxErrorKind::InvalidOption); @@ -473,11 +478,11 @@ pub extern fn vcx_wallet_delete_record_tags(command_handle: u32, /// Error will be a libindy error code /// #[no_mangle] -pub extern fn vcx_wallet_get_record(command_handle: u32, +pub extern fn vcx_wallet_get_record(command_handle: CommandHandle, type_: *const c_char, id: *const c_char, options_json: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_wallet_get_record >>>"); check_useful_c_str!(type_, VcxErrorKind::InvalidOption); @@ -530,10 +535,10 @@ pub extern fn vcx_wallet_get_record(command_handle: u32, /// Error will be a libindy error code /// #[no_mangle] -pub extern fn vcx_wallet_delete_record(command_handle: u32, +pub extern fn vcx_wallet_delete_record(command_handle: CommandHandle, type_: *const c_char, id: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_wallet_delete_record >>>"); check_useful_c_str!(type_, VcxErrorKind::InvalidOption); @@ -545,7 +550,7 @@ pub extern fn vcx_wallet_delete_record(command_handle: u32, spawn(move || { match wallet::delete_record(&type_, &id) { - Ok(x) => { + Ok(()) => { trace!("vcx_wallet_delete_record(command_handle: {}, rc: {})", command_handle, error::SUCCESS.message); @@ -583,11 +588,11 @@ pub extern fn vcx_wallet_delete_record(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_wallet_send_tokens(command_handle: u32, +pub extern fn vcx_wallet_send_tokens(command_handle: CommandHandle, payment_handle: u32, tokens: *const c_char, recipient: *const c_char, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_wallet_send_tokens >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -603,7 +608,7 @@ pub extern fn vcx_wallet_send_tokens(command_handle: u32, spawn(move || { match pay_a_payee(tokens, &recipient) { - Ok((payment, msg)) => { + Ok((_payment, msg)) => { trace!("vcx_wallet_send_tokens_cb(command_handle: {}, rc: {}, receipt: {})", command_handle, error::SUCCESS.message, msg); let msg = CStringUtils::string_to_cstring(msg); @@ -652,12 +657,12 @@ pub extern fn vcx_wallet_send_tokens(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_wallet_open_search(command_handle: i32, - type_: *const c_char, - query_json: *const c_char, - options_json: *const c_char, - cb: Option) -> u32 { +pub extern fn vcx_wallet_open_search(command_handle: CommandHandle, + _type_: *const c_char, + _query_json: *const c_char, + _options_json: *const c_char, + cb: Option) -> u32 { info!("vcx_wallet_open_search >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -692,10 +697,10 @@ pub extern fn vcx_wallet_open_search(command_handle: i32, /// }], /// } #[no_mangle] -pub extern fn vcx_wallet_search_next_records(command_handle: i32, +pub extern fn vcx_wallet_search_next_records(command_handle: CommandHandle, wallet_search_handle: i32, - count: usize, - cb: Option) -> u32 { info!("vcx_wallet_search_next_records >>>"); @@ -727,9 +732,9 @@ pub extern fn vcx_wallet_search_next_records(command_handle: i32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn vcx_wallet_close_search(command_handle: u32, +pub extern fn vcx_wallet_close_search(command_handle: CommandHandle, search_handle: u32, - cb: Option) -> u32 { + cb: Option) -> u32 { info!("vcx_wallet_close_search >>>"); check_useful_c_callback!(cb, VcxErrorKind::InvalidOption); @@ -760,10 +765,10 @@ pub extern fn vcx_wallet_close_search(command_handle: u32, /// Error code - success indicates that the api call was successfully created and execution /// is scheduled to begin in a separate thread. #[no_mangle] -pub extern fn vcx_wallet_export(command_handle: u32, +pub extern fn vcx_wallet_export(command_handle: CommandHandle, path: *const c_char, backup_key: *const c_char, - cb: Option) -> u32 { info!("vcx_wallet_export >>>"); @@ -779,7 +784,7 @@ pub extern fn vcx_wallet_export(command_handle: u32, let path = Path::new(&path); trace!("vcx_wallet_export(command_handle: {}, path: {:?}, backup_key: ****)", command_handle, path); match export(get_wallet_handle(), &path, &backup_key) { - Ok(_) => { + Ok(()) => { let return_code = error::SUCCESS.code_num; trace!("vcx_wallet_export(command_handle: {}, rc: {})", command_handle, return_code); cb(command_handle, return_code); @@ -812,9 +817,9 @@ pub extern fn vcx_wallet_export(command_handle: u32, /// Error code - success indicates that the api call was successfully created and execution /// is scheduled to begin in a separate thread. #[no_mangle] -pub extern fn vcx_wallet_import(command_handle: u32, +pub extern fn vcx_wallet_import(command_handle: CommandHandle, config: *const c_char, - cb: Option) -> u32 { info!("vcx_wallet_import >>>"); @@ -827,7 +832,7 @@ pub extern fn vcx_wallet_import(command_handle: u32, thread::spawn(move || { trace!("vcx_wallet_import(command_handle: {}, config: ****)", command_handle); match import(&config) { - Ok(_) => { + Ok(()) => { trace!("vcx_wallet_import(command_handle: {}, rc: {})", command_handle, error::SUCCESS.message); cb(command_handle, error::SUCCESS.code_num); } @@ -883,7 +888,7 @@ pub extern fn vcx_wallet_validate_payment_address(command_handle: i32, /// #Returns /// Error code as u32 #[no_mangle] -pub extern fn vcx_wallet_set_handle(handle: i32) -> i32 { +pub extern fn vcx_wallet_set_handle(handle: WalletHandle) -> WalletHandle { wallet::set_wallet_handle(handle) } @@ -962,7 +967,6 @@ pub mod tests { let sig = "signature"; let sig_len = sig.len(); let sig_raw = CString::new(sig).unwrap(); - let res = true; assert_eq!(vcx_wallet_verify_with_address(cb.command_handle, CString::new("address").unwrap().into_raw(), msg_raw.as_ptr() as *const u8, @@ -1095,7 +1099,6 @@ pub mod tests { init!("false"); let xtype = CStringUtils::string_to_cstring("record_type".to_string()); let id = CStringUtils::string_to_cstring("123".to_string()); - let value = CStringUtils::string_to_cstring("Record Value".to_string()); let options = json!({ "retrieveType": true, "retrieveValue": true, @@ -1155,12 +1158,6 @@ pub mod tests { let id = CStringUtils::string_to_cstring("123".to_string()); let value = CStringUtils::string_to_cstring("Record Value".to_string()); let tags = CStringUtils::string_to_cstring("{}".to_string()); - let options = json!({ - "retrieveType": true, - "retrieveValue": true, - "retrieveTags": false - }).to_string(); - let options = CStringUtils::string_to_cstring(options); // Add record let cb = return_types_u32::Return_U32::new().unwrap(); @@ -1239,12 +1236,12 @@ pub mod tests { #[test] fn test_wallet_import_export() { - use utils::devsetup::tests::setup_wallet_env; use std::env; use std::fs; use std::path::Path; use std::time::Duration; use settings; + use utils::devsetup::tests::setup_wallet_env; settings::set_defaults(); teardown!("false"); @@ -1257,7 +1254,7 @@ pub mod tests { if Path::new(&dir).exists() { fs::remove_file(Path::new(&dir)).unwrap(); } - let handle = setup_wallet_env(&wallet_name).unwrap(); + let _handle = setup_wallet_env(&wallet_name).unwrap(); let dir_c_str = CString::new(dir.to_str().unwrap()).unwrap(); let backup_key_c_str = CString::new(backup_key).unwrap(); @@ -1284,8 +1281,6 @@ pub mod tests { Some(cb.get_callback())), error::SUCCESS.code_num); cb.receive(Some(Duration::from_secs(50))).unwrap(); - let handle = setup_wallet_env(&wallet_name).unwrap(); - delete_wallet(&wallet_name, None, None, None).unwrap(); fs::remove_file(Path::new(&dir)).unwrap(); assert!(!Path::new(&dir).exists()); diff --git a/vcx/libvcx/src/connection.rs b/vcx/libvcx/src/connection.rs index 71ceb8ed05..465971461d 100644 --- a/vcx/libvcx/src/connection.rs +++ b/vcx/libvcx/src/connection.rs @@ -219,10 +219,6 @@ impl Connection { fn get_source_id(&self) -> &String { &self.source_id } - fn ready_to_connect(&self) -> bool { - self.state != VcxStateType::VcxStateNone && self.state != VcxStateType::VcxStateAccepted - } - fn create_agent_pairwise(&mut self) -> VcxResult { debug!("creating pairwise keys on agent for connection {}", self.source_id); @@ -257,7 +253,7 @@ impl Connection { Ok(error::SUCCESS.code_num) } - pub fn update_state(&mut self, message: Option) -> VcxResult { + pub fn update_state(&mut self, _message: Option) -> VcxResult { debug!("updating state for connection {}", self.source_id); if self.state == VcxStateType::VcxStateInitialized || self.state == VcxStateType::VcxStateAccepted { @@ -349,7 +345,7 @@ pub fn set_agent_did(handle: u32, did: &str) -> VcxResult<()> { CONNECTION_MAP.get_mut(handle, |connection| { match connection { Connections::V1(ref mut connection) => Ok(connection.set_agent_did(did)), - Connections::V3(ref mut connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) + Connections::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) } }).or(Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle))) } @@ -376,7 +372,7 @@ pub fn set_pw_did(handle: u32, did: &str) -> VcxResult<()> { CONNECTION_MAP.get_mut(handle, |connection| { match connection { Connections::V1(ref mut connection) => Ok(connection.set_pw_did(did)), - Connections::V3(ref mut connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) + Connections::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) } }).or(Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle))) } @@ -394,7 +390,7 @@ pub fn set_their_pw_did(handle: u32, did: &str) -> VcxResult<()> { CONNECTION_MAP.get_mut(handle, |connection| { match connection { Connections::V1(ref mut connection) => Ok(connection.set_their_pw_did(did)), - Connections::V3(ref mut connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) + Connections::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) } }).or(Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle))) } @@ -403,7 +399,7 @@ pub fn set_their_public_did(handle: u32, did: &str) -> VcxResult<()> { CONNECTION_MAP.get_mut(handle, |connection| { match connection { Connections::V1(ref mut connection) => Ok(connection.set_their_public_did(did)), - Connections::V3(ref mut connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) + Connections::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) } }).or(Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle))) } @@ -412,7 +408,7 @@ pub fn get_their_public_did(handle: u32) -> VcxResult> { CONNECTION_MAP.get(handle, |connection| { match connection { Connections::V1(ref connection) => Ok(connection.get_their_public_did()), - Connections::V3(ref connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) + Connections::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) } }).or(Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle))) } @@ -430,7 +426,7 @@ pub fn set_their_pw_verkey(handle: u32, did: &str) -> VcxResult<()> { CONNECTION_MAP.get_mut(handle, |cxn| { match cxn { Connections::V1(ref mut connection) => Ok(connection.set_their_pw_verkey(did)), - Connections::V3(ref connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) + Connections::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) } }).or(Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle))) } @@ -439,7 +435,7 @@ pub fn get_uuid(handle: u32) -> VcxResult { CONNECTION_MAP.get(handle, |cxn| { match cxn { Connections::V1(ref connection) => Ok(connection.get_uuid().to_string()), - Connections::V3(ref connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) + Connections::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) } }).or(Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle))) } @@ -448,7 +444,7 @@ pub fn set_uuid(handle: u32, uuid: &str) -> VcxResult<()> { CONNECTION_MAP.get_mut(handle, |cxn| { match cxn { Connections::V1(ref mut connection) => Ok(connection.set_uuid(uuid)), - Connections::V3(ref mut connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) + Connections::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) } }).or(Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle))) } @@ -458,7 +454,7 @@ pub fn get_endpoint(handle: u32) -> VcxResult { CONNECTION_MAP.get(handle, |cxn| { match cxn { Connections::V1(ref connection) => Ok(connection.get_endpoint().to_string()), - Connections::V3(ref connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) + Connections::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) } }).or(Err(VcxError::from(VcxErrorKind::NoEndpoint))) } @@ -467,7 +463,7 @@ pub fn set_endpoint(handle: u32, endpoint: &str) -> VcxResult<()> { CONNECTION_MAP.get_mut(handle, |cxn| { match cxn { Connections::V1(ref mut connection) => Ok(connection.set_endpoint(endpoint)), - Connections::V3(ref mut connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) + Connections::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) } }).or(Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle))) } @@ -485,7 +481,7 @@ pub fn set_agent_verkey(handle: u32, verkey: &str) -> VcxResult<()> { CONNECTION_MAP.get_mut(handle, |cxn| { match cxn { Connections::V1(ref mut connection) => Ok(connection.set_agent_verkey(verkey).clone()), - Connections::V3(ref mut connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) + Connections::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) } }).or(Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle))) } @@ -503,7 +499,7 @@ pub fn set_pw_verkey(handle: u32, verkey: &str) -> VcxResult<()> { CONNECTION_MAP.get_mut(handle, |cxn| { match cxn { Connections::V1(ref mut connection) => Ok(connection.set_pw_verkey(verkey).clone()), - Connections::V3(ref mut connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) + Connections::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) } }).or(Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle))) } @@ -523,7 +519,7 @@ pub fn set_state(handle: u32, state: VcxStateType) -> VcxResult<()> { CONNECTION_MAP.get_mut(handle, |cxn| { match cxn { Connections::V1(ref mut connection) => Ok(connection.set_state(state)), - Connections::V3(ref mut connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) + Connections::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) } }).or(Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle))) } @@ -589,7 +585,7 @@ pub fn create_connection_with_invite(source_id: &str, details: &str) -> VcxResul let invite_details: InviteDetail = match serde_json::from_value(details.clone()) { Ok(x) => x, - Err(x) => { + Err(_) => { // Try converting to abbreviated let details = unabbrv_event_detail(details)?; serde_json::from_value(details) @@ -635,7 +631,7 @@ pub fn parse_acceptance_details(message: &Message) -> VcxResult { Ok(response.sender_detail) } MessagePayload::V2(payload) => { - let payload = Payloads::decrypt_payload_v2(&my_vk, &payload)?; + let payload = Payloads::decrypt_payload_v2(&payload)?; let response: AcceptanceDetails = serde_json::from_str(&payload.msg) .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidJson, format!("Cannot deserialize AcceptanceDetails: {}", err)))?; @@ -770,7 +766,7 @@ pub fn get_invite_details(handle: u32, abbreviated: bool) -> VcxResult { Connections::V1(ref connection) => { match abbreviated { false => { - serde_json::to_string(&connection.invite_detail) + serde_json::to_string(&connection.get_invite_detail()) .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidInviteDetail, format!("Cannot serialize InviteDetail: {}", err))) } true => { @@ -796,7 +792,7 @@ pub fn set_invite_details(handle: u32, invite_detail: &InviteDetail) -> VcxResul connection.set_invite_detail(invite_detail.clone()); Ok(()) } - Connections::V3(ref mut connection) => { + Connections::V3(_) => { Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) } } @@ -960,7 +956,7 @@ pub fn decode_message(handle: u32, message: Message) -> VcxResult { pub fn send_message(handle: u32, message: A2AMessage) -> VcxResult<()> { CONNECTION_MAP.get_mut(handle, |connection| { match connection { - Connections::V1(ref mut connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)), + Connections::V1(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)), Connections::V3(ref mut connection) => connection.send_message(&message) } }) @@ -973,7 +969,7 @@ pub fn send_message_to_self_endpoint(message: A2AMessage, did_doc: &DidDoc) -> V pub fn add_pending_messages(handle: u32, messages: HashMap) -> VcxResult<()> { CONNECTION_MAP.get_mut(handle, |connection| { match connection { - Connections::V1(ref mut connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)), + Connections::V1(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)), Connections::V3(ref mut connection) => connection.add_pending_messages(messages.clone()) } }) @@ -982,7 +978,7 @@ pub fn add_pending_messages(handle: u32, messages: HashMap) - pub fn remove_pending_message(handle: u32, id: &MessageId) -> VcxResult<()> { CONNECTION_MAP.get_mut(handle, |connection| { match connection { - Connections::V1(ref mut connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)), + Connections::V1(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)), Connections::V3(ref mut connection) => connection.remove_pending_message(id.clone()) } }) @@ -991,8 +987,8 @@ pub fn remove_pending_message(handle: u32, id: &MessageId) -> VcxResult<()> { pub fn is_v3_connection(connection_handle: u32) -> VcxResult { CONNECTION_MAP.get(connection_handle, |connection| { match connection { - Connections::V1(ref connection) => Ok(false), - Connections::V3(ref connection) => Ok(true) + Connections::V1(_) => Ok(false), + Connections::V3(_) => Ok(true) } }).or(Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle))) } @@ -1000,7 +996,7 @@ pub fn is_v3_connection(connection_handle: u32) -> VcxResult { pub fn send_ping(connection_handle: u32, comment: Option) -> VcxResult<()> { CONNECTION_MAP.get_mut(connection_handle, |connection| { match connection { - Connections::V1(ref connection) => Err(VcxError::from(VcxErrorKind::ActionNotSupported)), + Connections::V1(_) => Err(VcxError::from(VcxErrorKind::ActionNotSupported)), Connections::V3(ref mut connection) => connection.send_ping(comment.clone()) } }) @@ -1009,7 +1005,7 @@ pub fn send_ping(connection_handle: u32, comment: Option) -> VcxResult<( pub fn send_discovery_features(connection_handle: u32, query: Option, comment: Option) -> VcxResult<()> { CONNECTION_MAP.get_mut(connection_handle, |connection| { match connection { - Connections::V1(ref connection) => Err(VcxError::from(VcxErrorKind::ActionNotSupported)), + Connections::V1(_) => Err(VcxError::from(VcxErrorKind::ActionNotSupported)), Connections::V3(ref mut connection) => connection.send_discovery_features(query.clone(), comment.clone()) } }) @@ -1024,7 +1020,6 @@ pub mod tests { use std::time::Duration; use utils::constants::INVITE_DETAIL_STRING; use super::*; - use rand::Rng; pub fn build_test_connection() -> u32 { let handle = create_connection("alice").unwrap(); @@ -1206,8 +1201,6 @@ pub mod tests { #[test] fn test_parse_acceptance_details() { init!("true"); - let test_name = "test_parse_acceptance_details"; - let handle = rand::thread_rng().gen::(); let response = Message { status_code: MessageStatusCode::Accepted, @@ -1220,23 +1213,6 @@ pub mod tests { decrypted_payload: None, }; - let c = Connection { - source_id: test_name.to_string(), - pw_did: "8XFh8yBzrpJQmNyZzgoTqB".to_string(), - pw_verkey: "EkVTa7SCJ5SntpYyX7CSb2pcBhiVGT9kWSagA8a9T69A".to_string(), - state: VcxStateType::VcxStateOfferSent, - uuid: String::new(), - endpoint: String::new(), - invite_detail: None, - invite_url: None, - agent_did: "8XFh8yBzrpJQmNyZzgoTqB".to_string(), - agent_vk: "EkVTa7SCJ5SntpYyX7CSb2pcBhiVGT9kWSagA8a9T69A".to_string(), - their_pw_did: String::new(), - their_pw_verkey: String::new(), - public_did: None, - their_public_did: None, - }; - parse_acceptance_details(&response).unwrap(); // test that it fails diff --git a/vcx/libvcx/src/credential.rs b/vcx/libvcx/src/credential.rs index 5b1551da9a..181bf118c1 100644 --- a/vcx/libvcx/src/credential.rs +++ b/vcx/libvcx/src/credential.rs @@ -7,7 +7,7 @@ use api::VcxStateType; use issuer_credential::{CredentialOffer, CredentialMessage, PaymentInfo}; use credential_request::CredentialRequest; use messages; -use messages::{GeneralMessage, RemoteMessageType, ObjectWithVersion}; +use messages::{GeneralMessage, RemoteMessageType}; use messages::payload::{Payloads, PayloadKinds}; use messages::thread::Thread; use messages::get_message; @@ -18,7 +18,6 @@ use utils::libindy::anoncreds::{libindy_prover_create_credential_req, libindy_pr use utils::libindy::anoncreds; use utils::libindy::payments::{pay_a_payee, PaymentTxn}; use utils::error; -use utils::constants::DEFAULT_SERIALIZE_VERSION; use error::prelude::*; use std::convert::TryInto; @@ -166,7 +165,6 @@ impl Credential { self.their_vk, self.my_vk); - let local_their_did = self.their_did.as_ref().ok_or(VcxError::from(VcxErrorKind::InvalidCredentialHandle))?; let local_their_vk = self.their_vk.as_ref().ok_or(VcxError::from(VcxErrorKind::InvalidCredentialHandle))?; let local_agent_did = self.agent_did.as_ref().ok_or(VcxError::from(VcxErrorKind::InvalidCredentialHandle))?; let local_agent_vk = self.agent_vk.as_ref().ok_or(VcxError::from(VcxErrorKind::InvalidCredentialHandle))?; @@ -349,13 +347,9 @@ impl Credential { Ok(self.payment_info.clone()) } - fn to_string(&self) -> VcxResult { - ObjectWithVersion::new(DEFAULT_SERIALIZE_VERSION, self.to_owned()) - .serialize() - .map_err(|err| err.extend("Cannot serialize Credential")) - } - + #[cfg(test)] fn from_str(data: &str) -> VcxResult { + use messages::ObjectWithVersion; ObjectWithVersion::deserialize(data) .map(|obj: ObjectWithVersion| obj.data) .map_err(|err| err.extend("Cannot deserialize Credential")) @@ -459,7 +453,7 @@ pub fn get_payment_txn(handle: u32) -> VcxResult { HANDLE_MAP.get(handle, |obj| { match obj { Credentials::V1(ref obj) => obj.get_payment_txn(), - Credentials::V3(ref obj) => Err(VcxError::from(VcxErrorKind::NoPaymentInformation)) + Credentials::V3(_) => Err(VcxError::from(VcxErrorKind::NoPaymentInformation)) } }).or(Err(VcxError::from(VcxErrorKind::NoPaymentInformation))) } @@ -471,7 +465,7 @@ pub fn get_credential_offer(handle: u32) -> VcxResult { debug!("getting credential offer {}", obj.source_id); obj.get_credential_offer() } - Credentials::V3(ref obj) => Err(VcxError::from(VcxErrorKind::InvalidCredentialHandle)) // TODO: implement + Credentials::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidCredentialHandle)) // TODO: implement } }) } @@ -480,7 +474,7 @@ pub fn get_credential_id(handle: u32) -> VcxResult { HANDLE_MAP.get(handle, |obj| { match obj { Credentials::V1(ref obj) => Ok(obj.get_credential_id()), - Credentials::V3(ref obj) => Err(VcxError::from(VcxErrorKind::InvalidCredentialHandle)) + Credentials::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidCredentialHandle)) } }) } @@ -502,7 +496,7 @@ pub fn generate_credential_request_msg(handle: u32, connection_handle: u32) -> V obj.set_state(VcxStateType::VcxStateOfferSent); req } - Credentials::V3(ref obj) => Err(VcxError::from(VcxErrorKind::InvalidCredentialHandle)) // TODO: implement + Credentials::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidCredentialHandle)) // TODO: implement } }).map_err(handle_err) } @@ -531,7 +525,7 @@ pub fn get_credential_offer_msg(connection_handle: u32, msg_id: &str) -> VcxResu return serde_json::to_string(&vec![credential_offer]). map_err(|err| { - VcxError::from_msg(VcxErrorKind::InvalidState, "Cannot serialize Offers") + VcxError::from_msg(VcxErrorKind::InvalidState, format!("Cannot serialize Offers: {:?}", err)) }); } @@ -578,7 +572,7 @@ pub fn get_credential_offer_messages(connection_handle: u32) -> VcxResult VcxResult { HANDLE_MAP.get(handle, |obj| { match obj { Credentials::V1(ref obj) => Ok(obj.is_payment_required()), - Credentials::V3(ref obj) => Ok(false), + Credentials::V3(_) => Ok(false), } }).map_err(handle_err) } @@ -703,7 +697,7 @@ pub fn submit_payment(handle: u32) -> VcxResult<(PaymentTxn, String)> { HANDLE_MAP.get(handle, |obj| { match obj { Credentials::V1(ref obj) => obj.submit_payment(), - Credentials::V3(ref obj) => Err(VcxError::from(VcxErrorKind::InvalidCredentialHandle)), + Credentials::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidCredentialHandle)), } }).map_err(handle_err) } @@ -712,7 +706,7 @@ pub fn get_payment_information(handle: u32) -> VcxResult> { HANDLE_MAP.get(handle, |obj| { match obj { Credentials::V1(ref obj) => obj.get_payment_info(), - Credentials::V3(ref obj) => Ok(None), + Credentials::V3(_) => Ok(None), } }).map_err(handle_err) } @@ -720,7 +714,7 @@ pub fn get_payment_information(handle: u32) -> VcxResult> { pub fn get_credential_status(handle: u32) -> VcxResult { HANDLE_MAP.get(handle, |obj| { match obj { - Credentials::V1(ref obj) => Err(VcxError::from(VcxErrorKind::InvalidCredentialHandle)), + Credentials::V1(_) => Err(VcxError::from(VcxErrorKind::InvalidCredentialHandle)), Credentials::V3(ref obj) => obj.get_credential_status(), } }) @@ -820,7 +814,7 @@ pub mod tests { assert_eq!(get_state(c_h).unwrap(), VcxStateType::VcxStateAccepted as u32); assert_eq!(get_credential_id(c_h).unwrap(), "cred_id"); // this is set in test mode assert!(get_credential(c_h).unwrap().len() > 100); - let serialized = to_string(c_h).unwrap(); + let _serialized = to_string(c_h).unwrap(); } #[test] @@ -845,7 +839,7 @@ pub mod tests { let connection_h = connection::tests::build_test_connection(); let offer = get_credential_offer_messages(connection_h).unwrap(); let o: serde_json::Value = serde_json::from_str(&offer).unwrap(); - let credential_offer: CredentialOffer = serde_json::from_str(&o[0][0].to_string()).unwrap(); + let _credential_offer: CredentialOffer = serde_json::from_str(&o[0][0].to_string()).unwrap(); assert!(offer.len() > 50); } @@ -889,9 +883,9 @@ pub mod tests { fn test_get_credential() { init!("true"); let handle = from_string(::utils::constants::DEFAULT_SERIALIZED_CREDENTIAL).unwrap(); - let offer_string = get_credential_offer(handle).unwrap(); + let _offer_string = get_credential_offer(handle).unwrap(); let handle = from_string(::utils::constants::FULL_CREDENTIAL_SERIALIZED).unwrap(); - let cred_string = get_credential(handle).unwrap(); + let _cred_string = get_credential(handle).unwrap(); } #[test] @@ -913,6 +907,6 @@ pub mod tests { let offer_string = get_credential_offer(handle).unwrap(); let offer_value: serde_json::Value = serde_json::from_str(&offer_string).unwrap(); - let offer_struct: CredentialOffer = serde_json::from_value(offer_value["credential_offer"].clone()).unwrap(); + let _offer_struct: CredentialOffer = serde_json::from_value(offer_value["credential_offer"].clone()).unwrap(); } } diff --git a/vcx/libvcx/src/credential_def.rs b/vcx/libvcx/src/credential_def.rs index 390c29d4ce..7dc238863f 100644 --- a/vcx/libvcx/src/credential_def.rs +++ b/vcx/libvcx/src/credential_def.rs @@ -439,7 +439,6 @@ pub mod tests { let wallet_name = "test_create_revocable_fails_with_no_tails_file"; init!("ledger"); - let data = r#"["address1","address2","zip","city","state"]"#.to_string(); let (schema_id, _) = ::utils::libindy::anoncreds::tests::create_and_write_test_schema(::utils::constants::DEFAULT_SCHEMA_ATTRS); let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); @@ -458,7 +457,6 @@ pub mod tests { let wallet_name = "test_create_revocable_cred_def"; init!("ledger"); - let data = r#"["address1","address2","zip","city","state"]"#.to_string(); let (schema_id, _) = ::utils::libindy::anoncreds::tests::create_and_write_test_schema(::utils::constants::DEFAULT_SCHEMA_ATTRS); let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); @@ -484,7 +482,6 @@ pub mod tests { fn test_create_credential_def_real() { init!("ledger"); - let data = r#"["address1","address2","zip","city","state"]"#.to_string(); let (schema_id, _) = ::utils::libindy::anoncreds::tests::create_and_write_test_schema(::utils::constants::DEFAULT_SCHEMA_ATTRS); let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); @@ -504,7 +501,7 @@ pub mod tests { fn test_create_credential_def_no_fees_real() { init!("ledger"); - let rc = create_cred_def_real(false); + let _rc = create_cred_def_real(false); } #[cfg(feature = "pool_tests")] @@ -514,7 +511,7 @@ pub mod tests { let (schema_id, _) = ::utils::libindy::anoncreds::tests::create_and_write_test_schema(::utils::constants::DEFAULT_SCHEMA_ATTRS); let my_did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); - let handle = create_and_publish_credentialdef("1".to_string(), + let _handle = create_and_publish_credentialdef("1".to_string(), "name".to_string(), my_did.clone(), schema_id.clone(), @@ -588,7 +585,7 @@ pub mod tests { use utils::libindy::payments::add_new_did; init!("ledger_zero_fees"); - let (schema_handle, schema_id, did, revocation_details) = prepare_create_cred_def_data(false); + let (_, schema_id, did, revocation_details) = prepare_create_cred_def_data(false); let (endorser_did, _) = add_new_did(Some("ENDORSER")); @@ -613,7 +610,7 @@ pub mod tests { use utils::libindy::payments::add_new_did; init!("ledger"); - let (schema_handle, schema_id, did, revocation_details) = prepare_create_cred_def_data(true); + let (_, schema_id, did, revocation_details) = prepare_create_cred_def_data(true); let (endorser_did, _) = add_new_did(Some("ENDORSER")); diff --git a/vcx/libvcx/src/credential_request.rs b/vcx/libvcx/src/credential_request.rs index d6f85f3b62..2f33aee5f3 100644 --- a/vcx/libvcx/src/credential_request.rs +++ b/vcx/libvcx/src/credential_request.rs @@ -35,8 +35,6 @@ mod tests { use serde_json; use utils::constants::{CREDENTIAL_REQ_STRING, CRED_REQ, CRED_REQ_META}; - static TEMP_ISSUER_DID: &'static str = "4reqXeZVm7JZAffAoaNLsb"; - fn create_credential_req() -> CredentialRequest { ::settings::set_defaults(); let issuer_did = ::settings::get_config_value(::settings::CONFIG_INSTITUTION_DID).unwrap(); @@ -59,7 +57,6 @@ mod tests { #[test] fn test_deserialize() { - let issuer_did = String::from("4reqXeZVm7JZAffAoaNLsb"); let req: CredentialRequest = serde_json::from_str(CREDENTIAL_REQ_STRING).unwrap(); assert_eq!(&req.libindy_cred_req, CRED_REQ); } diff --git a/vcx/libvcx/src/disclosed_proof.rs b/vcx/libvcx/src/disclosed_proof.rs index c5465d7c15..5b466cdb7d 100644 --- a/vcx/libvcx/src/disclosed_proof.rs +++ b/vcx/libvcx/src/disclosed_proof.rs @@ -8,7 +8,7 @@ use object_cache::ObjectCache; use api::VcxStateType; use connection; use messages; -use messages::{GeneralMessage, RemoteMessageType, ObjectWithVersion}; +use messages::{GeneralMessage, RemoteMessageType}; use messages::payload::{Payloads, PayloadKinds}; use messages::thread::Thread; use messages::proofs::proof_message::ProofMessage; @@ -17,7 +17,7 @@ use messages::get_message::Message; use error::prelude::*; use settings; use utils::{httpclient, error}; -use utils::constants::{DEFAULT_SERIALIZE_VERSION, CREDS_FROM_PROOF_REQ, DEFAULT_GENERATED_PROOF}; +use utils::constants::{CREDS_FROM_PROOF_REQ, DEFAULT_GENERATED_PROOF}; use utils::libindy::cache::{get_rev_reg_cache, set_rev_reg_cache, RevRegCache, RevState}; use utils::libindy::anoncreds; use utils::libindy::anoncreds::{get_rev_reg_def_json, get_rev_reg_delta_json}; @@ -326,7 +326,7 @@ impl DisclosedProof { // do same for predicates and self_attested if let Value::Object(ref mut map) = rtn["requested_attributes"] { for ref cred_info in credentials_identifiers { - if let Some(ref attr) = proof_req.requested_attributes.get(&cred_info.requested_attr) { + if let Some(_) = proof_req.requested_attributes.get(&cred_info.requested_attr) { let insert_val = json!({"cred_id": cred_info.referent, "revealed": true, "timestamp": cred_info.timestamp}); map.insert(cred_info.requested_attr.to_owned(), insert_val); } @@ -335,7 +335,7 @@ impl DisclosedProof { if let Value::Object(ref mut map) = rtn["requested_predicates"] { for ref cred_info in credentials_identifiers { - if let Some(ref attr) = proof_req.requested_predicates.get(&cred_info.requested_attr) { + if let Some(_) = proof_req.requested_predicates.get(&cred_info.requested_attr) { let insert_val = json!({"cred_id": cred_info.referent, "timestamp": cred_info.timestamp}); map.insert(cred_info.requested_attr.to_owned(), insert_val); } @@ -459,19 +459,6 @@ impl DisclosedProof { fn set_source_id(&mut self, id: &str) { self.source_id = id.to_string(); } fn get_source_id(&self) -> &String { &self.source_id } - - fn to_string(&self) -> VcxResult { - trace!("DisclosedProof::to_string >>>"); - ObjectWithVersion::new(DEFAULT_SERIALIZE_VERSION, self.to_owned()) - .serialize() - .map_err(|err| err.extend("Cannot serialize DisclosedProof")) - } - fn from_str(data: &str) -> VcxResult { - trace!("DisclosedProof::from_str >>> data: {}", secret!(&data)); - ObjectWithVersion::deserialize(data) - .map(|obj: ObjectWithVersion| obj.data) - .map_err(|err| err.extend("Cannot deserialize DisclosedProof")) - } } //******************************************** @@ -602,7 +589,7 @@ pub fn generate_proof(handle: u32, credentials: String, self_attested_attrs: Str pub fn decline_presentation_request(handle: u32, connection_handle: u32, reason: Option, proposal: Option) -> VcxResult { HANDLE_MAP.get_mut(handle, |obj| { match obj { - DisclosedProofs::V1(obj) => { + DisclosedProofs::V1(_) => { Err(VcxError::from(VcxErrorKind::ActionNotSupported)) }, DisclosedProofs::V3(ref mut obj) => { @@ -674,7 +661,7 @@ pub fn get_proof_request_messages(connection_handle: u32, match_name: Option<&st return serde_json::to_string(&msgs). map_err(|err| { - VcxError::from_msg(VcxErrorKind::InvalidState, "Cannot serialize ProofRequestMessage") + VcxError::from_msg(VcxErrorKind::InvalidState, format!("Cannot serialize ProofRequestMessage: {:?}", err)) }); } @@ -736,7 +723,7 @@ pub fn get_source_id(handle: u32) -> VcxResult { pub fn get_presentation_status(handle: u32) -> VcxResult { HANDLE_MAP.get(handle, |obj| { match obj { - DisclosedProofs::V1(obj) => Err(VcxError::from(VcxErrorKind::InvalidDisclosedProofHandle)), + DisclosedProofs::V1(_) => Err(VcxError::from(VcxErrorKind::InvalidDisclosedProofHandle)), DisclosedProofs::V3(ref obj) => Ok(obj.presentation_status()) } }) @@ -817,7 +804,7 @@ mod tests { let serialized = to_string(handle).unwrap(); let j: Value = serde_json::from_str(&serialized).unwrap(); assert_eq!(j["version"], "1.0"); - DisclosedProof::from_str(&serialized).unwrap(); + from_string(&serialized).unwrap(); } #[test] @@ -829,7 +816,6 @@ mod tests { fn test_find_schemas() { init!("true"); - let proof: DisclosedProof = Default::default(); assert_eq!(DisclosedProof::build_schemas_json(&Vec::new()).unwrap(), "{}".to_string()); let cred1 = CredInfo { @@ -876,7 +862,6 @@ mod tests { tails_file: None, timestamp: None, }]; - let proof: DisclosedProof = Default::default(); assert_eq!(DisclosedProof::build_schemas_json(&credential_ids).unwrap_err().kind(), VcxErrorKind::InvalidSchema); } @@ -907,7 +892,6 @@ mod tests { }; let creds = vec![cred1, cred2]; - let proof: DisclosedProof = Default::default(); let credential_def = DisclosedProof::build_cred_def_json(&creds).unwrap(); assert!(credential_def.len() > 0); assert!(credential_def.contains(r#""id":"2hoqvcwupRTUNkXn6ArYzs:3:CL:2471","schemaId":"2471""#)); @@ -928,7 +912,6 @@ mod tests { tails_file: None, timestamp: None, }]; - let proof: DisclosedProof = Default::default(); assert_eq!(DisclosedProof::build_cred_def_json(&credential_ids).unwrap_err().kind(), VcxErrorKind::InvalidProofCredentialData); } @@ -975,7 +958,6 @@ mod tests { "requested_predicates":{} }); - let proof: DisclosedProof = Default::default(); let proof_req = json!({ "nonce": "123432421212", "name": "proof_req_1", @@ -1095,7 +1077,6 @@ mod tests { #[test] fn test_retrieve_credentials_fails_with_no_proof_req() { init!("false"); - let proof: DisclosedProof = Default::default(); assert_eq!(proof.retrieve_credentials().unwrap_err().kind(), VcxErrorKind::NotReady); } @@ -1281,7 +1262,7 @@ mod tests { fn test_generate_proof() { init!("ledger"); let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); - let (schema_id, _, cred_def_id, _, _, _, _, cred_id, _, _) = ::utils::libindy::anoncreds::tests::create_and_store_credential(::utils::constants::DEFAULT_SCHEMA_ATTRS, true); + ::utils::libindy::anoncreds::tests::create_and_store_credential(::utils::constants::DEFAULT_SCHEMA_ATTRS, true); let mut proof_req = ProofRequestMessage::create(); let to = time::get_time().sec; let indy_proof_req = json!({ @@ -1335,8 +1316,6 @@ mod tests { #[test] fn test_generate_self_attested_proof() { init!("ledger"); - let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); - let mut proof_req = ProofRequestMessage::create(); let indy_proof_req = json!({ "nonce":"123432421212", @@ -1374,7 +1353,7 @@ mod tests { fn test_generate_proof_with_predicates() { init!("ledger"); let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); - let (schema_id, _, cred_def_id, _, _, _, _, cred_id, _, _) = ::utils::libindy::anoncreds::tests::create_and_store_credential(::utils::constants::DEFAULT_SCHEMA_ATTRS, true); + ::utils::libindy::anoncreds::tests::create_and_store_credential(::utils::constants::DEFAULT_SCHEMA_ATTRS, true); let mut proof_req = ProofRequestMessage::create(); let to = time::get_time().sec; let indy_proof_req = json!({ @@ -1501,7 +1480,6 @@ mod tests { let cache = get_rev_reg_cache(&rev_reg_id); assert_eq!(cache.rev_state, None); - let (_, rev_reg_def_json) = get_rev_reg_def_json(&rev_reg_id).unwrap(); let states = build_rev_states_json(vec![cred2].as_mut()).unwrap(); assert!(states.contains(&rev_reg_id)); @@ -1552,7 +1530,6 @@ mod tests { let cache = get_rev_reg_cache(&rev_reg_id); assert_eq!(cache, cached_data); - let (_, rev_reg_def_json) = get_rev_reg_def_json(&rev_reg_id).unwrap(); let states = build_rev_states_json(vec![cred2].as_mut()).unwrap(); assert!(states.contains(&rev_reg_id)); @@ -1607,7 +1584,6 @@ mod tests { let cache = get_rev_reg_cache(&rev_reg_id); assert_eq!(cache, cached_data); - let (_, rev_reg_def_json) = get_rev_reg_def_json(&rev_reg_id).unwrap(); let states = build_rev_states_json(vec![cred2].as_mut()).unwrap(); assert!(states.contains(&rev_reg_id)); @@ -1662,7 +1638,6 @@ mod tests { let cache = get_rev_reg_cache(&rev_reg_id); assert_eq!(cache, cached_data); - let (_, rev_reg_def_json) = get_rev_reg_def_json(&rev_reg_id).unwrap(); let states = build_rev_states_json(vec![cred2].as_mut()).unwrap(); assert!(states.contains(&rev_reg_id)); diff --git a/vcx/libvcx/src/issuer_credential.rs b/vcx/libvcx/src/issuer_credential.rs index 84059fd0e7..352b57db62 100644 --- a/vcx/libvcx/src/issuer_credential.rs +++ b/vcx/libvcx/src/issuer_credential.rs @@ -5,14 +5,14 @@ use api::VcxStateType; use v3; use messages; use settings; -use messages::{RemoteMessageType, MessageStatusCode, GeneralMessage, ObjectWithVersion}; +use messages::{RemoteMessageType, MessageStatusCode, GeneralMessage}; use messages::payload::{Payloads, PayloadKinds}; use messages::thread::Thread; use connection; use credential_request::CredentialRequest; use utils::error; use utils::libindy::{payments, anoncreds}; -use utils::constants::{CRED_MSG, DEFAULT_SERIALIZE_VERSION}; +use utils::constants::{CRED_MSG}; use utils::openssl::encode; use utils::libindy::payments::PaymentTxn; use utils::qualifier::Qualifier; @@ -34,8 +34,6 @@ enum IssuerCredentials { V3(Issuer), } -static CREDENTIAL_OFFER_ID_KEY: &str = "claim_offer_id"; - #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] pub struct IssuerCredential { source_id: String, @@ -129,7 +127,7 @@ impl PaymentInfo { pub fn to_string(&self) -> VcxResult { serde_json::to_string(&self) - .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidJson, format!("Cannot serialize payment info"))) + .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidJson, format!("Cannot serialize payment info: {:?}", err))) } } @@ -140,7 +138,7 @@ impl IssuerCredential { Ok(error::SUCCESS.code_num) } - pub fn generate_credential_offer_msg(&mut self, connection_handle: u32) -> VcxResult<(String, String)> { + pub fn generate_credential_offer_msg(&mut self, _connection_handle: u32) -> VcxResult<(String, String)> { let mut payload = Vec::new(); let connection_name = settings::get_config_value(settings::CONFIG_INSTITUTION_NAME)?; @@ -301,7 +299,7 @@ impl IssuerCredential { let (payload, thread) = Payloads::decrypt(&self.issued_vk, &message) .map_err(|err| VcxError::from_msg(VcxErrorKind::Common(err.into()), "Cannot decrypt CredentialOffer payload"))?; - if let Some(tr) = thread { + if let Some(_) = thread { let remote_did = self.remote_did.as_str(); self.thread.as_mut().map(|thread| thread.increment_receiver(&remote_did)); } @@ -335,7 +333,6 @@ impl IssuerCredential { self.state as u32 } fn get_offer_uid(&self) -> &String { &self.msg_uid } - fn set_offer_uid(&mut self, uid: &str) { self.msg_uid = uid.to_owned(); } fn get_credential_attributes(&self) -> &String { &self.credential_attributes } fn get_source_id(&self) -> &String { &self.source_id } @@ -372,7 +369,7 @@ impl IssuerCredential { msg_type: PayloadKinds::Cred.name().to_string(), libindy_cred: cred, rev_reg_def_json: self.rev_reg_def_json.clone().unwrap_or(String::new()), - cred_def_id: self.cred_def_id.clone(), + cred_def_id, cred_revoc_id, revoc_reg_delta_json, }) @@ -469,17 +466,14 @@ impl IssuerCredential { } } + #[cfg(test)] pub fn to_string(&self) -> VcxResult { + use messages::ObjectWithVersion; + use utils::constants::DEFAULT_SERIALIZE_VERSION; ObjectWithVersion::new(DEFAULT_SERIALIZE_VERSION, self.to_owned()) .serialize() .map_err(|err| err.extend("Cannot serialize credential")) } - - fn from_str(data: &str) -> VcxResult { - ObjectWithVersion::deserialize(data) - .map(|obj: ObjectWithVersion| obj.data) - .map_err(|err| err.extend("Cannot deserialize IssuerCredential")) - } } /** @@ -556,7 +550,7 @@ pub fn get_encoded_attributes(handle: u32) -> VcxResult { ISSUER_CREDENTIAL_MAP.get(handle, |obj| { match obj { IssuerCredentials::V1(ref obj) => obj.create_attributes_encodings(), - IssuerCredentials::V3(ref obj) => Err(VcxError::from(VcxErrorKind::InvalidIssuerCredentialHandle)) + IssuerCredentials::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidIssuerCredentialHandle)) } }) } @@ -565,7 +559,7 @@ pub fn get_offer_uid(handle: u32) -> VcxResult { ISSUER_CREDENTIAL_MAP.get(handle, |obj| { match obj { IssuerCredentials::V1(ref obj) => Ok(obj.get_offer_uid().to_string()), - IssuerCredentials::V3(ref obj) => Err(VcxError::from(VcxErrorKind::InvalidIssuerCredentialHandle)) + IssuerCredentials::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidIssuerCredentialHandle)) } }) } @@ -574,7 +568,7 @@ pub fn get_payment_txn(handle: u32) -> VcxResult { ISSUER_CREDENTIAL_MAP.get(handle, |obj| { match obj { IssuerCredentials::V1(ref obj) => obj.get_payment_txn(), - IssuerCredentials::V3(ref obj) => Err(VcxError::from(VcxErrorKind::NoPaymentInformation)) + IssuerCredentials::V3(_) => Err(VcxError::from(VcxErrorKind::NoPaymentInformation)) } }) } @@ -646,7 +640,7 @@ pub fn update_state(handle: u32, message: Option) -> VcxResult { IssuerCredentials::V1(ref mut obj) => { match obj.update_state(message.clone()) { Ok(x) => Ok(x), - Err(x) => Ok(obj.get_state()), + Err(_) => Ok(obj.get_state()), } } IssuerCredentials::V3(ref mut obj) => { @@ -669,7 +663,7 @@ pub fn get_state(handle: u32) -> VcxResult { pub fn get_credential_status(handle: u32) -> VcxResult { ISSUER_CREDENTIAL_MAP.get(handle, |obj| { match obj { - IssuerCredentials::V1(ref obj) => Err(VcxError::from(VcxErrorKind::InvalidIssuerCredentialHandle)), + IssuerCredentials::V1(_) => Err(VcxError::from(VcxErrorKind::InvalidIssuerCredentialHandle)), IssuerCredentials::V3(ref obj) => obj.get_credential_status(), } }) @@ -706,7 +700,7 @@ pub fn generate_credential_offer_msg(handle: u32, connection_handle: u32) -> Vcx ISSUER_CREDENTIAL_MAP.get_mut(handle, |obj| { match obj { IssuerCredentials::V1(ref mut obj) => obj.generate_credential_offer_msg(connection_handle), - IssuerCredentials::V3(ref obj) => Err(VcxError::from(VcxErrorKind::InvalidIssuerCredentialHandle)), // TODO: implement + IssuerCredentials::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidIssuerCredentialHandle)), // TODO: implement } }) } @@ -729,7 +723,7 @@ pub fn generate_credential_msg(handle: u32, connection_handle: u32) -> VcxResult ISSUER_CREDENTIAL_MAP.get_mut(handle, |obj| { match obj { IssuerCredentials::V1(ref mut obj) => obj.generate_credential_msg(connection_handle), - IssuerCredentials::V3(ref obj) => Err(VcxError::from(VcxErrorKind::InvalidIssuerCredentialHandle)), // TODO: implement + IssuerCredentials::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidIssuerCredentialHandle)), // TODO: implement } }) } @@ -752,14 +746,14 @@ pub fn revoke_credential(handle: u32) -> VcxResult<()> { ISSUER_CREDENTIAL_MAP.get_mut(handle, |obj| { match obj { IssuerCredentials::V1(ref mut obj) => obj.revoke_cred(), - IssuerCredentials::V3(ref obj) => Err(VcxError::from(VcxErrorKind::NotReady)), // TODO: implement + IssuerCredentials::V3(_) => Err(VcxError::from(VcxErrorKind::NotReady)), // TODO: implement } }) } pub fn convert_to_map(s: &str) -> VcxResult> { serde_json::from_str(s) - .map_err(|err| { + .map_err(|_| { warn!("{}", error::INVALID_ATTRIBUTES_STRUCTURE.message); VcxError::from_msg(VcxErrorKind::InvalidAttributesStructure, error::INVALID_ATTRIBUTES_STRUCTURE.message) }) @@ -769,7 +763,7 @@ pub fn get_credential_attributes(handle: u32) -> VcxResult { ISSUER_CREDENTIAL_MAP.get(handle, |obj| { match obj { IssuerCredentials::V1(ref obj) => Ok(obj.get_credential_attributes().to_string()), - IssuerCredentials::V3(ref obj) => Err(VcxError::from(VcxErrorKind::NotReady)), // TODO: implement + IssuerCredentials::V3(_) => Err(VcxError::from(VcxErrorKind::NotReady)), // TODO: implement } }) } @@ -802,14 +796,6 @@ pub mod tests { static DEFAULT_CREDENTIAL_NAME: &str = "Credential"; static DEFAULT_CREDENTIAL_ID: &str = "defaultCredentialId"; - static SCHEMA: &str = r#"{{ - "seqNo":32, - "data":{{ - "name":"gvt", - "version":"1.0", - "attr_names":["address1","address2","city","state", "zip"] - }} - }}"#; static CREDENTIAL_DATA: &str = r#"{"address2":["101 Wilson Lane"], @@ -819,12 +805,7 @@ pub mod tests { "address1":["101 Tela Lane"] }"#; - static X_CREDENTIAL_JSON: &str = - r#"{"claim":{"address1":["101 Tela Lane","63690509275174663089934667471948380740244018358024875547775652380902762701972"],"address2":["101 Wilson Lane","68086943237164982734333428280784300550565381723532936263016368251445461241953"],"city":["SLC","101327353979588246869873249766058188995681113722618593621043638294296500696424"],"state":["UT","93856629670657830351991220989031130499313559332549427637940645777813964461231"],"zip":["87121","87121"]},"issuer_did":"NcYxiDXkpYi6ov5FcYDi1e","schema_seq_no":15,"signature":{"non_revocation_claim":null,"primary_claim":{"a":"","e":"","m2":"","v":""}}}"#; - - pub fn util_put_credential_def_in_issuer_wallet(schema_seq_num: u32, wallet_handle: i32) { - let stored_xcredential = String::from(""); - + pub fn util_put_credential_def_in_issuer_wallet(_schema_seq_num: u32, _wallet_handle: i32) { let issuer_did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); let tag = "test_tag"; let config = "{support_revocation: false}"; @@ -868,7 +849,6 @@ pub mod tests { } pub fn create_pending_issuer_credential() -> IssuerCredential { - let connection_handle = build_test_connection(); let credential_req: CredentialRequest = serde_json::from_str(CREDENTIAL_REQ_STRING).unwrap(); let (credential_offer, _) = ::credential::parse_json_offer(CREDENTIAL_OFFER_JSON).unwrap(); let credential: IssuerCredential = IssuerCredential { @@ -903,20 +883,6 @@ pub mod tests { credential } - fn normalize_credentials(c1: &str, c2: &str) -> (serde_json::Value, serde_json::Value) { - let mut v1: serde_json::Value = serde_json::from_str(c1.clone()).unwrap(); - let mut v2: serde_json::Value = serde_json::from_str(c2.clone()).unwrap(); - v1["signature"]["primary_claim"]["a"] = serde_json::to_value("".to_owned()).unwrap(); - v1["signature"]["primary_claim"]["e"] = serde_json::to_value("".to_owned()).unwrap(); - v1["signature"]["primary_claim"]["v"] = serde_json::to_value("".to_owned()).unwrap(); - v1["signature"]["primary_claim"]["m2"] = serde_json::to_value("".to_owned()).unwrap(); - v2["signature"]["primary_claim"]["a"] = serde_json::to_value("".to_owned()).unwrap(); - v2["signature"]["primary_claim"]["e"] = serde_json::to_value("".to_owned()).unwrap(); - v2["signature"]["primary_claim"]["v"] = serde_json::to_value("".to_owned()).unwrap(); - v2["signature"]["primary_claim"]["m2"] = serde_json::to_value("".to_owned()).unwrap(); - (v1, v2) - } - pub fn create_full_issuer_credential() -> (IssuerCredential, ::credential::Credential) { let issuer_did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); let (_, cred_def_handle) = ::credential_def::tests::create_cred_def_real(true); @@ -1004,8 +970,6 @@ pub mod tests { init!("true"); let connection_handle = build_test_connection(); - let credential_id = DEFAULT_CREDENTIAL_ID; - let handle = issuer_credential_create(::credential_def::tests::create_cred_def_fake(), "1".to_string(), "8XFh8yBzrpJQmNyZzgoTqB".to_owned(), @@ -1023,7 +987,7 @@ pub mod tests { #[test] fn test_generate_cred_offer() { init!("ledger"); - let issuer = create_full_issuer_credential().0.generate_credential_offer(&settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap()).unwrap(); + let _issuer = create_full_issuer_credential().0.generate_credential_offer(&settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap()).unwrap(); } #[test] @@ -1031,8 +995,6 @@ pub mod tests { init!("true"); let connection_handle = build_test_connection(); - let credential_id = DEFAULT_CREDENTIAL_ID; - let handle = issuer_credential_create(::credential_def::tests::create_cred_def_fake(), "1".to_string(), "8XFh8yBzrpJQmNyZzgoTqB".to_owned(), @@ -1211,7 +1173,7 @@ pub mod tests { r#"{"name":["frank"],"gpa":["4.0"]}"#.to_string(), 1).unwrap(); - let encoded_attributes = self::get_encoded_attributes(issuer_credential_handle).unwrap(); + let _encoded_attributes = self::get_encoded_attributes(issuer_credential_handle).unwrap(); } #[test] @@ -1299,27 +1261,27 @@ pub mod tests { // for reference....expectation is encode_attributes returns this: let expected = json!({ -"address2": { -"encoded": "68086943237164982734333428280784300550565381723532936263016368251445461241953", -"raw": "101 Wilson Lane" -}, -"zip": { -"encoded": "87121", -"raw": "87121" -}, -"city": { -"encoded": "101327353979588246869873249766058188995681113722618593621043638294296500696424", -"raw": "SLC" -}, -"address1": { -"encoded": "63690509275174663089934667471948380740244018358024875547775652380902762701972", -"raw": "101 Tela Lane" -}, -"state": { -"encoded": "93856629670657830351991220989031130499313559332549427637940645777813964461231", -"raw": "UT" -} -}); + "address2": { + "encoded": "68086943237164982734333428280784300550565381723532936263016368251445461241953", + "raw": "101 Wilson Lane" + }, + "zip": { + "encoded": "87121", + "raw": "87121" + }, + "city": { + "encoded": "101327353979588246869873249766058188995681113722618593621043638294296500696424", + "raw": "SLC" + }, + "address1": { + "encoded": "63690509275174663089934667471948380740244018358024875547775652380902762701972", + "raw": "101 Tela Lane" + }, + "state": { + "encoded": "93856629670657830351991220989031130499313559332549427637940645777813964461231", + "raw": "UT" + } + }); static TEST_CREDENTIAL_DATA: &str = @@ -1333,28 +1295,17 @@ pub mod tests { let results_json = encode_attributes(TEST_CREDENTIAL_DATA).unwrap(); let results: Value = serde_json::from_str(&results_json).unwrap(); - - let address2: &Value = &results["address2"]; - assert_eq!(encode("101 Wilson Lane").unwrap(), address2["encoded"]); - assert_eq!("101 Wilson Lane", address2["raw"]); - - let state: &Value = &results["state"]; - assert_eq!(encode("UT").unwrap(), state["encoded"]); - assert_eq!("UT", state["raw"]); - - let zip: &Value = &results["zip"]; - assert_eq!("87121", zip["encoded"]); - assert_eq!("87121", zip["raw"]); + assert_eq!(expected, results); } #[test] fn test_encode_with_one_attribute_success() { let expected = json!({ -"address2": { -"encoded": "68086943237164982734333428280784300550565381723532936263016368251445461241953", -"raw": "101 Wilson Lane" -} -}); + "address2": { + "encoded": "68086943237164982734333428280784300550565381723532936263016368251445461241953", + "raw": "101 Wilson Lane" + } + }); static TEST_CREDENTIAL_DATA: &str = r#"{"address2":["101 Wilson Lane"]}"#; @@ -1371,28 +1322,27 @@ pub mod tests { // for reference....expectation is encode_attributes returns this: let expected = json!({ -"address2": { -"encoded": "68086943237164982734333428280784300550565381723532936263016368251445461241953", -"raw": "101 Wilson Lane" -}, -"zip": { -"encoded": "87121", -"raw": "87121" -}, -"city": { -"encoded": "101327353979588246869873249766058188995681113722618593621043638294296500696424", -"raw": "SLC" -}, -"address1": { -"encoded": "63690509275174663089934667471948380740244018358024875547775652380902762701972", -"raw": "101 Tela Lane" -}, -"state": { -"encoded": "93856629670657830351991220989031130499313559332549427637940645777813964461231", -"raw": "UT" -} -}); - + "address2": { + "encoded": "68086943237164982734333428280784300550565381723532936263016368251445461241953", + "raw": "101 Wilson Lane" + }, + "zip": { + "encoded": "87121", + "raw": "87121" + }, + "city": { + "encoded": "101327353979588246869873249766058188995681113722618593621043638294296500696424", + "raw": "SLC" + }, + "address1": { + "encoded": "63690509275174663089934667471948380740244018358024875547775652380902762701972", + "raw": "101 Tela Lane" + }, + "state": { + "encoded": "93856629670657830351991220989031130499313559332549427637940645777813964461231", + "raw": "UT" + } + }); static TEST_CREDENTIAL_DATA: &str = r#"{"address2":"101 Wilson Lane", @@ -1405,28 +1355,17 @@ pub mod tests { let results_json = encode_attributes(TEST_CREDENTIAL_DATA).unwrap(); let results: Value = serde_json::from_str(&results_json).unwrap(); - - let address2: &Value = &results["address2"]; - assert_eq!(encode("101 Wilson Lane").unwrap(), address2["encoded"]); - assert_eq!("101 Wilson Lane", address2["raw"]); - - let state: &Value = &results["state"]; - assert_eq!(encode("UT").unwrap(), state["encoded"]); - assert_eq!("UT", state["raw"]); - - let zip: &Value = &results["zip"]; - assert_eq!("87121", zip["encoded"]); - assert_eq!("87121", zip["raw"]); + assert_eq!(expected, results); } #[test] fn test_encode_with_new_format_one_attribute_success() { let expected = json!({ -"address2": { -"encoded": "68086943237164982734333428280784300550565381723532936263016368251445461241953", -"raw": "101 Wilson Lane" -} -}); + "address2": { + "encoded": "68086943237164982734333428280784300550565381723532936263016368251445461241953", + "raw": "101 Wilson Lane" + } + }); static TEST_CREDENTIAL_DATA: &str = r#"{"address2": "101 Wilson Lane"}"#; @@ -1443,27 +1382,27 @@ pub mod tests { // for reference....expectation is encode_attributes returns this: let expected = json!({ -"address2": { -"encoded": "68086943237164982734333428280784300550565381723532936263016368251445461241953", -"raw": "101 Wilson Lane" -}, -"zip": { -"encoded": "87121", -"raw": "87121" -}, -"city": { -"encoded": "101327353979588246869873249766058188995681113722618593621043638294296500696424", -"raw": "SLC" -}, -"address1": { -"encoded": "63690509275174663089934667471948380740244018358024875547775652380902762701972", -"raw": "101 Tela Lane" -}, -"state": { -"encoded": "93856629670657830351991220989031130499313559332549427637940645777813964461231", -"raw": "UT" -} -}); + "address2": { + "encoded": "68086943237164982734333428280784300550565381723532936263016368251445461241953", + "raw": "101 Wilson Lane" + }, + "zip": { + "encoded": "87121", + "raw": "87121" + }, + "city": { + "encoded": "101327353979588246869873249766058188995681113722618593621043638294296500696424", + "raw": "SLC" + }, + "address1": { + "encoded": "63690509275174663089934667471948380740244018358024875547775652380902762701972", + "raw": "101 Tela Lane" + }, + "state": { + "encoded": "93856629670657830351991220989031130499313559332549427637940645777813964461231", + "raw": "UT" + } + }); static TEST_CREDENTIAL_DATA: &str = @@ -1477,18 +1416,8 @@ pub mod tests { let results_json = encode_attributes(TEST_CREDENTIAL_DATA).unwrap(); let results: Value = serde_json::from_str(&results_json).unwrap(); - let address2: &Value = &results["address2"]; - - assert_eq!("68086943237164982734333428280784300550565381723532936263016368251445461241953", address2["encoded"]); - assert_eq!("101 Wilson Lane", address2["raw"]); - - let state: &Value = &results["state"]; - assert_eq!("93856629670657830351991220989031130499313559332549427637940645777813964461231", state["encoded"]); - assert_eq!("UT", state["raw"]); + assert_eq!(expected, results); - let zip: &Value = &results["zip"]; - assert_eq!("87121", zip["encoded"]); - assert_eq!("87121", zip["raw"]); } #[test] diff --git a/vcx/libvcx/src/lib.rs b/vcx/libvcx/src/lib.rs index 73e0dd111a..16631b1f37 100644 --- a/vcx/libvcx/src/lib.rs +++ b/vcx/libvcx/src/lib.rs @@ -1,6 +1,4 @@ #![cfg_attr(feature = "fatal_warnings", deny(warnings))] -#![allow(unused_variables)] -#![allow(dead_code)] #![crate_name = "vcx"] //this is needed for some large json macro invocations #![recursion_limit = "128"] @@ -14,7 +12,6 @@ extern crate futures; #[macro_use] extern crate log; -extern crate log4rs; extern crate libc; @@ -36,6 +33,7 @@ extern crate uuid; extern crate failure; extern crate rmp_serde; +extern crate indy_sys; extern crate base64; @@ -43,6 +41,8 @@ extern crate strum; #[macro_use] extern crate strum_macros; +extern crate chrono; + #[macro_use] pub mod utils; pub mod settings; @@ -65,6 +65,7 @@ pub mod disclosed_proof; pub mod v3; #[allow(unused_imports)] +#[allow(dead_code)] #[cfg(test)] mod tests { @@ -279,7 +280,7 @@ mod tests { attrs_list.as_array_mut().unwrap().push(json!(format!("key{}",i))); } let attrs_list = attrs_list.to_string(); - let (schema_id, schema_json, cred_def_id, cred_def_json, cred_def_handle, _) = ::utils::libindy::anoncreds::tests::create_and_store_credential_def(&attrs_list, false); + let (schema_id, _schema_json, cred_def_id, _cred_def_json, cred_def_handle, _) = ::utils::libindy::anoncreds::tests::create_and_store_credential_def(&attrs_list, false); let mut credential_data = json!({}); for i in 1..number_of_attributes { credential_data[format!("key{}", i)] = json!([format!("value{}",i)]); @@ -339,7 +340,6 @@ mod tests { #[cfg(feature = "pool_tests")] #[test] fn test_real_proof_with_revocation() { - let number_of_attributes = 10; init!("agency"); let institution_did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); let (faber, alice) = ::connection::tests::create_connected_connections(); @@ -347,7 +347,7 @@ mod tests { // CREATE SCHEMA AND CRED DEF println!("creating schema/credential_def and paying fees"); let attrs_list = json!(["address1", "address2", "city", "state", "zip"]).to_string(); - let (schema_id, schema_json, cred_def_id, cred_def_json, cred_def_handle, rev_reg_id) = + let (schema_id, _schema_json, cred_def_id, _cred_def_json, cred_def_handle, rev_reg_id) = ::utils::libindy::anoncreds::tests::create_and_store_credential_def(&attrs_list, true); // AS INSTITUTION SEND CREDENTIAL OFFER @@ -378,7 +378,7 @@ mod tests { proof::update_state(proof_req_handle, None).unwrap(); assert_eq!(proof::get_proof_state(proof_req_handle).unwrap(), ProofStateType::ProofValidated as u32); println!("proof validated!"); - let wallet = ::utils::libindy::payments::get_wallet_token_info().unwrap(); + let _wallet = ::utils::libindy::payments::get_wallet_token_info().unwrap(); // AS INSTITUTION REVOKE CRED revoke_credential(credential_offer, rev_reg_id); diff --git a/vcx/libvcx/src/messages/create_key.rs b/vcx/libvcx/src/messages/create_key.rs index 0ebda33f9a..e9f85d4d5e 100644 --- a/vcx/libvcx/src/messages/create_key.rs +++ b/vcx/libvcx/src/messages/create_key.rs @@ -117,7 +117,6 @@ mod tests { #[test] fn test_create_key_set_values() { - let to_did = "8XFh8yBzrpJQmNyZzgoTqB"; let for_did = "11235yBzrpJQmNyZzgoTqB"; let for_verkey = "EkVTa7SCJ5SntpYyX7CSb2pcBhiVGT9kWSagA8a9T69A"; @@ -130,9 +129,9 @@ mod tests { fn test_create_key_set_values_and_serialize() { init!("false"); - let (agent_did, agent_vk) = create_and_store_my_did(Some(MY2_SEED)).unwrap(); + let (_agent_did, agent_vk) = create_and_store_my_did(Some(MY2_SEED)).unwrap(); let (my_did, my_vk) = create_and_store_my_did(Some(MY1_SEED)).unwrap(); - let (agency_did, agency_vk) = create_and_store_my_did(Some(MY3_SEED)).unwrap(); + let (_agency_did, agency_vk) = create_and_store_my_did(Some(MY3_SEED)).unwrap(); settings::set_config_value(settings::CONFIG_AGENCY_VERKEY, &agency_vk); settings::set_config_value(settings::CONFIG_REMOTE_TO_SDK_VERKEY, &agent_vk); diff --git a/vcx/libvcx/src/messages/get_message.rs b/vcx/libvcx/src/messages/get_message.rs index 0125302847..a134435f9d 100644 --- a/vcx/libvcx/src/messages/get_message.rs +++ b/vcx/libvcx/src/messages/get_message.rs @@ -288,13 +288,13 @@ impl Message { let decrypted_payload = match payload { MessagePayload::V1(payload) => Payloads::decrypt_payload_v1(&vk, &payload) .map(Payloads::PayloadV1), - MessagePayload::V2(payload) => Payloads::decrypt_payload_v2(&vk, &payload) + MessagePayload::V2(payload) => Payloads::decrypt_payload_v2(&payload) .map(Payloads::PayloadV2) }; if let Ok(decrypted_payload) = decrypted_payload { new_message.decrypted_payload = ::serde_json::to_string(&decrypted_payload).ok(); - } else if let Ok(decrypted_payload) = self._decrypt_v3_message(vk) { + } else if let Ok(decrypted_payload) = self._decrypt_v3_message() { new_message.decrypted_payload = ::serde_json::to_string(&json!(decrypted_payload)).ok() } else { new_message.decrypted_payload = ::serde_json::to_string(&json!(null)).ok(); @@ -304,14 +304,14 @@ impl Message { new_message } - fn _decrypt_v3_message(&self, vk: &str) -> VcxResult<::messages::payload::PayloadV1> { + fn _decrypt_v3_message(&self) -> VcxResult<::messages::payload::PayloadV1> { use v3::messages::a2a::A2AMessage; use v3::utils::encryption_envelope::EncryptionEnvelope; use ::issuer_credential::{CredentialOffer, CredentialMessage}; use ::messages::payload::{PayloadTypes, PayloadV1, PayloadKinds}; use std::convert::TryInto; - let a2a_message = EncryptionEnvelope::open(vk, self.payload()?)?; + let a2a_message = EncryptionEnvelope::open(self.payload()?)?; let (kind, msg) = match a2a_message { A2AMessage::PresentationRequest(presentation_request) => { @@ -438,7 +438,6 @@ mod tests { fn test_parse_get_connection_messages_response() { init!("true"); - let json: serde_json::Value = rmp_serde::from_slice(GET_ALL_MESSAGES_RESPONSE).unwrap(); let result = GetMessagesBuilder::parse_download_messages_response(GET_ALL_MESSAGES_RESPONSE.to_vec()).unwrap(); assert_eq!(result.len(), 1) } @@ -452,12 +451,6 @@ mod tests { last_updated_date_time: "2017-12-14T03:35:20.444Z[UTC]".to_string(), }; - let delivery_details2 = DeliveryDetails { - to: "3Xk9vxK9jeiqVaCPrEQ8bg".to_string(), - status_code: "MDS-101".to_string(), - last_updated_date_time: "2017-12-14T03:35:20.500Z[UTC]".to_string(), - }; - let msg1 = Message { status_code: MessageStatusCode::Accepted, payload: Some(MessagePayload::V1(vec![-9, 108, 97, 105, 109, 45, 100, 97, 116, 97])), @@ -491,7 +484,7 @@ mod tests { let bundle = Bundled::create(data).encode().unwrap(); let message = crypto::prep_msg(&my_vk, &verkey, &bundle[..]).unwrap(); - let result = GetMessagesBuilder::create().parse_response(message).unwrap(); + let _result = GetMessagesBuilder::create().parse_response(message).unwrap(); } #[cfg(feature = "agency")] @@ -503,7 +496,7 @@ mod tests { init!("agency"); let institution_did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); - let (faber, alice) = ::connection::tests::create_connected_connections(); + let (_faber, alice) = ::connection::tests::create_connected_connections(); let (_, cred_def_handle) = ::credential_def::tests::create_cred_def_real(false); let credential_data = r#"{"address1": ["123 Main St"], "address2": ["Suite 3"], "city": ["Draper"], "state": ["UT"], "zip": ["84000"]}"#; diff --git a/vcx/libvcx/src/messages/invite.rs b/vcx/libvcx/src/messages/invite.rs index 44dec38c5f..7ba2098454 100644 --- a/vcx/libvcx/src/messages/invite.rs +++ b/vcx/libvcx/src/messages/invite.rs @@ -535,8 +535,8 @@ mod tests { init!("false"); let (user_did, user_vk) = create_and_store_my_did(None).unwrap(); let (agent_did, agent_vk) = create_and_store_my_did(Some(MY2_SEED)).unwrap(); - let (my_did, my_vk) = create_and_store_my_did(Some(MY1_SEED)).unwrap(); - let (agency_did, agency_vk) = create_and_store_my_did(Some(MY3_SEED)).unwrap(); + let (_my_did, my_vk) = create_and_store_my_did(Some(MY1_SEED)).unwrap(); + let (_agency_did, agency_vk) = create_and_store_my_did(Some(MY3_SEED)).unwrap(); settings::set_config_value(settings::CONFIG_AGENCY_VERKEY, &agency_vk); settings::set_config_value(settings::CONFIG_REMOTE_TO_SDK_VERKEY, &agent_vk); diff --git a/vcx/libvcx/src/messages/mod.rs b/vcx/libvcx/src/messages/mod.rs index 023cc3fc6a..0d9ee3f63f 100644 --- a/vcx/libvcx/src/messages/mod.rs +++ b/vcx/libvcx/src/messages/mod.rs @@ -858,7 +858,7 @@ impl Bundled { pub fn try_i8_bundle(data: Vec) -> VcxResult>> { let bundle: Bundled> = rmp_serde::from_slice(&data[..]) - .map_err(|err| { + .map_err(|_| { warn!("could not deserialize bundle with i8, will try u8"); VcxError::from_msg(VcxErrorKind::InvalidMessagePack, "Could not deserialize bundle with i8") })?; diff --git a/vcx/libvcx/src/messages/payload.rs b/vcx/libvcx/src/messages/payload.rs index a3a0f438e4..03adf4b608 100644 --- a/vcx/libvcx/src/messages/payload.rs +++ b/vcx/libvcx/src/messages/payload.rs @@ -87,7 +87,7 @@ impl Payloads { Ok((payload.msg, None)) } MessagePayload::V2(payload) => { - let payload = Payloads::decrypt_payload_v2(my_vk, payload)?; + let payload = Payloads::decrypt_payload_v2(payload)?; Ok((payload.msg, Some(payload.thread))) } } @@ -102,7 +102,7 @@ impl Payloads { Ok(my_payload) } - pub fn decrypt_payload_v2(my_vk: &str, payload: &::serde_json::Value) -> VcxResult { + pub fn decrypt_payload_v2(payload: &::serde_json::Value) -> VcxResult { let payload = ::serde_json::to_vec(&payload) .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidState, err))?; diff --git a/vcx/libvcx/src/messages/proofs/proof_message.rs b/vcx/libvcx/src/messages/proofs/proof_message.rs index 1ae33ea013..46a878b140 100644 --- a/vcx/libvcx/src/messages/proofs/proof_message.rs +++ b/vcx/libvcx/src/messages/proofs/proof_message.rs @@ -80,10 +80,6 @@ pub mod tests { use super::*; use ::utils::constants::{SCHEMA_ID, CRED_DEF_ID, REV_REG_ID}; - static TEMP_REQUESTER_DID: &'static str = "GxtnGN6ypZYgEqcftSQFnC"; - static MSG_FROM_API: &str = r#"{"proofs":{"claim::71b6070f-14ba-45fa-876d-1fe8491fe5d4":{"proof":{"primary_proof":{"eq_proof":{"revealed_attrs":{"sex":"5944657099558967239210949258394887428692050081607692519917050011144233115103","name":"1139481716457488690172217916278103335"},"a_prime":"55115757663642844902979276276581544287881791112969892277372135316353511833640150801244335663890109536491278379177551666081054765286807563008348637104046950934828407012194403360724040287698135607556244297972578864339500981366412262454282194811242239615009347165118318516694216754501345324782597475927199400880006212632553233049354866295429520527445980181939247828351677971991914388778860092824318440481574181300185829423762990910739241691289976584754979812272223819007422499654272590946235912914032826994670588466080422906806402660885408376207875827950805200378568062518210110828954480363081643567615791016011737856977","e":"34976147138641338975844073241645969211530343885520088294714132974884138611036204288689212378023649179372520412699253155486970203797562324","v":"961473607552945346906354315658276499450491951690969023699851664262072769313929148332129868528140265952852653009499943891795293148107502144091334703992581737220352761140064276811372868396353572957613845323343723271098601244774874235526135299483412285009916812621185291842845156342501611029106982811773616231232684804116984093651972537804480090649736612551759833591251845595059217608938213987633789344584340351801507541774726753840600143685051258161251666953243698589585559347435011414292427590918153421953579895479604685390401357681887618798200391305919594609949167659780330698000168295871428737686822637913218269005987492318466661186509308179489615192663542904993253626728197630057096161118638090776180812895097232529119979970798938360220605280817954648588493778338816318524451785027916181454650102696493927306340658666852294316562458212054696739343800993703515542777264448535624584845146378512183572107830260813929222999","m":{},"m1":"75548120024969192086664289521241751069844239013520403238642886571169851979005373784309432586593371476370934469326730539754613694936161784687213609047455188306625204249706249661640538349287762196100659095340756990269587317065862046598569445591945049204366911309949910119711238973099702616527117177036784698661","m2":"287944186286321709724396773443214682376883853676549188669693055373059354657799325692443906346632814001611911026063358134413175852024773765930829079850890920811398176944587192618"},"ge_proofs":[{"u":{"1":"1","0":"0","3":"3","2":"4"},"r":{"1":"1","0":"2","DELTA":"3","3":"4","2":"5"},"mj":"6","alpha":"7","t":{"1":"8","3":"3","0":"2","DELTA":"1","2":"2"},"predicate":{"attr_name":"age","p_type":"GE","value":18,"schema_seq_no":14,"issuer_did":"33UDR9R7fjwELRvH9JT6HH"}}]},"non_revoc_proof":null},"schema_seq_no":103,"issuer_did":"V4SGRU86Z58d6TV7PBUe6f"}},"aggregated_proof":{"c_hash":"63330487197040957750863022608534150304998351350639315143102570772502292901825","c_list":[[1,180,153,212,162,132,5,189,14,181,140,112,236,109,182,76,91,6,161,215,62,207,205,135,86,211,49,197,215,198,104,201,14,22,48,6,112,170,31,191,110,118,121,15,62,114,126,249,221,107,114,161,163,234,19,233,150,236,182,217,195,6,218,217,193,6,94,160,33,23,103,147,109,221,81,38,138,20,225,141,68,37,142,10,225,79,164,119,168,250,188,186,47,229,165,8,237,230,14,35,53,176,97,28,82,105,87,210,117,16,154,222,66,11,96,172,90,13,239,190,29,71,11,88,53,36,219,139,67,21,136,58,161,164,97,106,56,230,55,157,59,35,187,235,154,194,111,93,168,135,67,15,97,136,38,169,87,142,32,255,50,247,111,83,44,88,251,99,6,226,182,170,146,229,118,164,118,228,235,51,137,168,135,50,1,14,1,201,72,175,102,241,149,117,88,83,84,37,205,130,26,155,124,158,211,89,112,33,46,24,94,93,202,8,127,172,214,178,6,156,79,188,132,223,239,127,200,158,95,247,139,101,51,162,168,175,74,1,67,201,94,108,192,14,130,109,217,248,193,10,142,37,95,231,227,251,209]]},"requested_proof":{"revealed_attrs":{"attr2_uuid":["claim::71b6070f-14ba-45fa-876d-1fe8491fe5d4","male","5944657099558967239210949258394887428692050081607692519917050011144233115103"],"attr1_uuid":["claim::71b6070f-14ba-45fa-876d-1fe8491fe5d4","Alex","1139481716457488690172217916278103335"]},"unrevealed_attrs":{},"self_attested_attrs":{"self_attr":"self_value"},"predicates":{"predicate_id":"claim::71b6070f-14ba-45fa-876d-1fe8491fe5d4"}},"remoteDid":"KP8AaEBc368CMK1PqZaEzX","userPairwiseDid":"PofTCeegEXT7S2aAePhM6a"}"#; - static TEST_ATTRS: &str = r#"[{"schema_seq_no":14,"issuer_did":"33UDR9R7fjwELRvH9JT6HH","credential_uuid":"claim::f33cc7c8-924f-4541-aeff-29a9aed9c46b","proof_attrs":[{"name":"state","value":"UT","revealed":true}]},{"schema_seq_no":15,"issuer_did":"4fUDR9R7fjwELRvH9JT6HH","credential_uuid":"claim::f22cc7c8-924f-4541-aeff-29a9aed9c46b","proof_attrs":[{"name":"state","value":"UT","revealed":true}]}]"#; - pub fn create_default_proof() -> ProofMessage { let mut proof = ProofMessage::new(); proof.libindy_proof = ::utils::constants::INDY_PROOF_JSON.to_string(); diff --git a/vcx/libvcx/src/messages/proofs/proof_request.rs b/vcx/libvcx/src/messages/proofs/proof_request.rs index 52e7fa165d..19e1ad392a 100644 --- a/vcx/libvcx/src/messages/proofs/proof_request.rs +++ b/vcx/libvcx/src/messages/proofs/proof_request.rs @@ -30,16 +30,19 @@ struct ProofTopic { #[serde(untagged)] pub enum Restrictions { V1(Vec), - V2(::serde_json::Value) + V2(::serde_json::Value), } #[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] pub struct AttrInfo { - pub name: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub name: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub names: Option>, #[serde(skip_serializing_if = "Option::is_none")] pub restrictions: Option, #[serde(skip_serializing_if = "Option::is_none")] - pub non_revoked: Option + pub non_revoked: Option, } #[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] @@ -49,7 +52,7 @@ pub struct Filter { pub schema_name: Option, pub schema_version: Option, pub issuer_did: Option, - pub cred_def_id: Option + pub cred_def_id: Option, } #[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] @@ -61,7 +64,7 @@ pub struct PredicateInfo { #[serde(skip_serializing_if = "Option::is_none")] pub restrictions: Option, #[serde(skip_serializing_if = "Option::is_none")] - pub non_revoked: Option + pub non_revoked: Option, } #[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] @@ -72,7 +75,7 @@ pub struct ProofPredicates { #[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, Hash)] pub struct NonRevokedInterval { pub from: Option, - pub to: Option + pub to: Option, } #[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] @@ -81,10 +84,12 @@ pub struct ProofRequestData { pub name: String, #[serde(rename = "version")] pub data_version: String, + #[serde(default)] pub requested_attributes: HashMap, + #[serde(default)] pub requested_predicates: HashMap, pub non_revoked: Option, - pub ver: Option + pub ver: Option, } #[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] @@ -129,7 +134,7 @@ impl ProofRequestMessage { requested_attributes: HashMap::new(), requested_predicates: HashMap::new(), non_revoked: None, - ver: None + ver: None, }, msg_ref_id: None, from_timestamp: None, @@ -186,12 +191,30 @@ impl ProofRequestMessage { let mut index = 1; for mut attr in proof_attrs.into_iter() { + let attr_name = match (attr.name.as_ref(), attr.names.as_ref()) { + (Some(name), None) => { name.clone() } + (None, Some(names)) => { + if names.is_empty(){ + return Err(VcxError::from_msg(VcxErrorKind::InvalidProofRequest, "Proof Request validation failed: there is empty request attribute names")) + } + names.join(",") + } + (Some(_), Some(_)) => { + return Err(VcxError::from_msg(VcxErrorKind::InvalidProofRequest, + format!("Proof Request validation failed: there is empty requested attribute: {:?}", attrs))); + } + (None, None) => { + return Err(VcxError::from_msg(VcxErrorKind::InvalidProofRequest, + format!("Proof request validation failed: there is a requested attribute with both name and names: {:?}", attrs))); + } + }; + attr.restrictions = self.process_restrictions(attr.restrictions); - if check_req_attrs.contains_key(&attr.name) { - check_req_attrs.insert(format!("{}_{}", attr.name, index), attr); + if check_req_attrs.contains_key(&attr_name) { + check_req_attrs.insert(format!("{}_{}", attr_name, index), attr); } else { - check_req_attrs.insert(attr.name.clone(), attr); + check_req_attrs.insert(attr_name, attr); } index = index + 1; } @@ -317,7 +340,7 @@ impl ProofRequestData { pub fn set_requested_attributes(mut self, requested_attrs: String) -> VcxResult { let requested_attributes: Vec = ::serde_json::from_str(&requested_attrs) - .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidJson, format!("Invalid Requested Attributes: {:?}", requested_attrs)))?; + .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidJson, format!("Invalid Requested Attributes: {:?}, err: {:?}", requested_attrs, err)))?; self.requested_attributes = requested_attributes .into_iter() @@ -329,7 +352,7 @@ impl ProofRequestData { pub fn set_requested_predicates(mut self, requested_predicates: String) -> VcxResult { let requested_predicates: Vec = ::serde_json::from_str(&requested_predicates) - .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidJson, format!("Invalid Requested Attributes: {:?}", requested_predicates)))?; + .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidJson, format!("Invalid Requested Attributes: {:?}, err: {:?}", requested_predicates, err)))?; self.requested_predicates = requested_predicates .into_iter() @@ -341,7 +364,7 @@ impl ProofRequestData { pub fn set_not_revoked_interval(mut self, non_revoc_interval: String) -> VcxResult { let non_revoc_interval: NonRevokedInterval = ::serde_json::from_str(&non_revoc_interval) - .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidJson, format!("Invalid Revocation Interval: {:?}", non_revoc_interval)))?; + .map_err(|_| VcxError::from_msg(VcxErrorKind::InvalidJson, format!("Invalid Revocation Interval: {:?}", non_revoc_interval)))?; self.non_revoked = match (non_revoc_interval.from, non_revoc_interval.to) { (None, None) => None, @@ -424,7 +447,6 @@ mod tests { let data_name = "Test"; let nonce = "123432421212"; let data_version = "3.75"; - let attrs = ""; let version = "1.3"; let tid = 89; let mid = 98; @@ -477,8 +499,34 @@ mod tests { assert_eq!(request.proof_request_data.requested_predicates, check_predicates); } + #[test] + fn test_requested_attrs_constructed_correctly_for_names() { + let attr_info = json!({ "names":["name", "age", "email"], "restrictions": [ { "schema_id": "6XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11" } ] }); + let attr_info_2 = json!({ "name":"name", "restrictions": [ { "schema_id": "6XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11" } ] }); + + let requested_attrs = json!([ attr_info, attr_info_2 ]).to_string(); + + let request = proof_request().requested_attrs(&requested_attrs).unwrap().clone(); + + let mut expected_req_attrs: HashMap = HashMap::new(); + expected_req_attrs.insert("name,age,email".to_string(), serde_json::from_value(attr_info).unwrap()); + expected_req_attrs.insert("name".to_string(), serde_json::from_value(attr_info_2).unwrap()); + + assert_eq!(request.proof_request_data.requested_attributes, expected_req_attrs); + } + + #[test] + fn test_requested_attrs_constructed_correctly_for_name_and_names_passed_together() { + let attr_info = json!({ "name":"name", "names":["name", "age", "email"], "restrictions": [ { "schema_id": "6XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11" } ] }); + + let requested_attrs = json!([ attr_info ]).to_string(); + + let err = proof_request().requested_attrs(&requested_attrs).unwrap_err(); + assert_eq!(VcxErrorKind::InvalidProofRequest, err.kind()); + } + #[test] fn test_indy_proof_req_parses_correctly() { - let proof_req: ProofRequestData = serde_json::from_str(::utils::constants::INDY_PROOF_REQ_JSON).unwrap(); + let _proof_req: ProofRequestData = serde_json::from_str(::utils::constants::INDY_PROOF_REQ_JSON).unwrap(); } } \ No newline at end of file diff --git a/vcx/libvcx/src/messages/send_message.rs b/vcx/libvcx/src/messages/send_message.rs index 55ebcf3fe3..66017da363 100644 --- a/vcx/libvcx/src/messages/send_message.rs +++ b/vcx/libvcx/src/messages/send_message.rs @@ -255,7 +255,7 @@ mod tests { }; /* just check that it doesn't panic */ - let packed = message.prepare_request().unwrap(); + let _packed = message.prepare_request().unwrap(); } #[test] @@ -287,7 +287,6 @@ mod tests { let uid = response.get_msg_uid().unwrap(); assert_eq!(test_val, uid); - let test_val = "devin"; let response = SendResponse { uid: None, uids: vec![], @@ -302,8 +301,7 @@ mod tests { #[test] fn test_send_generic_message() { init!("agency"); - let institution_did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); - let (faber, alice) = ::connection::tests::create_connected_connections(); + let (_faber, alice) = ::connection::tests::create_connected_connections(); match send_generic_message(alice, "this is the message", &json!({"msg_type":"type", "msg_title": "title", "ref_msg_id":null}).to_string()) { Ok(x) => println!("message id: {}", x), @@ -320,7 +318,6 @@ mod tests { #[test] fn test_send_message_and_download_response() { init!("agency"); - let institution_did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); let (faber, alice) = ::connection::tests::create_connected_connections(); let msg_id = send_generic_message(alice, "this is the message", &json!({"msg_type":"type", "msg_title": "title", "ref_msg_id":null}).to_string()).unwrap(); diff --git a/vcx/libvcx/src/messages/update_connection.rs b/vcx/libvcx/src/messages/update_connection.rs index 2e63082e0c..f2c9e3109c 100644 --- a/vcx/libvcx/src/messages/update_connection.rs +++ b/vcx/libvcx/src/messages/update_connection.rs @@ -93,19 +93,11 @@ impl DeleteConnectionBuilder { let mut response = parse_response_from_agency(response)?; match response.remove(0) { - A2AMessage::Version1(A2AMessageV1::UpdateConnectionResponse(res)) => Ok(()), - A2AMessage::Version2(A2AMessageV2::UpdateConnectionResponse(res)) => Ok(()), + A2AMessage::Version1(A2AMessageV1::UpdateConnectionResponse(_)) => Ok(()), + A2AMessage::Version2(A2AMessageV2::UpdateConnectionResponse(_)) => Ok(()), _ => Err(VcxError::from_msg(VcxErrorKind::InvalidHttpResponse, "Message does not match any variant of UpdateConnectionResponse")) } } - - fn print_info(&self) { - println!("\n****\n**** message pack: Delete Connection"); - println!("self.status_code {:?}", &self.status_code); - println!("self.to_vk: {}", &self.to_vk); - println!("self.agent_did: {}", &self.agent_did); - println!("self.agent_vk: {}", &self.agent_vk); - } } pub fn send_delete_connection_message(pw_did: &str, pw_verkey: &str, agent_did: &str, agent_vk: &str) -> VcxResult<()> { diff --git a/vcx/libvcx/src/messages/update_message.rs b/vcx/libvcx/src/messages/update_message.rs index 49703549e4..65e3d35689 100644 --- a/vcx/libvcx/src/messages/update_message.rs +++ b/vcx/libvcx/src/messages/update_message.rs @@ -105,8 +105,8 @@ impl UpdateMessageStatusByConnectionsBuilder { let mut response = parse_response_from_agency(response)?; match response.remove(0) { - A2AMessage::Version1(A2AMessageV1::UpdateMessageStatusByConnectionsResponse(res)) => Ok(()), - A2AMessage::Version2(A2AMessageV2::UpdateMessageStatusByConnectionsResponse(res)) => Ok(()), + A2AMessage::Version1(A2AMessageV1::UpdateMessageStatusByConnectionsResponse(_)) => Ok(()), + A2AMessage::Version2(A2AMessageV2::UpdateMessageStatusByConnectionsResponse(_)) => Ok(()), _ => Err(VcxError::from_msg(VcxErrorKind::InvalidHttpResponse, "Message does not match any variant of UpdateMessageStatusByConnectionsResponse")) } } @@ -154,7 +154,7 @@ mod tests { use std::time::Duration; init!("agency"); let institution_did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); - let (faber, alice) = ::connection::tests::create_connected_connections(); + let (_faber, alice) = ::connection::tests::create_connected_connections(); let (_, cred_def_handle) = ::credential_def::tests::create_cred_def_real(false); diff --git a/vcx/libvcx/src/messages/update_profile.rs b/vcx/libvcx/src/messages/update_profile.rs index 7c3d9f5955..65941509cb 100644 --- a/vcx/libvcx/src/messages/update_profile.rs +++ b/vcx/libvcx/src/messages/update_profile.rs @@ -123,8 +123,8 @@ impl UpdateProfileDataBuilder { let mut response = parse_response_from_agency(&response)?; match response.remove(0) { - A2AMessage::Version1(A2AMessageV1::UpdateConfigsResponse(res)) => Ok(()), - A2AMessage::Version2(A2AMessageV2::UpdateConfigsResponse(res)) => Ok(()), + A2AMessage::Version1(A2AMessageV1::UpdateConfigsResponse(_)) => Ok(()), + A2AMessage::Version2(A2AMessageV2::UpdateConfigsResponse(_)) => Ok(()), _ => Err(VcxError::from_msg(VcxErrorKind::InvalidHttpResponse, "Message does not match any variant of UpdateConfigsResponse")) } } @@ -142,7 +142,7 @@ mod tests { let to_did = "8XFh8yBzrpJQmNyZzgoTqB"; let name = "name"; let url = "https://random.com"; - let msg = update_data() + let _msg = update_data() .to(to_did).unwrap() .name(&name).unwrap() .logo_url(&url).unwrap() @@ -153,8 +153,8 @@ mod tests { fn test_update_data_set_values_and_post() { init!("false"); let (agent_did, agent_vk) = create_and_store_my_did(Some(MY2_SEED)).unwrap(); - let (my_did, my_vk) = create_and_store_my_did(Some(MY1_SEED)).unwrap(); - let (agency_did, agency_vk) = create_and_store_my_did(Some(MY3_SEED)).unwrap(); + let (_my_did, my_vk) = create_and_store_my_did(Some(MY1_SEED)).unwrap(); + let (_agency_did, agency_vk) = create_and_store_my_did(Some(MY3_SEED)).unwrap(); settings::set_config_value(settings::CONFIG_AGENCY_VERKEY, &agency_vk); settings::set_config_value(settings::CONFIG_REMOTE_TO_SDK_VERKEY, &agent_vk); diff --git a/vcx/libvcx/src/messages/validation.rs b/vcx/libvcx/src/messages/validation.rs index 6f94990f15..c153cbb78c 100644 --- a/vcx/libvcx/src/messages/validation.rs +++ b/vcx/libvcx/src/messages/validation.rs @@ -55,7 +55,7 @@ pub fn validate_url(url: &str) -> VcxResult { pub fn validate_actors(actors: &str) -> VcxResult> { ::serde_json::from_str(&actors) - .map_err(|err| VcxError::from(VcxErrorKind::InvalidOption)) + .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidOption, format!("Invalid actors: {:?}", err))) } pub fn validate_phone_number(p_num: &str) -> VcxResult { @@ -70,7 +70,7 @@ mod tests { fn test_did_is_b58_and_valid_length() { let to_did = "8XFh8yBzrpJQmNyZzgoTqB"; match validate_did(&to_did) { - Err(x) => panic!("Should be valid did"), + Err(_) => panic!("Should be valid did"), Ok(x) => assert_eq!(x, to_did.to_string()) } } @@ -80,7 +80,7 @@ mod tests { let to_did = "8XFh8yBzrpJQmNyZzgoT"; match validate_did(&to_did) { Err(x) => assert_eq!(x.kind(), VcxErrorKind::InvalidDid), - Ok(x) => panic!("Should be invalid did"), + Ok(_) => panic!("Should be invalid did"), } } @@ -89,7 +89,7 @@ mod tests { let to_did = "8*Fh8yBzrpJQmNyZzgoTqB"; match validate_did(&to_did) { Err(x) => assert_eq!(x.kind(), VcxErrorKind::NotBase58), - Ok(x) => panic!("Should be invalid did"), + Ok(_) => panic!("Should be invalid did"), } } @@ -97,7 +97,7 @@ mod tests { fn test_verkey_is_b58_and_valid_length() { let verkey = "EkVTa7SCJ5SntpYyX7CSb2pcBhiVGT9kWSagA8a9T69A"; match validate_verkey(&verkey) { - Err(x) => panic!("Should be valid verkey"), + Err(_) => panic!("Should be valid verkey"), Ok(x) => assert_eq!(x, verkey) } } @@ -107,7 +107,7 @@ mod tests { let verkey = "8XFh8yBzrpJQmNyZzgoT"; match validate_verkey(&verkey) { Err(x) => assert_eq!(x.kind(), VcxErrorKind::InvalidVerkey), - Ok(x) => panic!("Should be invalid verkey"), + Ok(_) => panic!("Should be invalid verkey"), } } @@ -116,7 +116,7 @@ mod tests { let verkey = "*kVTa7SCJ5SntpYyX7CSb2pcBhiVGT9kWSagA8a9T69A"; match validate_verkey(&verkey) { Err(x) => assert_eq!(x.kind(), VcxErrorKind::NotBase58), - Ok(x) => panic!("Should be invalid verkey"), + Ok(_) => panic!("Should be invalid verkey"), } } } \ No newline at end of file diff --git a/vcx/libvcx/src/object_cache/mod.rs b/vcx/libvcx/src/object_cache/mod.rs index b403e8496f..2a7accad08 100644 --- a/vcx/libvcx/src/object_cache/mod.rs +++ b/vcx/libvcx/src/object_cache/mod.rs @@ -45,7 +45,7 @@ impl ObjectCache { match store.get(&handle) { Some(m) => match m.lock() { Ok(obj) => closure(obj.deref()), - Err(err) => Err(VcxError::from_msg(VcxErrorKind::Common(10), "Unable to lock Object Store")) //TODO better error + Err(_) => Err(VcxError::from_msg(VcxErrorKind::Common(10), "Unable to lock Object Store")) //TODO better error }, None => Err(VcxError::from_msg(VcxErrorKind::InvalidHandle, format!("Object not found for handle: {}", handle))) } @@ -57,7 +57,7 @@ impl ObjectCache { match store.get_mut(&handle) { Some(m) => match m.lock() { Ok(mut obj) => closure(obj.deref_mut()), - Err(err) => Err(VcxError::from_msg(VcxErrorKind::Common(10), "Unable to lock Object Store")) //TODO better error + Err(_) => Err(VcxError::from_msg(VcxErrorKind::Common(10), "Unable to lock Object Store")) //TODO better error }, None => Err(VcxError::from_msg(VcxErrorKind::InvalidHandle, format!("Object not found for handle: {}", handle))) } @@ -108,7 +108,7 @@ mod tests { #[test] fn create_test() { - let c: ObjectCache = Default::default(); + let _c: ObjectCache = Default::default(); } #[test] @@ -124,13 +124,14 @@ mod tests { fn to_string_test() { let test: ObjectCache = Default::default(); let handle = test.add(2222).unwrap(); - let string: String = test.get(handle, |obj| { + let string: String = test.get(handle, |_| { Ok(String::from("TEST")) }).unwrap(); assert_eq!("TEST", string); } + #[test] fn mut_object_test() { let test: ObjectCache = Default::default(); let handle = test.add(String::from("TEST")).unwrap(); @@ -144,6 +145,6 @@ mod tests { Ok(obj.clone()) }).unwrap(); - assert_eq!("test", string); + assert_eq!("TEST", string); } } diff --git a/vcx/libvcx/src/proof.rs b/vcx/libvcx/src/proof.rs index 7b9c30c1ee..cf9af24d47 100644 --- a/vcx/libvcx/src/proof.rs +++ b/vcx/libvcx/src/proof.rs @@ -8,14 +8,13 @@ use connection; use api::{VcxStateType, ProofStateType}; use messages; use messages::proofs::proof_message::{ProofMessage, CredInfo}; -use messages::{RemoteMessageType, ObjectWithVersion, GeneralMessage}; +use messages::{RemoteMessageType, GeneralMessage}; use messages::payload::{Payloads, PayloadKinds}; use messages::thread::Thread; use messages::proofs::proof_request::{ProofRequestMessage, ProofRequestVersion}; use utils::error; use utils::constants::*; use utils::libindy::anoncreds; -use utils::constants::DEFAULT_SERIALIZE_VERSION; use object_cache::ObjectCache; use error::prelude::*; use utils::openssl::encode; @@ -213,10 +212,6 @@ impl Proof { } fn proof_validation(&mut self) -> VcxResult { - let proof_msg = self.proof - .clone() - .ok_or(VcxError::from(VcxErrorKind::InvalidProof))?; - let proof_json = self.build_proof_json()?; let proof_req_json = self.build_proof_req_json()?; @@ -355,7 +350,7 @@ impl Proof { let (payload, thread) = Payloads::decrypt(&self.prover_vk, &message)?; - if let Some(tr) = thread { + if let Some(_) = thread { let remote_did = self.remote_did.as_str(); self.thread.as_mut().map(|thread| thread.increment_receiver(&remote_did)); } @@ -367,14 +362,14 @@ impl Proof { debug!("proof: {}", payload); self.proof = match parse_proof_payload(&payload) { - Err(err) => return Ok(self.get_state()), + Err(_) => return Ok(self.get_state()), Ok(x) => Some(x), }; self.state = VcxStateType::VcxStateAccepted; match self.proof_validation() { - Ok(x) => { + Ok(_) => { if self.proof_state != ProofStateType::ProofInvalid { debug!("Proof format was validated for proof {}", self.source_id); self.proof_state = ProofStateType::ProofValidated; @@ -406,15 +401,11 @@ impl Proof { fn get_proof_uuid(&self) -> &String { &self.msg_uid } - fn get_source_id(&self) -> &String { &self.source_id } - - fn to_string(&self) -> VcxResult { - ObjectWithVersion::new(DEFAULT_SERIALIZE_VERSION, self.to_owned()) - .serialize() - .map_err(|err| err.extend("Cannot serialize Proof")) - } + fn get_source_id(&self) -> String { self.source_id.to_string() } + #[cfg(test)] fn from_str(data: &str) -> VcxResult { + use messages::ObjectWithVersion; ObjectWithVersion::deserialize(data) .map(|obj: ObjectWithVersion| obj.data) .map_err(|err| err.extend("Cannot deserialize Proof")) @@ -528,8 +519,10 @@ pub fn to_string(handle: u32) -> VcxResult { pub fn get_source_id(handle: u32) -> VcxResult { PROOF_MAP.get(handle, |obj| { - serde_json::to_string(obj) - .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidState, format!("cannot serialize Proofs object: {:?}", err))) + match obj { + Proofs::V1(ref obj) => Ok(obj.get_source_id()), + Proofs::V3(ref obj) => Ok(obj.get_source_id()) + } }) } @@ -567,7 +560,7 @@ pub fn get_proof_uuid(handle: u32) -> VcxResult { PROOF_MAP.get(handle, |obj| { match obj { Proofs::V1(ref obj) => Ok(obj.get_proof_uuid().clone()), - Proofs::V3(ref obj) => Err(VcxError::from(VcxErrorKind::InvalidProofHandle)) + Proofs::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidProofHandle)) } }) } @@ -604,14 +597,6 @@ mod tests { use connection::tests::build_test_connection; use utils::libindy::{pool, set_libindy_rc}; - static PROOF_MSG: &str = r#"{"msg_type":"proof","version":"0.1","to_did":"BnRXf8yDMUwGyZVDkSENeq","from_did":"GxtnGN6ypZYgEqcftSQFnC","proof_request_id":"cCanHnpFAD","proofs":{"claim::e5fec91f-d03d-4513-813c-ab6db5715d55":{"proof":{"primary_proof":{"eq_proof":{"revealed_attrs":{"state":"96473275571522321025213415717206189191162"},"a_prime":"22605045280481376895214546474258256134055560453004805058368015338423404000586901936329279496160366852115900235316791489357953785379851822281248296428005020302405076144264617943389810572564188437603815231794326272302243703078443007359698858400857606408856314183672828086906560155576666631125808137726233827430076624897399072853872527464581329767287002222137559918765406079546649258389065217669558333867707240780369514832185660287640444094973804045885379406641474693993903268791773620198293469768106363470543892730424494655747935463337367735239405840517696064464669905860189004121807576749786474060694597244797343224031","e":"70192089123105616042684481760592174224585053817450673797400202710878562748001698340846985261463026529360990669802293480312441048965520897","v":"1148619141217957986496757711054111791862691178309410923416837802801708689012670430650138736456223586898110113348220116209094530854607083005898964558239710027534227973983322542548800291320747321452329327824406430787211689678096549398458892087551551587767498991043777397791000822007896620414888602588897806008609113730393639807814070738699614969916095861363383223421727858670289337712185089527052065958362840287749622133424503902085247641830693297082507827948006947829401008622239294382186995101394791468192083810475776455445579931271665980788474331866572497866962452476638881287668931141052552771328556458489781734943404258692308937784221642452132005267809852656378394530342203469943982066011466088478895643800295937901139711103301249691253510784029114718919483272055970725860849610885050165709968510696738864528287788491998027072378656038991754015693216663830793243584350961586874315757599094357535856429087122365865868729","m":{"address2":"11774234640096848605908744857306447015748098256395922562149769943967941106193320512788344020652220849708117081570187385467979956319507248530701654682748372348387275979419669108338","city":"4853213962270369118453000522408430296589146124488849630769837449684434138367659379663124155088827069418193027370932024893343033367076071757003149452226758383807126385017161888440","address1":"12970590675851114145396120869959510754345567924518524026685086869487243290925032320159287997675756075512889990901552679591155319959039145119122576164798225386578339739435869622811","zip":"8333721522340131864419931745588776943042067606218561135102011966361165456174036379901390244538991611895455576519950813910672825465382312504250936740379785802177629077591444977329"},"m1":"92853615502250003546205004470333326341901175168428906399291824325990659330595200000112546157141090642053863739870044907457400076448073272490169488870502566172795456430489790324815765612798273406119873266684053517977802902202155082987833343670942161987285661291655743810590661447300059024966135828466539810035","m2":"14442362430453309930284822850357071315613831915865367971974791350454381198894252834180803515368579729220423713315556807632571621646127926114010380486713602821529657583905131582938"},"ge_proofs":[]},"non_revoc_proof":null},"schema_seq_no":15,"issuer_did":"4fUDR9R7fjwELRvH9JT6HH"}},"aggregated_proof":{"c_hash":"68430476900085482958838239880418115228681348197588159723604944078288347793331","c_list":[[179,17,2,242,194,227,92,203,28,32,255,113,112,20,5,243,9,111,220,111,21,210,116,12,167,119,253,181,37,40,143,215,140,42,179,97,75,229,96,94,54,248,206,3,48,14,61,219,160,122,139,227,166,183,37,43,197,200,28,220,217,10,65,42,6,195,124,44,164,65,114,206,51,231,254,156,170,141,21,153,50,251,237,65,147,97,243,17,157,116,213,201,80,119,106,70,88,60,55,36,33,160,135,106,60,212,191,235,116,57,78,177,61,86,44,226,205,100,134,118,93,6,26,58,220,66,232,166,202,62,90,174,231,207,19,239,233,223,70,191,199,100,157,62,139,176,28,184,9,70,116,199,142,237,198,183,12,32,53,84,207,202,77,56,97,177,154,169,223,201,212,163,212,101,184,255,215,167,16,163,136,44,25,123,49,15,229,41,149,133,159,86,106,208,234,73,207,154,194,162,141,63,159,145,94,47,174,51,225,91,243,2,221,202,59,11,212,243,197,208,116,42,242,131,221,137,16,169,203,215,239,78,254,150,42,169,202,132,172,106,179,130,178,130,147,24,173,213,151,251,242,44,54,47,208,223]]},"requested_proof":{"revealed_attrs":{"sdf":["claim::e5fec91f-d03d-4513-813c-ab6db5715d55","UT","96473275571522321025213415717206189191162"]},"unrevealed_attrs":{},"self_attested_attrs":{},"predicates":{}}}"#; - - extern "C" fn create_cb(command_handle: u32, err: u32, connection_handle: u32) { - assert_eq!(err, 0); - assert!(connection_handle > 0); - println!("successfully called create_cb") - } - fn create_boxed_proof() -> Box { Box::new(Proof { source_id: "12".to_string(), @@ -774,8 +759,6 @@ mod tests { fn test_update_state_with_pending_proof() { init!("true"); - let connection_handle = build_test_connection(); - let mut proof = Box::new(Proof { source_id: "12".to_string(), msg_uid: String::from("1234"), @@ -810,8 +793,6 @@ mod tests { fn test_update_state_with_message() { init!("true"); - let connection_handle = build_test_connection(); - let mut proof = Box::new(Proof { source_id: "12".to_string(), msg_uid: String::from("1234"), @@ -843,8 +824,6 @@ mod tests { fn test_get_proof_returns_proof_when_proof_state_invalid() { init!("true"); - let connection_handle = build_test_connection(); - let mut proof = Box::new(Proof { source_id: "12".to_string(), msg_uid: String::from("1234"), @@ -885,8 +864,6 @@ mod tests { #[test] fn test_build_credential_defs_json_with_multiple_credentials() { init!("true"); - let proof = create_boxed_proof(); - let cred1 = CredInfo { schema_id: "schema_key1".to_string(), cred_def_id: "cred_def_key1".to_string(), @@ -910,7 +887,6 @@ mod tests { #[test] fn test_build_schemas_json_with_multiple_schemas() { init!("true"); - let proof = create_boxed_proof(); let cred1 = CredInfo { schema_id: "schema_key1".to_string(), cred_def_id: "cred_def_key1".to_string(), @@ -934,7 +910,6 @@ mod tests { #[test] fn test_build_rev_reg_defs_json() { init!("true"); - let proof = create_boxed_proof(); let cred1 = CredInfo { schema_id: "schema_key1".to_string(), cred_def_id: "cred_def_key1".to_string(), @@ -958,7 +933,6 @@ mod tests { #[test] fn test_build_rev_reg_json() { init!("true"); - let proof = create_boxed_proof(); let cred1 = CredInfo { schema_id: "schema_key1".to_string(), cred_def_id: "cred_def_key1".to_string(), @@ -1080,9 +1054,7 @@ mod tests { fn test_get_proof_request_status_can_be_retried() { init!("true"); - let connection_handle = build_test_connection(); - - let new_handle = 1; + let _new_handle = 1; let mut proof = create_boxed_proof(); @@ -1143,8 +1115,7 @@ mod tests { #[test] fn test_proof_verification() { init!("ledger"); - let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); - let (schemas, cred_defs, proof_req, proof) = ::utils::libindy::anoncreds::tests::create_proof(); + let (_, _, proof_req, proof) = ::utils::libindy::anoncreds::tests::create_proof(); let mut proof_req_obj = ProofRequestMessage::create(); proof_req_obj.proof_request_data = serde_json::from_str(&proof_req).unwrap(); @@ -1168,7 +1139,6 @@ mod tests { #[test] fn test_self_attested_proof_verification() { init!("ledger"); - let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); let (proof_req, proof) = ::utils::libindy::anoncreds::tests::create_self_attested_proof(); let mut proof_req_obj = ProofRequestMessage::create(); @@ -1207,8 +1177,7 @@ mod tests { "requested_predicates": {}, }).to_string(); - let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); - let (schemas, cred_defs, _, proof) = ::utils::libindy::anoncreds::tests::create_proof(); + let (_, _, _, proof) = ::utils::libindy::anoncreds::tests::create_proof(); let mut proof_req_obj = ProofRequestMessage::create(); proof_req_obj.proof_request_data = serde_json::from_str(&proof_req).unwrap(); @@ -1241,8 +1210,7 @@ mod tests { #[test] fn test_proof_validate_attribute() { init!("ledger"); - let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); - let (schemas, cred_defs, proof_req, proof_json) = ::utils::libindy::anoncreds::tests::create_proof(); + let (_, _, proof_req, proof_json) = ::utils::libindy::anoncreds::tests::create_proof(); let mut proof_req_obj = ProofRequestMessage::create(); @@ -1257,7 +1225,7 @@ mod tests { proof_msg.libindy_proof = proof_json.clone(); proof.proof = Some(proof_msg); - let rc = proof.proof_validation().unwrap(); + let _rc = proof.proof_validation().unwrap(); assert_eq!(proof.proof_state, ProofStateType::ProofValidated); } diff --git a/vcx/libvcx/src/schema.rs b/vcx/libvcx/src/schema.rs index 6c26587349..ea7e58350c 100644 --- a/vcx/libvcx/src/schema.rs +++ b/vcx/libvcx/src/schema.rs @@ -3,7 +3,6 @@ use serde_json; use std::string::ToString; use api::PublicEntityStateType; -use settings; use utils::libindy::anoncreds; use utils::libindy::ledger; use utils::libindy::payments::PaymentTxn; @@ -60,7 +59,7 @@ impl CreateSchema { } fn update_state(&mut self) -> VcxResult { - if let Ok(res) = anoncreds::get_schema_json(&self.schema_id) { + if anoncreds::get_schema_json(&self.schema_id).is_ok() { self.state = PublicEntityStateType::Published } Ok(self.state as u32) @@ -78,11 +77,11 @@ pub fn create_and_publish_schema(source_id: &str, debug!("creating schema with source_id: {}, name: {}, issuer_did: {}", source_id, name, issuer_did); let (schema_id, schema) = anoncreds::create_schema(&name, &version, &data)?; - let payment_txn = anoncreds::publish_schema(&name, &schema)?; + let payment_txn = anoncreds::publish_schema(&schema)?; debug!("created schema on ledger with id: {}", schema_id); - let schema_handle = _store_schema(source_id, issuer_did, name, version, schema_id, data, payment_txn, PublicEntityStateType::Published)?; + let schema_handle = _store_schema(source_id, name, version, schema_id, data, payment_txn, PublicEntityStateType::Published)?; Ok(schema_handle) } @@ -97,18 +96,17 @@ pub fn prepare_schema_for_endorser(source_id: &str, debug!("preparing schema for endorser with source_id: {}, name: {}, issuer_did: {}", source_id, name, issuer_did); let (schema_id, schema) = anoncreds::create_schema(&name, &version, &data)?; - let schema_request = anoncreds::build_schema_request(&name, &schema)?; + let schema_request = anoncreds::build_schema_request(&schema)?; let schema_request = ledger::set_endorser(&schema_request, &endorser)?; debug!("prepared schema for endorser with id: {}", schema_id); - let schema_handle = _store_schema(source_id, issuer_did, name, version, schema_id, data, None, PublicEntityStateType::Built)?; + let schema_handle = _store_schema(source_id, name, version, schema_id, data, None, PublicEntityStateType::Built)?; Ok((schema_handle, schema_request)) } fn _store_schema(source_id: &str, - issuer_did: String, name: String, version: String, schema_id: String, @@ -132,8 +130,6 @@ fn _store_schema(source_id: &str, pub fn get_schema_attrs(source_id: String, schema_id: String) -> VcxResult<(u32, String)> { trace!("get_schema_attrs >>> source_id: {}, schema_id: {}", source_id, schema_id); - let submitter_did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID)?; - let (schema_id, schema_data_json) = anoncreds::get_schema_json(&schema_id) .map_err(|err| err.map(VcxErrorKind::InvalidSchemaSeqNo, "Schema not found"))?; @@ -215,6 +211,7 @@ pub fn get_state(handle: u32) -> VcxResult { #[cfg(test)] pub mod tests { extern crate rand; + use settings; use super::*; #[allow(unused_imports)] @@ -258,7 +255,7 @@ pub mod tests { let value: serde_json::Value = serde_json::from_str(&schema_str).unwrap(); assert_eq!(value["version"], "1.0"); let data = value["data"].clone(); - let schema: CreateSchema = serde_json::from_str(&data.to_string()).unwrap(); + let _schema: CreateSchema = serde_json::from_str(&data.to_string()).unwrap(); } #[test] @@ -322,7 +319,7 @@ pub mod tests { assert!(payment.len() > 50); assert!(handle > 0); - let schema_id = get_schema_id(handle).unwrap(); + let _schema_id = get_schema_id(handle).unwrap(); } #[cfg(feature = "pool_tests")] @@ -333,7 +330,7 @@ pub mod tests { let handle = create_schema_real(); assert!(handle > 0); - let schema_id = get_schema_id(handle).unwrap(); + let _schema_id = get_schema_id(handle).unwrap(); } #[cfg(feature = "pool_tests")] diff --git a/vcx/libvcx/src/settings.rs b/vcx/libvcx/src/settings.rs index 0895241d0b..d0b35048ea 100644 --- a/vcx/libvcx/src/settings.rs +++ b/vcx/libvcx/src/settings.rs @@ -157,11 +157,6 @@ pub fn validate_config(config: &HashMap) -> VcxResult { Ok(error::SUCCESS.code_num) } -fn validate_wallet_key(key: &str) -> VcxResult { - if key == UNINITIALIZED_WALLET_KEY { return Err(VcxError::from(VcxErrorKind::MissingWalletKey)); } - Ok(error::SUCCESS.code_num) -} - fn validate_optional_config_val(val: Option<&String>, err: VcxErrorKind, closure: F) -> VcxResult where F: Fn(&str) -> Result { if val.is_none() { return Ok(error::SUCCESS.code_num); } @@ -189,7 +184,7 @@ pub fn test_indy_mode_enabled() -> bool { pub fn get_threadpool_size() -> usize { let size = match get_config_value(CONFIG_THREADPOOL_SIZE) { Ok(x) => x.parse::().unwrap_or(DEFAULT_THREADPOOL_SIZE), - Err(x) => DEFAULT_THREADPOOL_SIZE, + Err(_) => DEFAULT_THREADPOOL_SIZE, }; if size > MAX_THREADPOOL_SIZE { @@ -281,7 +276,7 @@ pub fn set_config_value(key: &str, value: &str) { .insert(key.to_string(), value.to_string()); } -pub fn get_wallet_config(wallet_name: &str, wallet_type: Option<&str>, storage_config: Option<&str>) -> String { +pub fn get_wallet_config(wallet_name: &str, wallet_type: Option<&str>, _storage_config: Option<&str>) -> String { // TODO: _storage_config must be used let mut config = json!({ "id": wallet_name, "storage_type": wallet_type @@ -293,7 +288,7 @@ pub fn get_wallet_config(wallet_name: &str, wallet_type: Option<&str>, storage_c config.to_string() } -pub fn get_wallet_credentials(storage_creds: Option<&str>) -> String { +pub fn get_wallet_credentials(_storage_creds: Option<&str>) -> String { // TODO: storage_creds must be used? let key = get_config_value(CONFIG_WALLET_KEY).unwrap_or(UNINITIALIZED_WALLET_KEY.to_string()); let mut credentials = json!({"key": key}); @@ -328,7 +323,7 @@ pub fn get_actors() -> Vec { get_config_value(ACTORS) .and_then(|actors| ::serde_json::from_str(&actors) - .map_err(|err| VcxError::from(VcxErrorKind::InvalidOption)) + .map_err(|_| VcxError::from(VcxErrorKind::InvalidOption)) ).unwrap_or_else(|_| Actors::iter().collect()) } @@ -414,7 +409,7 @@ pub fn remove_file_if_exists(filename: &str) { trace!("remove_file_if_exists >>> filename: {}", filename); if Path::new(filename).exists() { match fs::remove_file(filename) { - Ok(t) => (), + Ok(()) => (), Err(e) => println!("Unable to remove file: {:?}", e) } } @@ -547,8 +542,6 @@ pub mod tests { #[test] fn test_validate_config_failures() { let invalid = "invalid"; - let valid_did = DEFAULT_DID; - let valid_ver = DEFAULT_VERKEY; let mut config: HashMap = HashMap::new(); assert_eq!(validate_config(&config).unwrap_err().kind(), VcxErrorKind::MissingWalletKey); diff --git a/vcx/libvcx/src/utils/devsetup.rs b/vcx/libvcx/src/utils/devsetup.rs index 6fe4f366cd..b953bbae0d 100644 --- a/vcx/libvcx/src/utils/devsetup.rs +++ b/vcx/libvcx/src/utils/devsetup.rs @@ -118,6 +118,7 @@ pub mod tests { static mut INSTITUTION_CONFIG: u32 = 0; static mut CONSUMER_CONFIG: u32 = 0; use indy::ErrorCode; + use indy::WalletHandle; static INIT_PLUGIN: std::sync::Once = std::sync::Once::new(); @@ -211,8 +212,8 @@ pub mod tests { pub fn setup_ledger_env(use_zero_fees: bool) { match pool::get_pool_handle() { - Ok(x) => pool::close().unwrap(), - Err(x) => (), + Ok(_) => pool::close().unwrap(), + Err(_) => (), }; pool::tests::delete_test_pool(); @@ -267,7 +268,7 @@ pub mod tests { fn change_wallet_handle() { let wallet_handle = settings::get_config_value(settings::CONFIG_WALLET_HANDLE).unwrap(); - unsafe { wallet::WALLET_HANDLE = wallet_handle.parse::().unwrap() } + unsafe { wallet::WALLET_HANDLE = WalletHandle(wallet_handle.parse::().unwrap()) } } pub fn setup_local_env(protocol_type: &str) { @@ -353,7 +354,7 @@ pub mod tests { pub fn config_with_wallet_handle(wallet_n: &str, config: &str) -> String { let wallet_handle = wallet::open_wallet(wallet_n, None, None, None).unwrap(); let mut config: serde_json::Value = serde_json::from_str(config).unwrap(); - config[settings::CONFIG_WALLET_HANDLE] = json!(wallet_handle.to_string()); + config[settings::CONFIG_WALLET_HANDLE] = json!(wallet_handle.0.to_string()); config.to_string() } @@ -364,7 +365,7 @@ pub mod tests { ::utils::libindy::anoncreds::tests::create_and_store_credential(::utils::constants::DEFAULT_SCHEMA_ATTRS, false); } - pub fn setup_wallet_env(test_name: &str) -> Result { + pub fn setup_wallet_env(test_name: &str) -> Result { use utils::libindy::wallet::init_wallet; settings::set_config_value(settings::CONFIG_ENABLE_TEST_MODE,"false"); init_wallet(test_name, None, None, None).map_err(|e| format!("Unable to init_wallet in tests: {}", e)) @@ -387,7 +388,7 @@ pub mod tests { init!("agency"); - let (faber, alice) = ::connection::tests::create_connected_connections(); + let (_faber, _alice) = ::connection::tests::create_connected_connections(); set_institution(); wallet::tests::delete_test_wallet(&format!("{}_{}", constants::ENTERPRISE_PREFIX, settings::DEFAULT_WALLET_NAME)); pool::close().unwrap(); diff --git a/vcx/libvcx/src/utils/error.rs b/vcx/libvcx/src/utils/error.rs index 09b85198ba..db80e8495f 100644 --- a/vcx/libvcx/src/utils/error.rs +++ b/vcx/libvcx/src/utils/error.rs @@ -233,7 +233,7 @@ fn insert_c_message(map: &mut HashMap, error: &Error) { } // Helper function for static defining of error messages. Does limited checking that it can. -fn insert_message(map: &mut HashMap, error: &Error) { +fn _insert_message(map: &mut HashMap, error: &Error) { if map.contains_key(&error.code_num) { panic!("Error Code number was repeated which is not allowed! (likely a copy/paste error)") } diff --git a/vcx/libvcx/src/utils/httpclient.rs b/vcx/libvcx/src/utils/httpclient.rs index 8c18bb0417..c438e0f26f 100644 --- a/vcx/libvcx/src/utils/httpclient.rs +++ b/vcx/libvcx/src/utils/httpclient.rs @@ -37,15 +37,15 @@ pub fn post_message(body_content: &Vec, url: &str) -> VcxResult> { .send() .map_err(|err| { error!("error: {}", err); - VcxError::from_msg(VcxErrorKind::PostMessageFailed, "Could not connect") + VcxError::from_msg(VcxErrorKind::PostMessageFailed, format!("Could not connect {:?}", err)) })?; trace!("Response Header: {:?}", response); if !response.status().is_success() { let mut content = String::new(); match response.read_to_string(&mut content) { - Ok(x) => info!("Request failed: {}", content), - Err(x) => info!("could not read response"), + Ok(_) => info!("Request failed: {}", content), + Err(_) => info!("could not read response"), }; return Err(VcxError::from_msg(VcxErrorKind::PostMessageFailed, format!("POST failed with: {}", content))); } diff --git a/vcx/libvcx/src/utils/json.rs b/vcx/libvcx/src/utils/json.rs index 46c827df12..93bc584675 100644 --- a/vcx/libvcx/src/utils/json.rs +++ b/vcx/libvcx/src/utils/json.rs @@ -11,7 +11,7 @@ pub trait KeyMatch { } impl KeyMatch for String { - fn matches(&self, key: &String, context: &Vec) -> bool { + fn matches(&self, key: &String, _context: &Vec) -> bool { key.eq(self) } } diff --git a/vcx/libvcx/src/utils/libindy/anoncreds.rs b/vcx/libvcx/src/utils/libindy/anoncreds.rs index 0ecf9fbd41..eb822df7bc 100644 --- a/vcx/libvcx/src/utils/libindy/anoncreds.rs +++ b/vcx/libvcx/src/utils/libindy/anoncreds.rs @@ -150,7 +150,7 @@ pub fn libindy_prover_get_credentials_for_proof_req(proof_req: &str) -> VcxResul // this may be too redundant since Prover::search_credentials will validate the proof reqeuest already. let proof_request_json: Map = serde_json::from_str(proof_req) - .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidProofRequest, format!("Cannot deserialize ProofRequest")))?; + .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidProofRequest, format!("Cannot deserialize ProofRequest: {:?}", err)))?; // since the search_credentials_for_proof request validates that the proof_req is properly structured, this get() // fn should never fail, unless libindy changes their formats. @@ -356,7 +356,7 @@ pub fn create_schema(name: &str, version: &str, data: &str) -> VcxResult<(String Ok((id, create_schema)) } -pub fn build_schema_request(id: &str, schema: &str) -> VcxResult { +pub fn build_schema_request(schema: &str) -> VcxResult { if settings::test_indy_mode_enabled() { return Ok(SCHEMA_TXN.to_string()); } @@ -370,14 +370,14 @@ pub fn build_schema_request(id: &str, schema: &str) -> VcxResult { Ok(request) } -pub fn publish_schema(id: &str, schema: &str) -> VcxResult> { +pub fn publish_schema(schema: &str) -> VcxResult> { if settings::test_indy_mode_enabled() { let inputs = vec!["pay:null:9UFgyjuJxi1i1HD".to_string()]; let outputs = serde_json::from_str::>(r#"[{"amount":4,"extra":null,"recipient":"pay:null:xkIsxem0YNtHrRO"}]"#).unwrap(); return Ok(Some(PaymentTxn::from_parts(inputs, outputs, 1, false))); } - let request = build_schema_request(id, schema)?; + let request = build_schema_request(schema)?; let (payment, response) = pay_for_txn(&request, CREATE_SCHEMA_ACTION)?; @@ -548,7 +548,7 @@ fn _check_schema_response(response: &str) -> VcxResult<()> { match parse_response(response)? { Response::Reply(_) => Ok(()), Response::Reject(reject) => Err(VcxError::from_msg(VcxErrorKind::DuplicationSchema, format!("{:?}", reject))), - Response::ReqNACK(reqnack) => Err(VcxError::from_msg(VcxErrorKind::UnknownSchemaRejection, "Unknown Rejection of Schema Creation, refer to libindy documentation")) + Response::ReqNACK(reqnack) => Err(VcxError::from_msg(VcxErrorKind::UnknownSchemaRejection, format!("{:?}", reqnack))) } } @@ -592,7 +592,7 @@ pub mod tests { } pub fn write_schema(request: &str) { - let (payment_info, response) = ::utils::libindy::payments::pay_for_txn(&request, CREATE_SCHEMA_ACTION).unwrap(); + ::utils::libindy::payments::pay_for_txn(&request, CREATE_SCHEMA_ACTION).unwrap(); } pub fn create_and_write_test_schema(attr_list: &str) -> (String, String) { @@ -652,7 +652,7 @@ pub mod tests { let credential_data = r#"{"address1": ["123 Main St"], "address2": ["Suite 3"], "city": ["Draper"], "state": ["UT"], "zip": ["84000"]}"#; let encoded_attributes = ::issuer_credential::encode_attributes(&credential_data).unwrap(); let (rev_def_json, tails_file) = if revocation { - let (id, json) = get_rev_reg_def_json(&rev_reg_id.clone().unwrap()).unwrap(); + let (_id, json) = get_rev_reg_def_json(&rev_reg_id.clone().unwrap()).unwrap(); (Some(json), Some(get_temp_dir_path(Some(TEST_TAILS_FILE)).to_str().unwrap().to_string().to_string())) } else { (None, None) }; @@ -664,7 +664,7 @@ pub mod tests { pub fn create_proof() -> (String, String, String, String) { let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); - let (schema_id, schema_json, cred_def_id, cred_def_json, offer, req, req_meta, cred_id, _, _) + let (schema_id, schema_json, cred_def_id, cred_def_json, _offer, _req, _req_meta, cred_id, _, _) = create_and_store_credential(::utils::constants::DEFAULT_SCHEMA_ATTRS, false); let proof_req = json!({ @@ -721,8 +721,6 @@ pub mod tests { } pub fn create_self_attested_proof() -> (String, String) { - let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); - let proof_req = json!({ "nonce":"123432421212", "name":"proof_req_1", @@ -764,7 +762,7 @@ pub mod tests { pub fn create_proof_with_predicate(include_predicate_cred: bool) -> (String, String, String, String) { let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); - let (schema_id, schema_json, cred_def_id, cred_def_json, offer, req, req_meta, cred_id, _, _) + let (schema_id, schema_json, cred_def_id, cred_def_json, _offer, _req, _req_meta, cred_id, _, _) = create_and_store_credential(::utils::constants::DEFAULT_SCHEMA_ATTRS, false); let proof_req = json!({ @@ -914,8 +912,6 @@ pub mod tests { }).to_string(); let result = libindy_prover_get_credentials_for_proof_req(&proof_req); let result_malformed_json = libindy_prover_get_credentials_for_proof_req("{}"); - let wallet_handle = get_wallet_handle(); - let proof_req_str: String = serde_json::to_string(&proof_req).unwrap(); assert!(result.is_ok()); assert_eq!(result_malformed_json.unwrap_err().kind(), VcxErrorKind::InvalidAttributesStructure); } @@ -927,7 +923,7 @@ pub mod tests { let rc = libindy_issuer_revoke_credential(get_temp_dir_path(Some(TEST_TAILS_FILE)).to_str().unwrap(), "", ""); assert!(rc.is_err()); - let (_, _, cred_def_id, _, _, _, _, cred_id, rev_reg_id, cred_rev_id) + let (_, _, _, _, _, _, _, _, rev_reg_id, cred_rev_id) = create_and_store_credential(::utils::constants::DEFAULT_SCHEMA_ATTRS, true); let rc = ::utils::libindy::anoncreds::libindy_issuer_revoke_credential(get_temp_dir_path(Some(TEST_TAILS_FILE)).to_str().unwrap(), &rev_reg_id.unwrap(), &cred_rev_id.unwrap()); @@ -946,16 +942,10 @@ pub mod tests { fn test_create_cred_def_real() { init!("ledger"); - let data = r#"["address1","address2","zip","city","state"]"#.to_string(); let (schema_id, _) = ::utils::libindy::anoncreds::tests::create_and_write_test_schema(::utils::constants::DEFAULT_SCHEMA_ATTRS); let (_, schema_json) = get_schema_json(&schema_id).unwrap(); let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); - let revocation_details = json!({ - "support_revocation": true, - "tails_file": get_temp_dir_path(Some("tails.txt")).to_str().unwrap(), - "max_creds": 2 - }).to_string(); let (_, cred_def_json) = generate_cred_def(&did, &schema_json, "tag_1", None, Some(true)).unwrap(); publish_cred_def(&did, &cred_def_json).unwrap(); } @@ -963,10 +953,8 @@ pub mod tests { #[cfg(feature = "pool_tests")] #[test] fn test_rev_reg_def_fails_for_cred_def_created_without_revocation() { - let wallet_name = "test_create_revocable_fails_with_no_tails_file"; init!("ledger"); - let data = r#"["address1","address2","zip","city","state"]"#.to_string(); // Cred def is created with support_revocation=false, // revoc_reg_def will fail in libindy because cred_Def doesn't have revocation keys let (_, _, cred_def_id, _, _, _) = ::utils::libindy::anoncreds::tests::create_and_store_credential_def(::utils::constants::DEFAULT_SCHEMA_ATTRS, false); @@ -981,7 +969,6 @@ pub mod tests { fn test_create_rev_reg_def() { init!("ledger"); - let data = r#"["address1","address2","zip","city","state"]"#.to_string(); let (schema_id, _) = ::utils::libindy::anoncreds::tests::create_and_write_test_schema(::utils::constants::DEFAULT_SCHEMA_ATTRS); let (_, schema_json) = get_schema_json(&schema_id).unwrap(); let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); @@ -1002,7 +989,7 @@ pub mod tests { ::utils::libindy::anoncreds::tests::create_and_store_credential_def(attrs, true); let rev_reg_id = rev_reg_id.unwrap(); - let (id, json) = get_rev_reg_def_json(&rev_reg_id).unwrap(); + let (id, _json) = get_rev_reg_def_json(&rev_reg_id).unwrap(); assert_eq!(id, rev_reg_id); } @@ -1015,7 +1002,7 @@ pub mod tests { ::utils::libindy::anoncreds::tests::create_and_store_credential_def(attrs, true); let rev_reg_id = rev_reg_id.unwrap(); - let (id, delta, timestamp) = get_rev_reg_delta_json(&rev_reg_id, None, None).unwrap(); + let (id, _delta, _timestamp) = get_rev_reg_delta_json(&rev_reg_id, None, None).unwrap(); assert_eq!(id, rev_reg_id); } @@ -1028,21 +1015,19 @@ pub mod tests { ::utils::libindy::anoncreds::tests::create_and_store_credential_def(attrs, true); let rev_reg_id = rev_reg_id.unwrap(); - let (id, rev_reg, timestamp) = get_rev_reg(&rev_reg_id, time::get_time().sec as u64).unwrap(); + let (id, _rev_reg, _timestamp) = get_rev_reg(&rev_reg_id, time::get_time().sec as u64).unwrap(); assert_eq!(id, rev_reg_id); } #[cfg(feature = "pool_tests")] #[test] fn from_pool_ledger_with_id() { - use settings; init!("ledger"); - let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); - let (schema_id, schema_json) = ::utils::libindy::anoncreds::tests::create_and_write_test_schema(::utils::constants::DEFAULT_SCHEMA_ATTRS); + let (schema_id, _schema_json) = ::utils::libindy::anoncreds::tests::create_and_write_test_schema(::utils::constants::DEFAULT_SCHEMA_ATTRS); let rc = get_schema_json(&schema_id); - let (id, retrieved_schema) = rc.unwrap(); + let (_id, retrieved_schema) = rc.unwrap(); assert!(retrieved_schema.contains(&schema_id)); } @@ -1058,7 +1043,7 @@ pub mod tests { #[test] fn test_revoke_credential() { init!("ledger"); - let (_, _, cred_def_id, _, _, _, _, cred_id, rev_reg_id, cred_rev_id) + let (_, _, _, _, _, _, _, _, rev_reg_id, cred_rev_id) = ::utils::libindy::anoncreds::tests::create_and_store_credential(::utils::constants::DEFAULT_SCHEMA_ATTRS, true); let rev_reg_id = rev_reg_id.unwrap(); @@ -1068,7 +1053,7 @@ pub mod tests { assert_eq!(first_rev_reg_delta, test_same_delta); assert_eq!(first_timestamp, test_same_timestamp); - let (payment, revoked_rev_reg_delta) = revoke_credential(get_temp_dir_path(Some(TEST_TAILS_FILE)).to_str().unwrap(), &rev_reg_id, cred_rev_id.unwrap().as_str()).unwrap(); + let (payment, _revoked_rev_reg_delta) = revoke_credential(get_temp_dir_path(Some(TEST_TAILS_FILE)).to_str().unwrap(), &rev_reg_id, cred_rev_id.unwrap().as_str()).unwrap(); // Delta should change after revocation let (_, second_rev_reg_delta, _) = get_rev_reg_delta_json(&rev_reg_id, Some(first_timestamp + 1), None).unwrap(); diff --git a/vcx/libvcx/src/utils/libindy/cache.rs b/vcx/libvcx/src/utils/libindy/cache.rs index ac20cf219a..30c568c5da 100644 --- a/vcx/libvcx/src/utils/libindy/cache.rs +++ b/vcx/libvcx/src/utils/libindy/cache.rs @@ -98,7 +98,7 @@ pub mod tests { #[test] fn test_get_credential_cache_returns_default_when_not_exists_in_wallet() { - let init = Init::new(); + let _init = Init::new(); let result = get_rev_reg_cache("test-id"); assert_eq!(result, RevRegCache::default()); @@ -106,7 +106,7 @@ pub mod tests { #[test] fn test_get_credential_cache_returns_default_when_invalid_data_in_the_wallet() { - let init = Init::new(); + let _init = Init::new(); let rev_reg_id = "test-id"; @@ -118,7 +118,7 @@ pub mod tests { #[test] fn test_credential_cache_set_than_get_works() { - let init = Init::new(); + let _init = Init::new(); let rev_reg_id = "test-id"; @@ -138,7 +138,7 @@ pub mod tests { #[test] fn test_credential_cache_set_than_double_get_works() { - let init = Init::new(); + let _init = Init::new(); let rev_reg_id = "test-id"; @@ -160,7 +160,7 @@ pub mod tests { #[test] fn test_credential_cache_overwrite_works() { - let init = Init::new(); + let _init = Init::new(); let rev_reg_id = "test-id"; diff --git a/vcx/libvcx/src/utils/libindy/callback.rs b/vcx/libvcx/src/utils/libindy/callback.rs index cf054607f4..be9b3b1d23 100644 --- a/vcx/libvcx/src/utils/libindy/callback.rs +++ b/vcx/libvcx/src/utils/libindy/callback.rs @@ -8,7 +8,8 @@ use std::slice; use std::ops::Deref; use std::hash::Hash; -use utils::libindy::next_i32_command_handle; +use utils::libindy::next_command_handle; +use indy_sys::CommandHandle; pub const POISON_MSG: &str = "FAILED TO LOCK CALLBACK MAP!"; @@ -166,7 +167,7 @@ mod tests { let mutex_map: Mutex>> = Default::default(); assert!(get_cb(2123, &mutex_map).is_none()); - let closure: Box = Box::new(move |err | { + let closure: Box = Box::new(move |_ | { }); @@ -184,8 +185,8 @@ mod tests { // Should be come not needed as the transition is complete //************************************** -fn init_callback(closure: T, map: &Mutex>) -> (i32) { - let command_handle = next_i32_command_handle(); +fn init_callback(closure: T, map: &Mutex>) -> CommandHandle { + let command_handle = next_command_handle(); { let mut callbacks = map.lock().unwrap(); callbacks.insert(command_handle, closure); diff --git a/vcx/libvcx/src/utils/libindy/callback_u32.rs b/vcx/libvcx/src/utils/libindy/callback_u32.rs index 0fb958e6f2..31eb104f66 100644 --- a/vcx/libvcx/src/utils/libindy/callback_u32.rs +++ b/vcx/libvcx/src/utils/libindy/callback_u32.rs @@ -4,35 +4,36 @@ use std::sync::Mutex; use std::ops::Deref; use utils::libindy::callback::{get_cb, build_string, build_buf}; +use indy_sys::CommandHandle; lazy_static! { - pub static ref CALLBACKS_U32: Mutex>> = Default::default(); - pub static ref CALLBACKS_U32_U32: Mutex>> = Default::default(); - pub static ref CALLBACKS_U32_STR: Mutex) + Send>>> = Default::default(); - pub static ref CALLBACKS_U32_U32_STR: Mutex) + Send>>> = Default::default(); - pub static ref CALLBACKS_U32_STR_STR: Mutex, Option) + Send>>> = Default::default(); - pub static ref CALLBACKS_U32_BOOL: Mutex>> = Default::default(); - pub static ref CALLBACKS_U32_BIN: Mutex) + Send>>> = Default::default(); - pub static ref CALLBACKS_U32_OPTSTR_BIN: Mutex, Vec) + Send>>> = Default::default(); - pub static ref CALLBACKS_U32_BIN_BIN: Mutex, Vec) + Send>>> = Default::default(); - pub static ref CALLBACKS_U32_U32_STR_STR_STR: Mutex, Option, Option) + Send>>> = Default::default(); + pub static ref CALLBACKS_U32: Mutex>> = Default::default(); + pub static ref CALLBACKS_U32_U32: Mutex>> = Default::default(); + pub static ref CALLBACKS_U32_STR: Mutex) + Send>>> = Default::default(); + pub static ref CALLBACKS_U32_U32_STR: Mutex) + Send>>> = Default::default(); + pub static ref CALLBACKS_U32_STR_STR: Mutex, Option) + Send>>> = Default::default(); + pub static ref CALLBACKS_U32_BOOL: Mutex>> = Default::default(); + pub static ref CALLBACKS_U32_BIN: Mutex) + Send>>> = Default::default(); + pub static ref CALLBACKS_U32_OPTSTR_BIN: Mutex, Vec) + Send>>> = Default::default(); + pub static ref CALLBACKS_U32_BIN_BIN: Mutex, Vec) + Send>>> = Default::default(); + pub static ref CALLBACKS_U32_U32_STR_STR_STR: Mutex, Option, Option) + Send>>> = Default::default(); } -pub extern "C" fn call_cb_u32(command_handle: u32, arg1: u32) { +pub extern "C" fn call_cb_u32(command_handle: CommandHandle, arg1: u32) { let cb = get_cb(command_handle, CALLBACKS_U32.deref()); if let Some(mut cb_fn) = cb { cb_fn(arg1) } } -pub extern "C" fn call_cb_u32_u32(command_handle: u32, arg1: u32, arg2: u32) { +pub extern "C" fn call_cb_u32_u32(command_handle: CommandHandle, arg1: u32, arg2: u32) { let cb = get_cb(command_handle, CALLBACKS_U32_U32.deref()); if let Some(mut cb_fn) = cb { cb_fn(arg1, arg2) } } -pub extern "C" fn call_cb_u32_u32_str(command_handle: u32, arg1: u32, arg2: u32, arg3: *const c_char) { +pub extern "C" fn call_cb_u32_u32_str(command_handle: CommandHandle, arg1: u32, arg2: u32, arg3: *const c_char) { let cb = get_cb(command_handle, CALLBACKS_U32_U32_STR.deref()); let str1 = build_string(arg3); if let Some(mut cb_fn) = cb { @@ -40,7 +41,7 @@ pub extern "C" fn call_cb_u32_u32_str(command_handle: u32, arg1: u32, arg2: u32, } } -pub extern "C" fn call_cb_u32_str(command_handle: u32, arg1: u32, arg2: *const c_char) { +pub extern "C" fn call_cb_u32_str(command_handle: CommandHandle, arg1: u32, arg2: *const c_char) { let cb = get_cb(command_handle, CALLBACKS_U32_STR.deref()); let str1 = build_string(arg2); if let Some(mut cb_fn) = cb { @@ -48,7 +49,7 @@ pub extern "C" fn call_cb_u32_str(command_handle: u32, arg1: u32, arg2: *const c } } -pub extern "C" fn call_cb_u32_str_str(command_handle: u32, arg1: u32, arg2: *const c_char, arg3: *const c_char) { +pub extern "C" fn call_cb_u32_str_str(command_handle: CommandHandle, arg1: u32, arg2: *const c_char, arg3: *const c_char) { let cb = get_cb(command_handle, CALLBACKS_U32_STR_STR.deref()); let str1 = build_string(arg2); let str2 = build_string(arg3); @@ -57,14 +58,14 @@ pub extern "C" fn call_cb_u32_str_str(command_handle: u32, arg1: u32, arg2: *con } } -pub extern "C" fn call_cb_u32_bool(command_handle: u32, arg1: u32, arg2: bool) { +pub extern "C" fn call_cb_u32_bool(command_handle: CommandHandle, arg1: u32, arg2: bool) { let cb = get_cb(command_handle, CALLBACKS_U32_BOOL.deref()); if let Some(mut cb_fn) = cb { cb_fn(arg1, arg2) } } -pub extern "C" fn call_cb_u32_bin(command_handle: u32, arg1: u32, buf: *const u8, len: u32) { +pub extern "C" fn call_cb_u32_bin(command_handle: CommandHandle, arg1: u32, buf: *const u8, len: u32) { let cb = get_cb(command_handle, CALLBACKS_U32_BIN.deref()); let data = build_buf(buf, len); if let Some(mut cb_fn) = cb { @@ -72,7 +73,7 @@ pub extern "C" fn call_cb_u32_bin(command_handle: u32, arg1: u32, buf: *const u8 } } -pub extern "C" fn call_cb_u32_str_bin(command_handle: u32, arg1: u32, arg2: *const c_char, buf: *const u8, len: u32) { +pub extern "C" fn call_cb_u32_str_bin(command_handle: CommandHandle, arg1: u32, arg2: *const c_char, buf: *const u8, len: u32) { let cb = get_cb(command_handle, CALLBACKS_U32_OPTSTR_BIN.deref()); let data = build_buf(buf, len); @@ -83,7 +84,7 @@ pub extern "C" fn call_cb_u32_str_bin(command_handle: u32, arg1: u32, arg2: *con } } -pub extern "C" fn call_cb_u32_bin_bin(command_handle: u32, arg1: u32, buf1: *const u8, buf1_len: u32, buf2: *const u8, buf2_len: u32) { +pub extern "C" fn call_cb_u32_bin_bin(command_handle: CommandHandle, arg1: u32, buf1: *const u8, buf1_len: u32, buf2: *const u8, buf2_len: u32) { let cb = get_cb(command_handle, CALLBACKS_U32_BIN_BIN.deref()); let data1 = build_buf(buf1, buf1_len); let data2 = build_buf(buf2, buf2_len); @@ -92,7 +93,7 @@ pub extern "C" fn call_cb_u32_bin_bin(command_handle: u32, arg1: u32, buf1: *con } } -pub extern "C" fn call_cb_u32_u32_str_str_str(command_handle: u32, arg1: u32, arg2: u32, arg3: *const c_char, arg4: *const c_char, arg5: *const c_char) { +pub extern "C" fn call_cb_u32_u32_str_str_str(command_handle: CommandHandle, arg1: u32, arg2: u32, arg3: *const c_char, arg4: *const c_char, arg5: *const c_char) { let cb = get_cb(command_handle, CALLBACKS_U32_U32_STR_STR_STR.deref()); let str1 = build_string(arg3); let str2 = build_string(arg4); @@ -125,7 +126,7 @@ mod tests { let mutex_map: Mutex>> = Default::default(); assert!(get_cb(2123, &mutex_map).is_none()); - let closure: Box = Box::new(move |err | { + let closure: Box = Box::new(move |_ | { }); diff --git a/vcx/libvcx/src/utils/libindy/mod.rs b/vcx/libvcx/src/utils/libindy/mod.rs index f8bec2fc7c..26d6bf48ae 100644 --- a/vcx/libvcx/src/utils/libindy/mod.rs +++ b/vcx/libvcx/src/utils/libindy/mod.rs @@ -16,6 +16,7 @@ use settings; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Mutex; use error::prelude::*; +use indy_sys::CommandHandle; lazy_static! { static ref NEXT_LIBINDY_RC: Mutex> = Mutex::new(vec![]); @@ -27,12 +28,8 @@ pub fn set_libindy_rc(rc: u32) { NEXT_LIBINDY_RC.lock().unwrap().push(rc as i32) static COMMAND_HANDLE_COUNTER: AtomicUsize = AtomicUsize::new(1); -pub fn next_i32_command_handle() -> i32 { - (COMMAND_HANDLE_COUNTER.fetch_add(1, Ordering::SeqCst) + 1) as i32 -} - -pub fn next_u32_command_handle() -> u32 { - (COMMAND_HANDLE_COUNTER.fetch_add(1, Ordering::SeqCst) + 1) as u32 +pub fn next_command_handle() -> CommandHandle { + (COMMAND_HANDLE_COUNTER.fetch_add(1, Ordering::SeqCst) + 1) as CommandHandle } pub fn init_pool() -> VcxResult<()> { @@ -51,7 +48,7 @@ pub fn init_pool() -> VcxResult<()> { warn!("Pool Config Creation Error: {}", e); Err(e) } - Ok(_) => { + Ok(()) => { debug!("Pool Config Created Successfully"); let pool_config: Option = settings::get_config_value(settings::CONFIG_POOL_CONFIG).ok(); pool::open_pool_ledger(&pool_name, pool_config.as_ref().map(String::as_str))?; @@ -64,8 +61,9 @@ pub fn init_pool() -> VcxResult<()> { pub mod tests { use super::*; use futures::Future; + use indy_sys::WalletHandle; - pub fn create_key(wallet_handle: i32, seed: Option<&str>) -> String { + pub fn create_key(_wallet_handle: WalletHandle, seed: Option<&str>) -> String { let key_config = json!({"seed": seed}).to_string(); indy::crypto::create_key(::utils::libindy::wallet::get_wallet_handle(), Some(&key_config)).wait().unwrap() } @@ -81,7 +79,7 @@ pub mod tests { pub struct Setup { pub name: String, pub wallet_config: String, - pub wallet_handle: i32, + pub wallet_handle: indy::WalletHandle, pub key: String, } @@ -102,7 +100,7 @@ pub mod tests { impl Drop for Setup { fn drop(&mut self) { - if self.wallet_handle != 0 { + if self.wallet_handle.0 != 0 { indy::wallet::close_wallet(self.wallet_handle).wait().unwrap(); indy::wallet::delete_wallet(&self.wallet_config, WALLET_CREDENTIALS).wait().unwrap(); } diff --git a/vcx/libvcx/src/utils/libindy/payments.rs b/vcx/libvcx/src/utils/libindy/payments.rs index 51ca8ab3f8..aa9a5601a4 100644 --- a/vcx/libvcx/src/utils/libindy/payments.rs +++ b/vcx/libvcx/src/utils/libindy/payments.rs @@ -13,7 +13,6 @@ use settings; use error::prelude::*; static DEFAULT_FEES: &str = r#"{"0":0, "1":0, "101":2, "10001":0, "102":42, "103":0, "104":0, "105":0, "107":0, "108":0, "109":0, "110":0, "111":0, "112":0, "113":2, "114":2, "115":0, "116":0, "117":0, "118":0, "119":0}"#; -static ZERO_FEES: &str = r#"{"0":0, "1":0, "101":0, "10001":0, "102":0, "103":0, "104":0, "105":0, "107":0, "108":0, "109":0, "110":0, "111":0, "112":0, "113":0, "114":0, "115":0, "116":0, "117":0, "118":0, "119":0}"#; #[derive(Serialize, Deserialize, Debug)] pub struct WalletInfo { @@ -58,7 +57,7 @@ impl fmt::Display for WalletInfo { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match ::serde_json::to_string(&self) { Ok(s) => write!(f, "{}", s), - Err(e) => write!(f, "null"), + Err(_) => write!(f, "null"), } } } @@ -98,7 +97,7 @@ pub fn create_address(seed: Option) -> VcxResult { None => "{}".to_string(), }; - payments::create_payment_address(get_wallet_handle() as i32, settings::get_payment_method().as_str(), &config) + payments::create_payment_address(get_wallet_handle(), settings::get_payment_method().as_str(), &config) .wait() .map_err(map_rust_indy_sdk_error) } @@ -108,7 +107,7 @@ pub fn sign_with_address(address: &str, message: &[u8]) -> VcxResult> { if settings::test_indy_mode_enabled() {return Ok(Vec::from(message).to_owned()); } - payments::sign_with_address(get_wallet_handle() as i32, address, message).wait().map_err(map_rust_indy_sdk_error) + payments::sign_with_address(get_wallet_handle(), address, message).wait().map_err(map_rust_indy_sdk_error) } pub fn verify_with_address(address: &str, message: &[u8], signature: &[u8]) -> VcxResult { @@ -145,7 +144,7 @@ pub fn get_address_info(address: &str) -> VcxResult { let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID)?; - let (txn, _) = payments::build_get_payment_sources_with_from_request(get_wallet_handle() as i32, Some(&did), address, None) + let (txn, _) = payments::build_get_payment_sources_with_from_request(get_wallet_handle(), Some(&did), address, None) .wait() .map_err(map_rust_indy_sdk_error)?; @@ -160,7 +159,7 @@ pub fn get_address_info(address: &str) -> VcxResult { let mut next_seqno = next; while next_seqno.is_some() { - let (txn, _) = payments::build_get_payment_sources_with_from_request(get_wallet_handle() as i32, Some(&did), address, next_seqno) + let (txn, _) = payments::build_get_payment_sources_with_from_request(get_wallet_handle(), Some(&did), address, next_seqno) .wait() .map_err(map_rust_indy_sdk_error)?; @@ -190,7 +189,7 @@ pub fn list_addresses() -> VcxResult> { return Ok(::serde_json::from_value(addresses).unwrap()); } - let addresses = payments::list_payment_addresses(get_wallet_handle() as i32) + let addresses = payments::list_payment_addresses(get_wallet_handle()) .wait() .map_err(map_rust_indy_sdk_error)?; @@ -267,7 +266,7 @@ pub fn pay_for_txn(req: &str, txn_action: (&str, &str, &str, Option<&str>, Optio let (refund, inputs, refund_address) = inputs(txn_price)?; let output = outputs(refund, &refund_address, None, None)?; - let (fee_response, txn_response) = _submit_fees_request(req, &inputs, &output)?; + let (_fee_response, txn_response) = _submit_fees_request(req, &inputs, &output)?; let payment = PaymentTxn::from_parts(inputs, output, txn_price, false); Ok((Some(payment), txn_response)) @@ -346,7 +345,7 @@ pub fn pay_a_payee(price: u64, address: &str) -> VcxResult<(PaymentTxn, String)> None => None }; - let (request, payment_method) = + let (request, _payment_method) = payments::build_payment_req(get_wallet_handle(), Some(&my_did), &inputs_json, &outputs_json, extra.as_ref().map(String::as_str)) .wait() .map_err(map_rust_indy_sdk_error)?; @@ -495,15 +494,15 @@ pub fn mint_tokens_and_set_fees(number_of_addresses: Option, tokens_per_add let tokens_per_address: u64 = tokens_per_address.unwrap_or(50_000_000_000); let mut addresses = Vec::new(); - for n in 0..number_of_addresses { + for _n in 0..number_of_addresses { addresses.push(create_address(seed.clone()).unwrap()) } - let mint: Vec = addresses.clone().into_iter().enumerate().map(|(i, payment_address)| + let mint: Vec = addresses.clone().into_iter().enumerate().map(|(_i, payment_address)| json!( { "recipient": payment_address, "amount": tokens_per_address } ) ).collect(); let outputs = serde_json::to_string(&mint).unwrap(); - let (req, _) = payments::build_mint_req(get_wallet_handle() as i32, Some(&did_1), &outputs, None).wait().unwrap(); + let (req, _) = payments::build_mint_req(get_wallet_handle(), Some(&did_1), &outputs, None).wait().unwrap(); let sign1 = ::utils::libindy::ledger::multisign_request(&did_1, &req).unwrap(); let sign2 = ::utils::libindy::ledger::multisign_request(&did_2, &sign1).unwrap(); @@ -511,13 +510,13 @@ pub fn mint_tokens_and_set_fees(number_of_addresses: Option, tokens_per_add let sign4 = ::utils::libindy::ledger::multisign_request(&did_4, &sign3).unwrap(); match ::utils::libindy::ledger::libindy_submit_request(&sign4) { - Ok(x) => (), + Ok(_) => (), Err(x) => println!("failure minting tokens: {}", x), }; } if let Some(fees_) = fees { - let txn = payments::build_set_txn_fees_req(get_wallet_handle() as i32, Some(&did_1), settings::get_payment_method().as_str(), fees_) + let txn = payments::build_set_txn_fees_req(get_wallet_handle(), Some(&did_1), settings::get_payment_method().as_str(), fees_) .wait() .map_err(map_rust_indy_sdk_error)?; @@ -557,12 +556,14 @@ pub fn add_new_did(role: Option<&str>) -> (String, String) { #[cfg(test)] pub mod tests { use super::*; + static ZERO_FEES: &str = r#"{"0":0, "1":0, "101":0, "10001":0, "102":0, "103":0, "104":0, "105":0, "107":0, "108":0, "109":0, "110":0, "111":0, "112":0, "113":0, "114":0, "115":0, "116":0, "117":0, "118":0, "119":0}"#; pub fn token_setup(number_of_addresses: Option, tokens_per_address: Option, use_zero_fees: bool) { let fees = if use_zero_fees { ZERO_FEES } else { DEFAULT_FEES }; mint_tokens_and_set_fees(number_of_addresses, tokens_per_address, Some(fees.to_string()), None).unwrap(); } + #[allow(dead_code)] fn get_my_balance() -> u64 { let info: WalletInfo = get_wallet_token_info().unwrap(); info.balance @@ -593,7 +594,7 @@ pub mod tests { fn test_get_addresses() { init!("true"); create_address(None).unwrap(); - let addresses = list_addresses().unwrap(); + let _addresses = list_addresses().unwrap(); } #[test] @@ -752,7 +753,7 @@ pub mod tests { // Schema let create_schema_req = ::utils::constants::SCHEMA_CREATE_JSON.to_string(); - let (payment, response) = pay_for_txn(&create_schema_req, ::utils::constants::CREATE_SCHEMA_ACTION).unwrap(); + let (_payment, response) = pay_for_txn(&create_schema_req, ::utils::constants::CREATE_SCHEMA_ACTION).unwrap(); assert_eq!(response, SUBMIT_SCHEMA_RESPONSE.to_string()); } @@ -764,7 +765,7 @@ pub mod tests { let create_schema_req = ::utils::libindy::anoncreds::tests::create_schema_req(&schema_json); let start_wallet = get_wallet_token_info().unwrap(); - let (payment, response) = pay_for_txn(&create_schema_req, ::utils::constants::CREATE_SCHEMA_ACTION).unwrap(); + let (payment, _response) = pay_for_txn(&create_schema_req, ::utils::constants::CREATE_SCHEMA_ACTION).unwrap(); let end_wallet = get_wallet_token_info().unwrap(); @@ -875,7 +876,7 @@ pub mod tests { let end_wallet = get_wallet_token_info().unwrap(); assert_eq!(start_wallet.balance - 2, end_wallet.balance); - let rc = _submit_fees_request(&req, &inputs, &output); + let _rc = _submit_fees_request(&req, &inputs, &output); } #[cfg(feature = "pool_tests")] @@ -892,9 +893,8 @@ pub mod tests { assert_eq!(remainder, remaining_balance); let output = outputs(remainder, &refund_address, None, None).unwrap(); - let expected_output: Vec = ::serde_json::from_str(&format!(r#"[{{"amount":{},"recipient":"{}"}}]"#, remaining_balance, refund_address)).unwrap(); - let rc = _submit_fees_request(&req, &inputs, &output).unwrap(); + let _rc = _submit_fees_request(&req, &inputs, &output).unwrap(); let end_wallet = get_wallet_token_info().unwrap(); assert_eq!(end_wallet.balance, remaining_balance); diff --git a/vcx/libvcx/src/utils/libindy/pool.rs b/vcx/libvcx/src/utils/libindy/pool.rs index 20d3506c94..5bdfcf5784 100644 --- a/vcx/libvcx/src/utils/libindy/pool.rs +++ b/vcx/libvcx/src/utils/libindy/pool.rs @@ -27,7 +27,7 @@ pub fn create_pool_ledger_config(pool_name: &str, path: &str) -> VcxResult<()> { match pool::create_pool_ledger_config(pool_name, Some(&pool_config)) .wait() { - Ok(x) => Ok(()), + Ok(()) => Ok(()), Err(x) => if x.error_code != ErrorCode::PoolLedgerConfigAlreadyExistsError { Err(VcxError::from_msg(VcxErrorKind::UnknownLiibndyError, x)) } else { @@ -88,7 +88,7 @@ pub mod tests { pub fn delete_test_pool() { match delete(POOL) { - Ok(_) => (), + Ok(()) => (), Err(_) => (), }; } diff --git a/vcx/libvcx/src/utils/libindy/wallet.rs b/vcx/libvcx/src/utils/libindy/wallet.rs index 8817f2f9db..32c0b5a584 100644 --- a/vcx/libvcx/src/utils/libindy/wallet.rs +++ b/vcx/libvcx/src/utils/libindy/wallet.rs @@ -6,15 +6,16 @@ use utils::libindy::error_codes::map_rust_indy_sdk_error; use std::path::Path; use error::prelude::*; +use indy::{WalletHandle, INVALID_WALLET_HANDLE}; -pub static mut WALLET_HANDLE: i32 = 0; +pub static mut WALLET_HANDLE: WalletHandle = INVALID_WALLET_HANDLE; -pub fn set_wallet_handle(handle: i32) -> i32 { +pub fn set_wallet_handle(handle: WalletHandle) -> WalletHandle { unsafe { WALLET_HANDLE = handle; } unsafe { WALLET_HANDLE } } -pub fn get_wallet_handle() -> i32 { unsafe { WALLET_HANDLE } } +pub fn get_wallet_handle() -> WalletHandle { unsafe { WALLET_HANDLE } } pub fn create_wallet(wallet_name: &str, wallet_type: Option<&str>, storage_config: Option<&str>, storage_creds: Option<&str>) -> VcxResult<()> { trace!("creating wallet: {}", wallet_name); @@ -25,7 +26,7 @@ pub fn create_wallet(wallet_name: &str, wallet_type: Option<&str>, storage_confi match wallet::create_wallet(&config, &credentials) .wait() { - Ok(x) => Ok(()), + Ok(()) => Ok(()), Err(x) => if x.error_code != ErrorCode::WalletAlreadyExistsError { warn!("could not create wallet {}: {:?}", wallet_name, x.message); Err(VcxError::from_msg(VcxErrorKind::WalletCreate, format!("could not create wallet {}: {:?}", wallet_name, x.message))) @@ -36,10 +37,10 @@ pub fn create_wallet(wallet_name: &str, wallet_type: Option<&str>, storage_confi } } -pub fn open_wallet(wallet_name: &str, wallet_type: Option<&str>, storage_config: Option<&str>, storage_creds: Option<&str>) -> VcxResult { +pub fn open_wallet(wallet_name: &str, wallet_type: Option<&str>, storage_config: Option<&str>, storage_creds: Option<&str>) -> VcxResult { trace!("open_wallet >>> wallet_name: {}", wallet_name); if settings::test_indy_mode_enabled() { - return Ok(set_wallet_handle(1)); + return Ok(set_wallet_handle(WalletHandle(1))); } let config = settings::get_wallet_config(wallet_name, wallet_type, storage_config); @@ -54,9 +55,9 @@ pub fn open_wallet(wallet_name: &str, wallet_type: Option<&str>, storage_config: Ok(handle) } -pub fn init_wallet(wallet_name: &str, wallet_type: Option<&str>, storage_config: Option<&str>, storage_creds: Option<&str>) -> VcxResult { +pub fn init_wallet(wallet_name: &str, wallet_type: Option<&str>, storage_config: Option<&str>, storage_creds: Option<&str>) -> VcxResult { if settings::test_indy_mode_enabled() { - return Ok(set_wallet_handle(1)); + return Ok(set_wallet_handle(WalletHandle(1))); } create_wallet(wallet_name, wallet_type, storage_config, storage_creds)?; @@ -67,14 +68,14 @@ pub fn close_wallet() -> VcxResult<()> { trace!("close_wallet >>>"); if settings::test_indy_mode_enabled() { - set_wallet_handle(0); + set_wallet_handle(INVALID_WALLET_HANDLE); return Ok(()); } let result = wallet::close_wallet(get_wallet_handle()) .wait() .map_err(map_rust_indy_sdk_error); - set_wallet_handle(0); + set_wallet_handle(INVALID_WALLET_HANDLE); result } @@ -82,7 +83,7 @@ pub fn delete_wallet(wallet_name: &str, wallet_type: Option<&str>, storage_confi trace!("delete_wallet >>> wallet_name: {}", wallet_name); if settings::test_indy_mode_enabled() { - set_wallet_handle(0); + set_wallet_handle(INVALID_WALLET_HANDLE); return Ok(()); } @@ -139,8 +140,8 @@ pub fn update_record_value(xtype: &str, id: &str, value: &str) -> VcxResult<()> .map_err(map_rust_indy_sdk_error) } -pub fn export(wallet_handle: i32, path: &Path, backup_key: &str) -> VcxResult<()> { - trace!("export >>> wallet_handle: {}, path: {:?}, backup_key: ****", wallet_handle, path); +pub fn export(wallet_handle: WalletHandle, path: &Path, backup_key: &str) -> VcxResult<()> { + trace!("export >>> wallet_handle: {:?}, path: {:?}, backup_key: ****", wallet_handle, path); let export_config = json!({ "key": backup_key, "path": &path}).to_string(); wallet::export_wallet(wallet_handle, &export_config) @@ -153,9 +154,6 @@ pub fn import(config: &str) -> VcxResult<()> { settings::process_config_string(config, true)?; - let key = settings::get_config_value(settings::CONFIG_WALLET_KEY) - .or(Err(VcxError::from(VcxErrorKind::MissingWalletKey)))?; - let name = settings::get_config_value(settings::CONFIG_WALLET_NAME) .or(Err(VcxError::from(VcxErrorKind::MissingWalletName)))?; @@ -211,12 +209,12 @@ pub mod tests { pub fn delete_test_wallet(name: &str) { match close_wallet() { - Ok(_) => (), + Ok(()) => (), Err(_) => (), }; match delete_wallet(name, None, None, None) { - Ok(_) => (), + Ok(()) => (), Err(_) => (), }; } @@ -224,7 +222,7 @@ pub mod tests { #[test] fn test_wallet() { init!("false"); - assert!(get_wallet_handle() > 0); + assert_ne!(get_wallet_handle(), INVALID_WALLET_HANDLE); assert_eq!(VcxErrorKind::WalletCreate, init_wallet(&String::from(""), None, None, None).unwrap_err().kind()); } @@ -272,7 +270,6 @@ pub mod tests { let xtype = "type1"; let id = "id1"; let value = "value1"; - let options = "{}"; ::api::vcx::vcx_shutdown(true); @@ -398,7 +395,6 @@ pub mod tests { let record = "Record Value"; let record_type = "Type"; let id = "123"; - let wallet_n = "test_add_new_record_with_no_tag"; add_record(record_type, id, record, None).unwrap(); } @@ -410,7 +406,6 @@ pub mod tests { let record = "Record Value"; let record_type = "Type"; let id = "123"; - let wallet_n = "test_add_duplicate_record_fails"; add_record(record_type, id, record, None).unwrap(); let rc = add_record(record_type, id, record, None); @@ -425,7 +420,6 @@ pub mod tests { let record_type = "Type"; let record_type2 = "Type2"; let id = "123"; - let wallet_n = "test_add_duplicate_record_fails"; add_record(record_type, id, record, None).unwrap(); add_record(record_type2, id, record, None).unwrap(); @@ -442,7 +436,6 @@ pub mod tests { "retrieveValue": false, "retrieveTags": false }).to_string(); - let wallet_n = "test_retrieve_missing_record_fails"; let rc = get_record(record_type, id, &options); assert_eq!(rc.unwrap_err().kind(), VcxErrorKind::WalletRecordNotFound); @@ -456,7 +449,6 @@ pub mod tests { let record = "Record Value"; let record_type = "Type"; let id = "123"; - let wallet_n = "test_retrieve_record_success"; let options = json!({ "retrieveType": true, "retrieveValue": true, @@ -487,7 +479,6 @@ pub mod tests { let record = "Record Value"; let record_type = "Type"; let id = "123"; - let wallet_n = "test_delete_record_success"; let options = json!({ "retrieveType": true, "retrieveValue": true, @@ -507,7 +498,6 @@ pub mod tests { let record = "Record Value"; let record_type = "Type"; let id = "123"; - let wallet_n = "test_update_record_value_fails_with_no_initial_record"; let rc = update_record_value(record_type, id, record); assert_eq!(rc.unwrap_err().kind(), VcxErrorKind::WalletRecordNotFound); @@ -521,7 +511,6 @@ pub mod tests { let changed_record = "Record2"; let record_type = "Type"; let id = "123"; - let wallet_n = "test_update_record_value_success"; let options = json!({ "retrieveType": true, "retrieveValue": true, diff --git a/vcx/libvcx/src/utils/logger.rs b/vcx/libvcx/src/utils/logger.rs index 440f11df07..3ff503fc04 100644 --- a/vcx/libvcx/src/utils/logger.rs +++ b/vcx/libvcx/src/utils/logger.rs @@ -1,7 +1,5 @@ extern crate env_logger; extern crate log; -extern crate log4rs; -extern crate log_panics; extern crate libc; extern crate indy_sys; @@ -11,7 +9,6 @@ extern crate android_logger; use std::io::Write; use self::env_logger::Builder as EnvLoggerBuilder; use self::log::{Level, LevelFilter, Metadata, Record}; -use std::sync::Once; use self::libc::{c_char}; use std::env; use std::ptr; @@ -28,7 +25,6 @@ use error::prelude::*; use utils::libindy; pub static mut LOGGER_STATE: LoggerState = LoggerState::Default; -static LOGGER_INIT: Once = Once::new(); static mut CONTEXT: *const CVoid = ptr::null(); static mut ENABLED_CB: Option = None; static mut LOG_CB: Option = None; @@ -146,7 +142,7 @@ impl LibvcxDefaultLogger { // the user did not set the RUST_LOG env var. let pattern = Some(env::var("RUST_LOG").unwrap_or("trace".to_string())); match LibvcxDefaultLogger::init(pattern) { - Ok(_) => (), + Ok(()) => (), Err(_) => (), } } @@ -183,7 +179,7 @@ impl LibvcxDefaultLogger { .filter(None, LevelFilter::Off) .parse(pattern.as_ref().map(String::as_str).unwrap_or("warn")) .try_init() { - Ok(_) => {} + Ok(()) => {} Err(e) => { error!("Error in logging init: {:?}", e); return Err(VcxError::from_msg(VcxErrorKind::LoggingError, format!("Cannot init logger: {:?}", e))) @@ -257,21 +253,19 @@ mod tests { ptr::null() } - static mut CHANGED: Option = None; static mut COUNT: u32 = 0; - extern fn custom_enabled(context: *const CVoid, level: u32, target: *const c_char) -> bool { true } + extern fn custom_enabled(_context: *const CVoid, _level: u32, _target: *const c_char) -> bool { true } - extern fn custom_flush(context: *const CVoid) {} + extern fn custom_flush(_context: *const CVoid) {} - extern fn custom_log(context: *const CVoid, - level: u32, - target: *const c_char, - message: *const c_char, - module_path: *const c_char, - file: *const c_char, - line: u32) { - let message = CStringUtils::c_str_to_string(message).unwrap(); + extern fn custom_log(_context: *const CVoid, + _level: u32, + _target: *const c_char, + _message: *const c_char, + _module_path: *const c_char, + _file: *const c_char, + _line: u32) { unsafe { COUNT = COUNT + 1 } } @@ -280,7 +274,7 @@ mod tests { fn test_logging_get_logger() { LibvcxDefaultLogger::init(Some("debug".to_string())).unwrap(); unsafe { - let (context, enabled_cb, log_cb, flush_cb) = LOGGER_STATE.get(); + let (context, enabled_cb, _log_cb, _flush_cb) = LOGGER_STATE.get(); assert_eq!(context, ptr::null()); let target = CStringUtils::string_to_cstring("target".to_string()); let level = 1; diff --git a/vcx/libvcx/src/utils/threadpool.rs b/vcx/libvcx/src/utils/threadpool.rs index 03c3cc9aa2..d07959ae0c 100644 --- a/vcx/libvcx/src/utils/threadpool.rs +++ b/vcx/libvcx/src/utils/threadpool.rs @@ -55,7 +55,7 @@ where unsafe { handle = TP_HANDLE; } match THREADPOOL.lock().unwrap().get(&handle) { Some(x) => { - let n = x.spawn(future); + let _n= x.spawn(future); }, None => panic!("no threadpool!"), } diff --git a/vcx/libvcx/src/v3/handlers/connection/agent.rs b/vcx/libvcx/src/v3/handlers/connection/agent.rs index 96a7d2b6f7..c653569f7d 100644 --- a/vcx/libvcx/src/v3/handlers/connection/agent.rs +++ b/vcx/libvcx/src/v3/handlers/connection/agent.rs @@ -119,7 +119,7 @@ impl AgentInfo { pub fn decode_message(&self, message: &Message) -> VcxResult { trace!("Agent::decode_message >>>"); - EncryptionEnvelope::open(&self.pw_vk, message.payload()?) + EncryptionEnvelope::open(message.payload()?) } pub fn send_message(&self, message: &A2AMessage, did_dod: &DidDoc) -> VcxResult<()> { diff --git a/vcx/libvcx/src/v3/handlers/connection/connection.rs b/vcx/libvcx/src/v3/handlers/connection/connection.rs index 9a977b3bbe..813b7cc9f1 100644 --- a/vcx/libvcx/src/v3/handlers/connection/connection.rs +++ b/vcx/libvcx/src/v3/handlers/connection/connection.rs @@ -9,6 +9,7 @@ use v3::messages::connection::invite::Invitation; use std::collections::HashMap; use v3::messages::connection::did_doc::DidDoc; +use v3::messages::basic_message::message::BasicMessage; #[derive(Debug, Clone, Serialize, Deserialize)] @@ -189,7 +190,23 @@ impl Connection { pub fn send_generic_message(&self, message: &str, _message_options: &str) -> VcxResult { trace!("Connection::send_generic_message >>> message: {:?}", message); - self.send_message(&A2AMessage::Generic(message.to_string())).map(|_| String::new()) + let message = match ::serde_json::from_str::(message) { + Ok(A2AMessage::Generic(message))=> { + BasicMessage::create() + .set_content(message.to_string()) + .set_time() + .to_a2a_message() + } + Ok(a2a_message) => a2a_message, + Err(_) => { + BasicMessage::create() + .set_content(message.to_string()) + .set_time() + .to_a2a_message() + } + }; + + self.send_message(&message).map(|_| String::new()) } pub fn send_ping(&mut self, comment: Option) -> VcxResult<()> { diff --git a/vcx/libvcx/src/v3/handlers/connection/mod.rs b/vcx/libvcx/src/v3/handlers/connection/mod.rs index 7b352150fc..ce20949bc7 100644 --- a/vcx/libvcx/src/v3/handlers/connection/mod.rs +++ b/vcx/libvcx/src/v3/handlers/connection/mod.rs @@ -68,7 +68,7 @@ pub mod tests { alice.update_state(4); faber.update_state(4); - let mut uid: String; + let uid: String; let message = _ack(); // Send Message works @@ -93,7 +93,7 @@ pub mod tests { } } - let res = ::messages::get_message::download_messages(None, None, Some(vec![uid.clone()])).unwrap(); + let _res = ::messages::get_message::download_messages(None, None, Some(vec![uid.clone()])).unwrap(); // Get Message by id works { @@ -116,12 +116,12 @@ pub mod tests { assert_eq!(0, messages.len()); } - // Send Generic Message works + // Send Basic Message works { faber.activate(); - let generic_message = r#"{"field":"value"}"#; - ::connection::send_generic_message(faber.connection_handle, generic_message, "").unwrap(); + let basic_message = r#"Hi there"#; + ::connection::send_generic_message(faber.connection_handle, basic_message, "").unwrap(); alice.activate(); @@ -132,7 +132,7 @@ pub mod tests { let message = messages.values().next().unwrap().clone(); match message { - A2AMessage::Generic(message) => assert_eq!(generic_message, message), + A2AMessage::BasicMessage(message) => assert_eq!(basic_message, message.content), _ => assert!(false) } ::connection::update_message_status(alice.connection_handle, uid).unwrap(); diff --git a/vcx/libvcx/src/v3/handlers/connection/states.rs b/vcx/libvcx/src/v3/handlers/connection/states.rs index e76a838646..158d6ba152 100644 --- a/vcx/libvcx/src/v3/handlers/connection/states.rs +++ b/vcx/libvcx/src/v3/handlers/connection/states.rs @@ -94,14 +94,14 @@ pub struct CompleteState { } impl From<(NullState, Invitation)> for InvitedState { - fn from((state, invitation): (NullState, Invitation)) -> InvitedState { + fn from((_state, invitation): (NullState, Invitation)) -> InvitedState { trace!("DidExchangeStateSM: transit state from NullState to InvitedState"); InvitedState { invitation } } } impl From<(InvitedState, ProblemReport)> for NullState { - fn from((state, error): (InvitedState, ProblemReport)) -> NullState { + fn from((_state, _error): (InvitedState, ProblemReport)) -> NullState { trace!("DidExchangeStateSM: transit state from InvitedState to NullState"); NullState {} } @@ -115,42 +115,42 @@ impl From<(InvitedState, Request)> for RequestedState { } impl From<(InvitedState, Request, SignedResponse, AgentInfo)> for RespondedState { - fn from((state, request, response, prev_agent_info): (InvitedState, Request, SignedResponse, AgentInfo)) -> RespondedState { + fn from((_state, request, response, prev_agent_info): (InvitedState, Request, SignedResponse, AgentInfo)) -> RespondedState { trace!("DidExchangeStateSM: transit state from InvitedState to RequestedState"); RespondedState { response, did_doc: request.connection.did_doc, prev_agent_info } } } impl From<(RequestedState, ProblemReport)> for NullState { - fn from((state, error): (RequestedState, ProblemReport)) -> NullState { + fn from((_state, _error): (RequestedState, ProblemReport)) -> NullState { trace!("DidExchangeStateSM: transit state from RequestedState to NullState"); NullState {} } } impl From<(RequestedState, Response)> for CompleteState { - fn from((state, response): (RequestedState, Response)) -> CompleteState { + fn from((_state, response): (RequestedState, Response)) -> CompleteState { trace!("DidExchangeStateSM: transit state from RequestedState to RespondedState"); CompleteState { did_doc: response.connection.did_doc, pending_messages: HashMap::new(), protocols: None } } } impl From<(RespondedState, ProblemReport)> for NullState { - fn from((state, error): (RespondedState, ProblemReport)) -> NullState { + fn from((_state, _error): (RespondedState, ProblemReport)) -> NullState { trace!("DidExchangeStateSM: transit state from RespondedState to NullState"); NullState {} } } impl From<(RespondedState, Ack)> for CompleteState { - fn from((state, ack): (RespondedState, Ack)) -> CompleteState { + fn from((state, _ack): (RespondedState, Ack)) -> CompleteState { trace!("DidExchangeStateSM: transit state from RespondedState to CompleteState"); CompleteState { did_doc: state.did_doc, pending_messages: HashMap::new(), protocols: None } } } impl From<(RespondedState, Ping)> for CompleteState { - fn from((state, ping): (RespondedState, Ping)) -> CompleteState { + fn from((state, _ping): (RespondedState, Ping)) -> CompleteState { trace!("DidExchangeStateSM: transit state from RespondedState to CompleteState"); CompleteState { did_doc: state.did_doc, pending_messages: HashMap::new(), protocols: None } } @@ -231,7 +231,7 @@ impl CompleteState { self.handle_ping(&ping, agent_info)?; DidExchangeState::Completed(self) } - DidExchangeMessages::PingResponseReceived(ping_response) => { + DidExchangeMessages::PingResponseReceived(_) => { DidExchangeState::Completed(self) } DidExchangeMessages::DiscoverFeatures((query_, comment)) => { @@ -345,7 +345,7 @@ impl DidExchangeSM { for (uid, message) in messages { match self.state { - ActorDidExchangeState::Inviter(DidExchangeState::Invited(ref state)) => { + ActorDidExchangeState::Inviter(DidExchangeState::Invited(_)) => { match message { request @ A2AMessage::ConnectionRequest(_) => { debug!("Inviter received ConnectionRequest message"); @@ -360,7 +360,7 @@ impl DidExchangeSM { } } } - ActorDidExchangeState::Invitee(DidExchangeState::Requested(ref state)) => { + ActorDidExchangeState::Invitee(DidExchangeState::Requested(_)) => { match message { response @ A2AMessage::ConnectionResponse(_) => { debug!("Invitee received ConnectionResponse message"); @@ -375,7 +375,7 @@ impl DidExchangeSM { } } } - ActorDidExchangeState::Inviter(DidExchangeState::Responded(ref state)) => { + ActorDidExchangeState::Inviter(DidExchangeState::Responded(_)) => { match message { ack @ A2AMessage::Ack(_) => { debug!("Ack message received"); @@ -394,8 +394,8 @@ impl DidExchangeSM { } } } - ActorDidExchangeState::Invitee(DidExchangeState::Completed(ref state)) | - ActorDidExchangeState::Inviter(DidExchangeState::Completed(ref state)) => { + ActorDidExchangeState::Invitee(DidExchangeState::Completed(_)) | + ActorDidExchangeState::Inviter(DidExchangeState::Completed(_)) => { match message { ping @ A2AMessage::Ping(_) => { debug!("Ping message received"); @@ -1105,6 +1105,7 @@ pub mod test { use v3::messages::connection::did_doc::tests::_service_endpoint; use ::utils::libindy::tests::create_key; + use indy_sys::WalletHandle; pub fn invitee_sm() -> DidExchangeSM { DidExchangeSM::new(Actor::Invitee, &source_id()) @@ -1122,7 +1123,7 @@ pub mod test { self } - pub fn to_invitee_completed_state(mut self, wallet_handle: i32) -> DidExchangeSM { + pub fn to_invitee_completed_state(mut self, wallet_handle: WalletHandle) -> DidExchangeSM { let key = create_key(wallet_handle, Some(::utils::libindy::tests::test_setup::TRUSTEE_SEED)); let invitation = Invitation::default().set_recipient_keys(vec![key.clone()]); @@ -1235,8 +1236,6 @@ pub mod test { let mut did_exchange_sm = invitee_sm().to_invitee_requested_state(); - let invitation = Invitation::default().set_recipient_keys(vec![key.clone()]); - did_exchange_sm = did_exchange_sm.step(DidExchangeMessages::ExchangeResponseReceived(_response(&key))).unwrap(); assert_match!(ActorDidExchangeState::Invitee(DidExchangeState::Completed(_)), did_exchange_sm.state); diff --git a/vcx/libvcx/src/v3/handlers/issuance/holder.rs b/vcx/libvcx/src/v3/handlers/issuance/holder.rs index cc2f349689..b5fd65dfd7 100644 --- a/vcx/libvcx/src/v3/handlers/issuance/holder.rs +++ b/vcx/libvcx/src/v3/handlers/issuance/holder.rs @@ -41,7 +41,12 @@ impl HolderSM { match self.state { HolderState::OfferReceived(_) => VcxStateType::VcxStateRequestReceived as u32, HolderState::RequestSent(_) => VcxStateType::VcxStateOfferSent as u32, - HolderState::Finished(_) => VcxStateType::VcxStateAccepted as u32, + HolderState::Finished(ref status) => { + match status.status { + Status::Success => VcxStateType::VcxStateAccepted as u32, + _ => VcxStateType::VcxStateNone as u32, + } + }, } } @@ -67,10 +72,10 @@ impl HolderSM { for (uid, message) in messages { match self.state { - HolderState::OfferReceived(ref state) => { + HolderState::OfferReceived(_) => { // do not process messages } - HolderState::RequestSent(ref state) => { + HolderState::RequestSent(_) => { match message { A2AMessage::Credential(credential) => { if credential.from_thread(&self.thread_id) { @@ -85,7 +90,7 @@ impl HolderSM { _ => {} } } - HolderState::Finished(ref state) => { + HolderState::Finished(_) => { // do not process messages } }; @@ -246,7 +251,7 @@ fn _make_credential_request(conn_handle: u32, offer: &CredentialOffer) -> VcxRes let my_did = connection::get_pw_did(conn_handle)?; let cred_offer = offer.offers_attach.content()?; let cred_def_id = _parse_cred_def_from_cred_offer(&cred_offer)?; - let (req, req_meta, cred_def_id, cred_def_json) = + let (req, req_meta, _cred_def_id, cred_def_json) = credential::Credential::create_credential_request(&cred_def_id, &my_did, &cred_offer)?; Ok((CredentialRequest::create().set_requests_attach(req)?, req_meta, cred_def_json)) } diff --git a/vcx/libvcx/src/v3/handlers/issuance/issuer.rs b/vcx/libvcx/src/v3/handlers/issuance/issuer.rs index 7c589bdf32..51a2f53930 100644 --- a/vcx/libvcx/src/v3/handlers/issuance/issuer.rs +++ b/vcx/libvcx/src/v3/handlers/issuance/issuer.rs @@ -66,10 +66,10 @@ impl IssuerSM { for (uid, message) in messages { match self.state { - IssuerState::Initial(ref state) => { + IssuerState::Initial(_) => { // do not process messages } - IssuerState::OfferSent(ref state) => { + IssuerState::OfferSent(_) => { match message { A2AMessage::CredentialRequest(credential) => { if credential.from_thread(&self.state.thread_id()) { @@ -91,10 +91,10 @@ impl IssuerSM { _ => {} } } - IssuerState::RequestReceived(ref state) => { + IssuerState::RequestReceived(_) => { // do not process messages } - IssuerState::CredentialSent(ref state) => { + IssuerState::CredentialSent(_) => { match message { A2AMessage::Ack(ack) | A2AMessage::CredentialAck(ack) => { if ack.from_thread(&self.state.thread_id()) { @@ -109,7 +109,7 @@ impl IssuerSM { _ => {} } } - IssuerState::Finished(ref state) => { + IssuerState::Finished(_) => { // do not process messages } }; @@ -124,7 +124,12 @@ impl IssuerSM { IssuerState::OfferSent(_) => VcxStateType::VcxStateOfferSent as u32, IssuerState::RequestReceived(_) => VcxStateType::VcxStateRequestReceived as u32, IssuerState::CredentialSent(_) => VcxStateType::VcxStateAccepted as u32, - IssuerState::Finished(_) => VcxStateType::VcxStateAccepted as u32, + IssuerState::Finished(ref status) => { + match status.status { + Status::Success => VcxStateType::VcxStateAccepted as u32, + _ => VcxStateType::VcxStateNone as u32, + } + }, } } @@ -151,7 +156,7 @@ impl IssuerSM { CredentialIssuanceMessage::CredentialRequest(request) => { IssuerState::RequestReceived((state_data, request).into()) } - CredentialIssuanceMessage::CredentialProposal(proposal) => { + CredentialIssuanceMessage::CredentialProposal(_) => { let problem_report = ProblemReport::create() .set_comment(String::from("CredentialProposal is not supported")) .set_thread_id(&state_data.thread_id); @@ -261,11 +266,11 @@ fn _create_credential(request: &CredentialRequest, rev_reg_id: &Option, let cred_data = encode_attributes(cred_data)?; - let (credential, cred_id, revoc_reg_delta) = anoncreds::libindy_issuer_create_credential(offer, - &request, - &cred_data, - rev_reg_id.clone(), - tails_file.clone())?; + let (credential, _, _) = anoncreds::libindy_issuer_create_credential(offer, + &request, + &cred_data, + rev_reg_id.clone(), + tails_file.clone())?; Credential::create() .set_credential(credential) } diff --git a/vcx/libvcx/src/v3/handlers/issuance/mod.rs b/vcx/libvcx/src/v3/handlers/issuance/mod.rs index ff482d7c26..7dddf4bb92 100644 --- a/vcx/libvcx/src/v3/handlers/issuance/mod.rs +++ b/vcx/libvcx/src/v3/handlers/issuance/mod.rs @@ -36,7 +36,7 @@ impl Issuer { self.step(CredentialIssuanceMessage::CredentialInit(connection_handle)) } - pub fn send_credential(&mut self, connection_handle: u32) -> VcxResult<()> { + pub fn send_credential(&mut self, _connection_handle: u32) -> VcxResult<()> { // TODO: should use connection_handle self.step(CredentialIssuanceMessage::CredentialSend()) } diff --git a/vcx/libvcx/src/v3/handlers/issuance/states.rs b/vcx/libvcx/src/v3/handlers/issuance/states.rs index 38e8a889ed..9a2e6bdb78 100644 --- a/vcx/libvcx/src/v3/handlers/issuance/states.rs +++ b/vcx/libvcx/src/v3/handlers/issuance/states.rs @@ -23,17 +23,17 @@ pub enum IssuerState { impl IssuerState { pub fn get_connection_handle(&self) -> u32 { match self { - IssuerState::Initial(state) => 0, + IssuerState::Initial(_) => 0, IssuerState::OfferSent(state) => state.connection_handle, IssuerState::RequestReceived(state) => state.connection_handle, IssuerState::CredentialSent(state) => state.connection_handle, - IssuerState::Finished(state) => 0 + IssuerState::Finished(_) => 0 } } pub fn thread_id(&self) -> String { match self { - IssuerState::Initial(state) => String::new(), + IssuerState::Initial(_) => String::new(), IssuerState::OfferSent(state) => state.thread_id.clone(), IssuerState::RequestReceived(state) => state.thread_id.clone(), IssuerState::CredentialSent(state) => state.thread_id.clone(), @@ -110,7 +110,7 @@ impl From<(InitialState, String, u32, MessageId)> for OfferSentState { } impl From for FinishedState { - fn from(state: InitialState) -> Self { + fn from(_state: InitialState) -> Self { trace!("SM is now in Finished state"); FinishedState { cred_id: None, @@ -136,7 +136,7 @@ impl From<(OfferSentState, CredentialRequest)> for RequestReceivedState { } impl From<(RequestReceivedState, MessageId)> for CredentialSentState { - fn from((state, sent_id): (RequestReceivedState, MessageId)) -> Self { + fn from((state, _sent_id): (RequestReceivedState, MessageId)) -> Self { trace!("SM is now in CredentialSent state"); CredentialSentState { connection_handle: state.connection_handle, @@ -210,9 +210,9 @@ pub enum HolderState { impl HolderState { pub fn get_connection_handle(&self) -> u32 { match self { - HolderState::OfferReceived(state) => 0, + HolderState::OfferReceived(_) => 0, HolderState::RequestSent(state) => state.connection_handle, - HolderState::Finished(state) => 0 + HolderState::Finished(_) => 0 } } } @@ -246,7 +246,7 @@ pub struct FinishedHolderState { } impl From<(OfferReceivedState, String, String, u32)> for RequestSentState { - fn from((state, req_meta, cred_def_json, connection_handle): (OfferReceivedState, String, String, u32)) -> Self { + fn from((_state, req_meta, cred_def_json, connection_handle): (OfferReceivedState, String, String, u32)) -> Self { trace!("SM is now in RequestSent state"); RequestSentState { req_meta, diff --git a/vcx/libvcx/src/v3/handlers/proof_presentation/prover/states.rs b/vcx/libvcx/src/v3/handlers/proof_presentation/prover/states.rs index f8fa3714b5..7fb47f35c5 100644 --- a/vcx/libvcx/src/v3/handlers/proof_presentation/prover/states.rs +++ b/vcx/libvcx/src/v3/handlers/proof_presentation/prover/states.rs @@ -143,7 +143,7 @@ impl From<(PresentationPreparationFailedState, u32)> for FinishedState { } impl From<(PresentationSentState, PresentationAck)> for FinishedState { - fn from((state, ack): (PresentationSentState, PresentationAck)) -> Self { + fn from((state, _ack): (PresentationSentState, PresentationAck)) -> Self { trace!("transit state from PresentationSentState to FinishedState"); FinishedState { connection_handle: state.connection_handle, @@ -180,7 +180,7 @@ impl ProverSM { for (uid, message) in messages { match self.state { - ProverState::Initiated(ref state) => { + ProverState::Initiated(_) => { match message { A2AMessage::PresentationRequest(_) => { // ignore it here?? @@ -194,7 +194,7 @@ impl ProverSM { ProverState::PresentationPreparationFailed(_) => { // do not process messages } - ProverState::PresentationSent(ref state) => { + ProverState::PresentationSent(_) => { match message { A2AMessage::Ack(ack) | A2AMessage::PresentationAck(ack) => { if ack.from_thread(&self.thread_id) { @@ -209,7 +209,7 @@ impl ProverSM { _ => {} } } - ProverState::Finished(ref state) => { + ProverState::Finished(_) => { // do not process messages } }; @@ -364,7 +364,12 @@ impl ProverSM { ProverState::PresentationPrepared(_) => VcxStateType::VcxStateInitialized as u32, ProverState::PresentationPreparationFailed(_) => VcxStateType::VcxStateInitialized as u32, ProverState::PresentationSent(_) => VcxStateType::VcxStateOfferSent as u32, // TODO: maybe VcxStateType::VcxStateAccepted - ProverState::Finished(_) => VcxStateType::VcxStateAccepted as u32, + ProverState::Finished(ref status) => { + match status.status { + Status::Success => VcxStateType::VcxStateAccepted as u32, + _ => VcxStateType::VcxStateNone as u32, + } + }, } } @@ -407,9 +412,9 @@ impl ProverSM { pub fn presentation(&self) -> VcxResult<&Presentation> { match self.state { - ProverState::Initiated(ref state) => Err(VcxError::from_msg(VcxErrorKind::NotReady, "Presentation is not created yet")), + ProverState::Initiated(_) => Err(VcxError::from_msg(VcxErrorKind::NotReady, "Presentation is not created yet")), ProverState::PresentationPrepared(ref state) => Ok(&state.presentation), - ProverState::PresentationPreparationFailed(ref state) => Err(VcxError::from_msg(VcxErrorKind::NotReady, "Presentation is not created yet")), + ProverState::PresentationPreparationFailed(_) => Err(VcxError::from_msg(VcxErrorKind::NotReady, "Presentation is not created yet")), ProverState::PresentationSent(ref state) => Ok(&state.presentation), ProverState::Finished(ref state) => Ok(&state.presentation), } diff --git a/vcx/libvcx/src/v3/handlers/proof_presentation/verifier/states.rs b/vcx/libvcx/src/v3/handlers/proof_presentation/verifier/states.rs index f497842d7a..f395f5e534 100644 --- a/vcx/libvcx/src/v3/handlers/proof_presentation/verifier/states.rs +++ b/vcx/libvcx/src/v3/handlers/proof_presentation/verifier/states.rs @@ -57,7 +57,7 @@ pub struct FinishedState { } impl From<(InitialState, PresentationRequest, u32)> for PresentationRequestSentState { - fn from((state, presentation_request, connection_handle): (InitialState, PresentationRequest, u32)) -> Self { + fn from((_state, presentation_request, connection_handle): (InitialState, PresentationRequest, u32)) -> Self { trace!("transit state from InitialState to PresentationRequestSentState"); PresentationRequestSentState { connection_handle, presentation_request } } @@ -111,10 +111,10 @@ impl VerifierSM { for (uid, message) in messages { match self.state { - VerifierState::Initiated(ref state) => { + VerifierState::Initiated(_) => { // do not process message } - VerifierState::PresentationRequestSent(ref state) => { + VerifierState::PresentationRequestSent(_) => { match message { A2AMessage::Presentation(presentation) => { if presentation.from_thread(&self.thread_id()) { @@ -134,7 +134,7 @@ impl VerifierSM { _ => {} } } - VerifierState::Finished(ref state) => { + VerifierState::Finished(_) => { // do not process message } }; @@ -196,7 +196,7 @@ impl VerifierSM { VerifierMessages::PresentationRejectReceived(problem_report) => { VerifierState::Finished((state, problem_report).into()) } - VerifierMessages::PresentationProposalReceived(presentation_proposal) => { // TODO: handle Presentation Proposal + VerifierMessages::PresentationProposalReceived(_) => { // TODO: handle Presentation Proposal let problem_report = ProblemReport::create() .set_comment(String::from("PresentationProposal is not supported")) @@ -224,7 +224,12 @@ impl VerifierSM { match self.state { VerifierState::Initiated(_) => VcxStateType::VcxStateInitialized as u32, VerifierState::PresentationRequestSent(_) => VcxStateType::VcxStateOfferSent as u32, - VerifierState::Finished(_) => VcxStateType::VcxStateAccepted as u32, + VerifierState::Finished(ref status) => { + match status.status { + Status::Success => VcxStateType::VcxStateAccepted as u32, + _ => VcxStateType::VcxStateNone as u32, + } + }, } } @@ -254,8 +259,8 @@ impl VerifierSM { pub fn presentation_request_data(&self) -> VcxResult<&PresentationRequestData> { match self.state { VerifierState::Initiated(ref state) => Ok(&state.presentation_request_data), - VerifierState::PresentationRequestSent(ref state) => Err(VcxError::from(VcxErrorKind::InvalidProofHandle)), - VerifierState::Finished(ref state) => Err(VcxError::from(VcxErrorKind::InvalidProofHandle)), + VerifierState::PresentationRequestSent(_) => Err(VcxError::from(VcxErrorKind::InvalidProofHandle)), + VerifierState::Finished(_) => Err(VcxError::from(VcxErrorKind::InvalidProofHandle)), } } @@ -271,8 +276,8 @@ impl VerifierSM { pub fn presentation(&self) -> VcxResult { match self.state { - VerifierState::Initiated(ref state) => Err(VcxError::from_msg(VcxErrorKind::NotReady, "Presentation is not received yet")), - VerifierState::PresentationRequestSent(ref state) => Err(VcxError::from_msg(VcxErrorKind::NotReady, "Presentation is not received yet")), + VerifierState::Initiated(_) => Err(VcxError::from_msg(VcxErrorKind::NotReady, "Presentation is not received yet")), + VerifierState::PresentationRequestSent(_) => Err(VcxError::from_msg(VcxErrorKind::NotReady, "Presentation is not received yet")), VerifierState::Finished(ref state) => { state.presentation.clone() .ok_or(VcxError::from(VcxErrorKind::InvalidProofHandle)) diff --git a/vcx/libvcx/src/v3/messages/a2a/message_family.rs b/vcx/libvcx/src/v3/messages/a2a/message_family.rs index 87a678ee64..3ee3747e71 100644 --- a/vcx/libvcx/src/v3/messages/a2a/message_family.rs +++ b/vcx/libvcx/src/v3/messages/a2a/message_family.rs @@ -11,6 +11,7 @@ pub enum MessageFamilies { PresentProof, TrustPing, DiscoveryFeatures, + Basicmessage, Unknown(String) } @@ -28,6 +29,7 @@ impl MessageFamilies { MessageFamilies::PresentProof => "1.0", MessageFamilies::TrustPing => "1.0", MessageFamilies::DiscoveryFeatures => "1.0", + MessageFamilies::Basicmessage => "1.0", MessageFamilies::Unknown(_) => "1.0" } } @@ -47,6 +49,7 @@ impl MessageFamilies { MessageFamilies::PresentProof => Some((Actors::Prover, Actors::Verifier)), MessageFamilies::TrustPing => Some((Actors::Sender, Actors::Receiver)), MessageFamilies::DiscoveryFeatures => Some((Actors::Sender, Actors::Receiver)), + MessageFamilies::Basicmessage => Some((Actors::Sender, Actors::Receiver)), MessageFamilies::Unknown(_) => None } } @@ -64,6 +67,7 @@ impl From for MessageFamilies { "present-proof" => MessageFamilies::PresentProof, "trust_ping" => MessageFamilies::TrustPing, "discover-features" => MessageFamilies::DiscoveryFeatures, + "basicmessage" => MessageFamilies::Basicmessage, family @ _ => MessageFamilies::Unknown(family.to_string()) } } @@ -81,6 +85,7 @@ impl ::std::string::ToString for MessageFamilies { MessageFamilies::PresentProof => "present-proof".to_string(), MessageFamilies::TrustPing => "trust_ping".to_string(), MessageFamilies::DiscoveryFeatures => "discover-features".to_string(), + MessageFamilies::Basicmessage => "basicmessage".to_string(), MessageFamilies::Unknown(family) => family.to_string() } } diff --git a/vcx/libvcx/src/v3/messages/a2a/mod.rs b/vcx/libvcx/src/v3/messages/a2a/mod.rs index e6c147ccbd..28155e1b1e 100644 --- a/vcx/libvcx/src/v3/messages/a2a/mod.rs +++ b/vcx/libvcx/src/v3/messages/a2a/mod.rs @@ -30,6 +30,8 @@ use v3::messages::proof_presentation::presentation::Presentation; use v3::messages::discovery::query::Query; use v3::messages::discovery::disclose::Disclose; +use v3::messages::basic_message::message::BasicMessage; + #[derive(Debug, PartialEq)] pub enum A2AMessage { /// routing @@ -66,6 +68,9 @@ pub enum A2AMessage { Query(Query), Disclose(Disclose), + /// basic message + BasicMessage(BasicMessage), + /// Any Raw Message Generic(String), } @@ -180,6 +185,11 @@ impl<'de> Deserialize<'de> for A2AMessage { .map(|msg| A2AMessage::Disclose(msg)) .map_err(de::Error::custom) } + (MessageFamilies::Basicmessage, A2AMessage::BASIC_MESSAGE) => { + BasicMessage::deserialize(value) + .map(|msg| A2AMessage::BasicMessage(msg)) + .map_err(de::Error::custom) + } (_, other_type) => { warn!("Unexpected @type field structure: {}", other_type); Ok(A2AMessage::Generic(value.to_string())) @@ -218,6 +228,7 @@ impl Serialize for A2AMessage { A2AMessage::PresentationAck(msg) => set_a2a_message_type(msg, MessageFamilies::PresentProof, A2AMessage::ACK), A2AMessage::Query(msg) => set_a2a_message_type(msg, MessageFamilies::DiscoveryFeatures, A2AMessage::QUERY), A2AMessage::Disclose(msg) => set_a2a_message_type(msg, MessageFamilies::DiscoveryFeatures, A2AMessage::DISCLOSE), + A2AMessage::BasicMessage(msg) => set_a2a_message_type(msg, MessageFamilies::Basicmessage, A2AMessage::BASIC_MESSAGE), A2AMessage::Generic(msg) => ::serde_json::to_value(msg), }.map_err(ser::Error::custom)?; @@ -271,6 +282,7 @@ impl A2AMessage { const PRESENTATION: &'static str = "presentation"; const QUERY: &'static str = "query"; const DISCLOSE: &'static str = "disclose"; + const BASIC_MESSAGE: &'static str = "message"; } #[macro_export] diff --git a/vcx/libvcx/src/v3/messages/a2a/protocol_registry.rs b/vcx/libvcx/src/v3/messages/a2a/protocol_registry.rs index fa5aa521a1..5ba96ad5ff 100644 --- a/vcx/libvcx/src/v3/messages/a2a/protocol_registry.rs +++ b/vcx/libvcx/src/v3/messages/a2a/protocol_registry.rs @@ -23,6 +23,7 @@ impl ProtocolRegistry { family @ MessageFamilies::CredentialIssuance | family @ MessageFamilies::PresentProof | family @ MessageFamilies::TrustPing | + family @ MessageFamilies::Basicmessage | family @ MessageFamilies::DiscoveryFeatures => registry.add_protocol(&actors, family), MessageFamilies::Signature => {} MessageFamilies::Unknown(_) => {} @@ -38,7 +39,7 @@ impl ProtocolRegistry { self.protocols.push(ProtocolDescriptor { pid: family.id(), roles: None }) } Some((actor_1, actor_2)) => { - match (actors.contains(&actor_1), actors.contains(&actor_1)) { + match (actors.contains(&actor_1), actors.contains(&actor_2)) { (true, true) => { self.protocols.push({ ProtocolDescriptor { pid: family.id(), roles: None } }) } @@ -46,7 +47,7 @@ impl ProtocolRegistry { self.protocols.push({ ProtocolDescriptor { pid: family.id(), roles: Some(vec![actor_1]) } }) } (false, true) => { - self.protocols.push({ ProtocolDescriptor { pid: family.id(), roles: Some(vec![actor_1]) } }) + self.protocols.push({ ProtocolDescriptor { pid: family.id(), roles: Some(vec![actor_2]) } }) } (false, false) => {} } @@ -150,11 +151,13 @@ pub mod tests { let expected_protocols = vec![ ProtocolDescriptor { pid: MessageFamilies::Connections.id(), roles: None }, ]; + assert_eq!(expected_protocols, protocols); let protocols = registry.get_protocols_for_query(Some("did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/1.0")); let expected_protocols = vec![ ProtocolDescriptor { pid: MessageFamilies::Connections.id(), roles: None }, ]; + assert_eq!(expected_protocols, protocols); } #[test] @@ -168,5 +171,8 @@ pub mod tests { let expected_protocols = vec![ ProtocolDescriptor { pid: MessageFamilies::Connections.id(), roles: Some(vec![Actors::Invitee]) }, ]; + assert_eq!(expected_protocols, protocols); + + ::settings::clear_config(); } } \ No newline at end of file diff --git a/vcx/libvcx/src/v3/messages/basic_message/message.rs b/vcx/libvcx/src/v3/messages/basic_message/message.rs new file mode 100644 index 0000000000..33c67d6f65 --- /dev/null +++ b/vcx/libvcx/src/v3/messages/basic_message/message.rs @@ -0,0 +1,57 @@ +use v3::messages::a2a::{MessageId, A2AMessage}; +use v3::messages::localization::Localization; +use chrono::prelude::*; + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)] +pub struct BasicMessage { + #[serde(rename = "@id")] + pub id: MessageId, + pub sent_time: String, + pub content: String, + #[serde(rename = "~l10n")] + #[serde(skip_serializing_if = "Option::is_none")] + pub l10n: Option, +} + +impl BasicMessage { + pub fn create() -> BasicMessage { + BasicMessage::default() + } + + pub fn set_content(mut self, content: String) -> Self { + self.content = content; + self + } + + pub fn set_time(mut self) -> Self { + self.sent_time = format!("{:?}", Utc::now()); + self + } + + pub fn set_default_localization(mut self) -> Self { + self.l10n = Some(Localization::default()); + self + } + + pub fn to_a2a_message(&self) -> A2AMessage { + A2AMessage::BasicMessage(self.clone()) // TODO: THINK how to avoid clone + } +} + +#[cfg(test)] +pub mod tests { + use super::*; + + fn _content() -> String { + String::from("Your hovercraft is full of eels.") + } + + #[test] + fn test_basic_message_build_works() { + let basic_message: BasicMessage = BasicMessage::default() + .set_content(_content()) + .set_time() + .set_default_localization(); + assert_eq!(_content(), basic_message.content); + } +} diff --git a/vcx/libvcx/src/v3/messages/basic_message/mod.rs b/vcx/libvcx/src/v3/messages/basic_message/mod.rs new file mode 100644 index 0000000000..e216a50180 --- /dev/null +++ b/vcx/libvcx/src/v3/messages/basic_message/mod.rs @@ -0,0 +1 @@ +pub mod message; diff --git a/vcx/libvcx/src/v3/messages/connection/did_doc.rs b/vcx/libvcx/src/v3/messages/connection/did_doc.rs index 6da2484162..23237df315 100644 --- a/vcx/libvcx/src/v3/messages/connection/did_doc.rs +++ b/vcx/libvcx/src/v3/messages/connection/did_doc.rs @@ -2,6 +2,7 @@ use v3::messages::connection::invite::Invitation; use error::prelude::*; use url::Url; +use messages::validation::validate_verkey; pub const CONTEXT: &str = "https://w3id.org/did/v1"; pub const KEY_TYPE: &str = "Ed25519VerificationKey2018"; @@ -13,6 +14,7 @@ pub const SERVICE_TYPE: &str = "IndyAgent"; pub struct DidDoc { #[serde(rename = "@context")] pub context: String, + #[serde(default)] pub id: String, #[serde(default)] #[serde(rename = "publicKey")] @@ -104,7 +106,7 @@ impl DidDoc { self.authentication.push( Authentication { type_: String::from(KEY_AUTHENTICATION_TYPE), - public_key: key_reference.clone() + public_key: key_reference.clone(), }); @@ -118,6 +120,7 @@ impl DidDoc { routing_keys .iter() .for_each(|key| { + // Note: comment lines 123 - 134 and append key instead key_reference to be compatible with Streetcred id += 1; let key_id = id.to_string(); @@ -141,38 +144,45 @@ impl DidDoc { pub fn validate(&self) -> VcxResult<()> { if self.context != CONTEXT { - return Err(VcxError::from_msg(VcxErrorKind::InvalidJson, format!("DIDDoc validation failed: Unsupported @context value: {:?}", self.context))) + return Err(VcxError::from_msg(VcxErrorKind::InvalidJson, format!("DIDDoc validation failed: Unsupported @context value: {:?}", self.context))); } if self.id.is_empty() { - return Err(VcxError::from_msg(VcxErrorKind::InvalidJson, "DIDDoc validation failed: id is empty")) + return Err(VcxError::from_msg(VcxErrorKind::InvalidJson, "DIDDoc validation failed: id is empty")); } - + for service in self.service.iter() { Url::parse(&service.service_endpoint) - .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidJson, format!("DIDDoc validation failed: Unsupported endpoint: {:?}", service.service_endpoint)))?; + .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidJson, format!("DIDDoc validation failed: Invalid endpoint \"{:?}\", err: {:?}", service.service_endpoint, err)))?; service.recipient_keys .iter() - .map(|key| { - self.validate_public_key(key) - .and_then(|public_key| - self.validate_authentication(&public_key.id) - ) - }) + .map(|key| self.validate_recipient_key(key)) .collect::>()?; service.routing_keys .iter() - .map(|key| { - self.validate_public_key(key).map(|_| ()) - }) + .map(|key| self.validate_routing_key(key)) .collect::>()?; } Ok(()) } + fn validate_recipient_key(&self, key: &str) -> VcxResult<()> { + let public_key = self.validate_public_key(key)?; + self.validate_authentication(&public_key.id) + } + + fn validate_routing_key(&self, key: &str) -> VcxResult<()> { + if DidDoc::_key_parts(key).len() == 2 { + self.validate_public_key(key)?; + } else { + validate_verkey(key)?; + } + Ok(()) + } + fn validate_public_key(&self, target_key: &str) -> VcxResult<&Ed25519PublicKey> { let id = DidDoc::_parse_key_reference(target_key); @@ -183,12 +193,14 @@ impl DidDoc { return Err(VcxError::from_msg(VcxErrorKind::InvalidJson, format!("DIDDoc validation failed: Unsupported PublicKey type: {:?}", key.type_))); } + validate_verkey(&key.public_key_base_58)?; + Ok(key) } fn validate_authentication(&self, target_key: &str) -> VcxResult<()> { - if self.authentication.is_empty(){ - return Ok(()) + if self.authentication.is_empty() { + return Ok(()); } let key = self.authentication.iter().find(|key_| @@ -246,15 +258,19 @@ impl DidDoc { self.public_key.iter().find(|key_| key_.id == id.to_string() || key_.public_key_base_58 == id.to_string()) .map(|key| key.public_key_base_58.clone()) - .unwrap_or_default() + .unwrap_or(id) } fn _build_key_reference(did: &str, id: &str) -> String { format!("{}#{}", did, id) } + fn _key_parts(key: &str) -> Vec<&str> { + key.split("#").collect() + } + fn _parse_key_reference(key_reference: &str) -> String { - let pars: Vec<&str> = key_reference.split("#").collect(); + let pars: Vec<&str> = DidDoc::_key_parts(key_reference); pars.get(1).or(pars.get(0)).map(|s| s.to_string()).unwrap_or_default() } } @@ -427,6 +443,25 @@ pub mod tests { } } + pub fn _did_doc_5() -> DidDoc { + DidDoc { + context: String::from(CONTEXT), + id: _id(), + public_key: vec![ + Ed25519PublicKey { id: _key_reference_1(), type_: KEY_TYPE.to_string(), controller: _id(), public_key_base_58: _key_1() }, + ], + authentication: vec![ + Authentication { type_: KEY_AUTHENTICATION_TYPE.to_string(), public_key: _key_reference_1() } + ], + service: vec![Service { + service_endpoint: _service_endpoint(), + recipient_keys: vec![_key_1()], + routing_keys: vec![_key_2(), _key_3()], + ..Default::default() + }], + } + } + #[test] fn test_did_doc_build_works() { let mut did_doc: DidDoc = DidDoc::default(); @@ -443,6 +478,7 @@ pub mod tests { _did_doc_2().validate().unwrap(); _did_doc_3().validate().unwrap(); _did_doc_4().validate().unwrap(); + _did_doc_5().validate().unwrap(); } #[test] @@ -455,6 +491,10 @@ pub mod tests { let (recipient_keys, routing_keys) = _did_doc().resolve_keys(); assert_eq!(_recipient_keys(), recipient_keys); assert_eq!(_routing_keys(), routing_keys); + + let (recipient_keys, routing_keys) = _did_doc_2().resolve_keys(); + assert_eq!(_recipient_keys(), recipient_keys); + assert_eq!(_routing_keys(), routing_keys); } #[test] diff --git a/vcx/libvcx/src/v3/messages/connection/problem_report.rs b/vcx/libvcx/src/v3/messages/connection/problem_report.rs index 56c03e52ed..8a9c982f53 100644 --- a/vcx/libvcx/src/v3/messages/connection/problem_report.rs +++ b/vcx/libvcx/src/v3/messages/connection/problem_report.rs @@ -1,4 +1,5 @@ use v3::messages::a2a::{MessageId, A2AMessage}; +use v3::messages::localization::Localization; use messages::thread::Thread; #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)] @@ -30,17 +31,6 @@ pub enum ProblemCode { ResponseProcessingError } -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)] -pub struct Localization { - locale: Locales -} - -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] -pub enum Locales { - #[serde(rename = "en")] - En, -} - impl ProblemReport { pub fn create() -> ProblemReport { ProblemReport::default() @@ -68,12 +58,6 @@ impl Default for ProblemCode { } } -impl Default for Locales { - fn default() -> Locales { - Locales::En - } -} - #[cfg(test)] pub mod tests { use super::*; diff --git a/vcx/libvcx/src/v3/messages/localization.rs b/vcx/libvcx/src/v3/messages/localization.rs new file mode 100644 index 0000000000..54f4e6447f --- /dev/null +++ b/vcx/libvcx/src/v3/messages/localization.rs @@ -0,0 +1,16 @@ +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)] +pub struct Localization { + locale: Locales +} + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +pub enum Locales { + #[serde(rename = "en")] + En, +} + +impl Default for Locales { + fn default() -> Locales { + Locales::En + } +} \ No newline at end of file diff --git a/vcx/libvcx/src/v3/messages/mod.rs b/vcx/libvcx/src/v3/messages/mod.rs index 99f876fc4b..9ceb2bf9ca 100644 --- a/vcx/libvcx/src/v3/messages/mod.rs +++ b/vcx/libvcx/src/v3/messages/mod.rs @@ -11,4 +11,6 @@ pub mod status; pub mod issuance; pub mod proof_presentation; pub mod discovery; -pub mod trust_ping; \ No newline at end of file +pub mod trust_ping; +pub mod basic_message; +pub mod localization; \ No newline at end of file diff --git a/vcx/libvcx/src/v3/mod.rs b/vcx/libvcx/src/v3/mod.rs index 8b94feb744..fbd6238a7c 100644 --- a/vcx/libvcx/src/v3/mod.rs +++ b/vcx/libvcx/src/v3/mod.rs @@ -13,6 +13,7 @@ pub mod test { use messages::agent_utils::connect_register_provision; use utils::libindy::wallet::*; use v3::messages::a2a::A2AMessage; + use indy_sys::WalletHandle; pub fn source_id() -> String { String::from("test source id") @@ -20,6 +21,7 @@ pub mod test { pub mod setup { use settings::{CONFIG_WALLET_KEY_DERIVATION, DEFAULT_WALLET_KEY}; + use indy_sys::WalletHandle; pub fn base_config() -> ::serde_json::Value { json!({ @@ -56,7 +58,7 @@ pub mod test { pub struct AgencyModeSetup { pub wallet_name: String, - pub wallet_handle: i32, + pub wallet_handle: WalletHandle, } impl AgencyModeSetup { @@ -123,7 +125,7 @@ pub mod test { pub struct Faber { pub wallet_name: String, - pub wallet_handle: i32, + pub wallet_handle: WalletHandle, pub connection_handle: u32, pub config: String, pub schema_handle: u32, @@ -231,7 +233,6 @@ pub mod test { } pub fn create_presentation_request(&self) -> u32 { - let did = String::from("V4SGRU86Z58d6TV7PBUe6f"); let requested_attrs = json!([ {"name": "name"}, {"name": "date"}, @@ -357,7 +358,7 @@ pub mod test { pub struct Alice { pub wallet_name: String, - pub wallet_handle: i32, + pub wallet_handle: WalletHandle, pub connection_handle: u32, pub config: String, pub credential_handle: u32, @@ -571,12 +572,12 @@ pub mod test { // Decline Presentation faber.request_presentation(); alice.decline_presentation_request(); - faber.update_proof_state(4, 2); + faber.update_proof_state(0, 2); // Propose Presentation faber.request_presentation(); alice.propose_presentation(); - faber.update_proof_state(4, 2); + faber.update_proof_state(0, 2); } #[cfg(feature = "aries")] diff --git a/vcx/libvcx/src/v3/utils/encryption_envelope.rs b/vcx/libvcx/src/v3/utils/encryption_envelope.rs index be4edc826c..fc04db982d 100644 --- a/vcx/libvcx/src/v3/utils/encryption_envelope.rs +++ b/vcx/libvcx/src/v3/utils/encryption_envelope.rs @@ -61,7 +61,7 @@ impl EncryptionEnvelope { crypto::pack_message(None, &receiver_keys, message.as_bytes()) } - pub fn open(my_vk: &str, payload: Vec) -> VcxResult { + pub fn open(payload: Vec) -> VcxResult { let unpacked_msg = crypto::unpack_message(&payload)?; let message: ::serde_json::Value = ::serde_json::from_slice(unpacked_msg.as_slice()) @@ -110,7 +110,7 @@ pub mod tests { let message = A2AMessage::Ack(_ack()); let envelope = EncryptionEnvelope::create(&message, Some(&setup.key), &_did_doc_4()).unwrap(); - assert_eq!(message, EncryptionEnvelope::open(&_key_1(), envelope.0).unwrap()); + assert_eq!(message, EncryptionEnvelope::open(envelope.0).unwrap()); } #[test] @@ -128,7 +128,7 @@ pub mod tests { let envelope = EncryptionEnvelope::create(&ack, Some(&setup.key), &did_doc).unwrap(); - let message_1 = EncryptionEnvelope::open(&key_1, envelope.0).unwrap(); + let message_1 = EncryptionEnvelope::open(envelope.0).unwrap(); let message_1 = match message_1 { A2AMessage::Forward(forward) => { @@ -138,7 +138,7 @@ pub mod tests { _ => return assert!(false) }; - let message_2 = EncryptionEnvelope::open(&key_2, message_1).unwrap(); + let message_2 = EncryptionEnvelope::open(message_1).unwrap(); let message_2 = match message_2 { A2AMessage::Forward(forward) => { @@ -148,6 +148,6 @@ pub mod tests { _ => return assert!(false) }; - assert_eq!(ack, EncryptionEnvelope::open(&_key_1(), message_2).unwrap()); + assert_eq!(ack, EncryptionEnvelope::open(message_2).unwrap()); } } \ No newline at end of file diff --git a/vcx/libvcx/tests/utils/demo.rs b/vcx/libvcx/tests/utils/demo.rs index 5518ee950f..096dda8168 100644 --- a/vcx/libvcx/tests/utils/demo.rs +++ b/vcx/libvcx/tests/utils/demo.rs @@ -1,5 +1,4 @@ extern crate vcx; -extern crate tempfile; extern crate libc; extern crate serde_json; @@ -98,7 +97,7 @@ pub fn deserialize_vcx_object(serialized_connection: &str,f:extern fn(u32, *cons lazy_static! { static ref CALLBACK_DESERIALIE_CONNECTION: Mutex>> = Default::default(); } - extern "C" fn callback(command_handle: u32, err: u32, connection_handle: u32) { + extern "C" fn callback(command_handle: CommandHandle, err: u32, connection_handle: u32) { let mut callbacks = CALLBACK_DESERIALIE_CONNECTION.lock().unwrap(); let mut cb = callbacks.remove(&command_handle).unwrap(); cb(err, connection_handle) @@ -125,12 +124,12 @@ pub fn deserialize_vcx_object(serialized_connection: &str,f:extern fn(u32, *cons #[allow(dead_code)] pub fn serialize_vcx_object(connection_handle: u32, f:extern fn(u32, u32, Option ) ->u32) -> u32{ - fn closure_to_serialize_connection(closure: Box) -> - (u32, Option) { + fn closure_to_serialize_connection(closure: Box) -> + (u32, Option) { lazy_static! { static ref CALLBACKS_SERIALIZE_CONNECTION: Mutex>> = Default::default(); } - extern "C" fn callback(command_handle: u32, err: u32, credential_string: *const c_char) { + extern "C" fn callback(command_handle: CommandHandle, err: u32, credential_string: *const c_char) { let mut callbacks = CALLBACKS_SERIALIZE_CONNECTION.lock().unwrap(); let mut cb = callbacks.remove(&command_handle).unwrap(); assert_eq!(err, 0); @@ -167,7 +166,7 @@ pub fn invite_details_vcx_object(connection_handle: u32, f:extern fn(u32, u32, b lazy_static! { static ref CALLBACKS_SERIALIZE_CONNECTION: Mutex>> = Default::default(); } - extern "C" fn callback(command_handle: u32, err: u32, details: *const c_char) { + extern "C" fn callback(command_handle: CommandHandle, err: u32, details: *const c_char) { let mut callbacks = CALLBACKS_SERIALIZE_CONNECTION.lock().unwrap(); let mut cb = callbacks.remove(&command_handle).unwrap(); assert_eq!(err, 0); @@ -216,14 +215,14 @@ pub fn wait_for_updated_state(handle: u32, target_state:u32, f: extern fn(u32, u pub fn closure_to_create_connection_cb(closure: Box) -> (u32, Option) { lazy_static! { static ref CALLBACKS_CREATE_CONNECTION: Mutex>> = Default::default(); } - extern "C" fn callback(command_handle: u32, err: u32, connection_handle: u32) { + extern "C" fn callback(command_handle: CommandHandle, err: u32, connection_handle: u32) { let mut callbacks = CALLBACKS_CREATE_CONNECTION.lock().unwrap(); let mut cb = callbacks.remove(&command_handle).unwrap(); cb(err, connection_handle) @@ -239,7 +238,7 @@ pub fn closure_to_create_connection_cb(closure: Box) #[allow(dead_code)] pub fn closure_to_connect_cb(closure: Box) -> (u32, Option) { lazy_static! { @@ -247,7 +246,7 @@ pub fn closure_to_connect_cb(closure: Box) -> (u32, } // this is the only difference between the two closure converters #[allow(unused_variables)] - extern "C" fn callback(command_handle: u32, err: u32, details: *const c_char) { + extern "C" fn callback(command_handle: CommandHandle, err: u32, details: *const c_char) { let mut callbacks = CALLBACKS.lock().unwrap(); let mut cb = callbacks.remove(&command_handle).unwrap(); cb(err) @@ -264,13 +263,13 @@ pub fn closure_to_connect_cb(closure: Box) -> (u32, pub fn closure_to_update_state(closure: Box) -> (u32, Option) { lazy_static! { static ref CALLBACKS_GET_STATE: Mutex>> = Default::default(); } #[allow(unused_variables)] - extern "C" fn callback(command_handle: u32, err: u32, state: u32) { + extern "C" fn callback(command_handle: CommandHandle, err: u32, state: u32) { let mut callbacks = CALLBACKS_GET_STATE.lock().unwrap(); let mut cb = callbacks.remove(&command_handle).unwrap(); cb(state) @@ -288,7 +287,7 @@ pub fn closure_to_create_credential(closure: Box) -> (u32, Option) { lazy_static! { static ref CALLBACKS_CREATE_CREDENTIAL: Mutex>> = Default::default(); } - extern "C" fn callback(command_handle: u32, err: u32, credential_handle: u32) { + extern "C" fn callback(command_handle: CommandHandle, err: u32, credential_handle: u32) { let mut callbacks = CALLBACKS_CREATE_CREDENTIAL.lock().unwrap(); let mut cb = callbacks.remove(&command_handle).unwrap(); cb(err, credential_handle) @@ -306,7 +305,7 @@ pub fn closure_to_create_credentialdef(closure: Box) (u32, Option) { lazy_static! { static ref CALLBACKS_CREATE_CREDENTIALDEF: Mutex>> = Default::default(); } - extern "C" fn callback(command_handle: u32, err: u32, credentialdef_handle: u32) { + extern "C" fn callback(command_handle: CommandHandle, err: u32, credentialdef_handle: u32) { let mut callbacks = CALLBACKS_CREATE_CREDENTIALDEF.lock().unwrap(); let mut cb = callbacks.remove(&command_handle).unwrap(); cb(err, credentialdef_handle) @@ -323,7 +322,7 @@ pub fn closure_to_create_credentialdef(closure: Box) pub fn closure_to_send_credential_object(closure: Box) -> (u32, Option) { lazy_static! { static ref CALLBACKS_SEND_CREDENTIAL: Mutex>> = Default::default(); } - extern "C" fn callback(command_handle: u32, err: u32) { + extern "C" fn callback(command_handle: CommandHandle, err: u32) { let mut callbacks = CALLBACKS_SEND_CREDENTIAL.lock().unwrap(); let mut cb = callbacks.remove(&command_handle).unwrap(); cb(err) @@ -373,7 +372,7 @@ pub fn get_proof(proof_handle: u32, connection_handle: u32) -> u32 { lazy_static! { static ref CALLBACK_GET_PROOF: Mutex>> = Default::default(); } - extern "C" fn callback(command_handle: u32, err: u32, proof_state: u32, proof_str: *const c_char) { + extern "C" fn callback(command_handle: CommandHandle, err: u32, proof_state: u32, proof_str: *const c_char) { let mut callbacks = CALLBACK_GET_PROOF.lock().unwrap(); let mut cb = callbacks.remove(&command_handle).unwrap(); diff --git a/vcx/wrappers/ios/vcx/ConnectMeVcx.h b/vcx/wrappers/ios/vcx/ConnectMeVcx.h index 500edb24e5..82b388c5f5 100644 --- a/vcx/wrappers/ios/vcx/ConnectMeVcx.h +++ b/vcx/wrappers/ios/vcx/ConnectMeVcx.h @@ -98,6 +98,11 @@ extern void VcxWrapperCommonNumberStringCallback(vcx_command_handle_t xcommand_h - (void)deleteConnection:(VcxHandle)connectionHandle withCompletion:(void (^)(NSError *error))completion; +- (void)connectionSendMessage:(VcxHandle)connectionHandle + withMessage:(NSString *)message + withSendMessageOptions:(NSString *)sendMessageOptions + withCompletion:(void (^)(NSError *error, NSString *msg_id))completion; + - (void)connectionSignData:(VcxHandle)connectionHandle data:(NSData *)data completion:(void (^)(NSError *, NSData *signature))completion; diff --git a/vcx/wrappers/ios/vcx/ConnectMeVcx.m b/vcx/wrappers/ios/vcx/ConnectMeVcx.m index bfc1f48667..0b325cc1bc 100644 --- a/vcx/wrappers/ios/vcx/ConnectMeVcx.m +++ b/vcx/wrappers/ios/vcx/ConnectMeVcx.m @@ -436,6 +436,28 @@ - (void)deleteConnection:(VcxHandle)connectionHandle } } +- (void)connectionSendMessage:(VcxHandle)connectionHandle + withMessage:(NSString *)message + withSendMessageOptions:(NSString *)sendMessageOptions + withCompletion:(void (^)(NSError *error, NSString *msg_id))completion +{ + vcx_command_handle_t handle= [[VcxCallbacks sharedInstance] createCommandHandleFor:completion]; + const char *message_ctype = [message cStringUsingEncoding:NSUTF8StringEncoding]; + const char *sendMessageOptions_ctype = [sendMessageOptions cStringUsingEncoding:NSUTF8StringEncoding]; + vcx_error_t ret = vcx_connection_send_message(handle, + connectionHandle, + message_ctype, + sendMessageOptions_ctype, + VcxWrapperCommonStringCallback); + if (ret != 0) + { + [[VcxCallbacks sharedInstance] deleteCommandHandleFor:handle]; + dispatch_async(dispatch_get_main_queue(), ^{ + completion([NSError errorFromVcxError: ret], nil); + }); + } +} + - (void)connectionSignData:(VcxHandle)connectionHandle data:(NSData *)data completion:(void (^)(NSError *, NSData *signature))completion diff --git a/vcx/wrappers/ios/vcx/include/libvcx.h b/vcx/wrappers/ios/vcx/include/libvcx.h index 8c7b0d5fff..f086f5906d 100644 --- a/vcx/wrappers/ios/vcx/include/libvcx.h +++ b/vcx/wrappers/ios/vcx/include/libvcx.h @@ -69,6 +69,8 @@ vcx_error_t vcx_update_agent_info(vcx_command_handle_t handle, const char *info, const char *vcx_error_c_message(int); const char *vcx_version(); +vcx_error_t vcx_get_current_error(const char ** error_json_p); + /** * Schema object * @@ -149,6 +151,35 @@ vcx_error_t vcx_connection_create_with_invite(vcx_command_handle_t command_handl /** Deletes a connection, send an API call to agency to stop sending messages from this connection */ vcx_error_t vcx_connection_delete_connection(vcx_command_handle_t command_handle, vcx_connection_handle_t connection_handle, void (*cb)(vcx_command_handle_t, vcx_error_t err)); +/** Send a message to the specified connection +/// +/// #params +/// +/// command_handle: command handle to map callback to user context. +/// +/// connection_handle: connection to receive the message +/// +/// msg: actual message to send +/// +/// send_message_options: config options json string that contains following options +/// { +/// msg_type: String, // type of message to send +/// msg_title: String, // message title (user notification) +/// ref_msg_id: Option, // If responding to a message, id of the message +/// } +/// +/// +/// cb: Callback that provides array of matching messages retrieved +/// +/// #Returns +/// Error code as a u32 + */ +vcx_error_t vcx_connection_send_message(vcx_command_handle_t command_handle, + vcx_connection_handle_t connection_handle, + const char *msg, + const char *send_message_options, + void (*cb)(vcx_command_handle_t xcommand_handle, vcx_error_t err, const char *msg_id)); + /** Generate a signature for the specified data */ vcx_error_t vcx_connection_sign_data(vcx_command_handle_t command_handle, vcx_connection_handle_t connection_handle, uint8_t const* data_raw, unsigned int data_len, void (*cb)(vcx_command_handle_t, vcx_error_t err, uint8_t const* signature_raw, unsigned int signature_len)); diff --git a/vcx/wrappers/ios/vcx/utils/NSError+VcxError.m b/vcx/wrappers/ios/vcx/utils/NSError+VcxError.m index 9c41e81da4..2a88f0f13c 100644 --- a/vcx/wrappers/ios/vcx/utils/NSError+VcxError.m +++ b/vcx/wrappers/ios/vcx/utils/NSError+VcxError.m @@ -15,11 +15,14 @@ + (NSError*) errorFromVcxError:(vcx_error_t) error { NSMutableDictionary *userInfo = [NSMutableDictionary new]; - if (error != Success) { + if (error != 0) { const char * error_json_p; vcx_get_current_error(&error_json_p); - NSString *errorDetailsJson = [NSString stringWithUTF8String:error_json_p]; + NSString *errorDetailsJson = nil; + if (error_json_p) { + errorDetailsJson = [NSString stringWithUTF8String:error_json_p]; + } NSError *error; NSDictionary *errorDetails = [NSJSONSerialization JSONObjectWithData:[NSData dataWithBytes:[errorDetailsJson UTF8String] @@ -27,7 +30,7 @@ + (NSError*) errorFromVcxError:(vcx_error_t) error options:kNilOptions error: &error]; - [userInfo setValue:errorDetails[@"error"] forKey:@"sdk_message"]; + [userInfo setValue:errorDetails[@"error"] forKey:@"sdk_message"]; [userInfo setValue:errorDetails[@"message"] forKey:@"sdk_full_message"]; [userInfo setValue:errorDetails[@"cause"] forKey:@"sdk_cause"]; [userInfo setValue:errorDetails[@"backtrace"] forKey:@"sdk_backtrace"]; @@ -36,4 +39,4 @@ + (NSError*) errorFromVcxError:(vcx_error_t) error return [NSError errorWithDomain:VcxErrorDomain code: error userInfo:userInfo]; } -@end +@end \ No newline at end of file diff --git a/vcx/wrappers/java/build.gradle b/vcx/wrappers/java/build.gradle index 0a5114b6df..9d9b415a5c 100755 --- a/vcx/wrappers/java/build.gradle +++ b/vcx/wrappers/java/build.gradle @@ -5,7 +5,7 @@ group = 'com.evernym.sdk' repositories { - maven { url "http://repo.maven.apache.org/maven2" } + maven { url "https://repo.maven.apache.org/maven2" } maven { url "https://maven.google.com" } @@ -25,7 +25,7 @@ test { } static def versionMajor() { - return '0.6.1' + return '0.6.2' } static def version() { diff --git a/vcx/wrappers/node/package.json b/vcx/wrappers/node/package.json index c475ebfc70..40ef2ef3bd 100644 --- a/vcx/wrappers/node/package.json +++ b/vcx/wrappers/node/package.json @@ -25,7 +25,7 @@ "url": "git+https://github.com/evernym/vcx.git", "type": "git" }, - "version": "0.6.1", + "version": "0.6.2", "dependencies": { "@types/ffi": "0.0.19", "@types/node": "^8.0.47", diff --git a/vcx/wrappers/node/src/api/connection.ts b/vcx/wrappers/node/src/api/connection.ts index 19ef6206c9..3106f7a79e 100644 --- a/vcx/wrappers/node/src/api/connection.ts +++ b/vcx/wrappers/node/src/api/connection.ts @@ -6,6 +6,124 @@ import { createFFICallbackPromise } from '../utils/ffi-helpers' import { ISerializedData, StateType } from './common' import { VCXBaseWithState } from './vcx-base-with-state' +/** + * The object of the VCX API representing a pairwise relationship with another identity owner. + * Once the relationship, or connection, is established communication can happen securely and privately. + * Credentials and Proofs are exchanged using this object. + * + * # States + * + * The set of object states and transitions depends on communication method is used. + * The communication method can be specified as config option on one of *_init function. The default communication method us `proprietary`. + * + * proprietary: + * Inviter: + * VcxStateType::VcxStateInitialized - once `vcx_connection_create` (create Connection object) is called. + * + * VcxStateType::VcxStateOfferSent - once `vcx_connection_connect` (send Connection invite) is called. + * + * VcxStateType::VcxStateAccepted - once `connReqAnswer` messages is received. + * use `vcx_connection_update_state` or `vcx_connection_update_state_with_message` functions for state updates. + * VcxStateType::VcxStateNone - once `vcx_connection_delete_connection` (delete Connection object) is called. + * + * Invitee: + * VcxStateType::VcxStateRequestReceived - once `vcx_connection_create_with_invite` (create Connection object with invite) is called. + * + * VcxStateType::VcxStateAccepted - once `vcx_connection_connect` (accept Connection invite) is called. + * + * VcxStateType::VcxStateNone - once `vcx_connection_delete_connection` (delete Connection object) is called. + * + * aries: + * Inviter: + * VcxStateType::VcxStateInitialized - once `vcx_connection_create` (create Connection object) is called. + * + * VcxStateType::VcxStateOfferSent - once `vcx_connection_connect` (prepared Connection invite) is called. + * + * VcxStateType::VcxStateRequestReceived - once `ConnectionRequest` messages is received. + * accept `ConnectionRequest` and send `ConnectionResponse` message. + * use `vcx_connection_update_state` or `vcx_connection_update_state_with_message` functions for state updates. + * + * VcxStateType::VcxStateAccepted - once `Ack` messages is received. + * use `vcx_connection_update_state` or `vcx_connection_update_state_with_message` functions for state updates. + * + * VcxStateType::VcxStateNone - once `vcx_connection_delete_connection` (delete Connection object) is called + * OR + * `ConnectionProblemReport` messages is received on state updates. + * + * Invitee: + * VcxStateType::VcxStateOfferSent - once `vcx_connection_create_with_invite` (create Connection object with invite) is called. + * + * VcxStateType::VcxStateRequestReceived - once `vcx_connection_connect` (accept `ConnectionInvite` and send `ConnectionRequest` message) is called. + * + * VcxStateType::VcxStateAccepted - once `ConnectionResponse` messages is received. + * send `Ack` message if requested. + * use `vcx_connection_update_state` or `vcx_connection_update_state_with_message` functions for state updates. + * + * VcxStateType::VcxStateNone - once `vcx_connection_delete_connection` (delete Connection object) is called + * OR + * `ConnectionProblemReport` messages is received on state updates. + * + * # Transitions + * + * proprietary: + * Inviter: + * VcxStateType::None - `vcx_connection_create` - VcxStateType::VcxStateInitialized + * VcxStateType::VcxStateInitialized - `vcx_connection_connect` - VcxStateType::VcxStateOfferSent + * VcxStateType::VcxStateOfferSent - received `connReqAnswer` - VcxStateType::VcxStateAccepted + * any state - `vcx_connection_delete_connection` - `VcxStateType::VcxStateNone` + * + * Invitee: + * VcxStateType::None - `vcx_connection_create_with_invite` - VcxStateType::VcxStateRequestReceived + * VcxStateType::VcxStateRequestReceived - `vcx_connection_connect` - VcxStateType::VcxStateAccepted + * any state - `vcx_connection_delete_connection` - `VcxStateType::VcxStateNone` + * + * aries - RFC: https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential + * Inviter: + * VcxStateType::None - `vcx_connection_create` - VcxStateType::VcxStateInitialized + * + * VcxStateType::VcxStateInitialized - `vcx_connection_connect` - VcxStateType::VcxStateOfferSent + * + * VcxStateType::VcxStateOfferSent - received `ConnectionRequest` - VcxStateType::VcxStateRequestReceived + * VcxStateType::VcxStateOfferSent - received `ConnectionProblemReport` - VcxStateType::VcxStateNone + * + * VcxStateType::VcxStateRequestReceived - received `Ack` - VcxStateType::VcxStateAccepted + * VcxStateType::VcxStateRequestReceived - received `ConnectionProblemReport` - VcxStateType::VcxStateNone + * + * VcxStateType::VcxStateAccepted - received `Ping`, `PingResponse`, `Query`, `Disclose` - VcxStateType::VcxStateAccepted + * + * any state - `vcx_connection_delete_connection` - VcxStateType::VcxStateNone + * + * Invitee: + * VcxStateType::None - `vcx_connection_create_with_invite` - VcxStateType::VcxStateOfferSent + * + * VcxStateType::VcxStateOfferSent - `vcx_connection_connect` - VcxStateType::VcxStateRequestReceived + * VcxStateType::VcxStateOfferSent - received `ConnectionProblemReport` - VcxStateType::VcxStateNone + * + * VcxStateType::VcxStateRequestReceived - received `ConnectionResponse` - VcxStateType::VcxStateAccepted + * VcxStateType::VcxStateRequestReceived - received `ConnectionProblemReport` - VcxStateType::VcxStateNone + * + * VcxStateType::VcxStateAccepted - received `Ping`, `PingResponse`, `Query`, `Disclose` - VcxStateType::VcxStateAccepted + * + * any state - `vcx_connection_delete_connection` - VcxStateType::VcxStateNone + * + * # Messages + * + * proprietary: + * ConnectionRequest (`connReq`) + * ConnectionRequestAnswer (`connReqAnswer`) + * + * aries: + * Invitation - https://github.com/hyperledger/aries-rfcs/tree/master/features/0160-connection-protocol#0-invitation-to-connect + * ConnectionRequest - https://github.com/hyperledger/aries-rfcs/tree/master/features/0160-connection-protocol#1-connection-request + * ConnectionResponse - https://github.com/hyperledger/aries-rfcs/tree/master/features/0160-connection-protocol#2-connection-response + * ConnectionProblemReport - https://github.com/hyperledger/aries-rfcs/tree/master/features/0160-connection-protocol#error-message-example + * Ack - https://github.com/hyperledger/aries-rfcs/tree/master/features/0015-acks#explicit-acks + * Ping - https://github.com/hyperledger/aries-rfcs/tree/master/features/0048-trust-ping#messages + * PingResponse - https://github.com/hyperledger/aries-rfcs/tree/master/features/0048-trust-ping#messages + * Query - https://github.com/hyperledger/aries-rfcs/tree/master/features/0031-discover-features#query-message-type + * Disclose - https://github.com/hyperledger/aries-rfcs/tree/master/features/0031-discover-features#disclose-message-type + */ + /** * @description Interface that represents the attributes of a Connection object. * This data is expected as the type for deserialize's parameter and serialize's return value @@ -24,29 +142,59 @@ export interface IConnectionData { state: StateType } +/** + * @description Interface that represents the parameters for `Connection.create` function. + * @interface + */ export interface IConnectionCreateData { + // Institution's personal identification for the connection id: string } +// A string representing a invitation json object. export type IConnectionInvite = string +/** + * @description Interface that represents the parameters for `Connection.createWithInvite` function. + * @interface + */ export interface IRecipientInviteInfo extends IConnectionCreateData { + // Invitation provided by an entity that wishes to make a connection. invite: IConnectionInvite } +/** + * @description Interface that represents the parameters for `Connection.connect` function. + * @interface + */ export interface IConnectOptions { + // Provides details indicating if the connection will be established by text or QR Code data: string } +/** + * @description Interface that represents the parameters for `Connection.sendMessage` function. + * @interface + */ export interface IMessageData { + // Actual message to send msg: string, + // Type of message to send. Can be any string type: string, + // Message title (user notification) title: string, + // If responding to a message, id of the message refMsgId?: string, } +/** + * @description Interface that represents the parameters for `Connection.verifySignature` function. + * @interface + */ export interface ISignatureData { + // Message was signed data: Buffer, + // Generated signature signature: Buffer } @@ -130,6 +278,7 @@ export class Connection extends VCXBaseWithState { /** * Delete the object from the agency and release any memory associated with it + * NOTE: This eliminates the connection and any ability to use it for any communication. * * Example: * ``` @@ -245,7 +394,7 @@ export class Connection extends VCXBaseWithState { } } /** - * Sign data using pairwise key. + * Sign data using connection pairwise key. * * Example: * ``` @@ -284,7 +433,7 @@ export class Connection extends VCXBaseWithState { } } /** - * Verify the signature of the data using pairwise key. + * Verify the signature of the data using connection pairwise key. * * Example: * ``` @@ -320,14 +469,14 @@ export class Connection extends VCXBaseWithState { } /** - * Gets the details of the invitation that was returned from the Agent Service. + * Get the invite details that were sent or can be sent to the remote side. * * Example: * ``` * phoneNumber = '8019119191' * connection = await Connection.create('foobar123') * inviteDetails = await connection.connect({phone: phoneNumber}) - * inivteDetailsAgain = await connection.inviteDetails() + * inviteDetailsAgain = await connection.inviteDetails() * ``` */ public async inviteDetails (abbr: boolean = false): Promise { diff --git a/vcx/wrappers/node/src/api/credential-def.ts b/vcx/wrappers/node/src/api/credential-def.ts index b949ed5bbf..f40705a23c 100644 --- a/vcx/wrappers/node/src/api/credential-def.ts +++ b/vcx/wrappers/node/src/api/credential-def.ts @@ -7,12 +7,16 @@ import { VCXBase } from './vcx-base' import { PaymentManager } from './vcx-payment-txn' /** - * @interface + * @interface Interface that represents the parameters for `CredentialDef.create` function. * @description - * SourceId: String for SDK User's reference. - * name: name of credentialdef. - * schemaNo: Schema Number wanted to create credentialdef off of - * revocation: + * SourceId: Enterprise's personal identification for the user. + * name: Name of credential definition + * schemaId: The schema id given during the creation of the schema + * revocation: type-specific configuration of credential definition revocation + * TODO: Currently supports ISSUANCE BY DEFAULT, support for ISSUANCE ON DEMAND will be added as part of ticket: IS-1074 + * support_revocation: true|false - Optional, by default its false + * tails_file: path to tails file - Optional if support_revocation is false + * max_creds: size of tails file - Optional if support_revocation is false */ export interface ICredentialDefCreateData { sourceId: string, @@ -22,6 +26,19 @@ export interface ICredentialDefCreateData { paymentHandle: number } +/** + * @interface Interface that represents the parameters for `CredentialDef.prepareForEndorser` function. + * @description + * SourceId: Enterprise's personal identification for the user. + * name: Name of credential definition + * schemaId: The schema id given during the creation of the schema + * revocation: type-specific configuration of credential definition revocation + * TODO: Currently supports ISSUANCE BY DEFAULT, support for ISSUANCE ON DEMAND will be added as part of ticket: IS-1074 + * support_revocation: true|false - Optional, by default its false + * tails_file: path to tails file - Optional if support_revocation is false + * max_creds: size of tails file - Optional if support_revocation is false + * endorser: DID of the Endorser that will submit the transaction. + */ export interface ICredentialDefPrepareForEndorserData { sourceId: string, name: string, @@ -122,7 +139,9 @@ export class CredentialDef extends VCXBase { } /** - * Builds a generic Schema object that will be published by Endorser later + * Create a new CredentialDef object that will be published by Endorser later. + * + * Note that CredentialDef can't be used for credential issuing until it will be published on the ledger. * * Example: * ``` @@ -289,7 +308,7 @@ export class CredentialDef extends VCXBase { /** * - * Checks if credential definition is published on the Ledger and updates the the state + * Checks if credential definition is published on the Ledger and updates the state * * Example: * ``` diff --git a/vcx/wrappers/node/src/api/credential.ts b/vcx/wrappers/node/src/api/credential.ts index cb703d2fcf..dcd44b6e65 100644 --- a/vcx/wrappers/node/src/api/credential.ts +++ b/vcx/wrappers/node/src/api/credential.ts @@ -8,27 +8,105 @@ import { Connection } from './connection' import { VCXBaseWithState } from './vcx-base-with-state' import { PaymentManager } from './vcx-payment-txn' +/** + * The object of the VCX API representing a Holder side in the credential issuance process. + * Assumes that pairwise connection between Issuer and Holder is already established. + * + * # State + * + * The set of object states and transitions depends on communication method is used. + * The communication method can be specified as config option on one of *_init function. The default communication method us `proprietary`. + * + * proprietary: + * VcxStateType::VcxStateRequestReceived - once `vcx_credential_create_with_offer` (create Credential object) is called. + * + * VcxStateType::VcxStateOfferSent - once `vcx_credential_send_request` (send `CRED_REQ` message) is called. + * + * VcxStateType::VcxStateAccepted - once `CRED` messages is received. + * use `vcx_credential_update_state` or `vcx_credential_update_state_with_message` functions for state updates. + * + * aries: + * VcxStateType::VcxStateRequestReceived - once `vcx_credential_create_with_offer` (create Credential object) is called. + * + * VcxStateType::VcxStateOfferSent - once `vcx_credential_send_request` (send `CredentialRequest` message) is called. + * + * VcxStateType::VcxStateAccepted - once `Credential` messages is received. + * VcxStateType::None - once `ProblemReport` messages is received. + * use `vcx_credential_update_state` or `vcx_credential_update_state_with_message` functions for state updates. + * + * # Transitions + * + * proprietary: + * VcxStateType::None - `vcx_credential_create_with_offer` - VcxStateType::VcxStateRequestReceived + * + * VcxStateType::VcxStateRequestReceived - `vcx_credential_send_request` - VcxStateType::VcxStateOfferSent + * + * VcxStateType::VcxStateOfferSent - received `CRED` - VcxStateType::VcxStateAccepted + * + * aries: RFC - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential + * VcxStateType::None - `vcx_credential_create_with_offer` - VcxStateType::VcxStateRequestReceived + * + * VcxStateType::VcxStateRequestReceived - `vcx_issuer_send_credential_offer` - VcxStateType::VcxStateOfferSent + * + * VcxStateType::VcxStateOfferSent - received `Credential` - VcxStateType::VcxStateAccepted + * VcxStateType::VcxStateOfferSent - received `ProblemReport` - VcxStateType::None + * + * # Messages + * + * proprietary: + * CredentialOffer (`CRED_OFFER`) + * CredentialRequest (`CRED_REQ`) + * Credential (`CRED`) + * + * aries: + * CredentialProposal - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential#propose-credential + * CredentialOffer - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential#offer-credential + * CredentialRequest - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential#request-credential + * Credential - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential#issue-credential + * ProblemReport - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0035-report-problem#the-problem-report-message-type + * Ack - https://github.com/hyperledger/aries-rfcs/tree/master/features/0015-acks#explicit-acks + */ + export interface ICredentialStructData { source_id: string, } export type ICredentialOffer = [ object, object ] +/** + * @description Interface that represents the parameters for `Credential.create` function. + * @interface + */ export interface ICredentialCreateWithOffer { + // Institution's personal identification for the credential, should be unique. sourceId: string, + // Credential offer received via "getOffers" offer: string, // We're going to need it in the future connection: Connection } +/** + * @description Interface that represents the parameters for `Credential.createWithMsgId` function. + * @interface + */ export interface ICredentialCreateWithMsgId { + // Institution's personal identification for the credential, should be unique. sourceId: string, + // Id of the message that contains the credential offer msgId: string, + // Connection to query for credential offer connection: Connection } +/** + * @description Interface that represents the parameters for `Credential.sendRequest` function. + * @interface + */ export interface ICredentialSendData { + // Connection to send credential request connection: Connection, + // Fee amount payment: number } @@ -98,7 +176,7 @@ export class Credential extends VCXBaseWithState { } /** - * Create a Credential object that requests and receives a credential for an institution + * Create a Credential object based off of a known message id for a given connection. * * ``` * credential = Credential.createWithMsgId({ @@ -227,7 +305,7 @@ export class Credential extends VCXBaseWithState { } } /** - * Gets the credential request message for sending to the specifed connection. + * Gets the credential request message for sending to the specified connection. * * ``` * connection = await Connection.create({id: 'foobar'}) diff --git a/vcx/wrappers/node/src/api/disclosed-proof.ts b/vcx/wrappers/node/src/api/disclosed-proof.ts index c50e9d1d60..db5f6288a8 100644 --- a/vcx/wrappers/node/src/api/disclosed-proof.ts +++ b/vcx/wrappers/node/src/api/disclosed-proof.ts @@ -7,25 +7,103 @@ import { ISerializedData } from './common' import { Connection } from './connection' import { VCXBaseWithState } from './vcx-base-with-state' +/** + * The API represents an Prover side in the credential presentation process. + * Assumes that pairwise connection between Verifier and Prover is already established. + * + * # State + * + * The set of object states and transitions depends on communication method is used. + * The communication method can be specified as config option on one of *_init function. The default communication method us `proprietary`. + * + * proprietary: + * VcxStateType::VcxStateRequestReceived - once `vcx_disclosed_proof_create_with_request` (create DisclosedProof object) is called. + * + * VcxStateType::VcxStateRequestReceived - once `vcx_disclosed_proof_generate_proof` is called. + * + * VcxStateType::VcxStateAccepted - once `vcx_disclosed_proof_send_proof` (send `PROOF_REQ` message) is called. + * + * aries: + * VcxStateType::VcxStateRequestReceived - once `vcx_disclosed_proof_create_with_request` (create DisclosedProof object) is called. + * + * VcxStateType::VcxStateRequestReceived - once `vcx_disclosed_proof_generate_proof` is called. + * + * VcxStateType::VcxStateOfferSent - once `vcx_disclosed_proof_send_proof` (send `Presentation` message) is called. + * VcxStateType::None - once `vcx_disclosed_proof_decline_presentation_request` (send `PresentationReject` or `PresentationProposal` message) is called. + * + * VcxStateType::VcxStateAccepted - once `Ack` messages is received. + * VcxStateType::None - once `ProblemReport` messages is received. + * + * # Transitions + * + * proprietary: + * VcxStateType::None - `vcx_disclosed_proof_create_with_request` - VcxStateType::VcxStateRequestReceived + * + * VcxStateType::VcxStateRequestReceived - `vcx_disclosed_proof_generate_proof` - VcxStateType::VcxStateRequestReceived + * + * VcxStateType::VcxStateRequestReceived - `vcx_disclosed_proof_send_proof` - VcxStateType::VcxStateAccepted + * + * aries: RFC - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0037-present-proof#propose-presentation + * VcxStateType::None - `vcx_disclosed_proof_create_with_request` - VcxStateType::VcxStateRequestReceived + * + * VcxStateType::VcxStateRequestReceived - `vcx_disclosed_proof_generate_proof` - VcxStateType::VcxStateRequestReceived + * + * VcxStateType::VcxStateRequestReceived - `vcx_disclosed_proof_send_proof` - VcxStateType::VcxStateAccepted + * VcxStateType::VcxStateRequestReceived - `vcx_disclosed_proof_decline_presentation_request` - VcxStateType::None + * + * VcxStateType::VcxStateOfferSent - received `Ack` - VcxStateType::VcxStateAccepted + * VcxStateType::VcxStateOfferSent - received `ProblemReport` - VcxStateType::None + * + * # Messages + * + * proprietary: + * ProofRequest (`PROOF_REQ`) + * Proof (`PROOF`) + * + * aries: + * PresentationRequest - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0037-present-proof#request-presentation + * Presentation - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0037-present-proof#presentation + * PresentationProposal - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0037-present-proof#propose-presentation + * Ack - https://github.com/hyperledger/aries-rfcs/tree/master/features/0015-acks#explicit-acks + */ + export interface IDisclosedProofData { source_id: string, } export type IDisclosedProofRequest = object +/** + * @description Interface that represents the parameters for `DisclosedProof.create` function. + * @interface + */ export interface IDisclosedProofCreateData { // We're going to need it in the future connection: Connection, + // Institution's identification for the proof, should be unique. sourceId: string, + // Proof request received via "getRequests" request: string } +/** + * @description Interface that represents the parameters for `DisclosedProof.createWithMsgId` function. + * @interface + */ export interface IDisclosedProofCreateWithMsgIdData { + // Connection to query for proof request connection: Connection, + // Id of the message that contains the proof request msgId: string, + // Institution's personal identification for the proof, should be unique. sourceId: string } +/** + * @description Interface that represents the result of `DisclosedProof.getCredentials` function. + * @interface + * example: {'attrs': {'attribute_0': [{'cred_info': {'schema_id': 'id', 'cred_def_id': 'id', 'attrs': {'attr_name': 'attr_value', ...}, 'referent': '914c7e11'}}]}} + */ export interface IRetrievedCreds { attrs: { [ index: string ]: ICredData[] @@ -40,6 +118,11 @@ export interface ICredData { interval: any } +/** + * @description Interface that represents the parameters for `DisclosedProof.generateProof` function. + * @interface + * example: {'attrs': {'attribute_0': {'credential': {'cred_info': {'cred_def_id': 'od', 'schema_id': 'id', 'referent': '0c212108-9433-4199-a21f-336a44164f38', 'attrs': {'attr_name': 'attr_value', ...}}}}}} + */ export interface IGenerateProofData { selectedCreds: { [index: string]: ICredData @@ -49,9 +132,16 @@ export interface IGenerateProofData { } } +/** + * @description Interface that represents the parameters for `DisclosedProof.declinePresentationRequest` function. + * @interface + */ export interface IDeclinePresentationRequestData { + // Connection to decline presentation request connection: Connection, + // Human-readable string that explain the reason of decline reason?: string, + // The proposed format of presentation request proposal?: any } @@ -111,7 +201,7 @@ export class DisclosedProof extends VCXBaseWithState { } /** - * Create a proof for fulfilling a corresponding proof request with MsgId from Agency Service + * Create a proof based off of a known message id for a given connection. * * Example: * ``` @@ -150,7 +240,8 @@ export class DisclosedProof extends VCXBaseWithState { } } /** - * Serializes the object + * Builds a proof object with defined attributes. + * Attributes are provided by a previous call to the serialize function. * * Example: * ``` @@ -169,7 +260,8 @@ export class DisclosedProof extends VCXBaseWithState { } } /** - * Serializes the object + * Queries agency for all pending proof requests from the given connection. + * * * Example: * ``` @@ -211,7 +303,7 @@ export class DisclosedProof extends VCXBaseWithState { private _proofReq: string = '' /** - * Gets the credentials from a disclosed proof + * Get credentials from wallet matching to the proof request associated with proof object * * Example: * ``` @@ -334,7 +426,8 @@ export class DisclosedProof extends VCXBaseWithState { } } /** - * Generates the proof + * Accept proof request associated with proof object and + * generates a proof from the selected credentials and self attested attributes * * Example: * ``` diff --git a/vcx/wrappers/node/src/api/init.ts b/vcx/wrappers/node/src/api/init.ts index 993cdd9603..560de79730 100644 --- a/vcx/wrappers/node/src/api/init.ts +++ b/vcx/wrappers/node/src/api/init.ts @@ -8,6 +8,7 @@ import { IInitVCXOptions } from './common' /** * Initializes VCX with config file. * An example config file is at libvcx/sample_config/config.json + * The list of available options see here: https://github.com/hyperledger/indy-sdk/blob/master/docs/configuration.md * * Example: * ``` @@ -43,7 +44,7 @@ export async function initVcx (configPath: string, options: IInitVCXOptions = {} /** * Initializes VCX with config file. - * An example config file is at libvcx/sample_config/config.json + * The list of available options see here: https://github.com/hyperledger/indy-sdk/blob/master/docs/configuration.md * * Example: * ``` diff --git a/vcx/wrappers/node/src/api/issuer-credential.ts b/vcx/wrappers/node/src/api/issuer-credential.ts index ff098f1737..1ebb46b4e4 100644 --- a/vcx/wrappers/node/src/api/issuer-credential.ts +++ b/vcx/wrappers/node/src/api/issuer-credential.ts @@ -7,13 +7,90 @@ import { Connection } from './connection' import { VCXBaseWithState } from './vcx-base-with-state' import { PaymentManager } from './vcx-payment-txn' +/** + * The object of the VCX API representing an Issuer side in the credential issuance process. + * Assumes that pairwise connection between Issuer and Holder is already established. + * + * # State + * + * The set of object states and transitions depends on communication method is used. + * The communication method can be specified as config option on one of *_init function. The default communication method us `proprietary`. + * + * proprietary: + * VcxStateType::VcxStateInitialized - once `vcx_issuer_create_credential` (create IssuerCredential object) is called. + * + * VcxStateType::VcxStateOfferSent - once `vcx_issuer_send_credential_offer` (send `CRED_OFFER` message) is called. + * + * VcxStateType::VcxStateRequestReceived - once `CRED_REQ` messages is received. + * use `vcx_issuer_credential_update_state` or `vcx_issuer_credential_update_state_with_message` functions for state updates. + * VcxStateType::VcxStateAccepted - once `vcx_issuer_send_credential` (send `CRED` message) is called. + * + * aries: + * VcxStateType::VcxStateInitialized - once `vcx_issuer_create_credential` (create IssuerCredential object) is called. + * + * VcxStateType::VcxStateOfferSent - once `vcx_issuer_send_credential_offer` (send `CredentialOffer` message) is called. + * + * VcxStateType::VcxStateRequestReceived - once `CredentialRequest` messages is received. + * VcxStateType::None - once `ProblemReport` messages is received. + * use `vcx_issuer_credential_update_state` or `vcx_issuer_credential_update_state_with_message` functions for state updates. + * + * VcxStateType::VcxStateAccepted - once `vcx_issuer_send_credential` (send `Credential` message) is called. + * + * # Transitions + * + * proprietary: + * VcxStateType::None - `vcx_issuer_create_credential` - VcxStateType::VcxStateInitialized + * + * VcxStateType::VcxStateInitialized - `vcx_issuer_send_credential_offer` - VcxStateType::VcxStateOfferSent + * + * VcxStateType::VcxStateOfferSent - received `CRED_REQ` - VcxStateType::VcxStateRequestReceived + * + * VcxStateType::VcxStateRequestReceived - `vcx_issuer_send_credential` - VcxStateType::VcxStateAccepted + * + * aries: RFC - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential + * VcxStateType::None - `vcx_issuer_create_credential` - VcxStateType::VcxStateInitialized + * + * VcxStateType::VcxStateInitialized - `vcx_issuer_send_credential_offer` - VcxStateType::VcxStateOfferSent + * + * VcxStateType::VcxStateOfferSent - received `CredentialRequest` - VcxStateType::VcxStateRequestReceived + * VcxStateType::VcxStateOfferSent - received `ProblemReport` - VcxStateType::None + * + * VcxStateType::VcxStateRequestReceived - vcx_issuer_send_credential` - VcxStateType::VcxStateAccepted + * + * VcxStateType::VcxStateAccepted - received `Ack` - VcxStateType::VcxStateAccepted + * + * # Messages + * + * proprietary: + * CredentialOffer (`CRED_OFFER`) + * CredentialRequest (`CRED_REQ`) + * Credential (`CRED`) + * + * aries: + * CredentialProposal - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential#propose-credential + * CredentialOffer - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential#offer-credential + * CredentialRequest - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential#request-credential + * Credential - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential#issue-credential + * ProblemReport - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0035-report-problem#the-problem-report-message-type + * Ack - https://github.com/hyperledger/aries-rfcs/tree/master/features/0015-acks#explicit-acks + */ + +/** + * @description Interface that represents the parameters for `IssuerCredential.create` function. + * @interface + */ export interface IIssuerCredentialCreateData { + // Enterprise's personal identification for the user. sourceId: string, + // Handle of the correspondent credential definition object credDefHandle: number, + // Data attributes offered to person in the credential ('{"state":"UT"}') attr: { [ index: string ]: string }, + // Name of the credential - ex. Drivers Licence credentialName: string, + // price of credential price: string, } @@ -59,7 +136,8 @@ export class IssuerCredentialPaymentManager extends PaymentManager { */ export class IssuerCredential extends VCXBaseWithState { /** - * Builds a generic Issuer Credential object + * Create a Issuer Credential object that provides a credential for an enterprise's user + * Assumes a credential definition has been already written to the ledger. * ``` * issuerCredential = await IssuerCredential.create({sourceId: "12", * credDefId: "credDefId", attr: {key: "value"}, credentialName: "name", price: "0"}) diff --git a/vcx/wrappers/node/src/api/proof.ts b/vcx/wrappers/node/src/api/proof.ts index 4912a21d8b..3060fa86dc 100644 --- a/vcx/wrappers/node/src/api/proof.ts +++ b/vcx/wrappers/node/src/api/proof.ts @@ -6,15 +6,84 @@ import { ISerializedData, StateType } from './common' import { Connection } from './connection' import { VCXBaseWithState } from './vcx-base-with-state' +/** + * The object of the VCX API representing a Verifier side in the credential presentation process. + * Assumes that pairwise connection between Verifier and Prover is already established. + * + * # State + * + * The set of object states and transitions depends on communication method is used. + * The communication method can be specified as config option on one of *_init function. The default communication method us `proprietary`. + * + * proprietary: + * VcxStateType::VcxStateInitialized - once `vcx_proof_create` (create Proof object) is called. + * + * VcxStateType::VcxStateOfferSent - once `vcx_credential_send_request` (send `PROOF_REQ` message) is called. + * + * VcxStateType::VcxStateAccepted - once `PROOF` messages is received. + * use `vcx_proof_update_state` or `vcx_proof_update_state_with_message` functions for state updates. + * + * aries: + * VcxStateType::VcxStateInitialized - once `vcx_proof_create` (create Proof object) is called. + * + * VcxStateType::VcxStateOfferSent - once `vcx_credential_send_request` (send `PresentationRequest` message) is called. + * + * VcxStateType::VcxStateAccepted - once `Presentation` messages is received. + * VcxStateType::None - once `ProblemReport` messages is received. + * VcxStateType::None - once `PresentationProposal` messages is received. + * VcxStateType::None - on `Presentation` validation failed. + * use `vcx_proof_update_state` or `vcx_proof_update_state_with_message` functions for state updates. + * + * # Transitions + * + * proprietary: + * VcxStateType::None - `vcx_proof_create` - VcxStateType::VcxStateInitialized + * + * VcxStateType::VcxStateInitialized - `vcx_credential_send_request` - VcxStateType::VcxStateOfferSent + * + * VcxStateType::VcxStateOfferSent - received `PROOF` - VcxStateType::VcxStateAccepted + * + * aries: RFC - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0037-present-proof#propose-presentation + * VcxStateType::None - `vcx_proof_create` - VcxStateType::VcxStateInitialized + * + * VcxStateType::VcxStateInitialized - `vcx_credential_send_request` - VcxStateType::VcxStateOfferSent + * + * VcxStateType::VcxStateOfferSent - received `Presentation` - VcxStateType::VcxStateAccepted + * VcxStateType::VcxStateOfferSent - received `PresentationProposal` - VcxStateType::None + * VcxStateType::VcxStateOfferSent - received `ProblemReport` - VcxStateType::None + * + * # Messages + * + * proprietary: + * ProofRequest (`PROOF_REQ`) + * Proof (`PROOF`) + * + * aries: + * PresentationRequest - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0037-present-proof#request-presentation + * Presentation - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0037-present-proof#presentation + * PresentationProposal - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0037-present-proof#propose-presentation + * Ack - https://github.com/hyperledger/aries-rfcs/tree/master/features/0015-acks#explicit-acks + */ + +/** + * @description Interface that represents the parameters for `Proof.create` function. + * @interface + */ export interface IProofCreateData { + // Enterprise's personal identification for the user. sourceId: string, + // Describes requested attribute attrs: IProofAttr[], + // Name of the proof request name: string, + // Revocation interval revocationInterval: IRevocationInterval } export interface IProofConstructorData { + // Describes requested attribute attrs: IProofAttr[], + // Name of the proof request name: string, } @@ -35,7 +104,9 @@ export interface IProofData { } export interface IProofResponses { + // Proof json proof?: string, + // Proof status proofState: ProofState, } @@ -58,7 +129,9 @@ export enum PredicateTypes { * @interface */ export interface IProofAttr { + // Requested attribute restrictions restrictions?: IFilter[], + // Requested attribute name name: string, } @@ -101,7 +174,8 @@ export class Proof extends VCXBaseWithState { * data = { * attrs: [ * { name: 'attr1' }, - * { name: 'attr2' }], + * { name: 'attr2' }, + * { names: ['attr3', 'attr4'] }], * name: 'Proof', * sourceId: 'testProofSourceId', * revocationInterval: {from: 1, to: 2} diff --git a/vcx/wrappers/node/src/api/schema.ts b/vcx/wrappers/node/src/api/schema.ts index 33b25c536d..bb11583857 100644 --- a/vcx/wrappers/node/src/api/schema.ts +++ b/vcx/wrappers/node/src/api/schema.ts @@ -7,15 +7,29 @@ import { ISerializedData } from './common' import { VCXBase } from './vcx-base' import { PaymentManager } from './vcx-payment-txn' +/** + * @interface Interface that represents the parameters for `Schema.create` function. + * @description + */ export interface ISchemaCreateData { + // Enterprise's personal identification for the user. sourceId: string, + // list of attributes that will make up the schema (the number of attributes should be less or equal than 125) data: ISchemaAttrs, + // future use (currently uses any address in the wallet) paymentHandle: number } +/** + * @interface Interface that represents the parameters for `Schema.prepareForEndorser` function. + * @description + */ export interface ISchemaPrepareForEndorserData { + // Enterprise's personal identification for the user. sourceId: string, + // list of attributes that will make up the schema (the number of attributes should be less or equal than 125) data: ISchemaAttrs, + // DID of the Endorser that will submit the transaction. endorser: string } @@ -23,7 +37,7 @@ export interface ISchemaPrepareForEndorserData { * @interface * @description * name: name of schema - * version: + * version: version of the scheme * attrNames: a list of named attribtes inteded to be added to the schema * (the number of attributes should be less or equal than 125) */ @@ -77,7 +91,7 @@ export class SchemaPaymentManager extends PaymentManager { export class Schema extends VCXBase { /** - * Builds a generic Schema object + * Creates a new Schema object that is written to the ledger * * Example: * ``` @@ -116,7 +130,7 @@ export class Schema extends VCXBase { } /** - * Builds a generic Schema object that will be published by Endorser later. + * Builds a new Schema object that will be published by Endorser later. * * Example: * ``` @@ -348,7 +362,7 @@ export class Schema extends VCXBase { /** * - * Checks if schema is published on the Ledger and updates the the state + * Checks if schema is published on the Ledger and updates the state * * Example: * ``` diff --git a/vcx/wrappers/node/src/api/utils.ts b/vcx/wrappers/node/src/api/utils.ts index 84e57a7a67..68c266eb84 100644 --- a/vcx/wrappers/node/src/api/utils.ts +++ b/vcx/wrappers/node/src/api/utils.ts @@ -49,6 +49,9 @@ export async function provisionAgent (configAgent: string, options: IInitVCXOpti } export async function updateAgentInfo (options: string): Promise { + /** + * Update information on the agent (ie, comm method and type) + */ try { return await createFFICallbackPromise( (resolve, reject, cb) => { @@ -140,6 +143,10 @@ export function setActiveTxnAuthorAgreementMeta (text: string | null | undefined hash: string | null | undefined, acc_mech_type: string, time_of_acceptance: number) { + /** + * Set some accepted agreement as active. + * As result of successful call of this function appropriate metadata will be appended to each write request. + */ return rustAPI().vcx_set_active_txn_author_agreement_meta(text, version, hash, acc_mech_type, time_of_acceptance) } @@ -179,6 +186,9 @@ export interface IDownloadMessagesConfigs { export async function downloadMessages ({ status, uids, pairwiseDids }: IDownloadMessagesConfigs): Promise { + /** + * Retrieve messages from the agency + */ try { return await createFFICallbackPromise( (resolve, reject, cb) => { @@ -208,6 +218,9 @@ export interface IUpdateMessagesConfigs { } export async function updateMessages ({ msgJson }: IUpdateMessagesConfigs): Promise { + /** + * Update the status of messages from the specified connection + */ try { return await createFFICallbackPromise( (resolve, reject, cb) => { @@ -237,6 +250,9 @@ export function setPoolHandle (handle: number): void { } export async function endorseTransaction (transaction: string): Promise { + /** + * Endorse transaction to the ledger preserving an original author + */ try { return await createFFICallbackPromise( (resolve, reject, cb) => { diff --git a/vcx/wrappers/python3/demo/alice.py b/vcx/wrappers/python3/demo/alice.py index 726f09d799..2bffeca436 100644 --- a/vcx/wrappers/python3/demo/alice.py +++ b/vcx/wrappers/python3/demo/alice.py @@ -2,9 +2,6 @@ import json from ctypes import cdll from time import sleep -import platform - -import logging from demo_utils import file_ext from vcx.api.connection import Connection @@ -13,6 +10,7 @@ from vcx.api.utils import vcx_agent_provision from vcx.api.vcx_init import vcx_init_with_config from vcx.state import State +from vc_auth_oidc.alice_vc_auth import handle_challenge # logging.basicConfig(level=logging.DEBUG) uncomment to get logs @@ -42,8 +40,12 @@ async def main(): config['institution_logo_url'] = 'http://robohash.org/456' config['genesis_path'] = 'docker.txn' + config = json.dumps(config) + + print('Alice config:\n ' + config) + print("#8 Initialize libvcx with new configuration") - await vcx_init_with_config(json.dumps(config)) + await vcx_init_with_config(config) print("#9 Input faber.py invitation details") details = input('invite details: ') @@ -58,10 +60,34 @@ async def main(): await connection_to_faber.update_state() connection_state = await connection_to_faber.get_state() - print("#11 Wait for faber.py to issue a credential offer") - sleep(10) - offers = await Credential.get_offers(connection_to_faber) - + print("Connection is established") + + while True: + answer = input( + "Would you like to do? \n " + "1 - check for credential offer \n " + "2 - check for proof request \n " + "3 - pass vc_auth_oidc-challenge \n " + "else finish \n") \ + .lower().strip() + if answer == '1': + print("Check agency for a credential offer") + offers = await Credential.get_offers(connection_to_faber) + await accept_offer(connection_to_faber, offers) + elif answer == '2': + print("Check agency for a proof request") + requests = await DisclosedProof.get_requests(connection_to_faber) + await create_proof(connection_to_faber, requests[0]) + elif answer == '3': + request = await handle_challenge() + await create_proof(None, request) + else: + break + + print("Finished") + + +async def accept_offer(connection_to_faber, offers): # Create a credential object from the credential offer credential = await Credential.create('credential', offers[0]) @@ -75,11 +101,10 @@ async def main(): await credential.update_state() credential_state = await credential.get_state() - print("#22 Poll agency for a proof request") - requests = await DisclosedProof.get_requests(connection_to_faber) +async def create_proof(connection_to_faber, request): print("#23 Create a Disclosed proof object from proof request") - proof = await DisclosedProof.create('proof', requests[0]) + proof = await DisclosedProof.create('proof', request) print("#24 Query for credentials in the wallet that satisfy the proof request") credentials = await proof.get_creds() @@ -93,7 +118,7 @@ async def main(): print("#25 Generate the proof") await proof.generate_proof(credentials, {}) - print("#26 Send the proof to faber") + print("#26 Send the proof") await proof.send_proof(connection_to_faber) proof_state = await proof.get_state() diff --git a/vcx/wrappers/python3/demo/demo_utils.py b/vcx/wrappers/python3/demo/demo_utils.py index b1a0ee45b6..1765ec1151 100644 --- a/vcx/wrappers/python3/demo/demo_utils.py +++ b/vcx/wrappers/python3/demo/demo_utils.py @@ -273,3 +273,8 @@ async def create_postgres_wallet(provisionConfig): if ex.error_code == ErrorCode.PoolLedgerConfigAlreadyExistsError: pass print("Postgres wallet provisioned") + + +def load_payment_library(): + payment_plugin = cdll.LoadLibrary('libnullpay' + file_ext()) + payment_plugin.nullpay_init() diff --git a/vcx/wrappers/python3/demo/faber.py b/vcx/wrappers/python3/demo/faber.py index 8b142282e6..7a070bb539 100644 --- a/vcx/wrappers/python3/demo/faber.py +++ b/vcx/wrappers/python3/demo/faber.py @@ -17,6 +17,7 @@ from vcx.api.vcx_init import vcx_init_with_config from vcx.state import State, ProofState + # logging.basicConfig(level=logging.DEBUG) uncomment to get logs # 'agency_url': URL of the agency @@ -55,13 +56,12 @@ async def main(): print("#3 Create a new schema on the ledger") version = format("%d.%d.%d" % (random.randint(1, 101), random.randint(1, 101), random.randint(1, 101))) - schema = await Schema.create('schema_uuid', 'degree schema', version, ['name', 'date', 'degree'], 0) + schema = await Schema.create('schema_uuid', 'degree schema', version, ['email', 'first_name', 'last_name'], 0) schema_id = await schema.get_schema_id() print("#4 Create a new credential definition on the ledger") cred_def = await CredentialDef.create('credef_uuid', 'degree', schema_id, 0) cred_def_handle = cred_def.handle - cred_def_id = await cred_def.get_cred_def_id() print("#5 Create a connection to alice and print out the invite details") connection_to_alice = await Connection.create('alice') @@ -79,10 +79,30 @@ async def main(): await connection_to_alice.update_state() connection_state = await connection_to_alice.get_state() + print("Connection is established") + + while True: + answer = input( + "Would you like to do? \n " + "1 - issue credential \n " + "2 - ask for proof request \n " + "else finish \n") \ + .lower().strip() + if answer == '1': + await issue_credential(connection_to_alice, cred_def_handle) + elif answer == '2': + await ask_for_proof(connection_to_alice, config['institution_did']) + else: + break + + print("Finished") + + +async def issue_credential(connection_to_alice, cred_def_handle): schema_attrs = { - 'name': 'alice', - 'date': '05-2018', - 'degree': 'maths', + 'email': 'test', + 'first_name': 'DemoName', + 'last_name': 'DemoLastName', } print("#12 Create an IssuerCredential object using the schema and credential definition") @@ -110,10 +130,12 @@ async def main(): await credential.update_state() credential_state = await credential.get_state() + +async def ask_for_proof(connection_to_alice, institution_did): proof_attrs = [ - {'name': 'name', 'restrictions': [{'issuer_did': config['institution_did']}]}, - {'name': 'date', 'restrictions': [{'issuer_did': config['institution_did']}]}, - {'name': 'degree', 'restrictions': [{'issuer_did': config['institution_did']}]} + {'name': 'email', 'restrictions': [{'issuer_did': institution_did}]}, + {'name': 'first_name', 'restrictions': [{'issuer_did': institution_did}]}, + {'name': 'last_name', 'restrictions': [{'issuer_did': institution_did}]} ] print("#19 Create a Proof object") diff --git a/vcx/wrappers/python3/demo/vc_auth_oidc/README.md b/vcx/wrappers/python3/demo/vc_auth_oidc/README.md new file mode 100644 index 0000000000..35f927f926 --- /dev/null +++ b/vcx/wrappers/python3/demo/vc_auth_oidc/README.md @@ -0,0 +1,27 @@ +# Authentication with VC-AuthN OIDC + +This is the script which shows how Vcx can be used to pass [VC-AuthN OIDC Demo](https://github.com/bcgov/vc-authn-oidc#a-quick-demo). + +## Steps to Run +1. Network - run local Pool Ledger or use any available. + * Update VCX demo genesis transactions (`demo/docker.txn` file) to point on the pool. +1. Run [VC-AuthN OIDC Demo](https://github.com/bcgov/vc-authn-oidc#a-quick-demo) environment with dependencies. + * It requires `von-network` instance to be run. + Take note that `von-network` must use the same Pool Ledger genesis transactions as VCX demo (`demo/docker.txn` file). + * `VC-AuthN OIDC Demo` troubleshooting: it may be needed to replace all usages of `localhost` on IP address of your machine. +1. Perform `VC-AuthN OIDC Demo` preparation steps: + * post Presentation Request schema + * Issue Credential for Alice: + * start Dummy Cloud Agent. + * modify `demo/faber.py` script to issue a credential with required attributes (`schema` and `schema_attrs` structures). + * run regular faber/alice demo to issue a credential for Alice. (After connection is established - choose option `1` from Faber and Alice scripts to issue a credential) + * Since credential is issued Alice is ready to pass `VC-AuthN OIDC` challenge. Keep Alice running. +1. Go to keycloaks `Login In` page and click `Verified Credential Access`. QR and URL should be showed. + * go to Alice and choose option `3`. It will ask for URL. + * proof will be automatically generated and send to VC-AuthN provider. +1. On success authentication: `Login In` page will be redirected to `Update Account Information` page. + +## Steps to pass OIDC challenge using VCX +1. Scan QR code -> send GET request to encoded URL -> take `location` header of response. +2. Take base64 string after `?m=` -> decode string -> presentation request +3. handle presentation request using VCX usual way. (`connection` object on `send_proof` function isn't required here) \ No newline at end of file diff --git a/vcx/wrappers/python3/demo/vc_auth_oidc/alice_vc_auth.py b/vcx/wrappers/python3/demo/vc_auth_oidc/alice_vc_auth.py new file mode 100644 index 0000000000..0f1ba64aa9 --- /dev/null +++ b/vcx/wrappers/python3/demo/vc_auth_oidc/alice_vc_auth.py @@ -0,0 +1,19 @@ +import json +import re +import base64 + +import requests + +async def handle_challenge(): + try: + url = input('Enter URL: ').strip() + response = requests.get(url, allow_redirects=False) + location = response.headers['location'] + + groups = re.match(".*?m=(.*)", location) + coded_proof_request = groups.group(1) + + proof_request = json.loads(base64.b64decode(coded_proof_request).decode('utf-8')) + return proof_request + except Exception as err: + print("Error occurred during getting Presentation Request: " + str(err)) diff --git a/vcx/wrappers/python3/setup.py b/vcx/wrappers/python3/setup.py index 4d39f868f8..85625793d4 100755 --- a/vcx/wrappers/python3/setup.py +++ b/vcx/wrappers/python3/setup.py @@ -1,7 +1,7 @@ from setuptools import setup, find_packages import os -PKG_VERSION = os.environ.get('PACKAGE_VERSION') or '0.6.1' +PKG_VERSION = os.environ.get('PACKAGE_VERSION') or '0.6.2' PKG_NAME = os.environ.get('PACKAGE_NAME') or 'python3-wrapper-vcx' setup( diff --git a/vcx/wrappers/python3/tests/test_proof.py b/vcx/wrappers/python3/tests/test_proof.py index cacdc30700..1541d0c360 100644 --- a/vcx/wrappers/python3/tests/test_proof.py +++ b/vcx/wrappers/python3/tests/test_proof.py @@ -10,7 +10,7 @@ source_id = '123' name = 'proof name' connection_options = '{"connection_type":"SMS","phone":"8019119191","use_public_did":true}' -requested_attrs = [{"name": "age", "restrictions": [{"schema_id": "6XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"Faber Student Info", "schema_version":"1.0", "schema_issuer_did":"6XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"8XFh8yBzrpJQmNyZzgoTqB", "cred_def_id": "8XFh8yBzrpJQmNyZzgoTqB:3:CL:1766" }, { "schema_id": "5XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"BYU Student Info", "schema_version":"1.0", "schema_issuer_did":"5XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"66Fh8yBzrpJQmNyZzgoTqB", "cred_def_id": "66Fh8yBzrpJQmNyZzgoTqB:3:CL:1766" } ] }, { "name":"name", "restrictions": [ { "schema_id": "6XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"Faber Student Info", "schema_version":"1.0", "schema_issuer_did":"6XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"8XFh8yBzrpJQmNyZzgoTqB", "cred_def_id": "8XFh8yBzrpJQmNyZzgoTqB:3:CL:1766" }, { "schema_id": "5XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"BYU Student Info", "schema_version":"1.0", "schema_issuer_did":"5XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"66Fh8yBzrpJQmNyZzgoTqB", "cred_def_id": "66Fh8yBzrpJQmNyZzgoTqB:3:CL:1766"}]}] +requested_attrs = [{"name": "age", "restrictions": [{"schema_id": "6XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"Faber Student Info", "schema_version":"1.0", "schema_issuer_did":"6XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"8XFh8yBzrpJQmNyZzgoTqB", "cred_def_id": "8XFh8yBzrpJQmNyZzgoTqB:3:CL:1766" }, { "schema_id": "5XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"BYU Student Info", "schema_version":"1.0", "schema_issuer_did":"5XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"66Fh8yBzrpJQmNyZzgoTqB", "cred_def_id": "66Fh8yBzrpJQmNyZzgoTqB:3:CL:1766" } ] }, { "names":["name", "male"], "restrictions": [ { "schema_id": "6XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"Faber Student Info", "schema_version":"1.0", "schema_issuer_did":"6XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"8XFh8yBzrpJQmNyZzgoTqB", "cred_def_id": "8XFh8yBzrpJQmNyZzgoTqB:3:CL:1766" }, { "schema_id": "5XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"BYU Student Info", "schema_version":"1.0", "schema_issuer_did":"5XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"66Fh8yBzrpJQmNyZzgoTqB", "cred_def_id": "66Fh8yBzrpJQmNyZzgoTqB:3:CL:1766"}]}] revocation_interval = {} diff --git a/vcx/wrappers/python3/vcx/api/connection.py b/vcx/wrappers/python3/vcx/api/connection.py index cb3435579d..05e94a6e07 100644 --- a/vcx/wrappers/python3/vcx/api/connection.py +++ b/vcx/wrappers/python3/vcx/api/connection.py @@ -15,9 +15,122 @@ class Connection(VcxStateful): """ - The basic object of the VCX API. Represents a pairwise relationship with another identity owner. Once the - relationship, or connection, is established communication can happen securely and privately. Credentials and - proofs are exchanged using this object. + The object of the VCX API representing a pairwise relationship with another identity owner. + Once the relationship, or connection, is established communication can happen securely and privately. + Credentials and Proofs are exchanged using this object. + + # States + + The set of object states and transitions depends on communication method is used. + The communication method can be specified as config option on one of *_init function. The default communication method us `proprietary`. + + proprietary: + Inviter: + VcxStateType::VcxStateInitialized - once `vcx_connection_create` (create Connection object) is called. + + VcxStateType::VcxStateOfferSent - once `vcx_connection_connect` (send Connection invite) is called. + + VcxStateType::VcxStateAccepted - once `connReqAnswer` messages is received. + use `vcx_connection_update_state` or `vcx_connection_update_state_with_message` functions for state updates. + VcxStateType::VcxStateNone - once `vcx_connection_delete_connection` (delete Connection object) is called. + + Invitee: + VcxStateType::VcxStateRequestReceived - once `vcx_connection_create_with_invite` (create Connection object with invite) is called. + + VcxStateType::VcxStateAccepted - once `vcx_connection_connect` (accept Connection invite) is called. + + VcxStateType::VcxStateNone - once `vcx_connection_delete_connection` (delete Connection object) is called. + + aries: + Inviter: + VcxStateType::VcxStateInitialized - once `vcx_connection_create` (create Connection object) is called. + + VcxStateType::VcxStateOfferSent - once `vcx_connection_connect` (prepared Connection invite) is called. + + VcxStateType::VcxStateRequestReceived - once `ConnectionRequest` messages is received. + accept `ConnectionRequest` and send `ConnectionResponse` message. + use `vcx_connection_update_state` or `vcx_connection_update_state_with_message` functions for state updates. + + VcxStateType::VcxStateAccepted - once `Ack` messages is received. + use `vcx_connection_update_state` or `vcx_connection_update_state_with_message` functions for state updates. + + VcxStateType::VcxStateNone - once `vcx_connection_delete_connection` (delete Connection object) is called + OR + `ConnectionProblemReport` messages is received on state updates. + + Invitee: + VcxStateType::VcxStateOfferSent - once `vcx_connection_create_with_invite` (create Connection object with invite) is called. + + VcxStateType::VcxStateRequestReceived - once `vcx_connection_connect` (accept `ConnectionInvite` and send `ConnectionRequest` message) is called. + + VcxStateType::VcxStateAccepted - once `ConnectionResponse` messages is received. + send `Ack` message if requested. + use `vcx_connection_update_state` or `vcx_connection_update_state_with_message` functions for state updates. + + VcxStateType::VcxStateNone - once `vcx_connection_delete_connection` (delete Connection object) is called + OR + `ConnectionProblemReport` messages is received on state updates. + + # Transitions + + proprietary: + Inviter: + VcxStateType::None - `vcx_connection_create` - VcxStateType::VcxStateInitialized + VcxStateType::VcxStateInitialized - `vcx_connection_connect` - VcxStateType::VcxStateOfferSent + VcxStateType::VcxStateOfferSent - received `connReqAnswer` - VcxStateType::VcxStateAccepted + any state - `vcx_connection_delete_connection` - `VcxStateType::VcxStateNone` + + Invitee: + VcxStateType::None - `vcx_connection_create_with_invite` - VcxStateType::VcxStateRequestReceived + VcxStateType::VcxStateRequestReceived - `vcx_connection_connect` - VcxStateType::VcxStateAccepted + any state - `vcx_connection_delete_connection` - `VcxStateType::VcxStateNone` + + aries - RFC: https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential + Inviter: + VcxStateType::None - `vcx_connection_create` - VcxStateType::VcxStateInitialized + + VcxStateType::VcxStateInitialized - `vcx_connection_connect` - VcxStateType::VcxStateOfferSent + + VcxStateType::VcxStateOfferSent - received `ConnectionRequest` - VcxStateType::VcxStateRequestReceived + VcxStateType::VcxStateOfferSent - received `ConnectionProblemReport` - VcxStateType::VcxStateNone + + VcxStateType::VcxStateRequestReceived - received `Ack` - VcxStateType::VcxStateAccepted + VcxStateType::VcxStateRequestReceived - received `ConnectionProblemReport` - VcxStateType::VcxStateNone + + VcxStateType::VcxStateAccepted - received `Ping`, `PingResponse`, `Query`, `Disclose` - VcxStateType::VcxStateAccepted + + any state - `vcx_connection_delete_connection` - VcxStateType::VcxStateNone + + + Invitee: + VcxStateType::None - `vcx_connection_create_with_invite` - VcxStateType::VcxStateOfferSent + + VcxStateType::VcxStateOfferSent - `vcx_connection_connect` - VcxStateType::VcxStateRequestReceived + VcxStateType::VcxStateOfferSent - received `ConnectionProblemReport` - VcxStateType::VcxStateNone + + VcxStateType::VcxStateRequestReceived - received `ConnectionResponse` - VcxStateType::VcxStateAccepted + VcxStateType::VcxStateRequestReceived - received `ConnectionProblemReport` - VcxStateType::VcxStateNone + + VcxStateType::VcxStateAccepted - received `Ping`, `PingResponse`, `Query`, `Disclose` - VcxStateType::VcxStateAccepted + + any state - `vcx_connection_delete_connection` - VcxStateType::VcxStateNone + + # Messages + + proprietary: + ConnectionRequest (`connReq`) + ConnectionRequestAnswer (`connReqAnswer`) + + aries: + Invitation - https://github.com/hyperledger/aries-rfcs/tree/master/features/0160-connection-protocol#0-invitation-to-connect + ConnectionRequest - https://github.com/hyperledger/aries-rfcs/tree/master/features/0160-connection-protocol#1-connection-request + ConnectionResponse - https://github.com/hyperledger/aries-rfcs/tree/master/features/0160-connection-protocol#2-connection-response + ConnectionProblemReport - https://github.com/hyperledger/aries-rfcs/tree/master/features/0160-connection-protocol#error-message-example + Ack - https://github.com/hyperledger/aries-rfcs/tree/master/features/0015-acks#explicit-acks + Ping - https://github.com/hyperledger/aries-rfcs/tree/master/features/0048-trust-ping#messages + PingResponse - https://github.com/hyperledger/aries-rfcs/tree/master/features/0048-trust-ping#messages + Query - https://github.com/hyperledger/aries-rfcs/tree/master/features/0031-discover-features#query-message-type + Disclose - https://github.com/hyperledger/aries-rfcs/tree/master/features/0031-discover-features#disclose-message-type TODO: document attributes """ @@ -58,6 +171,18 @@ async def create_with_details(source_id: str, invite_details: str): Invite details are provided by the entity offering a connection and generally pulled from a provided QRCode. :param source_id: Institution's unique ID for the connection :param invite_details: A string representing a json object which is provided by an entity that wishes to make a connection. + Invite format depends on communication method: + proprietary: + {"targetName": "", "statusMsg": "message created", "connReqId": "mugIkrWeMr", "statusCode": "MS-101", "threadId": null, "senderAgencyDetail": {"endpoint": "http://localhost:8080", "verKey": "key", "DID": "did"}, "senderDetail": {"agentKeyDlgProof": {"agentDID": "8f6gqnT13GGMNPWDa2TRQ7", "agentDelegatedKey": "5B3pGBYjDeZYSNk9CXvgoeAAACe2BeujaAkipEC7Yyd1", "signature": "TgGSvZ6+/SynT3VxAZDOMWNbHpdsSl8zlOfPlcfm87CjPTmC/7Cyteep7U3m9Gw6ilu8SOOW59YR1rft+D8ZDg=="}, "publicDID": "7YLxxEfHRiZkCMVNii1RCy", "name": "Faber", "logoUrl": "http://robohash.org/234", "verKey": "CoYZMV6GrWqoG9ybfH3npwH3FnWPcHmpWYUF8n172FUx", "DID": "Ney2FxHT4rdEyy6EDCCtxZ"}} + aries: https://github.com/hyperledger/aries-rfcs/tree/master/features/0160-connection-protocol#0-invitation-to-connect + { + "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/1.0/invitation", + "label": "Alice", + "recipientKeys": ["8HH5gYEeNc3z7PYXmd54d4x6qAfCNrqQqEB3nS7Zfu7K"], + "serviceEndpoint": "https://example.com/endpoint", + "routingKeys": ["8HH5gYEeNc3z7PYXmd54d4x6qAfCNrqQqEB3nS7Zfu7K"] + } + Example: connection2 = await Connection.create_with_details('MyBank', invite_details) :return: connection object @@ -76,9 +201,9 @@ async def create_with_details(source_id: str, invite_details: str): @staticmethod async def deserialize(data: dict): """ - Create the object from a previously serialized object. + Takes a json string representing a connection object and recreates an object matching the json. - :param data: The output of the "serialize" call + :param data: json string representing a connection object. Is an output of `serialize` function. Example: data = await connection1.serialize() connection2 = await Connection.deserialize(data) @@ -117,11 +242,21 @@ async def connect(self, options: str) -> str: async def send_message(self, msg: str, msg_type: str, msg_title: str, ref_msg_id: str = None) -> str: """ Send a generic message to the connection - :param msg: - :param msg_type: - :param msg_title: + :param msg: actual message to send + :param msg_type: type of message to send. can be any string. + :param msg_title: message title (user notification) :param ref_msg_id: if responding to a message, provide msg id - :return: + + Example options: + msg: "HI" or "{"key": "value"}" or "{ "@type": "type", "@id": "518be002-de8e-456e-b3d5-8fe472477a86", "comment": "Hi. Are you listening?"}" + msg_type: "Greeting" + msg_title: "Hi There" + + Example code: + connection = await Connection.create_with_details('MyBank', invite_details) + await connection.send_message("HI", "Greeting", "Hi There") + + :return: response message """ if not hasattr(Connection.send_message, "cb"): self.logger.debug("vcx_connection_send_message: Creating callback") @@ -148,7 +283,7 @@ async def send_message(self, msg: str, msg_type: str, msg_title: str, ref_msg_id async def sign_data(self, msg: bytes) -> bytes: """ Sign data using connection's pairwise key - :param msg: + :param msg: message to sign represented as bytes :return: signature """ @@ -173,10 +308,10 @@ def transform_cb(arr_ptr: POINTER(c_uint8), arr_len: c_uint32): async def verify_signature(self, msg: bytes, signature: bytes) -> bool: """ - Verification the signature of a msg - :param msg: - :param signature: - :return: bool + Verify the signature is valid for the specified data using connection pairwise keys + :param msg: message was signed + :param signature: generated signature + :return: bool - whether the signature was valid or not """ if not hasattr(Connection.verify_signature, "cb"): self.logger.debug("vcx_connection_verify_signature: Creating callback") @@ -206,7 +341,7 @@ async def _delete(self): async def serialize(self) -> dict: """ - Serialize the object for storage + Takes the Connection object and returns a json string of all its attributes Example: data = await connection1.serialize() :return: serialized object @@ -215,29 +350,43 @@ async def serialize(self) -> dict: async def update_state(self) -> int: """ - Query the agency for the current state of the connection. Used to determine whether the connection - has been accepted by both endpoints. + Query the agency for the received messages. + Checks for any messages changing state in the connection object and updates the state attribute. Example: connection = await Connection.create(source_id) assert await connection.update_state() == State.Initialized - :return: Current state of the connection + :return: Current state of the connection. Possible states: + 1 - Initialized + 2 - Request Sent + 3 - Offer Received + 4 - Accepted """ return await self._update_state(Connection, 'vcx_connection_update_state') async def update_state_with_message(self, message: str) -> int: """ Update the state of the connection based on the given message. + :param msg: message to process Example: connection = await Connection.create(source_id) assert await connection.update_state_with_message(message) == State.Accepted - :param message: - :return Current state of the connection + :param message: message to process for state changes + :return Current state of the connection. Possible states: + 1 - Initialized + 2 - Request Sent + 3 - Offer Received + 4 - Accepted """ return await self._update_state_with_message(Connection, message, 'vcx_connection_update_state_with_message') async def get_state(self) -> int: """ - Returns the current internal state of the connection. Does NOT query agency for state updates. + Returns the current internal state of the connection. Does NOT query agency for state updates. + Possible states: + 1 - Initialized + 2 - Offer Sent + 3 - Request Received + 4 - Accepted Example: connection = await Connection.create(source_id) assert await connection.get_state() == State.Initialized @@ -268,15 +417,27 @@ async def delete(self): async def invite_details(self, abbreviated: bool) -> dict: """ - Get the invite details that were sent or can be sent to the endpoint. + Get the invite details that were sent or can be sent to the remote side. - :param abbreviated: abbreviate invite details or not + :param abbreviated: abbreviate invite details or not (applicable for `proprietary` communication method only) Example: phone_number = '8019119191' connection = await Connection.create('foobar123') invite_details = await connection.connect(phone_number) inivte_details_again = await connection.invite_details() :return: JSON of invite_details sent to connection + Invite format depends on communication method: + proprietary: + {"targetName": "", "statusMsg": "message created", "connReqId": "mugIkrWeMr", "statusCode": "MS-101", "threadId": null, "senderAgencyDetail": {"endpoint": "http://localhost:8080", "verKey": "key", "DID": "did"}, "senderDetail": {"agentKeyDlgProof": {"agentDID": "8f6gqnT13GGMNPWDa2TRQ7", "agentDelegatedKey": "5B3pGBYjDeZYSNk9CXvgoeAAACe2BeujaAkipEC7Yyd1", "signature": "TgGSvZ6+/SynT3VxAZDOMWNbHpdsSl8zlOfPlcfm87CjPTmC/7Cyteep7U3m9Gw6ilu8SOOW59YR1rft+D8ZDg=="}, "publicDID": "7YLxxEfHRiZkCMVNii1RCy", "name": "Faber", "logoUrl": "http://robohash.org/234", "verKey": "CoYZMV6GrWqoG9ybfH3npwH3FnWPcHmpWYUF8n172FUx", "DID": "Ney2FxHT4rdEyy6EDCCtxZ"}} + aries: https://github.com/hyperledger/aries-rfcs/tree/master/features/0160-connection-protocol#0-invitation-to-connect + { + "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/1.0/invitation", + "label": "Alice", + "recipientKeys": ["8HH5gYEeNc3z7PYXmd54d4x6qAfCNrqQqEB3nS7Zfu7K"], + "serviceEndpoint": "https://example.com/endpoint", + "routingKeys": ["8HH5gYEeNc3z7PYXmd54d4x6qAfCNrqQqEB3nS7Zfu7K"] + } + """ if not hasattr(Connection.invite_details, "cb"): self.logger.debug("vcx_connection_invite_details: Creating callback") @@ -298,7 +459,7 @@ async def send_ping(self, comment: Optional[str] = None): Send trust ping message to the specified connection to prove that two agents have a functional pairwise channel. Note that this function is useful in case `aries` communication method is used. - In other cases it returns IActionNotSupported error. + In other cases it returns ActionNotSupported error. :param comment: (Optional) human-friendly description of the ping. :return: no value diff --git a/vcx/wrappers/python3/vcx/api/credential.py b/vcx/wrappers/python3/vcx/api/credential.py index c73a65524e..46b221df2b 100644 --- a/vcx/wrappers/python3/vcx/api/credential.py +++ b/vcx/wrappers/python3/vcx/api/credential.py @@ -8,6 +8,64 @@ class Credential(VcxStateful): + """ + The object of the VCX API representing a Holder side in the credential issuance process. + Assumes that pairwise connection between Issuer and Holder is already established. + + # State + + The set of object states and transitions depends on communication method is used. + The communication method can be specified as config option on one of *_init function. The default communication method us `proprietary`. + + proprietary: + VcxStateType::VcxStateRequestReceived - once `vcx_credential_create_with_offer` (create Credential object) is called. + + VcxStateType::VcxStateOfferSent - once `vcx_credential_send_request` (send `CRED_REQ` message) is called. + + VcxStateType::VcxStateAccepted - once `CRED` messages is received. + use `vcx_credential_update_state` or `vcx_credential_update_state_with_message` functions for state updates. + + aries: + VcxStateType::VcxStateRequestReceived - once `vcx_credential_create_with_offer` (create Credential object) is called. + + VcxStateType::VcxStateOfferSent - once `vcx_credential_send_request` (send `CredentialRequest` message) is called. + + VcxStateType::VcxStateAccepted - once `Credential` messages is received. + VcxStateType::None - once `ProblemReport` messages is received. + use `vcx_credential_update_state` or `vcx_credential_update_state_with_message` functions for state updates. + + # Transitions + + proprietary: + VcxStateType::None - `vcx_credential_create_with_offer` - VcxStateType::VcxStateRequestReceived + + VcxStateType::VcxStateRequestReceived - `vcx_credential_send_request` - VcxStateType::VcxStateOfferSent + + VcxStateType::VcxStateOfferSent - received `CRED` - VcxStateType::VcxStateAccepted + + aries: RFC - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential + VcxStateType::None - `vcx_credential_create_with_offer` - VcxStateType::VcxStateRequestReceived + + VcxStateType::VcxStateRequestReceived - `vcx_issuer_send_credential_offer` - VcxStateType::VcxStateOfferSent + + VcxStateType::VcxStateOfferSent - received `Credential` - VcxStateType::VcxStateAccepted + VcxStateType::VcxStateOfferSent - received `ProblemReport` - VcxStateType::None + + # Messages + + proprietary: + CredentialOffer (`CRED_OFFER`) + CredentialRequest (`CRED_REQ`) + Credential (`CRED`) + + aries: + CredentialProposal - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential#propose-credential + CredentialOffer - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential#offer-credential + CredentialRequest - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential#request-credential + Credential - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential#issue-credential + ProblemReport - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0035-report-problem#the-problem-report-message-type + Ack - https://github.com/hyperledger/aries-rfcs/tree/master/features/0015-acks#explicit-acks + """ def __init__(self, source_id: str): VcxStateful.__init__(self, source_id) @@ -34,35 +92,53 @@ async def create(source_id: str, credential_offer: str): :param credential_offer: JSON string representing the offer used as the basis of creation. :return: A created credential Example: - offer = [{ - "msg_type": "CLAIM_OFFER", - "version": "0.1", - "to_did": "8XFh8yBzrpJQmNyZzgoTqB", - "from_did": "8XFh8yBzrpJQmNyZzgoTqB", - "libindy_offer": '{}', - "credential_attrs": { - "address1": [ - "101 Tela Lane" - ], - "address2": [ - "101 Wilson Lane" - ], - "city": [ - "SLC" - ], - "state": [ - "UT" - ], - "zip": [ - "87121" - ] - }, - "schema_seq_no": 1487, - "cred_def_id": "id1", - "claim_name": "Credential", - "claim_id": "defaultCredentialId", - "msg_ref_id": None, - }] + offer depends on communication method: + proprietary: + [{ + "msg_type": "CLAIM_OFFER", + "version": "0.1", + "to_did": "8XFh8yBzrpJQmNyZzgoTqB", + "from_did": "8XFh8yBzrpJQmNyZzgoTqB", + "libindy_offer": '{}', + "credential_attrs": { + "address1": [ + "101 Tela Lane" + ], + "address2": [ + "101 Wilson Lane" + ], + "city": [ + "SLC" + ], + "state": [ + "UT" + ], + "zip": [ + "87121" + ] + }, + "schema_seq_no": 1487, + "cred_def_id": "id1", + "claim_name": "Credential", + "claim_id": "defaultCredentialId", + "msg_ref_id": None, + }] + aries: + { + "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/issue-credential/1.0/offer-credential", + "@id": "", + "comment": "some comment", + "credential_preview": , + "offers~attach": [ + { + "@id": "libindy-cred-offer-0", + "mime-type": "application/json", + "data": { + "base64": "" + } + } + ] + } credential = await Credential.create(source_id, offer) """ constructor_params = (source_id,) @@ -80,8 +156,8 @@ async def create_with_msgid(source_id: str, connection: Connection, msg_id: str) """ Create a credential based off of a known message id for a given connection. :param source_id: user defined id of object. - :param connection: connection handle of connection to receive offer from - :param msg_id: message id + :param connection: connection to receive offer from + :param msg_id: id of the message that contains the credential offer :return: A created credential Example: credential = await Credential.create_with_msgid(source_id, connection, msg_id) @@ -127,8 +203,9 @@ async def deserialize(data: dict): async def get_offers(connection: Connection) -> dict: """ Retrieves all pending credential offers for a given connection. - :param connection: A connection handle + :param connection: A connection to query for credential offers. :return: A list of dictionary objects representing offers from a given connection. + "[[{"msg_type": "CREDENTIAL_OFFER","version": "0.1","to_did": "...","from_did":"...","credential": {"account_num": ["...."],"name_on_account": ["Alice"]},"schema_seq_no": 48,"issuer_did": "...","credential_name": "Account Certificate","credential_id": "3675417066","msg_ref_id": "ymy5nth"}]]" Example: credential = await Credential.create_with_msgid(source_id, connection, msg_id) offers = await credential.get_offers(connection) @@ -156,7 +233,10 @@ async def serialize(self) -> dict: async def update_state(self) -> int: """ - Communicates with the agent service for polling and setting the state of the entity. + Query the agency for the received messages. + Checks for any messages changing state in the credential object and updates the state attribute. + If it detects a credential it will store the credential in the wallet. + Example: credential = await Credential.create(source_id, offer) credential.update_state() @@ -167,19 +247,23 @@ async def update_state(self) -> int: async def update_state_with_message(self, message: str) -> int: """ - Update the state of the proof based on the given message. + Update the state of the credential based on the given message. Example: proof = await Proof.create(source_id) assert await proof.update_state_with_message(message) == State.Accepted - :param message: - :return Current state of the Proof + :param message: message to process for state changes + :return Current state of the credential """ return await self._update_state_with_message(Credential, message, 'vcx_credential_update_state_with_message') async def get_state(self) -> int: """ - Gets the state of the entity. - :return: state of the object + Get the current state of the credential object + :return: credential state of the object. Possible states: + 2 - Request Sent + 3 - Request Received + 4 - Accepted + Example: credential = await Credential.create(source_id, offer) credential.update_state() @@ -222,8 +306,8 @@ async def send_request(self, connection: Connection, payment_handle: int): async def get_request_msg(self, connection: Connection, payment_handle: int): """ - Approves the credential offer and gets the credential request message - :param connection: connection to submit request from + Approves the credential offer and gets the credential request message that can be sent to the specified connection + :param connection: connection that identifies pairwise connection :param payment_handle: currently unused :return: Example: @@ -256,7 +340,12 @@ async def get_payment_info(self): submitting the credential request (which triggers the payment to be made). Example: info = credential.get_payment_info() - :return: + :return: payment information + { + "payment_required":"one-time", + "payment_addr":"pov:null:OsdjtGKavZDBuG2xFw2QunVwwGs5IB3j", + "price":1 + } """ if not hasattr(Credential.get_payment_info, "cb"): self.logger.debug("vcx_credential_get_payment_info: Creating callback") @@ -270,10 +359,19 @@ async def get_payment_info(self): async def get_payment_txn(self): """ - Retirieve the payment transaction associated with this credential. This can be used to get the txn that + Retrieve the payment transaction associated with this credential. This can be used to get the txn that was used to pay the issuer from the prover. This could be considered a receipt of payment from the payer to the issuer. - :return: + :return: payment transaction + { + "amount":25, + "inputs":[ + "pay:null:1_3FvPC7dzFbQKzfG" + ], + "outputs":[ + {"recipient":"pay:null:FrSVC3IrirScyRh","amount":5,"extra":null} + ] + } Example: txn = credential.get_payment_txn() """ diff --git a/vcx/wrappers/python3/vcx/api/credential_def.py b/vcx/wrappers/python3/vcx/api/credential_def.py index 3caac7685e..51d120d7fa 100644 --- a/vcx/wrappers/python3/vcx/api/credential_def.py +++ b/vcx/wrappers/python3/vcx/api/credential_def.py @@ -97,7 +97,9 @@ async def create(source_id: str, name: str, schema_id: str, payment_handle: int) @staticmethod async def prepare_for_endorser(source_id: str, name: str, schema_id: str, endorser: str): """ - Create a new CredentialDef object that will be published by Endorser later. + Create a new CredentialDef object that will be published on the ledger by Endorser later. + + Note that CredentialDef can't be used for credential issuing until it will be published on the ledger. :param source_id: Institution's unique ID for the credential definition :param name: Name of credential definition @@ -228,6 +230,15 @@ async def get_payment_txn(self): credential_def1 = await CredentialDef.create(source_id, name, schema_id, payment_handle) txn = await credential_def1.get_payment_txn() :return: JSON object with input address and output UTXOs + { + "amount":25, + "inputs":[ + "pay:null:1_3FvPC7dzFbQKzfG" + ], + "outputs":[ + {"recipient":"pay:null:FrSVC3IrirScyRh","amount":5,"extra":null} + ] + } """ if not hasattr(CredentialDef.get_payment_txn, "cb"): self.logger.debug("vcx_credentialdef_get_payment_txn: Creating callback") @@ -244,14 +255,17 @@ async def get_payment_txn(self): async def update_state(self) -> int: """ - Checks if credential definition is published on the Ledger and updates the the state + Checks if credential definition is published on the Ledger and updates the state. + Possible states: + 0 = Built + 1 = Published Example: source_id = 'foobar123' schema_name = 'Schema Name' payment_handle = 0 credential_def = await CredentialDef.create(source_id, name, schema_id, payment_handle) assert await credential_def.update_state() == PublicEntityState.Published - :return: Current state of the сredential definition + :return: Current state of the credential definition """ return await self._update_state(CredentialDef, 'vcx_credentialdef_update_state') @@ -259,12 +273,15 @@ async def update_state(self) -> int: async def get_state(self) -> int: """ Get the current state of the credential definition object + Possible states: + 0 = Built + 1 = Published Example: source_id = 'foobar123' schema_name = 'Schema Name' payment_handle = 0 credential_def = await CredentialDef.create(source_id, name, schema_id, payment_handle) assert await credential_def.get_state() == PublicEntityState.Published - :return: Current internal state of the schema + :return: Current state of the credential definition """ return await self._get_state(CredentialDef, 'vcx_credentialdef_get_state') diff --git a/vcx/wrappers/python3/vcx/api/disclosed_proof.py b/vcx/wrappers/python3/vcx/api/disclosed_proof.py index a42b04b096..26be5b5c1c 100644 --- a/vcx/wrappers/python3/vcx/api/disclosed_proof.py +++ b/vcx/wrappers/python3/vcx/api/disclosed_proof.py @@ -8,6 +8,65 @@ class DisclosedProof(VcxStateful): + """ + The object of the VCX API representing a Prover side in the credential presentation process. + Assumes that pairwise connection between Verifier and Prover is already established. + + # State + + The set of object states and transitions depends on communication method is used. + The communication method can be specified as config option on one of *_init function. The default communication method us `proprietary`. + + proprietary: + VcxStateType::VcxStateRequestReceived - once `vcx_disclosed_proof_create_with_request` (create DisclosedProof object) is called. + + VcxStateType::VcxStateRequestReceived - once `vcx_disclosed_proof_generate_proof` (send `PROOF_REQ` message) is called. + + VcxStateType::VcxStateAccepted - once `vcx_disclosed_proof_send_proof` (send `PROOF_REQ` message) is called. + + aries: + VcxStateType::VcxStateRequestReceived - once `vcx_disclosed_proof_create_with_request` (create DisclosedProof object) is called. + + VcxStateType::VcxStateRequestReceived - once `vcx_disclosed_proof_generate_proof` is called. + + VcxStateType::VcxStateOfferSent - once `vcx_disclosed_proof_send_proof` (send `Presentation` message) is called. + VcxStateType::None - once `vcx_disclosed_proof_decline_presentation_request` (send `PresentationReject` or `PresentationProposal` message) is called. + + VcxStateType::VcxStateAccepted - once `Ack` messages is received. + VcxStateType::None - once `ProblemReport` messages is received. + + # Transitions + + proprietary: + VcxStateType::None - `vcx_disclosed_proof_create_with_request` - VcxStateType::VcxStateRequestReceived + + VcxStateType::VcxStateRequestReceived - `vcx_disclosed_proof_generate_proof` - VcxStateType::VcxStateRequestReceived + + VcxStateType::VcxStateRequestReceived - `vcx_disclosed_proof_send_proof` - VcxStateType::VcxStateAccepted + + aries: RFC - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0037-present-proof#propose-presentation + VcxStateType::None - `vcx_disclosed_proof_create_with_request` - VcxStateType::VcxStateRequestReceived + + VcxStateType::VcxStateRequestReceived - `vcx_disclosed_proof_generate_proof` - VcxStateType::VcxStateRequestReceived + + VcxStateType::VcxStateRequestReceived - `vcx_disclosed_proof_send_proof` - VcxStateType::VcxStateAccepted + VcxStateType::VcxStateRequestReceived - `vcx_disclosed_proof_decline_presentation_request` - VcxStateType::None + + VcxStateType::VcxStateOfferSent - received `Ack` - VcxStateType::VcxStateAccepted + VcxStateType::VcxStateOfferSent - received `ProblemReport` - VcxStateType::None + + # Messages + + proprietary: + ProofRequest (`PROOF_REQ`) + Proof (`PROOF`) + + aries: + PresentationRequest - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0037-present-proof#request-presentation + Presentation - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0037-present-proof#presentation + PresentationProposal - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0037-present-proof#propose-presentation + Ack - https://github.com/hyperledger/aries-rfcs/tree/master/features/0015-acks#explicit-acks + """ def __init__(self, source_id: str): VcxStateful.__init__(self, source_id) @@ -31,7 +90,7 @@ async def create(source_id: str, proof_request: str): """ Create a proof for fulfilling a corresponding proof request :param source_id: Tag associated by user of sdk - :param proof_request: Proof Request data sent by requestor. + :param proof_request: Proof Request data sent by requester. Example: source_id = 'sourceId' request = { @@ -78,10 +137,11 @@ async def create(source_id: str, proof_request: str): @staticmethod async def create_with_msgid(source_id: str, connection: Connection, msg_id: str): """ + Create a proof based off of a known message id for a given connection. - :param source_id: - :param connection: - :param msg_id: + :param source_id: user defined id of object. + :param connection: connection to receive proof request from + :param msg_id: id of the message that contains the proof request Example: msg_id = '1' phone_number = '8019119191' @@ -112,7 +172,8 @@ async def create_with_msgid(source_id: str, connection: Connection, msg_id: str) @staticmethod async def deserialize(data: dict): """ - :param data: Data provided by the serialize method + Create a DisclosedProof object from a previously serialized proof object + :param data: JSON data from a serialized object. Example: msg_id = '1' phone_number = '8019119191' @@ -131,6 +192,8 @@ async def deserialize(data: dict): @staticmethod async def get_requests(connection: Connection) -> dict: """ + Retrieves all pending proof requests for a given connection. + Example: msg_id = '1' phone_number = '8019119191' @@ -140,6 +203,7 @@ async def get_requests(connection: Connection) -> dict: requests = await DisclosedProof.get_requests(connection) :param connection: Connection :return: requests associated with the connection + [{'@topic': {'tid': 0, 'mid': 0}, '@type': {'version': '1.0', 'name': 'PROOF_REQUEST'}, 'proof_request_data': {'name': 'proof_req', 'nonce': '118065925949165739229152', 'version': '0.1', 'requested_predicates': {}, 'non_revoked': None, 'requested_attributes': {'attribute_0': {'name': 'name', 'restrictions': {'$or': [{'issuer_did': 'did'}]}}}, 'ver': '1.0'}, 'thread_id': '40bdb5b2'}] """ if not hasattr(DisclosedProof.get_requests, "cb"): DisclosedProof.get_requests.cb = create_cb(CFUNCTYPE(None, c_uint32, c_uint32, c_char_p)) @@ -154,7 +218,7 @@ async def get_requests(connection: Connection) -> dict: async def serialize(self) -> dict: """ - Serialize the object + Serializes the proof object for storage and later deserialization. Example: msg_id = '1' phone_number = '8019119191' @@ -168,6 +232,9 @@ async def serialize(self) -> dict: async def update_state(self) -> int: """ + Query the agency for the received messages. + Checks for any messages changing state in the proof object and updates the state attribute. + Example: msg_id = '1' phone_number = '8019119191' @@ -181,6 +248,7 @@ async def update_state(self) -> int: async def update_state_with_message(self, message: str) -> int: """ + Update the state of the proof based on the given message. Example: msg_id = '1' phone_number = '8019119191' @@ -188,14 +256,14 @@ async def update_state_with_message(self, message: str) -> int: await connection.connect(phone_number) disclosed_proof = await DisclosedProof.create_with_msgid(source_id, connection, msg_id) assert await disclosed_proof.update_state_with_message(msg) == State.RequestReceived + :param message: - message to process for state changes :return: """ return await self._update_state_with_message(DisclosedProof, message, 'vcx_disclosed_proof_update_state_with_message') async def get_state(self) -> int: """ - - Gets the state of the entity. + Get the current state of the credential object Example: msg_id = '1' phone_number = '8019119191' @@ -203,7 +271,9 @@ async def get_state(self) -> int: await connection.connect(phone_number) disclosed_proof = await DisclosedProof.create_with_msgid(source_id, connection, msg_id) assert await proof.get_state() == State.Initialized - :return: StateType + :return: credential state of the object. Possible states: + 3 - Request Received + 4 - Accepted """ return await self._get_state(DisclosedProof, 'vcx_disclosed_proof_get_state') @@ -216,7 +286,7 @@ def release(self) -> None: async def get_creds(self) -> dict: """ - Gets the credentials from a disclosed proof + Get credentials from wallet matching to the proof request associated with proof object Example: msg_id = '1' phone_number = '8019119191' @@ -225,6 +295,7 @@ async def get_creds(self) -> dict: disclosed_proof = await DisclosedProof.create_with_msgid(source_id, connection, msg_id) creds = await disclosed_proof.get_creds() :return: credentials + {'attrs': {'attribute_0': [{'cred_info': {'schema_id': 'id', 'cred_def_id': 'id', 'attrs': {'attr_name': 'attr_value', ...}, 'referent': '914c7e11'}}]}} """ if not hasattr(DisclosedProof.get_creds, "cb"): self.logger.debug("vcx_disclosed_proof_retrieve_credentials: Creating callback") @@ -264,6 +335,7 @@ async def send_proof(self, connection: Optional[Connection] = None): async def get_send_proof_msg(self): """ + Gets the proof message that can be sent to the specified connection Example: msg = await disclosed_proof.get_send_proof_msg() :param @@ -284,7 +356,7 @@ async def get_send_proof_msg(self): async def generate_proof(self, selected_creds: dict, self_attested_attrs: dict): """ - Generates the proof + Accept proof request associated with proof object and generates a proof from the selected credentials and self attested attributes Example: msg_id = '1' phone_number = '8019119191' @@ -292,8 +364,36 @@ async def generate_proof(self, selected_creds: dict, self_attested_attrs: dict): await connection.connect(phone_number) disclosed_proof = await DisclosedProof.create_with_msgid(source_id, connection, msg_id) await disclosed_proof.generate_proof({}, {}) - :param selected_creds: Credentials issued - :param self_attested_attrs: Self Attested Attributes + :param selected_creds: a json with a credential for each proof request attribute. + List of possible credentials for each attribute is returned from vcx_disclosed_proof_retrieve_credentials, + (user needs to select specific credential to use from list of credentials) + { + "attrs":{ + String:{// Attribute key: This may not be the same as the attr name ex. "age_1" where attribute name is "age" + "credential": { + "cred_info":{ + "referent":String, + "attrs":{ String: String }, // ex. {"age": "111", "name": "Bob"} + "schema_id": String, + "cred_def_id": String, + "rev_reg_id":Option, + "cred_rev_id":Option, + }, + "interval":Option<{to: Option, from:: Option}> + }, // This is the exact credential information selected from list of + // credentials returned from vcx_disclosed_proof_retrieve_credentials + "tails_file": Option<"String">, // Path to tails file for this credential + }, + }, + "predicates":{ TODO: will be implemented as part of IS-1095 ticket. } + } + selected_credentials can be empty "{}" if the proof only contains self_attested_attrs + :param self_attested_attrs: a json with attributes self attested by user + + Example: + self_attested_attrs: {"self_attested_attr_0":"attested_val"} or {} + selected_credentials -> {'attrs': {'attribute_0': {'credential': {'cred_info': {'cred_def_id': 'od', 'schema_id': 'id', 'referent': '0c212108-9433-4199-a21f-336a44164f38', 'attrs': {'attr_name': 'attr_value', ...}}}}}} + :return: None """ if not hasattr(DisclosedProof.generate_proof, "cb"): diff --git a/vcx/wrappers/python3/vcx/api/issuer_credential.py b/vcx/wrappers/python3/vcx/api/issuer_credential.py index a518c0da2e..6c6f99818c 100644 --- a/vcx/wrappers/python3/vcx/api/issuer_credential.py +++ b/vcx/wrappers/python3/vcx/api/issuer_credential.py @@ -7,7 +7,73 @@ import json class IssuerCredential(VcxStateful): - """Class representing an Issuer Credential""" + """ + The object of the VCX API representing an Issuer side in the credential issuance process. + Assumes that pairwise connection between Issuer and Holder is already established. + + # State + + The set of object states and transitions depends on communication method is used. + The communication method can be specified as config option on one of *_init function. The default communication method us `proprietary`. + + proprietary: + VcxStateType::VcxStateInitialized - once `vcx_issuer_create_credential` (create IssuerCredential object) is called. + + VcxStateType::VcxStateOfferSent - once `vcx_issuer_send_credential_offer` (send `CRED_OFFER` message) is called. + + VcxStateType::VcxStateRequestReceived - once `CRED_REQ` messages is received. + use `vcx_issuer_credential_update_state` or `vcx_issuer_credential_update_state_with_message` functions for state updates. + VcxStateType::VcxStateAccepted - once `vcx_issuer_send_credential` (send `CRED` message) is called. + + aries: + VcxStateType::VcxStateInitialized - once `vcx_issuer_create_credential` (create IssuerCredential object) is called. + + VcxStateType::VcxStateOfferSent - once `vcx_issuer_send_credential_offer` (send `CredentialOffer` message) is called. + + VcxStateType::VcxStateRequestReceived - once `CredentialRequest` messages is received. + VcxStateType::None - once `ProblemReport` messages is received. + use `vcx_issuer_credential_update_state` or `vcx_issuer_credential_update_state_with_message` functions for state updates. + + VcxStateType::VcxStateAccepted - once `vcx_issuer_send_credential` (send `Credential` message) is called. + + # Transitions + + proprietary: + VcxStateType::None - `vcx_issuer_create_credential` - VcxStateType::VcxStateInitialized + + VcxStateType::VcxStateInitialized - `vcx_issuer_send_credential_offer` - VcxStateType::VcxStateOfferSent + + VcxStateType::VcxStateOfferSent - received `CRED_REQ` - VcxStateType::VcxStateRequestReceived + + VcxStateType::VcxStateRequestReceived - `vcx_issuer_send_credential` - VcxStateType::VcxStateAccepted + + aries: RFC - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential + VcxStateType::None - `vcx_issuer_create_credential` - VcxStateType::VcxStateInitialized + + VcxStateType::VcxStateInitialized - `vcx_issuer_send_credential_offer` - VcxStateType::VcxStateOfferSent + + VcxStateType::VcxStateOfferSent - received `CredentialRequest` - VcxStateType::VcxStateRequestReceived + VcxStateType::VcxStateOfferSent - received `ProblemReport` - VcxStateType::None + + VcxStateType::VcxStateRequestReceived - vcx_issuer_send_credential` - VcxStateType::VcxStateAccepted + + VcxStateType::VcxStateAccepted - received `Ack` - VcxStateType::VcxStateAccepted + + # Messages + + proprietary: + CredentialOffer (`CRED_OFFER`) + CredentialRequest (`CRED_REQ`) + Credential (`CRED`) + + aries: + CredentialProposal - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential#propose-credential + CredentialOffer - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential#offer-credential + CredentialRequest - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential#request-credential + Credential - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential#issue-credential + ProblemReport - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0035-report-problem#the-problem-report-message-type + Ack - https://github.com/hyperledger/aries-rfcs/tree/master/features/0015-acks#explicit-acks + """ def __init__(self, source_id: str, attrs: dict, cred_def_id: str, name: str, price: float): @@ -24,7 +90,9 @@ def __del__(self): @staticmethod async def create(source_id: str, attrs: dict, cred_def_handle: int, name: str, price: str): """ - Creates a Class representing an Issuer Credential + Create a Issuer Credential object that provides a credential for an enterprise's user + Assumes a credential definition has been already written to the ledger. + :param source_id: Tag associated by user of sdk :param attrs: attributes that will form the credential :param cred_def_handle: Handle from previously created credential def object @@ -59,7 +127,7 @@ async def create(source_id: str, attrs: dict, cred_def_handle: int, name: str, p @staticmethod async def deserialize(data: dict): """ - Creates IssuerCredential object from a dict. + Create a IssuerCredential object from a previously serialized object :param data: dict representing a serialized IssuerCredential Object :return: IssuerCredential object @@ -86,7 +154,7 @@ async def deserialize(data: dict): async def serialize(self) -> dict: """ - Serializes a issuer credential. + Serializes the issuer credential object for storage and later deserialization. Example: source_id = '1' @@ -104,7 +172,9 @@ async def serialize(self) -> dict: async def update_state(self) -> int: """ - Communicates with the agent service for polling and setting the state of the entity. + Query the agency for the received messages. + Checks for any messages changing state in the object and updates the state attribute. + Example: issuer_credential = await IssuerCredential.create(source_id, attrs, cred_def_id, name, price) issuer_credential.update_state() @@ -118,18 +188,22 @@ async def update_state_with_message(self, message: str) -> int: Example: cred = await IssuerCredential.create(source_id) assert await cred.update_state_with_message(message) == State.Accepted - :param message: + :param message: message to process for state changes :return Current state of the IssuerCredential """ return await self._update_state_with_message(IssuerCredential, message, 'vcx_issuer_credential_update_state_with_message') async def get_state(self) -> int: """ - Gets the state of the entity. + Get the current state of the issuer credential object Example: issuer_credential = await IssuerCredential.create(source_id, attrs, cred_def_id, name, price) issuer_credential.update_state() - :return: State of the Object + :return: State of the Object. Possible states: + 1 - Initialized + 2 - Offer Sent + 3 - Request Received + 4 - Issued """ return await self._get_state(IssuerCredential, 'vcx_issuer_credential_get_state') @@ -142,8 +216,8 @@ def release(self) -> None: async def send_offer(self, connection: Connection): """ - Sends an offer to a prover. Once accepted, a request will be recieved. - :param connection: vcx.api.connection.Connection + Send a credential offer to a holder showing what will be included in the actual credential + :param connection: Connection that identifies pairwise connection :return: None Example: @@ -172,8 +246,8 @@ async def send_offer(self, connection: Connection): async def get_offer_msg(self, connection: Connection): """ - Gets the offer message to send to specified connection. - :param connection: vcx.api.connection.Connection + Gets the offer message that can be sent to the specified connection + :param connection: Connection that identifies pairwise connection :return: None Example: @@ -204,8 +278,8 @@ async def get_offer_msg(self, connection: Connection): async def send_credential(self, connection: Connection): """ - Sends the credential to the end user (prover). - :param connection: Connection Object + Sends the credential to the end user (holder). + :param connection: Connection that identifies pairwise connection :return: None Example: credential.send_credential(connection) @@ -224,8 +298,8 @@ async def send_credential(self, connection: Connection): async def get_credential_msg(self, connection: Connection): """ - Get the credential to send to the end user (prover). - :param connection: Connection Object + Gets the credential message that can be sent to the user + :param connection: Connection that identifies pairwise connection :return: None Example: credential.send_credential(connection) @@ -263,10 +337,24 @@ async def revoke_credential(self): async def get_payment_txn(self): """ - Retrieve Payment Transaction that was used to pay for this Credential + Retrieve the payment transaction associated with this credential. This can be used to get the txn that + was used to pay the issuer from the prover. This could be considered a receipt of payment from the payer to + the issuer. + Example: txn = credential.get_payment_txn() - :return: + :return: payment transaction + { + "amount":25, + "inputs":[ + "pay:null:1_3FvPC7dzFbQKzfG", + "pay:null:1_lWVGKc07Pyc40m6" + ], + "outputs":[ + {"recipient":"pay:null:FrSVC3IrirScyRh","amount":5,"extra":null}, + {"recipient":"pov:null:OsdjtGKavZDBuG2xFw2QunVwwGs5IB3j","amount":25,"extra":null} + ] + } """ if not hasattr(IssuerCredential.get_payment_txn, "cb"): self.logger.debug("vcx_issuer_credential_get_payment_txn: Creating callback") diff --git a/vcx/wrappers/python3/vcx/api/proof.py b/vcx/wrappers/python3/vcx/api/proof.py index 58370d2dfb..d2eeb02896 100644 --- a/vcx/wrappers/python3/vcx/api/proof.py +++ b/vcx/wrappers/python3/vcx/api/proof.py @@ -6,6 +6,64 @@ import json class Proof(VcxStateful): + """ + The object of the VCX API representing a Verifier side in the credential presentation process. + Assumes that pairwise connection between Verifier and Prover is already established. + + # State + + The set of object states and transitions depends on communication method is used. + The communication method can be specified as config option on one of *_init function. The default communication method us `proprietary`. + + proprietary: + VcxStateType::VcxStateInitialized - once `vcx_proof_create` (create Proof object) is called. + + VcxStateType::VcxStateOfferSent - once `vcx_credential_send_request` (send `PROOF_REQ` message) is called. + + VcxStateType::VcxStateAccepted - once `PROOF` messages is received. + use `vcx_proof_update_state` or `vcx_proof_update_state_with_message` functions for state updates. + + aries: + VcxStateType::VcxStateInitialized - once `vcx_proof_create` (create Proof object) is called. + + VcxStateType::VcxStateOfferSent - once `vcx_credential_send_request` (send `PresentationRequest` message) is called. + + VcxStateType::VcxStateAccepted - once `Presentation` messages is received. + VcxStateType::None - once `ProblemReport` messages is received. + VcxStateType::None - once `PresentationProposal` messages is received. + VcxStateType::None - on `Presentation` validation failed. + use `vcx_proof_update_state` or `vcx_proof_update_state_with_message` functions for state updates. + + # Transitions + + proprietary: + VcxStateType::None - `vcx_proof_create` - VcxStateType::VcxStateInitialized + + VcxStateType::VcxStateInitialized - `vcx_credential_send_request` - VcxStateType::VcxStateOfferSent + + VcxStateType::VcxStateOfferSent - received `PROOF` - VcxStateType::VcxStateAccepted + + aries: RFC - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0037-present-proof#propose-presentation + VcxStateType::None - `vcx_proof_create` - VcxStateType::VcxStateInitialized + + VcxStateType::VcxStateInitialized - `vcx_credential_send_request` - VcxStateType::VcxStateOfferSent + + VcxStateType::VcxStateOfferSent - received `Presentation` - VcxStateType::VcxStateAccepted + VcxStateType::VcxStateOfferSent - received `PresentationProposal` - VcxStateType::None + VcxStateType::VcxStateOfferSent - received `ProblemReport` - VcxStateType::None + + # Messages + + proprietary: + ProofRequest (`PROOF_REQ`) + Proof (`PROOF`) + + aries: + PresentationRequest - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0037-present-proof#request-presentation + Presentation - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0037-present-proof#presentation + PresentationProposal - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0037-present-proof#propose-presentation + Ack - https://github.com/hyperledger/aries-rfcs/tree/master/features/0015-acks#explicit-acks + """ def __init__(self, source_id: str): VcxStateful.__init__(self, source_id) @@ -26,14 +84,44 @@ def proof_state(self, x): @staticmethod async def create(source_id: str, name: str, requested_attrs: list, revocation_interval: dict, requested_predicates: list = []): """ - Builds a generic proof object + Create a new Proof object that requests a proof for an enterprise :param source_id: Tag associated by user of sdk :param name: Name of the Proof :param requested_attrs: Attributes associated with the Proof + { + "name": Optional, // attribute name, (case insensitive and ignore spaces) + "names": Optional<[string, string]>, // attribute names, (case insensitive and ignore spaces) + // NOTE: should either be "name" or "names", not both and not none of them. + // Use "names" to specify several attributes that have to match a single credential. + "restrictions": (filter_json) { + "schema_id": string, (Optional) + "schema_issuer_did": string, (Optional) + "schema_name": string, (Optional) + "schema_version": string, (Optional) + "issuer_did": string, (Optional) + "cred_def_id": string, (Optional) + }, + "non_revoked": { + "from": Optional<(u64)> Requested time represented as a total number of seconds from Unix Epoch, Optional + "to": Optional<(u64)> + //Requested time represented as a total number of seconds from Unix Epoch, Optional + } + } + :param requested_predicates: Predicates associated with the Proof + { // set of requested predicates + "name": attribute name, (case insensitive and ignore spaces) + "p_type": predicate type (Currently ">=" only) + "p_value": int predicate value + "restrictions": Optional, // see above + "non_revoked": Optional<{ + "from": Optional<(u64)> Requested time represented as a total number of seconds from Unix Epoch, Optional + "to": Optional<(u64)> Requested time represented as a total number of seconds from Unix Epoch, Optional + }> + } :param revocation_interval: interval applied to all requested attributes indicating when the claim must be valid (NOT revoked) Example: name = "proof name" - requested_attrs = [{"name": "age", "restrictions": [{"schema_id": "6XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"Faber Student Info", "schema_version":"1.0", "schema_issuer_did":"6XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"8XFh8yBzrpJQmNyZzgoTqB", "cred_def_id": "8XFh8yBzrpJQmNyZzgoTqB:3:CL:1766" }, { "schema_id": "5XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"BYU Student Info", "schema_version":"1.0", "schema_issuer_did":"5XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"66Fh8yBzrpJQmNyZzgoTqB", "cred_def_id": "66Fh8yBzrpJQmNyZzgoTqB:3:CL:1766" } ] }, { "name":"name", "restrictions": [ { "schema_id": "6XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"Faber Student Info", "schema_version":"1.0", "schema_issuer_did":"6XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"8XFh8yBzrpJQmNyZzgoTqB", "cred_def_id": "8XFh8yBzrpJQmNyZzgoTqB:3:CL:1766" }, { "schema_id": "5XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"BYU Student Info", "schema_version":"1.0", "schema_issuer_did":"5XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"66Fh8yBzrpJQmNyZzgoTqB", "cred_def_id": "66Fh8yBzrpJQmNyZzgoTqB:3:CL:1766"}]}] + requested_attrs = [{"name": "age", "restrictions": [{"schema_id": "6XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"Faber Student Info", "schema_version":"1.0", "schema_issuer_did":"6XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"8XFh8yBzrpJQmNyZzgoTqB", "cred_def_id": "8XFh8yBzrpJQmNyZzgoTqB:3:CL:1766" }, { "schema_id": "5XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"BYU Student Info", "schema_version":"1.0", "schema_issuer_did":"5XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"66Fh8yBzrpJQmNyZzgoTqB", "cred_def_id": "66Fh8yBzrpJQmNyZzgoTqB:3:CL:1766" } ] }, { "names":["name", "male"], "restrictions": [ { "schema_id": "6XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"Faber Student Info", "schema_version":"1.0", "schema_issuer_did":"6XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"8XFh8yBzrpJQmNyZzgoTqB", "cred_def_id": "8XFh8yBzrpJQmNyZzgoTqB:3:CL:1766" }, { "schema_id": "5XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"BYU Student Info", "schema_version":"1.0", "schema_issuer_did":"5XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"66Fh8yBzrpJQmNyZzgoTqB", "cred_def_id": "66Fh8yBzrpJQmNyZzgoTqB:3:CL:1766"}]}] revocation_interval = {"from": 1, "to": 2} // Both values are optional proof = await Proof.create(source_id, name, requested_attrs) :return: Proof Object @@ -84,7 +172,8 @@ async def serialize(self) -> dict: async def update_state(self) -> int: """ - Communicates with the agent service for polling and setting the state of the entity. + Query the agency for the received messages. + Checks for any messages changing state in the object and updates the state attribute. Example: name = "proof name" requested_attrs = [{"name": "age", "restrictions": [{"schema_id": "6XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"Faber Student Info", "schema_version":"1.0", "schema_issuer_did":"6XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"8XFh8yBzrpJQmNyZzgoTqB", "cred_def_id": "8XFh8yBzrpJQmNyZzgoTqB:3:CL:1766" }, { "schema_id": "5XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"BYU Student Info", "schema_version":"1.0", "schema_issuer_did":"5XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"66Fh8yBzrpJQmNyZzgoTqB", "cred_def_id": "66Fh8yBzrpJQmNyZzgoTqB:3:CL:1766" } ] }, { "name":"name", "restrictions": [ { "schema_id": "6XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"Faber Student Info", "schema_version":"1.0", "schema_issuer_did":"6XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"8XFh8yBzrpJQmNyZzgoTqB", "cred_def_id": "8XFh8yBzrpJQmNyZzgoTqB:3:CL:1766" }, { "schema_id": "5XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"BYU Student Info", "schema_version":"1.0", "schema_issuer_did":"5XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"66Fh8yBzrpJQmNyZzgoTqB", "cred_def_id": "66Fh8yBzrpJQmNyZzgoTqB:3:CL:1766"}]}] @@ -100,7 +189,7 @@ async def update_state_with_message(self, message: str) -> int: Example: proof = await Proof.create(source_id) assert await proof.update_state_with_message(message) == State.Accepted - :param message: + :param message: message to process for state changes :return Current state of the Proof """ return await self._update_state_with_message(Connection, message, 'vcx_proof_update_state_with_message') @@ -113,7 +202,11 @@ async def get_state(self) -> int: requested_attrs = [{"name": "age", "restrictions": [{"schema_id": "6XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"Faber Student Info", "schema_version":"1.0", "schema_issuer_did":"6XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"8XFh8yBzrpJQmNyZzgoTqB", "cred_def_id": "8XFh8yBzrpJQmNyZzgoTqB:3:CL:1766" }, { "schema_id": "5XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"BYU Student Info", "schema_version":"1.0", "schema_issuer_did":"5XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"66Fh8yBzrpJQmNyZzgoTqB", "cred_def_id": "66Fh8yBzrpJQmNyZzgoTqB:3:CL:1766" } ] }, { "name":"name", "restrictions": [ { "schema_id": "6XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"Faber Student Info", "schema_version":"1.0", "schema_issuer_did":"6XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"8XFh8yBzrpJQmNyZzgoTqB", "cred_def_id": "8XFh8yBzrpJQmNyZzgoTqB:3:CL:1766" }, { "schema_id": "5XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"BYU Student Info", "schema_version":"1.0", "schema_issuer_did":"5XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"66Fh8yBzrpJQmNyZzgoTqB", "cred_def_id": "66Fh8yBzrpJQmNyZzgoTqB:3:CL:1766"}]}] proof = await Proof.create(source_id, name, requested_attrs) assert await proof.get_state() == State.Initialized - :return: StateType + :return: Possible states: + 1 - Initialized + 2 - Request Sent + 3 - Proof Received + 4 - Accepted """ return await self._get_state(Proof, 'vcx_proof_get_state') @@ -126,13 +219,15 @@ def release(self) -> None: async def get_proof_request_msg(self): """ + Gets the proof request message that can be sent to the specified connection Example: name = "proof name" requested_attrs = [{"name": "age", "restrictions": [{"schema_id": "6XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"Faber Student Info", "schema_version":"1.0", "schema_issuer_did":"6XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"8XFh8yBzrpJQmNyZzgoTqB", "cred_def_id": "8XFh8yBzrpJQmNyZzgoTqB:3:CL:1766" }, { "schema_id": "5XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"BYU Student Info", "schema_version":"1.0", "schema_issuer_did":"5XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"66Fh8yBzrpJQmNyZzgoTqB", "cred_def_id": "66Fh8yBzrpJQmNyZzgoTqB:3:CL:1766" } ] }, { "name":"name", "restrictions": [ { "schema_id": "6XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"Faber Student Info", "schema_version":"1.0", "schema_issuer_did":"6XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"8XFh8yBzrpJQmNyZzgoTqB", "cred_def_id": "8XFh8yBzrpJQmNyZzgoTqB:3:CL:1766" }, { "schema_id": "5XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"BYU Student Info", "schema_version":"1.0", "schema_issuer_did":"5XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"66Fh8yBzrpJQmNyZzgoTqB", "cred_def_id": "66Fh8yBzrpJQmNyZzgoTqB:3:CL:1766"}]}] proof = await Proof.create(source_id, name, requested_attrs) await proof.get_proof_request_msg() :param - :return: + :return: proof request message + {'@topic': {'tid': 0, 'mid': 0}, '@type': {'version': '1.0', 'name': 'PROOF_REQUEST'}, 'proof_request_data': {'name': 'proof_req', 'nonce': '118065925949165739229152', 'version': '0.1', 'requested_predicates': {}, 'non_revoked': None, 'requested_attributes': {'attribute_0': {'name': 'name', 'restrictions': {'$or': [{'issuer_did': 'did'}]}}}, 'ver': '1.0'}, 'thread_id': '40bdb5b2'} """ if not hasattr(Proof.get_proof_request_msg, "cb"): self.logger.debug("vcx_proof_send_request: Creating callback") @@ -148,6 +243,7 @@ async def get_proof_request_msg(self): async def request_proof(self, connection: Connection): """ + Sends a proof request message to the specified connection Example: connection = await Connection.create(source_id) await connection.connect(phone_number) @@ -155,7 +251,7 @@ async def request_proof(self, connection: Connection): requested_attrs = [{"name": "age", "restrictions": [{"schema_id": "6XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"Faber Student Info", "schema_version":"1.0", "schema_issuer_did":"6XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"8XFh8yBzrpJQmNyZzgoTqB", "cred_def_id": "8XFh8yBzrpJQmNyZzgoTqB:3:CL:1766" }, { "schema_id": "5XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"BYU Student Info", "schema_version":"1.0", "schema_issuer_did":"5XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"66Fh8yBzrpJQmNyZzgoTqB", "cred_def_id": "66Fh8yBzrpJQmNyZzgoTqB:3:CL:1766" } ] }, { "name":"name", "restrictions": [ { "schema_id": "6XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"Faber Student Info", "schema_version":"1.0", "schema_issuer_did":"6XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"8XFh8yBzrpJQmNyZzgoTqB", "cred_def_id": "8XFh8yBzrpJQmNyZzgoTqB:3:CL:1766" }, { "schema_id": "5XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"BYU Student Info", "schema_version":"1.0", "schema_issuer_did":"5XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"66Fh8yBzrpJQmNyZzgoTqB", "cred_def_id": "66Fh8yBzrpJQmNyZzgoTqB:3:CL:1766"}]}] proof = await Proof.create(source_id, name, requested_attrs) await proof.request_proof(connection) - :param connection: Connection + :param connection: Connection to send proof request :return: """ if not hasattr(Proof.request_proof, "cb"): @@ -172,6 +268,7 @@ async def request_proof(self, connection: Connection): async def get_proof(self, connection: Connection) -> list: """ + Gets the proof message Example: connection = await Connection.create(source_id) await connection.connect(phone_number) diff --git a/vcx/wrappers/python3/vcx/api/schema.py b/vcx/wrappers/python3/vcx/api/schema.py index e2bf68cde7..58885d38c6 100644 --- a/vcx/wrappers/python3/vcx/api/schema.py +++ b/vcx/wrappers/python3/vcx/api/schema.py @@ -114,6 +114,8 @@ async def prepare_for_endorser(source_id: str, name: str, version: str, attrs: l """ Create a new Schema object that will be published by Endorser later. + Note that CredentialDef can't be used for credential issuing until it will be published on the ledger. + :param source_id: Institution's unique ID for the schema :param name: Name of schema :param version: Version of the schema @@ -281,7 +283,7 @@ async def get_schema_id(self): async def get_payment_txn(self): """ - Get the payment transaction information generated when paying the ledger fee + Retrieve the txn associated with paying for the schema Example: source_id = 'foobar123' @@ -292,6 +294,15 @@ async def get_payment_txn(self): schema1 = await Schema.create(source_id, name, version, attrs, payment_handle) txn = await schema1.get_payment_txn() :return: JSON object with input address and output UTXOs + { + "amount":25, + "inputs":[ + "pay:null:1_3FvPC7dzFbQKzfG" + ], + "outputs":[ + {"recipient":"pay:null:FrSVC3IrirScyRh","amount":5,"extra":null} + ] + } """ if not hasattr(Schema.get_payment_txn, "cb"): self.logger.debug("vcx_schema_get_payment_txn: Creating callback") @@ -308,7 +319,10 @@ async def get_payment_txn(self): async def update_state(self) -> int: """ - Checks if schema is published on the Ledger and updates the the state + Checks if schema is published on the Ledger and updates the state + Possible states: + 0 = Built + 1 = Published Example: source_id = 'foobar123' name = 'Address Schema' @@ -325,6 +339,9 @@ async def update_state(self) -> int: async def get_state(self) -> int: """ Get the current state of the schema object + Possible states: + 0 = Built + 1 = Published Example: source_id = 'foobar123' name = 'Address Schema' diff --git a/vcx/wrappers/python3/vcx/api/utils.py b/vcx/wrappers/python3/vcx/api/utils.py index 3a83317d54..00911ecdf0 100644 --- a/vcx/wrappers/python3/vcx/api/utils.py +++ b/vcx/wrappers/python3/vcx/api/utils.py @@ -68,6 +68,7 @@ async def vcx_ledger_get_fees() -> str: Example: fees = await vcx_ledger_get_fees() :return: JSON representing fees + { "txnType1": amount1, "txnType2": amount2, ..., "txnTypeN": amountN } """ logger = logging.getLogger(__name__) @@ -84,11 +85,19 @@ async def vcx_ledger_get_fees() -> str: async def vcx_messages_download(status: str = None, uids: str = None, pw_dids: str = None) -> str: """ - Retrieve messages from the specified connection - :param status: - :param uids: - :param pw_dids: - :return: + Retrieve messages from the agent + :param status: optional, comma separated - query for messages with the specified status. + Possible statuses: + MS-101 - Created + MS-102 - Sent + MS-103 - Received + MS-104 - Accepted + MS-105 - Rejected + MS-106 - Reviewed + :param uids: optional, comma separated - query for messages with the specified uids + :param pw_dids: optional, comma separated - DID's pointing to specific connection + :return: message + [{"pairwiseDID":"did","msgs":[{"statusCode":"MS-106","payload":null,"senderDID":"","uid":"6BDkgc3z0E","type":"aries","refMsgId":null,"deliveryDetails":[],"decryptedPayload":"{"@msg":".....","@type":{"fmt":"json","name":"aries","ver":"1.0"}}"}]}] """ logger = logging.getLogger(__name__) @@ -124,7 +133,14 @@ async def vcx_messages_download(status: str = None, uids: str = None, pw_dids: s async def vcx_messages_update_status(msg_json: str): """ Update the status of messages from the specified connection - :param msg_json: + :param msg_json: messages to update: + [ + { + "pairwiseDID":"string", + "uids":["string"] + }, + ... + ] :return: """ logger = logging.getLogger(__name__) @@ -157,8 +173,8 @@ def vcx_pool_set_handle(handle: int) -> None: async def vcx_get_ledger_author_agreement(): """ - Retrieve author agreement set on the Ledger - :return: + Retrieve author agreement and acceptance mechanisms set on the Ledger + :return: {"text":"Default agreement", "version":"1.0.0", "aml": {"label1": "description"}} """ logger = logging.getLogger(__name__) @@ -177,6 +193,19 @@ def vcx_set_active_txn_author_agreement_meta(text: Optional[str], hash: Optional[str], acc_mech_type: str, time_of_acceptance: int) -> None: + """ + Set some accepted agreement as active. + As result of successful call of this function appropriate metadata will be appended to each write request. + + :param text and version - (optional) raw data about TAA from ledger. + These parameters should be passed together. + These parameters are required if hash parameter is ommited. + :param hash - (optional) hash on text and version. This parameter is required if text and version parameters are ommited. + :param acc_mech_type - mechanism how user has accepted the TAA + :param time_of_acceptance - UTC timestamp when user has accepted the TAA + + :return: no value + """ logger = logging.getLogger(__name__) name = 'vcx_set_active_txn_author_agreement_meta' diff --git a/vcx/wrappers/python3/vcx/api/vcx_init.py b/vcx/wrappers/python3/vcx/api/vcx_init.py index 66559758e1..60e4b62f41 100644 --- a/vcx/wrappers/python3/vcx/api/vcx_init.py +++ b/vcx/wrappers/python3/vcx/api/vcx_init.py @@ -7,7 +7,9 @@ async def vcx_init(config_path: str) -> None: """ Initializes VCX with config file. - :param config_path: String + The list of available options see here: https://github.com/hyperledger/indy-sdk/blob/master/docs/configuration.md + + :param config_path: String - path to a config file to populate config attributes Example: await vcx_init('/home/username/vcxconfig.json') :return: @@ -30,8 +32,11 @@ async def vcx_init(config_path: str) -> None: async def vcx_init_with_config(config: str) -> None: """ + Initializes VCX with config settings + + :param config: config as json. + The list of available options see here: https://github.com/hyperledger/indy-sdk/blob/master/docs/configuration.md - :param config: Example: config = { "agency_did": "VsKV7grR1BUE29mG2Fm2kX", diff --git a/vcx/wrappers/python3/vcx/api/wallet.py b/vcx/wrappers/python3/vcx/api/wallet.py index 7a3a00ec2a..c8505a25ad 100644 --- a/vcx/wrappers/python3/vcx/api/wallet.py +++ b/vcx/wrappers/python3/vcx/api/wallet.py @@ -361,7 +361,8 @@ async def get_token_info(handle: int) -> str: Example: payment_handle = 0 // payment handle is always 0, for now. info = await Wallet.get_token_info(payment_handle) - :return: + :return: info + "{"balance":6,"balance_str":"6","addresses":[{"address":"pay:null:9UFgyjuJxi1i1HD","balance":3,"utxo":[{"source":"pay:null:1","paymentAddress":"pay:null:zR3GN9lfbCVtHjp","amount":1,"extra":"yqeiv5SisTeUGkw"}]}]}" """ logger = logging.getLogger(__name__) diff --git a/wrappers/dotnet/indy-sdk-dotnet/DidApi/Did.cs b/wrappers/dotnet/indy-sdk-dotnet/DidApi/Did.cs index 14ee47a604..2e8cce3a48 100644 --- a/wrappers/dotnet/indy-sdk-dotnet/DidApi/Did.cs +++ b/wrappers/dotnet/indy-sdk-dotnet/DidApi/Did.cs @@ -322,7 +322,9 @@ public static Task ReplaceKeysApplyAsync(Wallet wallet, string did) /// /// { /// "did": string, (required) - /// "verkey": string (optional, can be avoided if did is cryptonym: did == verkey), + /// "verkey": string + /// - optional is case of adding a new DID, and DID is cryptonym: did == verkey, + /// - mandatory in case of updating an existing DID /// } /// /// The did member specifies the DID to store. This value is required. diff --git a/wrappers/ios/libindy-pod/Indy-demoTests/Test Utils/WalletUtils.m b/wrappers/ios/libindy-pod/Indy-demoTests/Test Utils/WalletUtils.m index 524d92207f..1aa8a4e189 100644 --- a/wrappers/ios/libindy-pod/Indy-demoTests/Test Utils/WalletUtils.m +++ b/wrappers/ios/libindy-pod/Indy-demoTests/Test Utils/WalletUtils.m @@ -129,7 +129,7 @@ - (NSError *)closeWalletWithHandle:(IndyHandle)walletHandle { [completionExpectation fulfill]; }]; - [self waitForExpectations:@[completionExpectation] timeout:[TestUtils shortTimeout]]; + [self waitForExpectations:@[completionExpectation] timeout:[TestUtils defaultTimeout]]; return err; } diff --git a/wrappers/ios/libindy-pod/Indy/Wrapper/IndyAnoncreds.h b/wrappers/ios/libindy-pod/Indy/Wrapper/IndyAnoncreds.h index 71400c7cf3..de21a0b7d5 100644 --- a/wrappers/ios/libindy-pod/Indy/Wrapper/IndyAnoncreds.h +++ b/wrappers/ios/libindy-pod/Indy/Wrapper/IndyAnoncreds.h @@ -555,7 +555,10 @@ And is documented in this HIPE: attr_referent: Proof-request local identifier of requested attribute attr_info: Describes requested attribute { - "name": string, // attribute name, (case insensitive and ignore spaces) + "name": Optional, // attribute name, (case insensitive and ignore spaces) + "names": Optional<[string, string]>, // attribute names, (case insensitive and ignore spaces) + // NOTE: should either be "name" or "names", not both and not none of them. + // Use "names" to specify several attributes that have to match a single credential. "restrictions": Optional, // see below "non_revoked": Optional<>, // see below, // If specified prover must proof non-revocation @@ -653,8 +656,11 @@ And is documented in this HIPE: attr_info: Describes requested attribute { - "name": string, // attribute name, (case insensitive and ignore spaces) - "restrictions": Optional, // see below + "name": Optional, // attribute name, (case insensitive and ignore spaces) + "names": Optional<[string, string]>, // attribute names, (case insensitive and ignore spaces) + // NOTE: should either be "name" or "names", not both and not none of them. + // Use "names" to specify several attributes that have to match a single credential. + "restrictions": Optional, // see below "non_revoked": Optional<>, // see below, // If specified prover must proof non-revocation // for date in this interval this attribute @@ -824,14 +830,17 @@ And is documented in this HIPE: where attr_referent: Proof-request local identifier of requested attribute attr_info: Describes requested attribute - { - "name": string, // attribute name, (case insensitive and ignore spaces) - "restrictions": Optional, // see below - "non_revoked": Optional<>, // see below, - // If specified prover must proof non-revocation - // for date in this interval this attribute - // (overrides proof level interval) - } + { + "name": Optional, // attribute name, (case insensitive and ignore spaces) + "names": Optional<[string, string]>, // attribute names, (case insensitive and ignore spaces) + // NOTE: should either be "name" or "names", not both and not none of them. + // Use "names" to specify several attributes that have to match a single credential. + "restrictions": Optional, // see below + "non_revoked": Optional<>, // see below, + // If specified prover must proof non-revocation + // for date in this interval this attribute + // (overrides proof level interval) + } predicate_referent: Proof-request local identifier of requested attribute predicate predicate_info: Describes requested attribute predicate { @@ -877,6 +886,17 @@ And is documented in this HIPE: "requested_attr1_id": {sub_proof_index: number, raw: string, encoded: string}, "requested_attr4_id": {sub_proof_index: number: string, encoded: string}, }, + "revealed_attr_groups": { + "requested_attr5_id": { + "sub_proof_index": number, + "values": { + "attribute_name": { + "raw": string, + "encoded": string + } + }, + } + }, "unrevealed_attrs": { "requested_attr3_id": {sub_proof_index: number} }, @@ -941,6 +961,17 @@ And is documented in this HIPE: "requested_attr1_id": {sub_proof_index: number, raw: string, encoded: string}, // NOTE: check that `encoded` value match to `raw` value on application level "requested_attr4_id": {sub_proof_index: number: string, encoded: string}, // NOTE: check that `encoded` value match to `raw` value on application level }, + "revealed_attr_groups": { + "requested_attr5_id": { + "sub_proof_index": number, + "values": { + "attribute_name": { + "raw": string, + "encoded": string + } + }, // NOTE: check that `encoded` value match to `raw` value on application level + } + }, "unrevealed_attrs": { "requested_attr3_id": {sub_proof_index: number} }, @@ -978,24 +1009,27 @@ And is documented in this HIPE: } @param revocRegsJSON: all revocation registries json participating in the proof { - "rev_reg_def1_id": { + "rev_reg_def1_id or credential_1_id": { "timestamp1": , "timestamp2": , }, - "rev_reg_def2_id": { + "rev_reg_def2_id" or credential_3_id: { "timestamp3": }, - "rev_reg_def3_id": { + "rev_reg_def3_id or credential_3_id": { "timestamp4": }, - } + } - Note: use credential_id instead rev_reg_id in case proving several credentials from the same revocation registry. where attr_referent: Proof-request local identifier of requested attribute attr_info: Describes requested attribute { - "name": string, // attribute name, (case insensitive and ignore spaces) - "restrictions": Optional, // see below + "name": Optional, // attribute name, (case insensitive and ignore spaces) + "names": Optional<[string, string]>, // attribute names, (case insensitive and ignore spaces) + // NOTE: should either be "name" or "names", not both and not none of them. + // Use "names" to specify several attributes that have to match a single credential. + "restrictions": Optional, // see below "non_revoked": Optional<>, // see below, // If specified prover must proof non-revocation // for date in this interval this attribute @@ -1040,12 +1074,19 @@ And is documented in this HIPE: completion:(void (^)(NSError *error, BOOL valid))completion; /** - Create revocation state for a credential in the particular time moment. + Create revocation state for a credential that corresponds to a particular time. + + Note that revocation delta must cover the whole registry existence time. + You can use `from`: `0` and `to`: `needed_time` as parameters for building request to get correct revocation delta. + + The resulting revocation state and provided timestamp can be saved and reused later with applying a new + revocation delta with `updateRevocationState` function. + This new delta should be received with parameters: `from`: `timestamp` and `to`: `needed_time`. @param credRevID: user credential revocation id in revocation registry @param timestamp: time represented as a total number of seconds from Unix Epoch @param revRegDefJSON: revocation registry definition json - @param revRegDeltaJSON: revocation registry definition delta json + @param revRegDeltaJSON: revocation registry definition delta which covers the whole registry existence time @param blobStorageReaderHandle: configuration of blob storage reader handle that will allow to read revocation tails @param completion Callback that takes command result as parameter. Returns result revocation state json: @@ -1064,13 +1105,19 @@ And is documented in this HIPE: completion:(void (^)(NSError *error, NSString *revStateJSON))completion; /** - Create new revocation state for a credential based on existed state at the particular time moment (to reduce calculation time). + Create a new revocation state for a credential based on a revocation state created before. + Note that provided revocation delta must cover the registry gap from based state creation until the specified time + (this new delta should be received with parameters: `from`: `state_timestamp` and `to`: `needed_time`). + + This function reduces the calculation time. + + The resulting revocation state and provided timestamp can be saved and reused later by applying a new revocation delta again. @param revStateJSON: revocation registry state json @param credRevID: user credential revocation id in revocation registry @param timestamp: time represented as a total number of seconds from Unix Epoch @param revRegDefJSON: revocation registry definition json - @param revRegDeltaJSON: revocation registry definition delta json + @param revRegDeltaJSON: revocation registry definition delta which covers the gap form original `rev_state_json` creation till the requested timestamp @param blobStorageReaderHandle: configuration of blob storage reader handle that will allow to read revocation tails @param completion Callback that takes command result as parameter. Returns result revocation state json: diff --git a/wrappers/ios/libindy-pod/Indy/Wrapper/IndyDid.h b/wrappers/ios/libindy-pod/Indy/Wrapper/IndyDid.h index 1c4a3871f7..75f8169978 100644 --- a/wrappers/ios/libindy-pod/Indy/Wrapper/IndyDid.h +++ b/wrappers/ios/libindy-pod/Indy/Wrapper/IndyDid.h @@ -82,6 +82,7 @@ /** Saves their DID for a pairwise connection in a secured Wallet, so that it can be used to verify transaction. + Updates DID associated verkey in case DID already exists in the Wallet. @code { @@ -93,6 +94,12 @@ @endcode @param identityJSON Identity information as json. See example above. + { + "did": string, (required) + "verkey": string + - optional is case of adding a new DID, and DID is cryptonym: did == verkey, + - mandatory in case of updating an existing DID + } @param walletHandle Wallet handler (created by IndyWallet::OpenWalletWithName). @param completion Callback that takes command result as parameter.Returns error code. */ diff --git a/wrappers/ios/libindy-pod/Indy/Wrapper/IndyPool.h b/wrappers/ios/libindy-pod/Indy/Wrapper/IndyPool.h index 882adc83dd..45d812d83a 100644 --- a/wrappers/ios/libindy-pod/Indy/Wrapper/IndyPool.h +++ b/wrappers/ios/libindy-pod/Indy/Wrapper/IndyPool.h @@ -42,10 +42,15 @@ { "timeout": int (optional), Timeout for network request (in sec). "extended_timeout": int (optional), Extended timeout for network request (in sec). - "preordered_nodes": array (optional), Names of nodes which will have a priority during request sending: - [ "name_of_1st_prior_node", "name_of_2nd_prior_node", .... ] - Note: Not specified nodes will be placed in a random way. + "preordered_nodes": array - (optional), names of nodes which will have a priority during request sending: + ["name_of_1st_prior_node", "name_of_2nd_prior_node", .... ] + This can be useful if a user prefers querying specific nodes. + Assume that `Node1` and `Node2` nodes reply faster. + If you pass them Libindy always sends a read request to these nodes first and only then (if not enough) to others. + Note: Nodes not specified will be placed randomly. "number_read_nodes": int (optional) - the number of nodes to send read requests (2 by default) + By default Libindy sends a read requests to 2 nodes in the pool. + If response isn't received or `state proof` is invalid Libindy sends the request again but to 2 (`number_read_nodes`) * 2 = 4 nodes and so far until completion. } @endcode diff --git a/wrappers/java/pom.xml b/wrappers/java/pom.xml index 7a6f7f1006..326bd956a3 100644 --- a/wrappers/java/pom.xml +++ b/wrappers/java/pom.xml @@ -5,7 +5,7 @@ org.hyperledger indy jar - 1.14.1 + 1.14.2 indy This is the official SDK for Hyperledger Indy (https://www.hyperledger.org/projects), which provides a distributed-ledger-based foundation for self-sovereign identity (https://sovrin.org). diff --git a/wrappers/java/src/main/java/org/hyperledger/indy/sdk/anoncreds/Anoncreds.java b/wrappers/java/src/main/java/org/hyperledger/indy/sdk/anoncreds/Anoncreds.java index 31a7d79e49..7062de04eb 100644 --- a/wrappers/java/src/main/java/org/hyperledger/indy/sdk/anoncreds/Anoncreds.java +++ b/wrappers/java/src/main/java/org/hyperledger/indy/sdk/anoncreds/Anoncreds.java @@ -1043,8 +1043,11 @@ public static CompletableFuture proverDeleteCredential( * attr_referent: Proof-request local identifier of requested attribute * attr_info: Describes requested attribute * { - * "name": string, // attribute name, (case insensitive and ignore spaces) - * "restrictions": Optional, // see below + * "name": Optional, // attribute name, (case insensitive and ignore spaces) + * "names": Optional<[string, string]>, // attribute names, (case insensitive and ignore spaces) + * // NOTE: should either be "name" or "names", not both and not none of them. + * // Use "names" to specify several attributes that have to match a single credential. + * "restrictions": Optional, // see below * "non_revoked": Optional<>, // see below, * // If specified prover must proof non-revocation * // for date in this interval this attribute @@ -1177,22 +1180,25 @@ public static CompletableFuture proverGetCredentialsForProofReq( * } * @param revStates All revocation states json participating in the proof request * { - * "rev_reg_def1_id": { + * "rev_reg_def1_id or credential_1_id": { * "timestamp1": {rev_state1}, * "timestamp2": {rev_state2}, * }, - * "rev_reg_def2_id": { + * "rev_reg_def2_id or credential_2_id": { * "timestamp3": {rev_state3} * }, - * "rev_reg_def3_id": { + * "rev_reg_def3_id or credential_3_id": { * "timestamp4": {rev_state4} * }, - * } + * } - Note: use credential_id instead rev_reg_id in case proving several credentials from the same revocation registry. * where * attr_referent: Proof-request local identifier of requested attribute * attr_info: Describes requested attribute * { - * "name": string, // attribute name, (case insensitive and ignore spaces) + * "name": Optional, // attribute name, (case insensitive and ignore spaces) + * "names": Optional<[string, string]>, // attribute names, (case insensitive and ignore spaces) + * // NOTE: should either be "name" or "names", not both and not none of them. + * // Use "names" to specify several attributes that have to match a single credential. * "restrictions": Optional, // see below * "non_revoked": Optional<>, // see below, * // If specified prover must proof non-revocation @@ -1237,6 +1243,17 @@ public static CompletableFuture proverGetCredentialsForProofReq( * "requested_attr1_id": {sub_proof_index: number, raw: string, encoded: string}, * "requested_attr4_id": {sub_proof_index: number: string, encoded: string}, * }, + * "revealed_attr_groups": { + * "requested_attr5_id": { + * "sub_proof_index": number, + * "values": { + * "attribute_name": { + * "raw": string, + * "encoded": string + * } + * }, + * } + * }, * "unrevealed_attrs": { * "requested_attr3_id": {sub_proof_index: number} * }, @@ -1331,6 +1348,17 @@ public static CompletableFuture proverCreateProof( * "requested_attr1_id": {sub_proof_index: number, raw: string, encoded: string}, // NOTE: check that `encoded` value match to `raw` value on application level * "requested_attr4_id": {sub_proof_index: number: string, encoded: string}, // NOTE: check that `encoded` value match to `raw` value on application level * }, + * "revealed_attr_groups": { + * "requested_attr5_id": { + * "sub_proof_index": number, + * "values": { + * "attribute_name": { + * "raw": string, + * "encoded": string + * } + * }, // NOTE: check that `encoded` value match to `raw` value on application level + * } + * }, * "unrevealed_attrs": { * "requested_attr3_id": {sub_proof_index: number} * }, @@ -1416,11 +1444,18 @@ public static CompletableFuture verifierVerifyProof( } /** - * Create revocation state for credential in the particular time moment. + * Create revocation state for a credential that corresponds to a particular time. + * + * Note that revocation delta must cover the whole registry existence time. + * You can use `from`: `0` and `to`: `needed_time` as parameters for building request to get correct revocation delta. + * + * The resulting revocation state and provided timestamp can be saved and reused later with applying a new + * revocation delta with `updateRevocationState` function. + * This new delta should be received with parameters: `from`: `timestamp` and `to`: `needed_time`. * * @param blobStorageReaderHandle Configuration of blob storage reader handle that will allow to read revocation tails * @param revRegDef Revocation registry definition json - * @param revRegDelta Revocation registry definition delta json + * @param revRegDelta Revocation registry delta which covers the whole registry existence time * @param timestamp Time represented as a total number of seconds from Unix Epoch * @param credRevId user credential revocation id in revocation registry * @return A future that resolves to a revocation state json: @@ -1460,13 +1495,18 @@ public static CompletableFuture createRevocationState( } /** - * Create new revocation state for a credential based on already state - * at the particular time moment (to reduce calculation time). + * Create a new revocation state for a credential based on a revocation state created before. + * Note that provided revocation delta must cover the registry gap from based state creation until the specified time + * (this new delta should be received with parameters: `from`: `state_timestamp` and `to`: `needed_time`). + * + * This function reduces the calculation time. + * + * The resulting revocation state and provided timestamp can be saved and reused later by applying a new revocation delta again. * * @param blobStorageReaderHandle Configuration of blob storage reader handle that will allow to read revocation tails * @param revState Rrevocation registry state json * @param revRegDef Revocation registry definition json - * @param revRegDelta Revocation registry definition delta json + * @param revRegDelta Revocation registry definition delta which covers the gap form original `rev_state_json` creation till the requested timestamp * @param timestamp Time represented as a total number of seconds from Unix Epoch * @param credRevId user credential revocation id in revocation registry * @return A future that resolves to a revocation state json: diff --git a/wrappers/java/src/main/java/org/hyperledger/indy/sdk/did/Did.java b/wrappers/java/src/main/java/org/hyperledger/indy/sdk/did/Did.java index 646bbb4fa9..22802a2e23 100644 --- a/wrappers/java/src/main/java/org/hyperledger/indy/sdk/did/Did.java +++ b/wrappers/java/src/main/java/org/hyperledger/indy/sdk/did/Did.java @@ -342,9 +342,17 @@ public static CompletableFuture replaceKeysApply( /** * Saves their DID for a pairwise connection in a secured Wallet so that it can be used to verify transaction. + * Updates DID associated verkey in case DID already exists in the Wallet. * * @param wallet The wallet. * @param identityJson Identity information as json. + * { + * "did": string, (required) + * "verkey": string + * - optional is case of adding a new DID, and DID is cryptonym: did == verkey, + * - mandatory in case of updating an existing DID + * } + * * @return A future that does not resolve any value. * @throws IndyException Thrown if an error occurs when calling the underlying SDK. */ diff --git a/wrappers/java/src/main/java/org/hyperledger/indy/sdk/pool/Pool.java b/wrappers/java/src/main/java/org/hyperledger/indy/sdk/pool/Pool.java index 4a625af2b1..e5a6eaa4da 100644 --- a/wrappers/java/src/main/java/org/hyperledger/indy/sdk/pool/Pool.java +++ b/wrappers/java/src/main/java/org/hyperledger/indy/sdk/pool/Pool.java @@ -115,10 +115,15 @@ public static CompletableFuture createPoolLedgerConfig( * { * "timeout": int (optional), timeout for network request (in sec). * "extended_timeout": int (optional), extended timeout for network request (in sec). - * "preordered_nodes": array[string] - (optional), names of nodes which will have a priority during request sending: - * [ "name_of_1st_prior_node", "name_of_2nd_prior_node", .... ] - * Note: Not specified nodes will be placed in a random way. + * "preordered_nodes": array(string) - (optional), names of nodes which will have a priority during request sending: + * ["name_of_1st_prior_node", "name_of_2nd_prior_node", .... ] + * This can be useful if a user prefers querying specific nodes. + * Assume that `Node1` and `Node2` nodes reply faster. + * If you pass them Libindy always sends a read request to these nodes first and only then (if not enough) to others. + * Note: Nodes not specified will be placed randomly. * "number_read_nodes": int (optional) - the number of nodes to send read requests (2 by default) + * By default Libindy sends a read requests to 2 nodes in the pool. + * If response isn't received or `state proof` is invalid Libindy sends the request again but to 2 (`number_read_nodes`) * 2 = 4 nodes and so far until completion. * } * * @return A future that resolves to an opened Pool instance. diff --git a/wrappers/nodejs/README.md b/wrappers/nodejs/README.md index 3c70ad9340..367bafcfff 100644 --- a/wrappers/nodejs/README.md +++ b/wrappers/nodejs/README.md @@ -546,7 +546,36 @@ Use <proverSearchCredentialsForProofReq> to fetch records by small batches - "1.0" to use unqualified identifiers for restrictions - "2.0" to use fully qualified identifiers for restrictions } -where +where: + attr_info: Describes requested attribute + { + "name": Optional, // attribute name, (case insensitive and ignore spaces) + "names": Optional<[string, string]>, // attribute names, (case insensitive and ignore spaces) + // NOTE: should either be "name" or "names", not both and not none of them. + // Use "names" to specify several attributes that have to match a single credential. + "restrictions": Optional, // see below + "non_revoked": Optional<>, // see below, + // If specified prover must proof non-revocation + // for date in this interval this attribute + // (overrides proof level interval) + } + predicate_referent: Proof-request local identifier of requested attribute predicate + predicate_info: Describes requested attribute predicate + { + "name": attribute name, (case insensitive and ignore spaces) + "p_type": predicate type (">=", ">", "<=", "<") + "p_value": predicate value + "restrictions": Optional, // see below + "non_revoked": Optional<>, // see below, + // If specified prover must proof non-revocation + // for date in this interval this attribute + // (overrides proof level interval) + } + non_revoc_interval: Defines non-revocation interval + { + "from": Optional, // timestamp of interval beginning + "to": Optional, // timestamp of interval ending + } ```` * __->__ `credentials`: Json - credentials\_json: json with credentials for the given proof request. ``` @@ -604,6 +633,36 @@ to fetch records by small batches \(with proverFetchCredentialsForProofReq\). - "1.0" to use unqualified identifiers for restrictions - "2.0" to use fully qualified identifiers for restrictions } +where: + attr_info: Describes requested attribute + { + "name": Optional, // attribute name, (case insensitive and ignore spaces) + "names": Optional<[string, string]>, // attribute names, (case insensitive and ignore spaces) + // NOTE: should either be "name" or "names", not both and not none of them. + // Use "names" to specify several attributes that have to match a single credential. + "restrictions": Optional, // see below + "non_revoked": Optional<>, // see below, + // If specified prover must proof non-revocation + // for date in this interval this attribute + // (overrides proof level interval) + } + predicate_referent: Proof-request local identifier of requested attribute predicate + predicate_info: Describes requested attribute predicate + { + "name": attribute name, (case insensitive and ignore spaces) + "p_type": predicate type (">=", ">", "<=", "<") + "p_value": predicate value + "restrictions": Optional, // see below + "non_revoked": Optional<>, // see below, + // If specified prover must proof non-revocation + // for date in this interval this attribute + // (overrides proof level interval) + } + non_revoc_interval: Defines non-revocation interval + { + "from": Optional, // timestamp of interval beginning + "to": Optional, // timestamp of interval ending + } ```` * `extraQuery`: Json - \(Optional\) List of extra queries that will be applied to correspondent attribute\/predicate: ``` @@ -695,6 +754,36 @@ The proof contains either proof or self-attested attribute value for each reques - "1.0" to use unqualified identifiers for restrictions - "2.0" to use fully qualified identifiers for restrictions } +where: + attr_info: Describes requested attribute + { + "name": Optional, // attribute name, (case insensitive and ignore spaces) + "names": Optional<[string, string]>, // attribute names, (case insensitive and ignore spaces) + // NOTE: should either be "name" or "names", not both and not none of them. + // Use "names" to specify several attributes that have to match a single credential. + "restrictions": Optional, // see below + "non_revoked": Optional<>, // see below, + // If specified prover must proof non-revocation + // for date in this interval this attribute + // (overrides proof level interval) + } + predicate_referent: Proof-request local identifier of requested attribute predicate + predicate_info: Describes requested attribute predicate + { + "name": attribute name, (case insensitive and ignore spaces) + "p_type": predicate type (">=", ">", "<=", "<") + "p_value": predicate value + "restrictions": Optional, // see below + "non_revoked": Optional<>, // see below, + // If specified prover must proof non-revocation + // for date in this interval this attribute + // (overrides proof level interval) + } + non_revoc_interval: Defines non-revocation interval + { + "from": Optional, // timestamp of interval beginning + "to": Optional, // timestamp of interval ending + } ```` * `requestedCredentials`: Json - either a credential or self-attested attribute for each requested attribute ``` @@ -731,17 +820,17 @@ The proof contains either proof or self-attested attribute value for each reques * `revStates`: Json - all revocation states json participating in the proof request ``` { - "rev_reg_def1_id": { + "rev_reg_def1_id or credential_1_id"": { "timestamp1": , "timestamp2": , }, - "rev_reg_def2_id": { + "rev_reg_def2_id or credential_2_id"": { "timestamp3": }, - "rev_reg_def3_id": { + "rev_reg_def3_id or credential_3_id"": { "timestamp4": }, - } + } - Note: use credential_id instead rev_reg_id in case proving several credentials from the same revocation registry. where where wql query: indy-sdk/docs/design/011-wallet-query-language/README.md ```` @@ -757,6 +846,17 @@ There is also aggregated proof part common for all credential proofs. "requested_attr1_id": {sub_proof_index: number, raw: string, encoded: string}, "requested_attr4_id": {sub_proof_index: number: string, encoded: string}, }, + "revealed_attr_groups": { + "requested_attr5_id": { + "sub_proof_index": number, + "values": { + "attribute_name": { + "raw": string, + "encoded": string + } + }, + } + }, "unrevealed_attrs": { "requested_attr3_id": {sub_proof_index: number} }, @@ -816,8 +916,19 @@ as the keys for corresponding `schemas`, `credentialDefsJsons`, `revRegDefs`, `r { "requested_proof": { "revealed_attrs": { - "requested_attr1_id": {sub_proof_index: number, raw: string, encoded: string}, - "requested_attr4_id": {sub_proof_index: number: string, encoded: string}, + "requested_attr1_id": {sub_proof_index: number, raw: string, encoded: string}, // NOTE: check that `encoded` value match to `raw` value on application level + "requested_attr4_id": {sub_proof_index: number: string, encoded: string}, // NOTE: check that `encoded` value match to `raw` value on application level + }, + "revealed_attr_groups": { + "requested_attr5_id": { + "sub_proof_index": number, + "values": { + "attribute_name": { + "raw": string, + "encoded": string + } + }, // NOTE: check that `encoded` value match to `raw` value on application level + } }, "unrevealed_attrs": { "requested_attr3_id": {sub_proof_index: number} @@ -875,11 +986,18 @@ Errors: `Annoncreds*`, `Common*`, `Wallet*` #### createRevocationState \( blobStorageReaderHandle, revRegDef, revRegDelta, timestamp, credRevId \) -> revState -Create revocation state for a credential in the particular time moment. +Create revocation state for a credential that corresponds to a particular time. + +Note that revocation delta must cover the whole registry existence time. +You can use `from`: `0` and `to`: `needed_time` as parameters for building request to get correct revocation delta. + +The resulting revocation state and provided timestamp can be saved and reused later with applying a new +revocation delta with `updateRevocationState` function. +This new delta should be received with parameters: `from`: `timestamp` and `to`: `needed_time`. * `blobStorageReaderHandle`: Handle (Number) - configuration of blob storage reader handle that will allow to read revocation tails * `revRegDef`: Json - revocation registry definition json -* `revRegDelta`: Json - revocation registry definition delta json +* `revRegDelta`: Json - revocation registry delta which covers the whole registry existence time * `timestamp`: Timestamp (Number) - time represented as a total number of seconds from Unix Epoch * `credRevId`: String - user credential revocation id in revocation registry * __->__ `revState`: Json - revocation state json: @@ -895,13 +1013,18 @@ Errors: `Common*`, `Wallet*`, `Anoncreds*` #### updateRevocationState \( blobStorageReaderHandle, revState, revRegDef, revRegDelta, timestamp, credRevId \) -> updatedRevState -Create new revocation state for a credential based on existed state -at the particular time moment \(to reduce calculation time\). + Create a new revocation state for a credential based on a revocation state created before. + Note that provided revocation delta must cover the registry gap from based state creation until the specified time + (this new delta should be received with parameters: `from`: `state_timestamp` and `to`: `needed_time`). + + This function reduces the calculation time. + + The resulting revocation state and provided timestamp can be saved and reused later by applying a new revocation delta again. * `blobStorageReaderHandle`: Handle (Number) - configuration of blob storage reader handle that will allow to read revocation tails * `revState`: Json - revocation registry state json * `revRegDef`: Json - revocation registry definition json -* `revRegDelta`: Json - revocation registry definition delta json +* `revRegDelta`: Json - revocation registry definition delta which covers the gap form original `rev_state_json` creation till the requested timestamp * `timestamp`: Timestamp (Number) - time represented as a total number of seconds from Unix Epoch * `credRevId`: String - user credential revocation id in revocation registry * __->__ `updatedRevState`: Json - revocation state json: @@ -1248,13 +1371,16 @@ Errors: `Common*`, `Wallet*`, `Crypto*` Saves their DID for a pairwise connection in a secured Wallet, so that it can be used to verify transaction. +Updates DID associated verkey in case DID already exists in the Wallet. * `wh`: Handle (Number) - wallet handle (created by openWallet) * `identity`: Json - Identity information as json. Example: ``` { "did": string, (required) - "verkey": string (optional, can be avoided if did is cryptonym: did == verkey), + "verkey": string + - optional is case of adding a new DID, and DID is cryptonym: did == verkey, + - mandatory in case of updating an existing DID } ```` * __->__ void @@ -2816,8 +2942,13 @@ if NULL, then default config will be used. Example: "extended_timeout": int (optional), extended timeout for network request (in sec). "preordered_nodes": array - (optional), names of nodes which will have a priority during request sending: ["name_of_1st_prior_node", "name_of_2nd_prior_node", .... ] - Note: Not specified nodes will be placed in a random way. + This can be useful if a user prefers querying specific nodes. + Assume that `Node1` and `Node2` nodes reply faster. + If you pass them Libindy always sends a read request to these nodes first and only then (if not enough) to others. + Note: Nodes not specified will be placed randomly. "number_read_nodes": int (optional) - the number of nodes to send read requests (2 by default) + By default Libindy sends a read requests to 2 nodes in the pool. + If response isn't received or `state proof` is invalid Libindy sends the request again but to 2 (`number_read_nodes`) * 2 = 4 nodes and so far until completion. } ```` diff --git a/wrappers/nodejs/package.json b/wrappers/nodejs/package.json index 16d07d9a33..776fd09d2f 100644 --- a/wrappers/nodejs/package.json +++ b/wrappers/nodejs/package.json @@ -1,6 +1,6 @@ { "name": "indy-sdk", - "version": "1.14.1", + "version": "1.14.2", "description": "Native bindings for hyperledger indy", "author": "hyperledger", "license": "Apache-2.0", diff --git a/wrappers/nodejs/test/anoncreds.js b/wrappers/nodejs/test/anoncreds.js index cfc86abe93..b3c18b3b8a 100644 --- a/wrappers/nodejs/test/anoncreds.js +++ b/wrappers/nodejs/test/anoncreds.js @@ -167,6 +167,23 @@ test('anoncreds', async function (t) { await indy.issuerMergeRevocationRegistryDeltas(revDelta, revocedDelta) + // Verify the proof with changed requested predicate value + proofReq = { + 'nonce': nonce, + 'name': 'proof_req_1', + 'version': '0.1', + 'requested_attributes': { + 'attr1_referent': { 'name': 'name' } + }, + 'requested_predicates': { + 'predicate1_referent': { 'name': 'age', 'p_type': '>=', 'p_value': 50 } // requested value is greater than actual (28) + }, + 'non_revoked': { 'from': 80, 'to': 100 } + } + var err = await t.throwsAsync( + indy.verifierVerifyProof(proofReq, proof, schemas, credentialDefs, revocRefDefs, revocRegs)) + t.is(err.indyName, 'AnoncredsProofRejected') + // Rotate credential definition var tempCredDef = await indy.issuerRotateCredentialDefStart(wh, credDefId, null) t.not(cred, tempCredDef) diff --git a/wrappers/python/indy/anoncreds.py b/wrappers/python/indy/anoncreds.py index 7eacd7a8e7..901a978c94 100644 --- a/wrappers/python/indy/anoncreds.py +++ b/wrappers/python/indy/anoncreds.py @@ -1150,7 +1150,10 @@ async def prover_get_credentials_for_proof_req(wallet_handle: int, attr_referent: Proof-request local identifier of requested attribute attr_info: Describes requested attribute { - "name": string, // attribute name, (case insensitive and ignore spaces) + "name": Optional, // attribute name, (case insensitive and ignore spaces) + "names": Optional<[string, string]>, // attribute names, (case insensitive and ignore spaces) + // NOTE: should either be "name" or "names", not both and not none of them. + // Use "names" to specify several attributes that have to match a single credential. "restrictions": Optional, // see below "non_revoked": Optional<>, // see below, // If specified prover must proof non-revocation @@ -1270,8 +1273,11 @@ async def prover_search_credentials_for_proof_req(wallet_handle: int, where attr_info: Describes requested attribute { - "name": string, // attribute name, (case insensitive and ignore spaces) - "restrictions": Optional, // see below + "name": Optional, // attribute name, (case insensitive and ignore spaces) + "names": Optional<[string, string]>, // attribute names, (case insensitive and ignore spaces) + // NOTE: should either be "name" or "names", not both and not none of them. + // Use "names" to specify several attributes that have to match a single credential. + "restrictions": Optional, // see below "non_revoked": Optional<>, // see below, // If specified prover must proof non-revocation // for date in this interval this attribute @@ -1482,28 +1488,31 @@ async def prover_create_proof(wallet_handle: int, } :param rev_states_json: all revocation states json participating in the proof request { - "rev_reg_def1_id": { + "rev_reg_def1_id or credential_1_id": { "timestamp1": , "timestamp2": , }, - "rev_reg_def2_id": { + "rev_reg_def2_id or credential_2_id": { "timestamp3": }, - "rev_reg_def3_id": { + "rev_reg_def3_id or credential_3_id": { "timestamp4": }, - } + } - Note: use credential_id instead rev_reg_id in case proving several credentials from the same revocation registry. where attr_referent: Proof-request local identifier of requested attribute attr_info: Describes requested attribute { - "name": string, // attribute name, (case insensitive and ignore spaces) - "restrictions": Optional, // see below + "name": Optional, // attribute name, (case insensitive and ignore spaces) + "names": Optional<[string, string]>, // attribute names, (case insensitive and ignore spaces) + // NOTE: should either be "name" or "names", not both and not none of them. + // Use "names" to specify several attributes that have to match a single credential. + "restrictions": Optional, // see below "non_revoked": Optional<>, // see below, // If specified prover must proof non-revocation // for date in this interval this attribute - // (overrides proof level interval) + // (overrides proof level interval) } predicate_referent: Proof-request local identifier of requested attribute predicate predicate_info: Describes requested attribute predicate @@ -1543,6 +1552,17 @@ async def prover_create_proof(wallet_handle: int, "requested_attr1_id": {sub_proof_index: number, raw: string, encoded: string}, "requested_attr4_id": {sub_proof_index: number: string, encoded: string}, }, + "revealed_attr_groups": { + "requested_attr5_id": { + "sub_proof_index": number, + "values": { + "attribute_name": { + "raw": string, + "encoded": string + } + }, + } + }, "unrevealed_attrs": { "requested_attr3_id": {sub_proof_index: number} }, @@ -1643,6 +1663,17 @@ async def verifier_verify_proof(proof_request_json: str, "requested_attr1_id": {sub_proof_index: number, raw: string, encoded: string}, // NOTE: check that `encoded` value match to `raw` value on application level "requested_attr4_id": {sub_proof_index: number: string, encoded: string}, // NOTE: check that `encoded` value match to `raw` value on application level }, + "revealed_attr_groups": { + "requested_attr5_id": { + "sub_proof_index": number, + "values": { + "attribute_name": { + "raw": string, + "encoded": string + } + }, // NOTE: check that `encoded` value match to `raw` value on application level + } + }, "unrevealed_attrs": { "requested_attr3_id": {sub_proof_index: number} }, @@ -1734,11 +1765,18 @@ async def create_revocation_state(blob_storage_reader_handle: int, timestamp: int, cred_rev_id: str) -> str: """ - Create revocation state for a credential in the particular time moment. + Create revocation state for a credential that corresponds to a particular time. + + Note that revocation delta must cover the whole registry existence time. + You can use `from`: `0` and `to`: `needed_time` as parameters for building request to get correct revocation delta. + + The resulting revocation state and provided timestamp can be saved and reused later with applying a new + revocation delta with `update_revocation_state` function. + This new delta should be received with parameters: `from`: `timestamp` and `to`: `needed_time`. :param blob_storage_reader_handle: configuration of blob storage reader handle that will allow to read revocation tails :param rev_reg_def_json: revocation registry definition json - :param rev_reg_delta_json: revocation registry definition delta json + :param rev_reg_delta_json: revocation registry definition delta which covers the whole registry existence time :param timestamp: time represented as a total number of seconds from Unix Epoch :param cred_rev_id: user credential revocation id in revocation registry :return: revocation state json { @@ -1787,13 +1825,18 @@ async def update_revocation_state(blob_storage_reader_handle: int, timestamp: int, cred_rev_id: str) -> str: """ - Create new revocation state for a credential based on existed state - at the particular time moment (to reduce calculation time). + Create a new revocation state for a credential based on a revocation state created before. + Note that provided revocation delta must cover the registry gap from based state creation until the specified time + (this new delta should be received with parameters: `from`: `state_timestamp` and `to`: `needed_time`). + + This function reduces the calculation time. + + The resulting revocation state and provided timestamp can be saved and reused later by applying a new revocation delta again. :param blob_storage_reader_handle: configuration of blob storage reader handle that will allow to read revocation tails :param rev_state_json: revocation registry state json :param rev_reg_def_json: revocation registry definition json - :param rev_reg_delta_json: revocation registry definition delta json + :param rev_reg_delta_json: revocation registry definition delta which covers the gap form original `rev_state_json` creation till the requested timestamp :param timestamp: time represented as a total number of seconds from Unix Epoch :param cred_rev_id: user credential revocation id in revocation registry :return: revocation state json { diff --git a/wrappers/python/indy/did.py b/wrappers/python/indy/did.py index 6b0af645c8..b125323807 100644 --- a/wrappers/python/indy/did.py +++ b/wrappers/python/indy/did.py @@ -137,6 +137,7 @@ async def store_their_did(wallet_handle: int, """ Saves their DID for a pairwise connection in a secured Wallet, so that it can be used to verify transaction. + Updates DID associated verkey in case DID already exists in the Wallet. :param wallet_handle: wallet handler (created by open_wallet). :param identity_json: Identity information as json. Example: diff --git a/wrappers/python/indy/pool.py b/wrappers/python/indy/pool.py index 4b03a1e271..c86d793fe7 100755 --- a/wrappers/python/indy/pool.py +++ b/wrappers/python/indy/pool.py @@ -59,8 +59,13 @@ async def open_pool_ledger(config_name: str, "extended_timeout": int (optional), extended timeout for network request (in sec). "preordered_nodes": array - (optional), names of nodes which will have a priority during request sending: ["name_of_1st_prior_node", "name_of_2nd_prior_node", .... ] - Note: Not specified nodes will be placed in a random way. + This can be useful if a user prefers querying specific nodes. + Assume that `Node1` and `Node2` nodes reply faster. + If you pass them Libindy always sends a read request to these nodes first and only then (if not enough) to others. + Note: Nodes not specified will be placed randomly. "number_read_nodes": int (optional) - the number of nodes to send read requests (2 by default) + By default Libindy sends a read requests to 2 nodes in the pool. + If response isn't received or `state proof` is invalid Libindy sends the request again but to 2 (`number_read_nodes`) * 2 = 4 nodes and so far until completion. } :return: Handle to opened pool to use in methods that require pool connection. """ diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py index 0cc3e0933c..375f38dc7d 100644 --- a/wrappers/python/setup.py +++ b/wrappers/python/setup.py @@ -1,7 +1,7 @@ from distutils.core import setup import os -PKG_VERSION = os.environ.get('PACKAGE_VERSION') or '1.14.1' +PKG_VERSION = os.environ.get('PACKAGE_VERSION') or '1.14.2' TEST_DEPS = [ 'pytest<3.7', 'pytest-asyncio', 'base58' diff --git a/wrappers/python/tests/interation/test_interaction_several_credentials.py b/wrappers/python/tests/interation/test_interaction_several_credentials.py new file mode 100644 index 0000000000..fa6954d758 --- /dev/null +++ b/wrappers/python/tests/interation/test_interaction_several_credentials.py @@ -0,0 +1,652 @@ +import json + +import pytest +import time + +from enum import IntEnum +from pprint import pformat + +from indy import ledger, anoncreds, wallet, blob_storage + +from tests.ledger.test_submit_request import ensure_previous_request_applied + +import logging + + +# logging.getLogger("tests").setLevel(logging.ERROR) +# logging.getLogger("indy").setLevel(logging.ERROR) + + +def ppjson(dumpit, elide_to: int = None) -> str: + if elide_to is not None: + elide_to = max(elide_to, 3) # make room for ellipses '...' + try: + rv = json.dumps(json.loads(dumpit) if isinstance(dumpit, str) else dumpit, indent=4) + except TypeError: + rv = '{}'.format(pformat(dumpit, indent=4, width=120)) + return rv if elide_to is None or len(rv) <= elide_to else '{}...'.format(rv[0:(elide_to - 3)]) + + +class Ink(IntEnum): + BLACK = 30 + RED = 31 + GREEN = 32 + YELLOW = 33 + BLUE = 34 + MAGENTA = 35 + CYAN = 36 + WHITE = 37 + + + def __call__(self, message: str) -> str: + return '\033[{}m{}\033[0m'.format(self.value, message) + + +@pytest.mark.asyncio +async def test_anoncreds_revocation_interaction_test_issuance_by_demand_4_creds(pool_name, pool_handle, wallet_handle, + identity_my, identity_my1, path_home, + did_my2, credentials): + issuer_did, _ = identity_my + issuer_wallet_handle = wallet_handle + + prover_did, _ = identity_my1 + + # Prover Creates Wallet and Get Wallet Handle + prover_wallet_config = '{"id":"prover_wallet"}' + await wallet.create_wallet(prover_wallet_config, credentials) + prover_wallet_handle = await wallet.open_wallet(prover_wallet_config, credentials) + + # Issuer Creates Schema + (schema_id, schema_json) = await anoncreds.issuer_create_schema( + issuer_did, + "gvt", + "1.0", + json.dumps(["name", "age", "sex", "height"]) + ) + + # Issuer Posts Schema + schema_request = await ledger.build_schema_request(issuer_did, schema_json) + await ledger.sign_and_submit_request(pool_handle, issuer_wallet_handle, issuer_did, schema_request) + + # Issuer Gets Schema from Ledger + get_schema_request = await ledger.build_get_schema_request(issuer_did, str(schema_id)) + get_schema_response = await ensure_previous_request_applied( + pool_handle, + get_schema_request, + lambda response: response['result']['seqNo'] is not None + ) + (schema_id, schema_json) = await ledger.parse_get_schema_response(get_schema_response) + + # Issuer Creates credential Definition for Schema + (cred_def_id, cred_def_json) = await anoncreds.issuer_create_and_store_credential_def( + issuer_wallet_handle, + issuer_did, + schema_json, + 'tag1', + 'CL', + '{"support_revocation": true}' + ) + + # Issuer Posts Credential Definition + cred_def_request = await ledger.build_cred_def_request(issuer_did, cred_def_json) + await ledger.sign_and_submit_request(pool_handle, issuer_wallet_handle, issuer_did, cred_def_request) + + # Issuer Creates Revocation Registry + tails_writer_config = json.dumps({'base_dir': str(path_home.joinpath("tails")), 'uri_pattern': ''}) + tails_writer = await blob_storage.open_writer('default', tails_writer_config) + (rev_reg_def_id, rev_reg_def_json, rev_reg_entry_json) = await anoncreds.issuer_create_and_store_revoc_reg( + issuer_wallet_handle, + issuer_did, None, + 'tag1', + cred_def_id, + '{"max_cred_num": 16, "issuance_type":"ISSUANCE_ON_DEMAND"}', + tails_writer + ) + + # Issuer posts Revocation Registry Definition to Ledger + revoc_reg_request = await ledger.build_revoc_reg_def_request(issuer_did, rev_reg_def_json) + await ledger.sign_and_submit_request(pool_handle, issuer_wallet_handle, issuer_did, revoc_reg_request) + + # Issuer posts Revocation Registry Entry to Ledger + revoc_reg_entry_request = await ledger.build_revoc_reg_entry_request( + issuer_did, + rev_reg_def_id, + "CL_ACCUM", + rev_reg_entry_json + ) + await ledger.sign_and_submit_request(pool_handle, issuer_wallet_handle, issuer_did, revoc_reg_entry_request) + + # ISSUANCE Credential for Prover + + # Prover Creates Master Secret + master_secret_id = "master_secret" + await anoncreds.prover_create_master_secret(prover_wallet_handle, master_secret_id) + + # Issuer Creates credential Offer + cred_offer_json = await anoncreds.issuer_create_credential_offer(issuer_wallet_handle, cred_def_id) + cred_offer = json.loads(cred_offer_json) + + # Prover Gets Credential Definition from Ledger + get_cred_def_request = await ledger.build_get_cred_def_request(prover_did, cred_offer['cred_def_id']) + get_cred_def_response = await ensure_previous_request_applied( + pool_handle, + get_cred_def_request, + lambda response: response['result']['seqNo'] is not None + ) + (cred_def_id, cred_def_json) = await ledger.parse_get_cred_def_response(get_cred_def_response) + + # Prover create credential Request + (cred_req_json, cred_req_metadata_json) = await anoncreds.prover_create_credential_req( + prover_wallet_handle, + prover_did, + cred_offer_json, + cred_def_json, + master_secret_id + ) + + # Issuer Opens Tails reader + blob_storage_reader_cfg_handle = await blob_storage.open_reader('default', tails_writer_config) + + # Issuer create credential for credential Request + # note that encoding is not standardized by Indy except that 32-bit integers are encoded as themselves. IS-786 + cred_values_json = [ + json.dumps( + { + "sex": {"raw": "male", "encoded": "7239210949258394887428692050081607692519917050011144233115103"}, + "name": {"raw": "Alex", "encoded": "1139481716457488690172217916278103335"}, + "height": {"raw": "180", "encoded": "180"}, + "age": {"raw": "28", "encoded": "28"} + } + ), + json.dumps( + { + "sex": {"raw": "female", "encoded": "7239210949258394887428692050081607692519917050011144233115104"}, + "name": {"raw": "Ludmilla", "encoded": "690172217916278103335"}, + "height": {"raw": "171", "encoded": "171"}, + "age": {"raw": "30", "encoded": "30"} + } + ), + json.dumps( + { + "sex": {"raw": "male", "encoded": "7239210949258394887428692050081607692519917050011144233115103"}, + "name": {"raw": "Boris", "encoded": "239572896838295261729"}, + "height": {"raw": "172", "encoded": "172"}, + "age": {"raw": "48", "encoded": "48"} + } + ), + json.dumps( + { + "sex": {"raw": "female", "encoded": "7239210949258394887428692050081607692519917050011144233115104"}, + "name": {"raw": "Olga", "encoded": "258623589235632895688"}, + "height": {"raw": "173", "encoded": "173"}, + "age": {"raw": "78", "encoded": "78"} + } + ) + ] + + cred_json = [None] * 4 + cred_rev_id = [None] * 4 + rev_reg_delta_json = [None] * 4 + credential = [None] * 4 + print(Ink.CYAN('\n\nCreating and storing credentials')) + for i in range(4): + (cred_json[i], cred_rev_id[i], rev_reg_delta_json[i]) = await anoncreds.issuer_create_credential( + issuer_wallet_handle, + cred_offer_json, + cred_req_json, + cred_values_json[i], + rev_reg_def_id, + blob_storage_reader_cfg_handle + ) + + # Issuer Posts Revocation Registry Delta to Ledger + revoc_reg_entry_request = await ledger.build_revoc_reg_entry_request( + issuer_did, + rev_reg_def_id, + "CL_ACCUM", + rev_reg_delta_json[i] + ) + await ledger.sign_and_submit_request(pool_handle, issuer_wallet_handle, issuer_did, revoc_reg_entry_request) + + # Prover Gets RevocationRegistryDefinition + credential[i] = json.loads(cred_json[i]) + get_revoc_reg_def_request = await ledger.build_get_revoc_reg_def_request( + prover_did, + credential[i]['rev_reg_id'] + ) + get_revoc_reg_def_response = await ensure_previous_request_applied( + pool_handle, + get_revoc_reg_def_request, + lambda response: response['result']['seqNo'] is not None + ) + (rev_reg_id, revoc_reg_def_json) = await ledger.parse_get_revoc_reg_def_response(get_revoc_reg_def_response) + + print( + '.. Prover storing credential {}, rev-id {}, values {}'.format( + 'cred_%s_id' % i, + cred_rev_id[i], + ppjson(json.loads(cred_json[i])['values']) + ) + ) + # Prover Stores Credential + await anoncreds.prover_store_credential( + prover_wallet_handle, + 'cred_%s_id' % i, + cred_req_metadata_json, + cred_json[i], + cred_def_json, + revoc_reg_def_json + ) + + # VERIFYING Prover Credentials (Alex, Olga) when issuer has not revoked any + time.sleep(2) + to = int(time.time()) + + proof_req_json = { + 'Alex': json.dumps( + { + 'nonce': '100000000001', + 'name': 'proof_req', + 'version': '0.1', + 'requested_attributes': { + 'attr1_referent': {'name': 'name'} + }, + 'requested_predicates': { + 'pred1_referent': {'name': 'height', 'p_type': '>=', 'p_value': 180} + }, + "non_revoked": {"to": to} + } + ), + 'Olga': json.dumps( + { + 'nonce': '100000000000', + 'name': 'proof_req', + 'version': '0.1', + 'requested_attributes': { + 'attr1_referent': {'name': 'name'} + }, + 'requested_predicates': { + 'pred1_referent': {'name': 'age', 'p_type': '>=', 'p_value': 65} + }, + "non_revoked": {"to": to} + } + ) + } + + rev_states = { + 'Alex': { + 'timestamp': 0, + 'value': '' + }, + 'Olga': { + 'timestamp': 0, + 'value': '' + } + } + + cred_info = {} + print(Ink.CYAN('\n\nCreating proofs')) + for proof_name in proof_req_json: + print('\n\n.. Creating proof for {}'.format(proof_name)) + # Prover Gets credentials for Proof Request + search_credentials_for_proof_handle = await anoncreds.prover_search_credentials_for_proof_req( + prover_wallet_handle, + proof_req_json[proof_name], + None + ) + fetched_credential_json = await anoncreds.prover_fetch_credentials_for_proof_req( + search_credentials_for_proof_handle, + 'attr1_referent', + 4 + ) + await anoncreds.prover_close_credentials_search_for_proof_req(search_credentials_for_proof_handle) + + pred_spec = None + for i in range(4): + found = json.loads(fetched_credential_json)[i]['cred_info'] # don't clobber cred_info ... + pred_spec = json.loads(proof_req_json[proof_name])['requested_predicates']['pred1_referent'] + if found['attrs'][pred_spec['name']] >= str(pred_spec['p_value']): + break + else: + print('!! No matching credential found for {}'.format(proof_name)) + assert False + cred_info[proof_name] = found # ... until we have the right cred info + print( + '.. Credential info for proof on {}>={} ({}): {}'.format( + pred_spec['name'], + pred_spec['p_value'], + proof_name, + ppjson(cred_info[proof_name]) + ) + ) + + # Prover Gets RevocationRegistryDelta from Ledger + get_revoc_reg_delta_request = await ledger.build_get_revoc_reg_delta_request( + prover_did, + rev_reg_def_id, + None, + to + ) + get_revoc_reg_delta_response = await ensure_previous_request_applied( + pool_handle, + get_revoc_reg_delta_request, + lambda response: response['result']['seqNo'] is not None + ) + (rev_reg_id, revoc_reg_delta_json, timestamp) = await ledger.parse_get_revoc_reg_delta_response( + get_revoc_reg_delta_response + ) + + # Prover Creates Revocation State + rev_state_from_timestamp_to_now_json = await anoncreds.create_revocation_state( + blob_storage_reader_cfg_handle, + revoc_reg_def_json, + revoc_reg_delta_json, + timestamp, + cred_info[proof_name]['cred_rev_id'] + ) + rev_states[proof_name] = { + 'timestamp': timestamp, + 'value': rev_state_from_timestamp_to_now_json, + } + + # Prover Gets Schema from Ledger + get_schema_request = await ledger.build_get_schema_request(prover_did, str(cred_info[proof_name]["schema_id"])) + get_schema_response = await ensure_previous_request_applied( + pool_handle, + get_schema_request, + lambda response: response['result']['seqNo'] is not None + ) + (schema_id, schema_json) = await ledger.parse_get_schema_response(get_schema_response) + + # Prover Creates Proof for Proof Request + requested_credentials_json = json.dumps( + { + 'self_attested_attributes': {}, + 'requested_attributes': { + 'attr1_referent': { + 'cred_id': cred_info[proof_name]['referent'], + 'revealed': True, + 'timestamp': timestamp + } + }, + 'requested_predicates': { + 'pred1_referent': { + 'cred_id': cred_info[proof_name]['referent'], + 'timestamp': timestamp + } + } + } + ) + + schemas_json = json.dumps({schema_id: json.loads(schema_json)}) + credential_defs_json = json.dumps({cred_def_id: json.loads(cred_def_json)}) + revoc_states_json = json.dumps({rev_reg_id: {timestamp: json.loads(rev_state_from_timestamp_to_now_json)}}) + + proof_json = await anoncreds.prover_create_proof( + prover_wallet_handle, + proof_req_json[proof_name], + requested_credentials_json, + master_secret_id, + schemas_json, + credential_defs_json, + revoc_states_json) + proof = json.loads(proof_json) + print('.. Proof for {}: {}'.format(proof_name, ppjson(proof_json, 1024))) + + # Verifier Gets required entities from Ledger + verifier_did = did_my2 + identifier = proof['identifiers'][0] + + # Verifier Gets Schema from Ledger + get_schema_request = await ledger.build_get_schema_request(verifier_did, identifier['schema_id']) + get_schema_response = await ensure_previous_request_applied( + pool_handle, + get_schema_request, + lambda response: response['result']['seqNo'] is not None + ) + (schema_id, schema_json) = await ledger.parse_get_schema_response(get_schema_response) + + # Verifier Gets Credential Definition from Ledger + get_cred_def_request = await ledger.build_get_cred_def_request(verifier_did, identifier['cred_def_id']) + get_cred_def_response = await ensure_previous_request_applied( + pool_handle, + get_cred_def_request, + lambda response: response['result']['seqNo'] is not None + ) + (cred_def_id, cred_def_json) = await ledger.parse_get_cred_def_response(get_cred_def_response) + + # Verifier Gets Revocation Registry Definition from Ledger + get_revoc_reg_def_request = await ledger.build_get_revoc_reg_def_request(verifier_did, identifier['rev_reg_id']) + get_revoc_reg_def_response = await ensure_previous_request_applied( + pool_handle, + get_revoc_reg_def_request, + lambda response: response['result']['seqNo'] is not None + ) + (rev_reg_id, revoc_reg_def_json) = await ledger.parse_get_revoc_reg_def_response(get_revoc_reg_def_response) + + # Verifier Gets Revocation Registry from Ledger + get_revoc_reg_request = await ledger.build_get_revoc_reg_request( + verifier_did, + identifier['rev_reg_id'], + identifier['timestamp'] + ) + get_revoc_reg_response = await ensure_previous_request_applied( + pool_handle, + get_revoc_reg_request, + lambda response: response['result']['seqNo'] is not None + ) + (rev_reg_id, rev_reg_json, identifier) = await ledger.parse_get_revoc_reg_response(get_revoc_reg_response) + + # Verifier verify proof + assert proof_name == proof['requested_proof']['revealed_attrs']['attr1_referent']['raw'] + + schemas_json = json.dumps({schema_id: json.loads(schema_json)}) + credential_defs_json = json.dumps({cred_def_id: json.loads(cred_def_json)}) + revoc_ref_defs_json = json.dumps({rev_reg_id: json.loads(revoc_reg_def_json)}) + revoc_regs_json = json.dumps({rev_reg_id: {timestamp: json.loads(rev_reg_json)}}) + + print(Ink.RED('>> rev regs: {}'.format(ppjson(revoc_regs_json)))) + verified = await anoncreds.verifier_verify_proof( + proof_req_json[proof_name], + proof_json, + schemas_json, + credential_defs_json, + revoc_ref_defs_json, + revoc_regs_json + ) + print(Ink.GREEN('.. Proof for {} before any revocations verifies as {}'.format(proof_name, verified))) + assert verified + + proof_req_expected_result = { + 'Alex': False, + 'Olga': True + } + # Issuer revokes creds for all but Olga, one by one, creating and verifying proofs for Alex and Olga each time + print(Ink.CYAN('\n\nIssuer revoking creds one by one')) + for i in range(3): + revo_name = json.loads(cred_values_json[i])['name']['raw'] + print( + '\n\n.. Issuer revoking {} (cred rev id {}) at epoch={}'.format( + revo_name, + cred_rev_id[i], + int(time.time()) + ) + ) + rev_reg_delta_json = await anoncreds.issuer_revoke_credential( + issuer_wallet_handle, + blob_storage_reader_cfg_handle, + rev_reg_def_id, + cred_rev_id[i] + ) + + # Issuer Posts RevocationRegistryDelta to Ledger + revoc_reg_entry_request = await ledger.build_revoc_reg_entry_request( + issuer_did, + rev_reg_def_id, + "CL_ACCUM", + rev_reg_delta_json + ) + await ledger.sign_and_submit_request(pool_handle, issuer_wallet_handle, issuer_did, revoc_reg_entry_request) + + print(Ink.CYAN('.. Processing proofs after revocation of {}'.format(revo_name))) + for proof_name in proof_req_json: + # VERIFYING Prover Credential after Revocation + time.sleep(2) + fro = to + to = int(time.time()) + print( + '.. .. after sleeping 2 seconds, doing {} for interval [{}, {}]'.format( + proof_name, + fro, + to + ) + ) + # There two possible ways: + + # 1) Prover creates updates previously created revocation state + # Prover Gets RevocationRegistryDelta from Ledger + # from: when last prover revocation state were created + # to: to + get_revoc_reg_delta_request = await ledger.build_get_revoc_reg_delta_request( + prover_did, + rev_reg_def_id, + rev_states[proof_name]['timestamp'], + to + ) + + get_revoc_reg_delta_response = await ensure_previous_request_applied( + pool_handle, + get_revoc_reg_delta_request, + lambda response: response['result']['seqNo'] is not None + ) + (rev_reg_id, revoc_reg_delta_json, timestamp) = await ledger.parse_get_revoc_reg_delta_response( + get_revoc_reg_delta_response + ) + + # Prover Updates previously created Revocation State + rev_state_from_timestamp_to_now_json = await anoncreds.update_revocation_state( + blob_storage_reader_cfg_handle, + rev_states[proof_name]['value'], + revoc_reg_def_json, + revoc_reg_delta_json, + timestamp, + cred_rev_id[0 if proof_name == 'Alex' else 3] # Alex, then Olga + ) + + # Prover creates revocation state from scratch + # from: 0 or time of credential issuance + # to: to + # Prover Gets RevocationRegistryDelta from Ledger + get_revoc_reg_delta_request_2 = await ledger.build_get_revoc_reg_delta_request( + prover_did, + rev_reg_def_id, + 0, + to + ) + + get_revoc_reg_delta_response_2 = await ensure_previous_request_applied( + pool_handle, + get_revoc_reg_delta_request_2, + lambda response: response['result']['seqNo'] is not None + ) + (rev_reg_id, revoc_reg_delta_json_2, timestamp_2) = await ledger.parse_get_revoc_reg_delta_response( + get_revoc_reg_delta_response_2 + ) + + # Prover creates Revocation State + rev_state_from_0_to_now_json = await anoncreds.create_revocation_state( + blob_storage_reader_cfg_handle, + revoc_reg_def_json, + revoc_reg_delta_json_2, + timestamp_2, + cred_rev_id[0 if proof_name == 'Alex' else 3] # Alex, then Olga + ) + + rev_states[proof_name] = { + 'timestamp': timestamp, + 'value': rev_state_from_timestamp_to_now_json # rev_state_from_0_to_now_json must also work + } + + revoc_states_json = json.dumps({rev_reg_id: {timestamp: json.loads(rev_states[proof_name]['value'])}}) + + # Prover Creates Proof for Proof Request + requested_credentials_json = json.dumps( + { + 'self_attested_attributes': {}, + 'requested_attributes': { + 'attr1_referent': { + 'cred_id': cred_info[proof_name]['referent'], + 'revealed': True, + 'timestamp': timestamp + } + }, + 'requested_predicates': { + 'pred1_referent': { + 'cred_id': cred_info[proof_name]['referent'], + 'timestamp': timestamp + } + } + } + ) + + proof_json = await anoncreds.prover_create_proof( + prover_wallet_handle, + proof_req_json[proof_name], + requested_credentials_json, + master_secret_id, + schemas_json, + credential_defs_json, + revoc_states_json + ) + + proof = json.loads(proof_json) + identifier = proof['identifiers'][0] + + # Verifier Gets RevocationRegistry from Ledger + get_revoc_reg_request = await ledger.build_get_revoc_reg_request( + verifier_did, + identifier['rev_reg_id'], + identifier['timestamp'] + ) + get_revoc_reg_response = await ensure_previous_request_applied( + pool_handle, + get_revoc_reg_request, + lambda response: response['result']['seqNo'] is not None + ) + (rev_reg_id, rev_reg_json, timestamp) = await ledger.parse_get_revoc_reg_response(get_revoc_reg_response) + + revoc_regs_json = json.dumps({rev_reg_id: {timestamp: json.loads(rev_reg_json)}}) + print(Ink.RED('>> >> rev regs: {}'.format(ppjson(revoc_regs_json)))) + + proof_req_touchup = json.loads(proof_req_json[proof_name]) + proof_req_touchup['non_revoked']['to'] = int(time.time()) + proof_req_json[proof_name] = json.dumps(proof_req_touchup) + print( + '.. .. {}: Proof req {}, proof {}'.format( + proof_name, + ppjson(proof_req_json[proof_name]), + ppjson(proof_json, 1024) + ) + ) + verified = await anoncreds.verifier_verify_proof( + proof_req_json[proof_name], + proof_json, + schemas_json, + credential_defs_json, + revoc_ref_defs_json, + revoc_regs_json + ) + assert proof_req_expected_result[proof_name] == verified + print( + Ink.GREEN( + '.. .. Proof for {} after {} revocation verifies as: {}'.format( + proof_name, + revo_name, + verified + ) + ) + ) + + # Close and Delete Prover Wallet + await wallet.close_wallet(prover_wallet_handle) + await wallet.delete_wallet(prover_wallet_config, credentials) diff --git a/wrappers/rust/Cargo.toml b/wrappers/rust/Cargo.toml index 89d7a34606..a58ecc2f52 100644 --- a/wrappers/rust/Cargo.toml +++ b/wrappers/rust/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "indy" -version = "1.14.1" +version = "1.14.2" description = "A library for assisting developers using LibIndy API" authors = ["Hyperledger Indy Contributors "] homepage = "https://github.com/hyperledger/indy-sdk" @@ -24,8 +24,8 @@ lazy_static = "1.3" log = { version = "0.4.1", features = ["std"] } num-traits = "0.2" num-derive = "0.2" -indy-sys = { path ="indy-sys", version = "=1.14.1" } -libc = "=0.2.60" +indy-sys = { path ="indy-sys", version = "=1.14.2" } +libc = "=0.2.66" serde_json = "1.0.40" serde_derive = "1.0.97" serde = "1.0.97" diff --git a/wrappers/rust/indy-sys/Cargo.toml b/wrappers/rust/indy-sys/Cargo.toml index 1c21dc2566..e857a6552c 100644 --- a/wrappers/rust/indy-sys/Cargo.toml +++ b/wrappers/rust/indy-sys/Cargo.toml @@ -1,14 +1,16 @@ [package] name = "indy-sys" description = "FFI bindings to Libindy C API" -version = "1.14.1" +version = "1.14.2" authors = ["Hyperledger Indy Contributors "] build = "build.rs" links = "indy" license = "MIT/Apache-2.0" [dependencies] -libc = "=0.2.60" +serde = "1.0.99" +serde_derive = "1.0.99" +libc = "=0.2.66" [build-dependencies] pkg-config = "0.3.9" diff --git a/wrappers/rust/indy-sys/src/anoncreds.rs b/wrappers/rust/indy-sys/src/anoncreds.rs index 573313e5c5..59f2c6007a 100644 --- a/wrappers/rust/indy-sys/src/anoncreds.rs +++ b/wrappers/rust/indy-sys/src/anoncreds.rs @@ -1,6 +1,7 @@ use super::*; -use {CString, Error, CommandHandle, WalletHandle}; +use {CString, Error}; + extern { diff --git a/wrappers/rust/indy-sys/src/lib.rs b/wrappers/rust/indy-sys/src/lib.rs index b6354d92c0..75ed7f146e 100644 --- a/wrappers/rust/indy-sys/src/lib.rs +++ b/wrappers/rust/indy-sys/src/lib.rs @@ -13,22 +13,30 @@ pub mod wallet; pub mod logger; pub mod cache; +extern crate serde; + +#[macro_use] +extern crate serde_derive; + use self::libc::{c_void, c_char}; pub type CVoid = c_void; pub type BString = *const u8; pub type CString = *const c_char; -pub type WalletHandle = i32; -//#[repr(transparent)] -//#[derive(Debug, Hash, PartialEq, Eq, Copy, Clone)] -//pub struct WalletHandle(pub i32); -//pub const INVALID_WALLET_HANDLE : WalletHandle = WalletHandle(0); +#[repr(transparent)] +#[derive(Debug, Hash, PartialEq, Eq, Copy, Clone, Serialize, Deserialize)] +pub struct WalletHandle(pub i32); +pub const INVALID_WALLET_HANDLE : WalletHandle = WalletHandle(0); + +pub type PoolHandle = i32; +pub const INVALID_POOL_HANDLE : PoolHandle = 0; + +pub type CommandHandle = i32; +pub const INVALID_COMMAND_HANDLE : CommandHandle = 0; //pub type Handle = i32; pub type IndyHandle = i32; -pub type CommandHandle = i32; -pub type PoolHandle = i32; pub type SearchHandle = i32; pub type RecordHandle = i32; pub type TailWriterHandle = i32; @@ -41,12 +49,10 @@ pub type TailsWriterHandle = i32; pub type Error = i32; -pub const INVALID_POOL_HANDLE: PoolHandle = 0; -pub const INVALID_WALLET_HANDLE: WalletHandle = 0; - pub type ResponseEmptyCB = extern fn(xcommand_handle: CommandHandle, err: Error); pub type ResponseBoolCB = extern fn(xcommand_handle: CommandHandle, err: Error, bool1: bool); pub type ResponseI32CB = extern fn(xcommand_handle: CommandHandle, err: Error, handle: IndyHandle); +pub type ResponseWalletHandleCB = extern fn(xcommand_handle: CommandHandle, err: Error, handle: WalletHandle); pub type ResponseI32UsizeCB = extern fn(xcommand_handle: CommandHandle, err: Error, handle: IndyHandle, total_count: usize); pub type ResponseStringCB = extern fn(xcommand_handle: CommandHandle, err: Error, str1: CString); pub type ResponseStringStringCB = extern fn(xcommand_handle: CommandHandle, err: Error, str1: CString, str2: CString); diff --git a/wrappers/rust/indy-sys/src/wallet.rs b/wrappers/rust/indy-sys/src/wallet.rs index 47dbb96ab1..09688d43d0 100644 --- a/wrappers/rust/indy-sys/src/wallet.rs +++ b/wrappers/rust/indy-sys/src/wallet.rs @@ -43,7 +43,7 @@ extern { pub fn indy_open_wallet(command_handle: CommandHandle, config: CString, credentials: CString, - cb: Option) -> Error; + cb: Option) -> Error; #[no_mangle] pub fn indy_export_wallet(command_handle: CommandHandle, diff --git a/wrappers/rust/src/anoncreds.rs b/wrappers/rust/src/anoncreds.rs index 26e8179f06..9b646236ab 100644 --- a/wrappers/rust/src/anoncreds.rs +++ b/wrappers/rust/src/anoncreds.rs @@ -1142,17 +1142,17 @@ fn _prover_close_credentials_search_for_proof_req(command_handle: CommandHandle, /// } /// * `rev_states_json`: all revocation states json participating in the proof request /// { -/// "rev_reg_def1_id": { +/// "rev_reg_def1_id or credential_1_id": { /// "timestamp1": , /// "timestamp2": , /// }, -/// "rev_reg_def2_id": { +/// "rev_reg_def2_id or credential_2_id": { /// "timestamp3": /// }, -/// "rev_reg_def3_id": { +/// "rev_reg_def3_id or credential_3_id": { /// "timestamp4": /// }, -/// } +/// } - Note: use credential_id instead rev_reg_id in case proving several credentials from the same revocation registry. /// /// where /// where wql query: indy-sdk/doc/design/011-wallet-query-language/README.md @@ -1346,12 +1346,19 @@ fn _verifier_verify_proof(command_handle: CommandHandle, proof_request_json: &st } -/// Create revocation state for a credential in the particular time moment. +/// Create revocation state for a credential that corresponds to a particular time. +/// +/// Note that revocation delta must cover the whole registry existence time. +/// You can use `from`: `0` and `to`: `needed_time` as parameters for building request to get correct revocation delta. +/// +/// The resulting revocation state and provided timestamp can be saved and reused later with applying a new +/// revocation delta with `update_revocation_state` function. +/// This new delta should be received with parameters: `from`: `timestamp` and `to`: `needed_time`. /// /// # Arguments /// * `blob_storage_reader_handle`: configuration of blob storage reader handle that will allow to read revocation tails /// * `rev_reg_def_json`: revocation registry definition json -/// * `rev_reg_delta_json`: revocation registry definition delta json +/// * `rev_reg_delta_json`: revocation registry delta which covers the whole registry existence time /// * `timestamp`: time represented as a total number of seconds from Unix Epoch /// * `cred_rev_id`: user credential revocation id in revocation registry /// @@ -1381,14 +1388,19 @@ fn _create_revocation_state(command_handle: CommandHandle, blob_storage_reader_h }) } -/// Create new revocation state for a credential based on existed state -/// at the particular time moment (to reduce calculation time). +/// Create a new revocation state for a credential based on a revocation state created before. +/// Note that provided revocation delta must cover the registry gap from based state creation until the specified time +/// (this new delta should be received with parameters: `from`: `state_timestamp` and `to`: `needed_time`). +/// +/// This function reduces the calculation time. +/// +/// The resulting revocation state and provided timestamp can be saved and reused later by applying a new revocation delta again. /// /// # Arguments /// * `blob_storage_reader_handle`: configuration of blob storage reader handle that will allow to read revocation tails /// * `rev_state_json`: revocation registry state json /// * `rev_reg_def_json`: revocation registry definition json -/// * `rev_reg_delta_json`: revocation registry definition delta json +/// * `rev_reg_delta_json`: revocation registry definition delta which covers the gap form original `rev_state_json` creation till the requested timestamp. /// * `timestamp`: time represented as a total number of seconds from Unix Epoch /// * `cred_rev_id`: user credential revocation id in revocation registry /// diff --git a/wrappers/rust/src/did.rs b/wrappers/rust/src/did.rs index 58f8790833..f0da95f388 100644 --- a/wrappers/rust/src/did.rs +++ b/wrappers/rust/src/did.rs @@ -108,6 +108,7 @@ fn _replace_keys_apply(command_handle: CommandHandle, wallet_handle: WalletHandl /// Saves their DID for a pairwise connection in a secured Wallet, /// so that it can be used to verify transaction. +/// Updates DID associated verkey in case DID already exists in the Wallet. /// /// # Arguments /// * `wallet_handle` - wallet handler (created by Wallet::open). @@ -116,7 +117,9 @@ fn _replace_keys_apply(command_handle: CommandHandle, wallet_handle: WalletHandl /// * `identity_json` /// { /// "did": string, (required) -/// "verkey": string (optional, can be avoided if did is cryptonym: did == verkey), +/// "verkey": string +/// - optional is case of adding a new DID, and DID is cryptonym: did == verkey, +/// - mandatory in case of updating an existing DID /// } pub fn store_their_did(wallet_handle: WalletHandle, identity_json: &str) -> Box> { let (receiver, command_handle, cb) = ClosureHandler::cb_ec(); diff --git a/wrappers/rust/src/lib.rs b/wrappers/rust/src/lib.rs index 10cff0df6b..073ddac0dc 100644 --- a/wrappers/rust/src/lib.rs +++ b/wrappers/rust/src/lib.rs @@ -41,23 +41,24 @@ use std::ffi::CStr; use failure::{Backtrace, Fail}; pub use ffi::{ - IndyHandle, - CommandHandle, - WalletHandle, - PoolHandle, - SearchHandle, RecordHandle, TailWriterHandle, - StorageHandle, BlobStorageReaderHandle, BlobStorageReaderCfgHandle, MetadataHandle, Timeout, TailsWriterHandle, + IndyHandle, + CommandHandle, + WalletHandle, + PoolHandle, + SearchHandle, + StorageHandle, + INVALID_WALLET_HANDLE, + INVALID_POOL_HANDLE, + INVALID_COMMAND_HANDLE }; -pub use ffi::{INVALID_POOL_HANDLE, INVALID_WALLET_HANDLE}; - /// Set libindy runtime configuration. Can be optionally called to change current params. /// /// # Arguments diff --git a/wrappers/rust/src/logger.rs b/wrappers/rust/src/logger.rs index 09e641759a..8c9fc37b79 100644 --- a/wrappers/rust/src/logger.rs +++ b/wrappers/rust/src/logger.rs @@ -10,7 +10,7 @@ use std::ptr::null; use utils::ctypes::c_str_to_string; -static mut LOGGER: Option> = None; +static mut LOGGER: Option> = None; /// Set default logger implementation. /// diff --git a/wrappers/rust/src/payments.rs b/wrappers/rust/src/payments.rs index 2bf2096281..b54d906bb5 100644 --- a/wrappers/rust/src/payments.rs +++ b/wrappers/rust/src/payments.rs @@ -10,10 +10,12 @@ use ffi::{ResponseStringCB, ResponseStringStringCB, ResponseStringI64CB, ResponseSliceCB, - ResponseBoolCB}; + ResponseBoolCB, + WalletHandle, + CommandHandle +}; use utils::callbacks::{ClosureHandler, ResultHandler}; -use {WalletHandle, CommandHandle}; use futures::IntoFuture; /// Create the payment address for specified payment method @@ -633,7 +635,7 @@ fn _get_request_info(command_handle: CommandHandle, get_auth_rule_resp_json: &st }) } -pub fn sign_with_address(wallet_handle: i32, address: &str, message: &[u8]) -> Box, Error=IndyError>> { +pub fn sign_with_address(wallet_handle: WalletHandle, address: &str, message: &[u8]) -> Box, Error=IndyError>> { let (receiver, command_handle, cb) = ClosureHandler::cb_ec_slice(); let err = _sign_with_address(command_handle, wallet_handle, address, message, cb); diff --git a/wrappers/rust/src/pool.rs b/wrappers/rust/src/pool.rs index 3e72dc5dea..4fb3bb640c 100644 --- a/wrappers/rust/src/pool.rs +++ b/wrappers/rust/src/pool.rs @@ -51,8 +51,13 @@ fn _create_pool_ledger_config(command_handle: CommandHandle, pool_name: &str, po /// "extended_timeout": int (optional), extended timeout for network request (in sec). /// "preordered_nodes": array - (optional), names of nodes which will have a priority during request sending: /// ["name_of_1st_prior_node", "name_of_2nd_prior_node", .... ] -/// Note: Not specified nodes will be placed in a random way. +/// This can be useful if a user prefers querying specific nodes. +/// Assume that `Node1` and `Node2` nodes reply faster. +/// If you pass them Libindy always sends a read request to these nodes first and only then (if not enough) to others. +/// Note: Nodes not specified will be placed randomly. /// "number_read_nodes": int (optional) - the number of nodes to send read requests (2 by default) +/// By default Libindy sends a read requests to 2 nodes in the pool. +/// If response isn't received or `state proof` is invalid Libindy sends the request again but to 2 (`number_read_nodes`) * 2 = 4 nodes and so far until completion. /// } /// /// # Returns diff --git a/wrappers/rust/src/utils/callbacks.rs b/wrappers/rust/src/utils/callbacks.rs index 66cb10d952..50981bc714 100644 --- a/wrappers/rust/src/utils/callbacks.rs +++ b/wrappers/rust/src/utils/callbacks.rs @@ -1,7 +1,7 @@ #![warn(dead_code)] use ::{ErrorCode, IndyError}; -use ffi::CommandHandle; +use ffi::{WalletHandle, CommandHandle}; use libc::c_char; @@ -16,6 +16,7 @@ lazy_static! { static ref CALLBACKS_EMPTY: Mutex>>> = Default::default(); static ref CALLBACKS_SLICE: Mutex, IndyError>>>> = Default::default(); static ref CALLBACKS_HANDLE: Mutex>>> = Default::default(); + static ref CALLBACKS_WALLETHANDLE: Mutex>>> = Default::default(); static ref CALLBACKS_BOOL: Mutex>>> = Default::default(); static ref CALLBACKS_STR_SLICE: Mutex), IndyError>>>> = Default::default(); static ref CALLBACKS_HANDLE_USIZE: Mutex>>> = Default::default(); @@ -50,7 +51,7 @@ macro_rules! cb_ec { let (rx, command_handle) = { let (tx, rx) = oneshot::channel(); - let command_handle = ::utils::sequence::SequenceUtils::get_next_id(); + let command_handle : CommandHandle = ::utils::sequence::SequenceUtils::get_next_id(); let mut callbacks = $cbs.lock().unwrap(); callbacks.insert(command_handle, tx); (rx, command_handle) @@ -67,6 +68,8 @@ impl ClosureHandler { cb_ec!(cb_ec_handle(handle:CommandHandle)->CommandHandle, CALLBACKS_HANDLE, handle); + cb_ec!(cb_ec_wallethandle(handle:WalletHandle)->WalletHandle, CALLBACKS_WALLETHANDLE, handle); + cb_ec!(cb_ec_handle_usize(handle:CommandHandle, u: usize)->(CommandHandle, usize), CALLBACKS_HANDLE_USIZE, (handle, u)); cb_ec!(cb_ec_string(str1:*const c_char)->String, @@ -129,6 +132,7 @@ pub struct ResultHandler {} impl ResultHandler { result_handler!(empty(()), CALLBACKS_EMPTY); result_handler!(handle(CommandHandle), CALLBACKS_HANDLE); + result_handler!(wallethandle(WalletHandle), CALLBACKS_WALLETHANDLE); result_handler!(slice(Vec), CALLBACKS_SLICE); result_handler!(bool(bool), CALLBACKS_BOOL); result_handler!(str(String), CALLBACKS_STR); diff --git a/wrappers/rust/src/wallet.rs b/wrappers/rust/src/wallet.rs index 57f8aeeeba..7b3ef73ee7 100644 --- a/wrappers/rust/src/wallet.rs +++ b/wrappers/rust/src/wallet.rs @@ -10,7 +10,8 @@ use utils::callbacks::{ClosureHandler, ResultHandler}; use ffi::{wallet, non_secrets}; use ffi::{ResponseEmptyCB, ResponseStringCB, - ResponseI32CB}; + ResponseI32CB, + ResponseWalletHandleCB}; use {CommandHandle, WalletHandle, SearchHandle}; /// Registers custom wallet implementation. @@ -188,14 +189,14 @@ fn _create_wallet(command_handle: CommandHandle, config: &str, credentials: &str /// # Returns /// Handle to opened wallet to use in methods that require wallet access. pub fn open_wallet(config: &str, credentials: &str) -> Box> { - let (receiver, command_handle, cb) = ClosureHandler::cb_ec_handle(); + let (receiver, command_handle, cb) = ClosureHandler::cb_ec_wallethandle(); let err = _open_wallet(command_handle, config, credentials, cb); - ResultHandler::handle(command_handle, err, receiver) + ResultHandler::wallethandle(command_handle, err, receiver) } -fn _open_wallet(command_handle: CommandHandle, config: &str, credentials: &str, cb: Option) -> ErrorCode { +fn _open_wallet(command_handle: CommandHandle, config: &str, credentials: &str, cb: Option) -> ErrorCode { let config = c_str!(config); let credentials = c_str!(credentials); diff --git a/wrappers/rust/tests/did.rs b/wrappers/rust/tests/did.rs index 4bc1869e86..36c4ec2b46 100644 --- a/wrappers/rust/tests/did.rs +++ b/wrappers/rust/tests/did.rs @@ -4,6 +4,8 @@ extern crate rmp_serde; extern crate byteorder; extern crate indyrs as indy; extern crate futures; +extern crate indy_sys; + #[macro_use] mod utils; @@ -15,12 +17,13 @@ use utils::constants::{ SEED_1, VERKEY_1, METADATA, - VERKEY_ABV_1, - INVALID_HANDLE + VERKEY_ABV_1 }; use utils::setup::{Setup, SetupConfig}; use utils::wallet::Wallet; +use indy::{INVALID_WALLET_HANDLE, INVALID_POOL_HANDLE}; + #[allow(unused_imports)] use futures::Future; @@ -107,7 +110,7 @@ mod create_new_did { #[test] fn create_did_with_invalid_wallet_handle() { - let result = did::create_and_store_my_did(INVALID_HANDLE, "{}").wait(); + let result = did::create_and_store_my_did(INVALID_WALLET_HANDLE, "{}").wait(); assert_eq!(ErrorCode::WalletInvalidHandle, result.unwrap_err().error_code); } @@ -139,7 +142,7 @@ mod replace_keys_start { #[test] fn replace_keys_start_invalid_wallet() { - let result = did::replace_keys_start(INVALID_HANDLE, DID_1, "{}").wait(); + let result = did::replace_keys_start(INVALID_WALLET_HANDLE, DID_1, "{}").wait(); assert_eq!(ErrorCode::WalletInvalidHandle, result.unwrap_err().error_code); } @@ -240,7 +243,7 @@ mod replace_keys_apply { #[test] fn replace_keys_apply_invalid_wallet() { - let result = did::replace_keys_apply(INVALID_HANDLE, DID_1).wait(); + let result = did::replace_keys_apply(INVALID_WALLET_HANDLE, DID_1).wait(); assert_eq!(ErrorCode::WalletInvalidHandle, result.unwrap_err().error_code); } } @@ -306,7 +309,7 @@ mod test_store_their_did { #[test] fn store_their_did_invalid_handle() { let config = json!({"did": DID_1, "verkey": VERKEY_1}).to_string(); - let result = did::store_their_did(INVALID_HANDLE, &config).wait(); + let result = did::store_their_did(INVALID_WALLET_HANDLE, &config).wait(); assert_eq!(ErrorCode::WalletInvalidHandle, result.unwrap_err().error_code); } @@ -366,28 +369,7 @@ mod test_store_their_did { did::store_their_did(wallet.handle, &config).wait().unwrap(); - let result = did::store_their_did(wallet.handle, &config).wait(); - - assert_eq!(ErrorCode::WalletItemAlreadyExists, result.unwrap_err().error_code); - } - - #[test] - /* - This test resulted from the ticket https://jira.hyperledger.org/browse/IS-802 - Previously, an error was being thrown because rollback wasn't happening. - This test ensures the error is no longer occuring. - */ - fn store_their_did_multiple_error_fixed() { - let wallet = Wallet::new(); - let config = json!({"did": DID_1, "verkey": VERKEY_1}).to_string(); - did::store_their_did(wallet.handle, &config).wait().unwrap(); - - let result = did::store_their_did(wallet.handle, &config).wait(); - assert_eq!(ErrorCode::WalletItemAlreadyExists, result.unwrap_err().error_code); - - let result = did::store_their_did(wallet.handle, &config).wait(); - assert_eq!(ErrorCode::WalletItemAlreadyExists, result.unwrap_err().error_code); } } @@ -427,7 +409,7 @@ mod test_get_verkey_local { #[test] fn get_verkey_local_invalid_wallet() { - let result = did::key_for_local_did(INVALID_HANDLE, DID_1).wait(); + let result = did::key_for_local_did(INVALID_WALLET_HANDLE, DID_1).wait(); assert_eq!(ErrorCode::WalletInvalidHandle, result.unwrap_err().error_code); } } @@ -521,7 +503,7 @@ mod test_get_verkey_ledger { #[test] fn get_verkey_invalid_wallet() { - let result = did::key_for_did(-1, INVALID_HANDLE, DID_1).wait(); + let result = did::key_for_did(INVALID_POOL_HANDLE, INVALID_WALLET_HANDLE, DID_1).wait(); assert_eq!(ErrorCode::WalletInvalidHandle, result.unwrap_err().error_code); } } @@ -529,6 +511,7 @@ mod test_get_verkey_ledger { #[cfg(test)] mod test_set_metadata { use super::*; + use indy::INVALID_WALLET_HANDLE; #[inline] fn setup() -> (Wallet, String) { @@ -611,7 +594,7 @@ mod test_set_metadata { #[test] fn set_metadata_invalid_wallet() { - let result = did::set_did_metadata(INVALID_HANDLE, DID_1, METADATA).wait(); + let result = did::set_did_metadata(INVALID_WALLET_HANDLE, DID_1, METADATA).wait(); assert_eq!(ErrorCode::WalletInvalidHandle, result.unwrap_err().error_code); } } @@ -680,7 +663,7 @@ mod test_get_metadata { #[test] fn get_metadata_invalid_wallet() { - let result = did::get_did_metadata(INVALID_HANDLE, DID_1).wait(); + let result = did::get_did_metadata(INVALID_WALLET_HANDLE, DID_1).wait(); assert_eq!(ErrorCode::WalletInvalidHandle, result.unwrap_err().error_code); } } @@ -830,6 +813,7 @@ mod test_abbreviate_verkey { #[cfg(test)] mod test_list_with_metadata { use super::*; + use indy::INVALID_WALLET_HANDLE; fn setup_multiple(wallet: &Wallet) -> Vec { let config = json!({"did": DID_1, "verkey": VERKEY_1}).to_string(); @@ -937,7 +921,7 @@ mod test_list_with_metadata { #[test] fn list_with_metadata_invalid_wallet() { - let result = did::list_my_dids_with_metadata(INVALID_HANDLE).wait(); + let result = did::list_my_dids_with_metadata(INVALID_WALLET_HANDLE).wait(); assert_eq!(ErrorCode::WalletInvalidHandle, result.unwrap_err().error_code); } } diff --git a/wrappers/rust/tests/ledger.rs b/wrappers/rust/tests/ledger.rs index 3a28a1d48d..10a871b1db 100644 --- a/wrappers/rust/tests/ledger.rs +++ b/wrappers/rust/tests/ledger.rs @@ -395,14 +395,16 @@ mod test_build_get_attrib_request { let submitter_wallet = Wallet::new(); let wallet = Wallet::new(); - let (submitter_did, _) = did::create_and_store_my_did(submitter_wallet.handle, "{}").wait().unwrap(); - let (did, _) = did::create_and_store_my_did(wallet.handle, "{}").wait().unwrap(); - match ledger::build_get_attrib_request(Some(&submitter_did), &did, Some("{}"), None, None).wait() { - Ok(_) => {}, - Err(ec) => { - assert!(false, "build_attrib_request failed with error {:?}", ec); + let f1 = did::create_and_store_my_did(submitter_wallet.handle, "{}"); + let f2 = did::create_and_store_my_did(wallet.handle, "{}"); + f1.join(f2).map(|((submitter_did, _), (did, _))| { + match ledger::build_get_attrib_request(Some(&submitter_did), &did, Some("{}"), None, None).wait() { + Ok(_) => {}, + Err(ec) => { + assert!(false, "build_attrib_request failed with error {:?}", ec); + } } - } + }).wait().unwrap(); } } @@ -410,7 +412,7 @@ mod test_build_get_attrib_request { mod test_build_schema_request { use super::*; - const SCHEMA_DATA: &str = r#"{"id":"NcYxiDXkpYi6ov5FcYDi1e:2:gvt:1.0","attrNames": ["name", "male"],"name":"gvt2","version":"3.1","ver":"1.0"}"#; + const SCHEMA_DATA: &str = r#"{"id":"NcYxiDXkpYi6ov5FcYDi1e:2:gvt2:3.1","attrNames": ["name", "male"],"name":"gvt2","version":"3.1","ver":"1.0"}"#; #[test] pub fn build_schema_request_success() { @@ -454,7 +456,7 @@ mod test_parse_get_schema_response { use super::*; const SCHEMA_NAME: &str = "schema_1234"; - const SCHEMA_DATA: &str = r#"{"id":"NcYxiDXkpYi6ov5FcYDi1e:2:gvt:1.0","attrNames": ["name", "male"],"name":"schema_1234","version":"1.0","ver":"1.0"}"#; + const SCHEMA_DATA: &str = r#"{"id":"NcYxiDXkpYi6ov5FcYDi1e:2:schema_1234:1.0","attrNames": ["name", "male"],"name":"schema_1234","version":"1.0","ver":"1.0"}"#; fn create_build_schema_request(did: &String) -> String { diff --git a/wrappers/rust/tests/pairwise.rs b/wrappers/rust/tests/pairwise.rs index f55c4268ed..b63fc5cffc 100644 --- a/wrappers/rust/tests/pairwise.rs +++ b/wrappers/rust/tests/pairwise.rs @@ -19,7 +19,7 @@ use utils::constants::{DID_TRUSTEE, VERKEY_TRUSTEE, METADATA, DID}; extern crate failure; use indy::ErrorCode; - +use indy::INVALID_WALLET_HANDLE; mod create_pairwise { use super::*; @@ -70,7 +70,7 @@ mod create_pairwise { indy::did::store_their_did(wallet.handle, &their_identity_json).wait().unwrap(); let (did, _) = indy::did::create_and_store_my_did(wallet.handle, "{}").wait().unwrap(); - let ec = indy::pairwise::create_pairwise(wallet.handle + 1, DID_TRUSTEE, &did, Some(METADATA)).wait().unwrap_err(); + let ec = indy::pairwise::create_pairwise(INVALID_WALLET_HANDLE, DID_TRUSTEE, &did, Some(METADATA)).wait().unwrap_err(); assert_eq!(ec.error_code, ErrorCode::WalletInvalidHandle); } @@ -126,7 +126,7 @@ mod list_pairwise { let (did, _) = indy::did::create_and_store_my_did(wallet.handle, "{}").wait().unwrap(); indy::pairwise::create_pairwise(wallet.handle, DID_TRUSTEE, &did, None).wait().unwrap(); - let ec = indy::pairwise::list_pairwise(wallet.handle + 1).wait().unwrap_err(); + let ec = indy::pairwise::list_pairwise(INVALID_WALLET_HANDLE).wait().unwrap_err(); assert_eq!(ec.error_code, ErrorCode::WalletInvalidHandle); } } @@ -162,7 +162,7 @@ mod pairwise_exists { let (did, _) = indy::did::create_and_store_my_did(wallet.handle, "{}").wait().unwrap(); indy::pairwise::create_pairwise(wallet.handle, DID_TRUSTEE, &did, Some(METADATA)).wait().unwrap(); - assert_eq!(ErrorCode::WalletInvalidHandle, indy::pairwise::is_pairwise_exists(wallet.handle + 1, DID_TRUSTEE).wait().unwrap_err().error_code); + assert_eq!(ErrorCode::WalletInvalidHandle, indy::pairwise::is_pairwise_exists(INVALID_WALLET_HANDLE, DID_TRUSTEE).wait().unwrap_err().error_code); } } @@ -201,7 +201,7 @@ mod get_pairwise { let (did, _) = indy::did::create_and_store_my_did(wallet.handle, "{}").wait().unwrap(); indy::pairwise::create_pairwise(wallet.handle, DID_TRUSTEE, &did, Some(METADATA)).wait().unwrap(); - let ec = indy::pairwise::get_pairwise(wallet.handle + 1, DID_TRUSTEE).wait().unwrap_err(); + let ec = indy::pairwise::get_pairwise(INVALID_WALLET_HANDLE, DID_TRUSTEE).wait().unwrap_err(); assert_eq!(ec.error_code, ErrorCode::WalletInvalidHandle); } @@ -270,7 +270,7 @@ mod set_pairwise_metadata { let (did, _) = indy::did::create_and_store_my_did(wallet.handle, "{}").wait().unwrap(); indy::pairwise::create_pairwise(wallet.handle, DID_TRUSTEE, &did, None).wait().unwrap(); - let ec = indy::pairwise::set_pairwise_metadata(wallet.handle + 1, DID_TRUSTEE, Some(METADATA)).wait().unwrap_err(); + let ec = indy::pairwise::set_pairwise_metadata(INVALID_WALLET_HANDLE, DID_TRUSTEE, Some(METADATA)).wait().unwrap_err(); assert_eq!(ec.error_code, ErrorCode::WalletInvalidHandle); } diff --git a/wrappers/rust/tests/utils/b58.rs b/wrappers/rust/tests/utils/b58.rs index 7ec18238c4..cdce7aa607 100644 --- a/wrappers/rust/tests/utils/b58.rs +++ b/wrappers/rust/tests/utils/b58.rs @@ -1,18 +1,16 @@ extern crate bs58; -use self::bs58::decode::{DecodeError}; - pub trait FromBase58 { - fn from_base58(&self) -> Result, DecodeError>; - fn from_base58_check(&self) -> Result, DecodeError>; + fn from_base58(&self) -> Result, bs58::decode::Error>; + fn from_base58_check(&self) -> Result, bs58::decode::Error>; } impl> FromBase58 for I { - fn from_base58(&self) -> Result, DecodeError> { + fn from_base58(&self) -> Result, bs58::decode::Error> { bs58::decode(self).into_vec() } - fn from_base58_check(&self) -> Result, DecodeError> { + fn from_base58_check(&self) -> Result, bs58::decode::Error> { bs58::decode(self).with_check(None).into_vec() } } diff --git a/wrappers/rust/tests/utils/constants.rs b/wrappers/rust/tests/utils/constants.rs index 91323d6f0b..52f931dd15 100644 --- a/wrappers/rust/tests/utils/constants.rs +++ b/wrappers/rust/tests/utils/constants.rs @@ -5,7 +5,6 @@ pub const DID: &str = "8wZcEriaNLNKtteJvx7f8i"; pub const DID_1: &str = "VsKV7grR1BUE29mG2Fm2kX"; pub const DID_TRUSTEE: &str = "V4SGRU86Z58d6TV7PBUe6f"; pub const EXPORT_KEY: &str = "export_key"; -pub const INVALID_HANDLE: i32 = 583741; pub const METADATA: &str = "some_metadata"; pub const MY1_SEED: &str = "00000000000000000000000000000My1"; pub const PROTOCOL_VERSION: i32 = 2; diff --git a/wrappers/rust/tests/utils/did.rs b/wrappers/rust/tests/utils/did.rs index 93cb5f8946..08014ba687 100644 --- a/wrappers/rust/tests/utils/did.rs +++ b/wrappers/rust/tests/utils/did.rs @@ -5,6 +5,7 @@ use self::futures::Future; use super::indy; use indy::IndyError; +use indy::{WalletHandle, PoolHandle}; type DidAndVerKey = (String, String); @@ -30,8 +31,8 @@ impl NymRole Generate a did and send a nym request for it. */ pub fn create_nym( - wallet_handle: i32, - pool_handle: i32, + wallet_handle: WalletHandle, + pool_handle: PoolHandle, did_trustee: &str, role: NymRole ) -> Result { @@ -54,8 +55,8 @@ pub fn create_nym( Creates multiple dids and corresponding nym requests. */ pub fn create_multiple_nym( - wallet_handle: i32, - pool_handle: i32, + wallet_handle: WalletHandle, + pool_handle: PoolHandle, did_trustee: &str, n: u8, role: NymRole @@ -74,7 +75,7 @@ Create and store the initial dids of trustees. Includes the initial trustee. */ -pub fn initial_trustees(num_trustees: u8, wallet_handle: i32, pool_handle: i32) -> Result, IndyError> { +pub fn initial_trustees(num_trustees: u8, wallet_handle: WalletHandle, pool_handle: PoolHandle) -> Result, IndyError> { let first = initial_trustee(wallet_handle); let mut trustees = create_multiple_nym( @@ -92,7 +93,7 @@ pub fn initial_trustees(num_trustees: u8, wallet_handle: i32, pool_handle: i32) /** Store the did of the intial trustee */ -pub fn initial_trustee(wallet_handle: i32) -> DidAndVerKey { +pub fn initial_trustee(wallet_handle: WalletHandle) -> DidAndVerKey { let first_json_seed = json!({ "seed":"000000000000000000000000Trustee1" }).to_string(); @@ -103,7 +104,7 @@ pub fn initial_trustee(wallet_handle: i32) -> DidAndVerKey { /** Discard the verkey and return the did from a `Vec(trustees: &'a Vec) -> Vec<&'a str> { +pub fn did_str_from_trustees(trustees: &Vec) -> Vec<&str> { trustees .iter() .map(|(ref did, _)| did.as_str()) diff --git a/wrappers/rust/tests/utils/wallet.rs b/wrappers/rust/tests/utils/wallet.rs index 579954e608..ea2e90edd6 100644 --- a/wrappers/rust/tests/utils/wallet.rs +++ b/wrappers/rust/tests/utils/wallet.rs @@ -4,6 +4,7 @@ use self::futures::Future; use super::indy; use indy::IndyError; use utils::rand::random_string; +use indy::{WalletHandle, INVALID_WALLET_HANDLE}; static USEFUL_CREDENTIALS : &'static str = r#"{"key":"8dvfYSt5d1taSd6yJdpjq4emkwsPDDLYxkNFysFD2cZY", "key_derivation_method":"RAW"}"#; @@ -28,14 +29,14 @@ assert!(wallet.handle > 0); */ pub struct Wallet { name: String, - pub handle: i32, + pub handle: WalletHandle, } impl Wallet { /* constructors */ pub fn new() -> Wallet { let wallet_name : String = random_string(20); - let mut wallet = Wallet { name : wallet_name , handle: -1 }; + let mut wallet = Wallet { name : wallet_name , handle: INVALID_WALLET_HANDLE }; wallet.create().unwrap(); wallet.open().unwrap(); @@ -43,7 +44,7 @@ impl Wallet { } pub fn from_name(name: &str) -> Wallet { - let mut wallet = Wallet { name: name.to_string(), handle: -1 }; + let mut wallet = Wallet { name: name.to_string(), handle: INVALID_WALLET_HANDLE }; wallet.create().unwrap(); wallet.open().unwrap(); @@ -58,7 +59,7 @@ impl Wallet { /* private instance methods for open/create/etc...*/ - fn open(&mut self) -> Result { + fn open(&mut self) -> Result { let config : String = Wallet::create_wallet_config(&self.name); let handle = indy::wallet::open_wallet(&config, USEFUL_CREDENTIALS).wait()?; self.handle = handle; diff --git a/wrappers/rust/tests/wallet.rs b/wrappers/rust/tests/wallet.rs index 9479a775c0..0d5a64b303 100644 --- a/wrappers/rust/tests/wallet.rs +++ b/wrappers/rust/tests/wallet.rs @@ -4,6 +4,7 @@ extern crate indyrs as indy; extern crate rmp_serde; extern crate byteorder; extern crate futures; +extern crate indy_sys; use indy::did; use indy::wallet; @@ -14,7 +15,7 @@ use std::path::{Path, PathBuf}; mod utils; -use utils::constants::{DEFAULT_CREDENTIALS, INVALID_HANDLE, METADATA}; +use utils::constants::{DEFAULT_CREDENTIALS, METADATA}; use utils::file::{TempDir, TempFile}; use utils::rand; #[allow(unused_imports)] @@ -385,7 +386,8 @@ mod test_wallet_open { #[cfg(test)] mod test_wallet_close { use super::*; - + use indy::INVALID_WALLET_HANDLE; + #[test] fn close_wallet() { let config = wallet_config::new(); @@ -404,7 +406,7 @@ mod test_wallet_close { #[test] fn close_wallet_invalid_handle() { - let result = wallet::close_wallet(INVALID_HANDLE).wait(); + let result = wallet::close_wallet(INVALID_WALLET_HANDLE).wait(); assert_eq!(ErrorCode::WalletInvalidHandle, result.unwrap_err().error_code); } @@ -428,6 +430,7 @@ mod test_wallet_close { #[cfg(test)] mod test_wallet_export { use super::*; + use indy::INVALID_WALLET_HANDLE; #[test] fn export_wallet() { @@ -482,7 +485,7 @@ mod test_wallet_export { fn export_wallet_invalid_handle() { let (config_export, path, _dir) = wallet_config::export::with_defaults(); - let result = wallet::export_wallet(INVALID_HANDLE, &config_export).wait(); + let result = wallet::export_wallet(INVALID_WALLET_HANDLE, &config_export).wait(); assert_eq!(ErrorCode::WalletInvalidHandle, result.unwrap_err().error_code); assert!(!path.exists()); }