Skip to content

Commit

Permalink
Typesafer slip10 (#201)
Browse files Browse the repository at this point in the history
* typesafer slip10

* changes

* nits

* slip10 error

* typo

* slip10 nits

* slip10 nits

* doc comments

* more doc comments

* slip10 sealed hazmat traits, export hazmat traits
  • Loading branch information
semenov-vladyslav authored Jun 14, 2023
1 parent cc7dbce commit baf4b83
Show file tree
Hide file tree
Showing 6 changed files with 296 additions and 217 deletions.
5 changes: 5 additions & 0 deletions .changes/typesafer-slip10.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"iota-crypto": minor
---

More static type safety for SLIP10 implementation to avoid runtime checks.
5 changes: 5 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ pub enum Error {
PrivateKeyError,
/// InvalidArgumentError
InvalidArgumentError { alg: &'static str, expected: &'static str },
#[cfg(feature = "slip10")]
/// Slip10 Segment Hardening Error
Slip10Error(crate::keys::slip10::SegmentHardeningError),
/// System Error
SystemError {
call: &'static str,
Expand All @@ -53,6 +56,8 @@ impl Display for Error {
Error::ConvertError { from, to } => write!(f, "failed to convert {} to {}", from, to),
Error::PrivateKeyError => write!(f, "Failed to generate private key."),
Error::InvalidArgumentError { alg, expected } => write!(f, "{} expects {}", alg, expected),
#[cfg(feature = "slip10")]
Error::Slip10Error(inner) => write!(f, "slip10 error: {inner:?}"),
Error::SystemError {
call,
raw_os_error: None,
Expand Down
Loading

0 comments on commit baf4b83

Please sign in to comment.