Skip to content

Commit

Permalink
chore: bump dependencies (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes authored Jun 9, 2023
1 parent 14db5c9 commit 4c3e0c7
Show file tree
Hide file tree
Showing 15 changed files with 161 additions and 173 deletions.
101 changes: 46 additions & 55 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,75 +15,66 @@ env:
CARGO_TERM_COLOR: always

jobs:
build:
test:
name: test ${{ matrix.features }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
features: ["", "--no-default-features"]
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v1
with:
cache-on-failure: true

- name: Build
run: cargo build --verbose
- name: Build (no default features)
run: cargo build --verbose --no-default-features --locked
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo test ${{ matrix.features }}

wasm:
name: Build WASM
name: check WASM
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install rust
uses: actions-rs/toolchain@v1
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
target: wasm32-unknown-unknown
profile: minimal
override: true
- uses: Swatinem/rust-cache@v2
- name: check
run: |
cargo check \
--target wasm32-unknown-unknown \
--no-default-features \
--features browser
- uses: Swatinem/rust-cache@v1
with:
cache-on-failure: true

- name: Check
uses: actions-rs/cargo@v1
with:
command: build
args: --verbose --target wasm32-unknown-unknown --no-default-features --features "browser"
clippy:
name: clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@clippy
- name: clippy
run: cargo clippy --workspace --all-targets
env:
RUSTFLAGS: "-D warnings"

test:
docs:
name: docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v1
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
with:
cache-on-failure: true
components: rust-docs
- name: doc
run: cargo doc --workspace --no-deps --document-private-items
env:
RUSTDOCFLAGS: "--cfg docsrs -D warnings"

- name: Run tests
run: cargo test --verbose

lint:
fmt:
name: fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
profile: minimal
components: rustfmt, clippy
override: true
- uses: Swatinem/rust-cache@v1
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
with:
cache-on-failure: true

- name: cargo fmt
run: cargo +nightly fmt -- --check
- name: cargo clippy
run: cargo +nightly clippy -- -D warnings
components: rustfmt
- name: fmt --check
run: cargo fmt --all --check
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
target/
Cargo.lock

pkg/
pkg-node/
**/*.rs.bk
Cargo.lock
tarpaulin-report.html
node_modules
.vscode
18 changes: 7 additions & 11 deletions bip32/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,20 @@ repository = "https://github.com/summa-tx/bitcoins-rs"
license = "MIT OR Apache-2.0"

[dependencies]
thiserror = "1.0"
hmac = "0.12"
sha2 = "0.10"
bs58 = "0.4.0"
coins-core = { version = "0.8.3", path = "../core" }
serde = "1.0.105"

k256 = { version = "0.13", features = ["std", "arithmetic"] }
bs58 = "0.5"
digest = "0.10"

[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2", features = ["js"] }
hmac = "0.12"
k256 = { version = "0.13", features = ["std", "arithmetic"] }
serde = "1.0"
sha2 = "0.10"
thiserror = "1.0"

[dev-dependencies]
hex = "0.4.2"
hex = "0.4"

[features]
default = ["mainnet"]
mainnet = []
testnet = []

4 changes: 0 additions & 4 deletions bip32/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,3 @@ impl From<std::convert::Infallible> for Bip32Error {
unimplemented!("unreachable, but required by type system")
}
}

// We need to specify the getrandom JS feature, but don't need the crate.
#[cfg(target_arch = "wasm32")]
use getrandom as _;
24 changes: 12 additions & 12 deletions bip39/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
[package]
name = "coins-bip39"
version = "0.8.6"
authors = ["Rohit Narurkar <[email protected]>", "James Prestwich <[email protected]>", "0xYYY <[email protected]>"]
authors = [
"Rohit Narurkar <[email protected]>",
"James Prestwich <[email protected]>",
"0xYYY <[email protected]>",
]
edition = "2018"
description = "Bip39 in Rust"
repository = "https://github.com/summa-tx/bitcoins-rs"
repository = "https://github.com/summa-tx/coins"
license = "MIT OR Apache-2.0"

[dependencies]
bitvec = "0.17.4"
coins-bip32 = { version = "0.8.3", path = "../bip32" }

bitvec = "1.0"
hmac = "0.12"
pbkdf2 = "0.12"
rand = "0.8.4"
rand = "0.8"
sha2 = "0.10"
thiserror = "1.0"

# used by all wordlists
once_cell = { version = "1.17.1", optional = true}
once_cell = { version = "1.17", optional = true }

[dev-dependencies]
hex = "0.4.2"

[target.'cfg(target_arch = "wasm32")'.dependencies.getrandom]
version = "0.2.3"
default-features = false
features=["js"]
hex = "0.4"

[features]
default = ["all-langs"]
Expand All @@ -50,4 +50,4 @@ italian = ["dep:once_cell"]
japanese = ["dep:once_cell"]
korean = ["dep:once_cell"]
portuguese = ["dep:once_cell"]
spanish = ["dep:once_cell"]
spanish = ["dep:once_cell"]
4 changes: 0 additions & 4 deletions bip39/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,3 @@ pub use self::mnemonic::*;
/// Wordlists
pub mod wordlist;
pub use self::wordlist::*;

// We need to specify the getrandom JS feature, but don't need the crate.
#[cfg(target_arch = "wasm32")]
use getrandom as _;
14 changes: 7 additions & 7 deletions bip39/src/mnemonic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,19 +224,19 @@ where
pub fn new_from_phrase(phrase: &str) -> Result<Self, MnemonicError> {
let words = phrase.split(' ').collect::<Vec<&str>>();

let mut entropy: BitVec<Msb0, u8> = BitVec::new();
let mut entropy: BitVec<u8, Msb0> = BitVec::new();
for word in words {
let index = W::get_index(word)?;
let index_u8: [u8; 2] = (index as u16).to_be_bytes();

// 11-bits per word as per BIP-39, and max index (2047) can be represented in 11-bits.
let index_slice = &BitVec::from_slice(&index_u8)[5..];

entropy.append(&mut BitVec::<Msb0, u8>::from_bitslice(index_slice));
entropy.append(&mut BitVec::<u8, Msb0>::from_bitslice(index_slice));
}

let mnemonic = Self {
entropy: Entropy::from_slice(entropy)?,
entropy: Entropy::from_slice(entropy.as_raw_slice())?,
_wordlist: PhantomData,
};

Expand All @@ -256,12 +256,12 @@ where
let mut hasher = Sha256::new();
hasher.update(self.entropy.as_ref());
let hash = hasher.finalize();
let hash_0 = BitVec::<Msb0, u8>::from_element(hash[0]);
let hash_0 = BitVec::<u8, Msb0>::from_element(hash[0]);
let (checksum, _) = hash_0.split_at(length / 3);

// Convert the entropy bytes into bits and append the checksum.
let mut encoding = BitVec::<Msb0, u8>::from_slice(self.entropy.as_ref());
encoding.append(&mut checksum.to_vec());
let mut encoding = BitVec::<u8, Msb0>::from_slice(self.entropy.as_ref());
encoding.append(&mut checksum.to_bitvec());

// Compute the phrase in 11 bit chunks which encode an index into the word list
let wordlist = W::get_all();
Expand Down Expand Up @@ -313,7 +313,7 @@ where
}
}

#[cfg(test)]
#[cfg(all(test, feature = "english"))]
mod tests {
use crate::English;
use coins_bip32::enc::{MainnetEncoder, XKeyEncoder};
Expand Down
23 changes: 15 additions & 8 deletions bip39/src/wordlist/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,50 @@ pub mod chinese_simplified;
#[cfg(feature = "chinese-simplified")]
pub use self::chinese_simplified::ChineseSimplified;

#[cfg(feature = "chinese-traditional")]
/// The Chinese (Traditional) wordlist
#[cfg(feature = "chinese-traditional")]
pub mod chinese_traditional;
#[cfg(feature = "chinese-traditional")]
pub use super::chinese_traditional::ChineseTraditional;
#[cfg(feature = "czech")]

/// The Czech wordlist
#[cfg(feature = "czech")]
pub mod czech;
#[cfg(feature = "czech")]
pub use super::czech::Czech;
#[cfg(feature = "french")]

/// The French wordlist
#[cfg(feature = "french")]
pub mod french;
#[cfg(feature = "french")]
pub use super::french::French;
#[cfg(feature = "italian")]

/// The Italian wordlist
#[cfg(feature = "italian")]
pub mod italian;
#[cfg(feature = "italian")]
pub use super::italian::Italian;
#[cfg(feature = "japanese")]

/// The Japanese wordlist
#[cfg(feature = "japanese")]
pub mod japanese;
#[cfg(feature = "japanese")]
pub use super::japanese::Japanese;
#[cfg(feature = "korean")]

/// The Korean wordlist
#[cfg(feature = "korean")]
pub mod korean;
#[cfg(feature = "korean")]
pub use super::korean::Korean;
#[cfg(feature = "portuguese")]

/// The Portuguese wordlist
#[cfg(feature = "portuguese")]
pub mod portuguese;
#[cfg(feature = "portuguese")]
pub use super::portuguese::Portuguese;
#[cfg(feature = "spanish")]

/// The Spanish wordlist
#[cfg(feature = "spanish")]
pub mod spanish;
#[cfg(feature = "spanish")]
pub use super::spanish::Spanish;
Expand Down
18 changes: 9 additions & 9 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ version = "0.8.3"
authors = ["James Prestwich <[email protected]>"]
edition = "2018"
description = "Core library for coins-bip32 and coins-bip39"
repository = "https://github.com/summa-tx/bitcoins-rs"
repository = "https://github.com/summa-tx/coins"
license = "MIT OR Apache-2.0"

[dependencies]
bech32 = "0.7.2"
hex = "0.4.2"
base64 = "0.21"
bech32 = "0.9"
bs58 = { version = "0.5", features = ["check"] }
hex = "0.4"
serde = { version = "1.0", features = ["derive"] }
serde_derive = "1.0"
thiserror = "1.0"
base64 = "0.21.0"
serde_derive = "1.0.106"
serde = { version = "1.0.106", features = ["derive"] }
bs58 = { version = "0.4.0", features = ["check"] }

# update in parallel
generic-array = "0.14.4"
digest = "0.10"
generic-array = "0.14"
ripemd = "0.1"
sha2 = "0.10"
sha3 = "0.10"
ripemd = "0.1"
4 changes: 2 additions & 2 deletions core/src/enc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ pub type EncodingResult<T> = Result<T, EncodingError>;
pub fn encode_bech32(hrp: &str, v: u8, h: &[u8]) -> EncodingResult<String> {
let mut v = vec![u5::try_from_u8(v)?];
v.extend(&h.to_base32());
b32_encode(hrp, &v).map_err(|v| v.into())
b32_encode(hrp, &v, bech32::Variant::Bech32).map_err(|v| v.into())
}

/// Decode a witness program from a bech32 string. Caller specifies an expected HRP. If a
/// different HRP is found, returns `WrongHrp`.
pub fn decode_bech32(expected_hrp: &str, s: &str) -> EncodingResult<(u8, Vec<u8>)> {
let (hrp, data) = b32_decode(s)?;
let (hrp, data, _variant) = b32_decode(s)?;
if hrp != expected_hrp {
return Err(EncodingError::WrongHrp {
got: hrp,
Expand Down
Loading

0 comments on commit 4c3e0c7

Please sign in to comment.