From ba9ebafae620ce046ef6116a3c05040cc544cb85 Mon Sep 17 00:00:00 2001 From: Denis Varlakov Date: Wed, 4 Dec 2024 13:27:39 +0100 Subject: [PATCH 1/3] Remove std feature, use core::error::Error, update docs Signed-off-by: Denis Varlakov --- Cargo.toml | 3 +-- src/errors.rs | 11 ++++------- src/lib.rs | 11 ++++++----- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 71bc57b..47acb77 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,6 @@ generic-ec = { version = "0.4", default-features = false, features = ["curve-sta [features] default = [] -std = [] # Adds support of secp256k1 curve to slip10 derivation curve-secp256k1 = ["generic-ec/curve-secp256k1", "slip10"] # Adds support of secp256r1 curve to slip10 derivation @@ -37,7 +36,7 @@ curve-secp256r1 = ["generic-ec/curve-secp256r1", "slip10"] curve-ed25519 = ["generic-ec/curve-ed25519", "edwards"] # Enables Stark-specific derivation curve-stark = ["generic-ec/curve-stark", "stark"] -all-curves = ["curve-secp256k1", "curve-secp256r1", "curve-ed25519"] +all-curves = ["curve-secp256k1", "curve-secp256r1", "curve-ed25519", "curve-stark"] serde = ["dep:serde", "generic-ec/serde"] # Enables Slip10 derivation diff --git a/src/errors.rs b/src/errors.rs index 4c003e3..595e655 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -12,8 +12,7 @@ impl fmt::Display for InvalidLength { } } -#[cfg(feature = "std")] -impl std::error::Error for InvalidLength {} +impl core::error::Error for InvalidLength {} /// Value was out of range #[derive(Debug)] @@ -25,8 +24,7 @@ impl fmt::Display for OutOfRange { } } -#[cfg(feature = "std")] -impl std::error::Error for OutOfRange {} +impl core::error::Error for OutOfRange {} /// Error returned by parsing child index #[derive(Debug)] @@ -46,9 +44,8 @@ impl fmt::Display for ParseChildIndexError { } } -#[cfg(feature = "std")] -impl std::error::Error for ParseChildIndexError { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { +impl core::error::Error for ParseChildIndexError { + fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { match self { ParseChildIndexError::ParseInt(e) => Some(e), ParseChildIndexError::IndexNotInRange(e) => Some(e), diff --git a/src/lib.rs b/src/lib.rs index 4178091..c666271 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -54,10 +54,11 @@ //! ``` //! //! ### Features -//! * `std`: enables std library support (mainly, it just implements [`Error`](std::error::Error) -//! trait for the error types) -//! * `curve-secp256k1`, `curve-secp256r1`, `curve-ed25519` add curve implementation into the crate -//! [curves] module +//! * `curve-secp256k1`, `curve-secp256r1`, `curve-ed25519`, `curve-stark` add curve implementation +//! into the crate [curves] module +//! * `all-curves` adds all curves listed above +//! * `slip10`, `edwards`, `stark` add [`slip10`], [`edwards`], and [`stark`] HD derivations respectively +//! * `serde` adds `serde::{Serialize, Deserialize}` traits implementation to the types in the library //! //! ## Join us in Discord! //! Feel free to reach out to us [in Discord](https://discordapp.com/channels/905194001349627914/1285268686147424388)! @@ -65,7 +66,7 @@ //! [slip10-spec]: https://github.com/satoshilabs/slips/blob/master/slip-0010.md //! [bip32-spec]: https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki -#![cfg_attr(not(feature = "std"), no_std)] +#![no_std] #![forbid(missing_docs, unsafe_code)] #![cfg_attr(not(test), forbid(unused_crate_dependencies))] From 036ea52ccd76fb23691c3799c62808e90e1941ca Mon Sep 17 00:00:00 2001 From: Denis Varlakov Date: Wed, 4 Dec 2024 13:31:06 +0100 Subject: [PATCH 2/3] Update changelog Signed-off-by: Denis Varlakov --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04d73e9..2f96d3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,15 @@ # hd-wallet crate changelog ## v0.6.0 -* Remove slip10-like derivation that can be instantiated with any curve: it is very inefficient +* BREAKING: Remove slip10-like derivation that can be instantiated with any curve: it is very inefficient when instantiated with certain curves, and may also enable attacker to perform DoS attack by finding derivation path that results into very long computation [#14] * Add stark-specific derivation: secure and efficient derivation for stark curve [#14] +* Use `Error` trait from `core` instead of `std` [#15] + * BREAKING: remove `std` feature as the lib is fully no_std now [#14]: https://github.com/LFDT-Lockness/hd-wallet/pull/14 +[#15]: https://github.com/LFDT-Lockness/hd-wallet/pull/15 ## v0.5.1 * Update docs and repo link [#11] From 36d887541cdf7677f54f95df3c5bf447f99b8ac6 Mon Sep 17 00:00:00 2001 From: Denis Varlakov Date: Wed, 4 Dec 2024 13:31:29 +0100 Subject: [PATCH 3/3] Update readme Signed-off-by: Denis Varlakov --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c367fee..ae62332 100644 --- a/README.md +++ b/README.md @@ -52,10 +52,11 @@ let child_key = derive_using_generic_algo::(master_key_pair); ``` ### Features -* `std`: enables std library support (mainly, it just implements `Error` - trait for the error types) -* `curve-secp256k1`, `curve-secp256r1`, `curve-ed25519` add curve implementation into the crate - curves module +* `curve-secp256k1`, `curve-secp256r1`, `curve-ed25519`, `curve-stark` add curve implementation + into the crate curves module +* `all-curves` adds all curves listed above +* `slip10`, `edwards`, `stark` add `slip10`, `edwards`, and `stark` HD derivations respectively +* `serde` adds `serde::{Serialize, Deserialize}` traits implementation to the types in the library ## Join us in Discord! Feel free to reach out to us [in Discord](https://discordapp.com/channels/905194001349627914/1285268686147424388)!