diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b39a0b1..02846c6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -13,20 +13,14 @@ jobs: runs-on: ubuntu-18.04 steps: - uses: actions/checkout@v2 - # Work around https://github.com/actions/cache/issues/133#issuecomment-599102035 - - run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/ - name: Fix perms on .cargo so we can restore the cache. - name: Cache cargo - uses: actions/cache@v1 - with: - path: ~/.cargo/ - key: ${{ github.job }} + uses: Swatinem/rust-cache@v1 - uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: nightly override: true - - run: rustup component add rustfmt + components: rustfmt - uses: actions-rs/cargo@v1 with: command: fmt @@ -57,20 +51,8 @@ jobs: target: x86_64-pc-windows-msvc steps: - uses: actions/checkout@v2 - # Work around https://github.com/actions/cache/issues/133#issuecomment-599102035 - - run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/ - name: Fix perms on .cargo so we can restore the cache. - if: "!contains(runner.os, 'windows')" - name: Cache cargo - uses: actions/cache@v1 - with: - path: ~/.cargo/ - key: ${{ github.job }}-${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.toml') }} - - name: Cache cargo build - uses: actions/cache@v1 - with: - path: target - key: ${{ github.job }}-${{ runner.os }}-${{ matrix.target }}-target-${{ hashFiles('**/Cargo.toml') }} + uses: Swatinem/rust-cache@v1 - uses: actions-rs/toolchain@v1 with: toolchain: stable @@ -91,23 +73,12 @@ jobs: rust: - stable - beta - - 1.41.1 #MSRV + - 1.48 #MSRV fail-fast: false steps: - uses: actions/checkout@v2 - # Work around https://github.com/actions/cache/issues/133#issuecomment-599102035 - - run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/ - name: Fix perms on .cargo so we can restore the cache. - name: Cache cargo - uses: actions/cache@v1 - with: - path: ~/.cargo/ - key: ${{ github.job }}-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}-${{ matrix.rust }} - - name: Cache cargo build - uses: actions/cache@v1 - with: - path: target - key: ${{ github.job }}-${{ runner.os }}-target-${{ hashFiles('**/Cargo.toml') }}-${{ matrix.rust }} + uses: Swatinem/rust-cache@v1 - uses: actions-rs/toolchain@v1 with: profile: minimal @@ -133,19 +104,8 @@ jobs: - uses: actions/checkout@v2 with: ref: ${{ matrix.ref }} - # Work around https://github.com/actions/cache/issues/133#issuecomment-599102035 - - run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/ - name: Fix perms on .cargo so we can restore the cache. - name: Cache cargo - uses: actions/cache@v1 - with: - path: ~/.cargo/ - key: ${{ github.job }}-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }} - - name: Cache cargo build - uses: actions/cache@v1 - with: - path: target - key: ${{ github.job }}-${{ runner.os }}-target-${{ hashFiles('**/Cargo.toml') }} + uses: Swatinem/rust-cache@v1 - uses: actions-rs/toolchain@v1 with: profile: minimal @@ -174,14 +134,8 @@ jobs: runs-on: ubuntu-18.04 steps: - uses: actions/checkout@v2 - # Work around https://github.com/actions/cache/issues/133#issuecomment-599102035 - - run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/ - name: Fix perms on .cargo so we can restore the cache. - name: Cache cargo - uses: actions/cache@v1 - with: - path: ~/.cargo/ - key: ${{ github.job }} + uses: Swatinem/rust-cache@v1 - name: Retrieve benchmark results uses: actions/download-artifact@v1 with: diff --git a/CHANGELOG.md b/CHANGELOG.md index adc3b32..b40cbfa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## 0.13.0 (Unreleased) + +### Public API changes + +- [[#152](https://github.com/IronCoreLabs/recrypt-rs/pull/152)] Change MSRV to Rust 1.48.0 + +### Notable internal changes + +- [[#152](https://github.com/IronCoreLabs/recrypt-rs/pull/152)] Remove dependency on `arrayvec` + ## 0.12.0 ### Public API changes diff --git a/Cargo.toml b/Cargo.toml index 146ba52..2115dc1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "recrypt" -version = "0.12.0" +version = "0.13.0-pre" authors = ["IronCore Labs "] readme = "README.md" license = "AGPL-3.0-only" @@ -25,7 +25,6 @@ rand_chacha = "~0.2.2" sha2 = "~0.9" num-traits = "~0.2" lazy_static = "~1.4" -arrayvec = "~0.5" #Disable all features for ed25519 and enable the proper ones down in the [features] section below ed25519-dalek = { version="=1.0.1", default-features = false, features = ["std"] } clear_on_drop = "~0.2" diff --git a/src/internal/bytedecoder.rs b/src/internal/bytedecoder.rs index 9d69918..8b31427 100644 --- a/src/internal/bytedecoder.rs +++ b/src/internal/bytedecoder.rs @@ -1,10 +1,9 @@ use crate::internal::ByteVector; -use arrayvec; -use arrayvec::ArrayVec; use gridiron::fp_256::Fp256; use gridiron::fp_480::Fp480; use quick_error::quick_error; use std::convert::From; +use std::convert::TryInto; use std::result::Result; /// Decode a ByteVector into an implementing type. @@ -23,9 +22,13 @@ where impl BytesDecoder for gridiron::fp_256::Monty { const ENCODED_SIZE_BYTES: usize = 32; fn decode(bytes: ByteVector) -> Result { - let byte_arr: ArrayVec<[u8; Self::ENCODED_SIZE_BYTES]> = bytes.into_iter().collect(); - let byte_arr: [u8; Self::ENCODED_SIZE_BYTES] = byte_arr.into_inner()?; - Result::Ok(Fp256::from(byte_arr).to_monty()) + let byte_array: Result<[u8; Self::ENCODED_SIZE_BYTES], ByteVector> = bytes.try_into(); + byte_array + .map(|array| Fp256::from(array).to_monty()) + .map_err(|b| DecodeErr::BytesNotCorrectLength { + required_length: Self::ENCODED_SIZE_BYTES, + bad_bytes: b, + }) } } @@ -52,26 +55,10 @@ quick_error! { BytesNotCorrectLength { required_length: usize, bad_bytes: ByteVector, - } { } BytesInvalid { message: String, bad_bytes: ByteVector, - }{} + } } } - -/// Needed for error handing when ArrayVec.into_inner is called on an instance that is not -/// at capacity. -macro_rules! from_arrayvec_n { ($($n: expr), *) => { - $(impl From> for DecodeErr { - fn from(x: arrayvec::ArrayVec<[u8; $n]>) -> Self { - DecodeErr::BytesNotCorrectLength { - required_length: $n, - bad_bytes: x.to_vec(), - } - } -})+ -}} - -from_arrayvec_n! {32, 128, 384} diff --git a/src/internal/mod.rs b/src/internal/mod.rs index c3e99f8..c285e3c 100644 --- a/src/internal/mod.rs +++ b/src/internal/mod.rs @@ -1139,7 +1139,7 @@ pub(crate) fn take_lock(m: &Mutex) -> MutexGuard { m.lock().unwrap_or_else(|e| { let error = format!("Error when acquiring lock: {}", e); error!("{}", error); - panic!(error); + panic!("{}", error); }) }