diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1bf48db..5a8126b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,132 +1,230 @@ -name: "Build Packages" +name: "Indy-Credx" -"on": +env: + RUST_VERSION: "1.60.0" + CROSS_VERSION: "0.2.4" + OPENSSL_STATIC: 1 + +on: + push: + branches: [main] + pull_request: + branches: [main] release: types: [created] workflow_dispatch: inputs: - publish: - description: "Publish packages" + publish-binaries: + description: "Publish Binaries to Release (will create a release if no release exists for branch or tag)" + required: true + default: false + type: boolean + publish-wrappers: + description: "Publish Wrappers to Registries" required: true - default: "false" + default: false + type: boolean jobs: - build-manylinux: - name: Build Library (Manylinux) - + checks: + name: Run checks strategy: + fail-fast: false matrix: - include: - - os: ubuntu-latest - lib: libindy_credx.so - container: andrewwhitehead/manylinux2014-base - - container: ${{ matrix.container }} + os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@master with: - profile: minimal - toolchain: stable + toolchain: ${{ env.RUST_VERSION }} + components: clippy, rustfmt - name: Cache cargo resources - uses: Swatinem/rust-cache@v1 + uses: Swatinem/rust-cache@v2 + with: + shared-key: deps + cache-on-failure: true - - name: Build library - env: - BUILD_FEATURES: vendored - BUILD_TARGET: ${{ matrix.target }} - run: sh ./build.sh + - name: Cargo fmt + run: cargo fmt --all -- --check + + - name: Cargo check + run: cargo check --workspace --features vendored + + - if: "runner.os == 'Linux'" + name: Pre-install cross + run: | + cargo install --bins --git https://github.com/rust-embedded/cross --tag v${{ env.CROSS_VERSION }} cross + + tests: + name: Run tests + needs: [checks] + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.RUST_VERSION }} - - name: Upload library artifacts - uses: actions/upload-artifact@v2 + - name: Cache cargo resources + uses: Swatinem/rust-cache@v2 with: - name: library-${{ runner.os }} - path: target/release/${{ matrix.lib }} + shared-key: deps + save-if: false + + - name: Debug build + run: cargo build --all-targets --features vendored + + - name: Test indy-utils + run: cargo test --manifest-path indy-utils/Cargo.toml + + # - name: Test indy-data-types (CL) + # run: cargo test --manifest-path indy-data-types/Cargo.toml --features cl + + - name: Test indy-data-types (CL-native) + run: cargo test --manifest-path indy-data-types/Cargo.toml --features cl_native,vendored - build-other: - name: Build Library (MacOS/Win) + - name: Test indy-credx (vendored) + run: cargo test --manifest-path indy-credx/Cargo.toml --features vendored + + build-release: + name: Build library + needs: [checks] strategy: matrix: include: - - os: macos-11 + - architecture: linux-aarch64 + os: ubuntu-latest + lib: libindy_credx.so + target: aarch64-unknown-linux-gnu + use_cross: true + - architecture: linux-x86_64 + os: ubuntu-latest + lib: libindy_credx.so + target: x86_64-unknown-linux-gnu + use_cross: true + - architecture: darwin-universal + os: macos-latest lib: libindy_credx.dylib - target: apple-darwin - toolchain: beta # beta required for Darwin build - - os: windows-latest + target: darwin-universal + # beta or nightly required for aarch64-apple-darwin target + toolchain: beta + - architecture: windows-x86_64 + os: windows-latest lib: indy_credx.dll - toolchain: stable + target: x86_64-pc-windows-msvc runs-on: ${{ matrix.os }} - steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@master with: - profile: minimal - toolchain: ${{ matrix.toolchain }} + toolchain: ${{ matrix.toolchain || env.RUST_VERSION }} - name: Cache cargo resources - uses: Swatinem/rust-cache@v1 + uses: Swatinem/rust-cache@v2 + with: + shared-key: deps + save-if: false + + - if: ${{ matrix.use_cross }} + name: Build (cross) + run: | + cargo install --bins --git https://github.com/rust-embedded/cross --tag v${{ env.CROSS_VERSION }} cross + cross build --lib --release --package indy-credx --target ${{ matrix.target }} --features vendored + + - if: ${{ !matrix.use_cross && matrix.architecture == 'darwin-universal' }} + name: Build (mac) + run: BUILD_FEATURES=vendored ./build-universal.sh - # pre-build so that openssl dependency is cached, otherwise it will complain: + # Requires using the default shell on Windows, otherwise it will complain: # "This perl implementation doesn't produce Windows like paths" - - if: "runner.os == 'Windows'" - name: Pre-build (Windows) - uses: actions-rs/cargo@v1 - env: - OPENSSL_STATIC: 1 + - if: ${{ !matrix.use_cross && matrix.architecture != 'darwin-universal' }} + name: Build (standard) + run: | + cargo build --lib --release --package indy-credx --target ${{ matrix.target }} --features vendored + + - name: Upload artifacts + uses: actions/upload-artifact@v3 with: - command: build - args: --release --manifest-path indy-credx/Cargo.toml --features vendored + name: library-${{ matrix.architecture }} + path: target/${{ matrix.target }}/release/${{ matrix.lib }} - - name: Build library - env: - BUILD_FEATURES: vendored - BUILD_TARGET: ${{ matrix.target }} - BUILD_TOOLCHAIN: ${{ matrix.toolchain }} - OPENSSL_STATIC: 1 - run: sh ./build.sh - - - name: Upload library artifacts - uses: actions/upload-artifact@v2 + - name: Create artifacts directory + if: | + github.event_name == 'release' || + (github.event_name == 'workflow_dispatch' && github.event.inputs.publish-binaries == 'true') + run: | + mkdir release-artifacts + cp target/${{ matrix.target }}/release/${{ matrix.lib }} release-artifacts/ + + - uses: a7ul/tar-action@v1.1.2 + if: | + github.event_name == 'release' || + (github.event_name == 'workflow_dispatch' && github.event.inputs.publish-binaries == 'true') + with: + command: c + cwd: release-artifacts + files: . + outPath: "library-${{ matrix.architecture }}.tar.gz" + + - name: Add artifacts to release + if: | + github.event_name == 'release' || + (github.event_name == 'workflow_dispatch' && github.event.inputs.publish-binaries == 'true') + uses: svenstaro/upload-release-action@v2 with: - name: library-${{ runner.os }} - path: target/release/${{ matrix.lib }} + file: library-${{ matrix.architecture }}.tar.gz + asset_name: "library-${{ matrix.architecture }}.tar.gz" build-py: - name: Build Python - needs: [build-manylinux, build-other] + name: Build and test Python wrapper + needs: [build-release] strategy: matrix: - os: [ubuntu-latest, macos-11, windows-latest] - python-version: [3.6] + architecture: + [linux-aarch64, linux-x86_64, darwin-universal, windows-x86_64] + python-version: ["3.8"] include: - os: ubuntu-latest + architecture: linux-aarch64 + plat-name: manylinux2014_aarch64 + - os: ubuntu-latest + architecture: linux-x86_64 plat-name: manylinux2014_x86_64 - - os: macos-11 + - os: macos-latest + architecture: darwin-universal plat-name: macosx_10_9_universal2 # macosx_10_9_x86_64 - os: windows-latest + architecture: windows-x86_64 plat-name: win_amd64 runs-on: ${{ matrix.os }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} @@ -136,41 +234,41 @@ jobs: pip install setuptools wheel twine auditwheel - name: Fetch library artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: - name: library-${{ runner.os }} + name: library-${{ matrix.architecture }} path: wrappers/python/indy_credx/ - - name: Build python package + - name: Build wheel package + shell: sh run: | python setup.py bdist_wheel --python-tag=py3 --plat-name=${{ matrix.plat-name }} working-directory: wrappers/python - - name: Test python package - shell: sh - run: | - cd wrappers/python - pip install --upgrade pip - pip install dist/* - python -m demo.test + - name: Run tests + # FIXME cross platform test the python package + # maybe use the cross docker image? + if: "matrix.architecture != 'linux-aarch64'" + run: python -m demo.test + working-directory: wrappers/python + env: + no_proxy: "*" # python issue 30385 + RUST_BACKTRACE: full + # RUST_LOG: debug - if: "runner.os == 'Linux'" - name: Auditwheel - run: auditwheel show wrappers/python/dist/* - - - name: Upload python package - uses: actions/upload-artifact@v2 - with: - name: python-${{ runner.os }} - path: wrappers/python/dist/* + name: Audit wheel + run: | + auditwheel show wrappers/python/dist/* | tee auditwheel.log + grep -q manylinux_2_17_ auditwheel.log - if: | - (github.event_name == 'release' || - (github.event_name == 'workflow_dispatch' && - github.event.inputs.publish == 'true')) - name: Publish python package + github.event_name == 'release' || + (github.event_name == 'workflow_dispatch' && github.event.inputs.publish-wrappers == 'true') + name: Publish env: TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | - twine upload --skip-existing wrappers/python/dist/* + twine upload --skip-existing dist/* + working-directory: wrappers/python diff --git a/.github/workflows/rusttest.yml b/.github/workflows/rusttest.yml deleted file mode 100644 index dd2b7f4..0000000 --- a/.github/workflows/rusttest.yml +++ /dev/null @@ -1,90 +0,0 @@ -name: "Run Tests" - -on: - push: - branches: [main] - pull_request: - branches: [main] - -jobs: - lints: - name: Lints - - runs-on: ubuntu-latest - - steps: - - name: Checkout sources - uses: actions/checkout@v2 - - - name: Install stable toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - - - name: Cache cargo resources - uses: Swatinem/rust-cache@v1 - - - name: Cargo check - uses: actions-rs/cargo@v1 - with: - command: check - - - name: Cargo fmt - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check - - test: - name: Test Suite - needs: [lints] - - strategy: - matrix: - os: [macos-latest, windows-latest, ubuntu-latest] - - runs-on: ${{ matrix.os }} - - steps: - - name: Checkout sources - uses: actions/checkout@v2 - - - name: Install stable toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - - - name: Cache cargo resources - uses: Swatinem/rust-cache@v1 - - - name: Debug build - uses: actions-rs/cargo@v1 - with: - command: build - args: --manifest-path indy-credx/Cargo.toml --features vendored - - - name: Test indy-utils - uses: actions-rs/cargo@v1 - with: - command: test - args: --manifest-path indy-utils/Cargo.toml - - - name: Test indy-data-types (CL) - uses: actions-rs/cargo@v1 - with: - command: test - args: --manifest-path indy-data-types/Cargo.toml --features cl - - - name: Test indy-data-types (CL-native) - uses: actions-rs/cargo@v1 - with: - command: test - args: --manifest-path indy-data-types/Cargo.toml --features cl_native,vendored - - - name: Test indy-credx (vendored) - uses: actions-rs/cargo@v1 - with: - command: test - args: --manifest-path indy-credx/Cargo.toml --features vendored diff --git a/Cargo.toml b/Cargo.toml index f5d1ec7..89e9422 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,10 +4,10 @@ members = [ "indy-credx", "indy-data-types", "indy-test-utils", - "indy-utils", - "indy-wql" + "indy-utils" ] [profile.release] +panic = "abort" lto = true codegen-units = 1 diff --git a/Cross.toml b/Cross.toml new file mode 100644 index 0000000..0d7223a --- /dev/null +++ b/Cross.toml @@ -0,0 +1,17 @@ +[target.aarch64-unknown-linux-gnu] +image = "ghcr.io/rust-cross/manylinux2014-cross:aarch64" + +[target.x86_64-unknown-linux-gnu] +image = "ghcr.io/rust-cross/manylinux2014-cross:x86_64" + +[target.x86_64-linux-android] +image = "ghcr.io/cross-rs/x86_64-linux-android:main" + +[target.i686-linux-android] +image = "ghcr.io/cross-rs/i686-linux-android:main" + +[target.aarch64-linux-android] +image = "ghcr.io/cross-rs/aarch64-linux-android:main" + +[target.armv7-linux-androideabi] +image = "ghcr.io/cross-rs/armv7-linux-androideabi:main" diff --git a/build-universal.sh b/build-universal.sh new file mode 100755 index 0000000..645fef8 --- /dev/null +++ b/build-universal.sh @@ -0,0 +1,61 @@ +#!/bin/sh + +# NOTE: +# MacOS universal build currently requires MacOS 11 (Big Sur) for the appropriate SDK, +# and `sudo xcode-select --install` must be run to install the command line utilities. +# Rust's `beta` channel must be installed because aarch64 is still a tier-2 target: +# `rustup toolchain install beta`. + +RUSTUP=${RUSTUP:-`command -v rustup`} +PROJECT=indy-credx +LIB_NAME=indy_credx +FEATURES="${BUILD_FEATURES:-default}" + +if [ ! -x "$RUSTUP" ]; then + echo "rustup command not found: it can be obtained from https://rustup.rs/" + exit 1 +fi + +TOOLCHAIN=`$RUSTUP default` +TARGET_DIR="${TARGET_DIR-./target/darwin-universal}" + +if [ -z "$BUILD_TOOLCHAIN" ]; then + BUILD_TOOLCHAIN=${TOOLCHAIN%%-*} + if [ -z "$BUILD_TOOLCHAIN" ]; then + echo "Error: Could not determine default Rust toolchain" + exit 1 + fi +fi + +MACOS_UNIVERSAL_TARGETS="aarch64-apple-darwin x86_64-apple-darwin" + +# Fail on any execution errors +set -e + +INSTALLED_TARGETS=`$RUSTUP +$BUILD_TOOLCHAIN target list --installed` +# Install target(s) as needed +echo "Checking install targets for MacOS universal build .." +for target in $MACOS_UNIVERSAL_TARGETS; do + if ! `echo "$INSTALLED_TARGETS" | grep -q $target`; then + $RUSTUP +$BUILD_TOOLCHAIN target add $target + fi +done + +MAJOR_VER=`sw_vers | grep ProductVersion | cut -f 2 | cut -f 1 -d .` +if [ "$MAJOR_VER" -lt 11 ]; then + echo "MacOS universal build requires OS 11 (Big Sur) or newer" + TARGET= +fi + +# Build both targets and combine them into a universal library with `lipo` +TARGET_LIBS= +for target in $MACOS_UNIVERSAL_TARGETS; do + echo "Building $PROJECT for toolchain '$BUILD_TOOLCHAIN', target '$target'.." + $RUSTUP run $BUILD_TOOLCHAIN cargo build --lib --features $FEATURES --release --target $target + TARGET_LIBS="./target/$target/release/lib${LIB_NAME}.dylib $TARGET_LIBS" +done + +mkdir -p "${TARGET_DIR}/release" +OUTPUT="${TARGET_DIR}/release/lib${LIB_NAME}.dylib" +echo "Combining targets into universal library" +lipo -create -output $OUTPUT $TARGET_LIBS diff --git a/build.sh b/build.sh deleted file mode 100755 index 8955f32..0000000 --- a/build.sh +++ /dev/null @@ -1,96 +0,0 @@ -#!/bin/sh - -# NOTE: -# MacOS universal build currently requires MacOS 11 (Big Sur) for the appropriate SDK, -# and `sudo xcode-select --install` must be run to install the command line utilities. -# Rust's `beta` channel must be installed because aarch64 is still a tier-2 target: -# `rustup toolchain install beta`. -# The build command becomes `BUILD_TARGET=apple-darwin BUILD_TOOLCHAIN=beta ./build.sh` - -RUSTUP=${RUSTUP:-`command -v rustup`} -PROJECT=indy-credx -LIB_NAME=indy_credx -FEATURES="${BUILD_FEATURES:-default}" - -if [ ! -x "$RUSTUP" ]; then - echo "rustup command not found: it can be obtained from https://rustup.rs/" - exit 1 -fi - -TOOLCHAIN=`$RUSTUP default` -TARGET="${BUILD_TARGET-}" - -if [ -z "$BUILD_TOOLCHAIN" ]; then - BUILD_TOOLCHAIN=${TOOLCHAIN%%-*} - if [ -z "$BUILD_TOOLCHAIN" ]; then - echo "Error: Could not determine default Rust toolchain" - exit 1 - fi -fi - -MACOS_UNIVERSAL_TARGETS="aarch64-apple-darwin x86_64-apple-darwin" - -# Fail on any execution errors -set -e - -if [ "$TARGET" = "apple-darwin" ]; then - # MacOS universal build - INSTALLED_TARGETS=`$RUSTUP +$BUILD_TOOLCHAIN target list --installed` - # Install target(s) as needed - echo "Checking install targets for MacOS universal build .." - for target in $MACOS_UNIVERSAL_TARGETS; do - if ! `echo "$INSTALLED_TARGETS" | grep -q $target`; then - $RUSTUP +$BUILD_TOOLCHAIN target add $target - fi - done -elif [ -z "$TARGET" ]; then - case "$TOOLCHAIN" in - *apple-darwin*) - # Check if the required targets for a universal build are installed - INSTALLED_TARGETS=`$RUSTUP +$BUILD_TOOLCHAIN target list --installed` - TARGET="apple-darwin" - for target in $MACOS_UNIVERSAL_TARGETS; do - if ! `echo "$INSTALLED_TARGETS" | grep -q $target`; then - TARGET= - break - fi - done - if [ "$TARGET" = "apple-darwin" ]; then - echo "Automatically enabled MacOS universal build" - else - echo "Universal MacOS build not enabled" - fi - esac -fi - -if [ "$TARGET" = "apple-darwin" ]; then - MAJOR_VER=`sw_vers | grep ProductVersion | cut -f 2 | cut -f 1 -d .` - if [ "$MAJOR_VER" -lt 11 ]; then - echo "MacOS universal build requires OS 11 (Big Sur) or newer" - TARGET= - fi -fi - -if [ "$TARGET" = "apple-darwin" ]; then - # Build both targets and combine them into a universal library with `lipo` - TARGET_LIBS= - for target in $MACOS_UNIVERSAL_TARGETS; do - echo "Building $PROJECT for toolchain '$BUILD_TOOLCHAIN', target '$target'.." - $RUSTUP run $BUILD_TOOLCHAIN cargo build --manifest-path indy-credx/Cargo.toml --release --features $FEATURES --target $target - TARGET_LIBS="./target/$target/release/lib${LIB_NAME}.dylib $TARGET_LIBS" - done - - mkdir -p ./target/release - OUTPUT="./target/release/lib${LIB_NAME}.dylib" - echo "Combining targets into universal library" - lipo -create -output $OUTPUT $TARGET_LIBS -else - # Build normal target - echo "Building $PROJECT for toolchain '$BUILD_TOOLCHAIN'.." - CMD="$RUSTUP run $BUILD_TOOLCHAIN cargo build --manifest-path indy-credx/Cargo.toml --release --features $FEATURES" - if [ -n "$TARGET" ]; then - $CMD --target "$TARGET" - else - $CMD - fi -fi diff --git a/indy-credx/Cargo.toml b/indy-credx/Cargo.toml index c98fb87..2369f33 100644 --- a/indy-credx/Cargo.toml +++ b/indy-credx/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "indy-credx" -version = "0.3.1" +version = "0.3.2" authors = ["Hyperledger Indy Contributors "] description = "Verifiable credential issuance and presentation for Hyperledger Indy (https://www.hyperledger.org/projects), which provides a distributed-ledger-based foundation for self-sovereign identity (https://sovrin.org)." edition = "2018" @@ -22,7 +22,7 @@ logger = ["env_logger"] vendored = ["indy-data-types/vendored"] [dependencies] -env_logger = { version = "0.7.1", optional = true } +env_logger = { version = "0.9", optional = true } ffi-support = { version = "0.4.0", optional = true } log = "0.4" once_cell = "1.9" @@ -36,7 +36,7 @@ thiserror = "1.0" zeroize = { version = "1.3", optional = true } [dependencies.indy-data-types] -version = "0.5" +version = "0.5.2" path = "../indy-data-types" features = ["cl_native"] @@ -44,4 +44,3 @@ features = ["cl_native"] version = "0.5" path = "../indy-utils" default-features = false -features = ["wql"] diff --git a/indy-credx/src/services/types.rs b/indy-credx/src/services/types.rs index 68a42c5..fe174a8 100644 --- a/indy-credx/src/services/types.rs +++ b/indy-credx/src/services/types.rs @@ -188,21 +188,6 @@ impl<'a, 'p> AddCredential<'a, 'p> { } } -#[derive(Debug)] -pub(crate) struct RequestedAttribute<'a> { - pub cred_id: String, - pub timestamp: Option, - pub revealed: bool, - pub rev_state: Option<&'a CredentialRevocationState>, -} - -#[derive(Debug)] -pub(crate) struct RequestedPredicate<'a> { - pub cred_id: String, - pub timestamp: Option, - pub rev_state: Option<&'a CredentialRevocationState>, -} - #[derive(Clone, Debug, PartialEq, Eq, Hash)] pub(crate) struct ProvingCredentialKey { pub cred_id: String, diff --git a/indy-credx/src/services/verifier.rs b/indy-credx/src/services/verifier.rs index 25b4bc2..0d05235 100644 --- a/indy-credx/src/services/verifier.rs +++ b/indy-credx/src/services/verifier.rs @@ -11,8 +11,8 @@ use indy_data_types::anoncreds::{ nonce::Nonce, pres_request::{AttributeInfo, NonRevocedInterval, PredicateInfo, PresentationRequestPayload}, presentation::{Identifier, RequestedProof, RevealedAttributeInfo}, + wql::Query, }; -use indy_utils::wql::Query; #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] pub struct Filter { diff --git a/indy-data-types/Cargo.toml b/indy-data-types/Cargo.toml index b6d0a45..e1ea65f 100644 --- a/indy-data-types/Cargo.toml +++ b/indy-data-types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "indy-data-types" -version = "0.5.1" +version = "0.5.2" authors = ["Hyperledger Indy Contributors "] description = "Common data types for Hyperledger Indy (https://www.hyperledger.org/projects), which provides a distributed-ledger-based foundation for self-sovereign identity (https://sovrin.org)." edition = "2018" @@ -21,25 +21,26 @@ cl = ["serde_support", "ursa", "ursa/cl", "ursa/serde"] cl_native = ["serde_support", "ursa", "ursa/cl_native", "ursa/serde"] merkle_tree = ["indy-utils/hash", "hex"] rich_schema = [] -serde_support = ["serde", "serde_json"] -vendored = ["openssl", "openssl/vendored"] +serde_support = ["serde", "serde_json", "indy-utils/serde"] +vendored = ["openssl", "openssl/vendored", "openssl-src"] [dependencies] hex = { version = "0.4", optional = true } openssl = { version = "0.10", optional = true } +openssl-src = { version = "=111.25.0", optional = true } # temp override once_cell = "1.9" regex = "1.3" serde = { version = "1.0", optional = true, features = ["derive"] } serde_json = { version = "1.0", optional = true, features = ["raw_value"] } -ursa = { version = "=0.3.6", default-features = false, optional = true } +ursa = { version = "0.3", default-features = false, optional = true } zeroize = { version = "1.1", features = ["zeroize_derive"] } [dependencies.indy-utils] version = "0.5" path = "../indy-utils" default-features = false -features = ["wql"] [dev-dependencies] hex = "0.4" +rand = "0.8" serde_json = "1.0" diff --git a/indy-data-types/src/anoncreds/mod.rs b/indy-data-types/src/anoncreds/mod.rs index 4a57d1d..af04a83 100644 --- a/indy-data-types/src/anoncreds/mod.rs +++ b/indy-data-types/src/anoncreds/mod.rs @@ -38,3 +38,5 @@ pub mod rich_schema; /// V1 credential schemas pub mod schema; + +pub mod wql; diff --git a/indy-data-types/src/anoncreds/pres_request.rs b/indy-data-types/src/anoncreds/pres_request.rs index b69175e..951d512 100644 --- a/indy-data-types/src/anoncreds/pres_request.rs +++ b/indy-data-types/src/anoncreds/pres_request.rs @@ -8,14 +8,14 @@ use serde_json::Value; use super::credential::Credential; use super::nonce::Nonce; +use super::wql::Query; +use crate::did::DidValue; use crate::identifiers::cred_def::CredentialDefinitionId; use crate::identifiers::rev_reg::RevocationRegistryId; use crate::identifiers::schema::SchemaId; +use crate::invalid; use crate::utils::{qualifiable, Qualifiable}; use crate::{Validatable, ValidationError}; -use indy_utils::did::DidValue; -use indy_utils::invalid; -use indy_utils::wql::Query; #[derive(Debug, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] diff --git a/indy-wql/src/lib.rs b/indy-data-types/src/anoncreds/wql.rs similarity index 99% rename from indy-wql/src/lib.rs rename to indy-data-types/src/anoncreds/wql.rs index 869b0bc..f49e37a 100644 --- a/indy-wql/src/lib.rs +++ b/indy-data-types/src/anoncreds/wql.rs @@ -1,7 +1,5 @@ //! Indy WQL (wallet query language) parsing and optimization -#![deny(missing_debug_implementations, missing_docs, rust_2018_idioms)] - /// An abstract query representation over a key and value type #[derive(Debug, Hash, Clone, PartialEq, Eq, PartialOrd, Ord)] pub enum AbstractQuery { diff --git a/indy-utils/Cargo.toml b/indy-utils/Cargo.toml index 6635e1d..b66c1e2 100644 --- a/indy-utils/Cargo.toml +++ b/indy-utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "indy-utils" -version = "0.5.1" +version = "0.5.2" authors = ["Hyperledger Indy Contributors "] description = "Utilities for Hyperledger Indy (https://www.hyperledger.org/projects), which provides a distributed-ledger-based foundation for self-sovereign identity (https://sovrin.org)." edition = "2018" @@ -16,12 +16,11 @@ path = "src/lib.rs" crate-type = ["rlib"] [features] -default = ["ed25519", "hash", "txn_signature", "wql"] +default = ["ed25519", "hash", "txn_signature"] base64 = ["base64_rs"] ed25519 = ["curve25519-dalek", "ed25519-dalek", "rand", "sha2", "x25519-dalek"] hash = ["sha2"] txn_signature = ["hex", "sha2", "serde", "serde_json"] -wql = ["indy-wql", "serde", "serde_json"] [dependencies] base64_rs = { package = "base64", version = "0.13", optional = true } @@ -29,13 +28,12 @@ bs58 = "0.4" curve25519-dalek = { version = "3.1", default-features = false, features = ["u64_backend"], optional = true } ed25519-dalek = { version = "1.0", default-features = false, features = ["u64_backend"], optional = true } hex = { version = "0.4", optional = true } -indy-wql = { version = "0.4", optional = true, path = "../indy-wql" } once_cell = "1.9" rand = { version = "0.8", optional = true } regex = "1.3" serde = { version = "1.0", optional = true, features = ["derive"] } serde_json = { version = "1.0", optional = true } -sha2 = { version = "0.10", optional = true } +sha2 = { version = "0.9", optional = true } thiserror = "1.0" x25519-dalek = { version = "=1.2", default-features = false, features = ["u64_backend"], optional = true } zeroize = { version = "1.3" } diff --git a/indy-utils/src/did.rs b/indy-utils/src/did.rs index 979865a..059d45b 100644 --- a/indy-utils/src/did.rs +++ b/indy-utils/src/did.rs @@ -1,6 +1,7 @@ use once_cell::sync::Lazy; use regex::Regex; +#[cfg(feature = "ed25519")] use sha2::{Digest, Sha256}; use crate::base58; diff --git a/indy-utils/src/error.rs b/indy-utils/src/error.rs index 23c1f38..898f8d1 100644 --- a/indy-utils/src/error.rs +++ b/indy-utils/src/error.rs @@ -118,7 +118,7 @@ define_error!( "Error type for failures of `Validatable::validate`" ); -#[cfg(feature = "serde")] +#[cfg(feature = "serde_json")] impl From for ConversionError { fn from(err: serde_json::error::Error) -> Self { Self::from_msg(err.to_string()) diff --git a/indy-utils/src/lib.rs b/indy-utils/src/lib.rs index 1ec949c..b73578a 100644 --- a/indy-utils/src/lib.rs +++ b/indy-utils/src/lib.rs @@ -39,7 +39,3 @@ pub mod hash; /// Generation of normalized ledger transaction for signing #[cfg(feature = "txn_signature")] pub mod txn_signature; - -/// Wallet query language -#[cfg(feature = "wql")] -pub use indy_wql as wql; diff --git a/indy-wql/Cargo.toml b/indy-wql/Cargo.toml deleted file mode 100644 index c40ba40..0000000 --- a/indy-wql/Cargo.toml +++ /dev/null @@ -1,28 +0,0 @@ -[package] -name = "indy-wql" -version = "0.4.0" -authors = ["Hyperledger Indy Contributors "] -description = "Wallet Query Language for Hyperledger Indy (https://www.hyperledger.org/projects), which provides a distributed-ledger-based foundation for self-sovereign identity (https://sovrin.org)." -edition = "2018" -license = "Apache-2.0" -readme = "../README.md" -repository = "https://github.com/hyperledger/indy-shared-rs/" -categories = ["authentication", "cryptography"] -keywords = ["hyperledger", "indy", "ssi", "verifiable", "credentials"] - -[lib] -name = "indy_wql" -path = "src/lib.rs" -crate-type = ["rlib"] - -[features] -default = ["serde_support"] -serde_support = ["serde", "serde_json"] - -[dependencies] -serde = { version = "1.0", optional = true, default-features = false } -serde_json = { version = "1.0", optional = true, default-features = false } - -[dev-dependencies] -rand = "0.8" -serde_json = "1.0" diff --git a/wrappers/python/indy_credx/version.py b/wrappers/python/indy_credx/version.py index 2506faa..90c1185 100644 --- a/wrappers/python/indy_credx/version.py +++ b/wrappers/python/indy_credx/version.py @@ -1,3 +1,3 @@ """indy_credx library wrapper version.""" -__version__ = "0.3.1" +__version__ = "0.3.2"