diff --git a/.github/actions/build-napi/action.yml b/.github/actions/build-napi/action.yml index c8ba0a4370..eb6ded59fb 100644 --- a/.github/actions/build-napi/action.yml +++ b/.github/actions/build-napi/action.yml @@ -12,7 +12,7 @@ inputs: node-version: default: 18 rust-version: - default: 1.65.0 + default: 1.70.0 runs: using: "composite" diff --git a/.github/ci/vdrproxy.dockerfile b/.github/ci/vdrproxy.dockerfile index 96c5e78692..95c2b3da47 100644 --- a/.github/ci/vdrproxy.dockerfile +++ b/.github/ci/vdrproxy.dockerfile @@ -18,7 +18,7 @@ RUN apk update && apk upgrade && \ USER indy WORKDIR /home/indy -ARG RUST_VER="1.65.0" +ARG RUST_VER="1.70.0" RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $RUST_VER --default-host x86_64-unknown-linux-musl ENV PATH="/home/indy/.cargo/bin:$PATH" @@ -32,7 +32,7 @@ RUN apk update && apk upgrade && \ USER indy RUN git clone https://github.com/hyperledger/indy-vdr.git WORKDIR /home/indy/indy-vdr/indy-vdr-proxy -RUN git checkout 32f44489 +RUN git checkout c143268 RUN cargo build --release FROM alpine:3.18 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c7da1db239..ea81f7f8de 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -118,7 +118,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - backend: ["vdrtools", "modular_libs", "vdr_proxy_ledger"] + backend: ["credx,vdrtools_wallet", "vdr_proxy_ledger"] steps: - name: "Git checkout" uses: actions/checkout@v3 @@ -133,7 +133,27 @@ jobs: sudo apt-get install -y libsodium-dev libssl-dev libzmq3-dev - name: "Verify clippy across the entire workspace with default features" run: | - cargo clippy -p aries-vcx --features legacy_proof,migration --features ${{ matrix.backend }} --no-default-features + cargo clippy -p aries-vcx --features legacy_proof --features ${{ matrix.backend }} --no-default-features + env: + RUSTFLAGS: -D warnings + + aries_vcx_no_features_clippy: + runs-on: ubuntu-20.04 + steps: + - name: "Git checkout" + uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ env.RUST_TOOLCHAIN_VERSON }} + components: clippy + - name: "Install dependencies" + shell: bash + run: | + sudo apt-get update -y + sudo apt-get install -y libsodium-dev libssl-dev libzmq3-dev + - name: "Verify clippy across the entire workspace with default features" + run: | + cargo clippy -p aries-vcx --no-default-features env: RUSTFLAGS: -D warnings @@ -141,7 +161,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - backend: ["vdrtools_anoncreds", "modular_libs", "vdr_proxy_ledger"] + backend: ["credx,vdrtools_wallet", "vdr_proxy_ledger"] steps: - name: "Git checkout" uses: actions/checkout@v3 @@ -237,7 +257,7 @@ jobs: run: | RUSTFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \ RUSTDOCFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \ - RUST_TEST_THREADS=1 CARGO_INCREMENTAL=0 TEST_POOL_IP=127.0.0.1 cargo test --package aries-vcx -F 'modular_libs' -- --ignored; + RUST_TEST_THREADS=1 CARGO_INCREMENTAL=0 TEST_POOL_IP=127.0.0.1 cargo test --package aries-vcx -- --ignored; mkdir -p /tmp/artifacts/coverage grcov ./target/debug/ -s . -t lcov --llvm --branch --ignore-not-existing -o /tmp/artifacts/coverage/coverage.lcov @@ -274,12 +294,6 @@ jobs: test-integration-aries-vcx: needs: workflow-setup runs-on: ubuntu-20.04 - strategy: - matrix: - features: [ - "vdrtools", - "modular_libs" - ] steps: - name: "Git checkout" uses: actions/checkout@v3 @@ -288,7 +302,7 @@ jobs: with: rust-toolchain-version: ${{ env.RUST_TOOLCHAIN_VERSON }} - name: "Run aries-vcx integration tests" - run: RUST_TEST_THREADS=1 cargo test --manifest-path="aries_vcx/Cargo.toml" --features ${{ matrix.features }} -- --ignored; + run: RUST_TEST_THREADS=1 cargo test --manifest-path="aries_vcx/Cargo.toml" -- --ignored; test-integration-aries-vcx-mysql: needs: workflow-setup @@ -332,24 +346,6 @@ jobs: with: name: "docker-services-${{ github.job }}" - test-integration-aries-vcx-migration: - needs: workflow-setup - runs-on: ubuntu-20.04 - steps: - - name: "Git checkout" - uses: actions/checkout@v3 - - name: "Setup rust testing environment" - uses: ./.github/actions/setup-testing-rust - with: - rust-toolchain-version: ${{ env.RUST_TOOLCHAIN_VERSON }} - - name: "Run aries-vcx tests: pool_tests agency_pool_tests" - run: | - cargo test --manifest-path="wallet_migrator/Cargo.toml"; - RUST_TEST_THREADS=1 CARGO_INCREMENTAL=0 TEST_POOL_IP=127.0.0.1 cargo test --manifest-path="aries_vcx/Cargo.toml" -F migration --test test_credential_issuance -- --include-ignored; - RUST_TEST_THREADS=1 CARGO_INCREMENTAL=0 TEST_POOL_IP=127.0.0.1 cargo test --manifest-path="aries_vcx/Cargo.toml" -F migration --test test_credential_retrieval -- --include-ignored; - RUST_TEST_THREADS=1 CARGO_INCREMENTAL=0 TEST_POOL_IP=127.0.0.1 cargo test --manifest-path="aries_vcx/Cargo.toml" -F migration --test test_proof_presentation -- --include-ignored; - RUST_TEST_THREADS=1 CARGO_INCREMENTAL=0 TEST_POOL_IP=127.0.0.1 cargo test --manifest-path="aries_vcx/Cargo.toml" -F migration --test test_revocations -- --include-ignored; - test-integration-libvcx: needs: workflow-setup if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} diff --git a/Cargo.lock b/Cargo.lock index 6c019f7cce..46ca1d7b38 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -21,17 +21,17 @@ dependencies = [ [[package]] name = "actix-http" -version = "3.3.1" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2079246596c18b4a33e274ae10c0e50613f4d32a4198e09c7b93771013fed74" +checksum = "a92ef85799cba03f76e4f7c10f533e66d87c9a7e7055f3391f09000ad8351bc9" dependencies = [ "actix-codec", "actix-rt", "actix-service", "actix-utils", - "ahash 0.8.3", - "base64 0.21.2", - "bitflags 1.3.2", + "ahash", + "base64", + "bitflags 2.4.0", "brotli", "bytes", "bytestring", @@ -43,7 +43,7 @@ dependencies = [ "http", "httparse", "httpdate", - "itoa 1.0.9", + "itoa", "language-tags", "local-channel", "mime", @@ -65,7 +65,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" dependencies = [ "quote", - "syn 2.0.28", + "syn 2.0.38", ] [[package]] @@ -83,9 +83,9 @@ dependencies = [ [[package]] name = "actix-rt" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15265b6b8e2347670eb363c47fc8c75208b4a4994b27192f345fcbe707804f3e" +checksum = "28f32d40287d3f402ae0028a9d54bef51af15c8769492826a69d28f81893151d" dependencies = [ "futures-core", "tokio", @@ -93,9 +93,9 @@ dependencies = [ [[package]] name = "actix-server" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e8613a75dd50cc45f473cee3c34d59ed677c0f7b44480ce3b8247d7dc519327" +checksum = "3eb13e7eef0423ea6eab0e59f6c72e7cb46d33691ad56a726b3cd07ddec2c2d4" dependencies = [ "actix-rt", "actix-service", @@ -103,8 +103,7 @@ dependencies = [ "futures-core", "futures-util", "mio", - "num_cpus", - "socket2", + "socket2 0.5.4", "tokio", "tracing", ] @@ -132,9 +131,9 @@ dependencies = [ [[package]] name = "actix-web" -version = "4.3.1" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd3cb42f9566ab176e1ef0b8b3a896529062b4efc6be0123046095914c4c1c96" +checksum = "0e4a5b5e29603ca8c94a77c65cf874718ceb60292c5a5c3e5f4ace041af462b9" dependencies = [ "actix-codec", "actix-http", @@ -145,17 +144,16 @@ dependencies = [ "actix-service", "actix-utils", "actix-web-codegen", - "ahash 0.7.6", + "ahash", "bytes", "bytestring", - "cfg-if 1.0.0", + "cfg-if", "cookie", "derive_more", "encoding_rs", "futures-core", "futures-util", - "http", - "itoa 1.0.9", + "itoa", "language-tags", "log", "mime", @@ -166,28 +164,28 @@ dependencies = [ "serde_json", "serde_urlencoded", "smallvec", - "socket2", + "socket2 0.5.4", "time 0.3.20", "url", ] [[package]] name = "actix-web-codegen" -version = "4.2.0" +version = "4.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2262160a7ae29e3415554a3f1fc04c764b1540c116aa524683208078b7a75bc9" +checksum = "eb1f50ebbb30eca122b188319a4398b3f7bb4a8cdf50ecfb73bfc6a3c3ce54f5" dependencies = [ "actix-router", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.38", ] [[package]] name = "addr2line" -version = "0.19.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ "gimli", ] @@ -198,72 +196,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aead" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331" -dependencies = [ - "generic-array 0.14.7", -] - -[[package]] -name = "aes" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "884391ef1066acaa41e766ba8f596341b96e93ce34f9a43e7d24bf0a0eaf0561" -dependencies = [ - "aes-soft", - "aesni", - "cipher 0.2.5", -] - -[[package]] -name = "aes" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" -dependencies = [ - "cfg-if 1.0.0", - "cipher 0.3.0", - "cpufeatures", - "opaque-debug 0.3.0", -] - -[[package]] -name = "aes-gcm" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5278b5fabbb9bd46e24aa69b2fdea62c99088e0a950a9be40e3e0101298f88da" -dependencies = [ - "aead", - "aes 0.6.0", - "cipher 0.2.5", - "ctr", - "ghash", - "subtle", -] - -[[package]] -name = "aes-soft" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072" -dependencies = [ - "cipher 0.2.5", - "opaque-debug 0.3.0", -] - -[[package]] -name = "aesni" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce" -dependencies = [ - "cipher 0.2.5", - "opaque-debug 0.3.0", -] - [[package]] name = "agency_client" version = "0.59.1" @@ -283,34 +215,23 @@ dependencies = [ "uuid 0.8.2", ] -[[package]] -name = "ahash" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" -dependencies = [ - "getrandom 0.2.9", - "once_cell", - "version_check", -] - [[package]] name = "ahash" version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ - "cfg-if 1.0.0", - "getrandom 0.2.9", + "cfg-if", + "getrandom 0.2.10", "once_cell", "version_check", ] [[package]] name = "aho-corasick" -version = "1.0.3" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b8f9420f797f2d9e935edf629310eb938a0d839f984e25327f3c7eed22300c" +checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab" dependencies = [ "memchr", ] @@ -331,29 +252,16 @@ dependencies = [ ] [[package]] -name = "amcl" -version = "0.2.0" +name = "allocator-api2" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee5cca1ddc8b9dceb55b7f1272a9d1e643d73006f350a20ab4926d24e33f0f0d" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] -name = "amcl_wrapper" -version = "0.4.0" +name = "amcl" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c7c7c7627444413f6a488bf9e6d352aea6fcfa281123cd92ecac0b3c9ef5ef2" -dependencies = [ - "byteorder", - "lazy_static", - "miracl_core", - "rand 0.7.3", - "rayon", - "serde", - "serde_bytes", - "serde_json", - "sha3 0.8.2", - "subtle-encoding", - "zeroize", -] +checksum = "ee5cca1ddc8b9dceb55b7f1272a9d1e643d73006f350a20ab4926d24e33f0f0d" [[package]] name = "android-tzdata" @@ -363,19 +271,20 @@ checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" [[package]] name = "android_log-sys" -version = "0.1.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8052e2d8aabbb8d556d6abbcce2a22b9590996c5f849b9c7ce4544a2e3b984e" +checksum = "5ecc8056bf6ab9892dcd53216c83d1597487d7dacac16c8df6b877d127df9937" [[package]] name = "android_logger" -version = "0.5.3" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86983875e7c3a202e31471cc6d60fcc18f30e194f1729cfff3bfb43d646ffced" +checksum = "c494134f746c14dc653a35a4ea5aca24ac368529da5370ecf41fe0341c35772f" dependencies = [ "android_log-sys", - "lazy_static", + "env_logger 0.10.0", "log", + "once_cell", ] [[package]] @@ -389,28 +298,28 @@ dependencies = [ [[package]] name = "anoncreds-clsignatures" -version = "0.2.0" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f683463c4f5558a4eab7fe4625d94f08b7de9691453032bac43facf06fe46d2e" +checksum = "5f0a6071c39753711af4abaac08590f276980ae550d4e8f4b8c4a0b40a3dc39c" dependencies = [ "amcl", "glass_pumpkin", "log", - "num-bigint 0.4.3", + "num-bigint", "num-integer", "num-traits", "once_cell", "openssl", "rand 0.8.5", "serde", - "sha2 0.10.7", + "sha2", ] [[package]] name = "anyhow" -version = "1.0.72" +version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" [[package]] name = "aries-vcx" @@ -421,31 +330,31 @@ dependencies = [ "aries_vcx_core", "async-channel", "async-trait", - "base64 0.10.1", - "bs58 0.4.0", + "base64", + "bs58 0.5.0", "chrono", - "derive_builder 0.10.2", + "derive_builder 0.12.0", "diddoc_legacy", - "env_logger 0.9.3", + "env_logger 0.10.0", "futures", "lazy_static", "log", "messages", - "num-bigint 0.4.3", - "rand 0.7.3", + "num-bigint", + "rand 0.8.5", "regex", "serde", "serde_derive", "serde_json", - "sha2 0.10.7", + "sha2", "shared_vcx", - "strum 0.16.0", - "strum_macros 0.16.0", + "strum 0.25.0", + "strum_macros 0.25.2", "thiserror", "time 0.3.20", "tokio", "url", - "uuid 0.8.2", + "uuid 1.4.1", "wallet_migrator", ] @@ -481,8 +390,8 @@ dependencies = [ "lazy_static", "libvdrtools", "log", - "lru 0.10.1", - "rand 0.7.3", + "lru", + "rand 0.8.5", "serde", "serde_json", "thiserror", @@ -491,12 +400,6 @@ dependencies = [ "uuid 1.4.1", ] -[[package]] -name = "arrayref" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" - [[package]] name = "askama" version = "0.11.1" @@ -565,14 +468,14 @@ dependencies = [ [[package]] name = "async-executor" -version = "1.5.1" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fa3dc5f2a8564f07759c008b9109dc0d39de92a88d5588b8a5036d286383afb" +checksum = "2c1da3ae8dabd9c00f453a329dfe1fb28da3c0a72e2478cdcd93171740c20499" dependencies = [ "async-lock", "async-task", "concurrent-queue", - "fastrand", + "fastrand 2.0.1", "futures-lite", "slab", ] @@ -599,16 +502,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" dependencies = [ "async-lock", - "autocfg 1.1.0", - "cfg-if 1.0.0", + "autocfg", + "cfg-if", "concurrent-queue", "futures-lite", "log", "parking", "polling", - "rustix", + "rustix 0.37.24", "slab", - "socket2", + "socket2 0.4.9", "waker-fn", ] @@ -667,14 +570,14 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.38", ] [[package]] name = "async-task" -version = "4.4.0" +version = "4.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc7ab41815b3c653ccd2978ec3255c81349336702dfdf62ee6f7069b12a3aae" +checksum = "b9441c6b2fe128a7c2bf680a44c34d0df31ce09e5b7e401fcca3faa483dbc921" [[package]] name = "async-trait" @@ -684,23 +587,23 @@ checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.38", ] [[package]] name = "atoi" -version = "0.4.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "616896e05fc0e2649463a93a15183c6a16bf03413a7af88ef1285ddedfa9cda5" +checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" dependencies = [ "num-traits", ] [[package]] name = "atomic-waker" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1181e1e0d1fce796a03db1ae795d67167da795f9cf4a39c37589e85ef57f26d3" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "atty" @@ -713,15 +616,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "autocfg" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dde43e75fd43e8a1bf86103336bc699aa8d17ad1be60c76c0bdfd4828e19b78" -dependencies = [ - "autocfg 1.1.0", -] - [[package]] name = "autocfg" version = "1.1.0" @@ -730,15 +624,15 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.67" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" dependencies = [ "addr2line", "cc", - "cfg-if 1.0.0", + "cfg-if", "libc", - "miniz_oxide 0.6.2", + "miniz_oxide", "object", "rustc-demangle", ] @@ -751,24 +645,15 @@ checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" [[package]] name = "base64" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" -dependencies = [ - "byteorder", -] - -[[package]] -name = "base64" -version = "0.13.1" +version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" [[package]] -name = "base64" -version = "0.21.2" +name = "base64ct" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "bincode" @@ -790,38 +675,8 @@ name = "bitflags" version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" - -[[package]] -name = "blake2" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a4e37d16930f5459780f5621038b6382b9bb37c19016f39fb6b5808d831f174" -dependencies = [ - "crypto-mac 0.8.0", - "digest 0.9.0", - "opaque-debug 0.3.0", -] - -[[package]] -name = "block-buffer" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" -dependencies = [ - "block-padding 0.1.5", - "byte-tools", - "byteorder", - "generic-array 0.12.4", -] - -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "block-padding 0.2.1", - "generic-array 0.14.7", + "serde", ] [[package]] @@ -830,54 +685,30 @@ version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ - "generic-array 0.14.7", -] - -[[package]] -name = "block-modes" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a0e8073e8baa88212fb5823574c02ebccb395136ba9a164ab89379ec6072f0" -dependencies = [ - "block-padding 0.2.1", - "cipher 0.2.5", + "generic-array", ] -[[package]] -name = "block-padding" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -dependencies = [ - "byte-tools", -] - -[[package]] -name = "block-padding" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" - [[package]] name = "blocking" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77231a1c8f801696fc0123ec6150ce92cffb8e164a02afb9c8ddee0e9b65ad65" +checksum = "94c4ef1f913d78636d78d538eec1f18de81e481f44b1be0a81060090530846e1" dependencies = [ "async-channel", "async-lock", "async-task", - "atomic-waker", - "fastrand", + "fastrand 2.0.1", + "futures-io", "futures-lite", - "log", + "piper", + "tracing", ] [[package]] name = "brotli" -version = "3.3.4" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1a0b1dbcc8ae29329621f8d4f0d835787c1c38bb1401979b49d13b0b305ff68" +checksum = "516074a47ef4bce09577a3b379392300159ce5b1ba2e501ff1c819950066100f" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -886,9 +717,9 @@ dependencies = [ [[package]] name = "brotli-decompressor" -version = "2.3.4" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b6561fd3f895a11e8f72af2cb7d22e08366bebc2b6b57f7744c4bda27034744" +checksum = "da74e2b81409b1b743f8f0c62cc6254afefb8b8e50bbfe3735550f7aeefa3448" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -911,27 +742,21 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" - -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "bytestring" @@ -942,15 +767,6 @@ dependencies = [ "bytes", ] -[[package]] -name = "c2-chacha" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "217192c943108d8b13bac38a1d51df9ce8a407a3f5a71ab633980665e68fbd9a" -dependencies = [ - "ppv-lite86", -] - [[package]] name = "camino" version = "1.1.6" @@ -985,81 +801,33 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.82" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "305fe645edc1442a0fa8b6726ba61d422798d37a52e12eaecf4b022ebbb88f01" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ "jobserver", "libc", ] -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "chacha20" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed8738f14471a99f0e316c327e68fc82a3611cc2895fcb604b89eedaf8f39d95" -dependencies = [ - "cipher 0.2.5", - "zeroize", -] - -[[package]] -name = "chacha20poly1305" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af1fc18e6d90c40164bf6c317476f2a98f04661e310e79830366b7e914c58a8e" -dependencies = [ - "aead", - "chacha20", - "cipher 0.2.5", - "poly1305", - "zeroize", -] - [[package]] name = "chrono" -version = "0.4.26" +version = "0.4.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", "serde", - "time 0.1.45", "wasm-bindgen", - "winapi", -] - -[[package]] -name = "cipher" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" -dependencies = [ - "generic-array 0.14.7", -] - -[[package]] -name = "cipher" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" -dependencies = [ - "generic-array 0.14.7", + "windows-targets", ] [[package]] @@ -1072,7 +840,7 @@ dependencies = [ "bitflags 1.3.2", "clap_derive", "clap_lex", - "indexmap", + "indexmap 1.9.3", "once_cell", "strsim 0.10.0", "termcolor", @@ -1085,7 +853,7 @@ version = "3.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae6371b8bdc8b7d3959e9cf7b22d4435ef3e79e138688421ec654acf8c81b008" dependencies = [ - "heck 0.4.1", + "heck", "proc-macro-error", "proc-macro2", "quote", @@ -1101,15 +869,6 @@ dependencies = [ "os_str_bytes", ] -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "cmake" version = "0.1.50" @@ -1121,18 +880,28 @@ dependencies = [ [[package]] name = "concurrent-queue" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62ec6771ecfa0762d24683ee5a32ad78487a3d3afdc0fb8cae19d2c5deb50b7c" +checksum = "f057a694a54f12365049b0958a1685bb52d567f5593b355fbf685838e873d400" dependencies = [ "crossbeam-utils", ] +[[package]] +name = "console_error_panic_hook" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +dependencies = [ + "cfg-if", + "wasm-bindgen", +] + [[package]] name = "const-oid" -version = "0.6.2" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b" +checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" [[package]] name = "convert_case" @@ -1194,26 +963,20 @@ dependencies = [ "libc", ] -[[package]] -name = "cpuid-bool" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcb25d077389e53838a8158c8e99174c5a9d902dee4904320db714f3c653ffba" - [[package]] name = "crc" -version = "2.1.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49fc9a695bca7f35f5f4c15cddc84415f66a74ea78eef08e90c5024f2b540e23" +checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" dependencies = [ "crc-catalog", ] [[package]] name = "crc-catalog" -version = "1.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccaeedb56da03b09f598226e25e80088cb4cd25f316e6e4df7d695f0feeb1403" +checksum = "9cace84e55f07e7301bae1c519df89cdad8cc3cd868413d3fdbdeca9ff3db484" [[package]] name = "crc32fast" @@ -1221,41 +984,7 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "crossbeam-channel" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" -dependencies = [ - "cfg-if 1.0.0", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" -dependencies = [ - "cfg-if 1.0.0", - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" -dependencies = [ - "autocfg 1.1.0", - "cfg-if 1.0.0", - "crossbeam-utils", - "memoffset", - "scopeguard", + "cfg-if", ] [[package]] @@ -1264,7 +993,7 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "crossbeam-utils", ] @@ -1274,19 +1003,7 @@ version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "crypto-bigint" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83bd3bb4314701c568e340cd8cf78c975aa0ca79e03d3f6d1677d5b0c9c0c03" -dependencies = [ - "generic-array 0.14.7", - "rand_core 0.6.4", - "subtle", - "zeroize", + "cfg-if", ] [[package]] @@ -1295,60 +1012,46 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "generic-array 0.14.7", + "generic-array", "typenum", ] -[[package]] -name = "crypto-mac" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" -dependencies = [ - "generic-array 0.14.7", - "subtle", -] - -[[package]] -name = "crypto-mac" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" -dependencies = [ - "generic-array 0.14.7", - "subtle", -] - [[package]] name = "ctor" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f34ba9a9bcb8645379e9de8cb3ecfcf4d1c85ba66d90deb3259206fa5aa193b" +checksum = "37e366bff8cd32dd8754b0991fb66b279dc48f598c3a18914852a6673deef583" dependencies = [ "quote", - "syn 2.0.28", + "syn 2.0.38", ] [[package]] -name = "ctr" -version = "0.6.0" +name = "curve25519-dalek" +version = "4.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb4a30d54f7443bf3d6191dcd486aca19e67cb3c49fa7a06a319966346707e7f" +checksum = "e89b8c6a2e4b1f45971ad09761aafb85514a84744b67a95e32c3cc1352d1f65c" dependencies = [ - "cipher 0.2.5", + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest", + "fiat-crypto", + "platforms", + "rustc_version", + "subtle", + "zeroize", ] [[package]] -name = "curve25519-dalek" -version = "3.2.1" +name = "curve25519-dalek-derive" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90f9d052967f590a76e62eb387bd0bbb1b000182c3cefe5364db6b7211651bc0" +checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.5.1", - "subtle", - "zeroize", + "proc-macro2", + "quote", + "syn 2.0.38", ] [[package]] @@ -1361,16 +1064,6 @@ dependencies = [ "darling_macro 0.10.2", ] -[[package]] -name = "darling" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f2c43f534ea4b0b049015d00269734195e6d3f0f6635cb692251aca6f9f8b3c" -dependencies = [ - "darling_core 0.12.4", - "darling_macro 0.12.4", -] - [[package]] name = "darling" version = "0.14.4" @@ -1405,20 +1098,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "darling_core" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e91455b86830a1c21799d94524df0845183fa55bafd9aa137b01c7d1065fa36" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim 0.10.0", - "syn 1.0.109", -] - [[package]] name = "darling_core" version = "0.14.4" @@ -1444,7 +1123,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn 2.0.28", + "syn 2.0.38", ] [[package]] @@ -1458,17 +1137,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "darling_macro" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29b5acf0dea37a7f66f7b25d2c5e93fd46f8f6968b1a5d7a3e02e97768afc95a" -dependencies = [ - "darling_core 0.12.4", - "quote", - "syn 1.0.109", -] - [[package]] name = "darling_macro" version = "0.14.4" @@ -1488,7 +1156,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core 0.20.3", "quote", - "syn 2.0.28", + "syn 2.0.38", ] [[package]] @@ -1519,20 +1187,13 @@ dependencies = [ [[package]] name = "der" -version = "0.4.5" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b71cca7d95d7681a4b3b9cdf63c8dbc3730d0584c2c74e31416d64a90493f4" +checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" dependencies = [ "const-oid", -] - -[[package]] -name = "derive_builder" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d13202debe11181040ae9063d739fa32cfcaaebe2275fe387703460ae2365b30" -dependencies = [ - "derive_builder_macro 0.10.2", + "pem-rfc7468", + "zeroize", ] [[package]] @@ -1553,18 +1214,6 @@ dependencies = [ "derive_builder_macro 0.12.0", ] -[[package]] -name = "derive_builder_core" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66e616858f6187ed828df7c64a6d71720d83767a7f19740b2d1b6fe6327b36e5" -dependencies = [ - "darling 0.12.4", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "derive_builder_core" version = "0.11.2" @@ -1589,16 +1238,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "derive_builder_macro" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58a94ace95092c5acb1e97a7e846b310cfbd499652f72297da7493f618a98d73" -dependencies = [ - "derive_builder_core 0.10.2", - "syn 1.0.109", -] - [[package]] name = "derive_builder_macro" version = "0.11.2" @@ -1636,12 +1275,12 @@ dependencies = [ name = "did_doc" version = "0.1.0" dependencies = [ - "base64 0.21.2", + "base64", "bs58 0.5.0", "did_parser", "hex", "multibase", - "pem 2.0.1", + "pem", "public_key", "serde", "serde_json", @@ -1653,7 +1292,7 @@ dependencies = [ name = "did_doc_sov" version = "0.1.0" dependencies = [ - "base64 0.21.2", + "base64", "did_doc", "did_key", "public_key", @@ -1686,7 +1325,7 @@ name = "did_peer" version = "0.1.0" dependencies = [ "async-trait", - "base64 0.21.2", + "base64", "bs58 0.5.0", "did_doc", "did_doc_sov", @@ -1778,60 +1417,44 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" -[[package]] -name = "digest" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -dependencies = [ - "generic-array 0.12.4", -] - -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array 0.14.7", -] - [[package]] name = "digest" version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "block-buffer 0.10.4", + "block-buffer", + "const-oid", "crypto-common", + "subtle", ] [[package]] name = "dirs" -version = "2.0.2" +version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" dependencies = [ - "cfg-if 0.1.10", "dirs-sys", ] [[package]] name = "dirs-sys" -version = "0.3.7" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" dependencies = [ "libc", + "option-ext", "redox_users", - "winapi", + "windows-sys", ] [[package]] -name = "dotenv" -version = "0.15.0" +name = "dotenvy" +version = "0.15.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" [[package]] name = "downcast" @@ -1839,38 +1462,24 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" -[[package]] -name = "ecdsa" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43ee23aa5b4f68c7a092b5c3beb25f50c406adc75e2363634f242f28ab255372" -dependencies = [ - "der", - "elliptic-curve", - "hmac", - "signature", -] - [[package]] name = "ed25519" -version = "1.5.3" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" +checksum = "60f6d271ca33075c88028be6f04d502853d63a5ece419d269c15315d4fc1cf1d" dependencies = [ "signature", ] [[package]] name = "ed25519-dalek" -version = "1.0.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" +checksum = "7277392b266383ef8396db7fdeb1e77b6c52fed775f5df15bb24f35b72156980" dependencies = [ "curve25519-dalek", "ed25519", - "rand 0.7.3", - "serde", - "sha2 0.9.9", + "sha2", "zeroize", ] @@ -1879,6 +1488,9 @@ name = "either" version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +dependencies = [ + "serde", +] [[package]] name = "elastic-array-plus" @@ -1886,29 +1498,13 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "562cc8504a01eb20c10fb154abd7c4baeb9beba2329cf85838ee2bd48a468b18" -[[package]] -name = "elliptic-curve" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beca177dcb8eb540133e7680baff45e7cc4d93bf22002676cec549f82343721b" -dependencies = [ - "crypto-bigint", - "ff", - "generic-array 0.14.7", - "group", - "pkcs8", - "rand_core 0.6.4", - "subtle", - "zeroize", -] - [[package]] name = "encoding_rs" -version = "0.8.32" +version = "0.8.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" +checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] [[package]] @@ -1937,15 +1533,21 @@ dependencies = [ "termcolor", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "errno" -version = "0.3.2" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f" +checksum = "add4f07d43996f76ef320709726a556a9d4f965d9410d8d0271132d2f8293480" dependencies = [ "errno-dragonfly", "libc", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -1964,6 +1566,17 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9435d864e017c3c6afeac1654189b06cdb491cf2ff73dbf0d73b0f292f42ff8" +[[package]] +name = "etcetera" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943" +dependencies = [ + "cfg-if", + "home", + "windows-sys", +] + [[package]] name = "etcommon-hexutil" version = "0.2.4" @@ -2020,14 +1633,10 @@ dependencies = [ ] [[package]] -name = "ff" -version = "0.10.1" +name = "fastrand" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0f40b2dcd8bc322217a5f6559ae5f9e9d1de202a2ecee2e9eafcbece7562a4f" -dependencies = [ - "rand_core 0.6.4", - "subtle", -] +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" [[package]] name = "ffi-support" @@ -2039,14 +1648,26 @@ dependencies = [ "log", ] +[[package]] +name = "fiat-crypto" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0870c84016d4b481be5c9f323c24f65e31e901ae618f0e80f4308fb00de1d2d" + +[[package]] +name = "finl_unicode" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6" + [[package]] name = "flate2" -version = "1.0.26" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" +checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010" dependencies = [ "crc32fast", - "miniz_oxide 0.7.1", + "miniz_oxide", ] [[package]] @@ -2058,6 +1679,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "flume" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" +dependencies = [ + "futures-core", + "futures-sink", + "spin 0.9.8", +] + [[package]] name = "fnv" version = "1.0.7" @@ -2100,12 +1732,6 @@ version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0845fa252299212f0389d64ba26f34fa32cfe41588355f21ed507c59a0f64541" -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - [[package]] name = "futures" version = "0.3.28" @@ -2151,13 +1777,13 @@ dependencies = [ [[package]] name = "futures-intrusive" -version = "0.4.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a604f7a68fbf8103337523b1fadc8ade7361ee3f112f7c680ad179651616aed5" +checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" dependencies = [ "futures-core", "lock_api", - "parking_lot 0.11.2", + "parking_lot", ] [[package]] @@ -2172,7 +1798,7 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" dependencies = [ - "fastrand", + "fastrand 1.9.0", "futures-core", "futures-io", "memchr", @@ -2189,7 +1815,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.38", ] [[package]] @@ -2222,15 +1848,6 @@ dependencies = [ "slab", ] -[[package]] -name = "generic-array" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" -dependencies = [ - "typenum", -] - [[package]] name = "generic-array" version = "0.14.7" @@ -2247,7 +1864,7 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "js-sys", "libc", "wasi 0.9.0+wasi-snapshot-preview1", @@ -2256,30 +1873,20 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "libc", "wasi 0.11.0+wasi-snapshot-preview1", ] -[[package]] -name = "ghash" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97304e4cd182c3846f7575ced3890c53012ce534ad9114046b0a9e00bb30a375" -dependencies = [ - "opaque-debug 0.3.0", - "polyval", -] - [[package]] name = "gimli" -version = "0.27.3" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" +checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" [[package]] name = "glass_pumpkin" @@ -2288,7 +1895,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e847fe780e2fd8aa993bef2124361c285349ff0e9315e8285f8126386b54a9" dependencies = [ "core2", - "num-bigint 0.4.3", + "num-bigint", "num-integer", "num-traits", "once_cell", @@ -2324,22 +1931,11 @@ dependencies = [ "scroll", ] -[[package]] -name = "group" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c363a5301b8f153d80747126a04b3c82073b9fe3130571a9d170cacdeaf7912" -dependencies = [ - "ff", - "rand_core 0.6.4", - "subtle", -] - [[package]] name = "h2" -version = "0.3.20" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049" +checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" dependencies = [ "bytes", "fnv", @@ -2347,64 +1943,47 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap", + "indexmap 1.9.3", "slab", "tokio", "tokio-util", "tracing", ] -[[package]] -name = "hashbrown" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" -dependencies = [ - "ahash 0.7.6", -] - [[package]] name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -dependencies = [ - "ahash 0.7.6", -] [[package]] name = "hashbrown" -version = "0.13.2" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" dependencies = [ - "ahash 0.8.3", + "ahash", + "allocator-api2", ] [[package]] name = "hashlink" -version = "0.7.0" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7249a3129cbc1ffccd74857f81464a323a152173cdb134e0fd81bc803b29facf" +checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" dependencies = [ - "hashbrown 0.11.2", + "hashbrown 0.14.1", ] [[package]] name = "heck" -version = "0.3.3" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" dependencies = [ "unicode-segmentation", ] -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - [[package]] name = "hermit-abi" version = "0.1.19" @@ -2416,9 +1995,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" [[package]] name = "hex" @@ -2428,22 +2007,29 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hkdf" -version = "0.11.0" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01706d578d5c281058480e673ae4086a9f4710d8df1ad80a5b03e39ece5f886b" +checksum = "791a029f6b9fc27657f6f188ec6e5e43f6911f6f878e0dc5501396e09809d437" dependencies = [ - "digest 0.9.0", "hmac", ] [[package]] name = "hmac" -version = "0.11.0" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "home" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" dependencies = [ - "crypto-mac 0.11.1", - "digest 0.9.0", + "windows-sys", ] [[package]] @@ -2454,7 +2040,7 @@ checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" dependencies = [ "bytes", "fnv", - "itoa 1.0.9", + "itoa", ] [[package]] @@ -2501,9 +2087,9 @@ dependencies = [ "http-body", "httparse", "httpdate", - "itoa 1.0.9", + "itoa", "pin-project-lite", - "socket2", + "socket2 0.4.9", "tokio", "tower-service", "tracing", @@ -2568,16 +2154,25 @@ version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ - "autocfg 1.1.0", + "autocfg", "hashbrown 0.12.3", ] +[[package]] +name = "indexmap" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" +dependencies = [ + "equivalent", + "hashbrown 0.14.1", +] + [[package]] name = "indy-api-types" version = "0.1.0" dependencies = [ - "aes 0.7.5", - "bs58 0.4.0", + "bs58 0.5.0", "futures", "libc", "log", @@ -2588,7 +2183,6 @@ dependencies = [ "sqlx", "thiserror", "ursa", - "zeroize", ] [[package]] @@ -2600,60 +2194,68 @@ dependencies = [ "amcl", "rand 0.8.5", "serde", - "sha2 0.10.7", - "sha3 0.10.8", + "sha2", + "sha3", ] [[package]] name = "indy-credx" -version = "1.0.1" -source = "git+https://github.com/hyperledger/indy-shared-rs?tag=v1.0.1#32a1943811e719540567769264e14f94e51c60ee" +version = "1.1.0" +source = "git+https://github.com/hyperledger/indy-shared-rs?tag=v1.1.0#0260b93f76573613cedb486bc8836c75c47d4cf4" dependencies = [ "env_logger 0.10.0", "ffi-support", - "indy-data-types 0.6.1 (git+https://github.com/hyperledger/indy-shared-rs?tag=v1.0.1)", - "indy-utils 0.6.0 (git+https://github.com/hyperledger/indy-shared-rs?tag=v1.0.1)", + "indy-data-types 0.7.0 (git+https://github.com/hyperledger/indy-shared-rs?tag=v1.1.0)", "log", "once_cell", "rand 0.8.5", "regex", "serde", "serde_json", - "sha2 0.10.7", - "thiserror", + "sha2", "zeroize", ] [[package]] name = "indy-data-types" -version = "0.6.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bc9972c657fd152d394f61b00d677aa8a700abd8c39137164e399a1d9fd0c6d" +checksum = "72a8c97ba7f3a0af57c6895f2b7836fc00aa7ed3a56ce28e2367ded9dea3d9be" dependencies = [ "anoncreds-clsignatures", + "bs58 0.5.0", + "curve25519-dalek", + "ed25519-dalek", "hex", - "indy-utils 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "once_cell", + "rand 0.8.5", "regex", "serde", "serde_json", - "sha2 0.10.7", + "sha2", + "thiserror", + "x25519-dalek", "zeroize", ] [[package]] name = "indy-data-types" -version = "0.6.1" -source = "git+https://github.com/hyperledger/indy-shared-rs?tag=v1.0.1#32a1943811e719540567769264e14f94e51c60ee" +version = "0.7.0" +source = "git+https://github.com/hyperledger/indy-shared-rs?tag=v1.1.0#0260b93f76573613cedb486bc8836c75c47d4cf4" dependencies = [ "anoncreds-clsignatures", + "bs58 0.5.0", + "curve25519-dalek", + "ed25519-dalek", "hex", - "indy-utils 0.6.0 (git+https://github.com/hyperledger/indy-shared-rs?tag=v1.0.1)", "once_cell", + "rand 0.8.5", "regex", "serde", "serde_json", - "sha2 0.10.7", + "sha2", + "thiserror", + "x25519-dalek", "zeroize", ] @@ -2673,7 +2275,7 @@ dependencies = [ name = "indy-utils" version = "0.1.0" dependencies = [ - "base64 0.10.1", + "base64", "dirs", "failure", "indy-api-types", @@ -2681,8 +2283,8 @@ dependencies = [ "libc", "log", "openssl", - "rand 0.7.3", - "rmp-serde 0.13.7", + "rand 0.8.5", + "rmp-serde", "serde", "serde_derive", "serde_json", @@ -2690,44 +2292,12 @@ dependencies = [ "zeroize", ] -[[package]] -name = "indy-utils" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d7e0cdcece8d97982e82aba5b0cb8c7e87ffb5f4fa48b935a3647d24db5439" -dependencies = [ - "bs58 0.5.0", - "curve25519-dalek", - "ed25519-dalek", - "once_cell", - "rand 0.8.5", - "regex", - "serde", - "sha2 0.10.7", - "thiserror", - "x25519-dalek", - "zeroize", -] - -[[package]] -name = "indy-utils" -version = "0.6.0" -source = "git+https://github.com/hyperledger/indy-shared-rs?tag=v1.0.1#32a1943811e719540567769264e14f94e51c60ee" -dependencies = [ - "bs58 0.5.0", - "once_cell", - "regex", - "serde", - "thiserror", - "zeroize", -] - [[package]] name = "indy-vdr" -version = "0.4.0-dev.16" -source = "git+https://github.com/hyperledger/indy-vdr.git?rev=879e29e#879e29e8b174b5ca1f031d8d70fa1fcb32a40cf0" +version = "0.4.0" +source = "git+https://github.com/hyperledger/indy-vdr.git?rev=c143268#c143268c2c86b300f8b8a33b57a4cff06de35626" dependencies = [ - "base64 0.21.2", + "base64", "bs58 0.5.0", "env_logger 0.10.0", "etcommon-rlp", @@ -2737,19 +2307,18 @@ dependencies = [ "futures-util", "hex", "indy-blssignatures", - "indy-data-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "indy-utils 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "indy-data-types 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "log", "once_cell", "percent-encoding", "pin-utils", "rand 0.8.5", "regex", - "rmp-serde 1.1.2", + "rmp-serde", "serde", "serde_json", - "sha2 0.10.7", - "sha3 0.10.8", + "sha2", + "sha3", "thiserror", "time 0.3.20", "url", @@ -2759,7 +2328,7 @@ dependencies = [ [[package]] name = "indy-vdr-proxy-client" version = "0.1.0" -source = "git+https://github.com/hyperledger/indy-vdr.git?rev=879e29e#879e29e8b174b5ca1f031d8d70fa1fcb32a40cf0" +source = "git+https://github.com/hyperledger/indy-vdr.git?rev=c143268#c143268c2c86b300f8b8a33b57a4cff06de35626" dependencies = [ "indy-vdr", "reqwest", @@ -2773,15 +2342,15 @@ version = "0.1.0" dependencies = [ "async-std", "async-trait", - "bs58 0.4.0", + "bs58 0.5.0", "byteorder", "futures", "indy-api-types", - "indy-utils 0.1.0", + "indy-utils", "libc", "log", - "lru 0.7.8", - "rmp-serde 0.13.7", + "lru", + "rmp-serde", "serde", "serde_derive", "serde_json", @@ -2795,7 +2364,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] [[package]] @@ -2810,9 +2379,9 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.2", + "hermit-abi 0.3.3", "libc", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -2823,14 +2392,13 @@ checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" [[package]] name = "is-terminal" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ - "hermit-abi 0.3.2", - "io-lifetimes", - "rustix", - "windows-sys 0.48.0", + "hermit-abi 0.3.3", + "rustix 0.38.17", + "windows-sys", ] [[package]] @@ -2852,10 +2420,13 @@ dependencies = [ ] [[package]] -name = "itoa" -version = "0.4.8" +name = "itertools" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] [[package]] name = "itoa" @@ -2881,18 +2452,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "k256" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "903ae2481bcdfdb7b68e0a9baa4b7c9aff600b9ae2e8e5bb5833b8c91ab851ea" -dependencies = [ - "cfg-if 1.0.0", - "ecdsa", - "elliptic-curve", - "sha2 0.9.9", -] - [[package]] name = "keccak" version = "0.1.4" @@ -2923,14 +2482,14 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" dependencies = [ - "spin", + "spin 0.5.2", ] [[package]] name = "libc" -version = "0.2.139" +version = "0.2.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" [[package]] name = "libloading" @@ -2938,15 +2497,15 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "winapi", ] [[package]] name = "libm" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "libsodium-sys" @@ -2960,9 +2519,9 @@ dependencies = [ [[package]] name = "libsqlite3-sys" -version = "0.22.2" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290b64917f8b0cb885d9de0f9959fe1f775d7fa12f1da2db9001c1c8ab60f89d" +checksum = "afc22eff61b133b115c6e8c74e818c628d6d5e7a502afea6f64dee076dd94326" dependencies = [ "cc", "pkg-config", @@ -2977,17 +2536,17 @@ dependencies = [ "aries-vcx", "aries_vcx_core", "async-trait", - "cfg-if 1.0.0", + "cfg-if", "chrono", "diddoc_legacy", - "env_logger 0.9.3", + "env_logger 0.10.0", "futures", "lazy_static", "libc", "log", "num-traits", "once_cell", - "rand 0.7.3", + "rand 0.8.5", "serde", "serde_derive", "serde_json", @@ -2995,7 +2554,7 @@ dependencies = [ "time 0.3.20", "tokio", "url", - "uuid 0.7.4", + "uuid 1.4.1", "wallet_migrator", ] @@ -3005,33 +2564,23 @@ version = "0.8.6" dependencies = [ "async-std", "async-trait", - "bs58 0.4.0", - "byteorder", + "bs58 0.5.0", "dirs", - "etcommon-rlp", "failure", "futures", "hex", "indy-api-types", - "indy-utils 0.1.0", + "indy-utils", "indy-wallet", "lazy_static", "libc", "log", "log-derive", - "num-derive", - "num-traits", - "rand 0.8.5", "regex", - "rmp-serde 1.1.2", "serde", "serde_derive", "serde_json", - "sha2 0.9.9", - "sha3 0.9.1", - "time 0.3.20", "ursa", - "uuid 0.8.2", "zeroize", ] @@ -3041,15 +2590,20 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" +[[package]] +name = "linux-raw-sys" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3852614a3bd9ca9804678ba6be5e3b8ce76dfc902cae004e3e0c44051b6e88db" + [[package]] name = "local-channel" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f303ec0e94c6c54447f84f3b0ef7af769858a9c4ef56ef2a986d3dcd4c3fc9c" +checksum = "e0a493488de5f18c8ffcba89eebb8532ffc562dc400490eb65b84893fae0b178" dependencies = [ "futures-core", "futures-sink", - "futures-util", "local-waker", ] @@ -3065,7 +2619,7 @@ version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" dependencies = [ - "autocfg 1.1.0", + "autocfg", "scopeguard", ] @@ -3080,12 +2634,11 @@ dependencies = [ [[package]] name = "log-derive" -version = "0.3.2" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c7f436d3b5b51857b145075009f3a0d88dd37d2e93f42bb227045f4562a131e" +checksum = "6a42526bb432bcd1b43571d5f163984effa25409a29f1a3242a54d0577d55bcf" dependencies = [ "darling 0.10.2", - "log", "proc-macro2", "quote", "syn 1.0.109", @@ -3093,36 +2646,28 @@ dependencies = [ [[package]] name = "lru" -version = "0.7.8" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999beba7b6e8345721bd280141ed958096a2e4abdf74f67ff4ce49b4b54e47a" +checksum = "1efa59af2ddfad1854ae27d75009d538d0998b4b2fd47083e743ac1a10e46c60" dependencies = [ - "hashbrown 0.12.3", + "hashbrown 0.14.1", ] [[package]] -name = "lru" -version = "0.10.1" +name = "md-5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "718e8fae447df0c7e1ba7f5189829e63fd536945c8988d61444c19039f16b670" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" dependencies = [ - "hashbrown 0.13.2", + "cfg-if", + "digest", ] [[package]] name = "memchr" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - -[[package]] -name = "memoffset" -version = "0.9.0" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" -dependencies = [ - "autocfg 1.1.0", -] +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "messages" @@ -3154,7 +2699,7 @@ dependencies = [ "proc-macro2", "quote", "shared_vcx", - "syn 2.0.28", + "syn 2.0.38", ] [[package]] @@ -3190,15 +2735,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "miniz_oxide" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" -dependencies = [ - "adler", -] - [[package]] name = "miniz_oxide" version = "0.7.1" @@ -3217,22 +2753,16 @@ dependencies = [ "libc", "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.48.0", + "windows-sys", ] -[[package]] -name = "miracl_core" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4330eca86d39f2b52d0481aa1e90fe21bfa61f11b0bf9b48ab95595013cefe48" - [[package]] name = "mockall" version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c84490118f2ee2d74570d114f3d0493cbf02790df303d2707606c3e14e07c96" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "downcast", "fragile", "lazy_static", @@ -3247,7 +2777,7 @@ version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22ce75669015c4f47b289fd4d4f56e894e4c96003ffdf3ac51313126f94c6cbb" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "proc-macro2", "quote", "syn 1.0.109", @@ -3266,9 +2796,9 @@ dependencies = [ [[package]] name = "napi" -version = "2.13.2" +version = "2.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ede2d12cd6fce44da537a4be1f5510c73be2506c2e32dfaaafd1f36968f3a0e" +checksum = "fd063c93b900149304e3ba96ce5bf210cd4f81ef5eb80ded0d100df3e85a3ac0" dependencies = [ "bitflags 2.4.0", "ctor", @@ -3290,7 +2820,7 @@ version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da1c6a8fa84d549aa8708fcd062372bf8ec6e849de39016ab921067d21bde367" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "convert_case 0.6.0", "napi-derive-backend", "proc-macro2", @@ -3358,22 +2888,11 @@ checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" [[package]] name = "num-bigint" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f6f7833f2cbf2360a6cfd58cd41a53aa7a90bd4c202f5b1c7dd2ed73c57b2c3" -dependencies = [ - "autocfg 1.1.0", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" dependencies = [ - "autocfg 1.1.0", + "autocfg", "num-integer", "num-traits", "rand 0.8.5", @@ -3381,9 +2900,9 @@ dependencies = [ [[package]] name = "num-bigint-dig" -version = "0.7.1" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9bc3e36fd683e004fd59c64a425e0e991616f5a8b617c3b9a933a93c168facc" +checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151" dependencies = [ "byteorder", "lazy_static", @@ -3396,24 +2915,13 @@ dependencies = [ "zeroize", ] -[[package]] -name = "num-derive" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "num-integer" version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" dependencies = [ - "autocfg 1.1.0", + "autocfg", "num-traits", ] @@ -3423,7 +2931,7 @@ version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" dependencies = [ - "autocfg 1.1.0", + "autocfg", "num-integer", "num-traits", ] @@ -3434,7 +2942,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" dependencies = [ - "autocfg 1.1.0", + "autocfg", "libm", ] @@ -3444,15 +2952,15 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.2", + "hermit-abi 0.3.3", "libc", ] [[package]] name = "object" -version = "0.30.4" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385" +checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" dependencies = [ "memchr", ] @@ -3463,26 +2971,14 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - [[package]] name = "openssl" -version = "0.10.56" +version = "0.10.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "729b745ad4a5575dd06a3e1af1414bd330ee561c01b3899eb584baeaa8def17e" +checksum = "bac25ee399abb46215765b1cb35bc0212377e58a061560d8b29b024fd0430e7c" dependencies = [ - "bitflags 1.3.2", - "cfg-if 1.0.0", + "bitflags 2.4.0", + "cfg-if", "foreign-types", "libc", "once_cell", @@ -3498,7 +2994,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.38", ] [[package]] @@ -3509,9 +3005,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.91" +version = "0.9.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "866b5f16f90776b9bb8dc1e1802ac6f0513de3a7a7465867bfbc563dc737faac" +checksum = "db4d56a4c0478783083cfafcc42493dd4a981d41669da64b4572a2a089b51b1d" dependencies = [ "cc", "libc", @@ -3519,6 +3015,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "os_str_bytes" version = "6.5.1" @@ -3527,20 +3029,9 @@ checksum = "4d5d9eb14b174ee9aa2ef96dc2b94637a2d4b6e7cb873c7e171f0c20c6cf3eac" [[package]] name = "parking" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14f2252c834a40ed9bb5422029649578e63aa341ac401f74e719dd1afda8394e" - -[[package]] -name = "parking_lot" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" -dependencies = [ - "instant", - "lock_api", - "parking_lot_core 0.8.6", -] +checksum = "e52c774a4c39359c1d1c52e43f73dd91a75a614652c825408eec30c95a9b2067" [[package]] name = "parking_lot" @@ -3549,21 +3040,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core 0.9.8", -] - -[[package]] -name = "parking_lot_core" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" -dependencies = [ - "cfg-if 1.0.0", - "instant", - "libc", - "redox_syscall 0.2.16", - "smallvec", - "winapi", + "parking_lot_core", ] [[package]] @@ -3572,11 +3049,11 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "libc", "redox_syscall 0.3.5", "smallvec", - "windows-targets 0.48.1", + "windows-targets", ] [[package]] @@ -3587,23 +3064,21 @@ checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "pem" -version = "0.8.3" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd56cbd21fea48d0c440b41cd69c589faacade08c992d9a54e471b79d0fd13eb" +checksum = "6b13fe415cdf3c8e44518e18a7c95a13431d9bdf6d15367d82b23c377fdd441a" dependencies = [ - "base64 0.13.1", - "once_cell", - "regex", + "base64", + "serde", ] [[package]] -name = "pem" -version = "2.0.1" +name = "pem-rfc7468" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b13fe415cdf3c8e44518e18a7c95a13431d9bdf6d15367d82b23c377fdd441a" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" dependencies = [ - "base64 0.21.2", - "serde", + "base64ct", ] [[package]] @@ -3632,9 +3107,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12cc1b0bf1727a77a54b6654e7b5f1af8604923edc8b81885f8ec92f9e3f0a05" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "pin-utils" @@ -3642,11 +3117,33 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "piper" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "668d31b1c4eba19242f2088b2bf3316b82ca31082a8335764db4e083db7485d4" +dependencies = [ + "atomic-waker", + "fastrand 2.0.1", + "futures-io", +] + +[[package]] +name = "pkcs1" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" +dependencies = [ + "der", + "pkcs8", + "spki", +] + [[package]] name = "pkcs8" -version = "0.7.6" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee3ef9b64d26bad0536099c816c6734379e45bbd5f14798def6809e5cc350447" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ "der", "spki", @@ -3664,41 +3161,26 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" +[[package]] +name = "platforms" +version = "3.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4503fa043bf02cee09a9582e9554b4c6403b2ef55e4612e96561d294419429f8" + [[package]] name = "polling" version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" dependencies = [ - "autocfg 1.1.0", + "autocfg", "bitflags 1.3.2", - "cfg-if 1.0.0", + "cfg-if", "concurrent-queue", "libc", "log", "pin-project-lite", - "windows-sys 0.48.0", -] - -[[package]] -name = "poly1305" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b7456bc1ad2d4cf82b3a016be4c2ac48daf11bf990c1603ebd447fe6f30fca8" -dependencies = [ - "cpuid-bool", - "universal-hash", -] - -[[package]] -name = "polyval" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eebcc4aa140b9abd2bc40d9c3f7ccec842679cd79045ac3a7ac698c1a064b7cd" -dependencies = [ - "cpuid-bool", - "opaque-debug 0.3.0", - "universal-hash", + "windows-sys", ] [[package]] @@ -3715,7 +3197,7 @@ checksum = "59230a63c37f3e18569bdb90e4a89cbf5bf8b06fea0b84e65ea10cc4df47addd" dependencies = [ "difflib", "float-cmp", - "itertools", + "itertools 0.10.5", "normalize-line-endings", "predicates-core", "regex", @@ -3763,9 +3245,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "5b1106fec09662ec6dd98ccac0f81cef56984d0b49f75c92d8cbad76e20c005c" dependencies = [ "unicode-ident", ] @@ -3774,7 +3256,7 @@ dependencies = [ name = "public_key" version = "0.1.0" dependencies = [ - "base64 0.21.2", + "base64", "bs58 0.5.0", "multibase", "serde", @@ -3785,32 +3267,13 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.32" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -dependencies = [ - "autocfg 0.1.8", - "libc", - "rand_chacha 0.1.1", - "rand_core 0.4.2", - "rand_hc 0.1.0", - "rand_isaac", - "rand_jitter", - "rand_os", - "rand_pcg", - "rand_xorshift", - "winapi", -] - [[package]] name = "rand" version = "0.7.3" @@ -3819,9 +3282,9 @@ checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ "getrandom 0.1.16", "libc", - "rand_chacha 0.2.1", + "rand_chacha 0.2.2", "rand_core 0.5.1", - "rand_hc 0.2.0", + "rand_hc", ] [[package]] @@ -3837,21 +3300,11 @@ dependencies = [ [[package]] name = "rand_chacha" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -dependencies = [ - "autocfg 0.1.8", - "rand_core 0.3.1", -] - -[[package]] -name = "rand_chacha" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ - "c2-chacha", + "ppv-lite86", "rand_core 0.5.1", ] @@ -3865,21 +3318,6 @@ dependencies = [ "rand_core 0.6.4", ] -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - [[package]] name = "rand_core" version = "0.5.1" @@ -3895,16 +3333,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.9", -] - -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -dependencies = [ - "rand_core 0.3.1", + "getrandom 0.2.10", ] [[package]] @@ -3916,90 +3345,6 @@ dependencies = [ "rand_core 0.5.1", ] -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -dependencies = [ - "libc", - "rand_core 0.4.2", - "winapi", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.4.2", - "rdrand", - "winapi", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -dependencies = [ - "autocfg 0.1.8", - "rand_core 0.4.2", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rayon" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" -dependencies = [ - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" -dependencies = [ - "crossbeam-channel", - "crossbeam-deque", - "crossbeam-utils", - "num_cpus", -] - -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "redox_syscall" version = "0.2.16" @@ -4024,16 +3369,16 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", "redox_syscall 0.2.16", "thiserror", ] [[package]] name = "regex" -version = "1.9.3" +version = "1.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a" +checksum = "ebee201405406dbf528b8b672104ae6d6d63e6d118cb10e4d51abbc7b58044ff" dependencies = [ "aho-corasick", "memchr", @@ -4043,9 +3388,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.6" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69" +checksum = "59b23e92ee4318893fa3fe3e6fb365258efbfe6ac6ab30f090cdcbb7aa37efa9" dependencies = [ "aho-corasick", "memchr", @@ -4054,17 +3399,17 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" [[package]] name = "reqwest" -version = "0.11.18" +version = "0.11.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" +checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" dependencies = [ - "base64 0.21.2", + "base64", "bytes", "encoding_rs", "futures-core", @@ -4085,6 +3430,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", + "system-configuration", "tokio", "tokio-native-tls", "tower-service", @@ -4104,7 +3450,7 @@ dependencies = [ "cc", "libc", "once_cell", - "spin", + "spin 0.5.2", "untrusted", "web-sys", "winapi", @@ -4121,17 +3467,6 @@ dependencies = [ "paste", ] -[[package]] -name = "rmp-serde" -version = "0.13.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "011e1d58446e9fa3af7cdc1fb91295b10621d3ac4cb3a85cc86385ee9ca50cd3" -dependencies = [ - "byteorder", - "rmp", - "serde", -] - [[package]] name = "rmp-serde" version = "1.1.2" @@ -4145,20 +3480,22 @@ dependencies = [ [[package]] name = "rsa" -version = "0.4.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0aeddcca1082112a6eeb43bf25fd7820b066aaf6eaef776e19d0a1febe38fe" +checksum = "6ab43bb47d23c1a631b4b680199a45255dce26fa9ab2fa902581f624ff13e6a8" dependencies = [ "byteorder", - "digest 0.9.0", - "lazy_static", + "const-oid", + "digest", "num-bigint-dig", "num-integer", "num-iter", "num-traits", - "pem 0.8.3", - "rand 0.8.5", - "simple_asn1", + "pkcs1", + "pkcs8", + "rand_core 0.6.4", + "signature", + "spki", "subtle", "zeroize", ] @@ -4180,29 +3517,59 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.3" +version = "0.37.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b24138615de35e32031d041a09032ef3487a616d901ca4db224e7d557efae2" +checksum = "4279d76516df406a8bd37e7dff53fd37d1a093f997a3c34a5c21658c126db06d" dependencies = [ "bitflags 1.3.2", "errno", "io-lifetimes", "libc", - "linux-raw-sys", - "windows-sys 0.45.0", + "linux-raw-sys 0.3.8", + "windows-sys", +] + +[[package]] +name = "rustix" +version = "0.38.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f25469e9ae0f3d0047ca8b93fc56843f38e6774f0914a107ff8b41be8be8e0b7" +dependencies = [ + "bitflags 2.4.0", + "errno", + "libc", + "linux-raw-sys 0.4.8", + "windows-sys", ] [[package]] name = "rustls" -version = "0.19.1" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" +checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" dependencies = [ - "base64 0.13.1", - "log", "ring", + "rustls-webpki", "sct", - "webpki", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" +dependencies = [ + "base64", +] + +[[package]] +name = "rustls-webpki" +version = "0.101.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c7d5dece342910d9ba34d259310cae3e0154b873b35408b787b59bce53d34fe" +dependencies = [ + "ring", + "untrusted", ] [[package]] @@ -4223,7 +3590,7 @@ version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" dependencies = [ - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -4249,39 +3616,19 @@ checksum = "1db149f81d46d2deba7cd3c50772474707729550221e69588478ebf9ada425ae" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.38", ] [[package]] name = "sct" -version = "0.6.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" +checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" dependencies = [ "ring", "untrusted", ] -[[package]] -name = "secp256k1" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6179428c22c73ac0fbb7b5579a56353ce78ba29759b3b8575183336ea74cdfb" -dependencies = [ - "rand 0.6.5", - "secp256k1-sys", - "serde", -] - -[[package]] -name = "secp256k1-sys" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11553d210db090930f4432bea123b31f70bbf693ace14504ea2a35e796c28dd2" -dependencies = [ - "cc", -] - [[package]] name = "security-framework" version = "2.9.2" @@ -4307,9 +3654,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" +checksum = "ad977052201c6de01a8ef2aa3378c4bd23217a056337d1d6da40468d267a4fb0" dependencies = [ "serde", ] @@ -4323,15 +3670,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde_bytes" -version = "0.11.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab33ec92f677585af6d88c65593ae2375adde54efdbf16d597f2cbc7a6d368ff" -dependencies = [ - "serde", -] - [[package]] name = "serde_derive" version = "1.0.188" @@ -4340,16 +3678,16 @@ checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.38", ] [[package]] name = "serde_json" -version = "1.0.104" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c" +checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" dependencies = [ - "itoa 1.0.9", + "itoa", "ryu", "serde", ] @@ -4361,104 +3699,53 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" dependencies = [ "form_urlencoded", - "itoa 1.0.9", + "itoa", "ryu", "serde", ] -[[package]] -name = "sha-1" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if 1.0.0", - "cpufeatures", - "digest 0.9.0", - "opaque-debug 0.3.0", -] - [[package]] name = "sha1" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" -dependencies = [ - "cfg-if 1.0.0", - "cpufeatures", - "digest 0.10.7", -] - -[[package]] -name = "sha2" -version = "0.9.9" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ - "block-buffer 0.9.0", - "cfg-if 1.0.0", + "cfg-if", "cpufeatures", - "digest 0.9.0", - "opaque-debug 0.3.0", + "digest", ] [[package]] name = "sha2" -version = "0.10.7" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "cpufeatures", - "digest 0.10.7", + "digest", ] [[package]] name = "sha256" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f5ed5ebbe2d9fb5c5e67be64aa462053d707941e02ffb5e65b6200c00b6161c" +checksum = "7895c8ae88588ccead14ff438b939b0c569cd619116f14b4d13fdff7b8333386" dependencies = [ "async-trait", "bytes", "hex", - "sha2 0.10.7", + "sha2", "tokio", ] -[[package]] -name = "sha3" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd26bc0e7a2e3a7c959bc494caf58b72ee0c71d67704e9520f736ca7e4853ecf" -dependencies = [ - "block-buffer 0.7.3", - "byte-tools", - "digest 0.8.1", - "keccak", - "opaque-debug 0.2.3", -] - -[[package]] -name = "sha3" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f81199417d4e5de3f04b1e871023acea7389672c4135918f05aa9cbf2f2fa809" -dependencies = [ - "block-buffer 0.9.0", - "digest 0.9.0", - "keccak", - "opaque-debug 0.3.0", -] - [[package]] name = "sha3" version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" dependencies = [ - "digest 0.10.7", + "digest", "keccak", ] @@ -4485,26 +3772,14 @@ dependencies = [ [[package]] name = "signature" -version = "1.3.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2807892cfa58e081aa1f1111391c7a0649d4fa127a4ffbe34bcbfb35a1171a4" +checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" dependencies = [ - "digest 0.9.0", + "digest", "rand_core 0.6.4", ] -[[package]] -name = "simple_asn1" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eb4ea60fb301dc81dfc113df680571045d375ab7345d171c5dc7d7e13107a80" -dependencies = [ - "chrono", - "num-bigint 0.4.3", - "num-traits", - "thiserror", -] - [[package]] name = "simple_message_relay" version = "0.1.0" @@ -4514,24 +3789,24 @@ dependencies = [ [[package]] name = "siphasher" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" [[package]] name = "slab" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ - "autocfg 1.1.0", + "autocfg", ] [[package]] name = "smallvec" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" +checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" [[package]] name = "socket2" @@ -4543,6 +3818,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "socket2" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" +dependencies = [ + "libc", + "windows-sys", +] + [[package]] name = "sodiumoxide" version = "0.0.16" @@ -4560,115 +3845,231 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +dependencies = [ + "lock_api", +] + [[package]] name = "spki" -version = "0.4.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c01a0c15da1b0b0e1494112e7af814a678fec9bd157881b49beac661e9b6f32" +checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" dependencies = [ + "base64ct", "der", ] [[package]] -name = "sqlformat" -version = "0.1.8" +name = "sqlformat" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b7b278788e7be4d0d29c0f39497a0eef3fba6bbc8e70d8bf7fde46edeaa9e85" +dependencies = [ + "itertools 0.11.0", + "nom", + "unicode_categories", +] + +[[package]] +name = "sqlx" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e50c216e3624ec8e7ecd14c6a6a6370aad6ee5d8cfc3ab30b5162eeeef2ed33" +dependencies = [ + "sqlx-core", + "sqlx-macros", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", +] + +[[package]] +name = "sqlx-core" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d6753e460c998bbd4cd8c6f0ed9a64346fcca0723d6e75e52fdc351c5d2169d" +dependencies = [ + "ahash", + "atoi", + "byteorder", + "bytes", + "crc", + "crossbeam-queue", + "dotenvy", + "either", + "event-listener", + "futures-channel", + "futures-core", + "futures-intrusive", + "futures-io", + "futures-util", + "hashlink", + "hex", + "indexmap 2.0.2", + "log", + "memchr", + "once_cell", + "paste", + "percent-encoding", + "rustls", + "rustls-pemfile", + "serde", + "serde_json", + "sha2", + "smallvec", + "sqlformat", + "thiserror", + "tokio", + "tokio-stream", + "tracing", + "url", + "webpki-roots", +] + +[[package]] +name = "sqlx-macros" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4b7922be017ee70900be125523f38bdd644f4f06a1b16e8fa5a8ee8c34bffd4" +checksum = "9a793bb3ba331ec8359c1853bd39eed32cdd7baaf22c35ccf5c92a7e8d1189ec" dependencies = [ - "itertools", - "nom", - "unicode_categories", + "proc-macro2", + "quote", + "sqlx-core", + "sqlx-macros-core", + "syn 1.0.109", ] [[package]] -name = "sqlx" -version = "0.5.8" -source = "git+https://github.com/jovfer/sqlx?branch=feature/json_no_preserve_order_v5#7b9b4b371071e7d29d3b10da5a205460b3fc2de4" +name = "sqlx-macros-core" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a4ee1e104e00dedb6aa5ffdd1343107b0a4702e862a84320ee7cc74782d96fc" dependencies = [ + "dotenvy", + "either", + "heck", + "hex", + "once_cell", + "proc-macro2", + "quote", + "serde", + "serde_json", + "sha2", "sqlx-core", - "sqlx-macros", + "sqlx-mysql", + "sqlx-sqlite", + "syn 1.0.109", + "tempfile", + "tokio", + "url", ] [[package]] -name = "sqlx-core" -version = "0.5.8" -source = "git+https://github.com/jovfer/sqlx?branch=feature/json_no_preserve_order_v5#7b9b4b371071e7d29d3b10da5a205460b3fc2de4" +name = "sqlx-mysql" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "864b869fdf56263f4c95c45483191ea0af340f9f3e3e7b4d57a61c7c87a970db" dependencies = [ - "ahash 0.7.6", "atoi", - "base64 0.13.1", - "bitflags 1.3.2", + "base64", + "bitflags 2.4.0", "byteorder", "bytes", "crc", - "crossbeam-channel", - "crossbeam-queue", - "crossbeam-utils", - "digest 0.9.0", + "digest", + "dotenvy", "either", "futures-channel", "futures-core", - "futures-intrusive", + "futures-io", "futures-util", - "generic-array 0.14.7", - "hashlink", + "generic-array", "hex", - "indexmap", - "itoa 0.4.8", - "libc", - "libsqlite3-sys", + "hkdf", + "hmac", + "itoa", "log", + "md-5", "memchr", - "num-bigint 0.3.3", "once_cell", - "parking_lot 0.11.2", "percent-encoding", "rand 0.8.5", "rsa", - "rustls", "serde", - "serde_json", - "sha-1", - "sha2 0.9.9", + "sha1", + "sha2", "smallvec", - "sqlformat", - "sqlx-rt", + "sqlx-core", "stringprep", "thiserror", - "tokio-stream", - "url", - "webpki", - "webpki-roots", + "tracing", "whoami", ] [[package]] -name = "sqlx-macros" -version = "0.5.8" -source = "git+https://github.com/jovfer/sqlx?branch=feature/json_no_preserve_order_v5#7b9b4b371071e7d29d3b10da5a205460b3fc2de4" +name = "sqlx-postgres" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb7ae0e6a97fb3ba33b23ac2671a5ce6e3cabe003f451abd5a56e7951d975624" dependencies = [ - "dotenv", - "either", - "heck 0.3.3", + "atoi", + "base64", + "bitflags 2.4.0", + "byteorder", + "crc", + "dotenvy", + "etcetera", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "hex", + "hkdf", + "hmac", + "home", + "itoa", + "log", + "md-5", + "memchr", "once_cell", - "proc-macro2", - "quote", + "rand 0.8.5", + "serde", "serde_json", - "sha2 0.9.9", + "sha1", + "sha2", + "smallvec", "sqlx-core", - "sqlx-rt", - "syn 1.0.109", - "url", + "stringprep", + "thiserror", + "tracing", + "whoami", ] [[package]] -name = "sqlx-rt" -version = "0.5.8" -source = "git+https://github.com/jovfer/sqlx?branch=feature/json_no_preserve_order_v5#7b9b4b371071e7d29d3b10da5a205460b3fc2de4" +name = "sqlx-sqlite" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59dc83cf45d89c555a577694534fcd1b55c545a816c816ce51f20bbe56a4f3f" dependencies = [ - "once_cell", - "tokio", - "tokio-rustls", + "atoi", + "flume", + "futures-channel", + "futures-core", + "futures-executor", + "futures-intrusive", + "futures-util", + "libsqlite3-sys", + "log", + "percent-encoding", + "serde", + "sqlx-core", + "tracing", + "url", ] [[package]] @@ -4679,10 +4080,11 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "stringprep" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3737bde7edce97102e0e2b15365bf7a20bfdb5f60f4f9e8d7004258a51a8da" +checksum = "bb41d74e231a107a1b4ee36bd1214b11285b77768d2e3824aedafa988fd36ee6" dependencies = [ + "finl_unicode", "unicode-bidi", "unicode-normalization", ] @@ -4701,55 +4103,47 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "strum" -version = "0.16.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6138f8f88a16d90134763314e3fc76fa3ed6a7db4725d6acf9a3ef95a3188d22" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" [[package]] name = "strum" -version = "0.24.1" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" [[package]] name = "strum_macros" -version = "0.16.0" +version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0054a7df764039a6cd8592b9de84be4bec368ff081d203a7d5371cbfa8e65c81" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" dependencies = [ - "heck 0.3.3", + "heck", "proc-macro2", "quote", + "rustversion", "syn 1.0.109", ] [[package]] name = "strum_macros" -version = "0.24.3" +version = "0.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +checksum = "ad8d03b598d3d0fff69bf533ee3ef19b8eeb342729596df84bcc7e1f96ec4059" dependencies = [ - "heck 0.4.1", + "heck", "proc-macro2", "quote", "rustversion", - "syn 1.0.109", + "syn 2.0.38", ] [[package]] name = "subtle" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" - -[[package]] -name = "subtle-encoding" -version = "0.5.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dcb1ed7b8330c5eed5441052651dd7a12c75e2ed88f2ec024ae1fa3a5e59945" -dependencies = [ - "zeroize", -] +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "syn" @@ -4764,9 +4158,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.28" +version = "2.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" dependencies = [ "proc-macro2", "quote", @@ -4785,24 +4179,45 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "tempfile" -version = "3.5.0" +version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" +checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" dependencies = [ - "cfg-if 1.0.0", - "fastrand", + "cfg-if", + "fastrand 2.0.1", "redox_syscall 0.3.5", - "rustix", - "windows-sys 0.45.0", + "rustix 0.38.17", + "windows-sys", ] [[package]] name = "termcolor" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64" dependencies = [ "winapi-util", ] @@ -4821,22 +4236,22 @@ checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" [[package]] name = "thiserror" -version = "1.0.44" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90" +checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.44" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" +checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.38", ] [[package]] @@ -4856,7 +4271,7 @@ version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" dependencies = [ - "itoa 1.0.9", + "itoa", "serde", "time-core", "time-macros", @@ -4894,21 +4309,21 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.28.2" +version = "1.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94d7b1cfd2aa4011f2de74c2c4c63665e27a71006b0a192dcd2710272e73dfa2" +checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" dependencies = [ - "autocfg 1.1.0", + "backtrace", "bytes", "libc", "mio", "num_cpus", - "parking_lot 0.12.1", + "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2", + "socket2 0.5.4", "tokio-macros", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -4919,7 +4334,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.38", ] [[package]] @@ -4932,17 +4347,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "tokio-rustls" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6" -dependencies = [ - "rustls", - "tokio", - "webpki", -] - [[package]] name = "tokio-stream" version = "0.1.14" @@ -4956,9 +4360,9 @@ dependencies = [ [[package]] name = "tokio-test" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53474327ae5e166530d17f2d956afcb4f8a004de581b3cae10f12006bc8163e3" +checksum = "e89b3cbabd3ae862100094ae433e1def582cf86451b4e9bf83aa7ac1d8a7d719" dependencies = [ "async-stream", "bytes", @@ -4969,9 +4373,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" +checksum = "1d68074620f57a0b21594d9735eb2e98ab38b17f80d3fcb189fca266771ca60d" dependencies = [ "bytes", "futures-core", @@ -5008,12 +4412,24 @@ version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "log", "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] + [[package]] name = "tracing-core" version = "0.1.31" @@ -5032,7 +4448,7 @@ dependencies = [ "darling 0.20.3", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.38", ] [[package]] @@ -5043,35 +4459,35 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "typed-builder" -version = "0.16.0" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6605aaa56cce0947127ffa0675a8a1b181f87773364390174de60a86ab9085f1" +checksum = "34085c17941e36627a879208083e25d357243812c30e7d7387c3b954f30ade16" dependencies = [ "typed-builder-macro", ] [[package]] name = "typed-builder-macro" -version = "0.16.0" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a6a6884f6a890a012adcc20ce498f30ebdc70fb1ea242c333cc5f435b0b3871" +checksum = "f03ca4cb38206e2bef0700092660bb74d696f808514dae47fa1467cbfe26e96e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.38", ] [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicase" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" dependencies = [ "version_check", ] @@ -5084,9 +4500,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" @@ -5159,7 +4575,7 @@ dependencies = [ "fs-err", "glob", "goblin", - "heck 0.4.1", + "heck", "once_cell", "paste", "serde", @@ -5263,21 +4679,11 @@ dependencies = [ "thiserror", ] -[[package]] -name = "universal-hash" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" -dependencies = [ - "generic-array 0.14.7", - "subtle", -] - [[package]] name = "unsigned-varint" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d86a8dc7f45e4c1b0d30e43038c38f274e77af056aa5f74b93c2cf9eb3c1c836" +checksum = "6889a77d49f1f013504cec6bf97a2c730394adedaeb1deb5ea08949a50541105" [[package]] name = "untrusted" @@ -5287,9 +4693,9 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "url" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" +checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" dependencies = [ "form_urlencoded", "idna", @@ -5303,55 +4709,30 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8760a62e18e4d3e3f599e15c09a9f9567fd9d4a90594d45166162be8d232e63b" dependencies = [ - "aead", - "aes 0.6.0", - "aes-gcm", "amcl", - "amcl_wrapper", - "arrayref", - "blake2", - "block-modes", - "block-padding 0.2.1", - "chacha20poly1305", - "curve25519-dalek", - "ed25519-dalek", + "console_error_panic_hook", "failure", "hex", - "hkdf", - "hmac", "int_traits", - "k256", + "js-sys", "lazy_static", "log", "openssl", "rand 0.7.3", - "rand_chacha 0.2.1", - "secp256k1", "serde", - "sha2 0.9.9", - "sha3 0.9.1", - "subtle", + "serde_json", "time 0.1.45", - "x25519-dalek", + "wasm-bindgen", "zeroize", ] -[[package]] -name = "uuid" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" -dependencies = [ - "rand 0.6.5", -] - [[package]] name = "uuid" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", ] [[package]] @@ -5360,7 +4741,7 @@ version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", ] [[package]] @@ -5397,9 +4778,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "waker-fn" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" +checksum = "f3c4517f54858c779bbcbf228f4fca63d121bf85fbecb2dc578cdf4a39395690" [[package]] name = "wallet_migrator" @@ -5447,7 +4828,9 @@ version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", + "serde", + "serde_json", "wasm-bindgen-macro", ] @@ -5462,7 +4845,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.38", "wasm-bindgen-shared", ] @@ -5472,7 +4855,7 @@ version = "0.4.37" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "js-sys", "wasm-bindgen", "web-sys", @@ -5496,7 +4879,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.38", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5517,23 +4900,13 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webpki" -version = "0.21.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "webpki-roots" -version = "0.21.1" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aabe153544e473b775453675851ecc86863d2a81d786d741f6b76778f2a48940" +checksum = "b291546d5d9d1eab74f069c77749f2cb8504a12caa20f0f2de93ddbf6f411888" dependencies = [ - "webpki", + "rustls-webpki", ] [[package]] @@ -5550,10 +4923,6 @@ name = "whoami" version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22fc3756b8a9133049b26c7f61ab35416c130e8c09b660f5b3958b446f52cc50" -dependencies = [ - "wasm-bindgen", - "web-sys", -] [[package]] name = "winapi" @@ -5573,9 +4942,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ "winapi", ] @@ -5592,16 +4961,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-targets 0.48.1", -] - -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", + "windows-targets", ] [[package]] @@ -5610,148 +4970,92 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.1", + "windows-targets", ] [[package]] name = "windows-targets" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows-targets" -version = "0.48.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" -dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_i686_gnu" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" - -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winreg" -version = "0.10.1" +version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ - "winapi", + "cfg-if", + "windows-sys", ] [[package]] name = "x25519-dalek" -version = "1.2.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2392b6b94a576b4e2bf3c5b2757d63f10ada8020a2e4d08ac849ebcf6ea8e077" +checksum = "fb66477291e7e8d2b0ff1bcb900bf29489a9692816d79874bea351e7a8b6de96" dependencies = [ "curve25519-dalek", - "rand_core 0.5.1", + "rand_core 0.6.4", "zeroize", ] [[package]] name = "zeroize" -version = "1.3.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" +checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" dependencies = [ "zeroize_derive", ] @@ -5764,7 +5068,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.38", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 290fca5d3b..be309025d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,6 @@ [workspace] +resolver = "2" + members = [ "aries_vcx", "libvcx_core", diff --git a/agents/rust/aries-vcx-agent/Cargo.toml b/agents/rust/aries-vcx-agent/Cargo.toml index fc5f284cb1..58194a7b0a 100644 --- a/agents/rust/aries-vcx-agent/Cargo.toml +++ b/agents/rust/aries-vcx-agent/Cargo.toml @@ -8,7 +8,7 @@ edition.workspace = true [dependencies] serde = "1.0.145" aries-vcx = { path = "../../../aries_vcx" } -aries_vcx_core = { path = "../../../aries_vcx_core" } +aries_vcx_core = { path = "../../../aries_vcx_core", features = ["credx", "vdrtools_wallet"] } async-trait = "0.1.64" derive_builder = "0.11.2" serde_json = "1.0.85" diff --git a/agents/rust/aries-vcx-agent/src/agent/agent_struct.rs b/agents/rust/aries-vcx-agent/src/agent/agent_struct.rs index 56ec8ed665..48e4f3d1b8 100644 --- a/agents/rust/aries-vcx-agent/src/agent/agent_struct.rs +++ b/agents/rust/aries-vcx-agent/src/agent/agent_struct.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use aries_vcx::core::profile::vdrtools_profile::VdrtoolsProfile; +use aries_vcx::core::profile::modular_libs_profile::ModularLibsProfile; use crate::{ agent::agent_config::AgentConfig, @@ -14,7 +14,7 @@ use crate::{ #[derive(Clone)] pub struct Agent { - pub(super) profile: Arc, + pub(super) profile: Arc, pub(super) config: AgentConfig, pub(super) connections: Arc, pub(super) schemas: Arc, @@ -27,7 +27,7 @@ pub struct Agent { } impl Agent { - pub fn profile(&self) -> &VdrtoolsProfile { + pub fn profile(&self) -> &ModularLibsProfile { &self.profile } diff --git a/agents/rust/aries-vcx-agent/src/agent/init.rs b/agents/rust/aries-vcx-agent/src/agent/init.rs index b7bc4af9c1..9108a1d9a2 100644 --- a/agents/rust/aries-vcx-agent/src/agent/init.rs +++ b/agents/rust/aries-vcx-agent/src/agent/init.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use aries_vcx::{ - core::profile::{ledger::VcxPoolConfig, vdrtools_profile::VdrtoolsProfile, Profile}, + core::profile::{ledger::VcxPoolConfig, modular_libs_profile::ModularLibsProfile, Profile}, global::settings::DEFAULT_LINK_SECRET_ALIAS, }; use aries_vcx_core::{ @@ -72,7 +72,7 @@ impl Agent { response_cache_config: None, }; - let indy_profile = VdrtoolsProfile::init(wallet, pool_config).unwrap(); + let indy_profile = ModularLibsProfile::init(wallet, pool_config).unwrap(); let profile = Arc::new(indy_profile); let anoncreds = profile.anoncreds(); anoncreds diff --git a/agents/rust/aries-vcx-agent/src/services/connection.rs b/agents/rust/aries-vcx-agent/src/services/connection.rs index a50252b2d8..d349d0ec7f 100644 --- a/agents/rust/aries-vcx-agent/src/services/connection.rs +++ b/agents/rust/aries-vcx-agent/src/services/connection.rs @@ -1,7 +1,7 @@ use std::sync::{Arc, Mutex}; use aries_vcx::{ - core::profile::{vdrtools_profile::VdrtoolsProfile, Profile}, + core::profile::{modular_libs_profile::ModularLibsProfile, Profile}, handlers::util::AnyInvitation, messages::msg_fields::protocols::{ connection::{request::Request, response::Response}, @@ -22,13 +22,13 @@ use crate::{ pub type ServiceEndpoint = Url; pub struct ServiceConnections { - profile: Arc, + profile: Arc, service_endpoint: ServiceEndpoint, connections: Arc>, } impl ServiceConnections { - pub fn new(profile: Arc, service_endpoint: ServiceEndpoint) -> Self { + pub fn new(profile: Arc, service_endpoint: ServiceEndpoint) -> Self { Self { profile, service_endpoint, diff --git a/agents/rust/aries-vcx-agent/src/services/credential_definition.rs b/agents/rust/aries-vcx-agent/src/services/credential_definition.rs index bb56ef3a8f..3b013615ec 100644 --- a/agents/rust/aries-vcx-agent/src/services/credential_definition.rs +++ b/agents/rust/aries-vcx-agent/src/services/credential_definition.rs @@ -2,7 +2,7 @@ use std::sync::{Arc, Mutex}; use aries_vcx::{ common::primitives::credential_definition::{CredentialDef, CredentialDefConfig}, - core::profile::{vdrtools_profile::VdrtoolsProfile, Profile}, + core::profile::{modular_libs_profile::ModularLibsProfile, Profile}, }; use crate::{ @@ -11,12 +11,12 @@ use crate::{ }; pub struct ServiceCredentialDefinitions { - profile: Arc, + profile: Arc, cred_defs: ObjectCache, } impl ServiceCredentialDefinitions { - pub fn new(profile: Arc) -> Self { + pub fn new(profile: Arc) -> Self { Self { profile, cred_defs: ObjectCache::new("cred-defs"), diff --git a/agents/rust/aries-vcx-agent/src/services/holder.rs b/agents/rust/aries-vcx-agent/src/services/holder.rs index cf3ce72c27..6c9a9a39f0 100644 --- a/agents/rust/aries-vcx-agent/src/services/holder.rs +++ b/agents/rust/aries-vcx-agent/src/services/holder.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use aries_vcx::{ - core::profile::{vdrtools_profile::VdrtoolsProfile, Profile}, + core::profile::{modular_libs_profile::ModularLibsProfile, Profile}, handlers::issuance::holder::Holder, messages::{ msg_fields::protocols::cred_issuance::v1::{ @@ -36,14 +36,14 @@ impl HolderWrapper { } pub struct ServiceCredentialsHolder { - profile: Arc, + profile: Arc, creds_holder: ObjectCache, service_connections: Arc, } impl ServiceCredentialsHolder { pub fn new( - profile: Arc, + profile: Arc, service_connections: Arc, ) -> Self { Self { diff --git a/agents/rust/aries-vcx-agent/src/services/issuer.rs b/agents/rust/aries-vcx-agent/src/services/issuer.rs index ab2088eeb9..0e828b5fa6 100644 --- a/agents/rust/aries-vcx-agent/src/services/issuer.rs +++ b/agents/rust/aries-vcx-agent/src/services/issuer.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use aries_vcx::{ - core::profile::{vdrtools_profile::VdrtoolsProfile, Profile}, + core::profile::{modular_libs_profile::ModularLibsProfile, Profile}, handlers::{issuance::issuer::Issuer, util::OfferInfo}, messages::{ msg_fields::protocols::cred_issuance::v1::{ @@ -36,14 +36,14 @@ impl IssuerWrapper { } pub struct ServiceCredentialsIssuer { - profile: Arc, + profile: Arc, creds_issuer: ObjectCache, service_connections: Arc, } impl ServiceCredentialsIssuer { pub fn new( - profile: Arc, + profile: Arc, service_connections: Arc, ) -> Self { Self { diff --git a/agents/rust/aries-vcx-agent/src/services/prover.rs b/agents/rust/aries-vcx-agent/src/services/prover.rs index 7fc9cc7e1d..7f9f92765e 100644 --- a/agents/rust/aries-vcx-agent/src/services/prover.rs +++ b/agents/rust/aries-vcx-agent/src/services/prover.rs @@ -1,7 +1,7 @@ use std::{collections::HashMap, sync::Arc}; use aries_vcx::{ - core::profile::{vdrtools_profile::VdrtoolsProfile, Profile}, + core::profile::{modular_libs_profile::ModularLibsProfile, Profile}, handlers::{ proof_presentation::{prover::Prover, types::SelectedCredentials}, util::PresentationProposalData, @@ -39,14 +39,14 @@ impl ProverWrapper { } pub struct ServiceProver { - profile: Arc, + profile: Arc, provers: ObjectCache, service_connections: Arc, } impl ServiceProver { pub fn new( - profile: Arc, + profile: Arc, service_connections: Arc, ) -> Self { Self { diff --git a/agents/rust/aries-vcx-agent/src/services/revocation_registry.rs b/agents/rust/aries-vcx-agent/src/services/revocation_registry.rs index 55f5017267..312f20c491 100644 --- a/agents/rust/aries-vcx-agent/src/services/revocation_registry.rs +++ b/agents/rust/aries-vcx-agent/src/services/revocation_registry.rs @@ -5,7 +5,7 @@ use std::{ use aries_vcx::{ common::primitives::revocation_registry::RevocationRegistry, - core::profile::{vdrtools_profile::VdrtoolsProfile, Profile}, + core::profile::{modular_libs_profile::ModularLibsProfile, Profile}, }; use crate::{ @@ -14,13 +14,13 @@ use crate::{ }; pub struct ServiceRevocationRegistries { - profile: Arc, + profile: Arc, issuer_did: String, rev_regs: ObjectCache, } impl ServiceRevocationRegistries { - pub fn new(profile: Arc, issuer_did: String) -> Self { + pub fn new(profile: Arc, issuer_did: String) -> Self { Self { profile, issuer_did, diff --git a/agents/rust/aries-vcx-agent/src/services/schema.rs b/agents/rust/aries-vcx-agent/src/services/schema.rs index e28c77a2ec..f7d238ff60 100644 --- a/agents/rust/aries-vcx-agent/src/services/schema.rs +++ b/agents/rust/aries-vcx-agent/src/services/schema.rs @@ -2,7 +2,7 @@ use std::sync::{Arc, Mutex}; use aries_vcx::{ common::primitives::credential_schema::Schema, - core::profile::{vdrtools_profile::VdrtoolsProfile, Profile}, + core::profile::{modular_libs_profile::ModularLibsProfile, Profile}, }; use aries_vcx_core::ledger::base_ledger::AnoncredsLedgerRead; @@ -12,13 +12,13 @@ use crate::{ }; pub struct ServiceSchemas { - profile: Arc, + profile: Arc, issuer_did: String, schemas: ObjectCache, } impl ServiceSchemas { - pub fn new(profile: Arc, issuer_did: String) -> Self { + pub fn new(profile: Arc, issuer_did: String) -> Self { Self { profile, issuer_did, diff --git a/agents/rust/aries-vcx-agent/src/services/verifier.rs b/agents/rust/aries-vcx-agent/src/services/verifier.rs index d8a252c1a4..2fc10cf15b 100644 --- a/agents/rust/aries-vcx-agent/src/services/verifier.rs +++ b/agents/rust/aries-vcx-agent/src/services/verifier.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use aries_vcx::{ common::proofs::proof_request::PresentationRequestData, - core::profile::{vdrtools_profile::VdrtoolsProfile, Profile}, + core::profile::{modular_libs_profile::ModularLibsProfile, Profile}, handlers::proof_presentation::verifier::Verifier, messages::{ msg_fields::protocols::present_proof::{ @@ -41,14 +41,14 @@ impl VerifierWrapper { } pub struct ServiceVerifier { - profile: Arc, + profile: Arc, verifiers: ObjectCache, service_connections: Arc, } impl ServiceVerifier { pub fn new( - profile: Arc, + profile: Arc, service_connections: Arc, ) -> Self { Self { diff --git a/aries_vcx/Cargo.toml b/aries_vcx/Cargo.toml index 43b78a29c5..566d5a602e 100644 --- a/aries_vcx/Cargo.toml +++ b/aries_vcx/Cargo.toml @@ -11,52 +11,47 @@ path = "src/lib.rs" doctest = false [features] -default = ["vdrtools"] -vdrtools = ["aries_vcx_core/vdrtools_anoncreds", "aries_vcx_core/vdrtools_wallet"] +default = ["credx", "vdrtools_wallet"] # Feature flag to include the 'modular library' dependencies (vdrtools alternatives; indy-vdr, indy-credx) -modular_libs = ["aries_vcx_core/modular_libs"] -# TODO: Remove using "vdrtools" feature flag for vdr_proxy_ledger once IndyCredxAnonCreds -# is fully implemented -vdr_proxy_ledger = ["aries_vcx_core/vdr_proxy_ledger", "vdrtools"] +credx = ["aries_vcx_core/credx"] +vdr_proxy_ledger = ["aries_vcx_core/vdr_proxy_ledger", "aries_vcx_core/vdrtools_wallet"] +vdrtools_wallet = ["aries_vcx_core/vdrtools_wallet"] # Feature for allowing legacy proof verification legacy_proof = ["aries_vcx_core/legacy_proof"] -# Used for testing the migrator -migration = ["vdrtools", "modular_libs", "legacy_proof"] - [dependencies] agency_client = { path = "../agency_client" } messages = { path = "../messages" } diddoc_legacy = { path = "../diddoc_legacy" } aries_vcx_core = { path = "../aries_vcx_core" } shared_vcx = { path = "../shared_vcx" } -bs58 = "0.4.0" +bs58 = "0.5.0" async-trait = "0.1.53" -env_logger = "0.9.0" +env_logger = "0.10.0" log = "0.4.16" chrono = "0.4.23" -time = "=0.3.20" +time = "0.3.20" lazy_static = "1.3" -rand = "0.7.3" +rand = "0.8.5" serde = "1.0.97" serde_json = "1.0.40" serde_derive = "1.0.97" regex = "1.1.0" -base64 = "0.10" +base64 = "0.21.4" sha2 = "0.10.7" num-bigint = "0.4.3" futures = { version = "0.3", default-features = false } -uuid = { version = "0.8", default-features = false, features = ["v4"] } -strum = "0.16.0" -strum_macros = "0.16.0" -derive_builder = "0.10.2" +uuid = { version = "1.4.1", default-features = false, features = ["v4"] } +strum = "0.25.0" +strum_macros = "0.25.2" +derive_builder = "0.12.0" tokio = { version = "1.20.4" } thiserror = "1.0.37" url = { version = "2.3", features = ["serde"] } [target.'cfg(target_os = "android")'.dependencies] -android_logger = "0.5" +android_logger = "0.13.3" [dev-dependencies] wallet_migrator = { path = "../wallet_migrator" } diff --git a/aries_vcx/src/common/anoncreds.rs b/aries_vcx/src/common/anoncreds.rs index 8dc06ea9d0..98c264a04a 100644 --- a/aries_vcx/src/common/anoncreds.rs +++ b/aries_vcx/src/common/anoncreds.rs @@ -70,7 +70,6 @@ pub mod integration_tests { .await; } - // #[cfg(feature = "modular_libs")] #[tokio::test] #[ignore] async fn test_pool_proof_req_attribute_names() { diff --git a/aries_vcx/src/common/keys.rs b/aries_vcx/src/common/keys.rs index 4c0b74ab41..79f1b4f724 100644 --- a/aries_vcx/src/common/keys.rs +++ b/aries_vcx/src/common/keys.rs @@ -108,7 +108,7 @@ pub async fn get_verkey_from_ledger( // // #[tokio::test] // #[ignore] -// #[cfg(all(not(feature = "vdr_proxy_ledger"), not(feature = "modular_libs"),))] +// #[cfg(all(not(feature = "vdr_proxy_ledger"), not(feature = "credx"),))] // async fn test_pool_rotate_verkey_fails() { // use super::*; // diff --git a/aries_vcx/src/common/mod.rs b/aries_vcx/src/common/mod.rs index a763cd7bc8..53055f2af3 100644 --- a/aries_vcx/src/common/mod.rs +++ b/aries_vcx/src/common/mod.rs @@ -5,6 +5,4 @@ pub mod ledger; pub mod primitives; pub mod proofs; pub mod signing; -#[cfg(feature = "vdrtools")] -// TODO: Used by tests/ so not "hideable" by #[cfg(test)] pub mod test_utils; diff --git a/aries_vcx/src/common/primitives/revocation_registry.rs b/aries_vcx/src/common/primitives/revocation_registry.rs index fa6321babf..3c0cf77b55 100644 --- a/aries_vcx/src/common/primitives/revocation_registry.rs +++ b/aries_vcx/src/common/primitives/revocation_registry.rs @@ -316,6 +316,3 @@ pub async fn generate_rev_reg( Ok((rev_reg_id, rev_reg_def, rev_reg_entry_json)) } - -// consider impl revoke_credential_local in a generic (non-vdrtools) fashion -// consider impl publish_local_revocations in a generic (non-vdrtools) fashion diff --git a/aries_vcx/src/common/signing.rs b/aries_vcx/src/common/signing.rs index bd584db4cc..bd0e803dcf 100644 --- a/aries_vcx/src/common/signing.rs +++ b/aries_vcx/src/common/signing.rs @@ -1,5 +1,5 @@ use aries_vcx_core::wallet::base_wallet::BaseWallet; -use base64; +use base64::{self, engine::general_purpose, Engine}; use messages::msg_fields::protocols::connection::{ response::{ConnectionSignature, ResponseContent}, ConnectionData, @@ -30,8 +30,8 @@ pub async fn sign_connection_response( let con_data = json!(con_data).to_string(); let (signature, sig_data) = get_signature_data(wallet, con_data, key).await?; - let sig_data = base64::encode_config(&sig_data, base64::URL_SAFE); - let signature = base64::encode_config(&signature, base64::URL_SAFE); + let sig_data = general_purpose::URL_SAFE.encode(sig_data); + let signature = general_purpose::URL_SAFE.encode(signature); let connection_sig = ConnectionSignature::new(signature, sig_data, key.to_string()); @@ -43,27 +43,23 @@ pub async fn decode_signed_connection_response( response: ResponseContent, their_vk: &str, ) -> VcxResult { - let signature = base64::decode_config( - &response.connection_sig.signature.as_bytes(), - base64::URL_SAFE, - ) - .map_err(|err| { - AriesVcxError::from_msg( - AriesVcxErrorKind::InvalidJson, - format!("Cannot decode ConnectionResponse: {:?}", err), - ) - })?; - - let sig_data = base64::decode_config( - &response.connection_sig.sig_data.as_bytes(), - base64::URL_SAFE, - ) - .map_err(|err| { - AriesVcxError::from_msg( - AriesVcxErrorKind::InvalidJson, - format!("Cannot decode ConnectionResponse: {:?}", err), - ) - })?; + let signature = general_purpose::URL_SAFE + .decode(response.connection_sig.signature.as_bytes()) + .map_err(|err| { + AriesVcxError::from_msg( + AriesVcxErrorKind::InvalidJson, + format!("Cannot decode ConnectionResponse: {:?}", err), + ) + })?; + + let sig_data = general_purpose::URL_SAFE + .decode(response.connection_sig.sig_data.as_bytes()) + .map_err(|err| { + AriesVcxError::from_msg( + AriesVcxErrorKind::InvalidJson, + format!("Cannot decode ConnectionResponse: {:?}", err), + ) + })?; if !wallet.verify(their_vk, &sig_data, &signature).await? { return Err(AriesVcxError::from_msg( diff --git a/aries_vcx/src/core/profile/mod.rs b/aries_vcx/src/core/profile/mod.rs index 6aa0ef0188..563dcff7f4 100644 --- a/aries_vcx/src/core/profile/mod.rs +++ b/aries_vcx/src/core/profile/mod.rs @@ -1,15 +1,11 @@ pub mod ledger; -#[cfg(feature = "modular_libs")] +#[cfg(all(feature = "credx", feature = "vdrtools_wallet"))] pub mod modular_libs_profile; #[cfg(feature = "vdr_proxy_ledger")] pub mod vdr_proxy_profile; -#[cfg(feature = "vdrtools")] -pub mod vdrtools_profile; use std::sync::Arc; -#[cfg(feature = "migration")] -use aries_vcx_core::WalletHandle; use aries_vcx_core::{ anoncreds::base_anoncreds::BaseAnonCreds, ledger::{ @@ -57,10 +53,5 @@ pub trait Profile: std::fmt::Debug + Send + Sync { fn wallet(&self) -> &Self::Wallet; - #[cfg(feature = "migration")] - fn wallet_handle(&self) -> Option { - None - } - fn update_taa_configuration(&self, taa_options: TxnAuthrAgrmtOptions) -> VcxResult<()>; } diff --git a/aries_vcx/src/core/profile/vdr_proxy_profile.rs b/aries_vcx/src/core/profile/vdr_proxy_profile.rs index d575db1966..3d3e9381b2 100644 --- a/aries_vcx/src/core/profile/vdr_proxy_profile.rs +++ b/aries_vcx/src/core/profile/vdr_proxy_profile.rs @@ -1,7 +1,7 @@ use std::{sync::Arc, time::Duration}; use aries_vcx_core::{ - anoncreds::indy_anoncreds::IndySdkAnonCreds, + anoncreds::credx_anoncreds::IndyCredxAnonCreds, ledger::{ base_ledger::{TaaConfigurator, TxnAuthrAgrmtOptions}, indy_vdr_ledger::{ @@ -23,14 +23,14 @@ use crate::errors::error::VcxResult; #[derive(Debug)] pub struct VdrProxyProfile { wallet: Arc, - anoncreds: IndySdkAnonCreds, + anoncreds: IndyCredxAnonCreds, indy_ledger_read: Arc>, indy_ledger_write: IndyVdrLedgerWrite, } impl VdrProxyProfile { pub async fn init(wallet: Arc, client: VdrProxyClient) -> VcxResult { - let anoncreds = IndySdkAnonCreds::new(wallet.wallet_handle); + let anoncreds = IndyCredxAnonCreds::new(wallet.clone()); let request_signer = Arc::new(BaseWalletRequestSigner::new(wallet.clone())); let request_submitter = Arc::new(VdrProxySubmitter::new(Arc::new(client))); let response_parser = Arc::new(ResponseParser); @@ -69,7 +69,7 @@ impl VdrProxyProfile { impl Profile for VdrProxyProfile { type LedgerRead = IndyVdrLedgerRead; type LedgerWrite = IndyVdrLedgerWrite; - type Anoncreds = IndySdkAnonCreds; + type Anoncreds = IndyCredxAnonCreds; type Wallet = IndySdkWallet; fn ledger_read(&self) -> &Self::LedgerRead { diff --git a/aries_vcx/src/core/profile/vdrtools_profile.rs b/aries_vcx/src/core/profile/vdrtools_profile.rs deleted file mode 100644 index 8b76e6035f..0000000000 --- a/aries_vcx/src/core/profile/vdrtools_profile.rs +++ /dev/null @@ -1,71 +0,0 @@ -use std::sync::Arc; - -use aries_vcx_core::{ - anoncreds::indy_anoncreds::IndySdkAnonCreds, ledger::base_ledger::TxnAuthrAgrmtOptions, - wallet::indy::IndySdkWallet, -}; -use async_trait::async_trait; - -use super::{ - ledger::{build_ledger_components, ArcIndyVdrLedgerRead, ArcIndyVdrLedgerWrite, VcxPoolConfig}, - Profile, -}; -use crate::errors::error::{AriesVcxError, AriesVcxErrorKind, VcxResult}; - -#[derive(Debug)] -pub struct VdrtoolsProfile { - wallet: Arc, - anoncreds: IndySdkAnonCreds, - indy_ledger_read: ArcIndyVdrLedgerRead, - indy_ledger_write: ArcIndyVdrLedgerWrite, -} - -impl VdrtoolsProfile { - pub fn init(wallet: Arc, vcx_pool_config: VcxPoolConfig) -> VcxResult { - let anoncreds = IndySdkAnonCreds::new(wallet.wallet_handle); - let (ledger_read, ledger_write) = build_ledger_components(wallet.clone(), vcx_pool_config)?; - - Ok(VdrtoolsProfile { - wallet, - anoncreds, - indy_ledger_read: ledger_read, - indy_ledger_write: ledger_write, - }) - } -} - -#[async_trait] -impl Profile for VdrtoolsProfile { - type LedgerRead = ArcIndyVdrLedgerRead; - type LedgerWrite = ArcIndyVdrLedgerWrite; - type Anoncreds = IndySdkAnonCreds; - type Wallet = IndySdkWallet; - - fn ledger_read(&self) -> &Self::LedgerRead { - &self.indy_ledger_read - } - - fn ledger_write(&self) -> &Self::LedgerWrite { - &self.indy_ledger_write - } - - fn anoncreds(&self) -> &Self::Anoncreds { - &self.anoncreds - } - - fn wallet(&self) -> &Self::Wallet { - &self.wallet - } - - #[cfg(feature = "migration")] - fn wallet_handle(&self) -> Option { - Some(self.wallet.wallet_handle) - } - - fn update_taa_configuration(&self, _taa_options: TxnAuthrAgrmtOptions) -> VcxResult<()> { - Err(AriesVcxError::from_msg( - AriesVcxErrorKind::ActionNotSupported, - "update_taa_configuration no implemented for VdrtoolsProfile", - )) - } -} diff --git a/aries_vcx/src/handlers/out_of_band/receiver.rs b/aries_vcx/src/handlers/out_of_band/receiver.rs index 956b14faf3..c0bb718537 100644 --- a/aries_vcx/src/handlers/out_of_band/receiver.rs +++ b/aries_vcx/src/handlers/out_of_band/receiver.rs @@ -2,6 +2,7 @@ use std::{clone::Clone, fmt::Display, str::FromStr}; use agency_client::agency_client::AgencyClient; use aries_vcx_core::{ledger::base_ledger::IndyLedgerRead, wallet::base_wallet::BaseWallet}; +use base64::{engine::general_purpose, Engine}; use diddoc_legacy::aries::diddoc::AriesDidDoc; use messages::{ decorators::{attachment::AttachmentType, thread::Thread}, @@ -166,7 +167,7 @@ impl OutOfBandReceiver { )); }; - let Ok(bytes) = base64::decode(encoded_attach) else { + let Ok(bytes) = general_purpose::STANDARD.decode(encoded_attach) else { return Err(AriesVcxError::from_msg( AriesVcxErrorKind::SerializationError, format!("Attachment is not base 64 encoded JSON: {attach:?}"), diff --git a/aries_vcx/src/handlers/util.rs b/aries_vcx/src/handlers/util.rs index 7426d9d7a7..a31af6808a 100644 --- a/aries_vcx/src/handlers/util.rs +++ b/aries_vcx/src/handlers/util.rs @@ -46,7 +46,7 @@ macro_rules! get_attach_as_string { }; let Some(messages::decorators::attachment::AttachmentType::Base64(encoded_attach)) = __attach else { return err_fn($attachments.get(0)); }; - let Ok(bytes) = base64::decode(&encoded_attach) else { return err_fn($attachments.get(0)); }; + let Ok(bytes) = base64::engine::Engine::decode(&base64::engine::general_purpose::STANDARD, &encoded_attach) else { return err_fn($attachments.get(0)); }; let Ok(attach_string) = String::from_utf8(bytes) else { return err_fn($attachments.get(0)); }; attach_string @@ -55,8 +55,9 @@ macro_rules! get_attach_as_string { macro_rules! make_attach_from_str { ($str_attach:expr, $id:expr) => {{ - let attach_type = - messages::decorators::attachment::AttachmentType::Base64(base64::encode($str_attach)); + let attach_type = messages::decorators::attachment::AttachmentType::Base64( + base64::engine::Engine::encode(&base64::engine::general_purpose::STANDARD, $str_attach), + ); let attach_data = messages::decorators::attachment::AttachmentData::builder() .content(attach_type) .build(); diff --git a/aries_vcx/src/utils/devsetup.rs b/aries_vcx/src/utils/devsetup.rs index fcc64814e4..1e01db48a6 100644 --- a/aries_vcx/src/utils/devsetup.rs +++ b/aries_vcx/src/utils/devsetup.rs @@ -18,14 +18,12 @@ use aries_vcx_core::{ }; use chrono::{DateTime, Duration, Utc}; -#[cfg(feature = "modular_libs")] +#[cfg(all(feature = "credx", feature = "vdrtools_wallet"))] use crate::core::profile::modular_libs_profile::ModularLibsProfile; #[cfg(feature = "vdr_proxy_ledger")] use crate::core::profile::vdr_proxy_profile::VdrProxyProfile; -#[cfg(feature = "vdrtools")] -use crate::core::profile::vdrtools_profile::VdrtoolsProfile; use crate::{ - core::profile::{ledger::VcxPoolConfig, Profile}, + core::profile::Profile, global::settings, utils::{constants::POOL1_TXN, file::write_file, test_logger::LibvcxDefaultLogger}, }; @@ -128,27 +126,13 @@ pub async fn dev_setup_wallet_indy(key_seed: &str) -> (String, WalletHandle) { (did, wallet_handle) } -#[cfg(feature = "vdrtools")] -pub fn dev_build_profile_vdrtools( - genesis_file_path: String, - wallet: Arc, -) -> VdrtoolsProfile { - info!("dev_build_profile_vdrtools >>"); - let vcx_pool_config = VcxPoolConfig { - genesis_file_path, - indy_vdr_config: None, - response_cache_config: None, - }; - VdrtoolsProfile::init(wallet, vcx_pool_config).unwrap() -} - -#[cfg(feature = "modular_libs")] +#[cfg(all(feature = "credx", feature = "vdrtools_wallet"))] pub fn dev_build_profile_modular( genesis_file_path: String, wallet: Arc, ) -> ModularLibsProfile { info!("dev_build_profile_modular >>"); - let vcx_pool_config = VcxPoolConfig { + let vcx_pool_config = crate::core::profile::ledger::VcxPoolConfig { genesis_file_path, indy_vdr_config: None, response_cache_config: None, @@ -177,29 +161,27 @@ pub async fn dev_build_featured_profile( genesis_file_path: String, wallet: Arc, ) -> impl Profile { - // In case of migration test setup, we are starting with vdrtools, then we migrate - #[cfg(all(feature = "modular_libs", not(feature = "migration")))] - return { - info!("SetupProfile >> using modular profile"); - dev_build_profile_modular(genesis_file_path, wallet) - }; - #[cfg(all(feature = "vdr_proxy_ledger", not(feature = "migration")))] + #[cfg(feature = "vdr_proxy_ledger")] return { info!("SetupProfile >> using vdr proxy profile"); dev_build_profile_vdr_proxy_ledger(wallet).await }; - #[cfg(any( - all( - feature = "vdrtools", - not(feature = "vdr_proxy_ledger"), - not(feature = "modular_libs") - ), - feature = "migration" + + #[cfg(all( + feature = "credx", + feature = "vdrtools_wallet", + not(feature = "vdr_proxy_ledger") ))] return { - info!("SetupProfile >> using indy profile"); - dev_build_profile_vdrtools(genesis_file_path, wallet) + info!("SetupProfile >> using modular profile"); + dev_build_profile_modular(genesis_file_path, wallet) }; + + #[cfg(not(any( + all(feature = "credx", feature = "vdrtools_wallet"), + feature = "vdr_proxy_ledger" + )))] + super::mockdata::profile::mock_profile::MockProfile } #[macro_export] diff --git a/aries_vcx/src/utils/mod.rs b/aries_vcx/src/utils/mod.rs index 2733ef25d2..f6586aa221 100644 --- a/aries_vcx/src/utils/mod.rs +++ b/aries_vcx/src/utils/mod.rs @@ -8,7 +8,7 @@ use crate::{ }; #[macro_use] -#[cfg(feature = "vdrtools")] +#[cfg(feature = "vdrtools_wallet")] pub mod devsetup; #[cfg(debug_assertions)] @@ -32,7 +32,6 @@ pub mod constants; pub mod file; pub mod mockdata; pub mod openssl; -#[cfg(feature = "vdrtools")] pub mod provision; pub mod qualifier; pub mod random; diff --git a/aries_vcx/src/utils/random.rs b/aries_vcx/src/utils/random.rs index 053665d6ae..5f70a2d076 100644 --- a/aries_vcx/src/utils/random.rs +++ b/aries_vcx/src/utils/random.rs @@ -1,24 +1,33 @@ use rand::{distributions::Alphanumeric, Rng}; pub fn generate_random_schema_name() -> String { - rand::thread_rng() - .sample_iter(&Alphanumeric) - .take(25) - .collect::() + String::from_utf8( + rand::thread_rng() + .sample_iter(&Alphanumeric) + .take(25) + .collect(), + ) + .unwrap() } pub fn generate_random_name() -> String { - rand::thread_rng() - .sample_iter(&Alphanumeric) - .take(25) - .collect::() + String::from_utf8( + rand::thread_rng() + .sample_iter(&Alphanumeric) + .take(25) + .collect(), + ) + .unwrap() } pub fn generate_random_seed() -> String { - rand::thread_rng() - .sample_iter(&Alphanumeric) - .take(32) - .collect::() + String::from_utf8( + rand::thread_rng() + .sample_iter(&Alphanumeric) + .take(32) + .collect(), + ) + .unwrap() } pub fn generate_random_schema_version() -> String { diff --git a/aries_vcx/tests/test_credential_issuance.rs b/aries_vcx/tests/test_credential_issuance.rs index 97843f0cb4..6f8b85da6c 100644 --- a/aries_vcx/tests/test_credential_issuance.rs +++ b/aries_vcx/tests/test_credential_issuance.rs @@ -11,8 +11,6 @@ use aries_vcx::{ utils::devsetup::*, }; -#[cfg(feature = "migration")] -use crate::utils::migration::Migratable; use crate::utils::{ scenarios::{ accept_credential_proposal, accept_offer, create_address_schema_creddef_revreg, @@ -45,11 +43,6 @@ async fn test_agency_pool_double_issuance_issuer_is_verifier() { ) .await; - // NOTE: Credx-anoncreds-implementation-generated presentation is not compatible with - // vdrtools anoncreds implementation as the presentation fails to deserialize - // #[cfg(feature = "migration")] - // let mut consumer = consumer.migrate().await; - let verifier = exchange_proof( &mut institution, &mut consumer, @@ -63,9 +56,6 @@ async fn test_agency_pool_double_issuance_issuer_is_verifier() { PresentationVerificationStatus::Valid ); - #[cfg(feature = "migration")] - let mut institution = institution.migrate().await; - let verifier = exchange_proof( &mut institution, &mut consumer, @@ -104,9 +94,6 @@ async fn test_agency_pool_two_creds_one_rev_reg() { ) .await; - #[cfg(feature = "migration")] - let mut issuer = issuer.migrate().await; - let _credential_handle2 = exchange_credential( &mut consumer, &mut issuer, @@ -117,9 +104,6 @@ async fn test_agency_pool_two_creds_one_rev_reg() { ) .await; - #[cfg(feature = "migration")] - let mut verifier = verifier.migrate().await; - let verifier_handler = exchange_proof( &mut verifier, &mut consumer, @@ -133,9 +117,6 @@ async fn test_agency_pool_two_creds_one_rev_reg() { PresentationVerificationStatus::Valid ); - #[cfg(feature = "migration")] - let mut consumer = consumer.migrate().await; - let verifier_handler = exchange_proof( &mut verifier, &mut consumer, @@ -166,9 +147,6 @@ async fn test_agency_pool_credential_exchange_via_proposal() { ) .await; - #[cfg(feature = "migration")] - let mut institution = institution.migrate().await; - exchange_credential_with_proposal( &mut consumer, &mut institution, @@ -202,9 +180,6 @@ async fn test_agency_pool_credential_exchange_via_proposal_failed() { let mut holder = create_holder_from_proposal(cred_proposal.clone()); let mut issuer = create_issuer_from_proposal(cred_proposal.clone()); - #[cfg(feature = "migration")] - let mut institution = institution.migrate().await; - let cred_offer = accept_credential_proposal( &mut institution, &mut issuer, @@ -239,17 +214,11 @@ async fn test_agency_pool_credential_exchange_via_proposal_with_negotiation() { ) .await; - #[cfg(feature = "migration")] - let mut institution = institution.migrate().await; - let cred_proposal = create_credential_proposal(&schema.schema_id, &cred_def.get_cred_def_id(), "comment"); let mut holder = create_holder_from_proposal(cred_proposal.clone()); let mut issuer = create_issuer_from_proposal(cred_proposal.clone()); - #[cfg(feature = "migration")] - let mut consumer = consumer.migrate().await; - let cred_proposal_1 = create_credential_proposal(&schema.schema_id, &cred_def.get_cred_def_id(), "comment"); let cred_offer_1 = accept_credential_proposal( diff --git a/aries_vcx/tests/test_credential_retrieval.rs b/aries_vcx/tests/test_credential_retrieval.rs index e80ebd9535..5deba6aca2 100644 --- a/aries_vcx/tests/test_credential_retrieval.rs +++ b/aries_vcx/tests/test_credential_retrieval.rs @@ -24,6 +24,7 @@ use aries_vcx::{ run_setup, utils::constants::DEFAULT_SCHEMA_ATTRS, }; +use base64::{engine::general_purpose, Engine}; use messages::{ decorators::attachment::{Attachment, AttachmentData, AttachmentType}, misc::MimeType, @@ -32,9 +33,6 @@ use messages::{ }, }; -#[cfg(feature = "migration")] -use crate::utils::migration::Migratable; - #[tokio::test] #[ignore] // TODO: This should be a unit test @@ -52,7 +50,9 @@ async fn test_agency_pool_retrieve_credentials_empty() { let pres_req_data: PresentationRequestData = serde_json::from_str(&req.to_string()).unwrap(); - let attach_type = AttachmentType::Base64(base64::encode(&json!(pres_req_data).to_string())); + let attach_type = AttachmentType::Base64( + general_purpose::STANDARD.encode(json!(pres_req_data).to_string()), + ); let attach_data = AttachmentData::builder().content(attach_type).build(); let attach = Attachment::builder() .data(attach_data) @@ -72,9 +72,6 @@ async fn test_agency_pool_retrieve_credentials_empty() { .build(); let proof: Prover = Prover::create_from_request("1", proof_req).unwrap(); - #[cfg(feature = "migration")] - let setup = setup.migrate().await; - let retrieved_creds = proof .retrieve_credentials(setup.profile.anoncreds()) .await @@ -90,7 +87,9 @@ async fn test_agency_pool_retrieve_credentials_empty() { let pres_req_data: PresentationRequestData = serde_json::from_str(&req.to_string()).unwrap(); - let attach_type = AttachmentType::Base64(base64::encode(&json!(pres_req_data).to_string())); + let attach_type = AttachmentType::Base64( + general_purpose::STANDARD.encode(json!(pres_req_data).to_string()), + ); let attach_data = AttachmentData::builder().content(attach_type).build(); let attach = Attachment::builder() .data(attach_data) @@ -176,7 +175,9 @@ async fn test_agency_pool_case_for_proof_req_doesnt_matter_for_retrieve_creds() serde_json::from_str(&req.to_string()).unwrap(); let id = "test_id".to_owned(); - let attach_type = AttachmentType::Base64(base64::encode(&json!(pres_req_data).to_string())); + let attach_type = AttachmentType::Base64( + general_purpose::STANDARD.encode(json!(pres_req_data).to_string()), + ); let attach_data = AttachmentData::builder().content(attach_type).build(); let attach = Attachment::builder() .data(attach_data) @@ -212,7 +213,9 @@ async fn test_agency_pool_case_for_proof_req_doesnt_matter_for_retrieve_creds() serde_json::from_str(&req.to_string()).unwrap(); let id = "test_id".to_owned(); - let attach_type = AttachmentType::Base64(base64::encode(&json!(pres_req_data).to_string())); + let attach_type = AttachmentType::Base64( + general_purpose::STANDARD.encode(json!(pres_req_data).to_string()), + ); let attach_data = AttachmentData::builder().content(attach_type).build(); let attach = Attachment::builder() .data(attach_data) @@ -224,9 +227,6 @@ async fn test_agency_pool_case_for_proof_req_doesnt_matter_for_retrieve_creds() .request_presentations_attach(vec![attach]) .build(); - #[cfg(feature = "migration")] - let setup = setup.migrate().await; - let proof_req = RequestPresentation::builder() .id(id) .content(content) @@ -249,7 +249,9 @@ async fn test_agency_pool_case_for_proof_req_doesnt_matter_for_retrieve_creds() serde_json::from_str(&req.to_string()).unwrap(); let id = "test_id".to_owned(); - let attach_type = AttachmentType::Base64(base64::encode(&json!(pres_req_data).to_string())); + let attach_type = AttachmentType::Base64( + general_purpose::STANDARD.encode(json!(pres_req_data).to_string()), + ); let attach_data = AttachmentData::builder().content(attach_type).build(); let attach = Attachment::builder() .data(attach_data) @@ -281,7 +283,7 @@ async fn test_agency_pool_case_for_proof_req_doesnt_matter_for_retrieve_creds() } // todo: credx implementation does not support checking credential value in respect to predicate -#[cfg(not(feature = "modular_libs"))] +#[cfg(not(feature = "credx"))] #[tokio::test] #[ignore] #[allow(unused_mut)] @@ -303,9 +305,6 @@ async fn test_agency_pool_it_should_fail_to_select_credentials_for_predicate() { issue_address_credential(&mut consumer, &mut institution).await; - #[cfg(feature = "migration")] - let mut institution = institution.migrate().await; - let requested_preds_string = serde_json::to_string(&json!([{ "name": "zip", "p_type": ">=", @@ -318,9 +317,6 @@ async fn test_agency_pool_it_should_fail_to_select_credentials_for_predicate() { .await; let mut verifier = create_verifier_from_request_data(presentation_request_data).await; - #[cfg(feature = "migration")] - let mut consumer = consumer.migrate().await; - let presentation_request = verifier.get_presentation_request_msg().unwrap(); let mut prover = create_prover_from_request(presentation_request.clone()).await; let selected_credentials = diff --git a/aries_vcx/tests/test_pool.rs b/aries_vcx/tests/test_pool.rs index e8ddf87bad..e39bce0e4d 100644 --- a/aries_vcx/tests/test_pool.rs +++ b/aries_vcx/tests/test_pool.rs @@ -47,8 +47,6 @@ use aries_vcx_core::{ }; use diddoc_legacy::aries::service::AriesService; -#[cfg(feature = "migration")] -use crate::utils::migration::Migratable; use crate::utils::{ scenarios::attr_names_address_list, test_agent::{create_test_agent, create_test_agent_trustee}, @@ -407,9 +405,6 @@ async fn test_agency_pool_get_credential_def() { ) .await; - #[cfg(feature = "migration")] - let setup = setup.migrate().await; - let ledger = setup.profile.ledger_read(); let r_cred_def_json = ledger.get_cred_def(&cred_def_id, None).await.unwrap(); @@ -445,9 +440,9 @@ async fn test_pool_rev_reg_def_fails_for_cred_def_created_without_revocation() { ) .await; - #[cfg(feature = "modular_libs")] + #[cfg(feature = "credx")] assert_eq!(rc.unwrap_err().kind(), AriesVcxErrorKind::InvalidState); - #[cfg(not(feature = "modular_libs"))] + #[cfg(not(feature = "credx"))] assert_eq!(rc.unwrap_err().kind(), AriesVcxErrorKind::InvalidInput); }) .await; diff --git a/aries_vcx/tests/test_proof_presentation.rs b/aries_vcx/tests/test_proof_presentation.rs index 0e51073ffb..4ba070df07 100644 --- a/aries_vcx/tests/test_proof_presentation.rs +++ b/aries_vcx/tests/test_proof_presentation.rs @@ -27,8 +27,6 @@ use aries_vcx::{ }; use messages::{msg_fields::protocols::present_proof::PresentProof, AriesMessage}; -#[cfg(feature = "migration")] -use crate::utils::migration::Migratable; use crate::utils::{ scenarios::{ accept_proof_proposal, create_address_schema_creddef_revreg, create_proof_proposal, @@ -111,9 +109,6 @@ async fn test_agency_pool_generate_proof_with_predicates() { let mut proof: Prover = Prover::create_from_request("1", proof_req).unwrap(); - #[cfg(feature = "migration")] - let setup = setup.migrate().await; - let all_creds = proof .retrieve_credentials(setup.profile.anoncreds()) .await @@ -185,9 +180,6 @@ async fn test_agency_pool_presentation_via_proposal() { .await; let tails_dir = rev_reg.get_tails_dir(); - #[cfg(feature = "migration")] - let mut institution = institution.migrate().await; - exchange_credential_with_proposal( &mut consumer, &mut institution, @@ -205,9 +197,6 @@ async fn test_agency_pool_presentation_via_proposal() { let presentation_request = accept_proof_proposal(&mut institution, &mut verifier, presentation_proposal).await; - #[cfg(feature = "migration")] - let mut consumer = consumer.migrate().await; - let selected_credentials = prover_select_credentials(&mut prover, &mut consumer, presentation_request, None).await; let presentation = @@ -234,9 +223,6 @@ async fn test_agency_pool_presentation_via_proposal_with_rejection() { .await; let tails_dir = rev_reg.get_tails_dir(); - #[cfg(feature = "migration")] - let mut institution = institution.migrate().await; - exchange_credential_with_proposal( &mut consumer, &mut institution, @@ -271,9 +257,6 @@ async fn test_agency_pool_presentation_via_proposal_with_negotiation() { .await; let tails_dir = rev_reg.get_tails_dir(); - #[cfg(feature = "migration")] - let mut institution = institution.migrate().await; - exchange_credential_with_proposal( &mut consumer, &mut institution, @@ -287,9 +270,6 @@ async fn test_agency_pool_presentation_via_proposal_with_negotiation() { let mut prover = Prover::create("1").unwrap(); let mut verifier = Verifier::create("1").unwrap(); - #[cfg(feature = "migration")] - let mut consumer = consumer.migrate().await; - let presentation_proposal = create_proof_proposal(&mut prover, &cred_def.get_cred_def_id()).await; let presentation_request = diff --git a/aries_vcx/tests/test_revocations.rs b/aries_vcx/tests/test_revocations.rs index f1e390daa3..8fe1aa29d0 100644 --- a/aries_vcx/tests/test_revocations.rs +++ b/aries_vcx/tests/test_revocations.rs @@ -15,8 +15,6 @@ use aries_vcx::{ utils::devsetup::*, }; -#[cfg(feature = "migration")] -use crate::utils::migration::Migratable; use crate::utils::{ scenarios::{ create_address_schema_creddef_revreg, create_proof_request_data, @@ -39,9 +37,6 @@ async fn test_agency_pool_basic_revocation() { let (schema, cred_def, rev_reg, issuer) = issue_address_credential(&mut consumer, &mut institution).await; - #[cfg(feature = "migration")] - let mut institution = institution.migrate().await; - assert!(!issuer .is_revoked(institution.profile.ledger_read()) .await @@ -50,9 +45,6 @@ async fn test_agency_pool_basic_revocation() { let time_before_revocation = time::OffsetDateTime::now_utc().unix_timestamp() as u64; revoke_credential_and_publish_accumulator(&mut institution, &issuer, &rev_reg).await; - #[cfg(feature = "migration")] - let mut consumer = consumer.migrate().await; - tokio::time::sleep(Duration::from_millis(1000)).await; let time_after_revocation = time::OffsetDateTime::now_utc().unix_timestamp() as u64; @@ -118,9 +110,6 @@ async fn test_agency_pool_revoked_credential_might_still_work() { .await .unwrap()); - #[cfg(feature = "migration")] - let mut institution = institution.migrate().await; - tokio::time::sleep(Duration::from_millis(1000)).await; let time_before_revocation = time::OffsetDateTime::now_utc().unix_timestamp() as u64; tokio::time::sleep(Duration::from_millis(1000)).await; @@ -128,9 +117,6 @@ async fn test_agency_pool_revoked_credential_might_still_work() { revoke_credential_and_publish_accumulator(&mut institution, &issuer, &rev_reg).await; tokio::time::sleep(Duration::from_millis(1000)).await; - #[cfg(feature = "migration")] - let mut consumer = consumer.migrate().await; - let from = time_before_revocation - 100; let to = time_before_revocation; let requested_attrs = requested_attrs_address( @@ -185,9 +171,6 @@ async fn test_agency_pool_local_revocation() { let (schema, cred_def, rev_reg, issuer) = issue_address_credential(&mut consumer, &mut institution).await; - #[cfg(feature = "migration")] - let mut institution = institution.migrate().await; - revoke_credential_local(&mut institution, &issuer, &rev_reg.rev_reg_id).await; assert!(!issuer .is_revoked(institution.profile.ledger_read()) @@ -261,9 +244,6 @@ async fn test_agency_batch_revocation() { ) .await; - #[cfg(feature = "migration")] - let mut institution = institution.migrate().await; - let issuer_credential2 = exchange_credential( &mut consumer2, &mut institution, @@ -274,9 +254,6 @@ async fn test_agency_batch_revocation() { ) .await; - #[cfg(feature = "migration")] - let mut consumer1 = consumer1.migrate().await; - let issuer_credential3 = exchange_credential( &mut consumer3, &mut institution, @@ -302,12 +279,6 @@ async fn test_agency_batch_revocation() { .await .unwrap()); - #[cfg(feature = "migration")] - let mut consumer2 = consumer2.migrate().await; - - #[cfg(feature = "migration")] - let mut consumer3 = consumer3.migrate().await; - // Revoke two locally and verify their are all still valid let verifier_handler = exchange_proof( &mut institution, @@ -425,9 +396,6 @@ async fn test_agency_pool_two_creds_one_rev_reg_revoke_first() { ) .await; - #[cfg(feature = "migration")] - let mut issuer = issuer.migrate().await; - let credential_data2 = credential_data_address_2().to_string(); let issuer_credential2 = exchange_credential( &mut consumer, @@ -448,9 +416,6 @@ async fn test_agency_pool_two_creds_one_rev_reg_revoke_first() { .await .unwrap()); - #[cfg(feature = "migration")] - let mut verifier = verifier.migrate().await; - revoke_credential_and_publish_accumulator(&mut issuer, &issuer_credential1, &rev_reg).await; let mut proof_verifier = verifier_create_proof_and_send_request( @@ -496,9 +461,6 @@ async fn test_agency_pool_two_creds_one_rev_reg_revoke_first() { ) .await; - #[cfg(feature = "migration")] - let _consumer = consumer.migrate().await; - proof_verifier .verify_presentation( verifier.profile.ledger_read(), @@ -546,9 +508,6 @@ async fn test_agency_pool_two_creds_one_rev_reg_revoke_second() { ) .await; - #[cfg(feature = "migration")] - let mut issuer = issuer.migrate().await; - let credential_data2 = credential_data_address_2().to_string(); let issuer_credential2 = exchange_credential( &mut consumer, @@ -569,9 +528,6 @@ async fn test_agency_pool_two_creds_one_rev_reg_revoke_second() { .await .unwrap()); - #[cfg(feature = "migration")] - let mut verifier = verifier.migrate().await; - revoke_credential_and_publish_accumulator(&mut issuer, &issuer_credential2, &rev_reg).await; let mut proof_verifier = verifier_create_proof_and_send_request( @@ -615,9 +571,6 @@ async fn test_agency_pool_two_creds_one_rev_reg_revoke_second() { ) .await; - #[cfg(feature = "migration")] - let _consumer = consumer.migrate().await; - proof_verifier .verify_presentation( verifier.profile.ledger_read(), @@ -664,9 +617,6 @@ async fn test_agency_pool_two_creds_two_rev_reg_id() { ) .await; - #[cfg(feature = "migration")] - let mut issuer = issuer.migrate().await; - let rev_reg_2 = rotate_rev_reg(&mut issuer, &cred_def, &rev_reg).await; let credential_data2 = credential_data_address_2().to_string(); let issuer_credential2 = exchange_credential( @@ -706,9 +656,6 @@ async fn test_agency_pool_two_creds_two_rev_reg_id() { PresentationVerificationStatus::Valid ); - #[cfg(feature = "migration")] - let mut verifier = verifier.migrate().await; - let mut proof_verifier = verifier_create_proof_and_send_request( &mut verifier, &schema.schema_id, @@ -717,9 +664,6 @@ async fn test_agency_pool_two_creds_two_rev_reg_id() { ) .await; - #[cfg(feature = "migration")] - let mut consumer = consumer.migrate().await; - let presentation = prover_select_credentials_and_send_proof( &mut consumer, proof_verifier.get_presentation_request_msg().unwrap(), @@ -774,9 +718,6 @@ async fn test_agency_pool_two_creds_two_rev_reg_id_revoke_first() { ) .await; - #[cfg(feature = "migration")] - let mut issuer = issuer.migrate().await; - let rev_reg_2 = rotate_rev_reg(&mut issuer, &cred_def, &rev_reg).await; let credential_data2 = credential_data_address_2().to_string(); let issuer_credential2 = exchange_credential( @@ -800,9 +741,6 @@ async fn test_agency_pool_two_creds_two_rev_reg_id_revoke_first() { revoke_credential_and_publish_accumulator(&mut issuer, &issuer_credential1, &rev_reg).await; - #[cfg(feature = "migration")] - let mut verifier = verifier.migrate().await; - let mut proof_verifier = verifier_create_proof_and_send_request( &mut verifier, &schema.schema_id, @@ -844,9 +782,6 @@ async fn test_agency_pool_two_creds_two_rev_reg_id_revoke_first() { ) .await; - #[cfg(feature = "migration")] - let _consumer = consumer.migrate().await; - proof_verifier .verify_presentation( verifier.profile.ledger_read(), @@ -893,9 +828,6 @@ async fn test_agency_pool_two_creds_two_rev_reg_id_revoke_second() { ) .await; - #[cfg(feature = "migration")] - let mut issuer = issuer.migrate().await; - let rev_reg_2 = rotate_rev_reg(&mut issuer, &cred_def, &rev_reg).await; let credential_data2 = credential_data_address_2().to_string(); let issuer_credential2 = exchange_credential( @@ -934,9 +866,6 @@ async fn test_agency_pool_two_creds_two_rev_reg_id_revoke_second() { ) .await; - #[cfg(feature = "migration")] - let mut verifier = verifier.migrate().await; - proof_verifier .verify_presentation( verifier.profile.ledger_read(), @@ -965,9 +894,6 @@ async fn test_agency_pool_two_creds_two_rev_reg_id_revoke_second() { ) .await; - #[cfg(feature = "migration")] - let _consumer = consumer.migrate().await; - proof_verifier .verify_presentation( verifier.profile.ledger_read(), @@ -1035,12 +961,6 @@ async fn test_agency_pool_three_creds_one_rev_reg_revoke_all() { .await .unwrap()); - #[cfg(feature = "migration")] - let mut issuer = issuer.migrate().await; - - #[cfg(feature = "migration")] - let mut consumer = consumer.migrate().await; - revoke_credential_local(&mut issuer, &issuer_credential2, &rev_reg.rev_reg_id).await; let issuer_credential3 = exchange_credential( diff --git a/aries_vcx/tests/utils/migration.rs b/aries_vcx/tests/utils/migration.rs deleted file mode 100644 index 7c3b0ca7f7..0000000000 --- a/aries_vcx/tests/utils/migration.rs +++ /dev/null @@ -1,93 +0,0 @@ -use std::sync::Arc; - -use aries_vcx::{ - core::profile::{modular_libs_profile::ModularLibsProfile, Profile}, - global::settings::WALLET_KDF_RAW, - utils::devsetup::{dev_build_profile_modular, SetupProfile}, -}; -use aries_vcx_core::{ - wallet::indy::{wallet::create_and_open_wallet, IndySdkWallet, WalletConfig}, - WalletHandle, -}; -use async_trait::async_trait; -use uuid::Uuid; - -use crate::utils::test_agent::TestAgent; - -#[async_trait] -pub trait Migratable { - type Output; - - async fn migrate(mut self) -> Self::Output; -} - -#[async_trait] -impl

Migratable for SetupProfile

-where - P: Profile, -{ - type Output = SetupProfile; - - async fn migrate(mut self) -> Self::Output { - info!("SetupProfile::migrate >>>"); - let old_wh = self.profile.wallet_handle().unwrap(); - let new_wh = migrate_to_new_wallet(old_wh).await; - let wallet = Arc::new(IndySdkWallet::new(new_wh)); - let profile = dev_build_profile_modular(self.genesis_file_path.clone(), wallet); - - SetupProfile { - institution_did: self.institution_did, - profile, - genesis_file_path: self.genesis_file_path, - } - } -} - -#[async_trait] -impl

Migratable for TestAgent

-where - P: Profile, -{ - type Output = TestAgent; - - async fn migrate(mut self) -> Self::Output { - info!("Faber::migrate >>>"); - let old_wh = self.profile.wallet_handle().unwrap(); - let new_wh = migrate_to_new_wallet(old_wh).await; - let wallet = Arc::new(IndySdkWallet::new(new_wh)); - let profile = dev_build_profile_modular(self.genesis_file_path.clone(), wallet); - - TestAgent { - profile, - institution_did: self.institution_did, - genesis_file_path: self.genesis_file_path, - } - } -} - -async fn migrate_to_new_wallet(src_wallet_handle: WalletHandle) -> WalletHandle { - let wallet_config = make_wallet_config(); - let dest_wallet_handle = create_and_open_wallet(&wallet_config).await.unwrap(); - - wallet_migrator::migrate_wallet( - src_wallet_handle, - dest_wallet_handle, - wallet_migrator::vdrtools2credx::migrate_any_record, - ) - .await - .unwrap(); - - dest_wallet_handle -} - -fn make_wallet_config() -> WalletConfig { - let wallet_key = "8dvfYSt5d1taSd6yJdpjq4emkwsPDDLYxkNFysFD2cZY".to_owned(); - let wallet_name = format!("wallet_{}", Uuid::new_v4()); - - WalletConfig { - wallet_name, - wallet_key, - wallet_key_derivation: WALLET_KDF_RAW.to_string(), - ..Default::default() - } -} diff --git a/aries_vcx/tests/utils/mod.rs b/aries_vcx/tests/utils/mod.rs index c1c8ca93b5..eabb184af4 100644 --- a/aries_vcx/tests/utils/mod.rs +++ b/aries_vcx/tests/utils/mod.rs @@ -1,5 +1,3 @@ -#[cfg(feature = "migration")] -pub mod migration; pub mod scenarios; pub mod test_agent; pub mod test_macros; diff --git a/aries_vcx_core/Cargo.toml b/aries_vcx_core/Cargo.toml index 5ddbe5fbea..b121fef3a6 100644 --- a/aries_vcx_core/Cargo.toml +++ b/aries_vcx_core/Cargo.toml @@ -5,36 +5,34 @@ edition = "2021" [features] ########################## DEP FLAGS ################################ -# Feature flag to include the libvdrtools dependency -vdrtools_anoncreds = ["dep:libvdrtools", "dep:indy-api-types"] vdrtools_wallet = ["dep:libvdrtools", "dep:indy-api-types"] # Feature flag to include the 'modular library' dependencies (vdrtools alternatives; indy-vdr, indy-credx) -modular_libs = ["dep:indy-credx"] -vdr_proxy_ledger = ["modular_libs", "dep:indy-vdr-proxy-client"] +credx = ["dep:indy-credx"] +vdr_proxy_ledger = ["credx", "dep:indy-vdr-proxy-client"] # Feature flag to allow legacy proof verification legacy_proof = [] [dependencies] agency_client = { path = "../agency_client" } -indy-vdr = { git = "https://github.com/hyperledger/indy-vdr.git", rev = "879e29e", default-features = false, features = ["log"] } -indy-credx = { git = "https://github.com/hyperledger/indy-shared-rs", tag = "v1.0.1", optional = true } +indy-vdr = { git = "https://github.com/hyperledger/indy-vdr.git", rev = "c143268", default-features = false, features = ["log"] } +indy-credx = { git = "https://github.com/hyperledger/indy-shared-rs", tag = "v1.1.0", optional = true } libvdrtools = { path = "../libvdrtools", optional = true } indy-api-types = { path = "../libvdrtools/indy-api-types", optional = true } async-trait = "0.1.68" futures = { version = "0.3", default-features = false } serde_json = "1.0.95" -time = "=0.3.20" +time = "0.3.20" serde = { version = "1.0.159", features = ["derive"] } -rand = "0.7.3" +rand = "0.8.5" log = "0.4.17" thiserror = "1.0.40" lazy_static = "1.4.0" derive_builder = "0.12.0" uuid = { version = "1.3.0", default-features = false, features = ["v4"] } tokio = { version = "1.20" } -indy-vdr-proxy-client = { git = "https://github.com/hyperledger/indy-vdr.git", rev = "879e29e", optional = true } +indy-vdr-proxy-client = { git = "https://github.com/hyperledger/indy-vdr.git", rev = "c143268", optional = true } indy-ledger-response-parser = { path = "../indy_ledger_response_parser" } -lru = { version = "0.10.0" } +lru = { version = "0.12.0" } [dev-dependencies] tokio = { version = "1.20", features = ["rt", "macros", "rt-multi-thread"] } diff --git a/aries_vcx_core/src/anoncreds/credx_anoncreds.rs b/aries_vcx_core/src/anoncreds/credx_anoncreds.rs index e4c6a3a180..6b2d2f3988 100644 --- a/aries_vcx_core/src/anoncreds/credx_anoncreds.rs +++ b/aries_vcx_core/src/anoncreds/credx_anoncreds.rs @@ -19,17 +19,21 @@ use credx::{ }; use indy_credx as credx; use serde::{de::DeserializeOwned, Deserialize, Serialize}; -use serde_json::Value; +use serde_json::{json, Value}; use uuid::Uuid; use super::base_anoncreds::BaseAnonCreds; use crate::{ errors::error::{AriesVcxCoreError, AriesVcxCoreErrorKind, VcxCoreResult}, utils::{ + async_fn_iterator::AsyncFnIterator, constants::ATTRS, json::{AsTypeOrDeserializationError, TryGetIndex}, }, - wallet::base_wallet::{AsyncFnIteratorCollect, BaseWallet}, + wallet::{ + base_wallet::{AsyncFnIteratorCollect, BaseWallet}, + structs_io::UnpackMessageOutput, + }, }; pub const CATEGORY_LINK_SECRET: &str = "VCX_LINK_SECRET"; @@ -56,14 +60,144 @@ pub struct RevocationRegistryInfo { pub used_ids: HashSet, } +/// Adapter used so that credx does not depend strictly on the vdrtools-wallet +/// Will get removed when the wallet and anoncreds interfaces are de-coupled. +#[derive(Debug)] +struct WalletAdapter(Arc); + +#[async_trait] +impl BaseWallet for WalletAdapter { + #[cfg(feature = "vdrtools_wallet")] + fn get_wallet_handle(&self) -> indy_api_types::WalletHandle { + self.0.get_wallet_handle() + } + + async fn create_and_store_my_did( + &self, + seed: Option<&str>, + kdf_method_name: Option<&str>, + ) -> VcxCoreResult<(String, String)> { + self.0.create_and_store_my_did(seed, kdf_method_name).await + } + + async fn key_for_local_did(&self, did: &str) -> VcxCoreResult { + self.0.key_for_local_did(did).await + } + + async fn replace_did_keys_start(&self, target_did: &str) -> VcxCoreResult { + self.0.replace_did_keys_start(target_did).await + } + + async fn replace_did_keys_apply(&self, target_did: &str) -> VcxCoreResult<()> { + self.0.replace_did_keys_apply(target_did).await + } + + async fn add_wallet_record( + &self, + xtype: &str, + id: &str, + value: &str, + tags: Option>, + ) -> VcxCoreResult<()> { + self.0.add_wallet_record(xtype, id, value, tags).await + } + + async fn get_wallet_record( + &self, + xtype: &str, + id: &str, + options: &str, + ) -> VcxCoreResult { + self.0.get_wallet_record(xtype, id, options).await + } + + async fn get_wallet_record_value(&self, xtype: &str, id: &str) -> VcxCoreResult { + self.0.get_wallet_record_value(xtype, id).await + } + + async fn delete_wallet_record(&self, xtype: &str, id: &str) -> VcxCoreResult<()> { + self.0.delete_wallet_record(xtype, id).await + } + + async fn update_wallet_record_value( + &self, + xtype: &str, + id: &str, + value: &str, + ) -> VcxCoreResult<()> { + self.0.update_wallet_record_value(xtype, id, value).await + } + + async fn add_wallet_record_tags( + &self, + xtype: &str, + id: &str, + tags: HashMap, + ) -> VcxCoreResult<()> { + self.0.add_wallet_record_tags(xtype, id, tags).await + } + + async fn update_wallet_record_tags( + &self, + xtype: &str, + id: &str, + tags: HashMap, + ) -> VcxCoreResult<()> { + self.0.update_wallet_record_tags(xtype, id, tags).await + } + + async fn delete_wallet_record_tags( + &self, + xtype: &str, + id: &str, + tag_names: &str, + ) -> VcxCoreResult<()> { + self.0.delete_wallet_record_tags(xtype, id, tag_names).await + } + + async fn iterate_wallet_records( + &self, + xtype: &str, + query: &str, + options: &str, + ) -> VcxCoreResult>>> { + self.0.iterate_wallet_records(xtype, query, options).await + } + + // ---- crypto + + async fn sign(&self, my_vk: &str, msg: &[u8]) -> VcxCoreResult> { + self.0.sign(my_vk, msg).await + } + + async fn verify(&self, vk: &str, msg: &[u8], signature: &[u8]) -> VcxCoreResult { + self.0.verify(vk, msg, signature).await + } + + async fn pack_message( + &self, + sender_vk: Option<&str>, + receiver_keys: &str, + msg: &[u8], + ) -> VcxCoreResult> { + self.0.pack_message(sender_vk, receiver_keys, msg).await + } + + async fn unpack_message(&self, msg: &[u8]) -> VcxCoreResult { + self.0.unpack_message(msg).await + } +} + #[derive(Debug)] pub struct IndyCredxAnonCreds { - wallet: Arc, + wallet: WalletAdapter, } impl IndyCredxAnonCreds { pub fn new(wallet: Arc) -> Self { - IndyCredxAnonCreds { wallet } + IndyCredxAnonCreds { + wallet: WalletAdapter(wallet), + } } async fn get_wallet_record_value(&self, category: &str, id: &str) -> VcxCoreResult diff --git a/aries_vcx_core/src/anoncreds/indy/credentials/holder/mod.rs b/aries_vcx_core/src/anoncreds/indy/credentials/holder/mod.rs deleted file mode 100644 index eb60c159b9..0000000000 --- a/aries_vcx_core/src/anoncreds/indy/credentials/holder/mod.rs +++ /dev/null @@ -1,113 +0,0 @@ -use vdrtools::{ - Credential, CredentialDefinition, CredentialOffer, CredentialRequestMetadata, DidValue, - Locator, RevocationRegistryDefinition, -}; - -use crate::{errors::error::VcxCoreResult, WalletHandle}; - -pub async fn libindy_prover_store_credential( - wallet_handle: WalletHandle, - cred_id: Option<&str>, - cred_req_meta: &str, - cred_json: &str, - cred_def_json: &str, - rev_reg_def_json: Option<&str>, -) -> VcxCoreResult { - trace!( - "libindy_prover_store_credential >>> cred_id: {:?}, cred_req_meta: {}, cred_json: {}, \ - cred_def_json: {}, rev_reg_def_json: {:?}", - cred_id, - cred_req_meta, - cred_json, - cred_def_json, - rev_reg_def_json, - ); - - let cred_req_meta = serde_json::from_str::(cred_req_meta)?; - - let cred_json = serde_json::from_str::(cred_json)?; - - let cred_def_json = serde_json::from_str::(cred_def_json)?; - - let rev_reg_def_json = match rev_reg_def_json { - None => None, - Some(s) => Some(serde_json::from_str::(s)?), - }; - - let res = Locator::instance() - .prover_controller - .store_credential( - wallet_handle, - cred_id.map(ToOwned::to_owned), - cred_req_meta, - cred_json, - cred_def_json, - rev_reg_def_json, - ) - .await?; - - Ok(res) -} - -pub async fn libindy_prover_get_credential( - wallet_handle: WalletHandle, - cred_id: &str, -) -> VcxCoreResult { - trace!("libindy_prover_get_credential >>> cred_id: {:?}", cred_id,); - - let res = Locator::instance() - .prover_controller - .get_credential(wallet_handle, cred_id.into()) - .await?; - - Ok(res) -} - -pub async fn libindy_prover_delete_credential( - wallet_handle: WalletHandle, - cred_id: &str, -) -> VcxCoreResult<()> { - Locator::instance() - .prover_controller - .delete_credential(wallet_handle, cred_id.into()) - .await?; - - Ok(()) -} - -pub async fn libindy_prover_create_master_secret( - wallet_handle: WalletHandle, - master_secret_id: &str, -) -> VcxCoreResult { - let res = Locator::instance() - .prover_controller - .create_master_secret(wallet_handle, Some(master_secret_id.into())) - .await?; - - Ok(res) -} - -pub async fn libindy_prover_create_credential_req( - wallet_handle: WalletHandle, - prover_did: &str, - credential_offer_json: &str, - credential_def_json: &str, - master_secret_name: &str, -) -> VcxCoreResult<(String, String)> { - let cred_offer = serde_json::from_str::(credential_offer_json)?; - - let cred_def = serde_json::from_str::(credential_def_json)?; - - let res = Locator::instance() - .prover_controller - .create_credential_request( - wallet_handle, - DidValue(prover_did.into()), - cred_offer, - cred_def, - master_secret_name.into(), - ) - .await?; - - Ok(res) -} diff --git a/aries_vcx_core/src/anoncreds/indy/credentials/issuer/mod.rs b/aries_vcx_core/src/anoncreds/indy/credentials/issuer/mod.rs deleted file mode 100644 index 874b7cf3a1..0000000000 --- a/aries_vcx_core/src/anoncreds/indy/credentials/issuer/mod.rs +++ /dev/null @@ -1,166 +0,0 @@ -use vdrtools::{ - CredentialOffer, CredentialRequest, CredentialValues, DidValue, Locator, RevocationRegistryId, -}; - -use crate::{ - anoncreds::indy::{general, general::blob_storage_open_reader}, - errors::error::VcxCoreResult, - indy::utils::parse_and_validate, - wallet::indy::wallet_non_secrets::{get_rev_reg_delta, set_rev_reg_delta}, - WalletHandle, -}; - -pub async fn libindy_issuer_create_credential_offer( - wallet_handle: WalletHandle, - cred_def_id: &str, -) -> VcxCoreResult { - let res = Locator::instance() - .issuer_controller - .create_credential_offer( - wallet_handle, - vdrtools::CredentialDefinitionId(cred_def_id.into()), - ) - .await?; - - Ok(res) -} - -pub async fn libindy_issuer_create_credential( - wallet_handle: WalletHandle, - cred_offer_json: &str, - cred_req_json: &str, - cred_values_json: &str, - rev_reg_id: Option, - tails_file: Option, -) -> VcxCoreResult<(String, Option, Option)> { - let blob_handle = match tails_file { - Some(x) => Some(blob_storage_open_reader(&x).await?), - None => None, - }; - - let res = Locator::instance() - .issuer_controller - .new_credential( - wallet_handle, - parse_and_validate::(cred_offer_json)?, - parse_and_validate::(cred_req_json)?, - parse_and_validate::(cred_values_json)?, - rev_reg_id.map(RevocationRegistryId), - blob_handle, - ) - .await?; - - Ok(res) -} - -pub const BLOB_STORAGE_TYPE: &str = "default"; - -pub async fn libindy_create_and_store_revoc_reg( - wallet_handle: WalletHandle, - issuer_did: &str, - cred_def_id: &str, - tails_dir: &str, - max_creds: u32, - tag: &str, -) -> VcxCoreResult<(String, String, String)> { - trace!( - "creating revocation: {}, {}, {}", - cred_def_id, - tails_dir, - max_creds - ); - - let tails_config = json!({"base_dir": tails_dir,"uri_pattern": ""}).to_string(); - - let writer = Locator::instance() - .blob_storage_controller - .open_writer(BLOB_STORAGE_TYPE.into(), tails_config) - .await?; - - let res = Locator::instance() - .issuer_controller - .create_and_store_revocation_registry( - wallet_handle, - DidValue(issuer_did.into()), - None, - tag.into(), - vdrtools::CredentialDefinitionId(cred_def_id.into()), - vdrtools::RevocationRegistryConfig { - issuance_type: Some(vdrtools::IssuanceType::ISSUANCE_BY_DEFAULT), - max_cred_num: Some(max_creds), - }, - writer, - ) - .await?; - - Ok(res) -} - -pub async fn libindy_issuer_revoke_credential( - wallet_handle: WalletHandle, - tails_file: &str, - rev_reg_id: &str, - cred_rev_id: &str, -) -> VcxCoreResult { - let blob_handle = general::blob_storage_open_reader(tails_file).await?; - - let res = Locator::instance() - .issuer_controller - .revoke_credential( - wallet_handle, - blob_handle, - vdrtools::RevocationRegistryId(rev_reg_id.into()), - cred_rev_id.into(), - ) - .await?; - - Ok(res) -} - -pub async fn libindy_issuer_merge_revocation_registry_deltas( - old_delta: &str, - new_delta: &str, -) -> VcxCoreResult { - let res = Locator::instance() - .issuer_controller - .merge_revocation_registry_deltas( - parse_and_validate(old_delta)?, - parse_and_validate(new_delta)?, - )?; - - Ok(res) -} - -pub async fn revoke_credential_local( - wallet_handle: WalletHandle, - tails_file: &str, - rev_reg_id: &str, - cred_rev_id: &str, -) -> VcxCoreResult<()> { - let mut new_delta_json = - libindy_issuer_revoke_credential(wallet_handle, tails_file, rev_reg_id, cred_rev_id) - .await?; - - debug!( - "revoke_credential_local >>> new_delta_json: {}", - new_delta_json - ); - - if let Some(old_delta_json) = get_rev_reg_delta(wallet_handle, rev_reg_id).await { - debug!( - "revoke_credential_local >>> old_delta_json: {}", - old_delta_json - ); - new_delta_json = libindy_issuer_merge_revocation_registry_deltas( - old_delta_json.as_str(), - new_delta_json.as_str(), - ) - .await?; - debug!( - "revoke_credential_local >>> merged_delta_json: {}", - new_delta_json - ); - } - - set_rev_reg_delta(wallet_handle, rev_reg_id, &new_delta_json).await -} diff --git a/aries_vcx_core/src/anoncreds/indy/credentials/mod.rs b/aries_vcx_core/src/anoncreds/indy/credentials/mod.rs deleted file mode 100644 index edadb99165..0000000000 --- a/aries_vcx_core/src/anoncreds/indy/credentials/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod holder; -pub mod issuer; diff --git a/aries_vcx_core/src/anoncreds/indy/general.rs b/aries_vcx_core/src/anoncreds/indy/general.rs deleted file mode 100644 index fdd3edaeb3..0000000000 --- a/aries_vcx_core/src/anoncreds/indy/general.rs +++ /dev/null @@ -1,34 +0,0 @@ -use vdrtools::Locator; - -use crate::{errors::error::VcxCoreResult, SearchHandle}; - -pub(crate) async fn blob_storage_open_reader(base_dir: &str) -> VcxCoreResult { - let tails_config = json!( - { - "base_dir": base_dir, - "uri_pattern": "" // TODO remove, unused - } - ) - .to_string(); - - let res = Locator::instance() - .blob_storage_controller - .open_reader("default".into(), tails_config) - .await?; - - Ok(res) -} - -pub(crate) async fn close_search_handle(search_handle: SearchHandle) -> VcxCoreResult<()> { - Locator::instance() - .prover_controller - .close_credentials_search_for_proof_req(search_handle) - .await?; - - Ok(()) -} - -pub async fn generate_nonce() -> VcxCoreResult { - let res = Locator::instance().verifier_controller.generate_nonce()?; - Ok(res) -} diff --git a/aries_vcx_core/src/anoncreds/indy/mod.rs b/aries_vcx_core/src/anoncreds/indy/mod.rs deleted file mode 100644 index 699364c196..0000000000 --- a/aries_vcx_core/src/anoncreds/indy/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub(crate) mod credentials; -pub(crate) mod general; -pub mod primitives; -pub(crate) mod proofs; diff --git a/aries_vcx_core/src/anoncreds/indy/primitives/credential_schema.rs b/aries_vcx_core/src/anoncreds/indy/primitives/credential_schema.rs deleted file mode 100644 index 635d85ec89..0000000000 --- a/aries_vcx_core/src/anoncreds/indy/primitives/credential_schema.rs +++ /dev/null @@ -1,34 +0,0 @@ -use log::trace; -use vdrtools::{ - domain::{anoncreds::schema::AttributeNames, crypto::did::DidValue}, - Locator, -}; - -use crate::errors::error::VcxCoreResult; - -// consider relocating out of primitive -pub async fn libindy_issuer_create_schema( - issuer_did: &str, - name: &str, - version: &str, - attrs: &str, -) -> VcxCoreResult<(String, String)> { - trace!( - "libindy_issuer_create_schema >>> issuer_did: {}, name: {}, version: {}, attrs: {}", - issuer_did, - name, - version, - attrs - ); - - let attrs = serde_json::from_str::(attrs)?; - - let res = Locator::instance().issuer_controller.create_schema( - DidValue(issuer_did.into()), - name.into(), - version.into(), - attrs, - )?; - - Ok(res) -} diff --git a/aries_vcx_core/src/anoncreds/indy/primitives/mod.rs b/aries_vcx_core/src/anoncreds/indy/primitives/mod.rs deleted file mode 100644 index 910adda11f..0000000000 --- a/aries_vcx_core/src/anoncreds/indy/primitives/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod credential_schema; diff --git a/aries_vcx_core/src/anoncreds/indy/proofs/mod.rs b/aries_vcx_core/src/anoncreds/indy/proofs/mod.rs deleted file mode 100644 index 96e9e18468..0000000000 --- a/aries_vcx_core/src/anoncreds/indy/proofs/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod prover; -pub mod verifier; diff --git a/aries_vcx_core/src/anoncreds/indy/proofs/prover.rs b/aries_vcx_core/src/anoncreds/indy/proofs/prover.rs deleted file mode 100644 index 237333e155..0000000000 --- a/aries_vcx_core/src/anoncreds/indy/proofs/prover.rs +++ /dev/null @@ -1,194 +0,0 @@ -use serde_json::{Map, Value}; -use vdrtools::{Locator, SearchHandle}; - -use crate::{ - anoncreds::indy::general::{blob_storage_open_reader, close_search_handle}, - errors::error::{prelude::*, VcxCoreResult}, - global::mockdata::mock_settings::get_mock_creds_retrieved_for_proof_request, - indy::utils::parse_and_validate, - utils::constants::{ATTRS, PROOF_REQUESTED_PREDICATES, REQUESTED_ATTRIBUTES}, - WalletHandle, -}; - -pub async fn libindy_prover_create_revocation_state( - tails_file_path: &str, - rev_reg_def_json: &str, - rev_reg_delta_json: &str, - timestamp: u64, - cred_rev_id: &str, -) -> VcxCoreResult { - let blob_handle = blob_storage_open_reader(tails_file_path).await?; - - let res = Locator::instance() - .prover_controller - .create_revocation_state( - blob_handle, - parse_and_validate(rev_reg_def_json)?, - parse_and_validate(rev_reg_delta_json)?, - timestamp, - cred_rev_id.into(), - ) - .await?; - - Ok(res) -} - -pub async fn libindy_prover_create_proof( - wallet_handle: WalletHandle, - proof_req_json: &str, - requested_credentials_json: &str, - master_secret_id: &str, - schemas_json: &str, - credential_defs_json: &str, - revoc_states_json: Option<&str>, -) -> VcxCoreResult { - let revoc_states_json = revoc_states_json.unwrap_or("{}"); - - let res = Locator::instance() - .prover_controller - .create_proof( - wallet_handle, - parse_and_validate(proof_req_json)?, - parse_and_validate(requested_credentials_json)?, - master_secret_id.into(), - serde_json::from_str(schemas_json)?, - serde_json::from_str(credential_defs_json)?, - serde_json::from_str(revoc_states_json)?, - ) - .await?; - - Ok(res) -} - -async fn fetch_credentials( - search_handle: SearchHandle, - requested_attributes: Map, -) -> VcxCoreResult { - let mut v: Value = json!({}); - - for item_referent in requested_attributes.keys() { - v[ATTRS][item_referent] = serde_json::from_str( - &Locator::instance() - .prover_controller - .fetch_credential_for_proof_request(search_handle, item_referent.clone(), 100) - .await - .map_err(|_| { - error!( - "Invalid Json Parsing of Object Returned from Libindy. Did Libindy change \ - its structure?" - ); - AriesVcxCoreError::from_msg( - AriesVcxCoreErrorKind::InvalidConfiguration, - "Invalid Json Parsing of Object Returned from Libindy. Did Libindy change \ - its structure?", - ) - })?, - )? - } - - Ok(v.to_string()) -} - -pub async fn libindy_prover_get_credentials( - wallet_handle: WalletHandle, - filter_json: Option<&str>, -) -> VcxCoreResult { - let res = Locator::instance() - .prover_controller - .get_credentials(wallet_handle, filter_json.map(String::from)) - .await - .map_err(|ec| { - error!("Getting prover credentials failed."); - ec - })?; - Ok(res) -} - -pub async fn libindy_prover_get_credentials_for_proof_req( - wallet_handle: WalletHandle, - proof_req: &str, -) -> VcxCoreResult { - trace!( - "libindy_prover_get_credentials_for_proof_req >>> proof_req: {}", - proof_req - ); - - { - match get_mock_creds_retrieved_for_proof_request() { - None => {} - Some(mocked_creds) => { - warn!("get_mock_creds_retrieved_for_proof_request returning mocked response"); - return Ok(mocked_creds); - } - } - } - - // 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| { - AriesVcxCoreError::from_msg( - AriesVcxCoreErrorKind::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. - let requested_attributes: Option> = - proof_request_json.get(REQUESTED_ATTRIBUTES).and_then(|v| { - serde_json::from_value(v.clone()) - .map_err(|_| { - error!( - "Invalid Json Parsing of Requested Attributes Retrieved From Libindy. Did \ - Libindy change its structure?" - ); - }) - .ok() - }); - - let requested_predicates: Option> = proof_request_json - .get(PROOF_REQUESTED_PREDICATES) - .and_then(|v| { - serde_json::from_value(v.clone()) - .map_err(|_| { - error!( - "Invalid Json Parsing of Requested Predicates Retrieved From Libindy. Did \ - Libindy change its structure?" - ); - }) - .ok() - }); - - // handle special case of "empty because json is bad" vs "empty because no attributes sepected" - if requested_attributes.is_none() && requested_predicates.is_none() { - return Err(AriesVcxCoreError::from_msg( - AriesVcxCoreErrorKind::InvalidAttributesStructure, - "Invalid Json Parsing of Requested Attributes Retrieved From Libindy", - )); - } - - let mut fetch_attrs: Map = match requested_attributes { - Some(attrs) => attrs.clone(), - None => Map::new(), - }; - if let Some(attrs) = requested_predicates { - fetch_attrs.extend(attrs) - } - if !fetch_attrs.is_empty() { - let search_handle = Locator::instance() - .prover_controller - .search_credentials_for_proof_req(wallet_handle, serde_json::from_str(proof_req)?, None) - .await?; - - let creds: String = fetch_credentials(search_handle, fetch_attrs).await?; - - // should an error on closing a search handle throw an error, or just a warning? - // for now we're are just outputting to the user that there is an issue, and continuing on. - let _ = close_search_handle(search_handle).await; - - Ok(creds) - } else { - Ok("{}".to_string()) - } -} diff --git a/aries_vcx_core/src/anoncreds/indy/proofs/verifier.rs b/aries_vcx_core/src/anoncreds/indy/proofs/verifier.rs deleted file mode 100644 index 5c700e7b82..0000000000 --- a/aries_vcx_core/src/anoncreds/indy/proofs/verifier.rs +++ /dev/null @@ -1,23 +0,0 @@ -use vdrtools::Locator; - -use crate::{errors::error::VcxCoreResult, indy::utils::parse_and_validate}; - -pub async fn libindy_verifier_verify_proof( - proof_req_json: &str, - proof_json: &str, - schemas_json: &str, - credential_defs_json: &str, - rev_reg_defs_json: &str, - rev_regs_json: &str, -) -> VcxCoreResult { - let res = Locator::instance().verifier_controller.verify_proof( - parse_and_validate(proof_req_json)?, - parse_and_validate(proof_json)?, - serde_json::from_str(schemas_json)?, - serde_json::from_str(credential_defs_json)?, - serde_json::from_str(rev_reg_defs_json)?, - serde_json::from_str(rev_regs_json)?, - )?; - - Ok(res) -} diff --git a/aries_vcx_core/src/anoncreds/indy_anoncreds.rs b/aries_vcx_core/src/anoncreds/indy_anoncreds.rs deleted file mode 100644 index 2aebefb665..0000000000 --- a/aries_vcx_core/src/anoncreds/indy_anoncreds.rs +++ /dev/null @@ -1,268 +0,0 @@ -use async_trait::async_trait; -use vdrtools::{DidValue, Locator}; - -use super::base_anoncreds::BaseAnonCreds; -use crate::{ - anoncreds, - anoncreds::indy::primitives::credential_schema::libindy_issuer_create_schema, - errors::error::VcxCoreResult, - indy::utils::parse_and_validate, - wallet::indy::wallet_non_secrets::{clear_rev_reg_delta, get_rev_reg_delta}, - WalletHandle, -}; - -#[derive(Debug)] -pub struct IndySdkAnonCreds { - indy_wallet_handle: WalletHandle, -} - -impl IndySdkAnonCreds { - pub fn new(indy_wallet_handle: WalletHandle) -> Self { - IndySdkAnonCreds { indy_wallet_handle } - } -} - -#[async_trait] -impl BaseAnonCreds for IndySdkAnonCreds { - async fn verifier_verify_proof( - &self, - proof_req_json: &str, - proof_json: &str, - schemas_json: &str, - credential_defs_json: &str, - rev_reg_defs_json: &str, - rev_regs_json: &str, - ) -> VcxCoreResult { - anoncreds::indy::proofs::verifier::libindy_verifier_verify_proof( - proof_req_json, - proof_json, - schemas_json, - credential_defs_json, - rev_reg_defs_json, - rev_regs_json, - ) - .await - } - - async fn issuer_create_and_store_revoc_reg( - &self, - issuer_did: &str, - cred_def_id: &str, - tails_dir: &str, - max_creds: u32, - tag: &str, - ) -> VcxCoreResult<(String, String, String)> { - anoncreds::indy::credentials::issuer::libindy_create_and_store_revoc_reg( - self.indy_wallet_handle, - issuer_did, - cred_def_id, - tails_dir, - max_creds, - tag, - ) - .await - } - - async fn issuer_create_and_store_credential_def( - &self, - issuer_did: &str, - schema_json: &str, - tag: &str, - sig_type: Option<&str>, - config_json: &str, - ) -> VcxCoreResult<(String, String)> { - let res = Locator::instance() - .issuer_controller - .create_and_store_credential_definition( - self.indy_wallet_handle, - DidValue(issuer_did.into()), - parse_and_validate(schema_json)?, - tag.into(), - sig_type.map(|s| s.into()), - Some(serde_json::from_str(config_json)?), - ) - .await?; - - Ok(res) - } - - async fn issuer_create_credential_offer(&self, cred_def_id: &str) -> VcxCoreResult { - anoncreds::indy::credentials::issuer::libindy_issuer_create_credential_offer( - self.indy_wallet_handle, - cred_def_id, - ) - .await - } - - async fn issuer_create_credential( - &self, - cred_offer_json: &str, - cred_req_json: &str, - cred_values_json: &str, - rev_reg_id: Option, - tails_dir: Option, - ) -> VcxCoreResult<(String, Option, Option)> { - anoncreds::indy::credentials::issuer::libindy_issuer_create_credential( - self.indy_wallet_handle, - cred_offer_json, - cred_req_json, - cred_values_json, - rev_reg_id, - tails_dir, - ) - .await - } - - async fn prover_create_proof( - &self, - proof_req_json: &str, - requested_credentials_json: &str, - master_secret_id: &str, - schemas_json: &str, - credential_defs_json: &str, - revoc_states_json: Option<&str>, - ) -> VcxCoreResult { - anoncreds::indy::proofs::prover::libindy_prover_create_proof( - self.indy_wallet_handle, - proof_req_json, - requested_credentials_json, - master_secret_id, - schemas_json, - credential_defs_json, - revoc_states_json, - ) - .await - } - - async fn prover_get_credential(&self, cred_id: &str) -> VcxCoreResult { - anoncreds::indy::credentials::holder::libindy_prover_get_credential( - self.indy_wallet_handle, - cred_id, - ) - .await - } - - async fn prover_get_credentials(&self, filter_json: Option<&str>) -> VcxCoreResult { - anoncreds::indy::proofs::prover::libindy_prover_get_credentials( - self.indy_wallet_handle, - filter_json, - ) - .await - } - - async fn prover_get_credentials_for_proof_req(&self, proof_req: &str) -> VcxCoreResult { - anoncreds::indy::proofs::prover::libindy_prover_get_credentials_for_proof_req( - self.indy_wallet_handle, - proof_req, - ) - .await - } - - async fn prover_create_credential_req( - &self, - prover_did: &str, - credential_offer_json: &str, - credential_def_json: &str, - master_secret_id: &str, - ) -> VcxCoreResult<(String, String)> { - anoncreds::indy::credentials::holder::libindy_prover_create_credential_req( - self.indy_wallet_handle, - prover_did, - credential_offer_json, - credential_def_json, - master_secret_id, - ) - .await - } - - async fn create_revocation_state( - &self, - tails_dir: &str, - rev_reg_def_json: &str, - rev_reg_delta_json: &str, - timestamp: u64, - cred_rev_id: &str, - ) -> VcxCoreResult { - anoncreds::indy::proofs::prover::libindy_prover_create_revocation_state( - tails_dir, - rev_reg_def_json, - rev_reg_delta_json, - timestamp, - cred_rev_id, - ) - .await - } - - async fn prover_store_credential( - &self, - cred_id: Option<&str>, - cred_req_meta: &str, - cred_json: &str, - cred_def_json: &str, - rev_reg_def_json: Option<&str>, - ) -> VcxCoreResult { - anoncreds::indy::credentials::holder::libindy_prover_store_credential( - self.indy_wallet_handle, - cred_id, - cred_req_meta, - cred_json, - cred_def_json, - rev_reg_def_json, - ) - .await - } - - async fn prover_delete_credential(&self, cred_id: &str) -> VcxCoreResult<()> { - anoncreds::indy::credentials::holder::libindy_prover_delete_credential( - self.indy_wallet_handle, - cred_id, - ) - .await - } - - async fn prover_create_link_secret(&self, master_secret_id: &str) -> VcxCoreResult { - anoncreds::indy::credentials::holder::libindy_prover_create_master_secret( - self.indy_wallet_handle, - master_secret_id, - ) - .await - } - - async fn issuer_create_schema( - &self, - issuer_did: &str, - name: &str, - version: &str, - attrs: &str, - ) -> VcxCoreResult<(String, String)> { - libindy_issuer_create_schema(issuer_did, name, version, attrs).await - } - - async fn revoke_credential_local( - &self, - tails_dir: &str, - rev_reg_id: &str, - cred_rev_id: &str, - ) -> VcxCoreResult<()> { - anoncreds::indy::credentials::issuer::revoke_credential_local( - self.indy_wallet_handle, - tails_dir, - rev_reg_id, - cred_rev_id, - ) - .await - } - - async fn get_rev_reg_delta(&self, rev_reg_id: &str) -> VcxCoreResult> { - Ok(get_rev_reg_delta(self.indy_wallet_handle, rev_reg_id).await) - } - - async fn clear_rev_reg_delta(&self, rev_reg_id: &str) -> VcxCoreResult<()> { - clear_rev_reg_delta(self.indy_wallet_handle, rev_reg_id).await?; - Ok(()) - } - - async fn generate_nonce(&self) -> VcxCoreResult { - anoncreds::indy::general::generate_nonce().await - } -} diff --git a/aries_vcx_core/src/anoncreds/mod.rs b/aries_vcx_core/src/anoncreds/mod.rs index 744331e109..754b6642d8 100644 --- a/aries_vcx_core/src/anoncreds/mod.rs +++ b/aries_vcx_core/src/anoncreds/mod.rs @@ -1,9 +1,3 @@ pub mod base_anoncreds; - -#[cfg(any(feature = "modular_libs", feature = "vdr_proxy_ledger"))] +#[cfg(feature = "credx")] pub mod credx_anoncreds; - -#[cfg(feature = "vdrtools_anoncreds")] -pub mod indy; -#[cfg(feature = "vdrtools_anoncreds")] -pub mod indy_anoncreds; diff --git a/aries_vcx_core/src/errors/mod.rs b/aries_vcx_core/src/errors/mod.rs index 9ef99a5d30..841ab45fe2 100644 --- a/aries_vcx_core/src/errors/mod.rs +++ b/aries_vcx_core/src/errors/mod.rs @@ -1,8 +1,8 @@ pub mod error; mod mapping_agency_client; -#[cfg(feature = "modular_libs")] +#[cfg(feature = "credx")] mod mapping_credx; -#[cfg(any(feature = "vdrtools_anoncreds", feature = "vdrtools_wallet"))] +#[cfg(feature = "vdrtools_wallet")] mod mapping_indy_api_types; mod mapping_indyvdr; #[cfg(feature = "vdr_proxy_ledger")] diff --git a/aries_vcx_core/src/indy/mod.rs b/aries_vcx_core/src/indy/mod.rs deleted file mode 100644 index b5614dd823..0000000000 --- a/aries_vcx_core/src/indy/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod utils; diff --git a/aries_vcx_core/src/indy/utils/mod.rs b/aries_vcx_core/src/indy/utils/mod.rs deleted file mode 100644 index d36378faec..0000000000 --- a/aries_vcx_core/src/indy/utils/mod.rs +++ /dev/null @@ -1,27 +0,0 @@ -use std::sync::atomic::{AtomicUsize, Ordering}; - -use vdrtools::{types::validation::Validatable, CommandHandle}; - -use crate::errors::error::{AriesVcxCoreError, AriesVcxCoreErrorKind, VcxCoreResult}; - -static COMMAND_HANDLE_COUNTER: AtomicUsize = AtomicUsize::new(1); - -pub fn next_command_handle() -> CommandHandle { - (COMMAND_HANDLE_COUNTER.fetch_add(1, Ordering::SeqCst) + 1) as CommandHandle -} - -pub fn parse_and_validate<'a, T>(s: &'a str) -> VcxCoreResult -where - T: Validatable, - T: serde::Deserialize<'a>, -{ - let data = serde_json::from_str::(s)?; - - match data.validate() { - Ok(_) => Ok(data), - Err(s) => Err(AriesVcxCoreError::from_msg( - AriesVcxCoreErrorKind::LibindyInvalidStructure, - s, - )), - } -} diff --git a/aries_vcx_core/src/lib.rs b/aries_vcx_core/src/lib.rs index c53e13c92a..adbbf43082 100644 --- a/aries_vcx_core/src/lib.rs +++ b/aries_vcx_core/src/lib.rs @@ -17,20 +17,16 @@ macro_rules! secret { #[macro_use] extern crate lazy_static; -#[macro_use] extern crate serde_json; #[macro_use] extern crate log; -#[macro_use] extern crate derive_builder; pub mod anoncreds; pub mod errors; pub mod global; -#[cfg(feature = "vdrtools_anoncreds")] -pub mod indy; pub mod ledger; pub mod utils; pub mod wallet; diff --git a/aries_vcx_core/src/wallet/indy/mod.rs b/aries_vcx_core/src/wallet/indy/mod.rs index 4d46b2cb9d..86938afaf1 100644 --- a/aries_vcx_core/src/wallet/indy/mod.rs +++ b/aries_vcx_core/src/wallet/indy/mod.rs @@ -1,6 +1,7 @@ use std::thread; use async_trait::async_trait; +use derive_builder::Builder; use futures::executor::block_on; use serde::{Deserialize, Serialize}; use serde_json::Value; diff --git a/aries_vcx_core/src/wallet/indy/wallet_non_secrets.rs b/aries_vcx_core/src/wallet/indy/wallet_non_secrets.rs index b09a18b410..0d55adeaa5 100644 --- a/aries_vcx_core/src/wallet/indy/wallet_non_secrets.rs +++ b/aries_vcx_core/src/wallet/indy/wallet_non_secrets.rs @@ -1,4 +1,4 @@ -use serde_json; +use serde_json::{self, json}; use crate::{ errors::error::{AriesVcxCoreError, AriesVcxCoreErrorKind, VcxCoreResult}, diff --git a/did_resolver_sov/Cargo.toml b/did_resolver_sov/Cargo.toml index 318790ddd2..c4f7021ed3 100644 --- a/did_resolver_sov/Cargo.toml +++ b/did_resolver_sov/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [dependencies] did_resolver = { path = "../did_resolver" } -aries_vcx_core = { path = "../aries_vcx_core", features = ["modular_libs"] } +aries_vcx_core = { path = "../aries_vcx_core", default_features = false} did_doc_sov = { path = "../did_doc_sov" } async-trait = "0.1.68" mockall = "0.11.4" diff --git a/did_resolver_sov/src/resolution/utils.rs b/did_resolver_sov/src/resolution/utils.rs index 7a025a1d3a..df3b797c7d 100644 --- a/did_resolver_sov/src/resolution/utils.rs +++ b/did_resolver_sov/src/resolution/utils.rs @@ -50,7 +50,7 @@ fn get_txn_time_from_response(resp: &str) -> Result { fn unix_to_datetime(posix_timestamp: i64) -> Option> { NaiveDateTime::from_timestamp_opt(posix_timestamp, 0) - .map(|date_time| DateTime::::from_utc(date_time, Utc)) + .map(|date_time| DateTime::::from_naive_utc_and_offset(date_time, Utc)) } pub(super) fn is_valid_sovrin_did_id(id: &str) -> bool { diff --git a/indy_ledger_response_parser/Cargo.toml b/indy_ledger_response_parser/Cargo.toml index ec8a66fc07..9946743374 100644 --- a/indy_ledger_response_parser/Cargo.toml +++ b/indy_ledger_response_parser/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" [dependencies] serde = { version = "1.0.163", features = ["derive"] } serde_json = "1.0.96" -time = "=0.3.20" -indy-vdr = { git = "https://github.com/hyperledger/indy-vdr.git", rev = "879e29e", default-features = false, features = ["log"] } +time = "0.3.20" +indy-vdr = { git = "https://github.com/hyperledger/indy-vdr.git", rev = "c143268", default-features = false, features = ["log"] } thiserror = "1.0.44" anoncreds-clsignatures = "0.2.0" diff --git a/libvcx_core/Cargo.toml b/libvcx_core/Cargo.toml index b83823b225..99e8473583 100644 --- a/libvcx_core/Cargo.toml +++ b/libvcx_core/Cargo.toml @@ -12,22 +12,22 @@ fatal_warnings = [] num-traits = "0.2.0" once_cell = { version = "1.15" } cfg-if = { version = "1.0" } -env_logger = "0.9.0" +env_logger = "0.10.0" log = "0.4.16" chrono = "0.4.23" -time = "=0.3.20" +time = "0.3.20" lazy_static = "1.3" -libc = "=0.2.139" -rand = "0.7.3" +libc = "0.2.148" +rand = "0.8.5" serde = "1.0.97" serde_json = "1.0.40" serde_derive = "1.0.97" futures = { version = "0.3", default-features = false } -aries-vcx = { path = "../aries_vcx", features = ["modular_libs"] } +aries-vcx = { path = "../aries_vcx" } aries_vcx_core = { path = "../aries_vcx_core" } diddoc_legacy = { path = "../diddoc_legacy" } thiserror = "1.0.37" -uuid = { version = "0.7.4", default-features = false, features = ["v4"] } +uuid = { version = "1.4.1", default-features = false, features = ["v4"] } agency_client = { path = "../agency_client" } async-trait = "0.1.61" url = "2.3.1" diff --git a/libvcx_core/src/api_vcx/api_global/wallet.rs b/libvcx_core/src/api_vcx/api_global/wallet.rs index af43aef96f..15cfda7116 100644 --- a/libvcx_core/src/api_vcx/api_global/wallet.rs +++ b/libvcx_core/src/api_vcx/api_global/wallet.rs @@ -53,8 +53,8 @@ fn build_component_base_wallet(wallet_handle: WalletHandle) -> Arc) -> Arc { - Arc::new(IndyCredxAnonCreds::new(Arc::clone(&base_wallet))) +fn build_component_anoncreds(base_wallet: Arc) -> Arc { + Arc::new(IndyCredxAnonCreds::new(base_wallet.clone())) } fn setup_global_wallet(wallet_handle: WalletHandle) -> LibvcxResult<()> { diff --git a/libvdrtools/Cargo.toml b/libvdrtools/Cargo.toml index 12c2796017..284bac6a5a 100644 --- a/libvdrtools/Cargo.toml +++ b/libvdrtools/Cargo.toml @@ -26,35 +26,25 @@ mysql_storage = [] fatal_warnings = [] [dependencies] -async-std = { version = "1.8.0", features = ["attributes"] } -async-trait = "0.1.42" -etcommon-rlp = "0.2.4" -failure = { version = "0.1.8", features = ["backtrace"] } -hex = "0.4.0" -libc = "0.2.114" -log = "0.4.8" -log-derive = "0.3.0" -rand = "0.8.4" -bs58 = { version = "0.4.0", optional = true } -serde = "1.0.99" -serde_json = "1.0.40" -serde_derive = "1.0.99" -sha2 = "0.9" -sha3 = "0.9" -rmp-serde = "1.1.1" -time = "=0.3.20" -lazy_static = "1.3" -byteorder = "1.3.2" -zeroize = "~1.3.0" -regex = "1.2.1" -indy-api-types = { path = "./indy-api-types", features = ["casting_errors"]} +async-std = { version = "1", features = ["attributes"] } +async-trait = "0.1" +failure = { version = "0.1", features = ["backtrace"] } +hex = "0.4" +libc = "0.2" +log = "0.4" +log-derive = "0.4" +bs58 = { version = "0.5", optional = true } +serde = "1" +serde_json = "1" +serde_derive = "1" +lazy_static = "1" +zeroize = "1" +regex = "1" +indy-api-types = { path = "./indy-api-types"} indy-utils = { path = "./indy-utils"} indy-wallet = { path = "./indy-wallet"} -num-traits = "0.2" -num-derive = "0.3" futures = { version = "0.3", default-features = false, features = [ "executor", "alloc", "thread-pool" ] } -uuid = { version = "0.8", default-features = false, features = ["v4"] } -ursa = { version = "0.3.7", optional = true} +ursa = { version = "0.3.7", optional = true, default-features = false, features = ["cl_native"] } [dev-dependencies] -dirs = "2.0.2" +dirs = "5" diff --git a/libvdrtools/indy-api-types/Cargo.toml b/libvdrtools/indy-api-types/Cargo.toml index 02804933b7..1cde54b95c 100644 --- a/libvdrtools/indy-api-types/Cargo.toml +++ b/libvdrtools/indy-api-types/Cargo.toml @@ -6,23 +6,15 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[features] -casting_errors_wallet = [ "sqlx" ] -casting_errors_misc = [ "openssl", "rust-base58", "ursa"] -casting_errors = [ "casting_errors_wallet", "casting_errors_misc"] -rust-base58 = ["bs58"] - [dependencies] -thiserror = "1.0.40" +thiserror = "1" futures = { version = "0.3", default-features = false, features = ["std"] } -log = { version = "0.4.17", features = ["std"] } -libc = "0.2.114" -openssl = {version = "0.10", optional = true} -bs58 = {version = "0.4.0", optional = true} -serde = "1.0.99" -serde_json = "1.0.40" -serde_derive = "1.0.99" -sqlx = { version = "0.5.8", git = "https://github.com/jovfer/sqlx", branch = "feature/json_no_preserve_order_v5", features = [ "sqlite", "json_no_preserve_order", "runtime-tokio-rustls" ], optional = true } -zeroize = "~1.3.0" -ursa = { version = "0.3.7", optional = true} -aes = "0.7.4" +log = { version = "0.4", features = ["std"] } +libc = "0.2" +serde = "1" +serde_json = "1" +serde_derive = "1" +openssl = { version = "0.10" } +bs58 = "0.5" +sqlx = { version = "0.7", features = [ "sqlite", "mysql", "runtime-tokio-rustls" ] } +ursa = { version = "0.3.7", default-features = false, features = ["wasm"] } \ No newline at end of file diff --git a/libvdrtools/indy-api-types/src/domain/wallet/mod.rs b/libvdrtools/indy-api-types/src/domain/wallet/mod.rs index 06e2140c17..b5a008cefe 100644 --- a/libvdrtools/indy-api-types/src/domain/wallet/mod.rs +++ b/libvdrtools/indy-api-types/src/domain/wallet/mod.rs @@ -2,8 +2,6 @@ use std::{collections::HashMap, fmt}; use serde_json::value::Value; -use crate::validation::Validatable; - #[derive(Debug, Serialize, Deserialize, Clone, Default)] pub struct Config { pub id: String, @@ -101,12 +99,3 @@ impl fmt::Debug for Record { } pub type Tags = HashMap; - -impl Validatable for Config { - fn validate(&self) -> Result<(), String> { - if self.id.is_empty() { - return Err("Wallet id is empty".to_string()); - } - Ok(()) - } -} diff --git a/libvdrtools/indy-api-types/src/errors.rs b/libvdrtools/indy-api-types/src/errors.rs index f1a132e0dd..d792848571 100644 --- a/libvdrtools/indy-api-types/src/errors.rs +++ b/libvdrtools/indy-api-types/src/errors.rs @@ -12,6 +12,7 @@ use log; #[cfg(feature = "casting_errors_wallet")] use sqlx; use thiserror::Error as ThisError; +use ursa::errors::{UrsaCryptoError, UrsaCryptoErrorKind}; #[cfg(feature = "casting_errors_misc")] use ursa::errors::{UrsaCryptoError, UrsaCryptoErrorKind}; @@ -245,7 +246,6 @@ impl From for IndyError { } } -#[cfg(feature = "casting_errors_misc")] impl From for IndyError { fn from(err: UrsaCryptoError) -> Self { match err.kind() { @@ -275,7 +275,6 @@ impl From for IndyError { } } -#[cfg(feature = "casting_errors_misc")] impl From for IndyError { fn from(_err: bs58::decode::Error) -> Self { IndyError::from_msg( @@ -285,7 +284,6 @@ impl From for IndyError { } } -#[cfg(feature = "casting_errors_misc")] impl From for IndyError { fn from(err: openssl::error::ErrorStack) -> IndyError { // TODO: FIXME: Analyze ErrorStack and split invalid structure errors from other errors @@ -293,7 +291,6 @@ impl From for IndyError { } } -#[cfg(feature = "casting_errors_wallet")] impl From for IndyError { fn from(err: sqlx::Error) -> IndyError { match &err { diff --git a/libvdrtools/indy-api-types/src/lib.rs b/libvdrtools/indy-api-types/src/lib.rs index a81e656296..8e9f98c1b0 100644 --- a/libvdrtools/indy-api-types/src/lib.rs +++ b/libvdrtools/indy-api-types/src/lib.rs @@ -47,8 +47,6 @@ pub mod domain; pub mod errors; pub use errors::IndyError; -pub mod validation; - #[derive(Debug, PartialEq, Eq, Copy, Clone)] #[repr(i32)] pub enum ErrorCode { diff --git a/libvdrtools/indy-api-types/src/validation.rs b/libvdrtools/indy-api-types/src/validation.rs deleted file mode 100644 index 9fe85212b7..0000000000 --- a/libvdrtools/indy-api-types/src/validation.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub trait Validatable { - fn validate(&self) -> Result<(), String> { - Ok(()) - } -} diff --git a/libvdrtools/indy-utils/Cargo.toml b/libvdrtools/indy-utils/Cargo.toml index e5c6f0da74..9b7bc91bbf 100644 --- a/libvdrtools/indy-utils/Cargo.toml +++ b/libvdrtools/indy-utils/Cargo.toml @@ -19,20 +19,20 @@ hash_openssl = [] randombytes_sodium = [] [dependencies] -base64 = {version = "0.10.1"} -dirs = "2.0.2" -failure = "0.1.6" +base64 = {version = "0.21"} +dirs = "5" +failure = "0.1" indy-api-types = { path = "../indy-api-types"} -lazy_static = "1.3" -libc = "0.2.114" -log = "0.4.8" +lazy_static = "1" +libc = "0.2" +log = "0.4" openssl = { version = "0.10" } -serde = "1.0.99" -serde_json = "1.0.40" -serde_derive = "1.0.99" -sodiumoxide = {version = "0.0.16"} -zeroize = "~1.3.0" +serde = "1" +serde_json = "1" +serde_derive = "1" +sodiumoxide = {version = "0.0.16"} # touching this makes things go boom +zeroize = "1" [dev-dependencies] -rmp-serde = "0.13.7" -rand = "0.7.0" +rmp-serde = "1" +rand = "0.8" diff --git a/libvdrtools/indy-utils/src/crypto/base64/rust_base64.rs b/libvdrtools/indy-utils/src/crypto/base64/rust_base64.rs index cac198ae91..1c48f23779 100644 --- a/libvdrtools/indy-utils/src/crypto/base64/rust_base64.rs +++ b/libvdrtools/indy-utils/src/crypto/base64/rust_base64.rs @@ -1,20 +1,22 @@ +use base64::{engine::general_purpose, Engine}; use indy_api_types::errors::prelude::*; pub fn encode(doc: &[u8]) -> String { - base64::encode(doc) + general_purpose::STANDARD.encode(doc) } pub fn decode(doc: &str) -> Result, IndyError> { - base64::decode(doc) + general_purpose::STANDARD + .decode(doc) .map_err(|e| e.to_indy(IndyErrorKind::InvalidStructure, "Invalid base64 sequence")) } pub fn encode_urlsafe(doc: &[u8]) -> String { - base64::encode_config(doc, base64::URL_SAFE) //TODO switch to URL_SAFE_NO_PAD + general_purpose::URL_SAFE.encode(doc) } pub fn decode_urlsafe(doc: &str) -> Result, IndyError> { - base64::decode_config(doc, base64::URL_SAFE_NO_PAD).map_err(|e| { + general_purpose::URL_SAFE.decode(doc).map_err(|e| { e.to_indy( IndyErrorKind::InvalidStructure, "Invalid base64URL_SAFE sequence", @@ -53,19 +55,4 @@ mod tests { assert!(result.is_ok(), "Got error"); assert_eq!(&[1, 2, 3], &result.unwrap()[..]); } - - #[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/libvdrtools/indy-utils/src/lib.rs b/libvdrtools/indy-utils/src/lib.rs index 83bc87b618..2888fda516 100644 --- a/libvdrtools/indy-utils/src/lib.rs +++ b/libvdrtools/indy-utils/src/lib.rs @@ -22,9 +22,6 @@ macro_rules! secret { pub mod crypto; pub mod environment; pub mod sequence; -#[macro_use] -#[allow(unused_macros)] -pub mod test; pub mod wql; use indy_api_types::{CommandHandle, SearchHandle, VdrHandle, WalletHandle}; diff --git a/libvdrtools/indy-utils/src/test.rs b/libvdrtools/indy-utils/src/test.rs deleted file mode 100644 index 27147c4ec3..0000000000 --- a/libvdrtools/indy-utils/src/test.rs +++ /dev/null @@ -1,124 +0,0 @@ -use std::{fs, fs::File, path::Path}; - -use super::environment; - -pub fn cleanup_files(dir: &Path, name: &str) { - let mut path = dir.to_path_buf(); - path.push(name); - if path.exists() { - if path.is_dir() { - fs::remove_dir_all(path).unwrap(); - } else { - fs::remove_file(path).unwrap(); - } - } -} - -pub fn cleanup_indy_home(name: &str) { - cleanup_files(&environment::indy_home_path(), name); -} - -pub fn cleanup_temp(name: &str) { - cleanup_files(&environment::tmp_path(), name); -} - -pub fn cleanup_wallet(name: &str) { - cleanup_files(&environment::wallet_home_path(), name); -} - -pub fn cleanup_pool(name: &str) { - cleanup_files(&environment::pool_home_path(), name); -} - -pub fn cleanup_storage(name: &str) { - cleanup_wallet(name); - cleanup_pool(name); - cleanup_indy_home(name); - cleanup_temp(name); -} - -pub fn test_pool_create_poolfile(pool_name: &str) -> File { - let mut pool_path = environment::pool_path(pool_name); - fs::create_dir_all(pool_path.as_path()).unwrap(); - pool_path.push(pool_name); - pool_path.set_extension("txn"); - fs::File::create(pool_path.as_path()).unwrap() -} - -pub fn check_pool_exists(name: &str) -> bool { - let mut path = environment::pool_home_path(); - path.push(name); - path.exists() -} - -pub fn gen_txns() -> Vec { - let test_pool_ip = environment::test_pool_ip(); - - vec![ - format!( - r#"{{"reqSignature":{{}},"txn":{{"data":{{"data":{{"alias":"Node1","blskey":"4N8aUNHSgjQVgkpm8nhNEfDf6txHznoYREg9kirmJrkivgL4oSEimFF6nsQ6M41QvhM2Z33nves5vfSn9n1UwNFJBYtWVnHYMATn76vLuL3zU88KyeAYcHfsih3He6UHcXDxcaecHVz6jhCYz1P2UZn2bDVruL5wXpehgBfBaLKm3Ba","blskey_pop":"RahHYiCvoNCtPTrVtP7nMC5eTYrsUA8WjXbdhNc8debh1agE9bGiJxWBXYNFbnJXoXhWFMvyqhqhRoq737YQemH5ik9oL7R4NTTCz2LEZhkgLJzB3QRQqJyBNyv7acbdHrAT8nQ9UkLbaVL9NBpnWXBTw4LEMePaSHEw66RzPNdAX1","client_ip":"{}","client_port":9702,"node_ip":"{}","node_port":9701,"services":["VALIDATOR"]}},"dest":"Gw6pDLhcBcoQesN72qfotTgFa7cbuqZpkX3Xo6pLhPhv"}},"metadata":{{"from":"Th7MpTaRZVRYnPiabds81Y"}},"type":"0"}},"txnMetadata":{{"seqNo":1,"txnId":"fea82e10e894419fe2bea7d96296a6d46f50f93f9eeda954ec461b2ed2950b62"}},"ver":"1"}}"#, - test_pool_ip, test_pool_ip - ), - format!( - r#"{{"reqSignature":{{}},"txn":{{"data":{{"data":{{"alias":"Node2","blskey":"37rAPpXVoxzKhz7d9gkUe52XuXryuLXoM6P6LbWDB7LSbG62Lsb33sfG7zqS8TK1MXwuCHj1FKNzVpsnafmqLG1vXN88rt38mNFs9TENzm4QHdBzsvCuoBnPH7rpYYDo9DZNJePaDvRvqJKByCabubJz3XXKbEeshzpz4Ma5QYpJqjk","blskey_pop":"Qr658mWZ2YC8JXGXwMDQTzuZCWF7NK9EwxphGmcBvCh6ybUuLxbG65nsX4JvD4SPNtkJ2w9ug1yLTj6fgmuDg41TgECXjLCij3RMsV8CwewBVgVN67wsA45DFWvqvLtu4rjNnE9JbdFTc1Z4WCPA3Xan44K1HoHAq9EVeaRYs8zoF5","client_ip":"{}","client_port":9704,"node_ip":"{}","node_port":9703,"services":["VALIDATOR"]}},"dest":"8ECVSk179mjsjKRLWiQtssMLgp6EPhWXtaYyStWPSGAb"}},"metadata":{{"from":"EbP4aYNeTHL6q385GuVpRV"}},"type":"0"}},"txnMetadata":{{"seqNo":2,"txnId":"1ac8aece2a18ced660fef8694b61aac3af08ba875ce3026a160acbc3a3af35fc"}},"ver":"1"}}"#, - test_pool_ip, test_pool_ip - ), - format!( - r#"{{"reqSignature":{{}},"txn":{{"data":{{"data":{{"alias":"Node3","blskey":"3WFpdbg7C5cnLYZwFZevJqhubkFALBfCBBok15GdrKMUhUjGsk3jV6QKj6MZgEubF7oqCafxNdkm7eswgA4sdKTRc82tLGzZBd6vNqU8dupzup6uYUf32KTHTPQbuUM8Yk4QFXjEf2Usu2TJcNkdgpyeUSX42u5LqdDDpNSWUK5deC5","blskey_pop":"QwDeb2CkNSx6r8QC8vGQK3GRv7Yndn84TGNijX8YXHPiagXajyfTjoR87rXUu4G4QLk2cF8NNyqWiYMus1623dELWwx57rLCFqGh7N4ZRbGDRP4fnVcaKg1BcUxQ866Ven4gw8y4N56S5HzxXNBZtLYmhGHvDtk6PFkFwCvxYrNYjh","client_ip":"{}","client_port":9706,"node_ip":"{}","node_port":9705,"services":["VALIDATOR"]}},"dest":"DKVxG2fXXTU8yT5N7hGEbXB3dfdAnYv1JczDUHpmDxya"}},"metadata":{{"from":"4cU41vWW82ArfxJxHkzXPG"}},"type":"0"}},"txnMetadata":{{"seqNo":3,"txnId":"7e9f355dffa78ed24668f0e0e369fd8c224076571c51e2ea8be5f26479edebe4"}},"ver":"1"}}"#, - test_pool_ip, test_pool_ip - ), - format!( - r#"{{"reqSignature":{{}},"txn":{{"data":{{"data":{{"alias":"Node4","blskey":"2zN3bHM1m4rLz54MJHYSwvqzPchYp8jkHswveCLAEJVcX6Mm1wHQD1SkPYMzUDTZvWvhuE6VNAkK3KxVeEmsanSmvjVkReDeBEMxeDaayjcZjFGPydyey1qxBHmTvAnBKoPydvuTAqx5f7YNNRAdeLmUi99gERUU7TD8KfAa6MpQ9bw","blskey_pop":"RPLagxaR5xdimFzwmzYnz4ZhWtYQEj8iR5ZU53T2gitPCyCHQneUn2Huc4oeLd2B2HzkGnjAff4hWTJT6C7qHYB1Mv2wU5iHHGFWkhnTX9WsEAbunJCV2qcaXScKj4tTfvdDKfLiVuU2av6hbsMztirRze7LvYBkRHV3tGwyCptsrP","client_ip":"{}","client_port":9708,"node_ip":"{}","node_port":9707,"services":["VALIDATOR"]}},"dest":"4PS3EDQ3dW1tci1Bp6543CfuuebjFrg36kLAUcskGfaA"}},"metadata":{{"from":"TWwCRQRZ2ZHMJFn9TzLp7W"}},"type":"0"}},"txnMetadata":{{"seqNo":4,"txnId":"aa5e817d7cc626170eca175822029339a444eb0ee8f0bd20d3b0b76e566fb008"}},"ver":"1"}}"#, - test_pool_ip, test_pool_ip - ), - ] -} - -#[macro_export] -macro_rules! assert_match { - ($pattern:pat, $var:expr) => { - assert!(match $var { - $pattern => true, - _ => false, - }) - }; - ($pattern:pat, $var:expr, $val_in_pattern:ident, $exp_value:expr) => { - assert!(match $var { - $pattern => $val_in_pattern == $exp_value, - _ => false, - }) - }; - ( - $pattern:pat, - $var:expr, - $val_in_pattern1:ident, - $exp_value1:expr, - $val_in_pattern2:ident, - $exp_value2:expr - ) => { - assert!(match $var { - $pattern => $val_in_pattern1 == $exp_value1 && $val_in_pattern2 == $exp_value2, - _ => false, - }) - }; -} - -#[macro_export] -macro_rules! assert_kind { - ($kind:expr, $var:expr) => { - match $var { - Err(e) => assert_eq!($kind, e.kind()), - _ => assert!(false, "Result expected to be error"), - } - }; -} - -#[macro_export] -macro_rules! assert_code { - ($code:expr, $var:expr) => { - match $var { - Err(e) => assert_eq!($code, e.error_code), - _ => assert!(false, "Result expected to be error"), - } - }; -} diff --git a/libvdrtools/indy-wallet/Cargo.toml b/libvdrtools/indy-wallet/Cargo.toml index e388816185..7d3c951630 100644 --- a/libvdrtools/indy-wallet/Cargo.toml +++ b/libvdrtools/indy-wallet/Cargo.toml @@ -12,21 +12,21 @@ mysql = [] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -async-trait = "0.1.42" -byteorder = "1.3.2" +async-trait = "0.1" +byteorder = "1" futures = { version = "0.3", default-features = false, features = [ "alloc" ] } -indy-api-types = { path = "../indy-api-types", features = [ "casting_errors_wallet", "casting_errors_misc" ] } +indy-api-types = { path = "../indy-api-types" } indy-utils = { path = "../indy-utils"} -libc = "0.2.114" -log = "0.4.8" -rmp-serde = "0.13.7" -bs58 = "0.4.0" -serde = "1.0.99" -serde_json = "1.0.40" -serde_derive = "1.0.99" -sqlx = { version = "0.5.8", git = "https://github.com/jovfer/sqlx", branch = "feature/json_no_preserve_order_v5", features = [ "sqlite", "mysql", "json_no_preserve_order", "runtime-tokio-rustls" ] } -zeroize = "~1.3.0" -lru = "0.7.6" +libc = "0.2" +log = "0.4" +rmp-serde = "1" +bs58 = "0.5" +serde = "1" +serde_json = "1" +serde_derive = "1" +sqlx = { version = "0.7", features = [ "sqlite", "mysql", "runtime-tokio-rustls" ] } +zeroize = "1" +lru = "0.12" [dev-dependencies] -async-std = "1.12.0" +async-std = "1" diff --git a/libvdrtools/indy-wallet/src/cache/cache.rs b/libvdrtools/indy-wallet/src/cache/cache.rs deleted file mode 100644 index 83732c4390..0000000000 --- a/libvdrtools/indy-wallet/src/cache/cache.rs +++ /dev/null @@ -1,11 +0,0 @@ -use crate::cache::wallet_cache::{WalletCacheKey, WalletCacheValue}; - -pub trait Cache { - fn put(&mut self, key: WalletCacheKey, value: WalletCacheValue) -> Option; - fn get(&mut self, key: &WalletCacheKey) -> Option<&WalletCacheValue>; - fn get_mut(&mut self, key: &WalletCacheKey) -> Option<&mut WalletCacheValue>; - fn pop(&mut self, key: &WalletCacheKey) -> Option; - fn peek(&self, key: &WalletCacheKey) -> Option<&WalletCacheValue>; - fn len(&self) -> usize; - fn cap(&self) -> usize; -} diff --git a/libvdrtools/indy-wallet/src/cache/lru.rs b/libvdrtools/indy-wallet/src/cache/lru.rs index b72988547e..fe50b13e4c 100644 --- a/libvdrtools/indy-wallet/src/cache/lru.rs +++ b/libvdrtools/indy-wallet/src/cache/lru.rs @@ -1,8 +1,10 @@ +use std::num::NonZeroUsize; + use lru::LruCache as InnerCache; use crate::cache::{ - cache::Cache, wallet_cache::{WalletCacheKey, WalletCacheValue}, + Cache, }; pub struct LruCache { @@ -10,7 +12,7 @@ pub struct LruCache { } impl LruCache { - pub fn new(size: usize) -> LruCache { + pub fn new(size: NonZeroUsize) -> LruCache { LruCache { inner: InnerCache::new(size), } @@ -43,6 +45,6 @@ impl Cache for LruCache { } fn cap(&self) -> usize { - self.inner.cap() + self.inner.cap().into() } } diff --git a/libvdrtools/indy-wallet/src/cache/mod.rs b/libvdrtools/indy-wallet/src/cache/mod.rs index 922e4fff0f..747dc487fc 100644 --- a/libvdrtools/indy-wallet/src/cache/mod.rs +++ b/libvdrtools/indy-wallet/src/cache/mod.rs @@ -1,3 +1,14 @@ -mod cache; mod lru; pub mod wallet_cache; + +use crate::cache::wallet_cache::{WalletCacheKey, WalletCacheValue}; + +pub trait Cache { + fn put(&mut self, key: WalletCacheKey, value: WalletCacheValue) -> Option; + fn get(&mut self, key: &WalletCacheKey) -> Option<&WalletCacheValue>; + fn get_mut(&mut self, key: &WalletCacheKey) -> Option<&mut WalletCacheValue>; + fn pop(&mut self, key: &WalletCacheKey) -> Option; + fn peek(&self, key: &WalletCacheKey) -> Option<&WalletCacheValue>; + fn len(&self) -> usize; + fn cap(&self) -> usize; +} diff --git a/libvdrtools/indy-wallet/src/cache/wallet_cache.rs b/libvdrtools/indy-wallet/src/cache/wallet_cache.rs index 8276c8cfb3..2bf91dad4e 100644 --- a/libvdrtools/indy-wallet/src/cache/wallet_cache.rs +++ b/libvdrtools/indy-wallet/src/cache/wallet_cache.rs @@ -1,6 +1,7 @@ use std::{ collections::{HashMap, HashSet}, iter::FromIterator, + num::NonZeroUsize, sync::{ atomic::{AtomicUsize, Ordering}, Mutex, RwLock, @@ -10,7 +11,7 @@ use std::{ use indy_api_types::domain::wallet::{CacheConfig, CachingAlgorithm}; use crate::{ - cache::{cache::Cache, lru::LruCache}, + cache::{lru::LruCache, Cache}, storage::{ StorageRecord, Tag, Tag::{Encrypted, PlainText}, @@ -42,7 +43,9 @@ impl WalletCache { match config { Some(cache_config) if cache_config.size > 0 && !cache_config.entities.is_empty() => { let cache = match cache_config.algorithm { - CachingAlgorithm::LRU => LruCache::new(cache_config.size), + CachingAlgorithm::LRU => { + LruCache::new(NonZeroUsize::new(cache_config.size).unwrap()) + } }; WalletCache { cache: Some(Mutex::new(Box::new(cache))), diff --git a/libvdrtools/indy-wallet/src/encryption.rs b/libvdrtools/indy-wallet/src/encryption.rs index efe8d01406..d3df984a1a 100644 --- a/libvdrtools/indy-wallet/src/encryption.rs +++ b/libvdrtools/indy-wallet/src/encryption.rs @@ -49,11 +49,11 @@ impl KeyDerivationData { (KeyDerivationMethod::RAW, &Metadata::MetadataRaw(_)) => { KeyDerivationData::Raw(passphrase) } - (KeyDerivationMethod::ARGON2I_INT, &Metadata::MetadataArgon(ref metadata)) => { + (KeyDerivationMethod::ARGON2I_INT, Metadata::MetadataArgon(metadata)) => { let master_key_salt = master_key_salt_from_slice(&metadata.master_key_salt)?; KeyDerivationData::Argon2iInt(passphrase, master_key_salt) } - (KeyDerivationMethod::ARGON2I_MOD, &Metadata::MetadataArgon(ref metadata)) => { + (KeyDerivationMethod::ARGON2I_MOD, Metadata::MetadataArgon(metadata)) => { let master_key_salt = master_key_salt_from_slice(&metadata.master_key_salt)?; KeyDerivationData::Argon2iMod(passphrase, master_key_salt) } diff --git a/libvdrtools/indy-wallet/src/export_import.rs b/libvdrtools/indy-wallet/src/export_import.rs index 0bba9edfd4..3dd2eb2e46 100644 --- a/libvdrtools/indy-wallet/src/export_import.rs +++ b/libvdrtools/indy-wallet/src/export_import.rs @@ -173,6 +173,7 @@ pub(super) async fn export_continue( Ok(()) } +#[allow(clippy::type_complexity)] pub(super) fn preparse_file_to_import( reader: T, passphrase: &str, diff --git a/libvdrtools/indy-wallet/src/lib.rs b/libvdrtools/indy-wallet/src/lib.rs index 06ed59e5f0..8528783d88 100644 --- a/libvdrtools/indy-wallet/src/lib.rs +++ b/libvdrtools/indy-wallet/src/lib.rs @@ -1,5 +1,3 @@ -#![allow(clippy::all)] - use std::{ collections::{HashMap, HashSet}, fmt, fs, @@ -52,6 +50,7 @@ pub struct MigrationResult { failed: u32, } +#[allow(clippy::type_complexity)] pub struct WalletService { storage_types: Mutex>>, wallets: Mutex>>, @@ -82,6 +81,7 @@ pub struct WalletService { cache_hit_metrics: WalletCacheHitMetrics, } +#[allow(clippy::new_without_default)] impl WalletService { pub fn new() -> WalletService { let storage_types = { @@ -976,6 +976,7 @@ impl WalletService { self.cache_hit_metrics.get_data() } + #[allow(clippy::type_complexity)] fn _get_config_and_cred_for_storage( &self, config: &Config, diff --git a/libvdrtools/indy-wallet/src/storage/default/mod.rs b/libvdrtools/indy-wallet/src/storage/default/mod.rs index d8e13aa897..d32790f65b 100644 --- a/libvdrtools/indy-wallet/src/storage/default/mod.rs +++ b/libvdrtools/indy-wallet/src/storage/default/mod.rs @@ -128,7 +128,7 @@ impl WalletStorage for SQLiteStorage { sqlx::query_as("SELECT id, value, key FROM items where type = ?1 AND name = ?2") .bind(type_) .bind(id) - .fetch_one(&mut conn) + .fetch_one(&mut *conn) .await?; let value = if options.retrieve_value { @@ -151,7 +151,7 @@ impl WalletStorage for SQLiteStorage { "SELECT name, value from tags_plaintext where item_id = ?", ) .bind(item_id) - .fetch_all(&mut conn) + .fetch_all(&mut *conn) .await? .drain(..) .map(|r| Tag::PlainText(r.0, r.1)), @@ -162,7 +162,7 @@ impl WalletStorage for SQLiteStorage { "SELECT name, value from tags_encrypted where item_id = ?", ) .bind(item_id) - .fetch_all(&mut conn) + .fetch_all(&mut *conn) .await? .drain(..) .map(|r| Tag::Encrypted(r.0, r.1)), @@ -218,7 +218,7 @@ impl WalletStorage for SQLiteStorage { .bind(id) .bind(&value.data) .bind(&value.key) - .execute(&mut tx) + .execute(&mut *tx) .await? .last_insert_rowid(); @@ -231,7 +231,7 @@ impl WalletStorage for SQLiteStorage { .bind(id) .bind(tag_name) .bind(tag_data) - .execute(&mut tx) + .execute(&mut *tx) .await? } Tag::PlainText(ref tag_name, ref tag_data) => { @@ -241,7 +241,7 @@ impl WalletStorage for SQLiteStorage { .bind(id) .bind(tag_name) .bind(tag_data) - .execute(&mut tx) + .execute(&mut *tx) .await? } }; @@ -258,9 +258,9 @@ impl WalletStorage for SQLiteStorage { sqlx::query("UPDATE items SET value = ?1, key = ?2 WHERE type = ?3 AND name = ?4") .bind(&value.data) .bind(&value.key) - .bind(&type_) - .bind(&id) - .execute(&mut tx) + .bind(type_) + .bind(id) + .execute(&mut *tx) .await? .rows_affected(); @@ -287,7 +287,7 @@ impl WalletStorage for SQLiteStorage { sqlx::query_as("SELECT id FROM items WHERE type = ?1 AND name = ?2") .bind(type_) .bind(id) - .fetch_one(&mut tx) + .fetch_one(&mut *tx) .await?; for tag in tags { @@ -300,7 +300,7 @@ impl WalletStorage for SQLiteStorage { .bind(item_id) .bind(tag_name) .bind(tag_data) - .execute(&mut tx) + .execute(&mut *tx) .await? } Tag::PlainText(ref tag_name, ref tag_data) => { @@ -311,7 +311,7 @@ impl WalletStorage for SQLiteStorage { .bind(item_id) .bind(tag_name) .bind(tag_data) - .execute(&mut tx) + .execute(&mut *tx) .await? } }; @@ -327,18 +327,18 @@ impl WalletStorage for SQLiteStorage { let (item_id,): (i64,) = sqlx::query_as("SELECT id FROM items WHERE type = ?1 AND name = ?2") .bind(type_) - .bind(&id) - .fetch_one(&mut tx) + .bind(id) + .fetch_one(&mut *tx) .await?; sqlx::query("DELETE FROM tags_encrypted WHERE item_id = ?1") .bind(item_id) - .execute(&mut tx) + .execute(&mut *tx) .await?; sqlx::query("DELETE FROM tags_plaintext WHERE item_id = ?1") .bind(item_id) - .execute(&mut tx) + .execute(&mut *tx) .await?; for tag in tags { @@ -350,7 +350,7 @@ impl WalletStorage for SQLiteStorage { .bind(item_id) .bind(tag_name) .bind(tag_data) - .execute(&mut tx) + .execute(&mut *tx) .await? } Tag::PlainText(ref tag_name, ref tag_data) => { @@ -360,7 +360,7 @@ impl WalletStorage for SQLiteStorage { .bind(item_id) .bind(tag_name) .bind(tag_data) - .execute(&mut tx) + .execute(&mut *tx) .await? } }; @@ -378,7 +378,7 @@ impl WalletStorage for SQLiteStorage { sqlx::query_as("SELECT id FROM items WHERE type = ?1 AND name = ?2") .bind(type_) .bind(id) - .fetch_one(&mut tx) + .fetch_one(&mut *tx) .await?; for tag_name in tag_names { @@ -387,14 +387,14 @@ impl WalletStorage for SQLiteStorage { sqlx::query("DELETE FROM tags_encrypted WHERE item_id = ?1 AND name = ?2") .bind(item_id) .bind(tag_name) - .execute(&mut tx) + .execute(&mut *tx) .await? } TagName::OfPlain(ref tag_name) => { sqlx::query("DELETE FROM tags_plaintext WHERE item_id = ?1 AND name = ?2") .bind(item_id) .bind(tag_name) - .execute(&mut tx) + .execute(&mut *tx) .await? } }; @@ -435,7 +435,7 @@ impl WalletStorage for SQLiteStorage { let rows_affected = sqlx::query("DELETE FROM items where type = ?1 AND name = ?2") .bind(type_) .bind(id) - .execute(&mut tx) + .execute(&mut *tx) .await? .rows_affected(); @@ -459,7 +459,7 @@ impl WalletStorage for SQLiteStorage { let mut conn = self.pool.acquire().await?; let (metadata,): (Vec,) = sqlx::query_as::<_, (Vec,)>("SELECT value FROM metadata") - .fetch_one(&mut conn) + .fetch_one(&mut *conn) .await?; Ok(metadata) @@ -470,7 +470,7 @@ impl WalletStorage for SQLiteStorage { sqlx::query("UPDATE metadata SET value = ?1") .bind(metadata) - .execute(&mut tx) + .execute(&mut *tx) .await?; tx.commit().await?; @@ -485,7 +485,7 @@ impl WalletStorage for SQLiteStorage { sqlx::query_as::<_, (i64, Vec, String)>( "SELECT item_id, name, value from tags_plaintext", ) - .fetch_all(&mut conn) + .fetch_all(&mut *conn) .await? .drain(..) .map(|r| (r.0, Tag::PlainText(r.1, r.2))), @@ -495,7 +495,7 @@ impl WalletStorage for SQLiteStorage { sqlx::query_as::<_, (i64, Vec, Vec)>( "SELECT item_id, name, value from tags_encrypted", ) - .fetch_all(&mut conn) + .fetch_all(&mut *conn) .await? .drain(..) .map(|r| (r.0, Tag::Encrypted(r.1, r.2))), @@ -510,7 +510,7 @@ impl WalletStorage for SQLiteStorage { let records: VecDeque<_> = sqlx::query_as::<_, (i64, Vec, Vec, Vec, Vec)>( "SELECT id, name, value, key, type FROM items", ) - .fetch_all(&mut conn) + .fetch_all(&mut *conn) .await? .drain(..) .map(|r| { @@ -563,7 +563,7 @@ impl WalletStorage for SQLiteStorage { } } - let mut records = query.fetch_all(&mut conn).await?; + let mut records = query.fetch_all(&mut *conn).await?; let mut mtags = if options.retrieve_tags && !records.is_empty() { let mut tags: Vec<(i64, Tag)> = Vec::new(); @@ -590,7 +590,7 @@ impl WalletStorage for SQLiteStorage { tags.extend( query - .fetch_all(&mut conn) + .fetch_all(&mut *conn) .await? .drain(..) .map(|r| (r.0, Tag::PlainText(r.1, r.2))), @@ -613,7 +613,7 @@ impl WalletStorage for SQLiteStorage { tags.extend( query - .fetch_all(&mut conn) + .fetch_all(&mut *conn) .await? .drain(..) .map(|r| (r.0, Tag::Encrypted(r.1, r.2))), @@ -671,7 +671,7 @@ impl WalletStorage for SQLiteStorage { } } - let (total_count,) = query.fetch_one(&mut conn).await?; + let (total_count,) = query.fetch_one(&mut *conn).await?; Some(total_count as usize) } else { None @@ -922,10 +922,10 @@ impl WalletStorageType for SQLiteStorageType { )); } - let mut connect_options = SqliteConnectOptions::new() + let connect_options = SqliteConnectOptions::new() .filename(db_path.as_path()) - .journal_mode(SqliteJournalMode::Wal); - connect_options.disable_statement_logging(); + .journal_mode(SqliteJournalMode::Wal) + .disable_statement_logging(); Ok(Box::new(SQLiteStorage { pool: SqlitePoolOptions::default() diff --git a/libvdrtools/indy-wallet/src/storage/default/query.rs b/libvdrtools/indy-wallet/src/storage/default/query.rs index e2ad6f5b79..d639b2c713 100644 --- a/libvdrtools/indy-wallet/src/storage/default/query.rs +++ b/libvdrtools/indy-wallet/src/storage/default/query.rs @@ -116,10 +116,7 @@ fn eq_to_sql<'a>( arguments: &mut Vec>, ) -> IndyResult { match (name, value) { - ( - &TagName::PlainTagName(ref queried_name), - &TargetValue::Unencrypted(ref queried_value), - ) => { + (TagName::PlainTagName(queried_name), TargetValue::Unencrypted(ref queried_value)) => { arguments.push(queried_name.into()); arguments.push(queried_value.into()); Ok( @@ -128,8 +125,8 @@ fn eq_to_sql<'a>( ) } ( - &TagName::EncryptedTagName(ref queried_name), - &TargetValue::Encrypted(ref queried_value), + TagName::EncryptedTagName(ref queried_name), + TargetValue::Encrypted(ref queried_value), ) => { arguments.push(queried_name.into()); arguments.push(queried_value.into()); @@ -151,10 +148,7 @@ fn neq_to_sql<'a>( arguments: &mut Vec>, ) -> IndyResult { match (name, value) { - ( - &TagName::PlainTagName(ref queried_name), - &TargetValue::Unencrypted(ref queried_value), - ) => { + (TagName::PlainTagName(ref queried_name), TargetValue::Unencrypted(ref queried_value)) => { arguments.push(queried_name.into()); arguments.push(queried_value.into()); Ok( @@ -163,8 +157,8 @@ fn neq_to_sql<'a>( ) } ( - &TagName::EncryptedTagName(ref queried_name), - &TargetValue::Encrypted(ref queried_value), + TagName::EncryptedTagName(ref queried_name), + TargetValue::Encrypted(ref queried_value), ) => { arguments.push(queried_name.into()); arguments.push(queried_value.into()); @@ -186,10 +180,7 @@ fn gt_to_sql<'a>( arguments: &mut Vec>, ) -> IndyResult { match (name, value) { - ( - &TagName::PlainTagName(ref queried_name), - &TargetValue::Unencrypted(ref queried_value), - ) => { + (TagName::PlainTagName(ref queried_name), TargetValue::Unencrypted(ref queried_value)) => { arguments.push(queried_name.into()); arguments.push(queried_value.into()); Ok( @@ -210,10 +201,7 @@ fn gte_to_sql<'a>( arguments: &mut Vec>, ) -> IndyResult { match (name, value) { - ( - &TagName::PlainTagName(ref queried_name), - &TargetValue::Unencrypted(ref queried_value), - ) => { + (TagName::PlainTagName(ref queried_name), TargetValue::Unencrypted(ref queried_value)) => { arguments.push(queried_name.into()); arguments.push(queried_value.into()); Ok( @@ -234,10 +222,7 @@ fn lt_to_sql<'a>( arguments: &mut Vec>, ) -> IndyResult { match (name, value) { - ( - &TagName::PlainTagName(ref queried_name), - &TargetValue::Unencrypted(ref queried_value), - ) => { + (TagName::PlainTagName(ref queried_name), TargetValue::Unencrypted(ref queried_value)) => { arguments.push(queried_name.into()); arguments.push(queried_value.into()); Ok( @@ -258,10 +243,7 @@ fn lte_to_sql<'a>( arguments: &mut Vec>, ) -> IndyResult { match (name, value) { - ( - &TagName::PlainTagName(ref queried_name), - &TargetValue::Unencrypted(ref queried_value), - ) => { + (TagName::PlainTagName(ref queried_name), TargetValue::Unencrypted(ref queried_value)) => { arguments.push(queried_name.into()); arguments.push(queried_value.into()); Ok( @@ -282,10 +264,7 @@ fn like_to_sql<'a>( arguments: &mut Vec>, ) -> IndyResult { match (name, value) { - ( - &TagName::PlainTagName(ref queried_name), - &TargetValue::Unencrypted(ref queried_value), - ) => { + (TagName::PlainTagName(ref queried_name), TargetValue::Unencrypted(ref queried_value)) => { arguments.push(queried_name.into()); arguments.push(queried_value.into()); Ok( diff --git a/libvdrtools/indy-wallet/src/storage/mysql/mod.rs b/libvdrtools/indy-wallet/src/storage/mysql/mod.rs index 68c73629d5..f479e8fd1f 100644 --- a/libvdrtools/indy-wallet/src/storage/mysql/mod.rs +++ b/libvdrtools/indy-wallet/src/storage/mysql/mod.rs @@ -122,12 +122,12 @@ impl MySqlStorageType { return Ok(connection.clone()); } - let mut my_sql_connect_options = MySqlConnectOptions::new() + let my_sql_connect_options = MySqlConnectOptions::new() .host(host_addr) .database(&config.db_name) .username(&credentials.user) - .password(&credentials.pass); - my_sql_connect_options.log_statements(LevelFilter::Debug); + .password(&credentials.pass) + .log_statements(LevelFilter::Debug); let connection = MySqlPoolOptions::default() .max_connections(config.connection_limit) @@ -200,7 +200,7 @@ impl WalletStorage for MySqlStorage { .bind(self.wallet_id) .bind(&base64::encode(type_)) .bind(&base64::encode(id)) - .fetch_one(&mut conn) + .fetch_one(&mut *conn) .await?; let value = if let Some(value) = value { @@ -271,8 +271,8 @@ impl WalletStorage for MySqlStorage { .bind(&base64::encode(id)) .bind(&value.to_bytes()) .bind(&_tags_to_json(tags)?) - .bind(&self.wallet_id) - .execute(&mut tx) + .bind(self.wallet_id) + .execute(&mut *tx) .await?; tx.commit().await?; @@ -294,8 +294,8 @@ impl WalletStorage for MySqlStorage { .bind(&value.to_bytes()) .bind(&base64::encode(type_)) .bind(&base64::encode(id)) - .bind(&self.wallet_id) - .execute(&mut tx) + .bind(self.wallet_id) + .execute(&mut *tx) .await? .rows_affected(); @@ -341,8 +341,8 @@ impl WalletStorage for MySqlStorage { )) .bind(&base64::encode(type_)) .bind(&base64::encode(id)) - .bind(&self.wallet_id) - .execute(&mut tx) + .bind(self.wallet_id) + .execute(&mut *tx) .await? .rows_affected(); @@ -377,8 +377,8 @@ impl WalletStorage for MySqlStorage { .bind(&_tags_to_json(tags)?) .bind(&base64::encode(type_)) .bind(&base64::encode(id)) - .bind(&self.wallet_id) - .execute(&mut tx) + .bind(self.wallet_id) + .execute(&mut *tx) .await? .rows_affected(); @@ -424,8 +424,8 @@ impl WalletStorage for MySqlStorage { )) .bind(&base64::encode(type_)) .bind(&base64::encode(id)) - .bind(&self.wallet_id) - .execute(&mut tx) + .bind(self.wallet_id) + .execute(&mut *tx) .await? .rows_affected(); @@ -482,8 +482,8 @@ impl WalletStorage for MySqlStorage { ) .bind(&base64::encode(type_)) .bind(&base64::encode(id)) - .bind(&self.wallet_id) - .execute(&mut tx) + .bind(self.wallet_id) + .execute(&mut *tx) .await? .rows_affected(); @@ -513,8 +513,8 @@ impl WalletStorage for MySqlStorage { WHERE id = ? "#, ) - .bind(&self.wallet_id) - .fetch_one(&mut conn) + .bind(self.wallet_id) + .fetch_one(&mut *conn) .await?; base64::decode(&metadata) @@ -531,8 +531,8 @@ impl WalletStorage for MySqlStorage { "#, ) .bind(base64::encode(metadata)) - .bind(&self.wallet_id) - .execute(&mut tx) + .bind(self.wallet_id) + .execute(&mut *tx) .await?; tx.commit().await?; @@ -611,7 +611,7 @@ impl WalletStorage for MySqlStorage { } } - let (total_count,) = query.fetch_one(&mut conn).await?; + let (total_count,) = query.fetch_one(&mut *conn).await?; Some(total_count as usize) } else { None @@ -750,7 +750,7 @@ impl WalletStorageType for MySqlStorageType { "#, ) .bind(id) - .execute(&mut tx) + .execute(&mut *tx) .await; let rows_affected = res?.rows_affected(); @@ -826,11 +826,11 @@ impl WalletStorageType for MySqlStorageType { "Absent credentials json", ))?; - let mut my_sql_connect_options = MySqlConnectOptions::new() + let my_sql_connect_options = MySqlConnectOptions::new() .host(&config.write_host) .username(&credentials.user) - .password(&credentials.pass); - my_sql_connect_options.log_statements(LevelFilter::Debug); + .password(&credentials.pass) + .log_statements(LevelFilter::Debug); let mut pool = MySqlPoolOptions::default() .max_connections(1) @@ -848,7 +848,7 @@ impl WalletStorageType for MySqlStorageType { "CREATE DATABASE IF NOT EXISTS `{}`;", config.db_name )) - .execute(&mut con) + .execute(&mut *con) .await?; // Replace the previous single use pool @@ -868,7 +868,7 @@ impl WalletStorageType for MySqlStorageType { PRIMARY KEY (`wallet_id`, `type`, `name`) );"#, ) - .execute(&mut con) + .execute(&mut *con) .await?; sqlx::query( @@ -880,7 +880,7 @@ impl WalletStorageType for MySqlStorageType { PRIMARY KEY (`id`) );"#, ) - .execute(&mut con) + .execute(&mut *con) .await?; let mut tx = pool.begin().await?; @@ -893,7 +893,7 @@ impl WalletStorageType for MySqlStorageType { ) .bind(id) .bind(base64::encode(metadata)) - .execute(&mut tx) + .execute(&mut *tx) .await; match res { @@ -996,13 +996,21 @@ impl WalletStorageType for MySqlStorageType { } #[cfg(test)] +#[allow(clippy::all)] mod tests { - #[allow(unused_imports)] - use indy_utils::{assert_kind, environment}; + use indy_utils::environment; use super::{super::Tag, *}; - // docker run --name indy-mysql -e MYSQL_ROOT_PASSWORD=pass@word1 -p 3306:3306 -d mysql:latest + #[allow(unused_macros)] + macro_rules! assert_kind { + ($kind:expr, $var:expr) => { + match $var { + Err(e) => assert_eq!($kind, e.kind()), + _ => assert!(false, "Result expected to be error"), + } + }; + } #[async_std::test] #[cfg(feature = "benchmark")] @@ -2023,11 +2031,11 @@ mod tests { } fn _metadata() -> Vec { - return vec![ + vec![ 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, - ]; + ] } fn _type(i: u8) -> Vec { @@ -2131,10 +2139,10 @@ mod tests { } fn _tags() -> Vec { - let mut tags: Vec = Vec::new(); - tags.push(Tag::Encrypted(vec![1, 5, 8], vec![3, 5, 6])); - tags.push(Tag::PlainText(vec![1, 5, 8, 1], "Plain value".to_string())); - tags + vec![ + Tag::Encrypted(vec![1, 5, 8], vec![3, 5, 6]), + Tag::PlainText(vec![1, 5, 8, 1], "Plain value".to_string()), + ] } fn _new_tags() -> Vec { diff --git a/libvdrtools/indy-wallet/src/wallet.rs b/libvdrtools/indy-wallet/src/wallet.rs index 39d695015b..e21d29afff 100644 --- a/libvdrtools/indy-wallet/src/wallet.rs +++ b/libvdrtools/indy-wallet/src/wallet.rs @@ -474,7 +474,7 @@ impl Wallet { Ok(WalletIterator::new(all_items, self.keys.clone())) } - pub fn get_id<'a>(&'a self) -> &'a str { + pub fn get_id(&self) -> &str { &self.id } } diff --git a/libvdrtools/mac.build.sh b/libvdrtools/mac.build.sh deleted file mode 100755 index db29ff9783..0000000000 --- a/libvdrtools/mac.build.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash - -onred='\033[41m' -ongreen='\033[42m' -onyellow='\033[43m' -endcolor="\033[0m" - -# Handle errors -set -e -error_report() { - echo -e "${onred}Error: failed on line $1.$endcolor" -} -trap 'error_report $LINENO' ERR - -echo -e "${onyellow}Installing libvdrtools...$endcolor" - -function brew_install { - if brew ls --versions $1 >/dev/null; then - if [[ $(brew outdated $1) ]]; then - HOMEBREW_NO_AUTO_UPDATE=1 brew upgrade $1 - fi - else - HOMEBREW_NO_AUTO_UPDATE=1 brew install $1 - fi -} - -if [[ "$OSTYPE" == "darwin"* ]]; then - xcode-select --version || xcode-select --install - brew --version || yes | /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" - cmake --version || brew install cmake # brew install cmake throws error, not warning if already installed - curl https://sh.rustup.rs -sSf | sh -s -- -y - export PATH="$HOME/.cargo/bin:$PATH" # so can use cargo without relog - brew_install pkg-config - brew_install libsodium - brew_install automake - brew_install autoconf - brew_install openssl - brew_install zeromq - brew_install zmq - export PKG_CONFIG_ALLOW_CROSS=1 - export CARGO_INCREMENTAL=1 - export RUST_LOG=indy=trace - export RUST_TEST_THREADS=1 - export OPENSSL_DIR=/usr/local/opt/`ls /usr/local/opt/ | grep openssl | sort | tail -1` - cargo build - export LIBRARY_PATH=$(pwd)/target/debug - cd ../cli - cargo build - echo 'export DYLD_LIBRARY_PATH='$LIBRARY_PATH' -export LD_LIBRARY_PATH='$LIBRARY_PATH >> ~/.bash_profile - echo -e "${ongreen}libvdrtools installed.$endcolor" -else - echo -e "${onred}You are not running MacOS. This is a MacOS installer.$endcolor" -fi - - diff --git a/libvdrtools/src/controllers/anoncreds/issuer.rs b/libvdrtools/src/controllers/anoncreds/issuer.rs deleted file mode 100644 index a129fc19c5..0000000000 --- a/libvdrtools/src/controllers/anoncreds/issuer.rs +++ /dev/null @@ -1,1526 +0,0 @@ -use std::{ - collections::{HashMap, HashSet}, - sync::Arc, -}; - -// use async_std::task::spawn_blocking; -use indy_api_types::{domain::wallet::Tags, errors::prelude::*, WalletHandle}; -use indy_wallet::{RecordOptions, WalletService}; -use ursa::cl::{ - new_nonce, CredentialKeyCorrectnessProof, CredentialPrivateKey, - RevocationRegistryDelta as CryptoRevocationRegistryDelta, Witness, -}; - -use super::tails::{store_tails_from_generator, SDKTailsAccessor}; -pub use crate::{ - domain::{ - anoncreds::{ - credential::{Credential, CredentialValues}, - credential_definition::{ - CredentialDefinition, CredentialDefinitionConfig, - CredentialDefinitionCorrectnessProof, CredentialDefinitionData, - CredentialDefinitionId, CredentialDefinitionPrivateKey, CredentialDefinitionV1, - SignatureType, TemporaryCredentialDefinition, - }, - credential_offer::CredentialOffer, - credential_request::CredentialRequest, - revocation_registry::{RevocationRegistry, RevocationRegistryV1}, - revocation_registry_definition::{ - IssuanceType, RegistryType, RevocationRegistryConfig, RevocationRegistryDefinition, - RevocationRegistryDefinitionPrivate, RevocationRegistryDefinitionV1, - RevocationRegistryDefinitionValue, RevocationRegistryId, RevocationRegistryInfo, - }, - revocation_registry_delta::{RevocationRegistryDelta, RevocationRegistryDeltaV1}, - schema::{AttributeNames, Schema, SchemaId, SchemaV1}, - }, - crypto::did::DidValue, - }, - services::{AnoncredsHelpers, BlobStorageService, CryptoService, IssuerService}, -}; - -pub struct IssuerController { - pub issuer_service: Arc, - pub blob_storage_service: Arc, - pub wallet_service: Arc, - pub crypto_service: Arc, -} - -impl IssuerController { - pub fn new( - issuer_service: Arc, - blob_storage_service: Arc, - wallet_service: Arc, - crypto_service: Arc, - ) -> IssuerController { - IssuerController { - issuer_service, - blob_storage_service, - wallet_service, - crypto_service, - } - } - - /* - These functions wrap the Ursa algorithm as documented in this paper: - https://github.com/hyperledger/ursa/blob/master/libursa/docs/AnonCred.pdf - - And is documented in this HIPE: - https://github.com/hyperledger/indy-hipe/blob/c761c583b1e01c1e9d3ceda2b03b35336fdc8cc1/text/anoncreds-protocol/README.md - */ - - /// Create credential schema entity that describes credential attributes list and allows - /// credentials interoperability. - /// - /// Schema is public and intended to be shared with all anoncreds workflow actors usually by - /// publishing SCHEMA transaction to Indy distributed ledger. - /// - /// It is IMPORTANT for current version POST Schema in Ledger and after that GET it from Ledger - /// with correct seq_no to save compatibility with Ledger. - /// After that can call indy_issuer_create_and_store_credential_def to build corresponding - /// Credential Definition. - /// - /// #Params - - /// issuer_did: DID of schema issuer - /// name: a name the schema - /// version: a version of the schema - /// attrs: a list of schema attributes descriptions (the number of attributes should be less or - /// equal than 125) `["attr1", "attr2"]` - /// - /// #Returns - /// schema_id: identifier of created schema - /// schema_json: schema as json: - /// { - /// id: identifier of schema - /// attrNames: array of attribute name strings - /// name: schema's name string - /// version: schema's version string, - /// ver: version of the Schema json - /// } - /// - /// #Errors - /// Common* - /// Anoncreds* - pub fn create_schema( - &self, - issuer_did: DidValue, - name: String, - version: String, - attrs: AttributeNames, - ) -> IndyResult<(String, String)> { - trace!( - "create_schema > issuer_did {:?} name {:?} version {:?} attrs {:?}", - issuer_did, - name, - version, - attrs - ); - - self.crypto_service.validate_did(&issuer_did)?; - - let schema_id = SchemaId::new(&issuer_did, &name, &version)?; - - let schema = Schema::SchemaV1(SchemaV1 { - id: schema_id.clone(), - name, - version, - attr_names: attrs, - seq_no: None, - }); - - let schema_json = serde_json::to_string(&schema) - .to_indy(IndyErrorKind::InvalidState, "Cannot serialize Schema")?; - - let res = Ok((schema_id.0, schema_json)); - trace!("create_schema < {:?}", res); - res - } - - /// Create credential definition entity that encapsulates credentials issuer DID, credential - /// schema, secrets used for signing credentials and secrets used for credentials - /// revocation. - /// - /// Credential definition entity contains private and public parts. Private part will be stored - /// in the wallet. Public part will be returned as json intended to be shared with all - /// anoncreds workflow actors usually by publishing CRED_DEF transaction to Indy distributed - /// ledger. - /// - /// It is IMPORTANT for current version GET Schema from Ledger with correct seq_no to save - /// compatibility with Ledger. - /// - /// Note: Use combination of `indy_issuer_rotate_credential_def_start` and - /// `indy_issuer_rotate_credential_def_apply` functions to generate new keys for an existing - /// credential definition. - /// - /// #Params - - /// wallet_handle: wallet handle (created by open_wallet). - /// issuer_did: a DID of the issuer - /// schema_json: credential schema as a json: { - /// id: identifier of schema - /// attrNames: array of attribute name strings - /// name: schema's name string - /// version: schema's version string, - /// seqNo: (Optional) schema's sequence number on the ledger, - /// ver: version of the Schema json - /// } - /// tag: any string that allows to distinguish between credential definitions for the same - /// issuer and schema signature_type: credential definition type (optional, 'CL' by default) - /// that defines credentials signature and revocation math. Supported signature types: - /// - 'CL': Camenisch-Lysyanskaya credential signature type that is implemented according to the - /// algorithm in this paper: https://github.com/hyperledger/ursa/blob/master/libursa/docs/AnonCred.pdf - /// And is documented in this HIPE: https://github.com/hyperledger/indy-hipe/blob/c761c583b1e01c1e9d3ceda2b03b35336fdc8cc1/text/anoncreds-protocol/README.md - /// config_json: (optional) type-specific configuration of credential definition as json: - /// - 'CL': { "support_revocation" - bool (optional, default false) whether to request - /// non-revocation credential } - /// - /// #Returns - /// cred_def_id: identifier of created credential definition - /// cred_def_json: public part of created credential definition - /// { - /// id: string - identifier of credential definition - /// schemaId: string - identifier of stored in ledger schema - /// type: string - type of the credential definition. CL is the only supported type now. - /// tag: string - allows to distinct between credential definitions for the same issuer and - /// schema value: Dictionary with Credential Definition's data is depended on the - /// signature type: { primary: primary credential public key, - /// Optional: revocation credential public key - /// }, - /// ver: Version of the CredDef json - /// } - /// - /// Note: `primary` and `revocation` fields of credential definition are complex opaque types - /// that contain data structures internal to Ursa. They should not be parsed and are likely - /// to change in future versions. - /// - /// #Errors - /// Common* - /// Wallet* - /// Anoncreds* - pub async fn create_and_store_credential_definition( - &self, - wallet_handle: WalletHandle, - issuer_did: DidValue, - schema: Schema, - tag: String, - type_: Option, - config: Option, - ) -> IndyResult<(String, String)> { - trace!( - "create_and_store_credential_definition > wallet_handle {:?} issuer_did {:?} schema \ - {:?} tag {:?} type_ {:?}, config {:?}", - wallet_handle, - issuer_did, - schema, - tag, - type_, - config - ); - - let mut schema = SchemaV1::from(schema); - - match (issuer_did.get_method(), schema.id.get_method()) { - (None, Some(_)) => { - return Err(IndyError::from_msg( - IndyErrorKind::InvalidStructure, - "You can't use unqualified Did with fully qualified Schema", - )); - } - (Some(prefix_), None) => { - schema.id = schema.id.qualify(&prefix_)?; - } - _ => {} - }; - - let cred_def_config = config.unwrap_or_default(); - - let signature_type = if let Some(type_) = type_ { - serde_json::from_str::(&format!("\"{}\"", type_)).to_indy( - IndyErrorKind::InvalidStructure, - "Invalid Signature Type format", - )? - } else { - SignatureType::CL - }; - - let schema_id = schema - .seq_no - .map(|n| SchemaId(n.to_string())) - .unwrap_or_else(|| schema.id.clone()); - - let cred_def_id = - CredentialDefinitionId::new(&issuer_did, &schema_id, signature_type.to_str(), &tag)?; - - let cred_def = self - .wallet_service - .get_indy_record_value::( - wallet_handle, - &cred_def_id.0, - &RecordOptions::id_value(), - ) - .await; - - if let Ok(cred_def) = cred_def { - let res = Ok((cred_def_id.0, cred_def)); - - trace!( - "create_and_store_credential_definition < already exists {:?}", - res - ); - - return res; - } - - let tag = tag.to_string(); - let attr_names = schema.attr_names.clone(); - - let (credential_definition_value, cred_priv_key, cred_key_correctness_proof) = self - ._create_credential_definition(&attr_names, cred_def_config.support_revocation) - .await?; - - let cred_def = CredentialDefinition::CredentialDefinitionV1(CredentialDefinitionV1 { - id: cred_def_id.clone(), - schema_id: schema_id.clone(), - signature_type, - tag, - value: credential_definition_value, - }); - - let cred_def_priv_key = CredentialDefinitionPrivateKey { - value: cred_priv_key, - }; - - let cred_def_correctness_proof = CredentialDefinitionCorrectnessProof { - value: cred_key_correctness_proof, - }; - - let schema_ = Schema::SchemaV1(schema.clone()); - - let cred_def_json = self - .wallet_service - .add_indy_object(wallet_handle, &cred_def_id.0, &cred_def, &HashMap::new()) - .await?; - - self.wallet_service - .add_indy_object( - wallet_handle, - &cred_def_id.0, - &cred_def_priv_key, - &HashMap::new(), - ) - .await?; - - self.wallet_service - .add_indy_object( - wallet_handle, - &cred_def_id.0, - &cred_def_correctness_proof, - &HashMap::new(), - ) - .await?; - - let _ = self - .wallet_service - .add_indy_object(wallet_handle, &schema_id.0, &schema_, &HashMap::new()) - .await - .ok(); - - let schema_id = schema.id.clone(); - - self._wallet_set_schema_id(wallet_handle, &cred_def_id.0, &schema_id) - .await?; // TODO: FIXME delete temporary storing of schema id - - let res = Ok((cred_def_id.0, cred_def_json)); - trace!("create_and_store_credential_definition < {:?}", res); - res - } - - async fn _create_credential_definition( - &self, - attr_names: &AttributeNames, - support_revocation: bool, - ) -> IndyResult<( - CredentialDefinitionData, - CredentialPrivateKey, - CredentialKeyCorrectnessProof, - )> { - // let attr_names = attr_names.clone(); - - IssuerService::new_credential_definition(attr_names, support_revocation) - // let res = spawn_blocking(move || { - // IssuerService::new_credential_definition(&attr_names, support_revocation) - // }) - // .await?; - - // Ok(res) - } - - /// Generate temporary credential definitional keys for an existing one (owned by the caller of - /// the library). - /// - /// Use `indy_issuer_rotate_credential_def_apply` function to set generated temporary keys as - /// the main. - /// - /// WARNING: Rotating the credential definitional keys will result in making all credentials - /// issued under the previous keys unverifiable. - /// - /// #Params - - /// wallet_handle: wallet handle (created by open_wallet). - /// cred_def_id: an identifier of created credential definition stored in the wallet - /// config_json: (optional) type-specific configuration of credential definition as json: - /// - 'CL': { "support_revocation" - bool (optional, default false) whether to request - /// non-revocation credential } - /// - /// #Returns - /// cred_def_json: public part of temporary created credential definition - /// { - /// id: string - identifier of credential definition - /// schemaId: string - identifier of stored in ledger schema - /// type: string - type of the credential definition. CL is the only supported type now. - /// tag: string - allows to distinct between credential definitions for the same issuer and - /// schema value: Dictionary with Credential Definition's data is depended on the - /// signature type: { primary: primary credential public key, - /// Optional: revocation credential public key - /// }, - only this field differs from the original credential definition - /// ver: Version of the CredDef json - /// } - /// - /// Note: `primary` and `revocation` fields of credential definition are complex opaque types - /// that contain data structures internal to Ursa. They should not be parsed and are likely - /// to change in future versions. - /// - /// #Errors - /// Common* - /// Wallet* - /// Anoncreds* - pub async fn rotate_credential_definition_start( - &self, - wallet_handle: WalletHandle, - cred_def_id: CredentialDefinitionId, - cred_def_config: Option, - ) -> IndyResult { - trace!( - "rotate_credential_definition_start > wallet_handle {:?} cred_def_id {:?} \ - cred_def_config {:?}", - wallet_handle, - cred_def_id, - cred_def_config - ); - - let cred_def = self - .wallet_service - .get_indy_object::( - wallet_handle, - &cred_def_id.0, - &RecordOptions::id_value(), - ) - .await?; - - let cred_def = CredentialDefinitionV1::from(cred_def); - - let temp_cred_def = self - .wallet_service - .get_indy_object::( - wallet_handle, - &cred_def_id.0, - &RecordOptions::id_value(), - ) - .await; - - if let Ok(temp_cred_def) = temp_cred_def { - let cred_def_json = serde_json::to_string(&temp_cred_def.cred_def).to_indy( - IndyErrorKind::InvalidState, - "Can't serialize CredentialDefinition", - )?; - - let res = Ok(cred_def_json); - - trace!( - "rotate_credential_definition_start < already exists {:?}", - res - ); - - return res; - } - - let schema = self - .wallet_service - .get_indy_object::( - wallet_handle, - &cred_def.schema_id.0, - &RecordOptions::id_value(), - ) - .await?; - - let schema = SchemaV1::from(schema); - - let support_revocation = cred_def_config - .map(|config| config.support_revocation) - .unwrap_or_default(); - - let (credential_definition_value, cred_priv_key, cred_key_correctness_proof) = self - ._create_credential_definition(&schema.attr_names, support_revocation) - .await?; - - let cred_def = CredentialDefinition::CredentialDefinitionV1(CredentialDefinitionV1 { - id: cred_def_id.clone(), - schema_id: cred_def.schema_id.clone(), - signature_type: cred_def.signature_type.clone(), - tag: cred_def.tag.clone(), - value: credential_definition_value, - }); - - let cred_def_priv_key = CredentialDefinitionPrivateKey { - value: cred_priv_key, - }; - - let cred_def_correctness_proof = CredentialDefinitionCorrectnessProof { - value: cred_key_correctness_proof, - }; - - let cred_def_json = ::serde_json::to_string(&cred_def).to_indy( - IndyErrorKind::InvalidState, - "Cannot serialize CredentialDefinition", - )?; - - let temp_cred_def = TemporaryCredentialDefinition { - cred_def, - cred_def_priv_key, - cred_def_correctness_proof, - }; - - self.wallet_service - .add_indy_object( - wallet_handle, - &cred_def_id.0, - &temp_cred_def, - &HashMap::new(), - ) - .await?; - - let res = Ok(cred_def_json); - trace!("rotate_credential_definition_start < {:?}", res); - res - } - - /// Apply temporary keys as main for an existing Credential Definition (owned by the caller of - /// the library). - /// - /// WARNING: Rotating the credential definitional keys will result in making all credentials - /// issued under the previous keys unverifiable. - /// - /// #Params - - /// wallet_handle: wallet handle (created by open_wallet). - /// cred_def_id: an identifier of created credential definition stored in the wallet - /// - /// #Returns - /// - /// #Errors - /// Common* - /// Wallet* - /// Anoncreds* - pub async fn rotate_credential_definition_apply( - &self, - wallet_handle: WalletHandle, - cred_def_id: CredentialDefinitionId, - ) -> IndyResult<()> { - trace!( - "rotate_credential_definition_apply > wallet_handle {:?} cred_def_id {:?}", - wallet_handle, - cred_def_id - ); - - let _cred_def: CredentialDefinition = self - .wallet_service - .get_indy_object(wallet_handle, &cred_def_id.0, &RecordOptions::id_value()) - .await?; - - let temp_cred_def: TemporaryCredentialDefinition = self - .wallet_service - .get_indy_object(wallet_handle, &cred_def_id.0, &RecordOptions::id_value()) - .await?; - - self.wallet_service - .update_indy_object(wallet_handle, &cred_def_id.0, &temp_cred_def.cred_def) - .await?; - - self.wallet_service - .update_indy_object( - wallet_handle, - &cred_def_id.0, - &temp_cred_def.cred_def_priv_key, - ) - .await?; - - self.wallet_service - .update_indy_object( - wallet_handle, - &cred_def_id.0, - &temp_cred_def.cred_def_correctness_proof, - ) - .await?; - - self.wallet_service - .delete_indy_record::(wallet_handle, &cred_def_id.0) - .await?; - - trace!("rotate_credential_definition_apply <<<"); - Ok(()) - } - - /// Create a new revocation registry for the given credential definition as tuple of entities - /// - Revocation registry definition that encapsulates credentials definition reference, - /// revocation type specific configuration and secrets used for credentials revocation - /// - Revocation registry state that stores the information about revoked entities in a - /// non-disclosing way. The state can be represented as ordered list of revocation registry - /// entries were each entry represents the list of revocation or issuance operations. - /// - /// Revocation registry definition entity contains private and public parts. Private part will - /// be stored in the wallet. Public part will be returned as json intended to be shared with - /// all anoncreds workflow actors usually by publishing REVOC_REG_DEF transaction - /// to Indy distributed ledger. - /// - /// Revocation registry state is stored on the wallet and also intended to be shared as the - /// ordered list of REVOC_REG_ENTRY transactions. This call initializes the state in the - /// wallet and returns the initial entry. - /// - /// Some revocation registry types (for example, 'CL_ACCUM') can require generation of binary - /// blob called tails used to hide information about revoked credentials in public - /// revocation registry and intended to be distributed out of leger (REVOC_REG_DEF transaction - /// will still contain uri and hash of tails). This call requires access to pre-configured - /// blob storage writer instance handle that will allow to write generated tails. - /// - /// #Params - - /// wallet_handle: wallet handle (created by open_wallet). - /// issuer_did: a DID of the issuer - /// revoc_def_type: revocation registry type (optional, default value depends on credential - /// definition type). Supported types are: - /// - 'CL_ACCUM': Type-3 pairing based accumulator implemented according to the algorithm in this paper: - /// https://github.com/hyperledger/ursa/blob/master/libursa/docs/AnonCred.pdf - /// This type is default for 'CL' credential definition type. - /// tag: any string that allows to distinct between revocation registries for the same issuer - /// and credential definition cred_def_id: id of stored in ledger credential definition - /// config_json: type-specific configuration of revocation registry as json: - /// - 'CL_ACCUM': { "issuance_type": (optional) type of issuance. Currently supported: 1) - /// ISSUANCE_BY_DEFAULT: all indices are assumed to be issued and initial accumulator is - /// calculated over all indices; Revocation Registry is updated only during revocation. 2) - /// ISSUANCE_ON_DEMAND: nothing is issued initially accumulator is 1 (used by default); - /// "max_cred_num": maximum number of credentials the new registry can process (optional, - /// default 100000) - /// } - /// tails_writer_handle: handle of blob storage to store tails (returned by - /// `indy_open_blob_storage_writer`). - /// - /// NOTE: - /// Recursive creation of folder for Default Tails Writer (correspondent to - /// `tails_writer_handle`) in the system-wide temporary directory may fail in some setup - /// due to permissions: `IO error: Permission denied`. In this case use `TMPDIR` - /// environment variable to define temporary directory specific for an application. - /// - /// #Returns - /// revoc_reg_id: identifier of created revocation registry definition - /// revoc_reg_def_json: public part of revocation registry definition - /// { - /// "id": string - ID of the Revocation Registry, - /// "revocDefType": string - Revocation Registry type (only CL_ACCUM is supported for - /// now), "tag": string - Unique descriptive ID of the Registry, - /// "credDefId": string - ID of the corresponding CredentialDefinition, - /// "value": Registry-specific data { - /// "issuanceType": string - Type of Issuance(ISSUANCE_BY_DEFAULT or - /// ISSUANCE_ON_DEMAND), "maxCredNum": number - Maximum number of credentials - /// the Registry can serve. "tailsHash": string - Hash of tails. - /// "tailsLocation": string - Location of tails file. - /// "publicKeys": - Registry's public key (opaque type that contains - /// data structures internal to Ursa. - /// It should not be parsed and are likely to change in future versions). }, - /// "ver": string - version of revocation registry definition json. - /// } - /// revoc_reg_entry_json: revocation registry entry that defines initial state of revocation - /// registry { - /// value: { - /// prevAccum: string - previous accumulator value. - /// accum: string - current accumulator value. - /// issued: array - an array of issued indices. - /// revoked: array an array of revoked indices. - /// }, - /// ver: string - version revocation registry entry json - /// } - /// - /// #Errors - /// Common* - /// Wallet* - /// Anoncreds* - pub async fn create_and_store_revocation_registry( - &self, - wallet_handle: WalletHandle, - issuer_did: DidValue, - type_: Option, - tag: String, - cred_def_id: CredentialDefinitionId, - config: RevocationRegistryConfig, - tails_writer_handle: i32, - ) -> IndyResult<(String, String, String)> { - trace!( - "create_and_store_revocation_registry > wallet_handle {:?} issuer_did {:?} type_ {:?} \ - tag: {:?} cred_def_id {:?} config: {:?} tails_handle {:?}", - wallet_handle, - issuer_did, - type_, - tag, - cred_def_id, - config, - tails_writer_handle - ); - - match (issuer_did.get_method(), cred_def_id.get_method()) { - (None, Some(_)) => { - return Err(IndyError::from_msg( - IndyErrorKind::InvalidStructure, - "You can't use unqualified Did with fully qualified Credential Definition", - )); - } - (Some(_), None) => { - return Err(IndyError::from_msg( - IndyErrorKind::InvalidStructure, - "You can't use fully qualified Did with unqualified Credential Definition", - )); - } - _ => {} - }; - - let rev_reg_type = if let Some(type_) = type_ { - serde_json::from_str::(&format!("\"{}\"", type_)).to_indy( - IndyErrorKind::InvalidStructure, - "Invalid Registry Type format", - )? - } else { - RegistryType::CL_ACCUM - }; - - let issuance_type = config - .issuance_type - .clone() - .unwrap_or(IssuanceType::ISSUANCE_ON_DEMAND); - - let max_cred_num = config.max_cred_num.unwrap_or(100000); - - let rev_reg_id = - RevocationRegistryId::new(&issuer_did, &cred_def_id, &rev_reg_type.to_str(), &tag)?; - - if let (Ok(rev_reg_def), Ok(rev_reg)) = ( - self.wallet_service - .get_indy_record_value::( - wallet_handle, - &rev_reg_id.0, - &RecordOptions::id_value(), - ) - .await, - self.wallet_service - .get_indy_record_value::( - wallet_handle, - &rev_reg_id.0, - &RecordOptions::id_value(), - ) - .await, - ) { - let res = Ok((cred_def_id.0.to_string(), rev_reg_def, rev_reg)); - - trace!( - "create_and_store_revocation_registry < already exists {:?}", - res - ); - - return res; - } - - let cred_def: CredentialDefinition = self - .wallet_service - .get_indy_object(wallet_handle, &cred_def_id.0, &RecordOptions::id_value()) - .await?; - - let (revoc_public_keys, revoc_key_private, revoc_registry, mut revoc_tails_generator) = - self.issuer_service.new_revocation_registry( - &CredentialDefinitionV1::from(cred_def), - max_cred_num, - issuance_type.to_bool(), - &issuer_did, - )?; - - let (tails_location, tails_hash) = store_tails_from_generator( - self.blob_storage_service.clone(), - tails_writer_handle, - &mut revoc_tails_generator, - ) - .await?; - - let revoc_reg_def_value = RevocationRegistryDefinitionValue { - max_cred_num, - issuance_type, - public_keys: revoc_public_keys, - tails_location, - tails_hash, - }; - - let revoc_reg_def = RevocationRegistryDefinition::RevocationRegistryDefinitionV1( - RevocationRegistryDefinitionV1 { - id: rev_reg_id.clone(), - revoc_def_type: rev_reg_type, - tag: tag.to_string(), - cred_def_id: cred_def_id.clone(), - value: revoc_reg_def_value, - }, - ); - - let revoc_reg = RevocationRegistry::RevocationRegistryV1(RevocationRegistryV1 { - value: revoc_registry, - }); - - let revoc_reg_def_priv = RevocationRegistryDefinitionPrivate { - value: revoc_key_private, - }; - - let revoc_reg_def_json = self - .wallet_service - .add_indy_object( - wallet_handle, - &rev_reg_id.0, - &revoc_reg_def, - &HashMap::new(), - ) - .await?; - - let revoc_reg_json = self - .wallet_service - .add_indy_object(wallet_handle, &rev_reg_id.0, &revoc_reg, &HashMap::new()) - .await?; - - self.wallet_service - .add_indy_object( - wallet_handle, - &rev_reg_id.0, - &revoc_reg_def_priv, - &HashMap::new(), - ) - .await?; - - let rev_reg_info = RevocationRegistryInfo { - id: rev_reg_id.clone(), - curr_id: 0, - used_ids: HashSet::new(), - }; - - self.wallet_service - .add_indy_object(wallet_handle, &rev_reg_id.0, &rev_reg_info, &HashMap::new()) - .await?; - - let res = Ok((rev_reg_id.0, revoc_reg_def_json, revoc_reg_json)); - trace!("create_and_store_revocation_registry < {:?}", res); - res - } - - /// Create credential offer that will be used by Prover for - /// credential request creation. Offer includes nonce and key correctness proof - /// for authentication between protocol steps and integrity checking. - /// - /// #Params - - /// wallet_handle: wallet handle (created by open_wallet) - /// cred_def_id: id of credential definition stored in the wallet - /// - /// #Returns - /// credential offer json: - /// { - /// "schema_id": string, - identifier of schema - /// "cred_def_id": string, - identifier of credential definition - /// // Fields below can depend on Credential Definition type - /// "nonce": string, - /// "key_correctness_proof" : key correctness proof for credential definition - /// correspondent to cred_def_id (opaque type that - /// contains data structures internal to Ursa. It should - /// not be parsed and are likely to change in future versions). } - /// - /// #Errors - /// Common* - /// Wallet* - /// Anoncreds* - pub async fn create_credential_offer( - &self, - wallet_handle: WalletHandle, - cred_def_id: CredentialDefinitionId, - ) -> IndyResult { - trace!( - "create_credential_offer > wallet_handle {:?} cred_def_id {:?}", - wallet_handle, - cred_def_id - ); - - let cred_def_correctness_proof: CredentialDefinitionCorrectnessProof = self - .wallet_service - .get_indy_object(wallet_handle, &cred_def_id.0, &RecordOptions::id_value()) - .await?; - - let nonce = new_nonce()?; - - let schema_id = self - ._wallet_get_schema_id(wallet_handle, &cred_def_id.0) - .await?; // TODO: FIXME get CredDef from wallet and use CredDef.schema_id - - let credential_offer = CredentialOffer { - schema_id, - cred_def_id: cred_def_id.clone(), - key_correctness_proof: cred_def_correctness_proof.value, - nonce, - method_name: None, - }; - - let credential_offer_json = serde_json::to_string(&credential_offer).to_indy( - IndyErrorKind::InvalidState, - "Cannot serialize CredentialOffer", - )?; - - let res = Ok(credential_offer_json); - trace!("create_credential_offer < {:?}", res); - res - } - - /// Check Cred Request for the given Cred Offer and issue Credential for the given Cred Request. - /// - /// Cred Request must match Cred Offer. The credential definition and revocation registry - /// definition referenced in Cred Offer and Cred Request must be already created and stored - /// into the wallet. - /// - /// Information for this credential revocation will be store in the wallet as part of revocation - /// registry under generated cred_revoc_id local for this wallet. - /// - /// This call returns revoc registry delta as json file intended to be shared as REVOC_REG_ENTRY - /// transaction. Note that it is possible to accumulate deltas to reduce ledger load. - /// - /// #Params - - /// wallet_handle: wallet handle (created by open_wallet). - /// cred_offer_json: a cred offer created by indy_issuer_create_credential_offer - /// cred_req_json: a credential request created by indy_prover_create_credential_req - /// cred_values_json: a credential containing attribute values for each of requested attribute - /// names. Example: - /// { - /// "attr1" : {"raw": "value1", "encoded": "value1_as_int" }, - /// "attr2" : {"raw": "value1", "encoded": "value1_as_int" } - /// } - /// If you want to use empty value for some credential field, you should set "raw" to "" and - /// "encoded" should not be empty rev_reg_id: id of revocation registry stored in the wallet - /// blob_storage_reader_handle: configuration of blob storage reader handle that will allow to - /// read revocation tails (returned by `indy_open_blob_storage_reader`) - /// - /// #Returns - /// cred_json: Credential json containing signed credential values - /// { - /// "schema_id": string, - identifier of schema - /// "cred_def_id": string, - identifier of credential definition - /// "rev_reg_def_id", Optional, - identifier of revocation registry - /// "values": , - credential values. - /// // Fields below can depend on Cred Def type - /// "signature": , - /// (opaque type that contains data structures internal to Ursa. - /// It should not be parsed and are likely to change in future versions). - /// "signature_correctness_proof": credential signature correctness proof - /// (opaque type that contains data structures internal to Ursa. - /// It should not be parsed and are likely to change in future versions). - /// "rev_reg" - (Optional) revocation registry accumulator value on the issuing moment. - /// (opaque type that contains data structures internal to Ursa. - /// It should not be parsed and are likely to change in future versions). - /// "witness" - (Optional) revocation related data - /// (opaque type that contains data structures internal to Ursa. - /// It should not be parsed and are likely to change in future versions). - /// } - /// cred_revoc_id: local id for revocation info (Can be used for revocation of this credential) - /// revoc_reg_delta_json: Revocation registry delta json with a newly issued credential - /// - /// #Errors - /// Anoncreds* - /// Common* - /// Wallet* - pub async fn new_credential( - &self, - wallet_handle: WalletHandle, - cred_offer: CredentialOffer, - cred_request: CredentialRequest, - cred_values: CredentialValues, - rev_reg_id: Option, - blob_storage_reader_handle: Option, - ) -> IndyResult<(String, Option, Option)> { - trace!( - "new_credential > wallet_handle {:?} cred_offer {:?} cred_request {:?} cred_values \ - {:?} rev_reg_id {:?} blob_storage_reader_handle {:?}", - wallet_handle, - secret!(&cred_offer), - secret!(&cred_request), - secret!(&cred_values), - rev_reg_id, - blob_storage_reader_handle - ); - - let cred_def_id = match cred_offer.method_name { - Some(ref method_name) => cred_offer.cred_def_id.qualify(method_name)?, - None => cred_offer.cred_def_id.clone(), - }; - - let cred_def: CredentialDefinitionV1 = CredentialDefinitionV1::from( - self.wallet_service - .get_indy_object::( - wallet_handle, - &cred_def_id.0, - &RecordOptions::id_value(), - ) - .await?, - ); - - let cred_def_priv_key: CredentialDefinitionPrivateKey = self - .wallet_service - .get_indy_object(wallet_handle, &cred_def_id.0, &RecordOptions::id_value()) - .await?; - - let (rev_reg_def, mut rev_reg, rev_reg_def_priv, sdk_tails_accessor, rev_reg_info) = - match rev_reg_id { - Some(ref r_reg_id) => { - let rev_reg_def: RevocationRegistryDefinitionV1 = - RevocationRegistryDefinitionV1::from( - self._wallet_get_rev_reg_def(wallet_handle, &r_reg_id) - .await?, - ); - - let rev_reg: RevocationRegistryV1 = RevocationRegistryV1::from( - self._wallet_get_rev_reg(wallet_handle, &r_reg_id).await?, - ); - - let rev_key_priv: RevocationRegistryDefinitionPrivate = self - .wallet_service - .get_indy_object(wallet_handle, &r_reg_id.0, &RecordOptions::id_value()) - .await?; - - let mut rev_reg_info = self - ._wallet_get_rev_reg_info(wallet_handle, &r_reg_id) - .await?; - - rev_reg_info.curr_id += 1; - - if rev_reg_info.curr_id > rev_reg_def.value.max_cred_num { - return Err(err_msg( - IndyErrorKind::RevocationRegistryFull, - "RevocationRegistryAccumulator is full", - )); - } - - if rev_reg_def.value.issuance_type == IssuanceType::ISSUANCE_ON_DEMAND { - rev_reg_info.used_ids.insert(rev_reg_info.curr_id); - } - - // TODO: FIXME: Review error kind! - let blob_storage_reader_handle = - blob_storage_reader_handle.ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidStructure, - "TailsReaderHandle not found", - ) - })?; - - let sdk_tails_accessor = SDKTailsAccessor::new( - self.blob_storage_service.clone(), - blob_storage_reader_handle, - &rev_reg_def, - ) - .await?; - - ( - Some(rev_reg_def), - Some(rev_reg), - Some(rev_key_priv), - Some(sdk_tails_accessor), - Some(rev_reg_info), - ) - } - None => (None, None, None, None, None), - }; - - let (credential_signature, signature_correctness_proof, rev_reg_delta) = - self.issuer_service.new_credential( - &cred_def, - &cred_def_priv_key.value, - &cred_offer.nonce, - &cred_request, - &cred_values, - rev_reg_info.as_ref().map(|r_reg_info| r_reg_info.curr_id), - rev_reg_def.as_ref(), - rev_reg.as_mut().map(|r_reg| &mut r_reg.value), - rev_reg_def_priv - .as_ref() - .map(|r_reg_def_priv| &r_reg_def_priv.value), - sdk_tails_accessor.as_ref(), - )?; - - let witness = if let ( - &Some(ref r_reg_def), - &Some(ref r_reg), - &Some(ref rev_tails_accessor), - &Some(ref rev_reg_info), - ) = (&rev_reg_def, &rev_reg, &sdk_tails_accessor, &rev_reg_info) - { - let (issued, revoked) = match r_reg_def.value.issuance_type { - IssuanceType::ISSUANCE_ON_DEMAND => (rev_reg_info.used_ids.clone(), HashSet::new()), - IssuanceType::ISSUANCE_BY_DEFAULT => { - (HashSet::new(), rev_reg_info.used_ids.clone()) - } - }; - - let rev_reg_delta = - CryptoRevocationRegistryDelta::from_parts(None, &r_reg.value, &issued, &revoked); - - Some(Witness::new( - rev_reg_info.curr_id, - r_reg_def.value.max_cred_num, - r_reg_def.value.issuance_type.to_bool(), - &rev_reg_delta, - rev_tails_accessor, - )?) - } else { - None - }; - - let cred_rev_reg_id = match (rev_reg_id.as_ref(), cred_offer.method_name.as_ref()) { - (Some(rev_reg_id), Some(ref _method_name)) => Some(rev_reg_id.to_unqualified()), - (rev_reg_id, _) => rev_reg_id.cloned(), - }; - - let credential = Credential { - schema_id: cred_offer.schema_id.clone(), - cred_def_id: cred_offer.cred_def_id.clone(), - rev_reg_id: cred_rev_reg_id, - values: cred_values.clone(), - signature: credential_signature, - signature_correctness_proof, - rev_reg: rev_reg.map(|r_reg| r_reg.value), - witness, - }; - - let cred_json = serde_json::to_string(&credential) - .to_indy(IndyErrorKind::InvalidState, "Cannot serialize Credential")?; - - let rev_reg_delta_json = rev_reg_delta - .map(|r_reg_delta| { - RevocationRegistryDelta::RevocationRegistryDeltaV1(RevocationRegistryDeltaV1 { - value: r_reg_delta, - }) - }) - .as_ref() - .map(serde_json::to_string) - .map_or(Ok(None), |v| v.map(Some)) - .to_indy( - IndyErrorKind::InvalidState, - "Cannot serialize RevocationRegistryDelta", - )?; - - if let (Some(r_reg), Some(r_reg_id), Some(r_reg_info)) = - (credential.rev_reg, rev_reg_id, rev_reg_info.clone()) - { - let revoc_reg = - RevocationRegistry::RevocationRegistryV1(RevocationRegistryV1 { value: r_reg }); - - self.wallet_service - .update_indy_object(wallet_handle, &r_reg_id.0, &revoc_reg) - .await?; - self.wallet_service - .update_indy_object(wallet_handle, &r_reg_id.0, &r_reg_info) - .await?; - }; - - let cred_rev_id = rev_reg_info.map(|r_reg_info| r_reg_info.curr_id.to_string()); - - let res = Ok((cred_json, cred_rev_id, rev_reg_delta_json)); - trace!("new_credential < {:?}", secret!(&res)); - res - } - - /// Revoke a credential identified by a cred_revoc_id (returned by - /// indy_issuer_create_credential). - /// - /// The corresponding credential definition and revocation registry must be already - /// created an stored into the wallet. - /// - /// This call returns revoc registry delta as json file intended to be shared as REVOC_REG_ENTRY - /// transaction. Note that it is possible to accumulate deltas to reduce ledger load. - /// - /// #Params - - /// wallet_handle: wallet handle (created by open_wallet). - /// blob_storage_reader_cfg_handle: configuration of blob storage reader handle that will allow - /// to read revocation tails (returned by `indy_open_blob_storage_reader`). rev_reg_id: id - /// of revocation registry stored in wallet cred_revoc_id: local id for revocation info - /// related to issued credential - /// - /// #Returns - /// revoc_reg_delta_json: Revocation registry delta json with a revoked credential - /// { - /// value: { - /// prevAccum: string - previous accumulator value. - /// accum: string - current accumulator value. - /// revoked: array an array of revoked indices. - /// }, - /// ver: string - version revocation registry delta json - /// } - /// - /// #Errors - /// Anoncreds* - /// Common* - /// Wallet* - pub async fn revoke_credential( - &self, - wallet_handle: WalletHandle, - blob_storage_reader_handle: i32, - rev_reg_id: RevocationRegistryId, - cred_revoc_id: String, - ) -> IndyResult { - trace!( - "revoke_credential > wallet_handle {:?} blob_storage_reader_handle {:?} rev_reg_id \ - {:?} cred_revoc_id {:?}", - wallet_handle, - blob_storage_reader_handle, - rev_reg_id, - secret!(&cred_revoc_id) - ); - - let cred_revoc_id = AnoncredsHelpers::parse_cred_rev_id(&cred_revoc_id)?; - - let revocation_registry_definition: RevocationRegistryDefinitionV1 = - RevocationRegistryDefinitionV1::from( - self._wallet_get_rev_reg_def(wallet_handle, &rev_reg_id) - .await?, - ); - - let mut rev_reg: RevocationRegistryV1 = - RevocationRegistryV1::from(self._wallet_get_rev_reg(wallet_handle, &rev_reg_id).await?); - - let sdk_tails_accessor = SDKTailsAccessor::new( - self.blob_storage_service.clone(), - blob_storage_reader_handle, - &revocation_registry_definition, - ) - .await?; - - if cred_revoc_id > revocation_registry_definition.value.max_cred_num + 1 { - return Err(err_msg( - IndyErrorKind::InvalidUserRevocId, - format!( - "Revocation id: {:?} not found in RevocationRegistry", - cred_revoc_id - ), - )); - } - - let mut rev_reg_info = self - ._wallet_get_rev_reg_info(wallet_handle, &rev_reg_id) - .await?; - - match revocation_registry_definition.value.issuance_type { - IssuanceType::ISSUANCE_ON_DEMAND => { - if !rev_reg_info.used_ids.remove(&cred_revoc_id) { - return Err(err_msg( - IndyErrorKind::InvalidUserRevocId, - format!( - "Revocation id: {:?} not found in RevocationRegistry", - cred_revoc_id - ), - )); - }; - } - IssuanceType::ISSUANCE_BY_DEFAULT => { - if !rev_reg_info.used_ids.insert(cred_revoc_id) { - return Err(err_msg( - IndyErrorKind::InvalidUserRevocId, - format!( - "Revocation id: {:?} not found in RevocationRegistry", - cred_revoc_id - ), - )); - } - } - }; - - let rev_reg_delta = self.issuer_service.revoke( - &mut rev_reg.value, - revocation_registry_definition.value.max_cred_num, - cred_revoc_id, - &sdk_tails_accessor, - )?; - - let rev_reg_delta = - RevocationRegistryDelta::RevocationRegistryDeltaV1(RevocationRegistryDeltaV1 { - value: rev_reg_delta, - }); - - let rev_reg_delta_json = serde_json::to_string(&rev_reg_delta).to_indy( - IndyErrorKind::InvalidState, - "Cannot serialize RevocationRegistryDelta", - )?; - - let rev_reg = RevocationRegistry::RevocationRegistryV1(rev_reg); - - self.wallet_service - .update_indy_object(wallet_handle, &rev_reg_id.0, &rev_reg) - .await?; - - self.wallet_service - .update_indy_object(wallet_handle, &rev_reg_id.0, &rev_reg_info) - .await?; - - let res = Ok(rev_reg_delta_json); - trace!("revoke_credential < {:?}", res); - res - } - - async fn _recovery_credential( - &self, - wallet_handle: WalletHandle, - blob_storage_reader_handle: i32, - rev_reg_id: &RevocationRegistryId, - cred_revoc_id: &str, - ) -> IndyResult { - trace!( - "recovery_credential >>> wallet_handle: {:?}, blob_storage_reader_handle: {:?}, \ - rev_reg_id: {:?}, cred_revoc_id: {:?}", - wallet_handle, - blob_storage_reader_handle, - rev_reg_id, - secret!(cred_revoc_id) - ); - - let cred_revoc_id = AnoncredsHelpers::parse_cred_rev_id(cred_revoc_id)?; - - let revocation_registry_definition: RevocationRegistryDefinitionV1 = - RevocationRegistryDefinitionV1::from( - self._wallet_get_rev_reg_def(wallet_handle, &rev_reg_id) - .await?, - ); - - let mut rev_reg: RevocationRegistryV1 = - RevocationRegistryV1::from(self._wallet_get_rev_reg(wallet_handle, &rev_reg_id).await?); - - let sdk_tails_accessor = SDKTailsAccessor::new( - self.blob_storage_service.clone(), - blob_storage_reader_handle, - &revocation_registry_definition, - ) - .await?; - - if cred_revoc_id > revocation_registry_definition.value.max_cred_num + 1 { - return Err(err_msg( - IndyErrorKind::InvalidUserRevocId, - format!( - "Revocation id: {:?} not found in RevocationRegistry", - cred_revoc_id - ), - )); - } - - let mut rev_reg_info = self - ._wallet_get_rev_reg_info(wallet_handle, &rev_reg_id) - .await?; - - match revocation_registry_definition.value.issuance_type { - IssuanceType::ISSUANCE_ON_DEMAND => { - if !rev_reg_info.used_ids.insert(cred_revoc_id) { - return Err(err_msg( - IndyErrorKind::InvalidUserRevocId, - format!( - "Revocation id: {:?} not found in RevocationRegistry", - cred_revoc_id - ), - )); - } - } - IssuanceType::ISSUANCE_BY_DEFAULT => { - if !rev_reg_info.used_ids.remove(&cred_revoc_id) { - return Err(err_msg( - IndyErrorKind::InvalidUserRevocId, - format!( - "Revocation id: {:?} not found in RevocationRegistry", - cred_revoc_id - ), - )); - } - } - }; - - let revocation_registry_delta = self.issuer_service.recovery( - &mut rev_reg.value, - revocation_registry_definition.value.max_cred_num, - cred_revoc_id, - &sdk_tails_accessor, - )?; - - let rev_reg_delta = - RevocationRegistryDelta::RevocationRegistryDeltaV1(RevocationRegistryDeltaV1 { - value: revocation_registry_delta, - }); - - let rev_reg_delta_json = serde_json::to_string(&rev_reg_delta).to_indy( - IndyErrorKind::InvalidState, - "Cannot serialize RevocationRegistryDelta: {:?}", - )?; - - let rev_reg = RevocationRegistry::RevocationRegistryV1(rev_reg); - - self.wallet_service - .update_indy_object(wallet_handle, &rev_reg_id.0, &rev_reg) - .await?; - - self.wallet_service - .update_indy_object(wallet_handle, &rev_reg_id.0, &rev_reg_info) - .await?; - - let res = Ok(rev_reg_delta_json); - trace!("recovery_credential < {:?}", res); - res - } - - /// Merge two revocation registry deltas (returned by indy_issuer_create_credential or - /// indy_issuer_revoke_credential) to accumulate common delta. Send common delta to ledger - /// to reduce the load. - /// - /// #Params - - /// rev_reg_delta_json: revocation registry delta. - /// { - /// value: { - /// prevAccum: string - previous accumulator value. - /// accum: string - current accumulator value. - /// issued: array an array of issued indices. - /// revoked: array an array of revoked indices. - /// }, - /// ver: string - version revocation registry delta json - /// } - /// - /// other_rev_reg_delta_json: revocation registry delta for which PrevAccum value is equal to - /// value of accum field of rev_reg_delta_json parameter. - /// - /// #Returns - /// merged_rev_reg_delta: Merged revocation registry delta - /// { - /// value: { - /// prevAccum: string - previous accumulator value. - /// accum: string - current accumulator value. - /// issued: array an array of issued indices. - /// revoked: array an array of revoked indices. - /// }, - /// ver: string - version revocation registry delta json - /// } - /// - /// #Errors - /// Anoncreds* - /// Common* - /// Wallet* - pub fn merge_revocation_registry_deltas( - &self, - rev_reg_delta: RevocationRegistryDelta, - other_rev_reg_delta: RevocationRegistryDelta, - ) -> IndyResult { - trace!( - "merge_revocation_registry_deltas > rev_reg_delta {:?} other_rev_reg_delta {:?}", - rev_reg_delta, - other_rev_reg_delta - ); - - let mut rev_reg_delta = RevocationRegistryDeltaV1::from(rev_reg_delta); - let other_rev_reg_delta = RevocationRegistryDeltaV1::from(other_rev_reg_delta); - - rev_reg_delta.value.merge(&other_rev_reg_delta.value)?; - - let rev_reg_delta = - RevocationRegistryDelta::RevocationRegistryDeltaV1(rev_reg_delta.clone()); - - let merged_rev_reg_delta_json = serde_json::to_string(&rev_reg_delta).to_indy( - IndyErrorKind::InvalidState, - "Cannot serialize RevocationRegistryDelta", - )?; - - let res = Ok(merged_rev_reg_delta_json); - trace!("merge_revocation_registry_deltas < {:?}", res); - res - } - - // TODO: DELETE IT - async fn _wallet_set_schema_id( - &self, - wallet_handle: WalletHandle, - id: &str, - schema_id: &SchemaId, - ) -> IndyResult<()> { - self.wallet_service - .add_record( - wallet_handle, - &self.wallet_service.add_prefix("SchemaId"), - id, - &schema_id.0, - &Tags::new(), - ) - .await - } - - // TODO: DELETE IT - async fn _wallet_get_schema_id( - &self, - wallet_handle: WalletHandle, - key: &str, - ) -> IndyResult { - let schema_id_record = self - .wallet_service - .get_record( - wallet_handle, - &self.wallet_service.add_prefix("SchemaId"), - &key, - &RecordOptions::id_value(), - ) - .await?; - - schema_id_record - .get_value() - .map(|id| SchemaId(id.to_string())) - .ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidStructure, - format!("SchemaId not found for id: {}", key), - ) - }) - } - - async fn _wallet_get_rev_reg_def( - &self, - wallet_handle: WalletHandle, - key: &RevocationRegistryId, - ) -> IndyResult { - self.wallet_service - .get_indy_object(wallet_handle, &key.0, &RecordOptions::id_value()) - .await - } - - async fn _wallet_get_rev_reg( - &self, - wallet_handle: WalletHandle, - key: &RevocationRegistryId, - ) -> IndyResult { - self.wallet_service - .get_indy_object(wallet_handle, &key.0, &RecordOptions::id_value()) - .await - } - - async fn _wallet_get_rev_reg_info( - &self, - wallet_handle: WalletHandle, - key: &RevocationRegistryId, - ) -> IndyResult { - self.wallet_service - .get_indy_object(wallet_handle, &key.0, &RecordOptions::id_value()) - .await - } -} diff --git a/libvdrtools/src/controllers/anoncreds/mod.rs b/libvdrtools/src/controllers/anoncreds/mod.rs deleted file mode 100644 index a7d2e092b2..0000000000 --- a/libvdrtools/src/controllers/anoncreds/mod.rs +++ /dev/null @@ -1,8 +0,0 @@ -mod issuer; -mod prover; -mod tails; -mod verifier; - -pub use issuer::{CredentialDefinitionId, IssuerController}; -pub use prover::ProverController; -pub use verifier::VerifierController; diff --git a/libvdrtools/src/controllers/anoncreds/prover.rs b/libvdrtools/src/controllers/anoncreds/prover.rs deleted file mode 100644 index 273fd394f2..0000000000 --- a/libvdrtools/src/controllers/anoncreds/prover.rs +++ /dev/null @@ -1,1894 +0,0 @@ -use std::{ - collections::{HashMap, HashSet}, - ops::DerefMut, - sync::Arc, -}; - -use futures::lock::Mutex; -use indy_api_types::{errors::prelude::*, SearchHandle, WalletHandle}; -use indy_utils::next_search_handle; -use indy_wallet::{RecordOptions, SearchOptions, WalletRecord, WalletSearch, WalletService}; -use log::trace; -use serde_json::Value; -use ursa::cl::{new_nonce, RevocationRegistry, Witness}; - -use super::tails::SDKTailsAccessor; -use crate::{ - domain::{ - anoncreds::{ - credential::{Credential, CredentialInfo}, - credential_attr_tag_policy::CredentialAttrTagPolicy, - credential_definition::{ - cred_defs_map_to_cred_defs_v1_map, CredentialDefinition, CredentialDefinitionId, - CredentialDefinitionV1, CredentialDefinitions, - }, - credential_for_proof_request::{CredentialsForProofRequest, RequestedCredential}, - credential_offer::CredentialOffer, - credential_request::{CredentialRequest, CredentialRequestMetadata}, - master_secret::MasterSecret, - proof_request::{ - NonRevocedInterval, PredicateInfo, ProofRequest, ProofRequestExtraQuery, - }, - requested_credential::RequestedCredentials, - revocation_registry_definition::{ - RevocationRegistryDefinition, RevocationRegistryDefinitionV1, - }, - revocation_registry_delta::{RevocationRegistryDelta, RevocationRegistryDeltaV1}, - revocation_state::{RevocationState, RevocationStates}, - schema::{schemas_map_to_schemas_v1_map, Schemas}, - }, - crypto::did::DidValue, - }, - services::{AnoncredsHelpers, BlobStorageService, CryptoService, ProverService}, - utils::wql::Query, -}; - -struct SearchForProofRequest { - search: WalletSearch, - interval: Option, - predicate_info: Option, -} - -impl SearchForProofRequest { - fn new( - search: WalletSearch, - interval: Option, - predicate_info: Option, - ) -> Self { - Self { - search, - interval, - predicate_info, - } - } -} - -pub struct ProverController { - prover_service: Arc, - wallet_service: Arc, - crypto_service: Arc, - blob_storage_service: Arc, - searches: Mutex>>, - searches_for_proof_requests: - Mutex>>>>, -} - -impl ProverController { - pub(crate) fn new( - prover_service: Arc, - wallet_service: Arc, - crypto_service: Arc, - blob_storage_service: Arc, - ) -> ProverController { - ProverController { - prover_service, - wallet_service, - crypto_service, - blob_storage_service, - searches: Mutex::new(HashMap::new()), - searches_for_proof_requests: Mutex::new(HashMap::new()), - } - } - - /// Creates a master secret with a given id and stores it in the wallet. - /// The id must be unique. - /// - /// #Params - - /// wallet_handle: wallet handle (created by open_wallet). - /// master_secret_id: (optional, if not present random one will be generated) new master id - /// - /// #Returns - /// out_master_secret_id: Id of generated master secret - /// - /// #Errors - /// Anoncreds* - /// Common* - /// Wallet* - pub async fn create_master_secret( - &self, - wallet_handle: WalletHandle, - master_secret_id: Option, - ) -> IndyResult { - trace!( - "create_master_secret > wallet_handle {:?} master_secret_id {:?}", - wallet_handle, - master_secret_id - ); - - let master_secret_id = master_secret_id.unwrap_or_else(|| uuid::Uuid::new_v4().to_string()); - - if self - .wallet_service - .record_exists::(wallet_handle, &master_secret_id) - .await? - { - return Err(err_msg( - IndyErrorKind::MasterSecretDuplicateName, - format!("MasterSecret already exists {}", master_secret_id), - )); - } - - let master_secret = self.prover_service.new_master_secret()?; - - let master_secret = MasterSecret { - value: master_secret, - }; - - self.wallet_service - .add_indy_object( - wallet_handle, - &master_secret_id, - &master_secret, - &HashMap::new(), - ) - .await?; - - let res = Ok(master_secret_id); - trace!("create_master_secret < {:?}", res); - res - } - - /// Creates a credential request for the given credential offer. - /// - /// The method creates a blinded master secret for a master secret identified by a provided - /// name. The master secret identified by the name must be already stored in the secure - /// wallet (see prover_create_master_secret) The blinded master secret is a part of the - /// credential request. - /// - /// #Params - - /// wallet_handle: wallet handle (created by open_wallet) - /// prover_did: a DID of the prover - /// cred_offer_json: credential offer as a json containing information about the issuer and a - /// credential { - /// "schema_id": string, - identifier of schema - /// "cred_def_id": string, - identifier of credential definition - /// ... - /// Other fields that contains data structures internal to Ursa. - /// These fields should not be parsed and are likely to change in future versions. - /// } - /// cred_def_json: credential definition json related to in - /// master_secret_id: the id of the master secret stored in the wallet - /// - /// #Returns - /// cred_req_json: Credential request json for creation of credential by Issuer - /// { - /// "prover_did" : string, - /// "cred_def_id" : string, - /// // Fields below can depend on Cred Def type - /// "blinded_ms" : , - /// (opaque type that contains data structures internal to Ursa. - /// It should not be parsed and are likely to change in future versions). - /// "blinded_ms_correctness_proof" : , - /// (opaque type that contains data structures internal to Ursa. - /// It should not be parsed and are likely to change in future versions). - /// "nonce": string - /// } - /// cred_req_metadata_json: Credential request metadata json for further processing of received - /// form Issuer credential. Credential request metadata contains data structures - /// internal to Ursa. Credential request metadata mustn't be shared with Issuer. - /// - /// #Errors - /// Anoncreds* - /// Common* - /// Wallet* - pub async fn create_credential_request( - &self, - wallet_handle: WalletHandle, - prover_did: DidValue, - cred_offer: CredentialOffer, - cred_def: CredentialDefinition, - master_secret_id: String, - ) -> IndyResult<(String, String)> { - trace!( - "create_credential_request > wallet_handle {:?} prover_did {:?} cred_offer {:?} \ - cred_def {:?} master_secret_id: {:?}", - wallet_handle, - prover_did, - cred_offer, - cred_def, - master_secret_id - ); - - let cred_def = CredentialDefinitionV1::from(cred_def); - - self.crypto_service.validate_did(&prover_did)?; - - let master_secret: MasterSecret = self - ._wallet_get_master_secret(wallet_handle, &master_secret_id) - .await?; - - let (blinded_ms, ms_blinding_data, blinded_ms_correctness_proof) = self - .prover_service - .new_credential_request(&cred_def, &master_secret.value, &cred_offer)?; - - let nonce = new_nonce()?; - - let credential_request = CredentialRequest { - prover_did, - cred_def_id: cred_offer.cred_def_id.clone(), - blinded_ms, - blinded_ms_correctness_proof, - nonce, - }; - - let credential_request_metadata = CredentialRequestMetadata { - master_secret_blinding_data: ms_blinding_data, - nonce: credential_request.nonce.try_clone()?, - master_secret_name: master_secret_id.to_string(), - }; - - let cred_req_json = serde_json::to_string(&credential_request).to_indy( - IndyErrorKind::InvalidState, - "Cannot serialize CredentialRequest", - )?; - - let cred_req_metadata_json = serde_json::to_string(&credential_request_metadata).to_indy( - IndyErrorKind::InvalidState, - "Cannot serialize CredentialRequestMetadata", - )?; - - let res = Ok((cred_req_json, cred_req_metadata_json)); - trace!("create_credential_request < {:?}", res); - res - } - - /// Set credential attribute tagging policy. - /// Writes a non-secret record marking attributes to tag, and optionally - /// updates tags on existing credentials on the credential definition to match. - /// - /// EXPERIMENTAL - /// - /// The following tags are always present on write: - /// { - /// "schema_id": , - /// "schema_issuer_did": , - /// "schema_name": , - /// "schema_version": , - /// "issuer_did": , - /// "cred_def_id": , - /// "rev_reg_id": , // "None" as string if not - /// present } - /// - /// The policy sets the following tags for each attribute it marks taggable, written to - /// subsequent credentials and (optionally) all existing credentials on the credential - /// definition: { - /// "attr::::marker": "1", - /// "attr::::value": , - /// } - /// - /// #Params - - /// wallet_handle: wallet handle (created by open_wallet). - /// cred_def_id: credential definition id - /// tag_attrs_json: JSON array with names of attributes to tag by policy, or null for all - /// retroactive: boolean, whether to apply policy to existing credentials on credential - /// definition identifier - /// - /// #Errors - /// Anoncreds* - /// Common* - /// Wallet* - pub async fn set_credential_attr_tag_policy( - &self, - wallet_handle: WalletHandle, - cred_def_id: CredentialDefinitionId, - catpol: Option, - retroactive: bool, - ) -> IndyResult<()> { - trace!( - "set_credential_attr_tag_policy > wallet_handle {:?} cred_def_id {:?} catpol {:?} \ - retroactive {:?}", - wallet_handle, - cred_def_id, - catpol, - retroactive - ); - - match catpol { - Some(ref pol) => { - self.wallet_service - .upsert_indy_object(wallet_handle, &cred_def_id.0, pol) - .await?; - } - None => { - if self - .wallet_service - .record_exists::(wallet_handle, &cred_def_id.0) - .await? - { - self.wallet_service - .delete_indy_record::( - wallet_handle, - &cred_def_id.0, - ) - .await?; - } - } - }; - - // Cascade whether we updated policy or not: could be a retroactive cred attr tags reset to - // existing policy - if retroactive { - let query_json = format!(r#"{{"cred_def_id": "{}"}}"#, cred_def_id.0); - - let mut credentials_search = self - .wallet_service - .search_indy_records::( - wallet_handle, - query_json.as_str(), - &SearchOptions::id_value(), - ) - .await?; - - while let Some(credential_record) = credentials_search.fetch_next_record().await? { - let (_, credential) = self._get_credential(&credential_record)?; - - let cred_tags = self - .prover_service - .build_credential_tags(&credential, catpol.as_ref())?; - - self.wallet_service - .update_record_tags( - wallet_handle, - self.wallet_service.add_prefix("Credential").as_str(), - credential_record.get_id(), - &cred_tags, - ) - .await?; - } - } - - let res = Ok(()); - trace!("set_credential_attr_tag_policy < {:?}", res); - res - } - - /// Get credential attribute tagging policy by credential definition id. - /// - /// EXPERIMENTAL - /// - /// #Params - - /// wallet_handle: wallet handle (created by open_wallet). - /// cred_def_id: credential definition id - /// - /// #Returns - /// JSON array with all attributes that current policy marks taggable; - /// null for default policy (tag all credential attributes). - /// - /// #Errors - /// Anoncreds* - /// Common* - /// Wallet* - pub async fn get_credential_attr_tag_policy( - &self, - wallet_handle: WalletHandle, - cred_def_id: CredentialDefinitionId, - ) -> IndyResult { - trace!( - "get_credential_attr_tag_policy > wallet_handle {:?} cred_def_id {:?}", - wallet_handle, - cred_def_id - ); - - let catpol = self - ._get_credential_attr_tag_policy(wallet_handle, &cred_def_id) - .await?; - - let res = Ok(catpol); - trace!("get_credential_attr_tag_policy < {:?}", res); - res - } - - /// Check credential provided by Issuer for the given credential request, - /// updates the credential by a master secret and stores in a secure wallet. - /// - /// To support efficient and flexible search the following tags will be created for stored - /// credential: { - /// "schema_id": , - /// "schema_issuer_did": , - /// "schema_name": , - /// "schema_version": , - /// "issuer_did": , - /// "cred_def_id": , - /// "rev_reg_id": , // "None" as string if not - /// present // for every attribute in that credential attribute - /// tagging policy marks taggable "attr::::marker": "1", - /// "attr::::value": , - /// } - /// - /// #Params - - /// wallet_handle: wallet handle (created by open_wallet). - /// cred_id: (optional, default is a random one) identifier by which credential will be stored - /// in the wallet cred_req_metadata_json: a credential request metadata created by - /// indy_prover_create_credential_req cred_json: credential json received from issuer - /// { - /// "schema_id": string, - identifier of schema - /// "cred_def_id": string, - identifier of credential definition - /// "rev_reg_def_id", Optional, - identifier of revocation registry - /// "values": - credential values - /// { - /// "attr1" : {"raw": "value1", "encoded": "value1_as_int" }, - /// "attr2" : {"raw": "value1", "encoded": "value1_as_int" } - /// } - /// // Fields below can depend on Cred Def type - /// Other fields that contains data structures internal to Ursa. - /// These fields should not be parsed and are likely to change in future versions. - /// } - /// cred_def_json: credential definition json related to in - /// rev_reg_def_json: revocation registry definition json related to in - /// - /// - /// #Returns - /// out_cred_id: identifier by which credential is stored in the wallet - /// - /// #Errors - /// Anoncreds* - /// Common* - /// Wallet* - pub async fn store_credential( - &self, - wallet_handle: WalletHandle, - cred_id: Option, - cred_req_metadata: CredentialRequestMetadata, - mut credential: Credential, - cred_def: CredentialDefinition, - rev_reg_def: Option, - ) -> IndyResult { - trace!( - "store_credential > wallet_handle {:?} cred_id {:?} cred_req_metadata {:?} credential \ - {:?} cred_def {:?} rev_reg_def {:?}", - wallet_handle, - cred_id, - cred_req_metadata, - credential, - cred_def, - rev_reg_def - ); - - let cred_def = CredentialDefinitionV1::from(cred_def); - let rev_reg_def = rev_reg_def.map(RevocationRegistryDefinitionV1::from); - - let master_secret: MasterSecret = self - ._wallet_get_master_secret(wallet_handle, &cred_req_metadata.master_secret_name) - .await?; - - self.prover_service.process_credential( - &mut credential, - &cred_req_metadata, - &master_secret.value, - &cred_def, - rev_reg_def.as_ref(), - )?; - - credential.rev_reg = None; - credential.witness = None; - - let out_cred_id = cred_id.unwrap_or_else(|| uuid::Uuid::new_v4().to_string()); - - let catpol_json = self - ._get_credential_attr_tag_policy(wallet_handle, &credential.cred_def_id) - .await?; - - let catpol: Option = if catpol_json.ne("null") { - Some(serde_json::from_str(catpol_json.as_str()).to_indy( - IndyErrorKind::InvalidState, - "Cannot deserialize CredentialAttrTagPolicy", - )?) - } else { - None - }; - - let cred_tags = self - .prover_service - .build_credential_tags(&credential, catpol.as_ref())?; - - self.wallet_service - .add_indy_object(wallet_handle, &out_cred_id, &credential, &cred_tags) - .await?; - - let res = Ok(out_cred_id); - trace!("store_credential < {:?}", res); - res - } - - /// Gets human readable credentials according to the filter. - /// If filter is NULL, then all credentials are returned. - /// Credentials can be filtered by Issuer, credential_def and/or Schema. - /// - /// #Params - /// wallet_handle: wallet handle (created by open_wallet). - /// filter_json: filter for credentials - /// { - /// "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) - /// } - /// - /// #Returns - /// credentials json - /// [{ - /// "referent": string, - id of credential in the wallet - /// "attrs": {"key1":"raw_value1", "key2":"raw_value2"}, - credential attributes - /// "schema_id": string, - identifier of schema - /// "cred_def_id": string, - identifier of credential definition - /// "rev_reg_id": Optional, - identifier of revocation registry definition - /// "cred_rev_id": Optional - identifier of credential in the revocation - /// registry definition }] - /// - /// #Errors - /// Anoncreds* - /// Common* - /// Wallet* - #[no_mangle] - pub async fn get_credentials( - &self, - wallet_handle: WalletHandle, - filter_json: Option, - ) -> IndyResult { - trace!( - "get_credentials > wallet_handle {:?} filter_json {:?}", - wallet_handle, - filter_json - ); - - let filter_json = filter_json.as_deref().unwrap_or("{}"); - let mut credentials_info: Vec = Vec::new(); - - let mut credentials_search = self - .wallet_service - .search_indy_records::( - wallet_handle, - filter_json, - &SearchOptions::id_value(), - ) - .await?; - - while let Some(credential_record) = credentials_search.fetch_next_record().await? { - let (referent, credential) = self._get_credential(&credential_record)?; - credentials_info.push(self._get_credential_info(&referent, credential)) - } - - let credentials_info_json = serde_json::to_string(&credentials_info).to_indy( - IndyErrorKind::InvalidState, - "Cannot serialize list of CredentialInfo", - )?; - - let res = Ok(credentials_info_json); - trace!("get_credentials < {:?}", res); - res - } - - /// Gets human readable credential by the given id. - /// - /// #Params - /// wallet_handle: wallet handle (created by open_wallet). - /// cred_id: Identifier by which requested credential is stored in the wallet - /// - /// #Returns - /// credential json: - /// { - /// "referent": string, - id of credential in the wallet - /// "attrs": {"key1":"raw_value1", "key2":"raw_value2"}, - credential attributes - /// "schema_id": string, - identifier of schema - /// "cred_def_id": string, - identifier of credential definition - /// "rev_reg_id": Optional, - identifier of revocation registry definition - /// "cred_rev_id": Optional - identifier of credential in the revocation - /// registry definition } - /// - /// #Errors - /// Anoncreds* - /// Common* - /// Wallet* - pub async fn get_credential( - &self, - wallet_handle: WalletHandle, - cred_id: String, - ) -> IndyResult { - trace!( - "get_credentials > wallet_handle {:?} cred_id {:?}", - wallet_handle, - cred_id - ); - - let credential: Credential = self - .wallet_service - .get_indy_object(wallet_handle, &cred_id, &RecordOptions::id_value()) - .await?; - - let credential_info = self._get_credential_info(&cred_id, credential); - - let credential_info_json = serde_json::to_string(&credential_info).to_indy( - IndyErrorKind::InvalidState, - "Cannot serialize CredentialInfo", - )?; - - let res = Ok(credential_info_json); - trace!("get_credential < {:?}", res); - res - } - - /// Search for credentials stored in wallet. - /// Credentials can be filtered by tags created during saving of credential. - /// - /// Instead of immediately returning of fetched credentials - /// this call returns search_handle that can be used later - /// to fetch records by small batches (with indy_prover_fetch_credentials). - /// - /// #Params - /// wallet_handle: wallet handle (created by open_wallet). - /// query_json: Wql query filter for credentials searching based on tags. - /// where query: indy-sdk/docs/design/011-wallet-query-language/README.md - /// - /// #Returns - /// search_handle: Search handle that can be used later to fetch records by small batches (with - /// indy_prover_fetch_credentials) total_count: Total count of records - /// - /// #Errors - /// Anoncreds* - /// Common* - /// Wallet* - pub async fn search_credentials( - &self, - wallet_handle: WalletHandle, - query_json: Option, - ) -> IndyResult<(SearchHandle, usize)> { - trace!( - "search_credentials > wallet_handle {:?} query_json {:?}", - wallet_handle, - query_json - ); - - let credentials_search = self - .wallet_service - .search_indy_records::( - wallet_handle, - query_json.as_deref().unwrap_or("{}"), - &SearchOptions::id_value(), - ) - .await?; - - let total_count = credentials_search.get_total_count()?.unwrap_or(0); - - let handle: SearchHandle = next_search_handle(); - - self.searches - .lock() - .await - .insert(handle, Box::new(credentials_search)); - - let res = (handle, total_count); - trace!("search_credentials < {:?}", res); - Ok(res) - } - - /// Fetch next credentials for search. - /// - /// #Params - /// search_handle: Search handle (created by indy_prover_search_credentials) - /// count: Count of credentials to fetch - /// - /// #Returns - /// credentials_json: List of human readable credentials: - /// [{ - /// "referent": string, - id of credential in the wallet - /// "attrs": {"key1":"raw_value1", "key2":"raw_value2"}, - credential attributes - /// "schema_id": string, - identifier of schema - /// "cred_def_id": string, - identifier of credential definition - /// "rev_reg_id": Optional, - identifier of revocation registry definition - /// "cred_rev_id": Optional - identifier of credential in the revocation - /// registry definition }] - /// NOTE: The list of length less than the requested count means credentials search iterator is - /// completed. - /// - /// #Errors - /// Anoncreds* - /// Common* - /// Wallet* - pub async fn fetch_credentials( - &self, - search_handle: SearchHandle, - count: usize, - ) -> IndyResult { - trace!( - "fetch_credentials > search_handle {:?} count {:?}", - search_handle, - count - ); - - let mut searches = self.searches.lock().await; - - let search = searches.get_mut(&search_handle).ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidWalletHandle, - "Unknown CredentialsSearch handle", - ) - })?; - - let mut credentials_info: Vec = Vec::new(); - - for _ in 0..count { - match search.fetch_next_record().await? { - Some(credential_record) => { - let (referent, credential) = self._get_credential(&credential_record)?; - credentials_info.push(self._get_credential_info(&referent, credential)) - } - None => break, - } - } - - let credentials_info_json = serde_json::to_string(&credentials_info).to_indy( - IndyErrorKind::InvalidState, - "Cannot serialize list of CredentialInfo", - )?; - - let res = Ok(credentials_info_json); - trace!("fetch_credentials < {:?}", res); - res - } - - /// Close credentials search (make search handle invalid) - /// - /// #Params - /// search_handle: Search handle (created by indy_prover_search_credentials) - /// - /// #Errors - /// Anoncreds* - /// Common* - /// Wallet* - pub async fn close_credentials_search(&self, search_handle: SearchHandle) -> IndyResult<()> { - trace!( - "close_credentials_search > search_handle {:?}", - search_handle - ); - - self.searches - .lock() - .await - .remove(&search_handle) - .ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidWalletHandle, - "Unknown CredentialsSearch handle", - ) - })?; - - let res = Ok(()); - trace!("close_credentials_search < {:?}", res); - res - } - - /// Gets human readable credentials matching the given proof request. - /// - /// NOTE: This method is deprecated because immediately returns all fetched credentials. - /// Use to fetch records by small batches. - /// - /// #Params - /// wallet_handle: wallet handle (created by open_wallet). - /// proof_request_json: proof request json - /// { - /// "name": string, - /// "version": string, - /// "nonce": string, - a decimal number represented as a string (use - /// `indy_generate_nonce` function to generate 80-bit number) "requested_attributes" - /// : { // set of requested attributes "": , // see - /// below ..., - /// }, - /// "requested_predicates": { // set of requested predicates - /// "": , // see below - /// ..., - /// }, - /// "non_revoked": Optional<>, // see below, - /// // If specified prover must proof non-revocation - /// // for date in this interval for each attribute - /// // (applies to every attribute and predicate but can be overridden on - /// attribute level), "ver": Optional - proof request version: - /// - omit or "1.0" to use unqualified identifiers for restrictions - /// - "2.0" to use fully qualified identifiers for restrictions - /// } - /// - /// where - /// attr_referent: Proof-request local identifier of requested attribute - /// 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": int 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 - /// } - /// 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) - /// } - /// - /// #Returns - /// credentials_json: json with credentials for the given proof request. - /// { - /// "attrs": { - /// "": [{ cred_info: , interval: - /// Optional }], ..., - /// }, - /// "predicates": { - /// "requested_predicates": [{ cred_info: , timestamp: - /// Optional }, { cred_info: , timestamp: Optional }], - /// "requested_predicate_2_referent": [{ cred_info: , timestamp: - /// Optional }] } - /// }, where is - /// { - /// "referent": string, - id of credential in the wallet - /// "attrs": {"key1":"raw_value1", "key2":"raw_value2"}, - credential attributes - /// "schema_id": string, - identifier of schema - /// "cred_def_id": string, - identifier of credential definition - /// "rev_reg_id": Optional, - identifier of revocation registry definition - /// "cred_rev_id": Optional - identifier of credential in the revocation - /// registry definition } - /// - /// #Errors - /// Anoncreds* - /// Common* - /// Wallet* - #[deprecated( - since = "1.6.1", - note = "Please use indy_prover_search_credentials_for_proof_req instead!" - )] - #[no_mangle] - pub async fn get_credentials_for_proof_req( - &self, - wallet_handle: WalletHandle, - proof_request: ProofRequest, - ) -> IndyResult { - trace!( - "get_credentials_for_proof_req > wallet_handle {:?} proof_request {:?}", - wallet_handle, - proof_request - ); - - let proof_req = proof_request.value(); - let proof_req_version = proof_request.version(); - - let mut credentials_for_proof_request: CredentialsForProofRequest = - CredentialsForProofRequest::default(); - - for (attr_id, requested_attr) in proof_req.requested_attributes.iter() { - let query = self.prover_service.process_proof_request_restrictions( - &proof_req_version, - &requested_attr.name, - &requested_attr.names, - &attr_id, - &requested_attr.restrictions, - &None, - )?; - - let interval = AnoncredsHelpers::get_non_revoc_interval( - &proof_req.non_revoked, - &requested_attr.non_revoked, - ); - - let credentials_for_attribute = self - ._query_requested_credentials(wallet_handle, &query, None, &interval) - .await?; - - credentials_for_proof_request - .attrs - .insert(attr_id.to_string(), credentials_for_attribute); - } - - for (predicate_id, requested_predicate) in proof_req.requested_predicates.iter() { - let query = self.prover_service.process_proof_request_restrictions( - &proof_req_version, - &Some(requested_predicate.name.clone()), - &None, - &predicate_id, - &requested_predicate.restrictions, - &None, - )?; - - let interval = AnoncredsHelpers::get_non_revoc_interval( - &proof_req.non_revoked, - &requested_predicate.non_revoked, - ); - - let credentials_for_predicate = self - ._query_requested_credentials( - wallet_handle, - &query, - Some(&requested_predicate), - &interval, - ) - .await?; - - credentials_for_proof_request - .predicates - .insert(predicate_id.to_string(), credentials_for_predicate); - } - - let credentials_for_proof_request_json = - serde_json::to_string(&credentials_for_proof_request).to_indy( - IndyErrorKind::InvalidState, - "Cannot serialize CredentialsForProofRequest", - )?; - - let res = Ok(credentials_for_proof_request_json); - trace!("get_credentials_for_proof_req < {:?}", res); - res - } - - /// Search for credentials matching the given proof request. - /// - /// Instead of immediately returning of fetched credentials - /// this call returns search_handle that can be used later - /// to fetch records by small batches (with indy_prover_fetch_credentials_for_proof_req). - /// - /// #Params - /// wallet_handle: wallet handle (created by open_wallet). - /// proof_request_json: proof request json - /// { - /// "name": string, - /// "version": string, - /// "nonce": string, - a decimal number represented as a string (use - /// `indy_generate_nonce` function to generate 80-bit number) "requested_attributes" - /// : { // set of requested attributes "": , // see - /// below ..., - /// }, - /// "requested_predicates": { // set of requested predicates - /// "": , // see below - /// ..., - /// }, - /// "non_revoked": Optional<>, // see below, - /// // If specified prover must proof non-revocation - /// // for date in this interval for each attribute - /// // (applies to every attribute and predicate but can be overridden on - /// attribute level) // (can be overridden on attribute level) - /// "ver": Optional - proof request version: - /// - omit or "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 - /// } - /// extra_query_json:(Optional) List of extra queries that will be applied to correspondent - /// attribute/predicate: { - /// "": , - /// "": , - /// } - /// where wql query: indy-sdk/docs/design/011-wallet-query-language/README.md - /// The list of allowed keys that can be combine into complex queries. - /// "schema_id": , - /// "schema_issuer_did": , - /// "schema_name": , - /// "schema_version": , - /// "issuer_did": , - /// "cred_def_id": , - /// "rev_reg_id": , // "None" as string if not - /// present // the following keys can be used for every `attribute name` in - /// credential. "attr::::marker": "1", - to filter based on - /// existence of a specific attribute "attr::::value": , - to filter based on value of a specific attribute - /// - /// - /// #Returns - /// search_handle: Search handle that can be used later to fetch records by small batches (with - /// indy_prover_fetch_credentials_for_proof_req) - /// - /// #Errors - /// Anoncreds* - /// Common* - /// Wallet* - pub async fn search_credentials_for_proof_req( - &self, - wallet_handle: WalletHandle, - proof_request: ProofRequest, - extra_query: Option, - ) -> IndyResult { - trace!( - "search_credentials_for_proof_req > wallet_handle {:?} proof_request {:?} extra_query \ - {:?}", - wallet_handle, - proof_request, - extra_query - ); - - let proof_req = proof_request.value(); - let version = proof_request.version(); - - let mut credentials_for_proof_request_search = - HashMap::>>::new(); - - for (attr_id, requested_attr) in proof_req.requested_attributes.iter() { - let query = self.prover_service.process_proof_request_restrictions( - &version, - &requested_attr.name, - &requested_attr.names, - &attr_id, - &requested_attr.restrictions, - &extra_query.as_ref(), - )?; - - let credentials_search = self - .wallet_service - .search_indy_records::( - wallet_handle, - &query.to_string(), - &SearchOptions::id_value(), - ) - .await?; - - let interval = AnoncredsHelpers::get_non_revoc_interval( - &proof_req.non_revoked, - &requested_attr.non_revoked, - ); - - credentials_for_proof_request_search.insert( - attr_id.to_string(), - Arc::new(Mutex::new(SearchForProofRequest::new( - credentials_search, - interval, - None, - ))), - ); - } - - for (predicate_id, requested_predicate) in proof_req.requested_predicates.iter() { - let query = self.prover_service.process_proof_request_restrictions( - &version, - &Some(requested_predicate.name.clone()), - &None, - &predicate_id, - &requested_predicate.restrictions, - &extra_query.as_ref(), - )?; - - let credentials_search = self - .wallet_service - .search_indy_records::( - wallet_handle, - &query.to_string(), - &SearchOptions::id_value(), - ) - .await?; - - let interval = AnoncredsHelpers::get_non_revoc_interval( - &proof_req.non_revoked, - &requested_predicate.non_revoked, - ); - - credentials_for_proof_request_search.insert( - predicate_id.to_string(), - Arc::new(Mutex::new(SearchForProofRequest::new( - credentials_search, - interval, - Some(requested_predicate.clone()), - ))), - ); - } - - let search_handle = next_search_handle(); - - self.searches_for_proof_requests - .lock() - .await - .insert(search_handle, credentials_for_proof_request_search); - - let res = Ok(search_handle); - trace!("search_credentials_for_proof_req < {:?}", search_handle); - res - } - - /// Fetch next credentials for the requested item using proof request search - /// handle (created by indy_prover_search_credentials_for_proof_req). - /// - /// #Params - /// search_handle: Search handle (created by indy_prover_search_credentials_for_proof_req) - /// item_referent: Referent of attribute/predicate in the proof request - /// count: Count of credentials to fetch - /// - /// #Returns - /// credentials_json: List of credentials for the given proof request. - /// [{ - /// cred_info: , - /// interval: Optional - /// }] - /// where - /// credential_info: - /// { - /// "referent": string, - id of credential in the wallet - /// "attrs": {"key1":"raw_value1", "key2":"raw_value2"}, - credential attributes - /// "schema_id": string, - identifier of schema - /// "cred_def_id": string, - identifier of credential definition - /// "rev_reg_id": Optional, - identifier of revocation registry definition - /// "cred_rev_id": Optional - identifier of credential in the revocation - /// registry definition } - /// non_revoc_interval: - /// { - /// "from": Optional, // timestamp of interval beginning - /// "to": Optional, // timestamp of interval ending - /// } - /// NOTE: The list of length less than the requested count means that search iterator - /// correspondent to the requested is completed. - /// - /// #Errors - /// Anoncreds* - /// Common* - /// Wallet* - pub async fn fetch_credential_for_proof_request( - &self, - search_handle: SearchHandle, - item_referent: String, - count: usize, - ) -> IndyResult { - trace!( - "fetch_credential_for_proof_request > search_handle {:?} item_referent {:?} count {:?}", - search_handle, - item_referent, - count - ); - - let search_mut = { - let mut searches = self.searches_for_proof_requests.lock().await; - - searches - .get_mut(&search_handle) - .ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidWalletHandle, - "Unknown CredentialsSearch", - ) - })? - .get(&item_referent) - .ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidWalletHandle, - "Unknown item referent for CredentialsSearch handle", - ) - })? - .clone() - }; - - let mut search_lock = search_mut.lock().await; - let search: &mut SearchForProofRequest = search_lock.deref_mut(); - - let requested_credentials: Vec = self - ._get_requested_credentials( - &mut search.search, - search.predicate_info.as_ref(), - &search.interval, - Some(count), - ) - .await?; - - let requested_credentials_json = serde_json::to_string(&requested_credentials).to_indy( - IndyErrorKind::InvalidState, - "Cannot serialize list of RequestedCredential", - )?; - - let res = Ok(requested_credentials_json); - trace!("fetch_credential_for_proof_request < {:?}", res); - res - } - - /// Close credentials search for proof request (make search handle invalid) - /// - /// #Params - /// search_handle: Search handle (created by indy_prover_search_credentials_for_proof_req) - /// - /// #Errors - /// Anoncreds* - /// Common* - /// Wallet* - pub async fn close_credentials_search_for_proof_req( - &self, - search_handle: SearchHandle, - ) -> IndyResult<()> { - trace!( - "close_credentials_search_for_proof_req > search_handle {:?}", - search_handle - ); - - self.searches_for_proof_requests - .lock() - .await - .remove(&search_handle) - .ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidWalletHandle, - "Unknown CredentialsSearch handle", - ) - })?; - - let res = Ok(()); - trace!("close_credentials_search_for_proof_req < {:?}", res); - res - } - - /// Deletes credential by given id. - /// - /// #Params - /// wallet_handle: wallet handle (created by open_wallet). - /// cred_id: Identifier by which requested credential is stored in the wallet - /// - /// #Errors - /// Anoncreds* - /// Common* - /// Wallet* - pub async fn delete_credential( - &self, - wallet_handle: WalletHandle, - cred_id: String, - ) -> IndyResult<()> { - trace!( - "delete_credential > wallet_handle {:?} cred_id {:?}", - wallet_handle, - cred_id - ); - - if !self - .wallet_service - .record_exists::(wallet_handle, &cred_id) - .await? - { - return Err(err_msg( - IndyErrorKind::WalletItemNotFound, - "Credential not found", - )); - } - - self.wallet_service - .delete_indy_record::(wallet_handle, &cred_id) - .await?; - - let res = Ok(()); - trace!("delete_credential < {:?}", res); - res - } - - /// Creates a proof according to the given proof request - /// Either a corresponding credential with optionally revealed attributes or self-attested - /// attribute must be provided for each requested attribute (see - /// indy_prover_get_credentials_for_pool_req). A proof request may request multiple - /// credentials from different schemas and different issuers. All required schemas, public - /// keys and revocation registries must be provided. The proof request also contains nonce. - /// The proof contains either proof or self-attested attribute value for each requested - /// attribute. - /// - /// #Params - /// wallet_handle: wallet handle (created by open_wallet). - - /// proof_request_json: proof request json - /// { - /// "name": string, - /// "version": string, - /// "nonce": string, - a decimal number represented as a string (use - /// `indy_generate_nonce` function to generate 80-bit number) "requested_attributes" - /// : { // set of requested attributes "": , // see - /// below ..., - /// }, - /// "requested_predicates": { // set of requested predicates - /// "": , // see below - /// ..., - /// }, - /// "non_revoked": Optional<>, // see below, - /// // If specified prover must proof non-revocation - /// // for date in this interval for each attribute - /// // (applies to every attribute and predicate but can be overridden on - /// attribute level) // (can be overridden on attribute level) - /// "ver": Optional - proof request version: - /// - omit or "1.0" to use unqualified identifiers for restrictions - /// - "2.0" to use fully qualified identifiers for restrictions - /// } - /// requested_credentials_json: either a credential or self-attested attribute for each - /// requested attribute { - /// "self_attested_attributes": { - /// "self_attested_attribute_referent": string - /// }, - /// "requested_attributes": { - /// "requested_attribute_referent_1": {"cred_id": string, "timestamp": - /// Optional, revealed: }}, "requested_attribute_referent_2": - /// {"cred_id": string, "timestamp": Optional, revealed: }} }, - /// "requested_predicates": { - /// "requested_predicates_referent_1": {"cred_id": string, "timestamp": - /// Optional }}, } - /// } - /// master_secret_id: the id of the master secret stored in the wallet - /// schemas_json: all schemas participating in the proof request - /// { - /// : , - /// : , - /// : , - /// } - /// credential_defs_json: all credential definitions participating in the proof request - /// { - /// "cred_def1_id": , - /// "cred_def2_id": , - /// "cred_def3_id": , - /// } - /// rev_states_json: all revocation states participating in the proof request - /// { - /// "rev_reg_def1_id or credential_1_id": { - /// "timestamp1": , - /// "timestamp2": , - /// }, - /// "rev_reg_def2_id or credential_1_id"": { - /// "timestamp3": - /// }, - /// "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. - /// - /// where - /// attr_referent: Proof-request local identifier of requested attribute - /// 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 - /// } - /// where wql query: indy-sdk/docs/design/011-wallet-query-language/README.md - /// The list of allowed keys that can be combine into complex queries. - /// "schema_id": , - /// "schema_issuer_did": , - /// "schema_name": , - /// "schema_version": , - /// "issuer_did": , - /// "cred_def_id": , - /// "rev_reg_id": , // "None" as string if not - /// present // the following keys can be used for every `attribute name` in - /// credential. "attr::::marker": "1", - to filter based on - /// existence of a specific attribute "attr::::value": , - to filter based on value of a specific attribute - /// - /// #Returns - /// Proof json - /// For each requested attribute either a proof (with optionally revealed attribute value) or - /// self-attested attribute value is provided. - /// Each proof is associated with a credential and corresponding schema_id, cred_def_id, - /// rev_reg_id and timestamp. There is also aggregated proof part common for all credential - /// proofs. { - /// "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}, }, - /// "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} - /// }, - /// "self_attested_attrs": { - /// "requested_attr2_id": self_attested_value, - /// }, - /// "predicates": { - /// "requested_predicate_1_referent": {sub_proof_index: int}, - /// "requested_predicate_2_referent": {sub_proof_index: int}, - /// } - /// } - /// "proof": { - /// "proofs": [ , , ], - /// "aggregated_proof": - /// } (opaque type that contains data structures internal to Ursa. - /// It should not be parsed and are likely to change in future versions). - /// "identifiers": [{schema_id, cred_def_id, Optional, Optional}] - /// } - /// - /// #Errors - /// Anoncreds* - /// Common* - /// Wallet* - pub async fn create_proof( - &self, - wallet_handle: WalletHandle, - proof_req: ProofRequest, - requested_credentials: RequestedCredentials, - master_secret_id: String, - schemas: Schemas, - cred_defs: CredentialDefinitions, - rev_states: RevocationStates, - ) -> IndyResult { - trace!( - "create_proof > wallet_handle {:?} proof_req {:?} requested_credentials {:?} \ - master_secret_id {:?} schemas {:?} cred_defs {:?} rev_states {:?}", - wallet_handle, - proof_req, - requested_credentials, - master_secret_id, - schemas, - cred_defs, - rev_states - ); - - let schemas = schemas_map_to_schemas_v1_map(schemas); - let cred_defs = cred_defs_map_to_cred_defs_v1_map(cred_defs); - - let master_secret = self - ._wallet_get_master_secret(wallet_handle, &master_secret_id) - .await?; - - let cred_refs_for_attrs = requested_credentials - .requested_attributes - .values() - .map(|requested_attr| requested_attr.cred_id.clone()) - .collect::>(); - - let cred_refs_for_predicates = requested_credentials - .requested_predicates - .values() - .map(|requested_predicate| requested_predicate.cred_id.clone()) - .collect::>(); - - let cred_referents = cred_refs_for_attrs - .union(&cred_refs_for_predicates) - .cloned() - .collect::>(); - - let mut credentials: HashMap = - HashMap::with_capacity(cred_referents.len()); - - for cred_referent in cred_referents.into_iter() { - let credential: Credential = self - .wallet_service - .get_indy_object(wallet_handle, &cred_referent, &RecordOptions::id_value()) - .await?; - credentials.insert(cred_referent, credential); - } - - let proof = self.prover_service.create_proof( - &credentials, - &proof_req, - &requested_credentials, - &master_secret.value, - &schemas, - &cred_defs, - &rev_states, - )?; - - let proof_json = serde_json::to_string(&proof) - .to_indy(IndyErrorKind::InvalidState, "Cannot serialize FullProof")?; - - let res = Ok(proof_json); - trace!("create_proof <{:?}", res); - res - } - - /// 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 - - /// 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 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) - /// - /// #Returns - /// revocation state json: - /// { - /// "rev_reg": , - /// "witness": , (opaque type that contains data structures internal to Ursa. - /// It should not be parsed and are likely to change in future - /// versions). "timestamp" : integer - /// } - /// - /// #Errors - /// Common* - /// Wallet* - /// Anoncreds* - pub async fn create_revocation_state( - &self, - blob_storage_reader_handle: i32, - revoc_reg_def: RevocationRegistryDefinition, - rev_reg_delta: RevocationRegistryDelta, - timestamp: u64, - cred_rev_id: String, - ) -> IndyResult { - trace!( - "create_revocation_state > blob_storage_reader_handle {:?} revoc_reg_def {:?} \ - rev_reg_delta {:?} timestamp {:?} cred_rev_id {:?}", - blob_storage_reader_handle, - revoc_reg_def, - rev_reg_delta, - timestamp, - cred_rev_id - ); - - let revoc_reg_def = RevocationRegistryDefinitionV1::from(revoc_reg_def); - let rev_idx = AnoncredsHelpers::parse_cred_rev_id(&cred_rev_id)?; - - let sdk_tails_accessor = SDKTailsAccessor::new( - self.blob_storage_service.clone(), - blob_storage_reader_handle, - &revoc_reg_def, - ) - .await?; - - let rev_reg_delta = RevocationRegistryDeltaV1::from(rev_reg_delta); - - let witness = Witness::new( - rev_idx, - revoc_reg_def.value.max_cred_num, - revoc_reg_def.value.issuance_type.to_bool(), - &rev_reg_delta.value, - &sdk_tails_accessor, - )?; - - let revocation_state = RevocationState { - witness, - rev_reg: RevocationRegistry::from(rev_reg_delta.value), - timestamp, - }; - - let revocation_state_json = serde_json::to_string(&revocation_state).to_indy( - IndyErrorKind::InvalidState, - "Cannot serialize RevocationState", - )?; - - let res = Ok(revocation_state_json); - trace!("create_revocation_state < {:?}", res); - res - } - - /// 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 - - /// 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 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) - /// - /// #Returns - /// revocation state json: - /// { - /// "rev_reg": , - /// "witness": , (opaque type that contains data structures internal to Ursa. - /// It should not be parsed and are likely to change in future - /// versions). "timestamp" : integer - /// } - /// - /// #Errors - /// Common* - /// Wallet* - /// Anoncreds* - pub async fn update_revocation_state( - &self, - blob_storage_reader_handle: i32, - mut rev_state: RevocationState, - rev_reg_def: RevocationRegistryDefinition, - rev_reg_delta: RevocationRegistryDelta, - timestamp: u64, - cred_rev_id: String, - ) -> IndyResult { - trace!( - "update_revocation_state > blob_storage_reader_handle {:?} rev_state {:?} rev_reg_def \ - {:?} rev_reg_delta {:?} timestamp {:?} cred_rev_id {:?}", - blob_storage_reader_handle, - rev_state, - rev_reg_def, - rev_reg_delta, - timestamp, - cred_rev_id - ); - - let revocation_registry_definition = RevocationRegistryDefinitionV1::from(rev_reg_def); - let rev_reg_delta = RevocationRegistryDeltaV1::from(rev_reg_delta); - let rev_idx = AnoncredsHelpers::parse_cred_rev_id(&cred_rev_id)?; - - let sdk_tails_accessor = SDKTailsAccessor::new( - self.blob_storage_service.clone(), - blob_storage_reader_handle, - &revocation_registry_definition, - ) - .await?; - - rev_state.witness.update( - rev_idx, - revocation_registry_definition.value.max_cred_num, - &rev_reg_delta.value, - &sdk_tails_accessor, - )?; - - rev_state.rev_reg = RevocationRegistry::from(rev_reg_delta.value); - rev_state.timestamp = timestamp; - - let rev_state_json = serde_json::to_string(&rev_state).to_indy( - IndyErrorKind::InvalidState, - "Cannot serialize RevocationState", - )?; - - let res = Ok(rev_state_json); - trace!("update_revocation_state < {:?}", res); - res - } - - fn _get_credential_info(&self, referent: &str, credential: Credential) -> CredentialInfo { - let credential_values: HashMap = credential - .values - .0 - .into_iter() - .map(|(attr, values)| (attr, values.raw)) - .collect(); - - CredentialInfo { - referent: referent.to_string(), - attrs: credential_values, - schema_id: credential.schema_id, - cred_def_id: credential.cred_def_id, - rev_reg_id: credential.rev_reg_id, - cred_rev_id: credential - .signature - .extract_index() - .map(|idx| idx.to_string()), - } - } - - fn _get_credential(&self, record: &WalletRecord) -> IndyResult<(String, Credential)> { - let referent = record.get_id(); - - let value = record.get_value().ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidState, - "Credential not found for id: {}", - ) - })?; - - let credential: Credential = serde_json::from_str(value) - .to_indy(IndyErrorKind::InvalidState, "Cannot deserialize Credential")?; - - Ok((referent.to_string(), credential)) - } - - async fn _query_requested_credentials( - &self, - wallet_handle: WalletHandle, - query_json: &Query, - predicate_info: Option<&PredicateInfo>, - interval: &Option, - ) -> IndyResult> { - trace!( - "_query_requested_credentials > wallet_handle {:?} query_json {:?} predicate_info {:?}", - wallet_handle, - query_json, - predicate_info - ); - - let mut credentials_search = self - .wallet_service - .search_indy_records::( - wallet_handle, - &query_json.to_string(), - &SearchOptions::id_value(), - ) - .await?; - - let credentials = self - ._get_requested_credentials(&mut credentials_search, predicate_info, interval, None) - .await?; - - let res = Ok(credentials); - trace!("_query_requested_credentials < {:?}", res); - res - } - - async fn _get_requested_credentials( - &self, - credentials_search: &mut WalletSearch, - predicate_info: Option<&PredicateInfo>, - interval: &Option, - max_count: Option, - ) -> IndyResult> { - let mut credentials: Vec = Vec::new(); - - if let Some(0) = max_count { - return Ok(vec![]); - } - - while let Some(credential_record) = credentials_search.fetch_next_record().await? { - let (referent, credential) = self._get_credential(&credential_record)?; - - if let Some(predicate) = predicate_info { - let values = self - .prover_service - .get_credential_values_for_attribute(&credential.values.0, &predicate.name) - .ok_or_else(|| { - err_msg(IndyErrorKind::InvalidState, "Credential values not found") - })?; - - let satisfy = self - .prover_service - .attribute_satisfy_predicate(predicate, &values.encoded)?; - if !satisfy { - continue; - } - } - - credentials.push(RequestedCredential { - cred_info: self._get_credential_info(&referent, credential), - interval: interval.clone(), - }); - - if let Some(mut count) = max_count { - count -= 1; - if count == 0 { - break; - } - } - } - - Ok(credentials) - } - - async fn _wallet_get_master_secret( - &self, - wallet_handle: WalletHandle, - key: &str, - ) -> IndyResult { - self.wallet_service - .get_indy_object(wallet_handle, &key, &RecordOptions::id_value()) - .await - } - - async fn _get_credential_attr_tag_policy( - &self, - wallet_handle: WalletHandle, - cred_def_id: &CredentialDefinitionId, - ) -> IndyResult { - let catpol = self - .wallet_service - .get_indy_opt_object::( - wallet_handle, - &cred_def_id.0, - &RecordOptions::id_value(), - ) - .await? - .as_ref() - .map(serde_json::to_string) - .transpose() - .to_indy( - IndyErrorKind::InvalidState, - "Cannot serialize CredentialAttrTagPolicy", - )? - .unwrap_or_else(|| Value::Null.to_string()); - - Ok(catpol) - } -} diff --git a/libvdrtools/src/controllers/anoncreds/tails.rs b/libvdrtools/src/controllers/anoncreds/tails.rs deleted file mode 100644 index a6e0522c99..0000000000 --- a/libvdrtools/src/controllers/anoncreds/tails.rs +++ /dev/null @@ -1,121 +0,0 @@ -use std::sync::Arc; - -use indy_api_types::errors::prelude::*; -use log::trace; -use ursa::{ - cl::{RevocationTailsAccessor, RevocationTailsGenerator, Tail}, - errors::prelude::{UrsaCryptoError, UrsaCryptoErrorKind}, -}; - -use crate::{ - domain::anoncreds::revocation_registry_definition::RevocationRegistryDefinitionV1, - services::BlobStorageService, - utils::crypto::base58::{FromBase58, ToBase58}, -}; - -const TAILS_BLOB_TAG_SZ: u8 = 2; -const TAIL_SIZE: usize = Tail::BYTES_REPR_SIZE; - -pub(crate) struct SDKTailsAccessor { - tails_service: Arc, - tails_reader_handle: i32, -} - -impl SDKTailsAccessor { - pub(crate) async fn new( - tails_service: Arc, - tails_reader_handle: i32, - rev_reg_def: &RevocationRegistryDefinitionV1, - ) -> IndyResult { - let tails_hash = - rev_reg_def.value.tails_hash.from_base58().map_err(|_| { - err_msg(IndyErrorKind::InvalidState, "Invalid base58 for Tails hash") - })?; - - let tails_reader_handle = tails_service - .open_blob( - tails_reader_handle, - &rev_reg_def.value.tails_location, - tails_hash.as_slice(), - ) - .await?; - - Ok(SDKTailsAccessor { - tails_service, - tails_reader_handle, - }) - } -} - -impl Drop for SDKTailsAccessor { - fn drop(&mut self) { - #[allow(unused_must_use)] //TODO - { - self.tails_service - .close(self.tails_reader_handle) - .map_err(map_err_err!()); - } - } -} - -impl RevocationTailsAccessor for SDKTailsAccessor { - fn access_tail( - &self, - tail_id: u32, - accessor: &mut dyn FnMut(&Tail), - ) -> Result<(), UrsaCryptoError> { - trace!("access_tail > tail_id {:?}", tail_id); - - // FIXME: Potentially it is significant lock - let tail_bytes = self - .tails_service - .read( - self.tails_reader_handle, - TAIL_SIZE, - TAIL_SIZE * tail_id as usize + TAILS_BLOB_TAG_SZ as usize, - ) - .map_err(|_| { - UrsaCryptoError::from_msg( - UrsaCryptoErrorKind::InvalidState, - "Can't read tail bytes from blob storage", - ) - })?; // FIXME: IO error should be returned - - let tail = Tail::from_bytes(tail_bytes.as_slice())?; - accessor(&tail); - - let res = Ok(()); - trace!("access_tail < {:?}", res); - res - } -} - -pub(crate) async fn store_tails_from_generator( - service: Arc, - writer_handle: i32, - rtg: &mut RevocationTailsGenerator, -) -> IndyResult<(String, String)> { - trace!( - "store_tails_from_generator > writer_handle {:?}", - writer_handle - ); - - let blob_handle = service.create_blob(writer_handle).await?; - - let version = vec![0u8, TAILS_BLOB_TAG_SZ]; - service.append(blob_handle, version.as_slice()).await?; - - while let Some(tail) = rtg.try_next()? { - let tail_bytes = tail.to_bytes()?; - service.append(blob_handle, tail_bytes.as_slice()).await?; - } - - let tails_info = service - .finalize(blob_handle) - .await - .map(|(location, hash)| (location, hash.to_base58()))?; - - let res = Ok(tails_info); - trace!("store_tails_from_generator < {:?}", res); - res -} diff --git a/libvdrtools/src/controllers/anoncreds/verifier.rs b/libvdrtools/src/controllers/anoncreds/verifier.rs deleted file mode 100644 index bfde54ccd1..0000000000 --- a/libvdrtools/src/controllers/anoncreds/verifier.rs +++ /dev/null @@ -1,240 +0,0 @@ -use std::sync::Arc; - -use indy_api_types::errors::prelude::*; -use log::trace; - -use crate::{ - domain::anoncreds::{ - credential_definition::{cred_defs_map_to_cred_defs_v1_map, CredentialDefinitions}, - proof::Proof, - proof_request::ProofRequest, - revocation_registry::{rev_regs_map_to_rev_regs_local_map, RevocationRegistries}, - revocation_registry_definition::{ - rev_reg_defs_map_to_rev_reg_defs_v1_map, RevocationRegistryDefinitions, - }, - schema::{schemas_map_to_schemas_v1_map, Schemas}, - }, - services::VerifierService, -}; - -pub struct VerifierController { - verifier_service: Arc, -} - -impl VerifierController { - pub(crate) fn new(verifier_service: Arc) -> VerifierController { - VerifierController { verifier_service } - } - - /// Verifies a proof (of multiple credential). - /// All required schemas, public keys and revocation registries must be provided. - /// - /// IMPORTANT: You must use *_id's (`schema_id`, `cred_def_id`, `rev_reg_id`) listed in - /// `proof[identifiers]` as the keys for corresponding `schemas_json`, - /// `credential_defs_json`, `rev_reg_defs_json`, `rev_regs_json` objects. - /// - /// #Params - /// wallet_handle: wallet handle (created by open_wallet). - - /// proof_request_json: proof request json - /// { - /// "name": string, - /// "version": string, - /// "nonce": string, - a decimal number represented as a string (use - /// `indy_generate_nonce` function to generate 80-bit number) "requested_attributes" - /// : { // set of requested attributes "": , // see - /// below ..., - /// }, - /// "requested_predicates": { // set of requested predicates - /// "": , // see below - /// ..., - /// }, - /// "non_revoked": Optional<>, // see below, - /// // If specified prover must proof non-revocation - /// // for date in this interval for each attribute - /// // (can be overridden on attribute level) - /// "ver": Optional - proof request version: - /// - omit or "1.0" to use unqualified identifiers for restrictions - /// - "2.0" to use fully qualified identifiers for restrictions - /// } - /// proof_json: created for request proof json - /// { - /// "requested_proof": { - /// "revealed_attrs": { - /// "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} - /// }, - /// "self_attested_attrs": { - /// "requested_attr2_id": self_attested_value, - /// }, - /// "requested_predicates": { - /// "requested_predicate_1_referent": {sub_proof_index: int}, - /// "requested_predicate_2_referent": {sub_proof_index: int}, - /// } - /// } - /// "proof": { - /// "proofs": [ , , ], - /// "aggregated_proof": - /// } - /// "identifiers": [{schema_id, cred_def_id, Optional, Optional}] - /// } - /// schemas_json: all schemas participating in the proof - /// { - /// : , - /// : , - /// : , - /// } - /// credential_defs_json: all credential definitions participating in the proof - /// { - /// "cred_def1_id": , - /// "cred_def2_id": , - /// "cred_def3_id": , - /// } - /// rev_reg_defs_json: all revocation registry definitions participating in the proof - /// { - /// "rev_reg_def1_id": , - /// "rev_reg_def2_id": , - /// "rev_reg_def3_id": , - /// } - /// rev_regs_json: all revocation registries participating in the proof - /// { - /// "rev_reg_def1_id": { - /// "timestamp1": , - /// "timestamp2": , - /// }, - /// "rev_reg_def2_id": { - /// "timestamp3": - /// }, - /// "rev_reg_def3_id": { - /// "timestamp4": - /// }, - /// } - /// where - /// attr_referent: Proof-request local identifier of requested attribute - /// 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 - /// } - /// where wql query: indy-sdk/docs/design/011-wallet-query-language/README.md - /// The list of allowed keys that can be combine into complex queries. - /// "schema_id": , - /// "schema_issuer_did": , - /// "schema_name": , - /// "schema_version": , - /// "issuer_did": , - /// "cred_def_id": , - /// "rev_reg_id": , // "None" as string if not - /// present // the following keys can be used for every `attribute name` in - /// credential. "attr::::marker": "1", - to filter based on - /// existence of a specific attribute "attr::::value": , - to filter based on value of a specific attribute - /// - /// - /// #Returns - /// valid: true - if signature is valid, false - otherwise - /// - /// #Errors - /// Anoncreds* - /// Common* - /// Wallet* - pub fn verify_proof( - &self, - proof_req: ProofRequest, - proof: Proof, - schemas: Schemas, - cred_defs: CredentialDefinitions, - rev_reg_defs: RevocationRegistryDefinitions, - rev_regs: RevocationRegistries, - ) -> IndyResult { - trace!( - "verify_proof > proof_req {:?} proof {:?} schemas {:?} cred_defs {:?} rev_reg_defs \ - {:?} rev_regs {:?}", - proof_req, - proof, - schemas, - cred_defs, - rev_reg_defs, - rev_regs - ); - - let schemas = schemas_map_to_schemas_v1_map(schemas); - let cred_defs = cred_defs_map_to_cred_defs_v1_map(cred_defs); - let rev_reg_defs = rev_reg_defs_map_to_rev_reg_defs_v1_map(rev_reg_defs); - let rev_regs = rev_regs_map_to_rev_regs_local_map(rev_regs); - - let valid = self.verifier_service.verify( - &proof, - &proof_req.value(), - &schemas, - &cred_defs, - &rev_reg_defs, - &rev_regs, - )?; - - let res = Ok(valid); - trace!("verify_proof < {:?}", res); - res - } - - /// Generates 80-bit numbers that can be used as a nonce for proof request. - /// - /// #Params - - /// - /// #Returns - /// nonce: generated number as a string - pub fn generate_nonce(&self) -> IndyResult { - trace!("generate_nonce >"); - - let nonce = self - .verifier_service - .generate_nonce()? - .to_dec() - .to_indy(IndyErrorKind::InvalidState, "Cannot serialize Nonce")?; - - let res = Ok(nonce); - trace!("generate_nonce < {:?}", res); - res - } -} diff --git a/libvdrtools/src/controllers/blob_storage.rs b/libvdrtools/src/controllers/blob_storage.rs deleted file mode 100644 index 6dc2a5bbef..0000000000 --- a/libvdrtools/src/controllers/blob_storage.rs +++ /dev/null @@ -1,43 +0,0 @@ -use std::sync::Arc; - -use indy_api_types::errors::prelude::*; - -use crate::services::BlobStorageService; - -pub struct BlobStorageController { - blob_storage_service: Arc, -} - -impl BlobStorageController { - pub(crate) fn new(blob_storage_service: Arc) -> BlobStorageController { - BlobStorageController { - blob_storage_service, - } - } - - pub async fn open_reader(&self, type_: String, config: String) -> IndyResult { - trace!("open_reader > type_ {:?} config {:?}", type_, config); - - let handle = self - .blob_storage_service - .open_reader(&type_, &config) - .await?; - - let res = Ok(handle); - trace!("open_reader < {:?}", res); - res - } - - pub async fn open_writer(&self, type_: String, config: String) -> IndyResult { - trace!("open_writer > type_ {:?} config {:?}", type_, config); - - let handle = self - .blob_storage_service - .open_writer(&type_, &config) - .await?; - - let res = Ok(handle); - trace!("open_writer < {:?}", res); - res - } -} diff --git a/libvdrtools/src/controllers/config.rs b/libvdrtools/src/controllers/config.rs deleted file mode 100644 index 5e903c80f2..0000000000 --- a/libvdrtools/src/controllers/config.rs +++ /dev/null @@ -1,40 +0,0 @@ -use std::env; - -use crate::domain::IndyConfig; - -pub struct ConfigController {} - -impl ConfigController { - pub(crate) fn new() -> ConfigController { - ConfigController {} - } - - /// Set libvdrtools runtime configuration. Can be optionally called to change current params. - /// - /// #Params - /// config: { - /// "crypto_thread_pool_size": Optional - size of thread pool for the most expensive - /// crypto operations. (4 by default) "collect_backtrace": Optional - whether - /// errors backtrace should be collected. Capturing of backtrace can affect library - /// performance. NOTE: must be set before invocation of any other API functions. - /// } - /// - /// #Errors - /// Common* - pub fn set_runtime_config(&self, config: IndyConfig) { - trace!("set_runtime_config > {:?}", config); - - // FIXME: Deprecate this param. - if let Some(_crypto_thread_pool_size) = config.crypto_thread_pool_size { - warn!("indy_set_runtime_config ! unsupported param used"); - } - - match config.collect_backtrace { - Some(true) => env::set_var("RUST_BACKTRACE", "1"), - Some(false) => env::set_var("RUST_BACKTRACE", "0"), - _ => {} - } - - trace!("set_runtime_config <"); - } -} diff --git a/libvdrtools/src/controllers/crypto.rs b/libvdrtools/src/controllers/crypto.rs index 32e61a79e4..2cd94972ae 100644 --- a/libvdrtools/src/controllers/crypto.rs +++ b/libvdrtools/src/controllers/crypto.rs @@ -110,7 +110,7 @@ impl CryptoController { let key: Key = self .wallet_service - .get_indy_object(wallet_handle, &my_vk, &RecordOptions::id_value()) + .get_indy_object(wallet_handle, my_vk, &RecordOptions::id_value()) .await?; let res = self.crypto_service.sign(&key, msg).await?; @@ -296,7 +296,7 @@ impl CryptoController { }); } // end for-loop - Ok(self._base64_encode_protected(encrypted_recipients_struct, false)?) + self._base64_encode_protected(encrypted_recipients_struct, false) } async fn _prepare_protected_authcrypt( @@ -337,7 +337,7 @@ impl CryptoController { }); } // end for-loop - Ok(self._base64_encode_protected(encrypted_recipients_struct, true)?) + self._base64_encode_protected(encrypted_recipients_struct, true) } fn _base64_encode_protected( diff --git a/libvdrtools/src/controllers/did.rs b/libvdrtools/src/controllers/did.rs index 284bbb394e..95905df4fd 100644 --- a/libvdrtools/src/controllers/did.rs +++ b/libvdrtools/src/controllers/did.rs @@ -4,23 +4,15 @@ use indy_api_types::{errors::prelude::*, WalletHandle}; use indy_wallet::{RecordOptions, SearchOptions, WalletService}; use crate::{ - domain::{ - crypto::{ - did::{ - Did, DidMetadata, DidMethod, DidValue, DidWithMeta, MyDidInfo, TemporaryDid, - TheirDid, TheirDidInfo, - }, - key::KeyInfo, + domain::crypto::{ + did::{ + Did, DidMetadata, DidValue, DidWithMeta, MyDidInfo, TemporaryDid, TheirDid, + TheirDidInfo, }, - ledger::{ - attrib::{AttribData, Endpoint, GetAttrReplyResult}, - did::{GetNymReplyResult, GetNymResultDataV0}, - response::Reply, - }, - pairwise::Pairwise, + key::KeyInfo, }, services::CryptoService, - utils::crypto::base58::{FromBase58, ToBase58}, + utils::crypto::base58::{DecodeBase58, ToBase58}, }; pub struct DidController { @@ -400,7 +392,7 @@ impl DidController { "No value for DID record", )) .and_then(|tags_json| { - serde_json::from_str(&tags_json).to_indy( + serde_json::from_str(tags_json).to_indy( IndyErrorKind::InvalidState, format!("Cannot deserialize Did {:?}", did_id), ) @@ -419,7 +411,7 @@ impl DidController { "No value for DID record", )) .and_then(|tags_json| { - serde_json::from_str(&tags_json).to_indy( + serde_json::from_str(tags_json).to_indy( IndyErrorKind::InvalidState, format!("Cannot deserialize Did {:?}", did_id), ) @@ -435,7 +427,7 @@ impl DidController { .get_value() .ok_or_else(|| err_msg(IndyErrorKind::InvalidState, "No value for DID record")) .and_then(|tags_json| { - serde_json::from_str(&tags_json).to_indy( + serde_json::from_str(tags_json).to_indy( IndyErrorKind::InvalidState, format!("Cannot deserialize Did {:?}", did_id), ) @@ -447,8 +439,8 @@ impl DidController { let did_with_meta = DidWithMeta { did: did.did, verkey: did.verkey, - temp_verkey: temp_verkey, - metadata: metadata, + temp_verkey, + metadata, }; dids.push(did_with_meta); @@ -519,49 +511,6 @@ impl DidController { res } - /// Set/replaces endpoint information for the given DID. - /// - /// #Params - - /// wallet_handle: Wallet handle (created by open_wallet). - /// did - The DID to resolve endpoint. - /// address - The DIDs endpoint address. indy-node and indy-plenum restrict this to - /// ip_address:port transport_key - The DIDs transport key (ver key, key id). - /// - /// #Returns - /// - /// #Errors - /// Common* - /// Wallet* - /// Crypto* - pub async fn set_endpoint_for_did( - &self, - wallet_handle: WalletHandle, - did: DidValue, - endpoint: Endpoint, - ) -> IndyResult<()> { - trace!( - "set_endpoint_for_did > wallet_handle {:?} did {:?} endpoint {:?}", - wallet_handle, - did, - endpoint - ); - - self.crypto_service.validate_did(&did)?; - - if let Some(ref transport_key) = endpoint.verkey { - self.crypto_service.validate_key(transport_key).await?; - } - - self.wallet_service - .upsert_indy_object(wallet_handle, &did.0, &endpoint) - .await?; - - let res = Ok(()); - trace!("set_endpoint_for_did < {:?}", res); - res - } - /// Saves/replaces the meta information for the giving DID in the wallet. /// /// #Params @@ -666,8 +615,8 @@ impl DidController { return res; } - let did = &did.to_unqualified().0.from_base58()?; - let dverkey = &verkey.from_base58()?; + let did = &did.to_unqualified().0.decode_base58()?; + let dverkey = &verkey.decode_base58()?; let (first_part, second_part) = dverkey.split_at(16); @@ -682,175 +631,6 @@ impl DidController { res } - /// Update DID stored in the wallet to make fully qualified, or to do other DID maintenance. - /// - If the DID has no method, a method will be appended (prepend did:peer to a legacy did) - /// - If the DID has a method, a method will be updated (migrate did:peer to did:peer-new) - /// - /// Update DID related entities stored in the wallet. - /// - /// #Params - - /// wallet_handle: Wallet handle (created by open_wallet). - /// did: target DID stored in the wallet. - /// method: method to apply to the DID. - /// - /// #Returns - /// did: fully qualified form of did - /// - /// #Errors - /// Common* - /// Wallet* - /// Crypto* - pub async fn qualify_did( - &self, - wallet_handle: WalletHandle, - did: DidValue, - method: DidMethod, - ) -> IndyResult { - trace!( - "qualify_did > wallet_handle {:?} curr_did {:?} method {:?}", - wallet_handle, - did, - method - ); - - self.crypto_service.validate_did(&did)?; - - let mut curr_did: Did = self - .wallet_service - .get_indy_object::(wallet_handle, &did.0, &RecordOptions::id_value()) - .await?; - - curr_did.did = DidValue::new(&did.to_short().0, None, Some(&method.0))?; - - self.wallet_service - .delete_indy_record::(wallet_handle, &did.0) - .await?; - - self.wallet_service - .add_indy_object(wallet_handle, &curr_did.did.0, &curr_did, &HashMap::new()) - .await?; - - // move temporary Did - if let Ok(mut temp_did) = self - .wallet_service - .get_indy_object::(wallet_handle, &did.0, &RecordOptions::id_value()) - .await - { - temp_did.did = curr_did.did.clone(); - - self.wallet_service - .delete_indy_record::(wallet_handle, &did.0) - .await?; - - self.wallet_service - .add_indy_object(wallet_handle, &curr_did.did.0, &temp_did, &HashMap::new()) - .await?; - } - - // move metadata - self._update_dependent_entity_reference::( - wallet_handle, - &did.0, - &curr_did.did.0, - ) - .await?; - - // move endpoint - self._update_dependent_entity_reference::(wallet_handle, &did.0, &curr_did.did.0) - .await?; - - // move all pairwise - let mut pairwise_search = self - .wallet_service - .search_indy_records::(wallet_handle, "{}", &RecordOptions::id_value()) - .await?; - - while let Some(pairwise_record) = pairwise_search.fetch_next_record().await? { - let mut pairwise: Pairwise = pairwise_record - .get_value() - .ok_or_else(|| err_msg(IndyErrorKind::InvalidState, "No value for Pairwise record")) - .and_then(|pairwise_json| { - serde_json::from_str(&pairwise_json).map_err(|err| { - IndyError::from_msg( - IndyErrorKind::InvalidState, - format!("Cannot deserialize Pairwise {:?}", err), - ) - }) - })?; - - if pairwise.my_did.eq(&did) { - pairwise.my_did = curr_did.did.clone(); - - self.wallet_service - .update_indy_object(wallet_handle, &pairwise.their_did.0, &pairwise) - .await?; - } - } - - let res = Ok(curr_did.did.0); - trace!("qualify_did < {:?}", res); - res - } - - pub async fn get_nym_ack_process_and_store_their_did( - &self, - wallet_handle: WalletHandle, - did: DidValue, - get_nym_reply_result: IndyResult, - ) -> IndyResult { - trace!( - "get_nym_ack_process_and_store_their_did > wallet_handle {:?} get_nym_reply_result \ - {:?}", - wallet_handle, - get_nym_reply_result - ); - - let get_nym_reply = get_nym_reply_result?; - - let get_nym_response: Reply = serde_json::from_str(&get_nym_reply) - .to_indy( - IndyErrorKind::InvalidState, - "Invalid GetNymReplyResult json", - )?; - - let their_did_info = match get_nym_response.result() { - GetNymReplyResult::GetNymReplyResultV0(res) => { - if let Some(data) = &res.data { - let gen_nym_result_data: GetNymResultDataV0 = serde_json::from_str(data) - .to_indy(IndyErrorKind::InvalidState, "Invalid GetNymResultData json")?; - - TheirDidInfo::new( - gen_nym_result_data.dest.qualify(did.get_method()), - gen_nym_result_data.verkey, - ) - } else { - return Err(err_msg( - IndyErrorKind::WalletItemNotFound, - "Their DID isn't found on the ledger", - )); //TODO FIXME use separate error - } - } - GetNymReplyResult::GetNymReplyResultV1(res) => TheirDidInfo::new( - res.txn.data.did.qualify(did.get_method()), - res.txn.data.verkey, - ), - }; - - let their_did = self - .crypto_service - .create_their_did(&their_did_info) - .await?; - - self.wallet_service - .add_indy_object(wallet_handle, &their_did.did.0, &their_did, &HashMap::new()) - .await?; - - trace!("get_nym_ack_process_and_store_their_did <<<"); - - Ok(their_did) - } - async fn _update_dependent_entity_reference( &self, wallet_handle: WalletHandle, @@ -876,50 +656,6 @@ impl DidController { Ok(()) } - async fn _get_attrib_ack_process_store_endpoint_to_wallet( - &self, - wallet_handle: WalletHandle, - get_attrib_reply_result: IndyResult, - ) -> IndyResult { - trace!( - "_get_attrib_ack_process_store_endpoint_to_wallet > wallet_handle {:?} \ - get_attrib_reply_result {:?}", - wallet_handle, - get_attrib_reply_result - ); - - let get_attrib_reply = get_attrib_reply_result?; - - let get_attrib_reply: Reply = serde_json::from_str(&get_attrib_reply) - .to_indy( - IndyErrorKind::InvalidState, - "Invalid GetAttrReplyResult json", - )?; - - let (raw, did) = match get_attrib_reply.result() { - GetAttrReplyResult::GetAttrReplyResultV0(res) => (res.data, res.dest), - GetAttrReplyResult::GetAttrReplyResultV1(res) => (res.txn.data.raw, res.txn.data.did), - }; - - let attrib_data: AttribData = serde_json::from_str(&raw) - .to_indy(IndyErrorKind::InvalidState, "Invalid GetAttReply json")?; - - let endpoint = Endpoint::new(attrib_data.endpoint.ha, attrib_data.endpoint.verkey); - - self.wallet_service - .add_indy_object(wallet_handle, &did.0, &endpoint, &HashMap::new()) - .await?; - - let res = Ok(endpoint); - - trace!( - "_get_attrib_ack_process_store_endpoint_to_wallet < {:?}", - res - ); - - res - } - async fn _wallet_get_my_did( &self, wallet_handle: WalletHandle, diff --git a/libvdrtools/src/controllers/mod.rs b/libvdrtools/src/controllers/mod.rs index 2d6cc00516..960f6d8d9d 100644 --- a/libvdrtools/src/controllers/mod.rs +++ b/libvdrtools/src/controllers/mod.rs @@ -1,20 +1,9 @@ -mod anoncreds; -mod blob_storage; -#[macro_use] -mod config; mod crypto; pub(crate) mod did; mod non_secrets; -mod pairwise; mod wallet; -pub use anoncreds::{ - CredentialDefinitionId, IssuerController, ProverController, VerifierController, -}; -pub(crate) use blob_storage::BlobStorageController; -pub(crate) use config::ConfigController; pub(crate) use crypto::CryptoController; pub(crate) use did::DidController; pub(crate) use non_secrets::NonSecretsController; -pub(crate) use pairwise::PairwiseController; pub(crate) use wallet::WalletController; diff --git a/libvdrtools/src/controllers/non_secrets.rs b/libvdrtools/src/controllers/non_secrets.rs index 3ae87a6a26..156bdfadf9 100644 --- a/libvdrtools/src/controllers/non_secrets.rs +++ b/libvdrtools/src/controllers/non_secrets.rs @@ -62,7 +62,7 @@ impl NonSecretsController { &type_, &id, &value, - &tags.unwrap_or_else(|| Tags::new()), + &tags.unwrap_or_default(), ) .await?; diff --git a/libvdrtools/src/controllers/pairwise.rs b/libvdrtools/src/controllers/pairwise.rs deleted file mode 100644 index 9d8833093b..0000000000 --- a/libvdrtools/src/controllers/pairwise.rs +++ /dev/null @@ -1,241 +0,0 @@ -use std::{collections::HashMap, sync::Arc}; - -use indy_api_types::{errors::prelude::*, WalletHandle}; -use indy_wallet::{RecordOptions, WalletService}; -use log::trace; - -use crate::domain::{ - crypto::did::{Did, DidValue, TheirDid}, - pairwise::{Pairwise, PairwiseInfo}, -}; - -pub struct PairwiseController { - wallet_service: Arc, -} - -impl PairwiseController { - pub(crate) fn new(wallet_service: Arc) -> PairwiseController { - PairwiseController { wallet_service } - } - - /// Check if pairwise is exists. - /// - /// #Params - /// wallet_handle: wallet handler (created by open_wallet). - - /// their_did: encrypted DID - /// - /// #Returns - /// exists: true - if pairwise is exists, false - otherwise - /// - /// #Errors - /// Common* - /// Wallet* - pub async fn pairwise_exists( - &self, - wallet_handle: WalletHandle, - their_did: DidValue, - ) -> IndyResult { - trace!( - "pairwise_exists > wallet_handle {:?} their_did {:?}", - wallet_handle, - their_did - ); - - let exists = self - .wallet_service - .record_exists::(wallet_handle, &their_did.0) - .await?; - - let res = Ok(exists); - trace!("pairwise_exists < {:?}", res); - res - } - - /// Creates pairwise. - /// - /// #Params - /// wallet_handle: wallet handler (created by open_wallet). - - /// their_did: encrypted DID - /// my_did: encrypted DID - /// metadata Optional: extra information for pairwise - /// - /// #Returns - /// Error code - /// - /// #Errors - /// Common* - /// Wallet* - pub async fn create_pairwise( - &self, - wallet_handle: WalletHandle, - their_did: DidValue, - my_did: DidValue, - metadata: Option, - ) -> IndyResult<()> { - trace!( - "create_pairwise > wallet_handle {:?} their_did {:?} my_did {:?} metadata {:?}", - wallet_handle, - their_did, - my_did, - metadata - ); - - self.wallet_service - .get_indy_record::(wallet_handle, &my_did.0, &RecordOptions::id()) - .await?; - - self.wallet_service - .get_indy_record::(wallet_handle, &their_did.0, &RecordOptions::id()) - .await?; - - let pairwise = Pairwise { - my_did, - their_did, - metadata, - }; - - self.wallet_service - .add_indy_object( - wallet_handle, - &pairwise.their_did.0, - &pairwise, - &HashMap::new(), - ) - .await?; - - let res = Ok(()); - trace!("create_pairwise < {:?}", res); - res - } - - /// Get list of saved pairwise. - /// - /// #Params - /// wallet_handle: wallet handler (created by open_wallet). - - /// - /// #Returns - /// list_pairwise: list of saved pairwise - /// - /// #Errors - /// Common* - /// Wallet* - pub async fn list_pairwise(&self, wallet_handle: WalletHandle) -> IndyResult { - trace!("list_pairwise > wallet_handle {:?}", wallet_handle); - - let mut search = self - .wallet_service - .search_indy_records::(wallet_handle, "{}", &RecordOptions::id_value()) - .await?; - - let mut pairwises: Vec = Vec::new(); - - while let Some(pairwise) = search.fetch_next_record().await? { - let pairwise = pairwise - .get_value() - .ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidState, - format!("No value for pairwise {}", pairwise.get_id()), - ) - })? - .to_string(); - - pairwises.push(pairwise); - } - - let pairwises = serde_json::to_string(&pairwises) - .to_indy(IndyErrorKind::InvalidState, "Can't serialize pairwise list")?; - - let res = Ok(pairwises); - trace!("list_pairwise < {:?}", res); - res - } - - /// Gets pairwise information for specific their_did. - /// - /// #Params - /// wallet_handle: wallet handler (created by open_wallet). - - /// their_did: encoded Did - /// - /// #Returns - /// pairwise_info_json: did info associated with their did - /// - /// #Errors - /// Common* - /// Wallet* - pub async fn get_pairwise( - &self, - wallet_handle: WalletHandle, - their_did: DidValue, - ) -> IndyResult { - trace!( - "get_pairwise > wallet_handle {:?} their_did {:?}", - wallet_handle, - their_did - ); - - let pairwise_info = PairwiseInfo::from( - self.wallet_service - .get_indy_object::( - wallet_handle, - &their_did.0, - &RecordOptions::id_value(), - ) - .await?, - ); - - let res = serde_json::to_string(&pairwise_info) - .to_indy(IndyErrorKind::InvalidState, "Can't serialize PairwiseInfo")?; - - let res = Ok(res); - trace!("get_pairwise < {:?}", res); - res - } - - /// Save some data in the Wallet for pairwise associated with Did. - /// - /// #Params - /// wallet_handle: wallet handler (created by open_wallet). - - /// their_did: encoded Did - /// metadata: some extra information for pairwise - /// - /// #Returns - /// Error code - /// - /// #Errors - /// Common* - /// Wallet* - pub async fn set_pairwise_metadata( - &self, - wallet_handle: WalletHandle, - their_did: DidValue, - metadata: Option, - ) -> IndyResult<()> { - trace!( - "set_pairwise_metadata > wallet_handle {:?} their_did {:?} metadata {:?}", - wallet_handle, - their_did, - metadata - ); - - let mut pairwise: Pairwise = self - .wallet_service - .get_indy_object(wallet_handle, &their_did.0, &RecordOptions::id_value()) - .await?; - - pairwise.metadata = metadata; - - self.wallet_service - .update_indy_object(wallet_handle, &their_did.0, &pairwise) - .await?; - - let res = Ok(()); - trace!("set_pairwise_metadata <<<"); - res - } -} diff --git a/libvdrtools/src/controllers/wallet.rs b/libvdrtools/src/controllers/wallet.rs index 95750fe863..980507ad89 100644 --- a/libvdrtools/src/controllers/wallet.rs +++ b/libvdrtools/src/controllers/wallet.rs @@ -422,9 +422,7 @@ impl WalletController { pub fn generate_key(&self, config: Option) -> IndyResult { trace!("generate_key > config: {:?}", secret!(&config)); - let seed = config - .as_ref() - .and_then(|config| config.seed.as_ref().map(String::as_str)); + let seed = config.as_ref().and_then(|config| config.seed.as_deref()); let key = match self.crypto_service.convert_seed(seed)? { Some(seed) => randombytes::randombytes_deterministic( diff --git a/libvdrtools/src/domain/anoncreds/credential.rs b/libvdrtools/src/domain/anoncreds/credential.rs index 3e7a51ebe6..9080a82f24 100644 --- a/libvdrtools/src/domain/anoncreds/credential.rs +++ b/libvdrtools/src/domain/anoncreds/credential.rs @@ -1,6 +1,5 @@ use std::collections::HashMap; -use indy_api_types::validation::Validatable; use ursa::cl::{CredentialSignature, RevocationRegistry, SignatureCorrectnessProof, Witness}; use super::{ @@ -55,38 +54,3 @@ pub struct AttributeValues { pub raw: String, pub encoded: String, } - -impl Validatable for CredentialValues { - fn validate(&self) -> Result<(), String> { - if self.0.is_empty() { - return Err(String::from( - "CredentialValues validation failed: empty list has been passed", - )); - } - - Ok(()) - } -} - -impl Validatable for Credential { - fn validate(&self) -> Result<(), String> { - self.schema_id.validate()?; - self.cred_def_id.validate()?; - self.values.validate()?; - - if self.rev_reg_id.is_some() && (self.witness.is_none() || self.rev_reg.is_none()) { - return Err(String::from( - "Credential validation failed: `witness` and `rev_reg` must be passed for \ - revocable Credential", - )); - } - - if self.values.0.is_empty() { - return Err(String::from( - "Credential validation failed: `values` is empty", - )); - } - - Ok(()) - } -} diff --git a/libvdrtools/src/domain/anoncreds/credential_attr_tag_policy.rs b/libvdrtools/src/domain/anoncreds/credential_attr_tag_policy.rs deleted file mode 100644 index 837030dd6f..0000000000 --- a/libvdrtools/src/domain/anoncreds/credential_attr_tag_policy.rs +++ /dev/null @@ -1,49 +0,0 @@ -use std::collections::HashSet; - -use serde::{ser::SerializeSeq, Deserialize, Deserializer, Serialize, Serializer}; - -#[derive(Debug)] -pub struct CredentialAttrTagPolicy { - pub taggable: HashSet, -} - -impl CredentialAttrTagPolicy { - pub fn is_taggable(&self, attr_name: &str) -> bool { - self.taggable - .contains(&attr_name.to_string().replace(" ", "").to_lowercase()) - } -} - -impl From> for CredentialAttrTagPolicy { - fn from(taggables: Vec) -> Self { - CredentialAttrTagPolicy { - taggable: taggables - .into_iter() - .map(|a| a.replace(" ", "").to_lowercase()) - .collect(), - } - } -} - -impl Serialize for CredentialAttrTagPolicy { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut seq = serializer.serialize_seq(Some(self.taggable.len()))?; - for ref element in &self.taggable { - seq.serialize_element(&element)?; - } - seq.end() - } -} - -impl<'de> Deserialize<'de> for CredentialAttrTagPolicy { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - let attr_names = Vec::deserialize(deserializer)?; - Ok(CredentialAttrTagPolicy::from(attr_names)) - } -} diff --git a/libvdrtools/src/domain/anoncreds/credential_definition.rs b/libvdrtools/src/domain/anoncreds/credential_definition.rs index acf9766d4b..8a765e782e 100644 --- a/libvdrtools/src/domain/anoncreds/credential_definition.rs +++ b/libvdrtools/src/domain/anoncreds/credential_definition.rs @@ -2,7 +2,6 @@ use std::collections::HashMap; use indy_api_types::{ errors::{IndyErrorKind, IndyResult}, - validation::Validatable, IndyError, }; use ursa::cl::{ @@ -14,7 +13,6 @@ use super::{ super::{ anoncreds::{schema::SchemaId, DELIMITER}, crypto::did::DidValue, - ledger::request::ProtocolVersion, }, indy_identifiers, }; @@ -35,20 +33,12 @@ impl SignatureType { } } -#[derive(Debug, Serialize, Deserialize, Clone)] +#[derive(Debug, Serialize, Deserialize, Clone, Default)] pub struct CredentialDefinitionConfig { #[serde(default)] pub support_revocation: bool, } -impl Default for CredentialDefinitionConfig { - fn default() -> Self { - CredentialDefinitionConfig { - support_revocation: false, - } - } -} - #[derive(Debug, Serialize, Deserialize)] pub struct CredentialDefinitionData { pub primary: CredentialPrimaryPublicKey, @@ -126,18 +116,6 @@ pub struct CredentialDefinitionCorrectnessProof { pub value: CredentialKeyCorrectnessProof, } -impl Validatable for CredentialDefinition { - fn validate(&self) -> Result<(), String> { - match self { - CredentialDefinition::CredentialDefinitionV1(cred_def) => { - cred_def.id.validate()?; - cred_def.schema_id.validate()?; - Ok(()) - } - } - } -} - qualifiable_type!(CredentialDefinitionId); impl CredentialDefinitionId { @@ -163,35 +141,24 @@ impl CredentialDefinitionId { "Unsupported DID method", )), None => { - let id = if ProtocolVersion::is_node_1_3() { - CredentialDefinitionId(format!( - "{}{}{}{}{}{}{}", - did.0, - DELIMITER, - Self::MARKER, - DELIMITER, - signature_type, - DELIMITER, - schema_id.0 - )) + let tag = if tag.is_empty() { + "".to_owned() } else { - let tag = if tag.is_empty() { - "".to_owned() - } else { - format!("{}{}", DELIMITER, tag) - }; - CredentialDefinitionId(format!( - "{}{}{}{}{}{}{}{}", - did.0, - DELIMITER, - Self::MARKER, - DELIMITER, - signature_type, - DELIMITER, - schema_id.0, - tag - )) + format!("{}{}", DELIMITER, tag) }; + + let id = CredentialDefinitionId(format!( + "{}{}{}{}{}{}{}{}", + did.0, + DELIMITER, + Self::MARKER, + DELIMITER, + signature_type, + DELIMITER, + schema_id.0, + tag + )); + Ok(id) } } @@ -303,18 +270,6 @@ impl CredentialDefinitionId { } } -impl Validatable for CredentialDefinitionId { - fn validate(&self) -> Result<(), String> { - self.parts().ok_or(format!( - "Credential Definition Id validation failed: {:?}, doesn't match pattern", - self.0 - ))?; - Ok(()) - } -} - -impl Validatable for CredentialDefinitionConfig {} - #[cfg(test)] mod tests { use super::*; @@ -479,39 +434,4 @@ mod tests { assert_eq!(_tag(), tag); } } - - mod validate { - use super::*; - - #[test] - fn test_validate_cred_def_id_as_unqualified() { - _cred_def_id_unqualified().validate().unwrap(); - } - - #[test] - fn test_validate_cred_def_id_as_unqualified_without_tag() { - _cred_def_id_unqualified_without_tag().validate().unwrap(); - } - - #[test] - fn test_validate_cred_def_id_as_unqualified_with_schema_as_seq_no() { - _cred_def_id_unqualified_with_schema_as_seq_no() - .validate() - .unwrap(); - } - - #[test] - fn test_validate_cred_def_id_as_unqualified_with_schema_as_seq_no_without_tag() { - _cred_def_id_unqualified_with_schema_as_seq_no_without_tag() - .validate() - .unwrap(); - } - - #[test] - fn test_validate_cred_def_id_as_fully_qualified_with_schema_as_seq_no() { - _cred_def_id_qualified_with_schema_as_seq_no() - .validate() - .unwrap(); - } - } } diff --git a/libvdrtools/src/domain/anoncreds/credential_for_proof_request.rs b/libvdrtools/src/domain/anoncreds/credential_for_proof_request.rs deleted file mode 100644 index 41f15442ae..0000000000 --- a/libvdrtools/src/domain/anoncreds/credential_for_proof_request.rs +++ /dev/null @@ -1,24 +0,0 @@ -use std::collections::HashMap; - -use super::{credential::CredentialInfo, proof_request::NonRevocedInterval}; - -#[derive(Debug, Deserialize, Serialize)] -pub struct CredentialsForProofRequest { - pub attrs: HashMap>, - pub predicates: HashMap>, -} - -impl Default for CredentialsForProofRequest { - fn default() -> Self { - CredentialsForProofRequest { - attrs: HashMap::new(), - predicates: HashMap::new(), - } - } -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct RequestedCredential { - pub cred_info: CredentialInfo, - pub interval: Option, -} diff --git a/libvdrtools/src/domain/anoncreds/credential_offer.rs b/libvdrtools/src/domain/anoncreds/credential_offer.rs index 715fdf21ba..d980b5d52c 100644 --- a/libvdrtools/src/domain/anoncreds/credential_offer.rs +++ b/libvdrtools/src/domain/anoncreds/credential_offer.rs @@ -1,4 +1,3 @@ -use indy_api_types::validation::Validatable; use ursa::cl::{CredentialKeyCorrectnessProof, Nonce}; use super::{credential_definition::CredentialDefinitionId, schema::SchemaId}; @@ -29,11 +28,3 @@ impl CredentialOffer { } } } - -impl Validatable for CredentialOffer { - fn validate(&self) -> Result<(), String> { - self.schema_id.validate()?; - self.cred_def_id.validate()?; - Ok(()) - } -} diff --git a/libvdrtools/src/domain/anoncreds/credential_request.rs b/libvdrtools/src/domain/anoncreds/credential_request.rs index ca804b8c88..a85416094d 100644 --- a/libvdrtools/src/domain/anoncreds/credential_request.rs +++ b/libvdrtools/src/domain/anoncreds/credential_request.rs @@ -1,4 +1,3 @@ -use indy_api_types::validation::Validatable; use ursa::cl::{ BlindedCredentialSecrets, BlindedCredentialSecretsCorrectnessProof, CredentialSecretsBlindingFactors, Nonce, @@ -33,13 +32,3 @@ impl CredentialRequest { } } } - -impl Validatable for CredentialRequest { - fn validate(&self) -> Result<(), String> { - self.cred_def_id.validate()?; - self.prover_did.validate()?; - Ok(()) - } -} - -impl Validatable for CredentialRequestMetadata {} diff --git a/libvdrtools/src/domain/anoncreds/master_secret.rs b/libvdrtools/src/domain/anoncreds/master_secret.rs index 72fb0f9293..0b6b30c9c4 100644 --- a/libvdrtools/src/domain/anoncreds/master_secret.rs +++ b/libvdrtools/src/domain/anoncreds/master_secret.rs @@ -1,9 +1,6 @@ -use indy_api_types::validation::Validatable; use ursa::cl::MasterSecret as CryptoMasterSecret; #[derive(Debug, Deserialize, Serialize)] pub struct MasterSecret { pub value: CryptoMasterSecret, } - -impl Validatable for MasterSecret {} diff --git a/libvdrtools/src/domain/anoncreds/mod.rs b/libvdrtools/src/domain/anoncreds/mod.rs index 9260ad8e7b..77fd6297b3 100644 --- a/libvdrtools/src/domain/anoncreds/mod.rs +++ b/libvdrtools/src/domain/anoncreds/mod.rs @@ -1,7 +1,5 @@ pub mod credential; -pub mod credential_attr_tag_policy; pub mod credential_definition; -pub mod credential_for_proof_request; pub mod credential_offer; pub mod credential_request; pub mod indy_identifiers; @@ -12,7 +10,6 @@ pub mod requested_credential; pub mod revocation_registry; pub mod revocation_registry_definition; pub mod revocation_registry_delta; -pub mod revocation_state; pub mod schema; pub const DELIMITER: &str = ":"; diff --git a/libvdrtools/src/domain/anoncreds/proof.rs b/libvdrtools/src/domain/anoncreds/proof.rs index 6b9b3dbebe..f66e0cce0a 100644 --- a/libvdrtools/src/domain/anoncreds/proof.rs +++ b/libvdrtools/src/domain/anoncreds/proof.rs @@ -1,6 +1,5 @@ use std::collections::HashMap; -use indy_api_types::validation::Validatable; use ursa::cl::Proof as CryptoProof; use super::{ @@ -15,7 +14,7 @@ pub struct Proof { pub identifiers: Vec, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize, Default)] pub struct RequestedProof { pub revealed_attrs: HashMap, #[serde(skip_serializing_if = "HashMap::is_empty")] @@ -29,18 +28,6 @@ pub struct RequestedProof { pub predicates: HashMap, } -impl Default for RequestedProof { - fn default() -> Self { - RequestedProof { - revealed_attrs: HashMap::new(), - revealed_attr_groups: HashMap::new(), - self_attested_attrs: HashMap::new(), - unrevealed_attrs: HashMap::new(), - predicates: HashMap::new(), - } - } -} - #[derive(Clone, Debug, Deserialize, Serialize)] pub struct SubProofReferent { pub sub_proof_index: u32, @@ -73,10 +60,10 @@ pub struct Identifier { pub timestamp: Option, } -impl Validatable for Proof {} - #[cfg(test)] mod tests { + use serde_json::json; + use super::*; #[test] diff --git a/libvdrtools/src/domain/anoncreds/proof_request.rs b/libvdrtools/src/domain/anoncreds/proof_request.rs index 0a67c1f417..f3b28ad616 100644 --- a/libvdrtools/src/domain/anoncreds/proof_request.rs +++ b/libvdrtools/src/domain/anoncreds/proof_request.rs @@ -1,8 +1,7 @@ use std::{collections::HashMap, fmt}; -use indy_api_types::validation::Validatable; use serde::{de, ser, Deserialize, Deserializer, Serialize, Serializer}; -use serde_json::Value; +use serde_json::{json, Value}; use ursa::cl::Nonce; use super::{ @@ -37,7 +36,7 @@ pub enum ProofRequestsVersion { } impl ProofRequest { - pub fn value<'a>(&'a self) -> &'a ProofRequestPayload { + pub fn value(&self) -> &ProofRequestPayload { match self { ProofRequest::ProofRequestV1(proof_req) => proof_req, ProofRequest::ProofRequestV2(proof_req) => proof_req, @@ -66,7 +65,7 @@ impl<'de> Deserialize<'de> for ProofRequest { let v = Value::deserialize(deserializer)?; let helper = Helper::deserialize(&v).map_err(de::Error::custom)?; - let nonce_cleaned = helper.nonce.replace(" ", "").replace("_", ""); + let nonce_cleaned = helper.nonce.replace([' ', '_'], ""); let proof_req = match helper.ver { Some(version) => match version.as_ref() { @@ -198,65 +197,6 @@ pub struct RequestedPredicateInfo { pub predicate_info: PredicateInfo, } -impl Validatable for ProofRequest { - fn validate(&self) -> Result<(), String> { - let value = self.value(); - let version = self.version(); - - if value.requested_attributes.is_empty() && value.requested_predicates.is_empty() { - return Err(String::from( - "Proof Request validation failed: both `requested_attributes` and \ - `requested_predicates` are empty", - )); - } - - for (_, requested_attribute) in value.requested_attributes.iter() { - let has_name = !requested_attribute - .name - .as_ref() - .map(String::is_empty) - .unwrap_or(true); - let has_names = !requested_attribute - .names - .as_ref() - .map(Vec::is_empty) - .unwrap_or(true); - if !has_name && !has_names { - return Err(format!( - "Proof Request validation failed: there is empty requested attribute: {:?}", - requested_attribute - )); - } - - if has_name && has_names { - return Err(format!( - "Proof request validation failed: there is a requested attribute with both \ - name and names: {:?}", - requested_attribute - )); - } - - if let Some(ref restrictions) = requested_attribute.restrictions { - _process_operator(&restrictions, &version)?; - } - } - - for (_, requested_predicate) in value.requested_predicates.iter() { - if requested_predicate.name.is_empty() { - return Err(format!( - "Proof Request validation failed: there is empty requested attribute: {:?}", - requested_predicate - )); - } - if let Some(ref restrictions) = requested_predicate.restrictions { - _process_operator(&restrictions, &version)?; - } - } - - Ok(()) - } -} - impl ProofRequest { pub fn to_unqualified(self) -> ProofRequest { let convert = |proof_request: &mut ProofRequestPayload| { @@ -264,13 +204,13 @@ impl ProofRequest { requested_attribute.restrictions = requested_attribute .restrictions .as_mut() - .map(|ref mut restrictions| _convert_query_to_unqualified(&restrictions)); + .map(|ref mut restrictions| _convert_query_to_unqualified(restrictions)); } for (_, requested_predicate) in proof_request.requested_predicates.iter_mut() { requested_predicate.restrictions = requested_predicate .restrictions .as_mut() - .map(|ref mut restrictions| _convert_query_to_unqualified(&restrictions)); + .map(|ref mut restrictions| _convert_query_to_unqualified(restrictions)); } }; @@ -307,13 +247,13 @@ fn _convert_query_to_unqualified(query: &Query) -> Query { Query::And(ref queries) => Query::And( queries .iter() - .map(|query| _convert_query_to_unqualified(query)) + .map(_convert_query_to_unqualified) .collect::>(), ), Query::Or(ref queries) => Query::Or( queries .iter() - .map(|query| _convert_query_to_unqualified(query)) + .map(_convert_query_to_unqualified) .collect::>(), ), Query::Not(ref query) => _convert_query_to_unqualified(query), diff --git a/libvdrtools/src/domain/anoncreds/requested_credential.rs b/libvdrtools/src/domain/anoncreds/requested_credential.rs index b135386d68..2f2ee0df53 100644 --- a/libvdrtools/src/domain/anoncreds/requested_credential.rs +++ b/libvdrtools/src/domain/anoncreds/requested_credential.rs @@ -1,7 +1,5 @@ use std::collections::HashMap; -use indy_api_types::validation::Validatable; - #[derive(Debug, Deserialize, Serialize)] pub struct RequestedCredentials { pub self_attested_attributes: HashMap, @@ -21,18 +19,3 @@ pub struct ProvingCredentialKey { pub cred_id: String, pub timestamp: Option, } - -impl Validatable for RequestedCredentials { - fn validate(&self) -> Result<(), String> { - if self.self_attested_attributes.is_empty() - && self.requested_attributes.is_empty() - && self.requested_predicates.is_empty() - { - return Err(String::from( - "Requested Credentials validation failed: `self_attested_attributes` and \ - `requested_attributes` and `requested_predicates` are empty", - )); - } - Ok(()) - } -} diff --git a/libvdrtools/src/domain/anoncreds/revocation_registry.rs b/libvdrtools/src/domain/anoncreds/revocation_registry.rs index 330166061e..f9a1042dd9 100644 --- a/libvdrtools/src/domain/anoncreds/revocation_registry.rs +++ b/libvdrtools/src/domain/anoncreds/revocation_registry.rs @@ -1,6 +1,5 @@ use std::collections::HashMap; -use indy_api_types::validation::Validatable; use ursa::cl::RevocationRegistry as CryptoRevocationRegistry; use super::revocation_registry_definition::RevocationRegistryId; @@ -41,5 +40,3 @@ pub fn rev_regs_map_to_rev_regs_local_map( }) .collect() } - -impl Validatable for RevocationRegistry {} diff --git a/libvdrtools/src/domain/anoncreds/revocation_registry_definition.rs b/libvdrtools/src/domain/anoncreds/revocation_registry_definition.rs index dcd678739d..003d0af9f6 100644 --- a/libvdrtools/src/domain/anoncreds/revocation_registry_definition.rs +++ b/libvdrtools/src/domain/anoncreds/revocation_registry_definition.rs @@ -1,9 +1,6 @@ use std::collections::{HashMap, HashSet}; -use indy_api_types::{ - errors::{err_msg, IndyErrorKind, IndyResult}, - validation::Validatable, -}; +use indy_api_types::errors::{err_msg, IndyErrorKind, IndyResult}; use lazy_static::lazy_static; use regex::Regex; use ursa::cl::{RevocationKeyPrivate, RevocationKeyPublic}; @@ -207,15 +204,14 @@ impl RevocationRegistryId { return Some(parts); } - match QUALIFIED_REV_REG_ID.captures(&self.0) { - Some(caps) => Some(( + QUALIFIED_REV_REG_ID.captures(&self.0).map(|caps| { + ( DidValue(caps["did"].to_string()), CredentialDefinitionId(caps["cred_def_id"].to_string()), caps["rev_reg_type"].to_string(), caps["tag"].to_string(), - )), - None => None, - } + ) + }) } pub fn to_unqualified(&self) -> RevocationRegistryId { @@ -232,41 +228,6 @@ impl RevocationRegistryId { } } -impl Validatable for RevocationRegistryConfig { - fn validate(&self) -> Result<(), String> { - if let Some(num_) = self.max_cred_num { - if num_ == 0 { - return Err(String::from( - "RevocationRegistryConfig validation failed: `max_cred_num` must be greater \ - than 0", - )); - } - } - Ok(()) - } -} - -impl Validatable for RevocationRegistryId { - fn validate(&self) -> Result<(), String> { - self.parts().ok_or(format!( - "Revocation Registry Id validation failed: {:?}, doesn't match pattern", - self.0 - ))?; - Ok(()) - } -} - -impl Validatable for RevocationRegistryDefinition { - fn validate(&self) -> Result<(), String> { - match self { - RevocationRegistryDefinition::RevocationRegistryDefinitionV1(revoc_reg_def) => { - revoc_reg_def.id.validate()?; - } - } - Ok(()) - } -} - #[cfg(test)] mod tests { use super::*; @@ -359,18 +320,4 @@ mod tests { assert_eq!(_tag(), tag); } } - - mod validate { - use super::*; - - #[test] - fn test_validate_rev_reg_id_as_unqualified() { - _rev_reg_id_unqualified().validate().unwrap(); - } - - #[test] - fn test_validate_rev_reg_id_as_fully_qualified() { - _rev_reg_id_qualified().validate().unwrap(); - } - } } diff --git a/libvdrtools/src/domain/anoncreds/revocation_registry_delta.rs b/libvdrtools/src/domain/anoncreds/revocation_registry_delta.rs index 3687ede8d5..f316d2cc6c 100644 --- a/libvdrtools/src/domain/anoncreds/revocation_registry_delta.rs +++ b/libvdrtools/src/domain/anoncreds/revocation_registry_delta.rs @@ -1,4 +1,3 @@ -use indy_api_types::validation::Validatable; use ursa::cl::RevocationRegistryDelta as RegistryDelta; #[derive(Debug, Clone, Serialize, Deserialize)] @@ -21,5 +20,3 @@ impl From for RevocationRegistryDeltaV1 { } } } - -impl Validatable for RevocationRegistryDelta {} diff --git a/libvdrtools/src/domain/anoncreds/revocation_state.rs b/libvdrtools/src/domain/anoncreds/revocation_state.rs deleted file mode 100644 index 7fef93a481..0000000000 --- a/libvdrtools/src/domain/anoncreds/revocation_state.rs +++ /dev/null @@ -1,24 +0,0 @@ -use std::collections::HashMap; - -use indy_api_types::validation::Validatable; -use ursa::cl::{RevocationRegistry, Witness}; - -#[derive(Clone, Debug, Serialize, Deserialize)] -pub struct RevocationState { - pub witness: Witness, - pub rev_reg: RevocationRegistry, - pub timestamp: u64, -} - -impl Validatable for RevocationState { - fn validate(&self) -> Result<(), String> { - if self.timestamp == 0 { - return Err(String::from( - "RevocationState validation failed: `timestamp` must be greater than 0", - )); - } - Ok(()) - } -} - -pub type RevocationStates = HashMap>; diff --git a/libvdrtools/src/domain/anoncreds/schema.rs b/libvdrtools/src/domain/anoncreds/schema.rs index deb73c130c..d2823b1f0d 100644 --- a/libvdrtools/src/domain/anoncreds/schema.rs +++ b/libvdrtools/src/domain/anoncreds/schema.rs @@ -2,7 +2,6 @@ use std::collections::{HashMap, HashSet}; use indy_api_types::{ errors::{IndyErrorKind, IndyResult}, - validation::Validatable, IndyError, }; @@ -60,10 +59,9 @@ pub fn schemas_map_to_schemas_v1_map(schemas: Schemas) -> HashMap); -#[allow(dead_code)] impl AttributeNames { pub fn new() -> Self { AttributeNames(HashSet::new()) @@ -76,54 +74,9 @@ impl From> for AttributeNames { } } -impl Into> for AttributeNames { - fn into(self) -> HashSet { - self.0 - } -} - -impl Validatable for Schema { - fn validate(&self) -> Result<(), String> { - match self { - 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(()) - } - } - } -} - -impl Validatable for AttributeNames { - fn validate(&self) -> Result<(), String> { - if self.0.is_empty() { - return Err(String::from( - "Empty list of Schema attributes has been passed", - )); - } - - if self.0.len() > MAX_ATTRIBUTES_COUNT { - return Err(format!( - "The number of Schema attributes {} cannot be greater than {}", - self.0.len(), - MAX_ATTRIBUTES_COUNT - )); - } - Ok(()) +impl From for HashSet { + fn from(value: AttributeNames) -> HashSet { + value.0 } } @@ -213,21 +166,6 @@ impl SchemaId { } } -impl Validatable for SchemaId { - fn validate(&self) -> Result<(), String> { - if self.0.parse::().is_ok() { - return Ok(()); - } - - self.parts().ok_or(format!( - "SchemaId validation failed: {:?}, doesn't match pattern", - self.0 - ))?; - - Ok(()) - } -} - #[cfg(test)] mod tests { use super::*; @@ -314,89 +252,4 @@ mod tests { assert!(_schema_id_invalid().parts().is_none()); } } - - mod validate { - use super::*; - - #[test] - fn test_validate_schema_id_as_seq_no() { - _schema_id_seq_no().validate().unwrap(); - } - - #[test] - fn test_validate_schema_id_as_unqualified() { - _schema_id_unqualified().validate().unwrap(); - } - - #[test] - fn test_validate_schema_id_as_fully_qualified() { - _schema_id_qualified().validate().unwrap(); - } - - #[test] - fn test_validate_schema_id_for_invalid_unqualified() { - _schema_id_invalid().validate().unwrap_err(); - } - - #[test] - fn test_validate_schema_id_for_invalid_fully_qualified() { - let id = SchemaId("schema:sov:NcYxiDXkpYi6ov5FcYDi1e:2:1.0".to_string()); - 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(); - } - } } diff --git a/libvdrtools/src/domain/crypto/did.rs b/libvdrtools/src/domain/crypto/did.rs index 3697df2990..9c48c7cf08 100644 --- a/libvdrtools/src/domain/crypto/did.rs +++ b/libvdrtools/src/domain/crypto/did.rs @@ -1,30 +1,10 @@ -use indy_api_types::{ - errors::{IndyError, IndyErrorKind, IndyResult}, - validation::Validatable, -}; -use lazy_static::lazy_static; -use regex::Regex; +use indy_api_types::errors::{IndyError, IndyErrorKind, IndyResult}; use crate::utils::qualifier; #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash)] pub struct DidMethod(pub String); -impl Validatable for DidMethod { - fn validate(&self) -> Result<(), String> { - lazy_static! { - static ref REGEX_METHOD_NAME: Regex = Regex::new("^[a-z0-9:]+$").unwrap(); - } - if !REGEX_METHOD_NAME.is_match(&self.0) { - return Err(format!( - "Invalid default name: {}. It does not match the DID method name format.", - self.0 - )); - } - Ok(()) - } -} - #[derive(Serialize, Deserialize, Clone, Debug, Default)] pub struct MyDidInfo { pub did: Option, @@ -35,18 +15,6 @@ pub struct MyDidInfo { pub ledger_type: Option, } -impl Validatable for MyDidInfo { - fn validate(&self) -> Result<(), String> { - if let Some(ref did) = self.did { - did.validate()?; - } - if let Some(ref name) = self.method_name { - name.validate()? - } - Ok(()) - } -} - #[derive(Debug, Serialize, Deserialize, Clone)] pub struct TheirDidInfo { pub did: DidValue, @@ -59,13 +27,6 @@ impl TheirDidInfo { } } -impl Validatable for TheirDidInfo { - fn validate(&self) -> Result<(), String> { - self.did.validate()?; - Ok(()) - } -} - #[derive(Serialize, Deserialize, Clone, Debug)] pub struct Did { pub did: DidValue, @@ -88,7 +49,7 @@ impl DidValue { (Some(ledger_type_), Some(method_)) => { Ok(DidValue(did.to_string()).set_ledger_and_method(ledger_type_, method_)) } - (None, Some(method_)) => Ok(DidValue(did.to_string()).set_method(&method_)), + (None, Some(method_)) => Ok(DidValue(did.to_string()).set_method(method_)), (None, None) => Ok(DidValue(did.to_string())), (Some(_), None) => Err(IndyError::from_msg( IndyErrorKind::InvalidStructure, @@ -102,7 +63,7 @@ impl DidValue { } pub fn qualify(&self, method: &str) -> DidValue { - self.set_method(&method) + self.set_method(method) } pub fn to_unqualified(&self) -> DidValue { @@ -118,27 +79,6 @@ impl DidValue { } } -impl Validatable for DidValue { - fn validate(&self) -> Result<(), String> { - if self.is_fully_qualified() { - // pass - } else { - let did = bs58::decode(&self.0) - .into_vec() - .map_err(|err| err.to_string())?; - - if did.len() != 16 && did.len() != 32 { - return Err(format!( - "Trying to use DID with unexpected length: {}. The 16- or 32-byte number upon \ - which a DID is based should be 22/23 or 44/45 bytes when encoded as base58.", - did.len() - )); - } - } - Ok(()) - } -} - qualifiable_type!(ShortDidValue); impl ShortDidValue { @@ -152,23 +92,6 @@ impl ShortDidValue { } } -impl Validatable for ShortDidValue { - fn validate(&self) -> Result<(), String> { - let did = bs58::decode(&self.0) - .into_vec() - .map_err(|err| err.to_string())?; - - if did.len() != 16 && did.len() != 32 { - return Err(format!( - "Trying to use DID with unexpected length: {}. The 16- or 32-byte number upon \ - which a DID is based should be 22/23 or 44/45 bytes when encoded as base58.", - did.len() - )); - } - Ok(()) - } -} - #[derive(Serialize, Deserialize, Debug)] pub struct DidMetadata { pub value: String, diff --git a/libvdrtools/src/domain/ledger/attrib.rs b/libvdrtools/src/domain/ledger/attrib.rs deleted file mode 100644 index b95906d8c0..0000000000 --- a/libvdrtools/src/domain/ledger/attrib.rs +++ /dev/null @@ -1,106 +0,0 @@ -use super::{ - super::crypto::did::ShortDidValue, - constants::{ATTRIB, GET_ATTR}, - response::GetReplyResultV1, -}; - -#[derive(Serialize, PartialEq, Debug)] -pub struct AttribOperation { - #[serde(rename = "type")] - pub _type: String, - pub dest: ShortDidValue, - #[serde(skip_serializing_if = "Option::is_none")] - pub hash: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub raw: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub enc: Option, -} - -impl AttribOperation { - pub fn new( - dest: ShortDidValue, - hash: Option, - raw: Option, - enc: Option, - ) -> AttribOperation { - AttribOperation { - _type: ATTRIB.to_string(), - dest, - hash, - raw, - enc, - } - } -} - -#[derive(Serialize, PartialEq, Debug)] -pub struct GetAttribOperation { - #[serde(rename = "type")] - pub _type: String, - pub dest: ShortDidValue, - #[serde(skip_serializing_if = "Option::is_none")] - pub raw: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub hash: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub enc: Option, -} - -impl GetAttribOperation { - pub fn new( - dest: ShortDidValue, - raw: Option<&str>, - hash: Option<&str>, - enc: Option<&str>, - ) -> GetAttribOperation { - GetAttribOperation { - _type: GET_ATTR.to_string(), - dest, - raw: raw.map(String::from), - hash: hash.map(String::from), - enc: enc.map(String::from), - } - } -} - -#[derive(Debug, Deserialize)] -#[serde(untagged)] -pub enum GetAttrReplyResult { - GetAttrReplyResultV0(GetAttResultV0), - GetAttrReplyResultV1(GetReplyResultV1), -} - -#[derive(Deserialize, Eq, PartialEq, Debug)] -#[serde(rename_all = "camelCase")] -pub struct GetAttResultV0 { - pub identifier: ShortDidValue, - pub data: String, - pub dest: ShortDidValue, - pub raw: String, -} - -#[derive(Deserialize, Eq, PartialEq, Debug)] -pub struct GetAttResultDataV1 { - pub ver: String, - pub id: String, - pub did: ShortDidValue, - pub raw: String, -} - -#[derive(Deserialize, Debug)] -pub struct AttribData { - pub endpoint: Endpoint, -} - -#[derive(Serialize, Deserialize, Clone, Debug)] -pub struct Endpoint { - pub ha: String, // indy-node and indy-plenum restrict this to ip-address:port - pub verkey: Option, -} - -impl Endpoint { - pub fn new(ha: String, verkey: Option) -> Endpoint { - Endpoint { ha, verkey } - } -} diff --git a/libvdrtools/src/domain/ledger/auth_rule.rs b/libvdrtools/src/domain/ledger/auth_rule.rs deleted file mode 100644 index 69a6d044c2..0000000000 --- a/libvdrtools/src/domain/ledger/auth_rule.rs +++ /dev/null @@ -1,261 +0,0 @@ -use std::ops::Not; - -use serde_json::Value; - -use super::constants::{AUTH_RULE, AUTH_RULES, GET_AUTH_RULE}; - -#[allow(non_camel_case_types)] -#[derive(Deserialize, Debug, Serialize, PartialEq)] -pub enum AuthAction { - ADD, - EDIT, -} - -/** - Enum of the constraint type within the GAT_AUTH_RULE result data - # parameters - Role - The final constraint - And - Combine multiple constraints all of them must be met - Or - Combine multiple constraints any of them must be met - Forbidden - action is forbidden -*/ -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] -#[serde(tag = "constraint_id")] -pub enum Constraint { - #[serde(rename = "OR")] - OrConstraint(CombinationConstraint), - #[serde(rename = "AND")] - AndConstraint(CombinationConstraint), - #[serde(rename = "ROLE")] - RoleConstraint(RoleConstraint), - #[serde(rename = "FORBIDDEN")] - ForbiddenConstraint(ForbiddenConstraint), -} - -/** - The final constraint - # parameters - sig_count - The number of signatures required to execution action - role - The role which the user must have to execute the action. - metadata - An additional parameters of the constraint (contains transaction FEE cost). - need_to_be_owner - The flag specifying if a user must be an owner of the transaction (false by default) . - off_ledger_signature - allow signature of unknow for ledger did (false by default). -*/ -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] -pub struct RoleConstraint { - pub sig_count: u32, - pub role: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub metadata: Option, - #[serde(default)] - pub need_to_be_owner: bool, - #[serde(default)] - #[serde(skip_serializing_if = "Not::not")] - pub off_ledger_signature: bool, -} - -/** - Combine multiple constraints - # parameters - auth_constraints - The type of the combination -*/ -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] -pub struct CombinationConstraint { - pub auth_constraints: Vec, -} - -/** - The forbidden constraint means that action is forbidden -*/ -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] -#[serde(deny_unknown_fields)] -pub struct ForbiddenConstraint {} - -#[derive(Serialize, PartialEq, Debug)] -#[serde(untagged)] -pub enum AuthRuleOperation { - Add(AddAuthRuleOperation), - Edit(EditAuthRuleOperation), -} - -#[derive(Serialize, PartialEq, Debug)] -pub struct AddAuthRuleOperation { - #[serde(rename = "type")] - pub _type: String, - pub auth_type: String, - pub field: String, - pub auth_action: AuthAction, - pub new_value: Option, - pub constraint: Constraint, -} - -#[derive(Serialize, PartialEq, Debug)] -pub struct EditAuthRuleOperation { - #[serde(rename = "type")] - pub _type: String, - pub auth_type: String, - pub field: String, - pub auth_action: AuthAction, - pub old_value: Option, - pub new_value: Option, - pub constraint: Constraint, -} - -impl AuthRuleOperation { - pub fn new( - auth_type: String, - field: String, - auth_action: AuthAction, - old_value: Option, - new_value: Option, - constraint: Constraint, - ) -> AuthRuleOperation { - match auth_action { - AuthAction::ADD => AuthRuleOperation::Add(AddAuthRuleOperation { - _type: AUTH_RULE.to_string(), - auth_type, - field, - auth_action, - new_value, - constraint, - }), - AuthAction::EDIT => AuthRuleOperation::Edit(EditAuthRuleOperation { - _type: AUTH_RULE.to_string(), - auth_type, - field, - auth_action, - old_value, - new_value, - constraint, - }), - } - } -} - -#[derive(Serialize, PartialEq, Debug)] -#[serde(untagged)] -pub enum GetAuthRuleOperation { - All(GetAllAuthRuleOperation), - Add(GetAddAuthRuleOperation), - Edit(GetEditAuthRuleOperation), -} - -#[derive(Serialize, PartialEq, Debug)] -pub struct GetAllAuthRuleOperation { - #[serde(rename = "type")] - pub _type: String, -} - -#[derive(Serialize, PartialEq, Debug)] -pub struct GetAddAuthRuleOperation { - #[serde(rename = "type")] - pub _type: String, - pub auth_type: String, - pub field: String, - pub auth_action: AuthAction, - pub new_value: Option, -} - -#[derive(Serialize, PartialEq, Debug)] -pub struct GetEditAuthRuleOperation { - #[serde(rename = "type")] - pub _type: String, - pub auth_type: String, - pub field: String, - pub auth_action: AuthAction, - pub old_value: Option, - pub new_value: Option, -} - -impl GetAuthRuleOperation { - pub fn get_all() -> GetAuthRuleOperation { - GetAuthRuleOperation::All(GetAllAuthRuleOperation { - _type: GET_AUTH_RULE.to_string(), - }) - } - - pub fn get_one( - auth_type: String, - field: String, - auth_action: AuthAction, - old_value: Option, - new_value: Option, - ) -> GetAuthRuleOperation { - match auth_action { - AuthAction::ADD => GetAuthRuleOperation::Add(GetAddAuthRuleOperation { - _type: GET_AUTH_RULE.to_string(), - auth_type, - field, - auth_action, - new_value, - }), - AuthAction::EDIT => GetAuthRuleOperation::Edit(GetEditAuthRuleOperation { - _type: GET_AUTH_RULE.to_string(), - auth_type, - field, - auth_action, - old_value, - new_value, - }), - } - } -} - -pub type AuthRules = Vec; - -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] -#[serde(tag = "auth_action")] -pub enum AuthRuleData { - #[serde(rename = "ADD")] - Add(AddAuthRuleData), - #[serde(rename = "EDIT")] - Edit(EditAuthRuleData), -} - -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] -pub struct AddAuthRuleData { - pub auth_type: String, - pub field: String, - pub new_value: Option, - pub constraint: Constraint, -} - -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] -pub struct EditAuthRuleData { - pub auth_type: String, - pub field: String, - pub old_value: Option, - pub new_value: Option, - pub constraint: Constraint, -} - -#[derive(Serialize, Deserialize, PartialEq, Debug)] -pub struct GetAuthRuleResult { - pub data: Vec, -} - -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] -pub struct AuthRule { - pub auth_type: String, - pub auth_action: String, - pub field: String, - pub old_value: Option, - pub new_value: Option, - pub constraint: Constraint, -} - -#[derive(Serialize, PartialEq, Debug)] -pub struct AuthRulesOperation { - #[serde(rename = "type")] - pub _type: String, - pub rules: AuthRules, -} - -impl AuthRulesOperation { - pub fn new(rules: AuthRules) -> AuthRulesOperation { - AuthRulesOperation { - _type: AUTH_RULES.to_string(), - rules, - } - } -} diff --git a/libvdrtools/src/domain/ledger/author_agreement.rs b/libvdrtools/src/domain/ledger/author_agreement.rs deleted file mode 100644 index 1a986f9784..0000000000 --- a/libvdrtools/src/domain/ledger/author_agreement.rs +++ /dev/null @@ -1,168 +0,0 @@ -use std::collections::HashMap; - -use indy_api_types::validation::Validatable; - -use super::constants::{ - DISABLE_ALL_TXN_AUTHR_AGRMTS, GET_TXN_AUTHR_AGRMT, GET_TXN_AUTHR_AGRMT_AML, TXN_AUTHR_AGRMT, - TXN_AUTHR_AGRMT_AML, -}; - -#[derive(Serialize, PartialEq, Debug)] -pub struct TxnAuthorAgreementOperation { - #[serde(rename = "type")] - _type: String, - #[serde(skip_serializing_if = "Option::is_none")] - text: Option, - version: String, - #[serde(skip_serializing_if = "Option::is_none")] - ratification_ts: Option, - #[serde(skip_serializing_if = "Option::is_none")] - retirement_ts: Option, -} - -impl TxnAuthorAgreementOperation { - pub fn new( - text: Option, - version: String, - ratification_ts: Option, - retirement_ts: Option, - ) -> TxnAuthorAgreementOperation { - TxnAuthorAgreementOperation { - _type: TXN_AUTHR_AGRMT.to_string(), - text, - version, - ratification_ts, - retirement_ts, - } - } -} - -#[derive(Serialize, PartialEq, Debug)] -pub struct DisableAllTxnAuthorAgreementsOperation { - #[serde(rename = "type")] - _type: String, -} - -impl DisableAllTxnAuthorAgreementsOperation { - pub fn new() -> DisableAllTxnAuthorAgreementsOperation { - DisableAllTxnAuthorAgreementsOperation { - _type: DISABLE_ALL_TXN_AUTHR_AGRMTS.to_string(), - } - } -} - -#[derive(Deserialize, PartialEq, Debug)] -pub struct GetTxnAuthorAgreementData { - pub digest: Option, - pub version: Option, - pub timestamp: Option, -} - -impl Validatable for GetTxnAuthorAgreementData { - fn validate(&self) -> Result<(), String> { - match ( - self.digest.as_ref(), - self.version.as_ref(), - self.timestamp.as_ref(), - ) { - (Some(_), None, None) => Ok(()), - (None, Some(_), None) => Ok(()), - (None, None, Some(_)) => Ok(()), - (None, None, None) => Ok(()), - (digest, version, timestamp) => Err(format!( - "Only one of field can be specified: digest: {:?}, version: {:?}, timestamp: {:?}", - digest, version, timestamp - )), - } - } -} - -#[derive(Serialize, PartialEq, Debug)] -pub struct GetTxnAuthorAgreementOperation { - #[serde(rename = "type")] - _type: String, - #[serde(skip_serializing_if = "Option::is_none")] - digest: Option, - #[serde(skip_serializing_if = "Option::is_none")] - version: Option, - #[serde(skip_serializing_if = "Option::is_none")] - timestamp: Option, -} - -impl GetTxnAuthorAgreementOperation { - pub fn new(data: Option<&GetTxnAuthorAgreementData>) -> GetTxnAuthorAgreementOperation { - GetTxnAuthorAgreementOperation { - _type: GET_TXN_AUTHR_AGRMT.to_string(), - digest: data.as_ref().and_then(|d| d.digest.clone()), - version: data.as_ref().and_then(|d| d.version.clone()), - timestamp: data.as_ref().and_then(|d| d.timestamp), - } - } -} - -#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)] -pub struct AcceptanceMechanisms(pub HashMap); - -impl AcceptanceMechanisms { - #[allow(dead_code)] - pub fn new() -> Self { - AcceptanceMechanisms(HashMap::new()) - } -} - -impl Validatable for AcceptanceMechanisms { - fn validate(&self) -> Result<(), String> { - if self.0.is_empty() { - return Err(String::from( - "Empty list of Acceptance Mechanisms has been passed", - )); - } - Ok(()) - } -} - -#[derive(Serialize, PartialEq, Debug)] -#[serde(rename_all = "camelCase")] -pub struct SetAcceptanceMechanismOperation { - #[serde(rename = "type")] - _type: String, - aml: AcceptanceMechanisms, - version: String, - #[serde(skip_serializing_if = "Option::is_none")] - aml_context: Option, -} - -impl SetAcceptanceMechanismOperation { - pub fn new( - aml: AcceptanceMechanisms, - version: String, - aml_context: Option, - ) -> SetAcceptanceMechanismOperation { - SetAcceptanceMechanismOperation { - _type: TXN_AUTHR_AGRMT_AML.to_string(), - aml, - version, - aml_context, - } - } -} - -#[derive(Serialize, PartialEq, Debug)] -pub struct GetAcceptanceMechanismOperation { - #[serde(rename = "type")] - _type: String, - #[serde(skip_serializing_if = "Option::is_none")] - timestamp: Option, - #[serde(skip_serializing_if = "Option::is_none")] - version: Option, -} - -impl GetAcceptanceMechanismOperation { - pub fn new(timestamp: Option, version: Option) -> GetAcceptanceMechanismOperation { - GetAcceptanceMechanismOperation { - _type: GET_TXN_AUTHR_AGRMT_AML.to_string(), - timestamp, - version, - } - } -} diff --git a/libvdrtools/src/domain/ledger/constants.rs b/libvdrtools/src/domain/ledger/constants.rs deleted file mode 100644 index ec1b38b65e..0000000000 --- a/libvdrtools/src/domain/ledger/constants.rs +++ /dev/null @@ -1,99 +0,0 @@ -pub const NODE: &str = "0"; -pub const NYM: &str = "1"; -pub const GET_TXN: &str = "3"; -pub const TXN_AUTHR_AGRMT: &str = "4"; // TODO Use nonabbreviated names as in updated design -pub const TXN_AUTHR_AGRMT_AML: &str = "5"; -pub const GET_TXN_AUTHR_AGRMT: &str = "6"; -pub const GET_TXN_AUTHR_AGRMT_AML: &str = "7"; -pub const DISABLE_ALL_TXN_AUTHR_AGRMTS: &str = "8"; -pub const ATTRIB: &str = "100"; -pub const SCHEMA: &str = "101"; -pub const CRED_DEF: &str = "102"; -pub const GET_ATTR: &str = "104"; -pub const GET_NYM: &str = "105"; -pub const GET_SCHEMA: &str = "107"; -pub const GET_CRED_DEF: &str = "108"; -pub const POOL_UPGRADE: &str = "109"; -pub const POOL_RESTART: &str = "118"; -pub const POOL_CONFIG: &str = "111"; -pub const REVOC_REG_DEF: &str = "113"; -pub const REVOC_REG_ENTRY: &str = "114"; -pub const GET_REVOC_REG_DEF: &str = "115"; -pub const GET_REVOC_REG: &str = "116"; -pub const GET_REVOC_REG_DELTA: &str = "117"; -pub const GET_VALIDATOR_INFO: &str = "119"; -pub const AUTH_RULE: &str = "120"; -pub const GET_AUTH_RULE: &str = "121"; -pub const AUTH_RULES: &str = "122"; -pub const GET_DDO: &str = "120"; //TODO change number - -pub const REQUESTS: [&str; 25] = [ - NODE, - NYM, - GET_TXN, - ATTRIB, - SCHEMA, - CRED_DEF, - GET_ATTR, - GET_NYM, - GET_SCHEMA, - GET_CRED_DEF, - POOL_UPGRADE, - POOL_RESTART, - POOL_CONFIG, - REVOC_REG_DEF, - REVOC_REG_ENTRY, - GET_REVOC_REG_DEF, - GET_REVOC_REG, - GET_REVOC_REG_DELTA, - GET_VALIDATOR_INFO, - AUTH_RULE, - GET_DDO, - TXN_AUTHR_AGRMT, - TXN_AUTHR_AGRMT_AML, - GET_TXN_AUTHR_AGRMT, - GET_TXN_AUTHR_AGRMT_AML, -]; - -pub const TRUSTEE: &str = "0"; -pub const STEWARD: &str = "2"; -pub const ENDORSER: &str = "101"; -pub const NETWORK_MONITOR: &str = "201"; -pub const ROLE_REMOVE: &str = ""; - -pub const ROLES: [&str; 4] = [TRUSTEE, STEWARD, ENDORSER, NETWORK_MONITOR]; - -pub fn txn_name_to_code(txn: &str) -> Option<&str> { - if REQUESTS.contains(&txn) { - return Some(txn); - } - - match txn { - "NODE" => Some(NODE), - "NYM" => Some(NYM), - "GET_TXN" => Some(GET_TXN), - "ATTRIB" => Some(ATTRIB), - "SCHEMA" => Some(SCHEMA), - "CRED_DEF" | "CLAIM_DEF" => Some(CRED_DEF), - "GET_ATTR" => Some(GET_ATTR), - "GET_NYM" => Some(GET_NYM), - "GET_SCHEMA" => Some(GET_SCHEMA), - "GET_CRED_DEF" => Some(GET_CRED_DEF), - "POOL_UPGRADE" => Some(POOL_UPGRADE), - "POOL_RESTART" => Some(POOL_RESTART), - "POOL_CONFIG" => Some(POOL_CONFIG), - "REVOC_REG_DEF" => Some(REVOC_REG_DEF), - "REVOC_REG_ENTRY" => Some(REVOC_REG_ENTRY), - "GET_REVOC_REG_DEF" => Some(GET_REVOC_REG_DEF), - "GET_REVOC_REG" => Some(GET_REVOC_REG), - "GET_REVOC_REG_DELTA" => Some(GET_REVOC_REG_DELTA), - "GET_VALIDATOR_INFO" => Some(GET_VALIDATOR_INFO), - "AUTH_RULE" => Some(AUTH_RULE), - "GET_DDO" => Some(GET_DDO), - "TXN_AUTHR_AGRMT" => Some(TXN_AUTHR_AGRMT), - "TXN_AUTHR_AGRMT_AML" => Some(TXN_AUTHR_AGRMT_AML), - "GET_TXN_AUTHR_AGRMT" => Some(GET_TXN_AUTHR_AGRMT), - "GET_TXN_AUTHR_AGRMT_AML" => Some(GET_TXN_AUTHR_AGRMT_AML), - val => Some(val), - } -} diff --git a/libvdrtools/src/domain/ledger/cred_def.rs b/libvdrtools/src/domain/ledger/cred_def.rs deleted file mode 100644 index 34bf36c1c5..0000000000 --- a/libvdrtools/src/domain/ledger/cred_def.rs +++ /dev/null @@ -1,110 +0,0 @@ -use super::{ - super::{ - anoncreds::{ - credential_definition::{ - CredentialDefinitionData, CredentialDefinitionId, CredentialDefinitionV1, - SignatureType, - }, - schema::SchemaId, - }, - crypto::did::ShortDidValue, - ledger::request::ProtocolVersion, - }, - constants::{CRED_DEF, GET_CRED_DEF}, - response::{GetReplyResultV1, ReplyType}, -}; - -#[derive(Serialize, Debug)] -pub struct CredDefOperation { - #[serde(rename = "ref")] - pub _ref: i32, - pub data: CredentialDefinitionData, - #[serde(rename = "type")] - pub _type: String, - pub signature_type: String, - #[serde(skip_serializing_if = "Option::is_none")] - pub tag: Option, -} - -impl CredDefOperation { - pub fn new(data: CredentialDefinitionV1) -> CredDefOperation { - CredDefOperation { - _ref: data.schema_id.0.parse::().unwrap_or(0), - signature_type: data.signature_type.to_str().to_string(), - data: data.value, - tag: if ProtocolVersion::is_node_1_3() { - None - } else { - Some(data.tag.clone()) - }, - _type: CRED_DEF.to_string(), - } - } -} - -#[derive(Serialize, PartialEq, Debug)] -pub struct GetCredDefOperation { - #[serde(rename = "type")] - pub _type: String, - #[serde(rename = "ref")] - pub _ref: i32, - pub signature_type: String, - pub origin: ShortDidValue, - #[serde(skip_serializing_if = "Option::is_none")] - pub tag: Option, -} - -impl GetCredDefOperation { - pub fn new( - _ref: i32, - signature_type: String, - origin: ShortDidValue, - tag: Option, - ) -> GetCredDefOperation { - GetCredDefOperation { - _type: GET_CRED_DEF.to_string(), - _ref, - signature_type, - origin, - tag, - } - } -} - -#[derive(Debug, Deserialize)] -#[serde(untagged)] -pub enum GetCredDefReplyResult { - GetCredDefReplyResultV0(GetCredDefResultV0), - GetCredDefReplyResultV1(GetReplyResultV1), -} - -impl ReplyType for GetCredDefReplyResult { - fn get_type<'a>() -> &'a str { - GET_CRED_DEF - } -} - -#[derive(Deserialize, Serialize, Debug)] -pub struct GetCredDefResultV0 { - pub identifier: ShortDidValue, - #[serde(rename = "ref")] - pub ref_: u64, - #[serde(rename = "seqNo")] - pub seq_no: i32, - pub signature_type: SignatureType, - pub origin: ShortDidValue, - pub tag: Option, - pub data: CredentialDefinitionData, -} - -#[derive(Deserialize, Debug)] -#[serde(rename_all = "camelCase")] -pub struct GetCredDefResultDataV1 { - pub ver: String, - pub id: CredentialDefinitionId, - #[serde(rename = "type")] - pub type_: SignatureType, - pub tag: String, - pub schema_ref: SchemaId, - pub public_keys: CredentialDefinitionData, -} diff --git a/libvdrtools/src/domain/ledger/ddo.rs b/libvdrtools/src/domain/ledger/ddo.rs deleted file mode 100644 index 827b3e74ea..0000000000 --- a/libvdrtools/src/domain/ledger/ddo.rs +++ /dev/null @@ -1,17 +0,0 @@ -use super::{super::crypto::did::ShortDidValue, constants::GET_DDO}; - -#[derive(Serialize, PartialEq, Debug)] -pub struct GetDdoOperation { - #[serde(rename = "type")] - pub _type: String, - pub dest: ShortDidValue, -} - -impl GetDdoOperation { - pub fn new(dest: ShortDidValue) -> GetDdoOperation { - GetDdoOperation { - _type: GET_DDO.to_string(), - dest, - } - } -} diff --git a/libvdrtools/src/domain/ledger/did.rs b/libvdrtools/src/domain/ledger/did.rs deleted file mode 100644 index a2d175df38..0000000000 --- a/libvdrtools/src/domain/ledger/did.rs +++ /dev/null @@ -1,99 +0,0 @@ -use super::{ - super::crypto::did::{DidValue, ShortDidValue}, - constants::{GET_NYM, NYM}, - response::{GetReplyResultV0, GetReplyResultV1, ReplyType}, -}; - -#[derive(Serialize, PartialEq, Debug)] -pub struct NymOperation { - #[serde(rename = "type")] - pub _type: String, - pub dest: ShortDidValue, - #[serde(skip_serializing_if = "Option::is_none")] - pub verkey: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub alias: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub role: Option<::serde_json::Value>, -} - -impl NymOperation { - pub fn new( - dest: ShortDidValue, - verkey: Option, - alias: Option, - role: Option<::serde_json::Value>, - ) -> NymOperation { - NymOperation { - _type: NYM.to_string(), - dest, - verkey, - alias, - role, - } - } -} - -#[derive(Serialize, PartialEq, Debug)] -pub struct GetNymOperation { - #[serde(rename = "type")] - pub _type: String, - pub dest: ShortDidValue, -} - -impl GetNymOperation { - pub fn new(dest: ShortDidValue) -> GetNymOperation { - GetNymOperation { - _type: GET_NYM.to_string(), - dest, - } - } -} - -#[derive(Debug, Deserialize)] -#[serde(untagged)] -pub enum GetNymReplyResult { - GetNymReplyResultV0(GetReplyResultV0), - GetNymReplyResultV1(GetReplyResultV1), -} - -impl ReplyType for GetNymReplyResult { - fn get_type<'a>() -> &'a str { - GET_NYM - } -} - -#[derive(Deserialize, Eq, PartialEq, Debug)] -pub struct GetNymResultDataV0 { - pub identifier: Option, - pub dest: ShortDidValue, - pub role: Option, - pub verkey: Option, -} - -#[derive(Deserialize, Eq, PartialEq, Debug)] -pub struct GetNymResultDataV1 { - pub ver: String, - pub id: String, - pub did: ShortDidValue, - pub verkey: Option, - pub role: Option, -} - -#[derive(Serialize, Deserialize, Eq, PartialEq, Debug)] -pub struct NymData { - pub did: ShortDidValue, - pub verkey: Option, - pub role: Option, -} - -#[derive(Serialize, Deserialize, Eq, PartialEq, Debug)] -pub struct NymTxnParams { - pub dest: DidValue, - #[serde(skip_serializing_if = "Option::is_none")] - pub verkey: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub alias: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub role: Option, -} diff --git a/libvdrtools/src/domain/ledger/mod.rs b/libvdrtools/src/domain/ledger/mod.rs deleted file mode 100644 index ca6b1e1160..0000000000 --- a/libvdrtools/src/domain/ledger/mod.rs +++ /dev/null @@ -1,16 +0,0 @@ -pub mod attrib; -pub mod auth_rule; -pub mod author_agreement; -pub mod constants; -pub mod cred_def; -pub mod ddo; -pub mod did; -pub mod node; -pub mod pool; -pub mod request; -pub mod response; -pub mod rev_reg; -pub mod rev_reg_def; -pub mod schema; -pub mod txn; -pub mod validator_info; diff --git a/libvdrtools/src/domain/ledger/node.rs b/libvdrtools/src/domain/ledger/node.rs deleted file mode 100644 index fb025f7c7c..0000000000 --- a/libvdrtools/src/domain/ledger/node.rs +++ /dev/null @@ -1,78 +0,0 @@ -use indy_api_types::validation::Validatable; - -use super::{super::crypto::did::ShortDidValue, constants::NODE}; - -#[derive(Serialize, PartialEq, Debug)] -pub struct NodeOperation { - #[serde(rename = "type")] - pub _type: String, - pub dest: ShortDidValue, - pub data: NodeOperationData, -} - -impl NodeOperation { - pub fn new(dest: ShortDidValue, data: NodeOperationData) -> NodeOperation { - NodeOperation { - _type: NODE.to_string(), - dest, - data, - } - } -} - -#[derive(Serialize, PartialEq, Debug, Deserialize)] -pub enum Services { - VALIDATOR, - OBSERVER, -} - -#[derive(Serialize, PartialEq, Debug, Deserialize)] -pub struct NodeOperationData { - #[serde(skip_serializing_if = "Option::is_none")] - pub node_ip: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub node_port: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub client_ip: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub client_port: Option, - pub alias: String, - #[serde(skip_serializing_if = "Option::is_none")] - pub services: Option>, - #[serde(skip_serializing_if = "Option::is_none")] - pub blskey: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub blskey_pop: Option, -} - -impl Validatable for NodeOperationData { - fn validate(&self) -> Result<(), String> { - if self.node_ip.is_none() - && self.node_port.is_none() - && self.client_ip.is_none() - && self.client_port.is_none() - && self.services.is_none() - && self.blskey.is_none() - && self.blskey_pop.is_none() - { - return Err(String::from("Invalid data json: all fields missed at once")); - } - - if (self.node_ip.is_some() - || self.node_port.is_some() - || self.client_ip.is_some() - || self.client_port.is_some()) - && (self.node_ip.is_none() - || self.node_port.is_none() - || self.client_ip.is_none() - || self.client_port.is_none()) - { - return Err(String::from( - "Invalid data json: Fields node_ip, node_port, client_ip, client_port must be \ - specified together", - )); - } - - Ok(()) - } -} diff --git a/libvdrtools/src/domain/ledger/pool.rs b/libvdrtools/src/domain/ledger/pool.rs deleted file mode 100644 index 1e19bfb2cd..0000000000 --- a/libvdrtools/src/domain/ledger/pool.rs +++ /dev/null @@ -1,93 +0,0 @@ -use std::collections::HashMap; - -use super::constants::{POOL_CONFIG, POOL_RESTART, POOL_UPGRADE}; - -#[derive(Serialize, PartialEq, Debug)] -pub struct PoolConfigOperation { - #[serde(rename = "type")] - pub _type: String, - pub writes: bool, - pub force: bool, -} - -impl PoolConfigOperation { - pub fn new(writes: bool, force: bool) -> PoolConfigOperation { - PoolConfigOperation { - _type: POOL_CONFIG.to_string(), - writes, - force, - } - } -} - -#[derive(Serialize, PartialEq, Debug)] -pub struct PoolRestartOperation { - #[serde(rename = "type")] - pub _type: String, - pub action: String, - //start, cancel - #[serde(skip_serializing_if = "Option::is_none")] - pub datetime: Option, -} - -impl PoolRestartOperation { - pub fn new(action: &str, datetime: Option) -> PoolRestartOperation { - PoolRestartOperation { - _type: POOL_RESTART.to_string(), - action: action.to_string(), - datetime, - } - } -} - -#[derive(Serialize, PartialEq, Debug)] -pub struct PoolUpgradeOperation { - #[serde(rename = "type")] - pub _type: String, - pub name: String, - pub version: String, - pub action: String, - //start, cancel - pub sha256: String, - #[serde(skip_serializing_if = "Option::is_none")] - pub timeout: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub schedule: Option>, - #[serde(skip_serializing_if = "Option::is_none")] - pub justification: Option, - pub reinstall: bool, - pub force: bool, - #[serde(skip_serializing_if = "Option::is_none")] - pub package: Option, -} - -impl PoolUpgradeOperation { - pub fn new( - name: &str, - version: &str, - action: &str, - sha256: &str, - timeout: Option, - schedule: Option>, - justification: Option<&str>, - reinstall: bool, - force: bool, - package: Option<&str>, - ) -> PoolUpgradeOperation { - PoolUpgradeOperation { - _type: POOL_UPGRADE.to_string(), - name: name.to_string(), - version: version.to_string(), - action: action.to_string(), - sha256: sha256.to_string(), - timeout, - schedule, - justification: justification.map(String::from), - reinstall, - force, - package: package.map(String::from), - } - } -} - -pub type Schedule = HashMap; diff --git a/libvdrtools/src/domain/ledger/request.rs b/libvdrtools/src/domain/ledger/request.rs deleted file mode 100644 index 8da3574019..0000000000 --- a/libvdrtools/src/domain/ledger/request.rs +++ /dev/null @@ -1,101 +0,0 @@ -use std::{ - collections::HashMap, - sync::atomic::{AtomicUsize, Ordering}, -}; - -use lazy_static::lazy_static; -use serde; -use serde_json; -use time; - -use super::super::crypto::did::{DidValue, ShortDidValue}; - -pub const DEFAULT_LIBIDY_DID: &str = "LibindyDid111111111111"; - -pub struct ProtocolVersion {} - -lazy_static! { - pub static ref PROTOCOL_VERSION: AtomicUsize = AtomicUsize::new(2); -} - -impl ProtocolVersion { - pub fn set(version: usize) { - PROTOCOL_VERSION.store(version, Ordering::Relaxed); - } - - pub fn get() -> usize { - PROTOCOL_VERSION.load(Ordering::Relaxed) - } - - pub fn is_node_1_3() -> bool { - ProtocolVersion::get() == 1 - } -} - -#[derive(Serialize, Deserialize, PartialEq, Debug)] -#[serde(rename_all = "camelCase")] -pub struct TxnAuthrAgrmtAcceptanceData { - pub mechanism: String, - pub taa_digest: String, - pub time: u64, -} - -fn get_req_id() -> u64 { - time::OffsetDateTime::now_utc().unix_timestamp() as u64 * (1e9 as u64) - + time::OffsetDateTime::now_utc().unix_timestamp_nanos() as u64 -} - -#[derive(Serialize, Deserialize, PartialEq, Debug)] -#[serde(rename_all = "camelCase")] -pub struct Request { - pub req_id: u64, - #[serde(skip_serializing_if = "Option::is_none")] - pub identifier: Option, - pub operation: T, - pub protocol_version: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub signature: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub signatures: Option>, - #[serde(skip_serializing_if = "Option::is_none")] - pub taa_acceptance: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub endorser: Option, -} - -impl Request { - pub fn new( - req_id: u64, - identifier: ShortDidValue, - operation: T, - protocol_version: usize, - ) -> Request { - Request { - req_id, - identifier: Some(identifier), - operation, - protocol_version: Some(protocol_version), - signature: None, - signatures: None, - taa_acceptance: None, - endorser: None, - } - } - - pub fn build_request(identifier: Option<&DidValue>, operation: T) -> Result { - let req_id = get_req_id(); - - let identifier = match identifier { - Some(identifier_) => identifier_.clone().to_short(), - None => ShortDidValue(DEFAULT_LIBIDY_DID.to_string()), - }; - - serde_json::to_string(&Request::new( - req_id, - identifier, - operation, - ProtocolVersion::get(), - )) - .map_err(|err| format!("Cannot serialize Request: {:?}", err)) - } -} diff --git a/libvdrtools/src/domain/ledger/response.rs b/libvdrtools/src/domain/ledger/response.rs deleted file mode 100644 index 797d8b7340..0000000000 --- a/libvdrtools/src/domain/ledger/response.rs +++ /dev/null @@ -1,89 +0,0 @@ -#[derive(Deserialize, Debug)] -#[serde(rename_all = "camelCase")] -pub struct Response { - pub req_id: u64, - pub reason: String, -} - -#[derive(Debug, Deserialize)] -#[serde(untagged)] -pub enum Reply { - ReplyV0(ReplyV0), - ReplyV1(ReplyV1), -} - -impl Reply { - pub fn result(self) -> T { - match self { - Reply::ReplyV0(reply) => reply.result, - Reply::ReplyV1(mut reply) => reply.data.result.remove(0).result, - } - } -} - -#[derive(Debug, Deserialize)] -pub struct ReplyV0 { - pub result: T, -} - -#[derive(Debug, Deserialize)] -pub struct ReplyV1 { - pub data: ReplyDataV1, -} - -#[derive(Debug, Deserialize)] -pub struct ReplyDataV1 { - pub result: Vec>, -} - -#[derive(Debug, Deserialize)] -pub struct GetReplyResultV0 { - pub data: Option, -} - -#[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct GetReplyResultV1 { - pub txn: GetReplyTxnV1, - pub txn_metadata: TxnMetadata, -} - -#[derive(Debug, Deserialize)] -pub struct GetReplyTxnV1 { - pub data: T, -} - -#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)] -#[serde(rename_all = "camelCase")] -pub struct TxnMetadata { - pub seq_no: u32, - pub creation_time: u64, -} - -#[derive(Deserialize, Debug)] -#[serde(tag = "op")] -pub enum Message { - #[serde(rename = "REQNACK")] - ReqNACK(Response), - #[serde(rename = "REPLY")] - Reply(Reply), - #[serde(rename = "REJECT")] - Reject(Response), -} - -pub trait ReplyType { - fn get_type<'a>() -> &'a str; -} - -#[derive(Serialize, Deserialize, Debug)] -#[serde(rename_all = "camelCase")] -pub struct ResponseMetadata { - #[serde(skip_serializing_if = "Option::is_none")] - pub seq_no: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub txn_time: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub last_txn_time: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub last_seq_no: Option, -} diff --git a/libvdrtools/src/domain/ledger/rev_reg.rs b/libvdrtools/src/domain/ledger/rev_reg.rs deleted file mode 100644 index 18b01a5079..0000000000 --- a/libvdrtools/src/domain/ledger/rev_reg.rs +++ /dev/null @@ -1,161 +0,0 @@ -use std::collections::HashSet; - -use ursa::cl::{RevocationRegistry, RevocationRegistryDelta}; - -use super::{ - super::anoncreds::{ - revocation_registry::RevocationRegistryV1, - revocation_registry_definition::RevocationRegistryId, - revocation_registry_delta::RevocationRegistryDeltaV1, - }, - constants::{GET_REVOC_REG, GET_REVOC_REG_DELTA, REVOC_REG_ENTRY}, - response::{GetReplyResultV1, ReplyType}, -}; - -#[derive(Serialize, Debug)] -#[serde(rename_all = "camelCase")] -pub struct RevRegEntryOperation { - #[serde(rename = "type")] - pub _type: String, - pub revoc_reg_def_id: RevocationRegistryId, - pub revoc_def_type: String, - pub value: RevocationRegistryDelta, -} - -impl RevRegEntryOperation { - pub fn new( - rev_def_type: &str, - revoc_reg_def_id: &RevocationRegistryId, - value: RevocationRegistryDeltaV1, - ) -> RevRegEntryOperation { - RevRegEntryOperation { - _type: REVOC_REG_ENTRY.to_string(), - revoc_def_type: rev_def_type.to_string(), - revoc_reg_def_id: revoc_reg_def_id.clone(), - value: value.value, - } - } -} - -#[derive(Serialize, PartialEq, Debug)] -#[serde(rename_all = "camelCase")] -pub struct GetRevRegOperation { - #[serde(rename = "type")] - pub _type: String, - pub revoc_reg_def_id: RevocationRegistryId, - pub timestamp: i64, -} - -impl GetRevRegOperation { - pub fn new(revoc_reg_def_id: &RevocationRegistryId, timestamp: i64) -> GetRevRegOperation { - GetRevRegOperation { - _type: GET_REVOC_REG.to_string(), - revoc_reg_def_id: revoc_reg_def_id.clone(), - timestamp, - } - } -} - -#[derive(Serialize, PartialEq, Debug)] -#[serde(rename_all = "camelCase")] -pub struct GetRevRegDeltaOperation { - #[serde(rename = "type")] - pub _type: String, - pub revoc_reg_def_id: RevocationRegistryId, - #[serde(skip_serializing_if = "Option::is_none")] - pub from: Option, - pub to: i64, -} - -impl GetRevRegDeltaOperation { - pub fn new( - revoc_reg_def_id: &RevocationRegistryId, - from: Option, - to: i64, - ) -> GetRevRegDeltaOperation { - GetRevRegDeltaOperation { - _type: GET_REVOC_REG_DELTA.to_string(), - revoc_reg_def_id: revoc_reg_def_id.clone(), - from, - to, - } - } -} - -#[derive(Debug, Deserialize)] -#[serde(untagged)] -pub enum GetRevocRegReplyResult { - GetRevocRegReplyResultV0(GetRevocRegResultV0), - GetRevocRegReplyResultV1(GetReplyResultV1), -} - -impl ReplyType for GetRevocRegReplyResult { - fn get_type<'a>() -> &'a str { - GET_REVOC_REG - } -} - -#[derive(Deserialize, Serialize, Debug)] -#[serde(rename_all = "camelCase")] -pub struct GetRevocRegResultV0 { - pub seq_no: i32, - pub revoc_reg_def_id: RevocationRegistryId, - pub data: RevocationRegistryV1, - pub txn_time: u64, -} - -#[derive(Debug, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct GetRevocRegDataV1 { - pub revoc_reg_def_id: RevocationRegistryId, - pub value: RevocationRegistryV1, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct RevocationRegistryDeltaData { - pub value: RevocationRegistryDeltaValue, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct RevocationRegistryDeltaValue { - pub accum_from: Option, - pub accum_to: AccumulatorState, - pub issued: HashSet, - pub revoked: HashSet, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct AccumulatorState { - pub value: RevocationRegistry, - pub txn_time: u64, -} - -#[derive(Debug, Deserialize)] -#[serde(untagged)] -pub enum GetRevocRegDeltaReplyResult { - GetRevocRegDeltaReplyResultV0(GetRevocRegDeltaResultV0), - GetRevocRegDeltaReplyResultV1(GetReplyResultV1), -} - -impl ReplyType for GetRevocRegDeltaReplyResult { - fn get_type<'a>() -> &'a str { - GET_REVOC_REG_DELTA - } -} - -#[derive(Deserialize, Serialize, Debug)] -#[serde(rename_all = "camelCase")] -pub struct GetRevocRegDeltaResultV0 { - pub seq_no: i32, - pub revoc_reg_def_id: RevocationRegistryId, - pub data: RevocationRegistryDeltaData, -} - -#[derive(Debug, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct GetRevocRegDeltaDataV1 { - pub revoc_reg_def_id: RevocationRegistryId, - pub value: RevocationRegistryDeltaData, -} diff --git a/libvdrtools/src/domain/ledger/rev_reg_def.rs b/libvdrtools/src/domain/ledger/rev_reg_def.rs deleted file mode 100644 index 56ac00f159..0000000000 --- a/libvdrtools/src/domain/ledger/rev_reg_def.rs +++ /dev/null @@ -1,73 +0,0 @@ -use super::{ - super::anoncreds::{ - credential_definition::CredentialDefinitionId, - revocation_registry_definition::{ - RevocationRegistryDefinitionV1, RevocationRegistryDefinitionValue, RevocationRegistryId, - }, - }, - constants::{GET_REVOC_REG_DEF, REVOC_REG_DEF}, - response::{GetReplyResultV1, ReplyType}, -}; - -#[derive(Serialize, Debug)] -#[serde(rename_all = "camelCase")] -pub struct RevRegDefOperation { - #[serde(rename = "type")] - pub _type: String, - pub id: RevocationRegistryId, - #[serde(rename = "revocDefType")] - pub type_: String, - pub tag: String, - pub cred_def_id: CredentialDefinitionId, - pub value: RevocationRegistryDefinitionValue, -} - -impl RevRegDefOperation { - pub fn new(rev_reg_def: RevocationRegistryDefinitionV1) -> RevRegDefOperation { - RevRegDefOperation { - _type: REVOC_REG_DEF.to_string(), - id: rev_reg_def.id, - type_: rev_reg_def.revoc_def_type.to_str().to_string(), - tag: rev_reg_def.tag, - cred_def_id: rev_reg_def.cred_def_id, - value: rev_reg_def.value, - } - } -} - -#[derive(Serialize, PartialEq, Debug)] -#[serde(rename_all = "camelCase")] -pub struct GetRevRegDefOperation { - #[serde(rename = "type")] - pub _type: String, - pub id: RevocationRegistryId, -} - -impl GetRevRegDefOperation { - pub fn new(id: &RevocationRegistryId) -> GetRevRegDefOperation { - GetRevRegDefOperation { - _type: GET_REVOC_REG_DEF.to_string(), - id: id.clone(), - } - } -} - -#[derive(Debug, Deserialize)] -#[serde(untagged)] -pub enum GetRevocRegDefReplyResult { - GetRevocRegDefReplyResultV0(GetRevocRegDefResultV0), - GetRevocRegDefReplyResultV1(GetReplyResultV1), -} - -impl ReplyType for GetRevocRegDefReplyResult { - fn get_type<'a>() -> &'a str { - GET_REVOC_REG_DEF - } -} - -#[derive(Deserialize, Serialize, Debug)] -#[serde(rename_all = "camelCase")] -pub struct GetRevocRegDefResultV0 { - pub seq_no: i32, - pub data: RevocationRegistryDefinitionV1, -} diff --git a/libvdrtools/src/domain/ledger/schema.rs b/libvdrtools/src/domain/ledger/schema.rs deleted file mode 100644 index 73baf2e6b7..0000000000 --- a/libvdrtools/src/domain/ledger/schema.rs +++ /dev/null @@ -1,107 +0,0 @@ -use std::collections::HashSet; - -use super::{ - super::{anoncreds::schema::SchemaId, crypto::did::ShortDidValue}, - constants::{GET_SCHEMA, SCHEMA}, - response::{GetReplyResultV1, ReplyType}, -}; - -#[derive(Serialize, PartialEq, Debug)] -pub struct SchemaOperation { - #[serde(rename = "type")] - pub _type: String, - pub data: SchemaOperationData, -} - -impl SchemaOperation { - pub fn new(data: SchemaOperationData) -> SchemaOperation { - SchemaOperation { - data, - _type: SCHEMA.to_string(), - } - } -} - -#[derive(Serialize, PartialEq, Debug, Deserialize)] -pub struct SchemaOperationData { - pub name: String, - pub version: String, - pub attr_names: HashSet, -} - -impl SchemaOperationData { - pub fn new(name: String, version: String, attr_names: HashSet) -> SchemaOperationData { - SchemaOperationData { - name, - version, - attr_names, - } - } -} - -#[derive(Serialize, PartialEq, Debug)] -pub struct GetSchemaOperation { - #[serde(rename = "type")] - pub _type: String, - pub dest: ShortDidValue, - pub data: GetSchemaOperationData, -} - -impl GetSchemaOperation { - pub fn new(dest: ShortDidValue, data: GetSchemaOperationData) -> GetSchemaOperation { - GetSchemaOperation { - _type: GET_SCHEMA.to_string(), - dest, - data, - } - } -} - -#[derive(Serialize, PartialEq, Debug, Deserialize)] -pub struct GetSchemaOperationData { - pub name: String, - pub version: String, -} - -impl GetSchemaOperationData { - pub fn new(name: String, version: String) -> GetSchemaOperationData { - GetSchemaOperationData { name, version } - } -} - -#[derive(Debug, Deserialize)] -#[serde(untagged)] -pub enum GetSchemaReplyResult { - GetSchemaReplyResultV0(GetSchemaResultV0), - GetSchemaReplyResultV1(GetReplyResultV1), -} - -impl ReplyType for GetSchemaReplyResult { - fn get_type<'a>() -> &'a str { - GET_SCHEMA - } -} - -#[derive(Deserialize, Debug)] -#[serde(rename_all = "camelCase")] -pub struct GetSchemaResultV0 { - pub seq_no: u32, - pub data: SchemaOperationData, - pub dest: ShortDidValue, -} - -#[derive(Deserialize, Debug)] -#[serde(rename_all = "camelCase")] -pub struct GetSchemaResultDataV1 { - pub ver: String, - pub id: SchemaId, - pub schema_name: String, - pub schema_version: String, - pub value: GetSchemaResultDataValueV1, -} - -#[derive(Deserialize, Debug)] -#[serde(rename_all = "camelCase")] -pub struct GetSchemaResultDataValueV1 { - pub attr_names: HashSet, -} diff --git a/libvdrtools/src/domain/ledger/txn.rs b/libvdrtools/src/domain/ledger/txn.rs deleted file mode 100644 index bdc69bdf5a..0000000000 --- a/libvdrtools/src/domain/ledger/txn.rs +++ /dev/null @@ -1,37 +0,0 @@ -use super::constants::GET_TXN; - -#[derive(Serialize, PartialEq, Debug)] -pub struct GetTxnOperation { - #[serde(rename = "type")] - pub _type: String, - pub data: i32, - #[serde(rename = "ledgerId")] - pub ledger_id: i32, -} - -impl GetTxnOperation { - pub fn new(data: i32, ledger_id: i32) -> GetTxnOperation { - GetTxnOperation { - _type: GET_TXN.to_string(), - data, - ledger_id, - } - } -} - -#[derive(Deserialize, Debug)] -pub enum LedgerType { - POOL = 0, - DOMAIN = 1, - CONFIG = 2, -} - -impl LedgerType { - pub fn to_id(&self) -> i32 { - match *self { - LedgerType::POOL => LedgerType::POOL as i32, - LedgerType::DOMAIN => LedgerType::DOMAIN as i32, - LedgerType::CONFIG => LedgerType::CONFIG as i32, - } - } -} diff --git a/libvdrtools/src/domain/ledger/validator_info.rs b/libvdrtools/src/domain/ledger/validator_info.rs deleted file mode 100644 index d5e302af8a..0000000000 --- a/libvdrtools/src/domain/ledger/validator_info.rs +++ /dev/null @@ -1,15 +0,0 @@ -use super::constants::GET_VALIDATOR_INFO; - -#[derive(Serialize, PartialEq, Debug)] -pub struct GetValidatorInfoOperation { - #[serde(rename = "type")] - pub _type: String, -} - -impl GetValidatorInfoOperation { - pub fn new() -> GetValidatorInfoOperation { - GetValidatorInfoOperation { - _type: GET_VALIDATOR_INFO.to_string(), - } - } -} diff --git a/libvdrtools/src/domain/mod.rs b/libvdrtools/src/domain/mod.rs index 9eed3ac863..1386661e11 100644 --- a/libvdrtools/src/domain/mod.rs +++ b/libvdrtools/src/domain/mod.rs @@ -1,15 +1,9 @@ pub mod anoncreds; pub mod cache; pub mod crypto; -pub mod ledger; -pub mod pairwise; - -use indy_api_types::validation::Validatable; #[derive(Debug, Serialize, Deserialize)] pub struct IndyConfig { pub crypto_thread_pool_size: Option, pub collect_backtrace: Option, } - -impl Validatable for IndyConfig {} diff --git a/libvdrtools/src/domain/pairwise/mod.rs b/libvdrtools/src/domain/pairwise/mod.rs deleted file mode 100644 index 4da97bebe7..0000000000 --- a/libvdrtools/src/domain/pairwise/mod.rs +++ /dev/null @@ -1,25 +0,0 @@ -use super::crypto::did::DidValue; - -#[derive(Serialize, Deserialize)] -pub struct Pairwise { - pub my_did: DidValue, - pub their_did: DidValue, - #[serde(skip_serializing_if = "Option::is_none")] - pub metadata: Option, -} - -#[derive(Serialize, Deserialize)] -pub struct PairwiseInfo { - pub my_did: DidValue, - #[serde(skip_serializing_if = "Option::is_none")] - pub metadata: Option, -} - -impl From for PairwiseInfo { - fn from(pairwise: Pairwise) -> Self { - PairwiseInfo { - my_did: pairwise.my_did, - metadata: pairwise.metadata, - } - } -} diff --git a/libvdrtools/src/lib.rs b/libvdrtools/src/lib.rs index b2625ac609..3221fee2a3 100644 --- a/libvdrtools/src/lib.rs +++ b/libvdrtools/src/lib.rs @@ -1,18 +1,9 @@ -#![cfg_attr(feature = "fatal_warnings", deny(warnings))] -#![allow(clippy::all)] - #[macro_use] extern crate log; -extern crate num_traits; - #[macro_use] extern crate serde_derive; -#[macro_use] -extern crate serde_json; - -#[allow(unused_imports)] #[macro_use] extern crate indy_utils; @@ -28,13 +19,13 @@ mod services; use std::sync::Arc; -pub use controllers::CredentialDefinitionId; pub use domain::{ anoncreds::{ credential::{AttributeValues, Credential, CredentialValues}, credential_definition::{ CredentialDefinition, CredentialDefinitionCorrectnessProof, CredentialDefinitionData, - CredentialDefinitionPrivateKey, CredentialDefinitionV1, SignatureType, + CredentialDefinitionId, CredentialDefinitionPrivateKey, CredentialDefinitionV1, + SignatureType, }, credential_offer::CredentialOffer, credential_request::{CredentialRequest, CredentialRequestMetadata}, @@ -47,7 +38,6 @@ pub use domain::{ RevocationRegistryId, RevocationRegistryInfo, }, revocation_registry_delta::{RevocationRegistryDelta, RevocationRegistryDeltaV1}, - revocation_state::RevocationStates, schema::{AttributeNames, Schema, SchemaId, SchemaV1}, }, crypto::{ @@ -62,18 +52,10 @@ pub use indy_api_types::{ }; pub use indy_wallet::WalletRecord; use lazy_static::lazy_static; -pub use services::AnoncredsHelpers; use crate::{ - controllers::{ - BlobStorageController, ConfigController, CryptoController, DidController, IssuerController, - NonSecretsController, PairwiseController, ProverController, VerifierController, - WalletController, - }, - services::{ - BlobStorageService, CryptoService, IssuerService, ProverService, VerifierService, - WalletService, - }, + controllers::{CryptoController, DidController, NonSecretsController, WalletController}, + services::{CryptoService, WalletService}, }; // Global (lazy inited) instance of Locator @@ -82,15 +64,9 @@ lazy_static! { } pub struct Locator { - pub issuer_controller: IssuerController, - pub prover_controller: ProverController, - pub verifier_controller: VerifierController, pub crypto_controller: CryptoController, - pub config_controller: ConfigController, pub did_controller: DidController, pub wallet_controller: WalletController, - pub pairwise_controller: PairwiseController, - pub blob_storage_controller: BlobStorageController, pub non_secret_controller: NonSecretsController, } @@ -102,53 +78,22 @@ impl Locator { fn new() -> Locator { info!("new >"); - let issuer_service = Arc::new(IssuerService::new()); - let prover_service = Arc::new(ProverService::new()); - let verifier_service = Arc::new(VerifierService::new()); - let blob_storage_service = Arc::new(BlobStorageService::new()); let crypto_service = Arc::new(CryptoService::new()); let wallet_service = Arc::new(WalletService::new()); - let issuer_controller = IssuerController::new( - issuer_service, - blob_storage_service.clone(), - wallet_service.clone(), - crypto_service.clone(), - ); - - let prover_controller = ProverController::new( - prover_service, - wallet_service.clone(), - crypto_service.clone(), - blob_storage_service.clone(), - ); - - let verifier_controller = VerifierController::new(verifier_service); - let crypto_controller = CryptoController::new(wallet_service.clone(), crypto_service.clone()); - let config_controller = ConfigController::new(); - let did_controller = DidController::new(wallet_service.clone(), crypto_service.clone()); let wallet_controller = WalletController::new(wallet_service.clone(), crypto_service.clone()); - - let pairwise_controller = PairwiseController::new(wallet_service.clone()); - let blob_storage_controller = BlobStorageController::new(blob_storage_service.clone()); let non_secret_controller = NonSecretsController::new(wallet_service.clone()); let res = Locator { - issuer_controller, - prover_controller, - verifier_controller, crypto_controller, - config_controller, did_controller, wallet_controller, - pairwise_controller, - blob_storage_controller, non_secret_controller, }; @@ -162,30 +107,3 @@ impl Drop for Locator { info!(target: "Locator", "drop <>"); } } - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn locator_new_works() { - let _locator = Locator::new(); - assert!(true); - } - - #[test] - fn locator_drop_works() { - { - let _locator = Locator::new(); - } - - assert!(true); - } - - #[test] - fn locator_get_instance_works() { - let locator = Locator::instance(); - let locator2 = Locator::instance(); - assert!(std::ptr::eq(locator, locator2)); - } -} diff --git a/libvdrtools/src/services/anoncreds/helpers.rs b/libvdrtools/src/services/anoncreds/helpers.rs deleted file mode 100644 index 1a3e981e35..0000000000 --- a/libvdrtools/src/services/anoncreds/helpers.rs +++ /dev/null @@ -1,319 +0,0 @@ -use std::collections::{HashMap, HashSet}; - -use indy_api_types::errors::prelude::*; -use ursa::cl::{ - issuer::Issuer as UrsaIssuer, verifier::Verifier as UrsaVerifier, CredentialSchema, - CredentialValues, MasterSecret, NonCredentialSchema, SubProofRequest, -}; - -use crate::domain::{ - anoncreds::{ - credential::AttributeValues, - credential_definition::{CredentialDefinition, CredentialDefinitionId}, - credential_offer::CredentialOffer, - credential_request::CredentialRequest, - proof_request::{AttributeInfo, NonRevocedInterval, PredicateInfo, ProofRequest}, - revocation_registry_definition::{RevocationRegistryDefinition, RevocationRegistryId}, - schema::{Schema, SchemaId}, - }, - crypto::did::DidValue, -}; - -macro_rules! _id_to_unqualified { - ($entity:expr, $type_:ident) => {{ - if $entity.contains($type_::PREFIX) { - return Ok($type_($entity.to_string()).to_unqualified().0); - } - }}; -} - -macro_rules! _object_to_unqualified { - ($entity:expr, $type_:ident) => {{ - if let Ok(object) = ::serde_json::from_str::<$type_>(&$entity) { - return Ok(json!(object.to_unqualified()).to_string()); - } - }}; -} - -pub struct AnoncredsHelpers {} - -impl AnoncredsHelpers { - pub(crate) fn attr_common_view(attr: &str) -> String { - attr.replace(" ", "").to_lowercase() - } - - pub(crate) fn build_credential_schema(attrs: &HashSet) -> IndyResult { - trace!("build_credential_schema > attrs {:?}", attrs); - - let credential_schema = { - let mut builder = UrsaIssuer::new_credential_schema_builder()?; - - for attr in attrs { - builder.add_attr(&Self::attr_common_view(attr))?; - } - - builder.finalize()? - }; - - let res = Ok(credential_schema); - trace!("build_credential_schema < {:?}", res); - res - } - - pub(crate) fn build_non_credential_schema() -> IndyResult { - trace!("build_non_credential_schema >"); - - let schema = { - let mut builder = UrsaIssuer::new_non_credential_schema_builder()?; - builder.add_attr("master_secret")?; - builder.finalize()? - }; - - let res = Ok(schema); - trace!("build_non_credential_schema < {:?}", res); - res - } - - pub(crate) fn build_credential_values( - credential_values: &HashMap, - master_secret: Option<&MasterSecret>, - ) -> IndyResult { - trace!( - "build_credential_values > credential_values {:?} master_secret {:?}", - credential_values, - secret!(master_secret), - ); - - let credential_values = { - let mut builder = UrsaIssuer::new_credential_values_builder()?; - - for (attr, values) in credential_values { - builder.add_dec_known(&Self::attr_common_view(attr), &values.encoded)?; - } - - if let Some(master_secret) = master_secret { - builder.add_value_hidden("master_secret", &master_secret.value()?)?; - } - - builder.finalize()? - }; - - let res = Ok(credential_values); - trace!("build_credential_values < {:?}", res); - res - } - - pub(crate) fn build_sub_proof_request( - attrs_for_credential: &[AttributeInfo], - predicates_for_credential: &[PredicateInfo], - ) -> IndyResult { - trace!( - "build_sub_proof_request > attrs_for_credential {:?} predicates_for_credential {:?}", - attrs_for_credential, - predicates_for_credential - ); - - let sub_proof_request = { - let mut builder = UrsaVerifier::new_sub_proof_request_builder()?; - - for ref attr in attrs_for_credential { - if let Some(ref name) = attr.name { - builder.add_revealed_attr(&Self::attr_common_view(name))? - } else if let Some(ref names) = attr.names { - for ref name in names { - builder.add_revealed_attr(&Self::attr_common_view(name))? - } - } else { - Err(IndyError::from_msg( - IndyErrorKind::InvalidStructure, - r#"Attr for credential restriction should contain "name" or "names" param."#, - ))? - }; - } - - for ref predicate in predicates_for_credential { - builder.add_predicate( - &Self::attr_common_view(&predicate.name), - &predicate.p_type.to_string(), - predicate.p_value, - )?; - } - - builder.finalize()? - }; - - let res = Ok(sub_proof_request); - trace!("build_sub_proof_request < {:?}", res); - res - } - - pub(crate) fn parse_cred_rev_id(cred_rev_id: &str) -> IndyResult { - trace!("parse_cred_rev_id > cred_rev_id {:?}", cred_rev_id); - - let cred_rev_id = cred_rev_id.parse::().to_indy( - IndyErrorKind::InvalidStructure, - "Cannot parse CredentialRevocationId", - )?; - - let res = Ok(cred_rev_id); - trace!("parse_cred_rev_id < {:?}", res); - res - } - - pub(crate) fn get_non_revoc_interval( - global_interval: &Option, - local_interval: &Option, - ) -> Option { - trace!( - "get_non_revoc_interval > global_interval {:?} local_interval {:?}", - global_interval, - local_interval - ); - - let res = local_interval - .clone() - .or_else(|| global_interval.clone().or(None)) - .filter(|x| x.to.is_some() || x.from.is_some()); - - trace!("get_non_revoc_interval < {:?}", res); - res - } - - pub fn to_unqualified(entity: &str) -> IndyResult { - trace!("to_unqualified > entity {:?}", entity); - - _object_to_unqualified!(entity, CredentialDefinition); - _object_to_unqualified!(entity, Schema); - _object_to_unqualified!(entity, RevocationRegistryDefinition); - _object_to_unqualified!(entity, CredentialOffer); - _object_to_unqualified!(entity, CredentialRequest); - _object_to_unqualified!(entity, ProofRequest); - - _id_to_unqualified!(entity, RevocationRegistryId); - _id_to_unqualified!(entity, CredentialDefinitionId); - _id_to_unqualified!(entity, SchemaId); - _id_to_unqualified!(entity, DidValue); - - let res = Ok(entity.to_string()); - trace!("to_unqualified < {:?}", res); - res - } -} - -#[cfg(test)] -mod tests { - use super::*; - - fn _interval() -> NonRevocedInterval { - NonRevocedInterval { - from: None, - to: Some(123), - } - } - - #[test] - fn get_non_revoc_interval_for_global() { - let res = AnoncredsHelpers::get_non_revoc_interval(&Some(_interval()), &None).unwrap(); - assert_eq!(_interval(), res); - } - - #[test] - fn get_non_revoc_interval_for_local() { - let res = AnoncredsHelpers::get_non_revoc_interval(&None, &Some(_interval())).unwrap(); - assert_eq!(_interval(), res); - } - - #[test] - fn get_non_revoc_interval_for_none() { - let res = AnoncredsHelpers::get_non_revoc_interval(&None, &None); - assert_eq!(None, res); - } - - #[test] - fn get_non_revoc_interval_for_empty_interval() { - let res = AnoncredsHelpers::get_non_revoc_interval( - &Some(NonRevocedInterval { - from: None, - to: None, - }), - &None, - ); - assert_eq!(None, res); - } - - mod to_unqualified { - use super::*; - - const DID_QUALIFIED: &str = "did:indy:NcYxiDXkpYi6ov5FcYDi1e"; - const DID_UNQUALIFIED: &str = "NcYxiDXkpYi6ov5FcYDi1e"; - const SCHEMA_ID_QUALIFIED: &str = - "did:indy:NcYxiDXkpYi6ov5FcYDi1e/anoncreds/v0/SCHEMA/gvt/1.0"; - const SCHEMA_ID_UNQUALIFIED: &str = "NcYxiDXkpYi6ov5FcYDi1e:2:gvt:1.0"; - const CRED_DEF_ID_QUALIFIED: &str = - "did:indy:NcYxiDXkpYi6ov5FcYDi1e/anoncreds/v0/CLAIM_DEF/1/tag"; - const CRED_DEF_ID_UNQUALIFIED: &str = "NcYxiDXkpYi6ov5FcYDi1e:3:CL:1:tag"; - const REV_REG_ID_QUALIFIED: &str = "did:indy:NcYxiDXkpYi6ov5FcYDi1e/anoncreds/v0/\ - REV_REG_DEF/did:indy:NcYxiDXkpYi6ov5FcYDi1e/anoncreds/\ - v0/SCHEMA/gvt/1.0/tag/TAG_1"; - const REV_REG_ID_UNQUALIFIED: &str = "NcYxiDXkpYi6ov5FcYDi1e:4:NcYxiDXkpYi6ov5FcYDi1e:3:\ - CL:NcYxiDXkpYi6ov5FcYDi1e:2:gvt:1.0:tag:CL_ACCUM:\ - TAG_1"; - const SCHEMA_ID_WITH_SPACES_QUALIFIED: &str = - "did:indy:NcYxiDXkpYi6ov5FcYDi1e/anoncreds/v0/SCHEMA/Passport Schema/1.0"; - const SCHEMA_ID_WITH_SPACES_UNQUALIFIED: &str = - "NcYxiDXkpYi6ov5FcYDi1e:2:Passport Schema:1.0"; - - #[test] - fn test_to_unqualified() { - // DID - assert_eq!( - DID_UNQUALIFIED, - AnoncredsHelpers::to_unqualified(DID_QUALIFIED).unwrap() - ); - assert_eq!( - DID_UNQUALIFIED, - AnoncredsHelpers::to_unqualified(DID_UNQUALIFIED).unwrap() - ); - - // SchemaId - assert_eq!( - SCHEMA_ID_UNQUALIFIED, - AnoncredsHelpers::to_unqualified(SCHEMA_ID_QUALIFIED).unwrap() - ); - assert_eq!( - SCHEMA_ID_UNQUALIFIED, - AnoncredsHelpers::to_unqualified(SCHEMA_ID_UNQUALIFIED).unwrap() - ); - - // SchemaId - assert_eq!( - SCHEMA_ID_WITH_SPACES_UNQUALIFIED, - AnoncredsHelpers::to_unqualified(SCHEMA_ID_WITH_SPACES_QUALIFIED).unwrap() - ); - assert_eq!( - SCHEMA_ID_WITH_SPACES_UNQUALIFIED, - AnoncredsHelpers::to_unqualified(SCHEMA_ID_WITH_SPACES_UNQUALIFIED).unwrap() - ); - - // Credential Definition Id - assert_eq!( - CRED_DEF_ID_UNQUALIFIED, - AnoncredsHelpers::to_unqualified(CRED_DEF_ID_QUALIFIED).unwrap() - ); - assert_eq!( - CRED_DEF_ID_UNQUALIFIED, - AnoncredsHelpers::to_unqualified(CRED_DEF_ID_UNQUALIFIED).unwrap() - ); - - // Revocation Registry Id - assert_eq!( - REV_REG_ID_UNQUALIFIED, - AnoncredsHelpers::to_unqualified(REV_REG_ID_QUALIFIED).unwrap() - ); - assert_eq!( - REV_REG_ID_UNQUALIFIED, - AnoncredsHelpers::to_unqualified(REV_REG_ID_UNQUALIFIED).unwrap() - ); - } - } -} diff --git a/libvdrtools/src/services/anoncreds/issuer.rs b/libvdrtools/src/services/anoncreds/issuer.rs deleted file mode 100644 index 14ef299eb9..0000000000 --- a/libvdrtools/src/services/anoncreds/issuer.rs +++ /dev/null @@ -1,282 +0,0 @@ -use indy_api_types::errors::prelude::*; -use ursa::cl::{ - issuer::Issuer as UrsaIssuer, CredentialKeyCorrectnessProof, CredentialPrivateKey, - CredentialPublicKey, CredentialSignature, Nonce, RevocationKeyPrivate, RevocationRegistry, - RevocationRegistryDelta, RevocationTailsAccessor, RevocationTailsGenerator, - SignatureCorrectnessProof, -}; - -use crate::{ - domain::{ - anoncreds::{ - credential::CredentialValues, - credential_definition::{ - CredentialDefinitionData, CredentialDefinitionV1 as CredentialDefinition, - }, - credential_request::CredentialRequest, - revocation_registry_definition::{ - RevocationRegistryDefinitionV1, RevocationRegistryDefinitionValuePublicKeys, - }, - schema::AttributeNames, - }, - crypto::did::DidValue, - }, - services::AnoncredsHelpers, -}; - -pub struct IssuerService {} - -impl IssuerService { - pub(crate) fn new() -> IssuerService { - IssuerService {} - } - - pub(crate) fn new_credential_definition( - attr_names: &AttributeNames, - support_revocation: bool, - ) -> IndyResult<( - CredentialDefinitionData, - CredentialPrivateKey, - CredentialKeyCorrectnessProof, - )> { - trace!( - "new_credential_definition > attr_names {:?} support_revocation {:?}", - attr_names, - support_revocation - ); - - let credential_schema = AnoncredsHelpers::build_credential_schema(&attr_names.0)?; - let non_credential_schema = AnoncredsHelpers::build_non_credential_schema()?; - - let (credential_public_key, credential_private_key, credential_key_correctness_proof) = - UrsaIssuer::new_credential_def( - &credential_schema, - &non_credential_schema, - support_revocation, - )?; - - let credential_definition_value = CredentialDefinitionData { - primary: credential_public_key.get_primary_key()?.try_clone()?, - revocation: credential_public_key.get_revocation_key()?.clone(), - }; - - let res = Ok(( - credential_definition_value, - credential_private_key, - credential_key_correctness_proof, - )); - - trace!("new_credential_definition < {:?}", secret!(&res)); - res - } - - pub(crate) fn new_revocation_registry( - &self, - cred_def: &CredentialDefinition, - max_cred_num: u32, - issuance_by_default: bool, - issuer_did: &DidValue, - ) -> IndyResult<( - RevocationRegistryDefinitionValuePublicKeys, - RevocationKeyPrivate, - RevocationRegistry, - RevocationTailsGenerator, - )> { - trace!( - "new_revocation_registry > pub_key {:?} max_cred_num {:?} issuance_by_default {:?} \ - issuer_did {:?}", - cred_def, - max_cred_num, - issuance_by_default, - issuer_did - ); - - let credential_pub_key = CredentialPublicKey::build_from_parts( - &cred_def.value.primary, - cred_def.value.revocation.as_ref(), - )?; - - let (rev_key_pub, rev_key_priv, rev_reg_entry, rev_tails_generator) = - UrsaIssuer::new_revocation_registry_def( - &credential_pub_key, - max_cred_num, - issuance_by_default, - )?; - - let rev_keys_pub = RevocationRegistryDefinitionValuePublicKeys { - accum_key: rev_key_pub, - }; - - let res = Ok(( - rev_keys_pub, - rev_key_priv, - rev_reg_entry, - rev_tails_generator, - )); - - trace!("new_revocation_registry < {:?}", secret!(&res)); - res - } - - pub(crate) fn new_credential( - &self, - cred_def: &CredentialDefinition, - cred_priv_key: &CredentialPrivateKey, - cred_issuance_blinding_nonce: &Nonce, - cred_request: &CredentialRequest, - cred_values: &CredentialValues, - rev_idx: Option, - rev_reg_def: Option<&RevocationRegistryDefinitionV1>, - rev_reg: Option<&mut RevocationRegistry>, - rev_key_priv: Option<&RevocationKeyPrivate>, - rev_tails_accessor: Option<&RTA>, - ) -> IndyResult<( - CredentialSignature, - SignatureCorrectnessProof, - Option, - )> - where - RTA: RevocationTailsAccessor, - { - trace!( - "new_credential > cred_def {:?} cred_priv_key {:?} cred_issuance_blinding_nonce {:?} \ - cred_request {:?} cred_values {:?} rev_idx {:?} rev_reg_def {:?} rev_reg {:?} \ - rev_key_priv {:?}", - cred_def, - secret!(&cred_priv_key), - secret!(&cred_issuance_blinding_nonce), - secret!(&cred_request), - secret!(&cred_values), - secret!(&rev_idx), - rev_reg_def, - rev_reg, - secret!(&rev_key_priv) - ); - - let credential_values = AnoncredsHelpers::build_credential_values(&cred_values.0, None)?; - - let credential_pub_key = CredentialPublicKey::build_from_parts( - &cred_def.value.primary, - cred_def.value.revocation.as_ref(), - )?; - - let (credential_signature, signature_correctness_proof, rev_reg_delta) = match rev_idx { - Some(rev_idx) => { - let rev_reg = rev_reg.ok_or_else(|| { - err_msg(IndyErrorKind::InvalidState, "RevocationRegistry not found") - })?; - - let rev_key_priv = rev_key_priv.ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidState, - "RevocationKeyPrivate not found", - ) - })?; - - let rev_reg_def = rev_reg_def.ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidState, - "RevocationRegistryDefinitionValue not found", - ) - })?; - - let rev_tails_accessor = rev_tails_accessor.ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidState, - "RevocationTailsAccessor not found", - ) - })?; - - UrsaIssuer::sign_credential_with_revoc( - &cred_request.prover_did.0, - &cred_request.blinded_ms, - &cred_request.blinded_ms_correctness_proof, - cred_issuance_blinding_nonce, - &cred_request.nonce, - &credential_values, - &credential_pub_key, - &cred_priv_key, - rev_idx, - rev_reg_def.value.max_cred_num, - rev_reg_def.value.issuance_type.to_bool(), - rev_reg, - rev_key_priv, - rev_tails_accessor, - )? - } - None => { - let (signature, correctness_proof) = UrsaIssuer::sign_credential( - &cred_request.prover_did.0, - &cred_request.blinded_ms, - &cred_request.blinded_ms_correctness_proof, - cred_issuance_blinding_nonce, - &cred_request.nonce, - &credential_values, - &credential_pub_key, - &cred_priv_key, - )?; - (signature, correctness_proof, None) - } - }; - - let res = Ok(( - credential_signature, - signature_correctness_proof, - rev_reg_delta, - )); - - trace!("new_credential < {:?}", secret!(&res)); - res - } - - pub(crate) fn revoke( - &self, - rev_reg: &mut RevocationRegistry, - max_cred_num: u32, - rev_idx: u32, - rev_tails_accessor: &RTA, - ) -> IndyResult - where - RTA: RevocationTailsAccessor, - { - trace!( - "revoke > rev_reg {:?} max_cred_num {:?} rev_idx {:?}", - rev_reg, - max_cred_num, - secret!(&rev_idx) - ); - - let rev_reg_delta = - UrsaIssuer::revoke_credential(rev_reg, max_cred_num, rev_idx, rev_tails_accessor)?; - - let res = Ok(rev_reg_delta); - trace!("recovery < {:?}", res); - res - } - - #[allow(dead_code)] - pub(crate) fn recovery( - &self, - rev_reg: &mut RevocationRegistry, - max_cred_num: u32, - rev_idx: u32, - rev_tails_accessor: &RTA, - ) -> IndyResult - where - RTA: RevocationTailsAccessor, - { - trace!( - "revoke > rev_reg {:?} max_cred_num {:?} rev_idx {:?}", - rev_reg, - max_cred_num, - secret!(&rev_idx) - ); - - let rev_reg_delta = - UrsaIssuer::recovery_credential(rev_reg, max_cred_num, rev_idx, rev_tails_accessor)?; - - let res = Ok(rev_reg_delta); - trace!("recovery < {:?}", res); - res - } -} diff --git a/libvdrtools/src/services/anoncreds/mod.rs b/libvdrtools/src/services/anoncreds/mod.rs deleted file mode 100644 index 0e945bee9c..0000000000 --- a/libvdrtools/src/services/anoncreds/mod.rs +++ /dev/null @@ -1,9 +0,0 @@ -mod helpers; -mod issuer; -mod prover; -mod verifier; - -pub use helpers::AnoncredsHelpers; -pub use issuer::IssuerService; -pub use prover::ProverService; -pub use verifier::VerifierService; diff --git a/libvdrtools/src/services/anoncreds/prover.rs b/libvdrtools/src/services/anoncreds/prover.rs deleted file mode 100644 index f000f7940f..0000000000 --- a/libvdrtools/src/services/anoncreds/prover.rs +++ /dev/null @@ -1,1724 +0,0 @@ -use std::collections::{hash_map::Entry, HashMap}; - -use indy_api_types::errors::prelude::*; -use ursa::cl::{ - issuer::Issuer as UrsaIssuer, prover::Prover as UrsaProver, verifier::Verifier as UrsaVerifier, - BlindedCredentialSecrets, BlindedCredentialSecretsCorrectnessProof, CredentialPublicKey, - CredentialSecretsBlindingFactors, MasterSecret, SubProofRequest, -}; - -use crate::{ - domain::anoncreds::{ - credential::{AttributeValues, Credential}, - credential_attr_tag_policy::CredentialAttrTagPolicy, - credential_definition::{ - CredentialDefinitionId, CredentialDefinitionV1 as CredentialDefinition, - }, - credential_offer::CredentialOffer, - credential_request::CredentialRequestMetadata, - proof::{ - AttributeValue, Identifier, Proof, RequestedProof, RevealedAttributeGroupInfo, - RevealedAttributeInfo, SubProofReferent, - }, - proof_request::{ - PredicateInfo, PredicateTypes, ProofRequest, ProofRequestExtraQuery, - ProofRequestPayload, ProofRequestsVersion, RequestedAttributeInfo, - RequestedPredicateInfo, - }, - requested_credential::{ProvingCredentialKey, RequestedCredentials}, - revocation_registry_definition::RevocationRegistryDefinitionV1, - revocation_state::RevocationState, - schema::{SchemaId, SchemaV1}, - }, - services::{AnoncredsHelpers, VerifierService}, - utils::wql::Query, -}; - -const ATTRIBUTE_EXISTENCE_MARKER: &str = "1"; - -pub struct ProverService {} - -impl ProverService { - pub fn new() -> ProverService { - ProverService {} - } - - pub fn new_master_secret(&self) -> IndyResult { - trace!("new_master_secret > "); - - let master_secret = UrsaProver::new_master_secret()?; - - let res = Ok(master_secret); - trace!("new_master_secret < {:?}", secret!(&res)); - res - } - - pub fn new_credential_request( - &self, - cred_def: &CredentialDefinition, - master_secret: &MasterSecret, - credential_offer: &CredentialOffer, - ) -> IndyResult<( - BlindedCredentialSecrets, - CredentialSecretsBlindingFactors, - BlindedCredentialSecretsCorrectnessProof, - )> { - trace!( - "new_credential_request > cred_def {:?} master_secret {:?} credential_offer {:?}", - cred_def, - secret!(&master_secret), - credential_offer - ); - - let credential_pub_key = CredentialPublicKey::build_from_parts( - &cred_def.value.primary, - cred_def.value.revocation.as_ref(), - )?; - - let cred_values = { - let mut builder = UrsaIssuer::new_credential_values_builder()?; - builder.add_value_hidden("master_secret", &master_secret.value()?)?; - builder.finalize()? - }; - - let blinded_secrets = UrsaProver::blind_credential_secrets( - &credential_pub_key, - &credential_offer.key_correctness_proof, - &cred_values, - &credential_offer.nonce, - )?; - - let res = Ok(blinded_secrets); - trace!("new_credential_request < {:?}", res); - res - } - - pub fn process_credential( - &self, - credential: &mut Credential, - cred_request_metadata: &CredentialRequestMetadata, - master_secret: &MasterSecret, - cred_def: &CredentialDefinition, - rev_reg_def: Option<&RevocationRegistryDefinitionV1>, - ) -> IndyResult<()> { - trace!( - "process_credential > credential {:?} cred_request_metadata {:?} master_secret {:?} \ - cred_def {:?} rev_reg_def {:?}", - credential, - cred_request_metadata, - secret!(&master_secret), - cred_def, - rev_reg_def - ); - - let credential_pub_key = CredentialPublicKey::build_from_parts( - &cred_def.value.primary, - cred_def.value.revocation.as_ref(), - )?; - - let credential_values = - AnoncredsHelpers::build_credential_values(&credential.values.0, Some(master_secret))?; - - UrsaProver::process_credential_signature( - &mut credential.signature, - &credential_values, - &credential.signature_correctness_proof, - &cred_request_metadata.master_secret_blinding_data, - &credential_pub_key, - &cred_request_metadata.nonce, - rev_reg_def - .as_ref() - .map(|r_reg_def| &r_reg_def.value.public_keys.accum_key), - credential.rev_reg.as_ref(), - credential.witness.as_ref(), - )?; - - let res = Ok(()); - trace!("process_credential < {:?}", res); - res - } - - pub fn create_proof( - &self, - credentials: &HashMap, - proof_req: &ProofRequest, - requested_credentials: &RequestedCredentials, - master_secret: &MasterSecret, - schemas: &HashMap, - cred_defs: &HashMap, - 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 - ); - - let proof_req_val = proof_req.value(); - - let mut proof_builder = { - let mut builder = UrsaProver::new_proof_builder()?; - builder.add_common_attribute("master_secret")?; - builder - }; - - let mut requested_proof = { - let mut rp = RequestedProof::default(); - rp.self_attested_attrs = requested_credentials.self_attested_attributes.clone(); - rp - }; - - let credentials_for_proving = - Self::_prepare_credentials_for_proving(requested_credentials, proof_req_val)?; - - let non_credential_schema = AnoncredsHelpers::build_non_credential_schema()?; - let mut identifiers: Vec = Vec::with_capacity(credentials_for_proving.len()); - let mut sub_proof_index = 0; - - for (cred_key, (req_attrs_for_cred, req_predicates_for_cred)) in credentials_for_proving { - let credential = credentials.get(cred_key.cred_id.as_str()).ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidStructure, - format!("Credential not found by id {:?}", cred_key.cred_id), - ) - })?; - - let schema = schemas.get(&credential.schema_id).ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidStructure, - format!("Schema not found by id {:?}", credential.schema_id), - ) - })?; - - let cred_def = cred_defs.get(&credential.cred_def_id).ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidStructure, - format!( - "CredentialDefinition not found by id {:?}", - credential.cred_def_id - ), - ) - })?; - - let rev_state = if let Some(timestamp) = cred_key.timestamp { - let rev_reg_id = credential.rev_reg_id.clone().ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidStructure, - "Revocation Registry Id not found", - ) - })?; - - 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).ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidStructure, - format!("RevocationInfo not found by timestamp {:?}", timestamp), - ) - })?) - } else { - None - }; - - let credential_pub_key = CredentialPublicKey::build_from_parts( - &cred_def.value.primary, - cred_def.value.revocation.as_ref(), - )?; - - let credential_schema = - AnoncredsHelpers::build_credential_schema(&schema.attr_names.0)?; - - let credential_values = AnoncredsHelpers::build_credential_values( - &credential.values.0, - Some(master_secret), - )?; - - let sub_proof_request = - Self::_build_sub_proof_request(&req_attrs_for_cred, &req_predicates_for_cred)?; - - proof_builder.add_sub_proof_request( - &sub_proof_request, - &credential_schema, - &non_credential_schema, - &credential.signature, - &credential_values, - &credential_pub_key, - rev_state.as_ref().map(|r_info| &r_info.rev_reg), - rev_state.as_ref().map(|r_info| &r_info.witness), - )?; - - let identifier = match proof_req { - ProofRequest::ProofRequestV1(_) => Identifier { - schema_id: credential.schema_id.to_unqualified(), - cred_def_id: credential.cred_def_id.to_unqualified(), - rev_reg_id: credential.rev_reg_id.as_ref().map(|id| id.to_unqualified()), - timestamp: cred_key.timestamp, - }, - ProofRequest::ProofRequestV2(_) => Identifier { - schema_id: credential.schema_id.clone(), - cred_def_id: credential.cred_def_id.clone(), - rev_reg_id: credential.rev_reg_id.clone(), - timestamp: cred_key.timestamp, - }, - }; - - identifiers.push(identifier); - - Self::_update_requested_proof( - req_attrs_for_cred, - req_predicates_for_cred, - proof_req_val, - credential, - sub_proof_index, - &mut requested_proof, - )?; - - sub_proof_index += 1; - } - - let proof = proof_builder.finalize(&proof_req_val.nonce)?; - - let full_proof = Proof { - proof, - requested_proof, - identifiers, - }; - - let res = Ok(full_proof); - trace!("create_proof < {:?}", res); - res - } - - pub fn _prepare_credentials_for_proving( - requested_credentials: &RequestedCredentials, - proof_req: &ProofRequestPayload, - ) -> IndyResult< - HashMap, Vec)>, - > { - trace!( - "_prepare_credentials_for_proving > requested_credentials {:?} proof_req {:?}", - requested_credentials, - proof_req - ); - - let mut credentials_for_proving: HashMap< - ProvingCredentialKey, - (Vec, Vec), - > = HashMap::new(); - - for (attr_referent, requested_attr) in requested_credentials.requested_attributes.iter() { - let attr_info = proof_req - .requested_attributes - .get(attr_referent.as_str()) - .ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidStructure, - format!( - "AttributeInfo not found in ProofRequest for referent \"{}\"", - attr_referent.as_str() - ), - ) - })?; - - let req_attr_info = RequestedAttributeInfo { - attr_referent: attr_referent.clone(), - attr_info: attr_info.clone(), - revealed: requested_attr.revealed, - }; - - match credentials_for_proving.entry(ProvingCredentialKey { - cred_id: requested_attr.cred_id.clone(), - timestamp: requested_attr.timestamp, - }) { - Entry::Occupied(cred_for_proving) => { - let &mut (ref mut attributes_for_credential, _) = cred_for_proving.into_mut(); - attributes_for_credential.push(req_attr_info); - } - Entry::Vacant(attributes_for_credential) => { - attributes_for_credential.insert((vec![req_attr_info], Vec::new())); - } - }; - } - - for (predicate_referent, proving_cred_key) in - requested_credentials.requested_predicates.iter() - { - let predicate_info = proof_req - .requested_predicates - .get(predicate_referent.as_str()) - .ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidStructure, - format!( - "PredicateInfo not found in ProofRequest for referent \"{}\"", - predicate_referent.as_str() - ), - ) - })?; - - let req_predicate_info = RequestedPredicateInfo { - predicate_referent: predicate_referent.clone(), - predicate_info: predicate_info.clone(), - }; - - match credentials_for_proving.entry(proving_cred_key.clone()) { - Entry::Occupied(cred_for_proving) => { - let &mut (_, ref mut predicates_for_credential) = cred_for_proving.into_mut(); - predicates_for_credential.push(req_predicate_info); - } - Entry::Vacant(v) => { - v.insert((Vec::new(), vec![req_predicate_info])); - } - }; - } - - let res = Ok(credentials_for_proving); - trace!("_prepare_credentials_for_proving < {:?}", res); - res - } - - pub fn get_credential_values_for_attribute( - &self, - credential_attrs: &HashMap, - requested_attr: &str, - ) -> Option { - trace!( - "get_credential_values_for_attribute > credential_attrs {:?} requested_attr {:?}", - credential_attrs, - requested_attr - ); - - let res = Self::_get_credential_values_for_attribute(credential_attrs, requested_attr); - - trace!("get_credential_values_for_attribute < {:?}", res); - res - } - - fn _get_credential_values_for_attribute( - credential_attrs: &HashMap, - requested_attr: &str, - ) -> Option { - credential_attrs - .iter() - .find(|&(ref key, _)| { - AnoncredsHelpers::attr_common_view(key) - == AnoncredsHelpers::attr_common_view(&requested_attr) - }) - .map(|(_, values)| values.clone()) - } - - pub fn build_credential_tags( - &self, - credential: &Credential, - catpol: Option<&CredentialAttrTagPolicy>, - ) -> IndyResult> { - trace!( - "build_credential_tags > credential {:?} catpol {:?}", - credential, - catpol - ); - - let mut res: HashMap = HashMap::new(); - - let (schema_issuer_did, schema_name, schema_version) = - credential.schema_id.parts().ok_or(IndyError::from_msg( - IndyErrorKind::InvalidState, - format!( - "Invalid Schema ID `{}`: wrong number of parts", - credential.schema_id.0 - ), - ))?; - - let issuer_did = credential - .cred_def_id - .issuer_did() - .ok_or(IndyError::from_msg( - IndyErrorKind::InvalidState, - format!( - "Invalid Credential Definition ID `{}`: wrong number of parts", - credential.cred_def_id.0 - ), - ))?; - - res.insert("schema_id".to_string(), credential.schema_id.0.to_string()); - - res.insert( - "schema_issuer_did".to_string(), - schema_issuer_did.0.to_string(), - ); - - res.insert("schema_name".to_string(), schema_name); - res.insert("schema_version".to_string(), schema_version); - res.insert("issuer_did".to_string(), issuer_did.0.to_string()); - - res.insert( - "cred_def_id".to_string(), - credential.cred_def_id.0.to_string(), - ); - - res.insert( - "rev_reg_id".to_string(), - credential - .rev_reg_id - .as_ref() - .map(|rev_reg_id| rev_reg_id.0.clone()) - .unwrap_or_else(|| "None".to_string()), - ); - - if credential.cred_def_id.is_fully_qualified() { - res.insert( - Credential::add_extra_tag_suffix("schema_id"), - credential.schema_id.to_unqualified().0, - ); - - res.insert( - Credential::add_extra_tag_suffix("schema_issuer_did"), - schema_issuer_did.to_unqualified().0, - ); - - res.insert( - Credential::add_extra_tag_suffix("issuer_did"), - issuer_did.to_unqualified().0, - ); - - res.insert( - Credential::add_extra_tag_suffix("cred_def_id"), - credential.cred_def_id.to_unqualified().0, - ); - - res.insert( - Credential::add_extra_tag_suffix("rev_reg_id"), - credential - .rev_reg_id - .as_ref() - .map(|rev_reg_id| rev_reg_id.to_unqualified().0.clone()) - .unwrap_or_else(|| "None".to_string()), - ); - } - - credential.values.0.iter().for_each(|(attr, values)| { - if catpol - .map(|cp| cp.is_taggable(attr.as_str())) - .unwrap_or(true) - { - // abstain for attrs policy marks untaggable - res.insert( - Self::_build_attr_marker_tag(attr), - ATTRIBUTE_EXISTENCE_MARKER.to_string(), - ); - - res.insert(Self::_build_attr_value_tag(attr), values.raw.clone()); - } - }); - - let res = Ok(res); - trace!("build_credential_tags < {:?}", res); - res - } - - fn _build_attr_marker_tag(attr: &str) -> String { - format!( - "attr::{}::marker", - AnoncredsHelpers::attr_common_view(&attr) - ) - } - - fn _build_attr_value_tag(attr: &str) -> String { - format!("attr::{}::value", AnoncredsHelpers::attr_common_view(&attr)) - } - - pub fn attribute_satisfy_predicate( - &self, - predicate: &PredicateInfo, - attribute_value: &str, - ) -> IndyResult { - trace!( - "attribute_satisfy_predicate > predicate {:?} attribute_value {:?}", - predicate, - attribute_value - ); - - let res = match predicate.p_type { - PredicateTypes::GE => { - let attribute_value = attribute_value.parse::().to_indy( - IndyErrorKind::InvalidStructure, - format!( - "Credential attribute value \"{:?}\" is invalid", - attribute_value - ), - )?; - Ok(attribute_value >= predicate.p_value) - } - PredicateTypes::GT => { - let attribute_value = attribute_value.parse::().to_indy( - IndyErrorKind::InvalidStructure, - format!( - "Credential attribute value \"{:?}\" is invalid", - attribute_value - ), - )?; - Ok(attribute_value > predicate.p_value) - } - PredicateTypes::LE => { - let attribute_value = attribute_value.parse::().to_indy( - IndyErrorKind::InvalidStructure, - format!( - "Credential attribute value \"{:?}\" is invalid", - attribute_value - ), - )?; - Ok(attribute_value <= predicate.p_value) - } - PredicateTypes::LT => { - let attribute_value = attribute_value.parse::().to_indy( - IndyErrorKind::InvalidStructure, - format!( - "Credential attribute value \"{:?}\" is invalid", - attribute_value - ), - )?; - Ok(attribute_value < predicate.p_value) - } - }; - - trace!("attribute_satisfy_predicate < {:?}", res); - res - } - - fn _update_requested_proof( - req_attrs_for_credential: Vec, - req_predicates_for_credential: Vec, - proof_req: &ProofRequestPayload, - credential: &Credential, - sub_proof_index: u32, - requested_proof: &mut RequestedProof, - ) -> IndyResult<()> { - trace!( - "_update_requested_proof > req_attrs_for_credential {:?} \ - req_predicates_for_credential {:?} proof_req {:?} credential {:?} sub_proof_index \ - {:?} requested_proof {:?}", - req_attrs_for_credential, - req_predicates_for_credential, - proof_req, - credential, - sub_proof_index, - requested_proof - ); - - for attr_info in req_attrs_for_credential { - if attr_info.revealed { - let attribute = &proof_req.requested_attributes[&attr_info.attr_referent]; - - if let Some(name) = &attribute.name { - let attribute_values = - Self::_get_credential_values_for_attribute(&credential.values.0, &name) - .ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidStructure, - format!("Credential value not found for attribute {:?}", name), - ) - })?; - - requested_proof.revealed_attrs.insert( - attr_info.attr_referent.clone(), - RevealedAttributeInfo { - sub_proof_index, - raw: attribute_values.raw, - encoded: attribute_values.encoded, - }, - ); - } else if let Some(names) = &attribute.names { - let mut value_map: HashMap = HashMap::new(); - - for name in names { - let attr_value = - Self::_get_credential_values_for_attribute(&credential.values.0, &name) - .ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidStructure, - format!( - "Credential value not found for attribute {:?}", - name - ), - ) - })?; - - value_map.insert( - name.clone(), - AttributeValue { - raw: attr_value.raw, - encoded: attr_value.encoded, - }, - ); - } - - requested_proof.revealed_attr_groups.insert( - attr_info.attr_referent.clone(), - RevealedAttributeGroupInfo { - sub_proof_index, - values: value_map, - }, - ); - } - } else { - requested_proof.unrevealed_attrs.insert( - attr_info.attr_referent, - SubProofReferent { sub_proof_index }, - ); - } - } - - for predicate_info in req_predicates_for_credential { - requested_proof.predicates.insert( - predicate_info.predicate_referent, - SubProofReferent { sub_proof_index }, - ); - } - - let res = Ok(()); - trace!("_update_requested_proof < {:?}", res); - res - } - - fn _build_sub_proof_request( - req_attrs_for_credential: &[RequestedAttributeInfo], - req_predicates_for_credential: &[RequestedPredicateInfo], - ) -> IndyResult { - trace!( - "_build_sub_proof_request > req_attrs_for_credential {:?} \ - req_predicates_for_credential {:?}", - req_attrs_for_credential, - req_predicates_for_credential - ); - - let sub_proof_request = { - let mut builder = UrsaVerifier::new_sub_proof_request_builder()?; - - for attr in req_attrs_for_credential { - if !attr.revealed { - continue; - } - - if let Some(ref name) = &attr.attr_info.name { - builder.add_revealed_attr(&AnoncredsHelpers::attr_common_view(name))? - } - - if let Some(ref names) = &attr.attr_info.names { - for name in names { - builder.add_revealed_attr(&AnoncredsHelpers::attr_common_view(name))? - } - } - } - - for predicate in req_predicates_for_credential { - builder.add_predicate( - &AnoncredsHelpers::attr_common_view(&predicate.predicate_info.name), - &predicate.predicate_info.p_type.to_string(), - predicate.predicate_info.p_value, - )?; - } - - builder.finalize()? - }; - - let res = Ok(sub_proof_request); - trace!("_build_sub_proof_request < {:?}", res); - res - } - - pub fn process_proof_request_restrictions( - &self, - version: &ProofRequestsVersion, - name: &Option, - names: &Option>, - referent: &str, - restrictions: &Option, - extra_query: &Option<&ProofRequestExtraQuery>, - ) -> IndyResult { - trace!( - "process_proof_request_restrictions > version {:?} name {:?} names {:?} referent {:?} \ - restrictions {:?} extra_query {:?}", - version, - name, - names, - referent, - restrictions, - extra_query - ); - - let mut queries: Vec = Vec::new(); - - let mut attr_queries: Vec = name - .iter() - .chain(names.iter().flatten()) - .map(|name| { - Query::Eq( - Self::_build_attr_marker_tag(name), - ATTRIBUTE_EXISTENCE_MARKER.to_string(), - ) - }) - .collect(); - - if attr_queries.is_empty() { - Err(IndyError::from_msg( - IndyErrorKind::InvalidStructure, - r#"Proof Request attribute restriction should contain "name" or "names" param"#, - ))?; - } - - if let Some(restrictions_) = restrictions.clone() { - match version { - ProofRequestsVersion::V1 => { - let insensitive_restrictions = - Self::_make_restrictions_by_internal_tags_case_insensitive(restrictions_)?; - queries.push(self._double_restrictions(insensitive_restrictions)?) - } - ProofRequestsVersion::V2 => { - let insensitive_restrictions = - Self::_make_restrictions_by_internal_tags_case_insensitive(restrictions_)?; - queries.push(insensitive_restrictions) - } - }; - } - - if let Some(extra_query_) = extra_query.as_ref().and_then(|query| query.get(referent)) { - 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); - - let res = Ok(Query::And(queries)); - trace!("process_proof_request_restrictions < {:?}", res); - res - } - - fn _make_restrictions_by_internal_tags_case_insensitive(operator: Query) -> IndyResult { - let query = match operator { - Query::Eq(tag_name, tag_value) => { - if let Some(tag_name) = VerifierService::attr_request_by_value(&tag_name) { - Query::Eq(Self::_build_attr_value_tag(tag_name), tag_value) - } else if let Some(tag_name) = VerifierService::attr_request_by_marker(&tag_name) { - Query::Eq(Self::_build_attr_marker_tag(tag_name), tag_value) - } else { - Query::Eq(tag_name, tag_value) - } - } - Query::Neq(tag_name, tag_value) => { - if let Some(tag_name) = VerifierService::attr_request_by_value(&tag_name) { - Query::Neq(Self::_build_attr_value_tag(tag_name), tag_value) - } else if let Some(tag_name) = VerifierService::attr_request_by_marker(&tag_name) { - Query::Neq(Self::_build_attr_marker_tag(tag_name), tag_value) - } else { - Query::Neq(tag_name, tag_value) - } - } - Query::In(tag_name, tag_values) => { - if let Some(tag_name) = VerifierService::attr_request_by_value(&tag_name) { - Query::In(Self::_build_attr_value_tag(tag_name), tag_values) - } else if let Some(tag_name) = VerifierService::attr_request_by_marker(&tag_name) { - Query::In(Self::_build_attr_marker_tag(tag_name), tag_values) - } else { - Query::In(tag_name, tag_values) - } - } - Query::And(operators) => Query::And( - operators - .into_iter() - .map(|op| Self::_make_restrictions_by_internal_tags_case_insensitive(op)) - .collect::>>()?, - ), - Query::Or(operators) => Query::Or( - operators - .into_iter() - .map(|op| Self::_make_restrictions_by_internal_tags_case_insensitive(op)) - .collect::>>()?, - ), - Query::Not(operator) => Query::Not(::std::boxed::Box::new( - Self::_make_restrictions_by_internal_tags_case_insensitive(*operator)?, - )), - _ => { - return Err(IndyError::from_msg( - IndyErrorKind::InvalidStructure, - "unsupported operator", - )) - } - }; - - Ok(query) - } - - fn _double_restrictions(&self, operator: Query) -> IndyResult { - let query = match operator { - Query::Eq(tag_name, tag_value) => { - if Credential::QUALIFIABLE_TAGS.contains(&tag_name.as_str()) { - Query::Or(vec![ - Query::Eq(tag_name.clone(), tag_value.clone()), - Query::Eq(Credential::add_extra_tag_suffix(&tag_name), tag_value), - ]) - } else { - Query::Eq(tag_name, tag_value) - } - } - Query::Neq(tag_name, tag_value) => { - if Credential::QUALIFIABLE_TAGS.contains(&tag_name.as_str()) { - Query::And(vec![ - Query::Neq(tag_name.clone(), tag_value.clone()), - Query::Neq(Credential::add_extra_tag_suffix(&tag_name), tag_value), - ]) - } else { - Query::Neq(tag_name, tag_value) - } - } - Query::In(tag_name, tag_values) => { - if Credential::QUALIFIABLE_TAGS.contains(&tag_name.as_str()) { - Query::Or(vec![ - Query::In(tag_name.clone(), tag_values.clone()), - Query::In(Credential::add_extra_tag_suffix(&&tag_name), tag_values), - ]) - } else { - Query::In(tag_name, tag_values) - } - } - Query::And(operators) => Query::And( - operators - .into_iter() - .map(|op| self._double_restrictions(op)) - .collect::>>()?, - ), - Query::Or(operators) => Query::Or( - operators - .into_iter() - .map(|op| self._double_restrictions(op)) - .collect::>>()?, - ), - Query::Not(operator) => Query::Not(::std::boxed::Box::new( - self._double_restrictions(*operator)?, - )), - _ => { - return Err(IndyError::from_msg( - IndyErrorKind::InvalidStructure, - "unsupported operator", - )) - } - }; - - Ok(query) - } -} - -#[cfg(test)] -mod tests { - use super::*; - - const SCHEMA_ID: &str = "NcYxiDXkpYi6ov5FcYDi1e:2:gvt:1.0"; - const SCHEMA_ISSUER_DID: &str = "NcYxiDXkpYi6ov5FcYDi1e"; - const SCHEMA_NAME: &str = "gvt"; - const SCHEMA_VERSION: &str = "1.0"; - const ISSUER_DID: &str = "NcYxiDXkpYi6ov5FcYDi1e"; - const CRED_DEF_ID: &str = "NcYxiDXkpYi6ov5FcYDi1e:3:CL:1:tag"; - const REV_REG_ID: &str = "NcYxiDXkpYi6ov5FcYDi1e:4:NcYxiDXkpYi6ov5FcYDi1e:3:CL:\ - NcYxiDXkpYi6ov5FcYDi1e:2:gvt:1.0:tag:CL_ACCUM:TAG_1"; - const NO_REV_REG_ID: &str = "None"; - - macro_rules! hashmap { - ($( $key: expr => $val: expr ),*) => { - { - let mut map = ::std::collections::HashMap::new(); - $( - map.insert($key, $val); - )* - map - } - } - } - - 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 so Alex -> 12345 is an application choice - // while 25 -> 25 is not - let mut attr_values: HashMap = HashMap::new(); - attr_values.insert( - "name".to_string(), - AttributeValues { - raw: "Alex".to_string(), - encoded: "12345".to_string(), - }, - ); - attr_values.insert( - "age".to_string(), - AttributeValues { - raw: "25".to_string(), - encoded: "25".to_string(), - }, - ); - - serde_json::from_str::( - &json!({ - "schema_id": SCHEMA_ID, - "cred_def_id": CRED_DEF_ID, - "values": attr_values, - "signature": json!({ - "p_credential": json!({"m_2": "0","a": "0","e": "0","v": "0"}) - }), - "signature_correctness_proof": json!({"se":"0", "c":"0"}) - }) - .to_string(), - ) - .unwrap() - } - - #[test] - fn build_credential_tags_works() { - let ps = ProverService::new(); - let tags = ps.build_credential_tags(&_credential(), None).unwrap(); - - let expected_tags: HashMap = hashmap!( - "schema_id".to_string() => SCHEMA_ID.to_string(), - "schema_issuer_did".to_string() => SCHEMA_ISSUER_DID.to_string(), - "schema_name".to_string() => SCHEMA_NAME.to_string(), - "schema_version".to_string() => SCHEMA_VERSION.to_string(), - "issuer_did".to_string() => ISSUER_DID.to_string(), - "cred_def_id".to_string() => CRED_DEF_ID.to_string(), - "rev_reg_id".to_string() => NO_REV_REG_ID.to_string(), - "attr::name::marker".to_string() => ATTRIBUTE_EXISTENCE_MARKER.to_string(), - "attr::name::value".to_string() => "Alex".to_string(), - "attr::age::marker".to_string() => ATTRIBUTE_EXISTENCE_MARKER.to_string(), - "attr::age::value".to_string() => "25".to_string() - ); - - assert_eq!(expected_tags, tags) - } - - #[test] - fn build_credential_tags_works_for_catpol() { - let ps = ProverService::new(); - let catpol = CredentialAttrTagPolicy::from(vec![String::from("name")]); - let tags = ps - .build_credential_tags(&_credential(), Some(catpol).as_ref()) - .unwrap(); - - let expected_tags: HashMap = hashmap!( - "schema_id".to_string() => SCHEMA_ID.to_string(), - "schema_issuer_did".to_string() => SCHEMA_ISSUER_DID.to_string(), - "schema_name".to_string() => SCHEMA_NAME.to_string(), - "schema_version".to_string() => SCHEMA_VERSION.to_string(), - "issuer_did".to_string() => ISSUER_DID.to_string(), - "cred_def_id".to_string() => CRED_DEF_ID.to_string(), - "rev_reg_id".to_string() => NO_REV_REG_ID.to_string(), - "attr::name::marker".to_string() => ATTRIBUTE_EXISTENCE_MARKER.to_string(), - "attr::name::value".to_string() => "Alex".to_string() - ); - - assert_eq!(expected_tags, tags) - } - - #[test] - fn build_credential_tags_works_for_rev_reg_id() { - let ps = ProverService::new(); - let mut credential = _credential(); - credential.rev_reg_id = Some(RevocationRegistryId(REV_REG_ID.to_string())); - let tags = ps.build_credential_tags(&credential, None).unwrap(); - - let expected_tags: HashMap = hashmap!( - "schema_id".to_string() => SCHEMA_ID.to_string(), - "schema_issuer_did".to_string() => SCHEMA_ISSUER_DID.to_string(), - "schema_name".to_string() => SCHEMA_NAME.to_string(), - "schema_version".to_string() => SCHEMA_VERSION.to_string(), - "issuer_did".to_string() => ISSUER_DID.to_string(), - "cred_def_id".to_string() => CRED_DEF_ID.to_string(), - "rev_reg_id".to_string() => REV_REG_ID.to_string(), - "attr::name::marker".to_string() => ATTRIBUTE_EXISTENCE_MARKER.to_string(), - "attr::name::value".to_string() => "Alex".to_string(), - "attr::age::marker".to_string() => ATTRIBUTE_EXISTENCE_MARKER.to_string(), - "attr::age::value".to_string() => "25".to_string() - ); - - assert_eq!(expected_tags, tags) - } - - #[test] - fn build_credential_tags_works_for_fully_qualified_ids() { - let ps = ProverService::new(); - - let schema_id = "did:indy:NcYxiDXkpYi6ov5FcYDi1e/anoncreds/v0/SCHEMA/gvt/1.0"; - let issuer_did = "did:indy:NcYxiDXkpYi6ov5FcYDi1e"; - let cred_def_id = "did:indy:NcYxiDXkpYi6ov5FcYDi1e/anoncreds/v0/CLAIM_DEF/1/tag"; - let rev_reg_id = "did:indy:NcYxiDXkpYi6ov5FcYDi1e/anoncreds/v0/REV_REG_DEF/did:indy:\ - NcYxiDXkpYi6ov5FcYDi1e/anoncreds/v0/SCHEMA/gvt/1.0/tag/TAG_1"; - - let mut credential = _credential(); - credential.schema_id = SchemaId(schema_id.to_string()); - credential.cred_def_id = CredentialDefinitionId(cred_def_id.to_string()); - credential.rev_reg_id = Some(RevocationRegistryId(rev_reg_id.to_string())); - - let tags = ps.build_credential_tags(&credential, None).unwrap(); - - let expected_tags: HashMap = hashmap!( - "schema_id".to_string() => schema_id.to_string(), - "schema_id_short".to_string() => SCHEMA_ID.to_string(), - "schema_issuer_did".to_string() => issuer_did.to_string(), - "schema_issuer_did_short".to_string() => ISSUER_DID.to_string(), - "schema_name".to_string() => SCHEMA_NAME.to_string(), - "schema_version".to_string() => SCHEMA_VERSION.to_string(), - "issuer_did".to_string() => issuer_did.to_string(), - "issuer_did_short".to_string() => ISSUER_DID.to_string(), - "cred_def_id".to_string() => cred_def_id.to_string(), - "cred_def_id_short".to_string() => CRED_DEF_ID.to_string(), - "rev_reg_id".to_string() => rev_reg_id.to_string(), - "rev_reg_id_short".to_string() => REV_REG_ID.to_string(), - "attr::name::marker".to_string() => ATTRIBUTE_EXISTENCE_MARKER.to_string(), - "attr::name::value".to_string() => "Alex".to_string(), - "attr::age::marker".to_string() => ATTRIBUTE_EXISTENCE_MARKER.to_string(), - "attr::age::value".to_string() => "25".to_string() - ); - - assert_eq!(expected_tags, tags) - } - } - - mod attribute_satisfy_predicate { - use super::*; - - fn predicate_info() -> PredicateInfo { - PredicateInfo { - name: "age".to_string(), - p_type: PredicateTypes::GE, - p_value: 8, - restrictions: None, - non_revoked: None, - } - } - - #[test] - fn attribute_satisfy_predicate_works() { - let ps = ProverService::new(); - let res = ps - .attribute_satisfy_predicate(&predicate_info(), "10") - .unwrap(); - assert!(res); - } - - #[test] - fn attribute_satisfy_predicate_works_for_false() { - let ps = ProverService::new(); - let res = ps - .attribute_satisfy_predicate(&predicate_info(), "5") - .unwrap(); - assert!(!res); - } - - #[test] - fn attribute_satisfy_predicate_works_for_invalid_attribute_value() { - let ps = ProverService::new(); - let res = ps.attribute_satisfy_predicate(&predicate_info(), "string"); - assert_kind!(IndyErrorKind::InvalidStructure, res); - } - } - - mod prepare_credentials_for_proving { - use super::*; - use crate::domain::anoncreds::{ - proof_request::{AttributeInfo, PredicateInfo}, - requested_credential::RequestedAttribute, - }; - - const CRED_ID: &str = "8591bcac-ee7d-4bef-ba7e-984696440b30"; - const ATTRIBUTE_REFERENT: &str = "attribute_referent"; - const PREDICATE_REFERENT: &str = "predicate_referent"; - - fn _attr_info() -> AttributeInfo { - AttributeInfo { - name: Some("name".to_string()), - names: None, - restrictions: None, - non_revoked: None, - } - } - - fn _predicate_info() -> PredicateInfo { - PredicateInfo { - name: "age".to_string(), - p_type: PredicateTypes::GE, - p_value: 8, - restrictions: None, - non_revoked: None, - } - } - - fn _proof_req() -> ProofRequestPayload { - ProofRequestPayload { - nonce: ursa::cl::new_nonce().unwrap(), - name: "Job-Application".to_string(), - version: "0.1".to_string(), - requested_attributes: hashmap!( - ATTRIBUTE_REFERENT.to_string() => _attr_info() - ), - requested_predicates: hashmap!( - PREDICATE_REFERENT.to_string() => _predicate_info() - ), - non_revoked: None, - } - } - - fn _req_cred() -> RequestedCredentials { - RequestedCredentials { - self_attested_attributes: HashMap::new(), - requested_attributes: hashmap!( - ATTRIBUTE_REFERENT.to_string() => RequestedAttribute{ - cred_id: CRED_ID.to_string(), - timestamp: None, - revealed: false, - } - ), - requested_predicates: hashmap!( - PREDICATE_REFERENT.to_string() => ProvingCredentialKey{ cred_id: CRED_ID.to_string(), timestamp: None } - ), - } - } - - #[test] - fn prepare_credentials_for_proving_works() { - let req_cred = _req_cred(); - let proof_req = _proof_req(); - - let res = - ProverService::_prepare_credentials_for_proving(&req_cred, &proof_req).unwrap(); - - assert_eq!(1, res.len()); - assert!(res.contains_key(&ProvingCredentialKey { - cred_id: CRED_ID.to_string(), - timestamp: None - })); - - let (req_attr_info, req_pred_info) = res - .get(&ProvingCredentialKey { - cred_id: CRED_ID.to_string(), - timestamp: None, - }) - .unwrap(); - assert_eq!(1, req_attr_info.len()); - assert_eq!(1, req_pred_info.len()); - } - - #[test] - fn prepare_credentials_for_proving_works_for_multiple_attributes_with_same_credential() { - let mut req_cred = _req_cred(); - let mut proof_req = _proof_req(); - - req_cred.requested_attributes.insert( - "attribute_referent_2".to_string(), - RequestedAttribute { - cred_id: CRED_ID.to_string(), - timestamp: None, - revealed: false, - }, - ); - - proof_req.requested_attributes.insert( - "attribute_referent_2".to_string(), - AttributeInfo { - name: Some("last_name".to_string()), - names: None, - restrictions: None, - non_revoked: None, - }, - ); - - let res = - ProverService::_prepare_credentials_for_proving(&req_cred, &proof_req).unwrap(); - - assert_eq!(1, res.len()); - assert!(res.contains_key(&ProvingCredentialKey { - cred_id: CRED_ID.to_string(), - timestamp: None - })); - - let (req_attr_info, req_pred_info) = res - .get(&ProvingCredentialKey { - cred_id: CRED_ID.to_string(), - timestamp: None, - }) - .unwrap(); - assert_eq!(2, req_attr_info.len()); - assert_eq!(1, req_pred_info.len()); - } - - #[test] - fn prepare_credentials_for_proving_works_for_missed_attribute() { - let req_cred = _req_cred(); - let mut proof_req = _proof_req(); - - proof_req.requested_attributes.clear(); - - let res = ProverService::_prepare_credentials_for_proving(&req_cred, &proof_req); - assert_kind!(IndyErrorKind::InvalidStructure, res); - } - - #[test] - fn prepare_credentials_for_proving_works_for_missed_predicate() { - let req_cred = _req_cred(); - let mut proof_req = _proof_req(); - - proof_req.requested_predicates.clear(); - - let res = ProverService::_prepare_credentials_for_proving(&req_cred, &proof_req); - assert_kind!(IndyErrorKind::InvalidStructure, res); - } - } - - mod get_credential_values_for_attribute { - use super::*; - - fn _attr_values() -> AttributeValues { - AttributeValues { - raw: "Alex".to_string(), - encoded: "123".to_string(), - } - } - - fn _cred_values() -> HashMap { - hashmap!("name".to_string() => _attr_values()) - } - - #[test] - fn get_credential_values_for_attribute_works() { - let ps = ProverService::new(); - - let res = ps - .get_credential_values_for_attribute(&_cred_values(), "name") - .unwrap(); - assert_eq!(_attr_values(), res); - } - - #[test] - fn get_credential_values_for_attribute_works_for_requested_attr_different_case() { - let ps = ProverService::new(); - - let res = ps - .get_credential_values_for_attribute(&_cred_values(), "NAme") - .unwrap(); - assert_eq!(_attr_values(), res); - } - - #[test] - fn get_credential_values_for_attribute_works_for_requested_attr_contains_spaces() { - let ps = ProverService::new(); - - let res = ps - .get_credential_values_for_attribute(&_cred_values(), " na me ") - .unwrap(); - assert_eq!(_attr_values(), res); - } - - #[test] - fn get_credential_values_for_attribute_works_for_cred_values_different_case() { - let ps = ProverService::new(); - - let cred_values = hashmap!("NAME".to_string() => _attr_values()); - - let res = ps - .get_credential_values_for_attribute(&cred_values, "name") - .unwrap(); - assert_eq!(_attr_values(), res); - } - - #[test] - fn get_credential_values_for_attribute_works_for_cred_values_contains_spaces() { - let ps = ProverService::new(); - - let cred_values = hashmap!(" name ".to_string() => _attr_values()); - - let res = ps - .get_credential_values_for_attribute(&cred_values, "name") - .unwrap(); - assert_eq!(_attr_values(), res); - } - - #[test] - fn get_credential_values_for_attribute_works_for_cred_values_and_requested_attr_contains_spaces( - ) { - let ps = ProverService::new(); - - let cred_values = hashmap!(" name ".to_string() => _attr_values()); - - let res = ps - .get_credential_values_for_attribute(&cred_values, " name ") - .unwrap(); - assert_eq!(_attr_values(), res); - } - } - - mod extend_operator { - use super::*; - - const QUALIFIABLE_TAG: &str = "issuer_did"; - const NOT_QUALIFIABLE_TAG: &str = "name"; - const VALUE: &str = "1"; - - #[test] - fn extend_operator_works_for_qualifiable_tag() { - let ps = ProverService::new(); - - let query = Query::Eq(QUALIFIABLE_TAG.to_string(), VALUE.to_string()); - let query = ps._double_restrictions(query).unwrap(); - - let expected_query = Query::Or(vec![ - Query::Eq(QUALIFIABLE_TAG.to_string(), VALUE.to_string()), - Query::Eq( - Credential::add_extra_tag_suffix(QUALIFIABLE_TAG), - VALUE.to_string(), - ), - ]); - - assert_eq!(expected_query, query); - } - - #[test] - fn extend_operator_works_for_not_qualifiable_tag() { - let ps = ProverService::new(); - - let query = Query::Eq(NOT_QUALIFIABLE_TAG.to_string(), VALUE.to_string()); - let query = ps._double_restrictions(query).unwrap(); - - let expected_query = Query::Eq(NOT_QUALIFIABLE_TAG.to_string(), VALUE.to_string()); - - assert_eq!(expected_query, query); - } - - #[test] - fn extend_operator_works_for_qualifiable_tag_for_combination() { - let ps = ProverService::new(); - - let query = Query::And(vec![ - Query::Eq(QUALIFIABLE_TAG.to_string(), VALUE.to_string()), - Query::Eq(NOT_QUALIFIABLE_TAG.to_string(), VALUE.to_string()), - ]); - let query = ps._double_restrictions(query).unwrap(); - - let expected_query = Query::And(vec![ - Query::Or(vec![ - Query::Eq(QUALIFIABLE_TAG.to_string(), VALUE.to_string()), - Query::Eq( - Credential::add_extra_tag_suffix(QUALIFIABLE_TAG), - VALUE.to_string(), - ), - ]), - Query::Eq(NOT_QUALIFIABLE_TAG.to_string(), VALUE.to_string()), - ]); - - assert_eq!(expected_query, query); - } - } - - mod extend_proof_request_restrictions { - use super::*; - - const ATTR_NAME: &str = "name"; - const ATTR_NAME_2: &str = "name_2"; - const ATTR_REFERENT: &str = "attr_1"; - - fn _value(json: &str) -> serde_json::Value { - serde_json::from_str::(json).unwrap() - } - - #[test] - fn build_query_works() { - let ps = ProverService::new(); - - let query = ps - .process_proof_request_restrictions( - &ProofRequestsVersion::V2, - &Some(ATTR_NAME.to_string()), - &None, - ATTR_REFERENT, - &None, - &None, - ) - .unwrap(); - - let expected_query = Query::And(vec![Query::Eq( - "attr::name::marker".to_string(), - ATTRIBUTE_EXISTENCE_MARKER.to_string(), - )]); - - assert_eq!(expected_query, query); - } - - #[test] - fn build_query_works_for_name() { - let ps = ProverService::new(); - - let query = ps - .process_proof_request_restrictions( - &ProofRequestsVersion::V2, - &None, - &Some(vec![ATTR_NAME.to_string(), ATTR_NAME_2.to_string()]), - ATTR_REFERENT, - &None, - &None, - ) - .unwrap(); - - let expected_query = Query::And(vec![ - Query::Eq( - "attr::name::marker".to_string(), - ATTRIBUTE_EXISTENCE_MARKER.to_string(), - ), - Query::Eq( - "attr::name_2::marker".to_string(), - ATTRIBUTE_EXISTENCE_MARKER.to_string(), - ), - ]); - - assert_eq!(expected_query, query); - } - - #[test] - fn build_query_works_for_restriction() { - let ps = ProverService::new(); - - let restriction = 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()), - ]); - - let query = ps - .process_proof_request_restrictions( - &ProofRequestsVersion::V2, - &Some(ATTR_NAME.to_string()), - &None, - ATTR_REFERENT, - &Some(restriction), - &None, - ) - .unwrap(); - - let expected_query = Query::And(vec![ - 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); - } - - #[test] - fn build_query_works_for_extra_query() { - let ps = ProverService::new(); - - let extra_query: ProofRequestExtraQuery = hashmap!( - ATTR_REFERENT.to_string() => Query::Eq("name".to_string(), "Alex".to_string()) - ); - - let query = ps - .process_proof_request_restrictions( - &ProofRequestsVersion::V2, - &Some(ATTR_NAME.to_string()), - &None, - ATTR_REFERENT, - &None, - &Some(&extra_query), - ) - .unwrap(); - - let expected_query = Query::And(vec![ - 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); - } - - #[test] - fn build_query_works_for_mix_restriction_and_extra_query() { - let ps = ProverService::new(); - - let restriction = 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()), - ]); - - let extra_query: ProofRequestExtraQuery = hashmap!( - ATTR_REFERENT.to_string() => Query::Eq("name".to_string(), "Alex".to_string()) - ); - - let query = ps - .process_proof_request_restrictions( - &ProofRequestsVersion::V2, - &Some(ATTR_NAME.to_string()), - &None, - ATTR_REFERENT, - &Some(restriction), - &Some(&extra_query), - ) - .unwrap(); - - let expected_query = Query::And(vec![ - 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); - } - - #[test] - fn build_query_works_for_extra_query_with_other_referent() { - let ps = ProverService::new(); - - let extra_query: ProofRequestExtraQuery = hashmap!( - "other_attr_referent".to_string() => Query::Eq("name".to_string(), "Alex".to_string()) - ); - - let query = ps - .process_proof_request_restrictions( - &ProofRequestsVersion::V2, - &Some(ATTR_NAME.to_string()), - &None, - ATTR_REFERENT, - &None, - &Some(&extra_query), - ) - .unwrap(); - - let expected_query = Query::And(vec![Query::Eq( - "attr::name::marker".to_string(), - ATTRIBUTE_EXISTENCE_MARKER.to_string(), - )]); - - assert_eq!(expected_query, query); - } - - #[test] - fn build_query_works_for_restriction_and_extra_query_contain_or_operator() { - let ps = ProverService::new(); - - let restriction = Query::Or(vec![ - Query::Eq("schema_id".to_string(), SCHEMA_ID.to_string()), - Query::Eq("schema_id".to_string(), "schema_id_2".to_string()), - ]); - - let extra_query: ProofRequestExtraQuery = hashmap!( - ATTR_REFERENT.to_string() => - Query::Or(vec![ - Query::Eq("name".to_string(), "Alex".to_string()), - Query::Eq("name".to_string(), "Alexander".to_string()), - ]) - ); - - let query = ps - .process_proof_request_restrictions( - &ProofRequestsVersion::V2, - &Some(ATTR_NAME.to_string()), - &None, - ATTR_REFERENT, - &Some(restriction), - &Some(&extra_query), - ) - .unwrap(); - - let expected_query = Query::And(vec![ - Query::Or(vec![ - Query::Eq("schema_id".to_string(), SCHEMA_ID.to_string()), - Query::Eq("schema_id".to_string(), "schema_id_2".to_string()), - ]), - 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); - } - - #[test] - fn build_query_works_for_restriction_by_internal_tags() { - let ps = ProverService::new(); - - let restriction = Query::And(vec![ - Query::Eq("schema_id".to_string(), SCHEMA_ID.to_string()), - Query::Eq( - "attr::firstname::value".to_string(), - "firstname_value".to_string(), - ), - Query::Eq( - "attr::Last Name::value".to_string(), - "lastname_value".to_string(), - ), - Query::Eq("attr::File Name::marker".to_string(), "1".to_string()), - Query::Eq("attr::textresult::marker".to_string(), "1".to_string()), - ]); - - let query = ps - .process_proof_request_restrictions( - &ProofRequestsVersion::V2, - &Some(ATTR_NAME.to_string()), - &None, - ATTR_REFERENT, - &Some(restriction), - &None, - ) - .unwrap(); - - let expected_query = Query::And(vec![ - Query::And(vec![ - Query::Eq("schema_id".to_string(), SCHEMA_ID.to_string()), - Query::Eq( - "attr::firstname::value".to_string(), - "firstname_value".to_string(), - ), - Query::Eq( - "attr::lastname::value".to_string(), - "lastname_value".to_string(), - ), - Query::Eq("attr::filename::marker".to_string(), "1".to_string()), - Query::Eq("attr::textresult::marker".to_string(), "1".to_string()), - ]), - Query::Eq( - "attr::name::marker".to_string(), - ATTRIBUTE_EXISTENCE_MARKER.to_string(), - ), - ]); - - assert_eq!(expected_query, query); - } - } -} diff --git a/libvdrtools/src/services/anoncreds/verifier.rs b/libvdrtools/src/services/anoncreds/verifier.rs deleted file mode 100644 index d6937261b0..0000000000 --- a/libvdrtools/src/services/anoncreds/verifier.rs +++ /dev/null @@ -1,1400 +0,0 @@ -use std::collections::{HashMap, HashSet}; - -use indy_api_types::errors::prelude::*; -use lazy_static::lazy_static; -use regex::Regex; -use ursa::{ - bn::BigNumber, - cl::{new_nonce, verifier::Verifier as CryptoVerifier, CredentialPublicKey, Nonce}, -}; - -use crate::{ - domain::anoncreds::{ - credential_definition::{CredentialDefinitionId, CredentialDefinitionV1}, - proof::{Identifier, Proof, RequestedProof, RevealedAttributeInfo}, - proof_request::{AttributeInfo, NonRevocedInterval, PredicateInfo, ProofRequestPayload}, - revocation_registry::RevocationRegistryV1, - revocation_registry_definition::{RevocationRegistryDefinitionV1, RevocationRegistryId}, - schema::{SchemaId, SchemaV1}, - }, - services::AnoncredsHelpers, - utils::wql::Query, -}; - -#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] -pub(crate) struct Filter { - schema_id: String, - schema_issuer_did: String, - schema_name: String, - schema_version: String, - issuer_did: String, - cred_def_id: String, -} - -lazy_static! { - pub(crate) static ref VALUE_TAG_MATCHER: Regex = Regex::new("^attr::([^:]+)::value$").unwrap(); - pub(crate) static ref MARKER_TAG_MATCHER: Regex = - Regex::new("^attr::([^:]+)::marker$").unwrap(); -} - -pub struct VerifierService {} - -impl VerifierService { - pub(crate) fn new() -> VerifierService { - VerifierService {} - } - - pub(crate) fn verify( - &self, - full_proof: &Proof, - proof_req: &ProofRequestPayload, - schemas: &HashMap, - cred_defs: &HashMap, - rev_reg_defs: &HashMap, - rev_regs: &HashMap>, - ) -> IndyResult { - trace!( - "verify >>> full_proof: {:?}, proof_req: {:?}, schemas: {:?}, cred_defs: {:?}, \ - rev_reg_defs: {:?} rev_regs: {:?}", - full_proof, - proof_req, - schemas, - cred_defs, - rev_reg_defs, - rev_regs - ); - - let received_revealed_attrs: HashMap = - VerifierService::_received_revealed_attrs(&full_proof)?; - let received_unrevealed_attrs: HashMap = - VerifierService::_received_unrevealed_attrs(&full_proof)?; - let received_predicates: HashMap = - VerifierService::_received_predicates(&full_proof)?; - let received_self_attested_attrs: HashSet = - VerifierService::_received_self_attested_attrs(&full_proof); - - VerifierService::_compare_attr_from_proof_and_request( - proof_req, - &received_revealed_attrs, - &received_unrevealed_attrs, - &received_self_attested_attrs, - &received_predicates, - )?; - - VerifierService::_verify_revealed_attribute_values(&proof_req, &full_proof)?; - - VerifierService::_verify_requested_restrictions( - &proof_req, - &full_proof.requested_proof, - &received_revealed_attrs, - &received_unrevealed_attrs, - &received_predicates, - &received_self_attested_attrs, - )?; - - VerifierService::_compare_timestamps_from_proof_and_request( - proof_req, - &received_revealed_attrs, - &received_unrevealed_attrs, - &received_self_attested_attrs, - &received_predicates, - )?; - - let mut proof_verifier = CryptoVerifier::new_proof_verifier()?; - let non_credential_schema = AnoncredsHelpers::build_non_credential_schema()?; - - for sub_proof_index in 0..full_proof.identifiers.len() { - let identifier = full_proof.identifiers[sub_proof_index].clone(); - - let schema: &SchemaV1 = schemas.get(&identifier.schema_id).ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidStructure, - format!("Schema not found for id: {:?}", identifier.schema_id), - ) - })?; - - let cred_def: &CredentialDefinitionV1 = - cred_defs.get(&identifier.cred_def_id).ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidStructure, - format!( - "CredentialDefinition not found for id: {:?}", - identifier.cred_def_id - ), - ) - })?; - - let (rev_reg_def, rev_reg) = if let Some(timestamp) = identifier.timestamp { - let rev_reg_id = identifier.rev_reg_id.clone().ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidStructure, - "Revocation Registry Id not found", - ) - })?; - - let rev_reg_def = Some(rev_reg_defs.get(&rev_reg_id).ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidStructure, - format!( - "RevocationRegistryDefinition not found for id: {:?}", - identifier.rev_reg_id - ), - ) - })?); - - let rev_regs_for_cred = rev_regs.get(&rev_reg_id).ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidStructure, - format!("RevocationRegistry not found for id: {:?}", rev_reg_id), - ) - })?; - - let rev_reg = Some(rev_regs_for_cred.get(×tamp).ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidStructure, - format!( - "RevocationRegistry not found for timestamp: {:?}", - timestamp - ), - ) - })?); - - (rev_reg_def, rev_reg) - } else { - (None, None) - }; - - let attrs_for_credential = VerifierService::_get_revealed_attributes_for_credential( - sub_proof_index, - &full_proof.requested_proof, - proof_req, - )?; - let predicates_for_credential = VerifierService::_get_predicates_for_credential( - sub_proof_index, - &full_proof.requested_proof, - proof_req, - )?; - - let credential_schema = - AnoncredsHelpers::build_credential_schema(&schema.attr_names.0)?; - - let sub_proof_request = AnoncredsHelpers::build_sub_proof_request( - &attrs_for_credential, - &predicates_for_credential, - )?; - - let credential_pub_key = CredentialPublicKey::build_from_parts( - &cred_def.value.primary, - cred_def.value.revocation.as_ref(), - )?; - - proof_verifier.add_sub_proof_request( - &sub_proof_request, - &credential_schema, - &non_credential_schema, - &credential_pub_key, - rev_reg_def - .as_ref() - .map(|r_reg_def| &r_reg_def.value.public_keys.accum_key), - rev_reg.as_ref().map(|r_reg| &r_reg.value), - )?; - } - - let valid = proof_verifier.verify(&full_proof.proof, &proof_req.nonce)?; - - trace!("verify <<< valid: {:?}", valid); - - Ok(valid) - } - - pub(crate) fn generate_nonce(&self) -> IndyResult { - trace!("generate_nonce >>> "); - - let nonce = new_nonce()?; - - trace!("generate_nonce <<< nonce: {:?} ", nonce); - - Ok(nonce) - } - - fn _get_revealed_attributes_for_credential( - sub_proof_index: usize, - requested_proof: &RequestedProof, - proof_req: &ProofRequestPayload, - ) -> IndyResult> { - trace!( - "_get_revealed_attributes_for_credential >>> sub_proof_index: {:?}, \ - requested_credentials: {:?}, proof_req: {:?}", - sub_proof_index, - requested_proof, - proof_req - ); - - let mut revealed_attrs_for_credential = requested_proof - .revealed_attrs - .iter() - .filter(|&(attr_referent, ref revealed_attr_info)| { - sub_proof_index == revealed_attr_info.sub_proof_index as usize - && proof_req.requested_attributes.contains_key(attr_referent) - }) - .map(|(attr_referent, _)| proof_req.requested_attributes[attr_referent].clone()) - .collect::>(); - - revealed_attrs_for_credential.append( - &mut requested_proof - .revealed_attr_groups - .iter() - .filter(|&(attr_referent, ref revealed_attr_info)| { - sub_proof_index == revealed_attr_info.sub_proof_index as usize - && proof_req.requested_attributes.contains_key(attr_referent) - }) - .map(|(attr_referent, _)| proof_req.requested_attributes[attr_referent].clone()) - .collect::>(), - ); - - trace!( - "_get_revealed_attributes_for_credential <<< revealed_attrs_for_credential: {:?}", - revealed_attrs_for_credential - ); - - Ok(revealed_attrs_for_credential) - } - - fn _get_predicates_for_credential( - sub_proof_index: usize, - requested_proof: &RequestedProof, - proof_req: &ProofRequestPayload, - ) -> IndyResult> { - trace!( - "_get_predicates_for_credential >>> sub_proof_index: {:?}, requested_credentials: \ - {:?}, proof_req: {:?}", - sub_proof_index, - requested_proof, - proof_req - ); - - let predicates_for_credential = requested_proof - .predicates - .iter() - .filter(|&(predicate_referent, requested_referent)| { - sub_proof_index == requested_referent.sub_proof_index as usize - && proof_req - .requested_predicates - .contains_key(predicate_referent) - }) - .map(|(predicate_referent, _)| { - proof_req.requested_predicates[predicate_referent].clone() - }) - .collect::>(); - - trace!( - "_get_predicates_for_credential <<< predicates_for_credential: {:?}", - predicates_for_credential - ); - - Ok(predicates_for_credential) - } - - fn _compare_attr_from_proof_and_request( - proof_req: &ProofRequestPayload, - received_revealed_attrs: &HashMap, - received_unrevealed_attrs: &HashMap, - received_self_attested_attrs: &HashSet, - received_predicates: &HashMap, - ) -> IndyResult<()> { - let requested_attrs: HashSet = - proof_req.requested_attributes.keys().cloned().collect(); - - let received_attrs: HashSet = received_revealed_attrs - .iter() - .chain(received_unrevealed_attrs) - .map(|(r, _)| r.to_string()) - .collect::>() - .union(&received_self_attested_attrs) - .cloned() - .collect(); - - if requested_attrs != received_attrs { - return Err(err_msg( - IndyErrorKind::InvalidStructure, - format!( - "Requested attributes {:?} do not correspond to received {:?}", - requested_attrs, received_attrs - ), - )); - } - - let requested_predicates: HashSet<&String> = - proof_req.requested_predicates.keys().collect(); - - let received_predicates_: HashSet<&String> = received_predicates.keys().collect(); - - if requested_predicates != received_predicates_ { - return Err(err_msg( - IndyErrorKind::InvalidStructure, - format!( - "Requested predicates {:?} do not correspond to received {:?}", - requested_predicates, received_predicates - ), - )); - } - - Ok(()) - } - - fn _compare_timestamps_from_proof_and_request( - proof_req: &ProofRequestPayload, - received_revealed_attrs: &HashMap, - received_unrevealed_attrs: &HashMap, - received_self_attested_attrs: &HashSet, - received_predicates: &HashMap, - ) -> IndyResult<()> { - proof_req - .requested_attributes - .iter() - .map(|(referent, info)| { - VerifierService::_validate_timestamp( - &received_revealed_attrs, - referent, - &proof_req.non_revoked, - &info.non_revoked, - ) - .or_else(|_| { - VerifierService::_validate_timestamp( - &received_unrevealed_attrs, - referent, - &proof_req.non_revoked, - &info.non_revoked, - ) - }) - .or_else(|_| { - received_self_attested_attrs - .get(referent) - .map(|_| ()) - .ok_or_else(|| IndyError::from(IndyErrorKind::InvalidStructure)) - }) - }) - .collect::>>()?; - - proof_req - .requested_predicates - .iter() - .map(|(referent, info)| { - VerifierService::_validate_timestamp( - received_predicates, - referent, - &proof_req.non_revoked, - &info.non_revoked, - ) - }) - .collect::>>()?; - - Ok(()) - } - - fn _validate_timestamp( - received_: &HashMap, - referent: &str, - global_interval: &Option, - local_interval: &Option, - ) -> IndyResult<()> { - if AnoncredsHelpers::get_non_revoc_interval(global_interval, local_interval).is_none() { - return Ok(()); - } - - if !received_ - .get(referent) - .map(|attr| attr.timestamp.is_some()) - .unwrap_or(false) - { - return Err(IndyError::from(IndyErrorKind::InvalidStructure)); - } - - Ok(()) - } - - fn _received_revealed_attrs(proof: &Proof) -> IndyResult> { - let mut revealed_identifiers: HashMap = HashMap::new(); - for (referent, info) in proof.requested_proof.revealed_attrs.iter() { - revealed_identifiers.insert( - referent.to_string(), - VerifierService::_get_proof_identifier(proof, info.sub_proof_index)?, - ); - } - for (referent, infos) in proof.requested_proof.revealed_attr_groups.iter() { - revealed_identifiers.insert( - referent.to_string(), - VerifierService::_get_proof_identifier(proof, infos.sub_proof_index)?, - ); - } - Ok(revealed_identifiers) - } - - fn _received_unrevealed_attrs(proof: &Proof) -> IndyResult> { - let mut unrevealed_identifiers: HashMap = HashMap::new(); - for (referent, info) in proof.requested_proof.unrevealed_attrs.iter() { - unrevealed_identifiers.insert( - referent.to_string(), - VerifierService::_get_proof_identifier(proof, info.sub_proof_index)?, - ); - } - Ok(unrevealed_identifiers) - } - - fn _received_predicates(proof: &Proof) -> IndyResult> { - let mut predicate_identifiers: HashMap = HashMap::new(); - for (referent, info) in proof.requested_proof.predicates.iter() { - predicate_identifiers.insert( - referent.to_string(), - VerifierService::_get_proof_identifier(proof, info.sub_proof_index)?, - ); - } - Ok(predicate_identifiers) - } - - fn _received_self_attested_attrs(proof: &Proof) -> HashSet { - proof - .requested_proof - .self_attested_attrs - .keys() - .cloned() - .collect() - } - - fn _get_proof_identifier(proof: &Proof, index: u32) -> IndyResult { - proof - .identifiers - .get(index as usize) - .cloned() - .ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidStructure, - format!("Identifier not found for index: {}", index), - ) - }) - } - - fn _verify_revealed_attribute_values( - proof_req: &ProofRequestPayload, - proof: &Proof, - ) -> IndyResult<()> { - for (attr_referent, attr_info) in proof.requested_proof.revealed_attrs.iter() { - let attr_name = proof_req - .requested_attributes - .get(attr_referent) - .as_ref() - .ok_or(IndyError::from_msg( - IndyErrorKind::ProofRejected, - format!( - "Attribute with referent \"{}\" not found in ProofRequests", - attr_referent - ), - ))? - .name - .as_ref() - .ok_or(IndyError::from_msg( - IndyErrorKind::ProofRejected, - format!( - "Attribute with referent \"{}\" not found in ProofRequests", - attr_referent - ), - ))?; - VerifierService::_verify_revealed_attribute_value( - attr_name.as_str(), - proof, - &attr_info, - )?; - } - - for (attr_referent, attr_infos) in proof.requested_proof.revealed_attr_groups.iter() { - let attr_names = proof_req - .requested_attributes - .get(attr_referent) - .as_ref() - .ok_or(IndyError::from_msg( - IndyErrorKind::ProofRejected, - format!( - "Attribute with referent \"{}\" not found in ProofRequests", - attr_referent - ), - ))? - .names - .as_ref() - .ok_or(IndyError::from_msg( - IndyErrorKind::ProofRejected, - format!( - "Attribute with referent \"{}\" not found in ProofRequests", - attr_referent - ), - ))?; - if attr_infos.values.len() != attr_names.len() { - error!( - "Proof Revealed Attr Group does not match Proof Request Attribute Group, \ - proof request attrs: {:?}, referent: {:?}, attr_infos: {:?}", - proof_req.requested_attributes, attr_referent, attr_infos - ); - return Err(IndyError::from_msg( - IndyErrorKind::InvalidStructure, - "Proof Revealed Attr Group does not match Proof Request Attribute Group", - )); - } - for attr_name in attr_names { - let attr_info = &attr_infos.values.get(attr_name).ok_or(IndyError::from_msg( - IndyErrorKind::InvalidStructure, - "Proof Revealed Attr Group does not match Proof Request Attribute Group", - ))?; - VerifierService::_verify_revealed_attribute_value( - attr_name, - proof, - &RevealedAttributeInfo { - sub_proof_index: attr_infos.sub_proof_index, - raw: attr_info.raw.clone(), - encoded: attr_info.encoded.clone(), - }, - )?; - } - } - Ok(()) - } - - fn _verify_revealed_attribute_value( - attr_name: &str, - proof: &Proof, - attr_info: &RevealedAttributeInfo, - ) -> IndyResult<()> { - let reveal_attr_encoded = &attr_info.encoded; - let sub_proof_index = attr_info.sub_proof_index as usize; - - let crypto_proof_encoded = proof - .proof - .proofs - .get(sub_proof_index) - .ok_or(IndyError::from_msg( - IndyErrorKind::ProofRejected, - format!("CryptoProof not found by index \"{}\"", sub_proof_index), - ))? - .revealed_attrs()? - .iter() - .find(|(key, _)| { - AnoncredsHelpers::attr_common_view(attr_name) - == AnoncredsHelpers::attr_common_view(&key) - }) - .map(|(_, val)| val.to_string()) - .ok_or(IndyError::from_msg( - IndyErrorKind::ProofRejected, - format!( - "Attribute with name \"{}\" not found in CryptoProof", - attr_name - ), - ))?; - - if BigNumber::from_dec(reveal_attr_encoded)? != BigNumber::from_dec(&crypto_proof_encoded)? - { - return Err(IndyError::from_msg( - IndyErrorKind::ProofRejected, - format!( - "Encoded Values for \"{}\" are different in RequestedProof \"{}\" and \ - CryptoProof \"{}\"", - attr_name, reveal_attr_encoded, crypto_proof_encoded - ), - )); - } - - Ok(()) - } - - fn _verify_requested_restrictions( - proof_req: &ProofRequestPayload, - requested_proof: &RequestedProof, - received_revealed_attrs: &HashMap, - received_unrevealed_attrs: &HashMap, - received_predicates: &HashMap, - self_attested_attrs: &HashSet, - ) -> IndyResult<()> { - let proof_attr_identifiers: HashMap = received_revealed_attrs - .iter() - .chain(received_unrevealed_attrs) - .map(|(r, id)| (r.to_string(), id.clone())) - .collect(); - - let requested_attrs: HashMap = proof_req - .requested_attributes - .iter() - .filter(|&(referent, info)| { - !VerifierService::_is_self_attested(&referent, &info, self_attested_attrs) - }) - .map(|(referent, info)| (referent.to_string(), info.clone())) - .collect(); - - for (referent, info) in requested_attrs.clone() { - if let Some(ref query) = info.restrictions { - let filter = - VerifierService::_gather_filter_info(&referent, &proof_attr_identifiers)?; - - let name_value_map: HashMap> = if let Some(name) = info.name { - let mut map = HashMap::new(); - map.insert( - name.clone(), - requested_proof - .revealed_attrs - .get(&referent) - .map(|attr| attr.raw.as_str()), - ); - map - } else if let Some(names) = info.names { - let mut map = HashMap::new(); - let attrs = requested_proof.revealed_attr_groups.get(&referent).ok_or( - IndyError::from_msg( - IndyErrorKind::InvalidStructure, - "Proof does not have referent from proof request", - ), - )?; - for name in names { - let val = attrs.values.get(&name).map(|attr| attr.raw.as_str()); - map.insert(name, val); - } - map - } else { - error!( - r#"Proof Request attribute restriction should contain "name" or "names" param. Current proof request: {:?}"#, - proof_req - ); - return Err(IndyError::from_msg( - IndyErrorKind::InvalidStructure, - r#"Proof Request attribute restriction should contain "name" or "names" param"#, - )); - }; - - VerifierService::_do_process_operator(&name_value_map, &query, &filter).map_err( - |err| { - err.extend(format!( - "Requested restriction validation failed for \"{:?}\" attributes", - &name_value_map - )) - }, - )?; - } - } - - for (referent, info) in proof_req.requested_predicates.iter() { - if let Some(ref query) = info.restrictions { - let filter = VerifierService::_gather_filter_info(&referent, received_predicates)?; - - // start with the predicate requested attribute, which is un-revealed - let mut attr_value_map = HashMap::new(); - attr_value_map.insert(info.name.to_string(), None); - - // include any revealed attributes for the same credential (based on - // sub_proof_index) - let pred_sub_proof_index = requested_proof - .predicates - .get(referent) - .unwrap() - .sub_proof_index; - for attr_referent in requested_proof.revealed_attrs.keys() { - let attr_info = requested_proof.revealed_attrs.get(attr_referent).unwrap(); - let attr_sub_proof_index = attr_info.sub_proof_index; - if pred_sub_proof_index == attr_sub_proof_index { - let attr_name = requested_attrs.get(attr_referent).unwrap().name.clone(); - if let Some(name) = attr_name { - attr_value_map.insert(name, Some(attr_info.raw.as_str())); - } - } - } - for attr_referent in requested_proof.revealed_attr_groups.keys() { - let attr_info = requested_proof - .revealed_attr_groups - .get(attr_referent) - .unwrap(); - let attr_sub_proof_index = attr_info.sub_proof_index; - if pred_sub_proof_index == attr_sub_proof_index { - for name in attr_info.values.keys() { - let raw_val = attr_info.values.get(name).unwrap().raw.as_str(); - attr_value_map.insert(name.clone(), Some(raw_val)); - } - } - } - - VerifierService::_do_process_operator(&attr_value_map, &query, &filter).map_err( - |err| { - err.extend(format!( - "Requested restriction validation failed for \"{}\" predicate", - &info.name - )) - }, - )?; - - // old style :-/ which fails for attribute restrictions on predicates - //VerifierService::_process_operator(&info.name, &query, &filter, None) - // .map_err(|err| err.extend(format!("Requested restriction validation failed for - // \"{}\" predicate", &info.name)))?; - } - } - - Ok(()) - } - - fn _is_self_attested( - referent: &str, - info: &AttributeInfo, - self_attested_attrs: &HashSet, - ) -> bool { - match info.restrictions.as_ref() { - Some(&Query::And(ref array)) | Some(&Query::Or(ref array)) if array.is_empty() => { - self_attested_attrs.contains(referent) - } - None => self_attested_attrs.contains(referent), - Some(_) => false, - } - } - - fn _gather_filter_info( - referent: &str, - identifiers: &HashMap, - ) -> IndyResult { - let identifier = identifiers.get(referent).ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidState, - format!("Identifier not found for referent: {}", referent), - ) - })?; - - let (schema_issuer_did, schema_name, schema_version) = - identifier.schema_id.parts().ok_or(IndyError::from_msg( - IndyErrorKind::InvalidState, - format!( - "Invalid Schema ID `{}`: wrong number of parts", - identifier.schema_id.0 - ), - ))?; - - let issuer_did = identifier - .cred_def_id - .issuer_did() - .ok_or(IndyError::from_msg( - IndyErrorKind::InvalidState, - format!( - "Invalid Credential Definition ID `{}`: wrong number of parts", - identifier.cred_def_id.0 - ), - ))?; - - Ok(Filter { - schema_id: identifier.schema_id.0.to_string(), - schema_name, - schema_issuer_did: schema_issuer_did.0, - schema_version, - cred_def_id: identifier.cred_def_id.0.to_string(), - issuer_did: issuer_did.0, - }) - } - - fn _process_operator( - attr: &str, - restriction_op: &Query, - filter: &Filter, - revealed_value: Option<&str>, - ) -> IndyResult<()> { - let mut attr_value_map = HashMap::new(); - attr_value_map.insert(attr.to_string(), revealed_value); - VerifierService::_do_process_operator(&attr_value_map, restriction_op, filter) - } - - fn _do_process_operator( - attr_value_map: &HashMap>, - restriction_op: &Query, - filter: &Filter, - ) -> IndyResult<()> { - match restriction_op { - Query::Eq(ref tag_name, ref tag_value) => { - VerifierService::_process_filter(attr_value_map, &tag_name, &tag_value, filter) - .map_err(|err| { - err.extend(format!( - "$eq operator validation failed for tag: \"{}\", value: \"{}\"", - tag_name, tag_value - )) - }) - } - Query::Neq(ref tag_name, ref tag_value) => { - if VerifierService::_process_filter(attr_value_map, &tag_name, &tag_value, filter) - .is_err() - { - Ok(()) - } else { - Err(IndyError::from_msg( - IndyErrorKind::ProofRejected, - format!( - "$neq operator validation failed for tag: \"{}\", value: \"{}\". \ - Condition was passed.", - tag_name, tag_value - ), - )) - } - } - Query::In(ref tag_name, ref tag_values) => { - let res = tag_values.iter().any(|val| { - VerifierService::_process_filter(attr_value_map, &tag_name, &val, filter) - .is_ok() - }); - if res { - Ok(()) - } else { - Err(IndyError::from_msg( - IndyErrorKind::ProofRejected, - format!( - "$in operator validation failed for tag: \"{}\", values \"{:?}\".", - tag_name, tag_values - ), - )) - } - } - Query::And(ref operators) => operators - .iter() - .map(|op| VerifierService::_do_process_operator(attr_value_map, op, filter)) - .collect::>>() - .map(|_| ()) - .map_err(|err| err.extend("$and operator validation failed.")), - Query::Or(ref operators) => { - let res = operators.iter().any(|op| { - VerifierService::_do_process_operator(attr_value_map, op, filter).is_ok() - }); - if res { - Ok(()) - } else { - Err(IndyError::from_msg( - IndyErrorKind::ProofRejected, - "$or operator validation failed. All conditions were failed.", - )) - } - } - Query::Not(ref operator) => { - if VerifierService::_do_process_operator(attr_value_map, &*operator, filter) - .is_err() - { - Ok(()) - } else { - Err(IndyError::from_msg( - IndyErrorKind::ProofRejected, - "$not operator validation failed. All conditions were passed.", - )) - } - } - _ => Err(IndyError::from_msg( - IndyErrorKind::ProofRejected, - "unsupported operator", - )), - } - } - - fn _process_filter( - attr_value_map: &HashMap>, - tag: &str, - tag_value: &str, - filter: &Filter, - ) -> IndyResult<()> { - trace!( - "_process_filter: attr_value_map: {:?}, tag: {}, tag_value: {}, filter: {:?}", - attr_value_map, - tag, - tag_value, - filter - ); - match tag { - tag_ @ "schema_id" => { - VerifierService::_precess_filed(tag_, &filter.schema_id, tag_value) - } - tag_ @ "schema_issuer_did" => { - VerifierService::_precess_filed(tag_, &filter.schema_issuer_did, tag_value) - } - tag_ @ "schema_name" => { - VerifierService::_precess_filed(tag_, &filter.schema_name, tag_value) - } - tag_ @ "schema_version" => { - VerifierService::_precess_filed(tag_, &filter.schema_version, tag_value) - } - tag_ @ "cred_def_id" => { - VerifierService::_precess_filed(tag_, &filter.cred_def_id, tag_value) - } - tag_ @ "issuer_did" => { - VerifierService::_precess_filed(tag_, &filter.issuer_did, tag_value) - } - x if VerifierService::_is_attr_with_revealed_value(x, attr_value_map) => { - // attr::::value -> check revealed value - VerifierService::_check_internal_tag_revealed_value(x, tag_value, attr_value_map) - } - x if VerifierService::_is_attr_marker_operator(x) => { - // attr::::marker -> ok - Ok(()) - } - _ => Err(err_msg( - IndyErrorKind::InvalidStructure, - "Unknown Filter Type", - )), - } - } - - fn _precess_filed(filed: &str, filter_value: &str, tag_value: &str) -> IndyResult<()> { - if filter_value == tag_value { - Ok(()) - } else { - Err(IndyError::from_msg( - IndyErrorKind::ProofRejected, - format!( - "\"{}\" values are different: expected: \"{}\", actual: \"{}\"", - filed, tag_value, filter_value - ), - )) - } - } - - pub(crate) fn attr_request_by_value(key: &str) -> Option<&str> { - VALUE_TAG_MATCHER - .captures(key) - .and_then(|caps| caps.get(1).map(|s| s.as_str())) - } - - pub(crate) fn attr_request_by_marker(key: &str) -> Option<&str> { - MARKER_TAG_MATCHER - .captures(key) - .and_then(|caps| caps.get(1).map(|s| s.as_str())) - } - - fn _is_attr_with_revealed_value( - key: &str, - attr_value_map: &HashMap>, - ) -> bool { - VALUE_TAG_MATCHER - .captures(key) - .map(|caps| { - caps.get(1) - .map(|s| { - attr_value_map.keys().any(|key| { - AnoncredsHelpers::attr_common_view(key) - == AnoncredsHelpers::attr_common_view(s.as_str()) - }) - }) - .unwrap_or(false) - }) - .unwrap_or(false) - } - - fn _check_internal_tag_revealed_value( - key: &str, - tag_value: &str, - attr_value_map: &HashMap>, - ) -> IndyResult<()> { - let captures = VALUE_TAG_MATCHER.captures(key).ok_or(IndyError::from_msg( - IndyErrorKind::InvalidState, - format!("Attribute name became unparseable"), - ))?; - - let attr_name = captures - .get(1) - .ok_or(IndyError::from_msg( - IndyErrorKind::InvalidState, - format!("No name has been parsed"), - ))? - .as_str(); - - let revealed_value = attr_value_map.iter().find(|(key, _)| { - AnoncredsHelpers::attr_common_view(key) == AnoncredsHelpers::attr_common_view(attr_name) - }); - - if let Some((_key, Some(revealed_value))) = revealed_value { - if *revealed_value != tag_value { - return Err(IndyError::from_msg( - IndyErrorKind::ProofRejected, - format!( - "\"{}\" values are different: expected: \"{}\", actual: \"{}\"", - key, tag_value, revealed_value - ), - )); - } - } else { - return Err(IndyError::from_msg( - IndyErrorKind::ProofRejected, - format!( - "Revealed value hasn't been find by key: expected key: \"{}\", \ - attr_value_map: \"{:?}\"", - key, attr_value_map - ), - )); - } - Ok(()) - } - - fn _is_attr_marker_operator(key: &str) -> bool { - MARKER_TAG_MATCHER.is_match(key) - } - - fn _is_attr_value_operator(key: &str) -> bool { - VALUE_TAG_MATCHER.is_match(key) - } -} - -#[cfg(test)] -mod tests { - use super::*; - - pub(crate) const SCHEMA_ID: &str = "123"; - pub(crate) const SCHEMA_NAME: &str = "Schema Name"; - pub(crate) const SCHEMA_ISSUER_DID: &str = "234"; - pub(crate) const SCHEMA_VERSION: &str = "1.2.3"; - pub(crate) const CRED_DEF_ID: &str = "345"; - pub(crate) const ISSUER_DID: &str = "456"; - - fn schema_id_tag() -> String { - "schema_id".to_string() - } - - fn schema_name_tag() -> String { - "schema_name".to_string() - } - - fn schema_issuer_did_tag() -> String { - "schema_issuer_did".to_string() - } - - fn schema_version_tag() -> String { - "schema_version".to_string() - } - - fn cred_def_id_tag() -> String { - "cred_def_id".to_string() - } - - fn issuer_did_tag() -> String { - "issuer_did".to_string() - } - - fn attr_tag() -> String { - "attr::zip::marker".to_string() - } - - fn attr_tag_value() -> String { - "attr::zip::value".to_string() - } - - fn bad_attr_tag() -> String { - "bad::zip::marker".to_string() - } - - fn filter() -> Filter { - Filter { - schema_id: SCHEMA_ID.to_string(), - schema_name: SCHEMA_NAME.to_string(), - schema_issuer_did: SCHEMA_ISSUER_DID.to_string(), - schema_version: SCHEMA_VERSION.to_string(), - cred_def_id: CRED_DEF_ID.to_string(), - issuer_did: ISSUER_DID.to_string(), - } - } - - #[test] - fn test_process_op_eq() { - let filter = filter(); - - let mut op = Query::Eq(schema_id_tag(), SCHEMA_ID.to_string()); - VerifierService::_process_operator("zip", &op, &filter, None).unwrap(); - - op = Query::And(vec![ - Query::Eq(attr_tag(), "1".to_string()), - Query::Eq(schema_id_tag(), SCHEMA_ID.to_string()), - ]); - VerifierService::_process_operator("zip", &op, &filter, None).unwrap(); - - op = Query::And(vec![ - Query::Eq(bad_attr_tag(), "1".to_string()), - Query::Eq(schema_id_tag(), SCHEMA_ID.to_string()), - ]); - - assert!(VerifierService::_process_operator("zip", &op, &filter, None).is_err()); - - op = Query::Eq(schema_id_tag(), "NOT HERE".to_string()); - - assert!(VerifierService::_process_operator("zip", &op, &filter, None).is_err()); - } - - #[test] - fn test_process_op_ne() { - let filter = filter(); - let mut op = Query::Neq(schema_id_tag(), SCHEMA_ID.to_string()); - assert!(VerifierService::_process_operator("zip", &op, &filter, None).is_err()); - - op = Query::Neq(schema_id_tag(), "NOT HERE".to_string()); - VerifierService::_process_operator("zip", &op, &filter, None).unwrap() - } - - #[test] - fn test_process_op_in() { - let filter = filter(); - let mut cred_def_ids = vec!["Not Here".to_string()]; - - let mut op = Query::In(cred_def_id_tag(), cred_def_ids.clone()); - assert!(VerifierService::_process_operator("zip", &op, &filter, None).is_err()); - - cred_def_ids.push(CRED_DEF_ID.to_string()); - op = Query::In(cred_def_id_tag(), cred_def_ids.clone()); - VerifierService::_process_operator("zip", &op, &filter, None).unwrap() - } - - #[test] - fn test_process_op_or() { - let filter = filter(); - let mut op = Query::Or(vec![ - Query::Eq(schema_id_tag(), "Not Here".to_string()), - Query::Eq(cred_def_id_tag(), "Not Here".to_string()), - ]); - assert!(VerifierService::_process_operator("zip", &op, &filter, None).is_err()); - - op = Query::Or(vec![ - Query::Eq(schema_id_tag(), SCHEMA_ID.to_string()), - Query::Eq(cred_def_id_tag(), "Not Here".to_string()), - ]); - VerifierService::_process_operator("zip", &op, &filter, None).unwrap() - } - - #[test] - fn test_process_op_and() { - let filter = filter(); - let mut op = Query::And(vec![ - Query::Eq(schema_id_tag(), "Not Here".to_string()), - Query::Eq(cred_def_id_tag(), "Not Here".to_string()), - ]); - assert!(VerifierService::_process_operator("zip", &op, &filter, None).is_err()); - - op = Query::And(vec![ - Query::Eq(schema_id_tag(), SCHEMA_ID.to_string()), - Query::Eq(cred_def_id_tag(), "Not Here".to_string()), - ]); - assert!(VerifierService::_process_operator("zip", &op, &filter, None).is_err()); - - op = Query::And(vec![ - Query::Eq(schema_id_tag(), SCHEMA_ID.to_string()), - Query::Eq(cred_def_id_tag(), CRED_DEF_ID.to_string()), - ]); - VerifierService::_process_operator("zip", &op, &filter, None).unwrap() - } - - #[test] - fn test_process_op_not() { - let filter = filter(); - let mut op = Query::Not(Box::new(Query::And(vec![ - Query::Eq(schema_id_tag(), SCHEMA_ID.to_string()), - Query::Eq(cred_def_id_tag(), CRED_DEF_ID.to_string()), - ]))); - assert!(VerifierService::_process_operator("zip", &op, &filter, None).is_err()); - - op = Query::Not(Box::new(Query::And(vec![ - Query::Eq(schema_id_tag(), "Not Here".to_string()), - Query::Eq(cred_def_id_tag(), "Not Here".to_string()), - ]))); - VerifierService::_process_operator("zip", &op, &filter, None).unwrap() - } - - #[test] - fn test_proccess_op_or_with_nested_and() { - let filter = filter(); - let mut op = Query::Or(vec![ - Query::And(vec![ - Query::Eq(schema_id_tag(), "Not Here".to_string()), - Query::Eq(cred_def_id_tag(), "Not Here".to_string()), - ]), - Query::And(vec![ - Query::Eq(schema_issuer_did_tag(), "Not Here".to_string()), - Query::Eq(schema_name_tag(), "Not Here".to_string()), - ]), - Query::And(vec![ - Query::Eq(schema_name_tag(), "Not Here".to_string()), - Query::Eq(issuer_did_tag(), "Not Here".to_string()), - ]), - ]); - assert!(VerifierService::_process_operator("zip", &op, &filter, None).is_err()); - - op = Query::Or(vec![ - Query::And(vec![ - Query::Eq(schema_id_tag(), SCHEMA_ID.to_string()), - Query::Eq(cred_def_id_tag(), "Not Here".to_string()), - ]), - Query::And(vec![ - Query::Eq(schema_issuer_did_tag(), "Not Here".to_string()), - Query::Eq(schema_name_tag(), "Not Here".to_string()), - ]), - Query::And(vec![ - Query::Eq(schema_name_tag(), "Not Here".to_string()), - Query::Eq(issuer_did_tag(), "Not Here".to_string()), - ]), - ]); - assert!(VerifierService::_process_operator("zip", &op, &filter, None).is_err()); - - op = Query::Or(vec![ - Query::And(vec![ - Query::Eq(schema_id_tag(), SCHEMA_ID.to_string()), - Query::Eq(cred_def_id_tag(), CRED_DEF_ID.to_string()), - ]), - Query::And(vec![ - Query::Eq(schema_issuer_did_tag(), "Not Here".to_string()), - Query::Eq(schema_name_tag(), "Not Here".to_string()), - ]), - Query::And(vec![ - Query::Eq(schema_name_tag(), "Not Here".to_string()), - Query::Eq(issuer_did_tag(), "Not Here".to_string()), - ]), - ]); - VerifierService::_process_operator("zip", &op, &filter, None).unwrap() - } - - #[test] - fn test_verify_op_complex_nested() { - let filter = filter(); - let mut op = Query::And(vec![ - Query::And(vec![ - Query::Or(vec![ - Query::Eq(schema_name_tag(), "Not Here".to_string()), - Query::Eq(issuer_did_tag(), "Not Here".to_string()), - ]), - Query::Eq(schema_id_tag(), SCHEMA_ID.to_string()), - Query::Eq(cred_def_id_tag(), CRED_DEF_ID.to_string()), - ]), - Query::And(vec![ - Query::Eq(schema_issuer_did_tag(), SCHEMA_ISSUER_DID.to_string()), - Query::Eq(schema_name_tag(), SCHEMA_NAME.to_string()), - ]), - Query::And(vec![ - Query::Eq(schema_version_tag(), SCHEMA_VERSION.to_string()), - Query::Eq(issuer_did_tag(), ISSUER_DID.to_string()), - ]), - ]); - assert!(VerifierService::_process_operator("zip", &op, &filter, None).is_err()); - - op = Query::And(vec![ - Query::And(vec![ - Query::Or(vec![ - Query::Eq(schema_name_tag(), SCHEMA_NAME.to_string()), - Query::Eq(issuer_did_tag(), "Not Here".to_string()), - ]), - Query::Eq(schema_id_tag(), SCHEMA_ID.to_string()), - Query::Eq(cred_def_id_tag(), CRED_DEF_ID.to_string()), - ]), - Query::And(vec![ - Query::Eq(schema_issuer_did_tag(), SCHEMA_ISSUER_DID.to_string()), - Query::Eq(schema_name_tag(), SCHEMA_NAME.to_string()), - ]), - Query::And(vec![ - Query::Eq(schema_version_tag(), SCHEMA_VERSION.to_string()), - Query::Eq(issuer_did_tag(), ISSUER_DID.to_string()), - ]), - Query::Not(Box::new(Query::Eq( - schema_version_tag(), - "NOT HERE".to_string(), - ))), - ]); - VerifierService::_process_operator("zip", &op, &filter, None).unwrap(); - - op = Query::And(vec![ - Query::And(vec![ - Query::Or(vec![ - Query::Eq(schema_name_tag(), SCHEMA_NAME.to_string()), - Query::Eq(issuer_did_tag(), "Not Here".to_string()), - ]), - Query::Eq(schema_id_tag(), SCHEMA_ID.to_string()), - Query::Eq(cred_def_id_tag(), CRED_DEF_ID.to_string()), - ]), - Query::And(vec![ - Query::Eq(schema_issuer_did_tag(), SCHEMA_ISSUER_DID.to_string()), - Query::Eq(schema_name_tag(), SCHEMA_NAME.to_string()), - ]), - Query::And(vec![ - Query::Eq(schema_version_tag(), SCHEMA_VERSION.to_string()), - Query::Eq(issuer_did_tag(), ISSUER_DID.to_string()), - ]), - Query::Not(Box::new(Query::Eq( - schema_version_tag(), - SCHEMA_VERSION.to_string(), - ))), - ]); - assert!(VerifierService::_process_operator("zip", &op, &filter, None).is_err()); - } - - #[test] - fn test_process_op_eq_revealed_value() { - let filter = filter(); - let value = "value"; - - let mut op = Query::Eq(attr_tag_value(), value.to_string()); - VerifierService::_process_operator("zip", &op, &filter, Some(value)).unwrap(); - - op = Query::And(vec![ - Query::Eq(attr_tag_value(), value.to_string()), - Query::Eq(schema_issuer_did_tag(), SCHEMA_ISSUER_DID.to_string()), - ]); - VerifierService::_process_operator("zip", &op, &filter, Some(value)).unwrap(); - - op = Query::Eq(attr_tag_value(), value.to_string()); - assert!(VerifierService::_process_operator("zip", &op, &filter, Some("NOT HERE")).is_err()); - } - - #[test] - fn test_process_op_eq_revealed_value_case_insensitive() { - let filter = filter(); - let value = "Alice Clark"; - - let mut op = Query::Eq("attr::givenname::value".to_string(), value.to_string()); - VerifierService::_process_operator("Given Name", &op, &filter, Some(value)).unwrap(); - - op = Query::And(vec![ - Query::Eq("attr::givenname::value".to_string(), value.to_string()), - Query::Eq(schema_issuer_did_tag(), SCHEMA_ISSUER_DID.to_string()), - ]); - VerifierService::_process_operator("Given Name", &op, &filter, Some(value)).unwrap(); - } - - fn _received() -> HashMap { - let mut res: HashMap = HashMap::new(); - res.insert( - "referent_1".to_string(), - Identifier { - timestamp: Some(1234), - schema_id: SchemaId(String::new()), - cred_def_id: CredentialDefinitionId(String::new()), - rev_reg_id: Some(RevocationRegistryId(String::new())), - }, - ); - res.insert( - "referent_2".to_string(), - Identifier { - timestamp: None, - schema_id: SchemaId(String::new()), - cred_def_id: CredentialDefinitionId(String::new()), - rev_reg_id: Some(RevocationRegistryId(String::new())), - }, - ); - res - } - - fn _interval() -> NonRevocedInterval { - NonRevocedInterval { - from: None, - to: Some(1234), - } - } - - #[test] - fn validate_timestamp_works() { - VerifierService::_validate_timestamp(&_received(), "referent_1", &None, &None).unwrap(); - VerifierService::_validate_timestamp(&_received(), "referent_1", &Some(_interval()), &None) - .unwrap(); - VerifierService::_validate_timestamp(&_received(), "referent_1", &None, &Some(_interval())) - .unwrap(); - } - - #[test] - fn validate_timestamp_not_work() { - VerifierService::_validate_timestamp(&_received(), "referent_2", &Some(_interval()), &None) - .unwrap_err(); - VerifierService::_validate_timestamp(&_received(), "referent_2", &None, &Some(_interval())) - .unwrap_err(); - VerifierService::_validate_timestamp(&_received(), "referent_3", &None, &Some(_interval())) - .unwrap_err(); - } -} diff --git a/libvdrtools/src/services/blob_storage/default_reader.rs b/libvdrtools/src/services/blob_storage/default_reader.rs deleted file mode 100644 index 901820246a..0000000000 --- a/libvdrtools/src/services/blob_storage/default_reader.rs +++ /dev/null @@ -1,93 +0,0 @@ -use std::{ - fs::File as SyncFile, - io::{Read, Seek, SeekFrom}, - path::PathBuf, -}; - -use async_trait::async_trait; -use indy_api_types::errors::prelude::*; -use indy_utils::crypto::hash::Hash; -use serde_json; - -use super::{ReadableBlob, Reader, ReaderType}; -use crate::utils::crypto::base58::ToBase58; - -pub(crate) struct DefaultReader { - file: SyncFile, - hash: Vec, -} - -#[derive(Serialize, Deserialize)] -struct DefaultReaderConfig { - base_dir: String, -} - -#[async_trait] -impl ReaderType for DefaultReaderType { - async fn open(&self, config: &str) -> IndyResult> { - let config: DefaultReaderConfig = serde_json::from_str(config).to_indy( - IndyErrorKind::InvalidStructure, - "Can't deserialize DefaultReaderConfig", - )?; - - Ok(Box::new(config)) - } -} - -#[async_trait] -impl Reader for DefaultReaderConfig { - async fn open(&self, hash: &[u8], _location: &str) -> IndyResult> { - let mut path = PathBuf::from(&self.base_dir); - path.push(hash.to_base58()); - - let file = SyncFile::open(path)?; - - Ok(Box::new(DefaultReader { - file, - hash: hash.to_owned(), - })) - } -} - -#[async_trait] -impl ReadableBlob for DefaultReader { - async fn verify(&mut self) -> IndyResult { - self.file.seek(SeekFrom::Start(0))?; - let mut hasher = Hash::new_context()?; - let mut buf = [0u8; 1024]; - - loop { - let sz = self.file.read(&mut buf)?; - - if sz == 0 { - return Ok(hasher.finish()?.to_vec().eq(&self.hash)); - } - - hasher.update(&buf[0..sz])?; - } - } - - fn close(&self) -> IndyResult<()> { - /* nothing to do */ - Ok(()) - } - - fn read(&mut self, size: usize, offset: usize) -> IndyResult> { - let mut buf = vec![0u8; size]; - - self.file.seek(SeekFrom::Start(offset as u64))?; - let act_size = self.file.read(buf.as_mut_slice())?; - - buf.truncate(act_size); - - Ok(buf) - } -} - -pub(crate) struct DefaultReaderType {} - -impl DefaultReaderType { - pub(crate) fn new() -> Self { - DefaultReaderType {} - } -} diff --git a/libvdrtools/src/services/blob_storage/default_writer.rs b/libvdrtools/src/services/blob_storage/default_writer.rs deleted file mode 100644 index acc2b79596..0000000000 --- a/libvdrtools/src/services/blob_storage/default_writer.rs +++ /dev/null @@ -1,112 +0,0 @@ -use std::path::PathBuf; - -use async_std::{fs, fs::File, prelude::*}; -use async_trait::async_trait; -use indy_api_types::errors::prelude::*; -use serde_json; - -use super::{WritableBlob, Writer, WriterType}; -use crate::utils::{crypto::base58::ToBase58, environment}; - -#[allow(dead_code)] -pub(crate) struct DefaultWriter { - base_dir: PathBuf, - uri_pattern: String, - file: File, - id: i32, -} - -#[derive(Serialize, Deserialize)] -struct DefaultWriterConfig { - base_dir: String, - uri_pattern: String, -} - -#[async_trait] -impl WriterType for DefaultWriterType { - async fn open(&self, config: &str) -> IndyResult> { - let config: DefaultWriterConfig = serde_json::from_str(config).to_indy( - IndyErrorKind::InvalidStructure, - "Can't deserialize DefaultWriterConfig", - )?; - - Ok(Box::new(config)) - } -} - -#[async_trait] -impl Writer for DefaultWriterConfig { - async fn create(&self, id: i32) -> IndyResult> { - let path = PathBuf::from(&self.base_dir); - - fs::DirBuilder::new() - .recursive(true) - .create(tmp_storage_file(id).parent().unwrap()) - .await?; - - let file = File::create(tmp_storage_file(id)) - .await - .map_err(map_err_trace!())?; - - Ok(Box::new(DefaultWriter { - base_dir: path, - uri_pattern: self.uri_pattern.clone(), - file, - id, - })) - } -} - -#[async_trait] -impl WritableBlob for DefaultWriter { - async fn append(&mut self, bytes: &[u8]) -> IndyResult { - trace!("append >>>"); - - self.file.write_all(bytes).await.map_err(map_err_trace!())?; - - let res = bytes.len(); - trace!("append <<< {}", res); - Ok(res) - } - - async fn finalize(&mut self, hash: &[u8]) -> IndyResult { - trace!("finalize >>>"); - - self.file.flush().await.map_err(map_err_trace!())?; - self.file.sync_all().await.map_err(map_err_trace!())?; - - let mut path = self.base_dir.clone(); - path.push(hash.to_base58()); - - fs::DirBuilder::new() - .recursive(true) - .create(path.parent().unwrap()) - .await - .map_err(map_err_trace!(format!("path: {:?}", path)))?; - - fs::copy(&tmp_storage_file(self.id), &path) - .await - .map_err(map_err_trace!())?; //FIXME - - fs::remove_file(&tmp_storage_file(self.id)) - .await - .map_err(map_err_trace!())?; - - let res = path.to_str().unwrap().to_owned(); - - trace!("finalize <<< {}", res); - Ok(res) - } -} - -fn tmp_storage_file(id: i32) -> PathBuf { - environment::tmp_file_path(&format!("def_storage_tmp_{}", id)) -} - -pub(crate) struct DefaultWriterType {} - -impl DefaultWriterType { - pub fn new() -> Self { - DefaultWriterType {} - } -} diff --git a/libvdrtools/src/services/blob_storage/mod.rs b/libvdrtools/src/services/blob_storage/mod.rs deleted file mode 100644 index b8cfe315a7..0000000000 --- a/libvdrtools/src/services/blob_storage/mod.rs +++ /dev/null @@ -1,271 +0,0 @@ -mod default_reader; -mod default_writer; - -use std::{collections::HashMap, sync::Mutex as SyncMutex}; - -use async_trait::async_trait; -use futures::lock::Mutex; -use indy_api_types::errors::prelude::*; -use indy_utils::sequence; -use sha2::{ - digest::{FixedOutput, Update}, - Sha256, -}; - -#[async_trait] -trait WriterType: Send + Sync { - async fn open(&self, config: &str) -> IndyResult>; -} - -#[async_trait] -trait Writer: Send + Sync { - async fn create(&self, id: i32) -> IndyResult>; -} - -#[async_trait] -trait WritableBlob: Send + Sync { - async fn append(&mut self, bytes: &[u8]) -> IndyResult; - async fn finalize(&mut self, hash: &[u8]) -> IndyResult; -} - -#[async_trait] -trait ReaderType: Send + Sync { - async fn open(&self, config: &str) -> IndyResult>; -} - -#[async_trait] -trait Reader: Send + Sync { - async fn open(&self, hash: &[u8], location: &str) -> IndyResult>; -} - -#[async_trait] -trait ReadableBlob: Send + Sync { - fn read(&mut self, size: usize, offset: usize) -> IndyResult>; - async fn verify(&mut self) -> IndyResult; - fn close(&self) -> IndyResult<()>; -} - -pub struct BlobStorageService { - writer_types: Mutex>>, - writer_configs: Mutex>>, - writer_blobs: Mutex, Sha256)>>, - - reader_types: Mutex>>, - reader_configs: Mutex>>, - reader_blobs: SyncMutex>>, -} - -impl BlobStorageService { - pub(crate) fn new() -> BlobStorageService { - let mut writer_types: HashMap> = HashMap::new(); - writer_types.insert( - "default".to_owned(), - Box::new(default_writer::DefaultWriterType::new()), - ); - - let mut reader_types: HashMap> = HashMap::new(); - reader_types.insert( - "default".to_owned(), - Box::new(default_reader::DefaultReaderType::new()), - ); - - BlobStorageService { - writer_types: Mutex::new(writer_types), - writer_configs: Mutex::new(HashMap::new()), - writer_blobs: Mutex::new(HashMap::new()), - - reader_types: Mutex::new(reader_types), - reader_configs: Mutex::new(HashMap::new()), - reader_blobs: SyncMutex::new(HashMap::new()), - } - } -} - -/* Writer */ -impl BlobStorageService { - pub(crate) async fn open_writer(&self, type_: &str, config: &str) -> IndyResult { - let writer_config = self - .writer_types - .lock() - .await - .get(type_) - .ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidStructure, - "Unknown BlobStorage Writer type", - ) - })? - .open(config) - .await?; - - let config_handle = sequence::get_next_id(); - - self.writer_configs - .lock() - .await - .insert(config_handle, writer_config); - - Ok(config_handle) - } - - pub(crate) async fn create_blob(&self, config_handle: i32) -> IndyResult { - let blob_handle = sequence::get_next_id(); - - let writer = self - .writer_configs - .lock() - .await - .get(&config_handle) - .ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidStructure, - "Invalid BlobStorage config handle", - ) - })? // FIXME: Review error kind - .create(blob_handle) - .await?; - - self.writer_blobs - .lock() - .await - .insert(blob_handle, (writer, Sha256::default())); - - Ok(blob_handle) - } - - pub(crate) async fn append(&self, handle: i32, bytes: &[u8]) -> IndyResult { - let mut writers = self.writer_blobs.lock().await; - - let &mut (ref mut writer, ref mut hasher) = writers.get_mut(&handle).ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidStructure, - "Invalid BlobStorage handle", - ) - })?; // FIXME: Review error kind - - hasher.update(bytes); - let res = writer.append(bytes).await?; - Ok(res) - } - - pub(crate) async fn finalize(&self, handle: i32) -> IndyResult<(String, Vec)> { - let mut writers = self.writer_blobs.lock().await; - - let (mut writer, hasher) = writers.remove(&handle).ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidStructure, - "Invalid BlobStorage handle", - ) - })?; // FIXME: Review error kind - - let hash = hasher.finalize_fixed().to_vec(); - - writer - .finalize(hash.as_slice()) - .await - .map(|location| (location, hash)) - } -} - -/* Reader */ -impl BlobStorageService { - pub(crate) async fn open_reader(&self, type_: &str, config: &str) -> IndyResult { - let reader_config = self - .reader_types - .lock() - .await - .get(type_) - .ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidStructure, - "Invalid BlobStorage Reader type", - ) - })? // FIXME: Review error kind - .open(config) - .await?; - - let config_handle = sequence::get_next_id(); - - self.reader_configs - .lock() - .await - .insert(config_handle, reader_config); - - Ok(config_handle) - } - - pub(crate) async fn open_blob( - &self, - config_handle: i32, - location: &str, - hash: &[u8], - ) -> IndyResult { - let reader = self - .reader_configs - .lock() - .await - .get(&config_handle) - .ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidStructure, - "Invalid BlobStorage config handle", - ) - })? // FIXME: Review error kind - .open(hash, location) - .await?; - - let reader_handle = sequence::get_next_id(); - self.reader_blobs - .lock() - .unwrap() - .insert(reader_handle, reader); - - Ok(reader_handle) - } - - pub(crate) fn read(&self, handle: i32, size: usize, offset: usize) -> IndyResult> { - self.reader_blobs - .lock() - .unwrap() - .get_mut(&handle) - .ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidStructure, - "Invalid BlobStorage handle", - ) - })? // FIXME: Review error kind - .read(size, offset) - } - - pub(crate) async fn _verify(&self, handle: i32) -> IndyResult { - let res = self - .reader_blobs - .lock() - .unwrap() - .get_mut(&handle) - .ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidStructure, - "Invalid BlobStorage handle", - ) - })? // FIXME: Review error kind - .verify() - .await?; - - Ok(res) - } - - pub(crate) fn close(&self, handle: i32) -> IndyResult<()> { - self.reader_blobs - .lock() - .unwrap() - .remove(&handle) - .ok_or_else(|| { - err_msg( - IndyErrorKind::InvalidStructure, - "Invalid BlobStorage handle", - ) - })? // FIXME: Review error kind - .close() - } -} diff --git a/libvdrtools/src/services/crypto/mod.rs b/libvdrtools/src/services/crypto/mod.rs index ea6ce01afe..af71363f61 100644 --- a/libvdrtools/src/services/crypto/mod.rs +++ b/libvdrtools/src/services/crypto/mod.rs @@ -17,7 +17,7 @@ use crate::{ key::{Key, KeyInfo}, }, utils::crypto::{ - base58::{FromBase58, ToBase58}, + base58::{DecodeBase58, ToBase58}, verkey_builder::{build_full_verkey, split_verkey, verkey_get_cryptoname}, }, }; @@ -96,8 +96,7 @@ impl CryptoService { let crypto_type_name = key_info .crypto_type - .as_ref() - .map(String::as_str) + .as_deref() .unwrap_or(DEFAULT_CRYPTO_TYPE); let crypto_types = self.crypto_types.read().await; @@ -131,8 +130,7 @@ impl CryptoService { let crypto_type_name = my_did_info .crypto_type - .as_ref() - .map(String::as_str) + .as_deref() .unwrap_or(DEFAULT_CRYPTO_TYPE); let crypto_types = self.crypto_types.read().await; @@ -188,11 +186,11 @@ impl CryptoService { trace!("create_their_did > their_did_info {:?}", their_did_info); // Check did is correct Base58 - let _ = self.validate_did(&their_did_info.did)?; + self.validate_did(&their_did_info.did)?; let verkey = build_full_verkey( &their_did_info.did.to_unqualified().0, - their_did_info.verkey.as_ref().map(String::as_str), + their_did_info.verkey.as_deref(), )?; self.validate_key(&verkey).await?; @@ -224,7 +222,7 @@ impl CryptoService { })?; let my_sk = ed25519_sign::SecretKey::from_slice( - &my_key.signkey.as_str().from_base58()?.as_slice(), + my_key.signkey.as_str().decode_base58()?.as_slice(), )?; let signature = crypto_type.sign(&my_sk, doc)?[..].to_vec(); @@ -261,8 +259,8 @@ impl CryptoService { ) })?; - let their_vk = ed25519_sign::PublicKey::from_slice(&their_vk.from_base58()?)?; - let signature = ed25519_sign::Signature::from_slice(&signature)?; + let their_vk = ed25519_sign::PublicKey::from_slice(&their_vk.decode_base58()?)?; + let signature = ed25519_sign::Signature::from_slice(signature)?; let valid = crypto_type.verify(&their_vk, msg, &signature)?; @@ -311,10 +309,11 @@ impl CryptoService { ) })?; - let my_sk = - ed25519_sign::SecretKey::from_slice(my_key.signkey.as_str().from_base58()?.as_slice())?; + let my_sk = ed25519_sign::SecretKey::from_slice( + my_key.signkey.as_str().decode_base58()?.as_slice(), + )?; - let their_vk = ed25519_sign::PublicKey::from_slice(their_vk.from_base58()?.as_slice())?; + let their_vk = ed25519_sign::PublicKey::from_slice(their_vk.decode_base58()?.as_slice())?; let nonce = crypto_type.gen_nonce(); let encrypted_doc = crypto_type.crypto_box(&my_sk, &their_vk, doc, &nonce)?; @@ -366,11 +365,12 @@ impl CryptoService { ) })?; - let my_sk = ed25519_sign::SecretKey::from_slice(&my_key.signkey.from_base58()?.as_slice())?; - let their_vk = ed25519_sign::PublicKey::from_slice(their_vk.from_base58()?.as_slice())?; - let nonce = ed25519_box::Nonce::from_slice(&nonce)?; + let my_sk = + ed25519_sign::SecretKey::from_slice(my_key.signkey.decode_base58()?.as_slice())?; + let their_vk = ed25519_sign::PublicKey::from_slice(their_vk.decode_base58()?.as_slice())?; + let nonce = ed25519_box::Nonce::from_slice(nonce)?; - let decrypted_doc = crypto_type.crypto_box_open(&my_sk, &their_vk, &doc, &nonce)?; + let decrypted_doc = crypto_type.crypto_box_open(&my_sk, &their_vk, doc, &nonce)?; let res = Ok(decrypted_doc); trace!("crypto_box_open < {:?}", res); @@ -393,7 +393,7 @@ impl CryptoService { ) })?; - let their_vk = ed25519_sign::PublicKey::from_slice(their_vk.from_base58()?.as_slice())?; + let their_vk = ed25519_sign::PublicKey::from_slice(their_vk.decode_base58()?.as_slice())?; let encrypted_doc = crypto_type.crypto_box_seal(&their_vk, doc)?; let res = Ok(encrypted_doc); @@ -422,10 +422,11 @@ impl CryptoService { ) })?; - let my_vk = ed25519_sign::PublicKey::from_slice(my_vk.from_base58()?.as_slice())?; + let my_vk = ed25519_sign::PublicKey::from_slice(my_vk.decode_base58()?.as_slice())?; - let my_sk = - ed25519_sign::SecretKey::from_slice(my_key.signkey.as_str().from_base58()?.as_slice())?; + let my_sk = ed25519_sign::SecretKey::from_slice( + my_key.signkey.as_str().decode_base58()?.as_slice(), + )?; let decrypted_doc = crypto_type.crypto_box_seal_open(&my_vk, &my_sk, doc)?; @@ -452,7 +453,7 @@ impl CryptoService { seed.as_bytes().to_vec() } else if seed.ends_with('=') { // is base64 string - let decoded = base64::decode(&seed).to_indy( + let decoded = base64::decode(seed).to_indy( IndyErrorKind::InvalidStructure, "Can't deserialize Seed from Base64 string", )?; @@ -507,10 +508,10 @@ impl CryptoService { ) })?; - if vk.starts_with('~') { - let _ = vk[1..].from_base58()?; // TODO: proper validate abbreviated verkey + if let Some(vk) = vk.strip_prefix('~') { + let _ = vk.decode_base58()?; // TODO: proper validate abbreviated verkey } else { - let vk = ed25519_sign::PublicKey::from_slice(vk.from_base58()?.as_slice())?; + let vk = ed25519_sign::PublicKey::from_slice(vk.decode_base58()?.as_slice())?; crypto_type.validate_key(&vk)?; }; @@ -537,7 +538,7 @@ impl CryptoService { ) -> (String, String, String) { //encrypt message with aad let (ciphertext, iv, tag) = - gen_nonce_and_encrypt_detached(plaintext.as_slice(), aad.as_bytes(), &cek); + gen_nonce_and_encrypt_detached(plaintext.as_slice(), aad.as_bytes(), cek); //base64 url encode data let iv_encoded = base64::encode_urlsafe(&iv[..]); @@ -876,7 +877,7 @@ mod tests { .await .unwrap(); - assert_eq!(false, valid); + assert!(!valid); } #[async_std::test] diff --git a/libvdrtools/src/services/mod.rs b/libvdrtools/src/services/mod.rs index 72c6529083..83962a3493 100644 --- a/libvdrtools/src/services/mod.rs +++ b/libvdrtools/src/services/mod.rs @@ -1,9 +1,5 @@ -mod anoncreds; -mod blob_storage; mod crypto; mod wallet; -pub use anoncreds::{AnoncredsHelpers, IssuerService, ProverService, VerifierService}; -pub use blob_storage::BlobStorageService; pub use crypto::CryptoService; pub(crate) use wallet::WalletService; diff --git a/libvdrtools/src/utils/ccallback.rs b/libvdrtools/src/utils/ccallback.rs deleted file mode 100644 index db4df06a72..0000000000 --- a/libvdrtools/src/utils/ccallback.rs +++ /dev/null @@ -1,8 +0,0 @@ -macro_rules! check_useful_c_callback { - ($x:ident, $e:expr) => { - let $x = match $x { - Some($x) => $x, - None => return $e, - }; - }; -} diff --git a/libvdrtools/src/utils/cheqd_crypto.rs b/libvdrtools/src/utils/cheqd_crypto.rs deleted file mode 100644 index c48335423f..0000000000 --- a/libvdrtools/src/utils/cheqd_crypto.rs +++ /dev/null @@ -1,122 +0,0 @@ -use indy_api_types::IndyError; -use indy_api_types::errors::{IndyErrorKind, IndyResult, IndyResultExt}; -use cosmrs::rpc; -use prost::Message; - -pub fn check_proofs( - result: &rpc::endpoint::abci_query::Response, -) -> IndyResult<()> { - // Decode state proofs - - // Decode proof for inner ival tree - let proof_op_0 = &result.response.proof.as_ref().ok_or( - IndyError::from_msg( - IndyErrorKind::InvalidStructure, - "The proof for inner ival tree is absent but should be placed" - ))?; - let proof_op_0 = &proof_op_0.ops[0].clone(); - let proof_0_data_decoded = - ics23::CommitmentProof::decode(proof_op_0.data.as_slice()).to_indy( - IndyErrorKind::InvalidStructure, - "The proof for inner ival tree cannot be decoded into ics23::CommitmentProof" - )?; - - // Decode proof for outer `ics23:simple` tendermint tree) - let proof_op_1 = result.response.proof.as_ref().ok_or( - IndyError::from_msg( - IndyErrorKind::InvalidStructure, - "The proof for outer ics23:simple is absent but should be placed" - ))?; - let proof_op_1 = &proof_op_1.ops[1].clone(); - let proof_1_data_decoded = - ics23::CommitmentProof::decode(proof_op_1.data.as_slice()).to_indy( - IndyErrorKind::InvalidStructure, - "The proof for outer ics23:simple cannot be decoded into ics23::CommitmentProof" - )?; - - // Get a root hash for the inner ival tree from the outer tree proof - let proof_1_existence = if let Some(ics23::commitment_proof::Proof::Exist(ex)) = - proof_1_data_decoded.proof.clone() - { - ex - } else { - let proof_op_1_str = serde_json::to_string(proof_op_1).to_indy( - IndyErrorKind::InvalidState, - "Cannot serialize object with proof for outer `ics23:simple` tendermint tree" - )?; - return Err(IndyError::from_msg( - IndyErrorKind::InvalidStructure, - format!( - "Commitment proof has an incorrect format {}", - proof_op_1_str - ), - )); - }; - let proof_0_root = proof_1_existence.clone().value; - - // Check state proofs 0 (inner iavl tree) - let is_proof_correct = match proof_0_data_decoded.proof { - Some(ics23::commitment_proof::Proof::Exist(_)) => { - ics23::verify_membership( - &proof_0_data_decoded, // proof for verification - &ics23::iavl_spec(), // tree specification - &proof_0_root, // value root hash in the inner ival tree (value for outer tree) - &proof_op_0.key, // key for the inner ival tree - &result.response.value, // received value - ) - } - Some(ics23::commitment_proof::Proof::Nonexist(_)) => { - ics23::verify_non_membership( - &proof_0_data_decoded, // proof for verification - &ics23::iavl_spec(), // tree specification - &proof_0_root, // value root hash in the inner ival tree - &proof_op_0.key // key for the inner ival tree - ) - } - _ => {false} - }; - - if !is_proof_correct { - let proof_op_0_str = serde_json::to_string(proof_op_0).to_indy( - IndyErrorKind::InvalidState, - "Cannot serialize object with proof for inner ival tree" - )?; - return Err(IndyError::from_msg( - IndyErrorKind::InvalidStructure, - format!( - "Commitment proof 0 is incorrect {}", - proof_op_0_str - ), - )); - } - - // Should be output from light client - // Calculate a root hash for the outer tree - let proof_1_root = ics23::calculate_existence_root(&proof_1_existence.clone()) - .map_err(|er | IndyError::from_msg( - IndyErrorKind::InvalidStructure, - format!("Commitment proof has an incorrect format {}", er)))?; - - // Check state proofs 1 (outer `ics23:simple` tendermint tree) - if !ics23::verify_membership( - &proof_1_data_decoded, // proof for verification - &ics23::tendermint_spec(), // tree specification - &proof_1_root, // root hash for the outer tree - &proof_op_1.key, // key for the outer tree - &proof_0_root, // inner tree root hash in the outer tree (should exist) - ) { - let proof_op_1_str = serde_json::to_string(proof_op_1).to_indy( - IndyErrorKind::InvalidState, - "Cannot serialize object with proof for outer `ics23:simple` tendermint tree" - )?; - return Err(IndyError::from_msg( - IndyErrorKind::InvalidStructure, - format!( - "Commitment proof 1 is incorrect {}", - proof_op_1_str - ), - )); - } - - Ok(()) -} diff --git a/libvdrtools/src/utils/cheqd_ledger.rs b/libvdrtools/src/utils/cheqd_ledger.rs deleted file mode 100644 index 95fc030a44..0000000000 --- a/libvdrtools/src/utils/cheqd_ledger.rs +++ /dev/null @@ -1,12 +0,0 @@ -pub const VERKEY_TYPE: &str = "Ed25519VerificationKey2020"; -const VERKEY_ALIAS: &str = "#verkey"; - -pub fn make_verification_id(did: &str) -> String { - let mut fully_v_id = did.to_string(); - fully_v_id.push_str(VERKEY_ALIAS); - fully_v_id -} - -pub fn make_base58_btc(verkey: &str) -> String { - format!("z{}",verkey.to_string()) -} diff --git a/libvdrtools/src/utils/crypto/base58.rs b/libvdrtools/src/utils/crypto/base58.rs index 257adac951..1f4948543a 100644 --- a/libvdrtools/src/utils/crypto/base58.rs +++ b/libvdrtools/src/utils/crypto/base58.rs @@ -3,8 +3,8 @@ use bs58::{decode, decode::Result, encode}; pub trait ToBase58 { fn to_base58(&self) -> String; } -pub trait FromBase58 { - fn from_base58(&self) -> Result>; +pub trait DecodeBase58 { + fn decode_base58(self) -> Result>; } impl ToBase58 for [u8] { @@ -13,14 +13,14 @@ impl ToBase58 for [u8] { } } -impl FromBase58 for [u8] { - fn from_base58(&self) -> Result> { +impl DecodeBase58 for &[u8] { + fn decode_base58(self) -> Result> { decode(self).into_vec() } } -impl FromBase58 for str { - fn from_base58(&self) -> Result> { +impl DecodeBase58 for &str { + fn decode_base58(self) -> Result> { decode(self.as_bytes()).into_vec() } } diff --git a/libvdrtools/src/utils/crypto/mod.rs b/libvdrtools/src/utils/crypto/mod.rs index 331746e09c..df7b29719e 100644 --- a/libvdrtools/src/utils/crypto/mod.rs +++ b/libvdrtools/src/utils/crypto/mod.rs @@ -1,3 +1,2 @@ pub mod base58; -pub mod signature_serializer; pub mod verkey_builder; diff --git a/libvdrtools/src/utils/crypto/proof_op.rs b/libvdrtools/src/utils/crypto/proof_op.rs deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/libvdrtools/src/utils/crypto/signature_serializer.rs b/libvdrtools/src/utils/crypto/signature_serializer.rs deleted file mode 100644 index 1360ab4ec9..0000000000 --- a/libvdrtools/src/utils/crypto/signature_serializer.rs +++ /dev/null @@ -1,191 +0,0 @@ -use indy_api_types::errors::prelude::*; -use indy_utils::crypto::hash::Hash; -use serde_json::Value; - -use crate::domain::ledger::constants::{ATTRIB, GET_ATTR}; - -fn _serialize_signature( - v: Value, - is_top_level: bool, - _type: Option<&str>, -) -> Result { - match v { - Value::Bool(value) => Ok(if value { - "True".to_string() - } else { - "False".to_string() - }), - Value::Number(value) => Ok(value.to_string()), - Value::String(value) => Ok(value), - Value::Array(array) => array - .into_iter() - .map(|element| _serialize_signature(element, false, _type)) - .collect::, IndyError>>() - .map(|res| res.join(",")), - Value::Object(map) => { - let mut result = "".to_string(); - let mut in_middle = false; - for key in map.keys() { - // Skip signature field at top level as in python code - if is_top_level && (key == "signature" || key == "fees" || key == "signatures") { - continue; - } - - if in_middle { - result += "|"; - } - - let mut value = map[key].clone(); - if (_type == Some(ATTRIB) || _type == Some(GET_ATTR)) - && (key == "raw" || key == "hash" || key == "enc") - { - // do it only for attribute related request - let mut ctx = Hash::new_context()?; - - ctx.update( - &value - .as_str() - .ok_or_else(|| { - IndyError::from_msg( - IndyErrorKind::InvalidState, - "Cannot update hash context", - ) - })? - .as_bytes(), - )?; - - value = Value::String(hex::encode(ctx.finish()?.as_ref())); - } - result = result + key + ":" + &_serialize_signature(value, false, _type)?; - in_middle = true; - } - Ok(result) - } - _ => Ok("".to_string()), - } -} - -#[cfg(test)] -mod tests { - use super::*; - - fn serialize_signature(v: Value) -> Result { - let _type = v["operation"]["type"].clone(); - _serialize_signature(v, true, _type.as_str()) - } - - #[test] - fn signature_serialize_works() { - let data = r#"{ - "name": "John Doe", - "age": 43, - "operation": { - "dest": 54 - }, - "phones": [ - "1234567", - "2345678", - {"rust": 5, "age": 1}, - 3 - ] - }"#; - let msg: Value = serde_json::from_str(data).unwrap(); - - let result = "age:43|name:John Doe|operation:dest:54|phones:1234567,2345678,age:1|rust:5,3"; - - assert_eq!(serialize_signature(msg).unwrap(), result) - } - - #[test] - fn signature_serialize_works_for_skipped_fields() { - let data = r#"{ - "name": "John Doe", - "age": 43, - "operation": { - "type": "100", - "hash": "cool hash", - "dest": 54 - }, - "fees": "fees1", - "signature": "sign1", - "signatures": "sign-m", - "phones": [ - "1234567", - "2345678", - {"rust": 5, "age": 1}, - 3 - ] - }"#; - let msg: Value = serde_json::from_str(data).unwrap(); - - let result = "age:43|name:John \ - Doe|operation:dest:54|hash:\ - 46aa0c92129b33ee72ee1478d2ae62fa6e756869dedc6c858af3214a6fcf1904|type:\ - 100|phones:1234567,2345678,age:1|rust:5,3"; - - assert_eq!(serialize_signature(msg).unwrap(), result) - } - - #[test] - fn signature_serialize_works_with_raw_hash_for_attrib_related_type() { - let data = r#"{ - "name": "John Doe", - "age": 43, - "operation": { - "type": "100", - "hash": "cool hash", - "dest": 54, - "raw": "string for hash" - }, - "phones": [ - "1234567", - "2345678", - {"rust": 5, "age": 1}, - 3 - ] - }"#; - let msg: Value = serde_json::from_str(data).unwrap(); - - let result = "age:43|name:John \ - Doe|operation:dest:54|hash:\ - 46aa0c92129b33ee72ee1478d2ae62fa6e756869dedc6c858af3214a6fcf1904|raw:\ - 1dcd0759ce38f57049344a6b3c5fc18144fca1724713090c2ceeffa788c02711|type:\ - 100|phones:1234567,2345678,age:1|rust:5,3"; - - assert_eq!(serialize_signature(msg).unwrap(), result) - } - - #[test] - fn signature_serialize_works_with_raw_hash_for_not_attrib_related_type() { - let data = r#"{ - "name": "John Doe", - "age": 43, - "operation": { - "type": "101", - "hash": "cool hash", - "dest": 54, - "raw": "string for hash" - }, - "phones": [ - "1234567", - "2345678", - {"rust": 5, "age": 1}, - 3 - ] - }"#; - let msg: Value = serde_json::from_str(data).unwrap(); - - let result = "age:43|name:John Doe|operation:dest:54|hash:cool hash|raw:string for \ - hash|type:101|phones:1234567,2345678,age:1|rust:5,3"; - - assert_eq!(serialize_signature(msg).unwrap(), result) - } - - #[test] - fn signature_serialize_works_with_null() { - let data = r#"{"signature": null}"#; - let v: serde_json::Value = serde_json::from_str(data).unwrap(); - let serialized = serialize_signature(v).unwrap(); - assert_eq!(serialized, ""); - } -} diff --git a/libvdrtools/src/utils/crypto/verkey_builder.rs b/libvdrtools/src/utils/crypto/verkey_builder.rs index 465228077e..b0b6fb2126 100644 --- a/libvdrtools/src/utils/crypto/verkey_builder.rs +++ b/libvdrtools/src/utils/crypto/verkey_builder.rs @@ -2,7 +2,7 @@ use indy_api_types::errors::prelude::*; use crate::{ services::CryptoService, - utils::crypto::base58::{FromBase58, ToBase58}, + utils::crypto::base58::{DecodeBase58, ToBase58}, }; pub fn build_full_verkey(dest: &str, verkey: Option<&str>) -> Result { @@ -14,9 +14,9 @@ pub fn build_full_verkey(dest: &str, verkey: Option<&str>) -> Result i32 { - let result = unsafe { OPENSSL_memcmp(a, b, len) }; - return result; -} - -#[cfg(target_os = "ios")] -extern "C" { - fn OPENSSL_memcmp(a: *const u8, b: *const u8, len: usize) -> i32; -} diff --git a/libvdrtools/src/utils/logger.rs b/libvdrtools/src/utils/logger.rs deleted file mode 100644 index e1fb77db9e..0000000000 --- a/libvdrtools/src/utils/logger.rs +++ /dev/null @@ -1,61 +0,0 @@ -#[macro_export] -macro_rules! try_log { - ($expr:expr) => { - match $expr { - Ok(val) => val, - Err(err) => { - error!("try_log! | {}", err); - return Err(From::from(err)); - } - } - }; -} - -macro_rules! _map_err { - ($lvl:expr, $expr:expr) => { - |err| { - log!($lvl, "{} - {}", $expr, err); - err - } - }; - ($lvl:expr) => { - |err| { - log!($lvl, "{}", err); - err - } - }; -} - -#[macro_export] -macro_rules! map_err_err { - () => ( _map_err!(::log::Level::Error) ); - ($($arg:tt)*) => ( _map_err!(::log::Level::Error, $($arg)*) ) -} - -#[macro_export] -macro_rules! map_err_trace { - () => ( _map_err!(::log::Level::Trace) ); - ($($arg:tt)*) => ( _map_err!(::log::Level::Trace, $($arg)*) ) -} - -#[macro_export] -macro_rules! map_err_info { - () => ( _map_err!(::log::Level::Info) ); - ($($arg:tt)*) => ( _map_err!(::log::Level::Info, $($arg)*) ) -} - -#[cfg(debug_assertions)] -#[macro_export] -macro_rules! secret { - ($val:expr) => {{ - $val - }}; -} - -#[cfg(not(debug_assertions))] -#[macro_export] -macro_rules! secret { - ($val:expr) => {{ - "_" - }}; -} diff --git a/libvdrtools/src/utils/mod.rs b/libvdrtools/src/utils/mod.rs index 330b6206ae..5acf386eae 100755 --- a/libvdrtools/src/utils/mod.rs +++ b/libvdrtools/src/utils/mod.rs @@ -1,24 +1,5 @@ pub use indy_utils::environment; - pub mod crypto; - -#[macro_use] -pub mod logger; - -#[allow(unused_macros)] -#[macro_use] -pub mod result; - -#[cfg(test)] -pub use indy_utils::test; - -#[macro_use] -pub mod try_utils; - -pub use indy_api_types::validation; pub use indy_utils::wql; - #[macro_use] pub mod qualifier; - -pub mod extensions; diff --git a/libvdrtools/src/utils/qualifier.rs b/libvdrtools/src/utils/qualifier.rs index 1720f78f82..6da00b58b8 100644 --- a/libvdrtools/src/utils/qualifier.rs +++ b/libvdrtools/src/utils/qualifier.rs @@ -49,7 +49,7 @@ pub fn method(entity: &str) -> Option { } pub fn is_fully_qualified(entity: &str) -> bool { - REGEX.is_match(&entity) + REGEX.is_match(entity) } macro_rules! qualifiable_type (($newtype:ident) => ( diff --git a/libvdrtools/src/utils/result.rs b/libvdrtools/src/utils/result.rs deleted file mode 100644 index a63c325f53..0000000000 --- a/libvdrtools/src/utils/result.rs +++ /dev/null @@ -1,44 +0,0 @@ -macro_rules! prepare_result { - ($result:ident) => {{ - trace!("prepare_result: >>> {:?}", $result); - match $result { - Ok(_) => ErrorCode::Success, - Err(err) => { - if err.kind() == indy_api_types::errors::IndyErrorKind::InvalidState { - error!("InvalidState: {}", err); - } - err.into() - } - } - }}; - ($result:ident, $($dflt_val:expr),*) => {{ - trace!("prepare_result: >>> {:?}", $result); - match $result { - Ok(res) => (ErrorCode::Success, res), - Err(err) => { - if err.kind() == indy_api_types::errors::IndyErrorKind::InvalidState { - error!("InvalidState: {}", err); - } - (err.into(), ($($dflt_val),*)) - } - } - }} -} - -macro_rules! unwrap_opt_or_return { - ($opt:expr, $err:expr) => { - match $opt { - Some(val) => val, - None => return $err, - } - }; -} - -macro_rules! unwrap_or_return { - ($result:expr, $err:expr) => { - match $result { - Ok(res) => res, - Err(_) => return $err, - } - }; -} diff --git a/libvdrtools/src/utils/try_utils.rs b/libvdrtools/src/utils/try_utils.rs deleted file mode 100644 index 456df3630d..0000000000 --- a/libvdrtools/src/utils/try_utils.rs +++ /dev/null @@ -1 +0,0 @@ -//FIXME [async] TODO remove file? diff --git a/uniffi_aries_vcx/core/Cargo.toml b/uniffi_aries_vcx/core/Cargo.toml index 4edd395d40..8610776bd1 100644 --- a/uniffi_aries_vcx/core/Cargo.toml +++ b/uniffi_aries_vcx/core/Cargo.toml @@ -16,7 +16,7 @@ path = "uniffi-bindgen.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -uniffi = "0.23.0" +uniffi = { version = "0.23.0", features = ["cli"] } aries-vcx = { path = "../../aries_vcx" } tokio = { version = "1.24.1" } once_cell = "1.17.0" diff --git a/uniffi_aries_vcx/core/src/core/profile.rs b/uniffi_aries_vcx/core/src/core/profile.rs index 24d877555c..7e0c995b1c 100644 --- a/uniffi_aries_vcx/core/src/core/profile.rs +++ b/uniffi_aries_vcx/core/src/core/profile.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use aries_vcx::{ aries_vcx_core::{ - anoncreds::indy_anoncreds::IndySdkAnonCreds, + anoncreds::credx_anoncreds::IndyCredxAnonCreds, ledger::base_ledger::TxnAuthrAgrmtOptions, wallet::indy::{wallet::create_and_open_wallet, IndySdkWallet, WalletConfig}, }, @@ -16,8 +16,8 @@ use crate::{errors::error::VcxUniFFIResult, runtime::block_on}; #[derive(Debug)] pub struct UniffiProfile { - wallet: IndySdkWallet, - anoncreds: IndySdkAnonCreds, + wallet: Arc, + anoncreds: IndyCredxAnonCreds, ledger_read: MockLedger, ledger_write: MockLedger, } @@ -26,7 +26,7 @@ pub struct UniffiProfile { impl Profile for UniffiProfile { type LedgerRead = MockLedger; type LedgerWrite = MockLedger; - type Anoncreds = IndySdkAnonCreds; + type Anoncreds = IndyCredxAnonCreds; type Wallet = IndySdkWallet; fn ledger_read(&self) -> &Self::LedgerRead { @@ -61,10 +61,10 @@ pub fn new_indy_profile(wallet_config: WalletConfig) -> VcxUniFFIResult