Skip to content

Commit 122095a

Browse files
authored
Remove dependency on arrayvec (#152)
1 parent 3022094 commit 122095a

File tree

5 files changed

+28
-78
lines changed

5 files changed

+28
-78
lines changed

.github/workflows/ci.yaml

Lines changed: 7 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,14 @@ jobs:
1313
runs-on: ubuntu-18.04
1414
steps:
1515
- uses: actions/checkout@v2
16-
# Work around https://github.com/actions/cache/issues/133#issuecomment-599102035
17-
- run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/
18-
name: Fix perms on .cargo so we can restore the cache.
1916
- name: Cache cargo
20-
uses: actions/cache@v1
21-
with:
22-
path: ~/.cargo/
23-
key: ${{ github.job }}
17+
uses: Swatinem/rust-cache@v1
2418
- uses: actions-rs/toolchain@v1
2519
with:
2620
profile: minimal
2721
toolchain: nightly
2822
override: true
29-
- run: rustup component add rustfmt
23+
components: rustfmt
3024
- uses: actions-rs/cargo@v1
3125
with:
3226
command: fmt
@@ -57,20 +51,8 @@ jobs:
5751
target: x86_64-pc-windows-msvc
5852
steps:
5953
- uses: actions/checkout@v2
60-
# Work around https://github.com/actions/cache/issues/133#issuecomment-599102035
61-
- run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/
62-
name: Fix perms on .cargo so we can restore the cache.
63-
if: "!contains(runner.os, 'windows')"
6454
- name: Cache cargo
65-
uses: actions/cache@v1
66-
with:
67-
path: ~/.cargo/
68-
key: ${{ github.job }}-${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.toml') }}
69-
- name: Cache cargo build
70-
uses: actions/cache@v1
71-
with:
72-
path: target
73-
key: ${{ github.job }}-${{ runner.os }}-${{ matrix.target }}-target-${{ hashFiles('**/Cargo.toml') }}
55+
uses: Swatinem/rust-cache@v1
7456
- uses: actions-rs/toolchain@v1
7557
with:
7658
toolchain: stable
@@ -91,23 +73,12 @@ jobs:
9173
rust:
9274
- stable
9375
- beta
94-
- 1.41.1 #MSRV
76+
- 1.48 #MSRV
9577
fail-fast: false
9678
steps:
9779
- uses: actions/checkout@v2
98-
# Work around https://github.com/actions/cache/issues/133#issuecomment-599102035
99-
- run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/
100-
name: Fix perms on .cargo so we can restore the cache.
10180
- name: Cache cargo
102-
uses: actions/cache@v1
103-
with:
104-
path: ~/.cargo/
105-
key: ${{ github.job }}-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}-${{ matrix.rust }}
106-
- name: Cache cargo build
107-
uses: actions/cache@v1
108-
with:
109-
path: target
110-
key: ${{ github.job }}-${{ runner.os }}-target-${{ hashFiles('**/Cargo.toml') }}-${{ matrix.rust }}
81+
uses: Swatinem/rust-cache@v1
11182
- uses: actions-rs/toolchain@v1
11283
with:
11384
profile: minimal
@@ -133,19 +104,8 @@ jobs:
133104
- uses: actions/checkout@v2
134105
with:
135106
ref: ${{ matrix.ref }}
136-
# Work around https://github.com/actions/cache/issues/133#issuecomment-599102035
137-
- run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/
138-
name: Fix perms on .cargo so we can restore the cache.
139107
- name: Cache cargo
140-
uses: actions/cache@v1
141-
with:
142-
path: ~/.cargo/
143-
key: ${{ github.job }}-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
144-
- name: Cache cargo build
145-
uses: actions/cache@v1
146-
with:
147-
path: target
148-
key: ${{ github.job }}-${{ runner.os }}-target-${{ hashFiles('**/Cargo.toml') }}
108+
uses: Swatinem/rust-cache@v1
149109
- uses: actions-rs/toolchain@v1
150110
with:
151111
profile: minimal
@@ -174,14 +134,8 @@ jobs:
174134
runs-on: ubuntu-18.04
175135
steps:
176136
- uses: actions/checkout@v2
177-
# Work around https://github.com/actions/cache/issues/133#issuecomment-599102035
178-
- run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/
179-
name: Fix perms on .cargo so we can restore the cache.
180137
- name: Cache cargo
181-
uses: actions/cache@v1
182-
with:
183-
path: ~/.cargo/
184-
key: ${{ github.job }}
138+
uses: Swatinem/rust-cache@v1
185139
- name: Retrieve benchmark results
186140
uses: actions/download-artifact@v1
187141
with:

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## 0.13.0 (Unreleased)
4+
5+
### Public API changes
6+
7+
- [[#152](https://github.com/IronCoreLabs/recrypt-rs/pull/152)] Change MSRV to Rust 1.48.0
8+
9+
### Notable internal changes
10+
11+
- [[#152](https://github.com/IronCoreLabs/recrypt-rs/pull/152)] Remove dependency on `arrayvec`
12+
313
## 0.12.0
414

515
### Public API changes

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "recrypt"
3-
version = "0.12.0"
3+
version = "0.13.0-pre"
44
authors = ["IronCore Labs <[email protected]>"]
55
readme = "README.md"
66
license = "AGPL-3.0-only"
@@ -25,7 +25,6 @@ rand_chacha = "~0.2.2"
2525
sha2 = "~0.9"
2626
num-traits = "~0.2"
2727
lazy_static = "~1.4"
28-
arrayvec = "~0.5"
2928
#Disable all features for ed25519 and enable the proper ones down in the [features] section below
3029
ed25519-dalek = { version="=1.0.1", default-features = false, features = ["std"] }
3130
clear_on_drop = "~0.2"

src/internal/bytedecoder.rs

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
use crate::internal::ByteVector;
2-
use arrayvec;
3-
use arrayvec::ArrayVec;
42
use gridiron::fp_256::Fp256;
53
use gridiron::fp_480::Fp480;
64
use quick_error::quick_error;
75
use std::convert::From;
6+
use std::convert::TryInto;
87
use std::result::Result;
98

109
/// Decode a ByteVector into an implementing type.
@@ -23,9 +22,13 @@ where
2322
impl BytesDecoder for gridiron::fp_256::Monty {
2423
const ENCODED_SIZE_BYTES: usize = 32;
2524
fn decode(bytes: ByteVector) -> Result<Self, DecodeErr> {
26-
let byte_arr: ArrayVec<[u8; Self::ENCODED_SIZE_BYTES]> = bytes.into_iter().collect();
27-
let byte_arr: [u8; Self::ENCODED_SIZE_BYTES] = byte_arr.into_inner()?;
28-
Result::Ok(Fp256::from(byte_arr).to_monty())
25+
let byte_array: Result<[u8; Self::ENCODED_SIZE_BYTES], ByteVector> = bytes.try_into();
26+
byte_array
27+
.map(|array| Fp256::from(array).to_monty())
28+
.map_err(|b| DecodeErr::BytesNotCorrectLength {
29+
required_length: Self::ENCODED_SIZE_BYTES,
30+
bad_bytes: b,
31+
})
2932
}
3033
}
3134

@@ -52,26 +55,10 @@ quick_error! {
5255
BytesNotCorrectLength {
5356
required_length: usize,
5457
bad_bytes: ByteVector,
55-
} {
5658
}
5759
BytesInvalid {
5860
message: String,
5961
bad_bytes: ByteVector,
60-
}{}
62+
}
6163
}
6264
}
63-
64-
/// Needed for error handing when ArrayVec.into_inner is called on an instance that is not
65-
/// at capacity.
66-
macro_rules! from_arrayvec_n { ($($n: expr), *) => {
67-
$(impl From<arrayvec::ArrayVec<[u8; $n]>> for DecodeErr {
68-
fn from(x: arrayvec::ArrayVec<[u8; $n]>) -> Self {
69-
DecodeErr::BytesNotCorrectLength {
70-
required_length: $n,
71-
bad_bytes: x.to_vec(),
72-
}
73-
}
74-
})+
75-
}}
76-
77-
from_arrayvec_n! {32, 128, 384}

src/internal/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ pub(crate) fn take_lock<T>(m: &Mutex<T>) -> MutexGuard<T> {
11391139
m.lock().unwrap_or_else(|e| {
11401140
let error = format!("Error when acquiring lock: {}", e);
11411141
error!("{}", error);
1142-
panic!(error);
1142+
panic!("{}", error);
11431143
})
11441144
}
11451145

0 commit comments

Comments
 (0)