keyfork-derive-util: minor refactor, tidy up publicness of modules

This commit is contained in:
Ryan Heywood 2024-02-11 01:04:13 -05:00
parent 0375ce7bdf
commit 086e56bef0
Signed by: ryan
GPG Key ID: 8E401478A3FBEF72
6 changed files with 24 additions and 22 deletions

View File

@ -4,7 +4,7 @@ use std::{env, process::ExitCode, str::FromStr};
use keyfork_derive_util::{ use keyfork_derive_util::{
request::{DerivationAlgorithm, DerivationError, DerivationRequest, DerivationResponse}, request::{DerivationAlgorithm, DerivationError, DerivationRequest, DerivationResponse},
DerivationPath, DerivationPath, PathError,
}; };
use keyforkd_client::Client; use keyforkd_client::Client;
@ -17,7 +17,7 @@ pub enum Error {
/// The given path could not be parsed. /// The given path could not be parsed.
#[error("Could not parse the given path: {0}")] #[error("Could not parse the given path: {0}")]
PathFormat(#[from] keyfork_derive_util::path::Error), PathFormat(#[from] PathError),
/// The request to derive data failed. /// The request to derive data failed.
#[error("Unable to perform key derivation request: {0}")] #[error("Unable to perform key derivation request: {0}")]

View File

@ -5,6 +5,7 @@ use std::time::{Duration, SystemTime, SystemTimeError};
use derive_util::{ use derive_util::{
request::{DerivationResponse, TryFromDerivationResponseError}, request::{DerivationResponse, TryFromDerivationResponseError},
DerivationIndex, ExtendedPrivateKey, PrivateKey, DerivationIndex, ExtendedPrivateKey, PrivateKey,
IndexError,
}; };
use ed25519_dalek::SigningKey; use ed25519_dalek::SigningKey;
pub use keyfork_derive_util as derive_util; pub use keyfork_derive_util as derive_util;
@ -37,7 +38,7 @@ pub enum Error {
/// A derivation index could not be created from the given index. /// A derivation index could not be created from the given index.
#[error("Could not create derivation index: {0}")] #[error("Could not create derivation index: {0}")]
Index(#[from] keyfork_derive_util::index::Error), Index(#[from] IndexError),
/// A derivation operation could not be performed against the private key. /// A derivation operation could not be performed against the private key.
#[error("Could not perform operation against private key: {0}")] #[error("Could not perform operation against private key: {0}")]

View File

@ -28,7 +28,7 @@ impl DerivationIndex {
/// # Examples /// # Examples
/// ```rust /// ```rust
/// # use keyfork_derive_util::*; /// # use keyfork_derive_util::*;
/// let bip44 = DerivationIndex::new(44, true); /// let bip44 = DerivationIndex::new(44, true).unwrap();
/// ``` /// ```
/// ///
/// Using a derivation index that is higher than 2^31 returns an error: /// Using a derivation index that is higher than 2^31 returns an error:

View File

@ -1,27 +1,27 @@
#![allow(clippy::module_name_repetitions, clippy::must_use_candidate)] #![allow(clippy::module_name_repetitions, clippy::must_use_candidate)]
#![doc = include_str!("../README.md")] #![doc = include_str!("../README.md")]
pub mod extended_key; pub mod extended_key;
///
pub mod index;
///
pub mod path;
///
pub mod private_key;
///
pub mod public_key;
///
pub mod request; pub mod request;
mod index;
mod path;
#[doc(hidden)]
pub mod private_key;
#[doc(hidden)]
pub mod public_key;
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;
#[doc(inline)]
pub use crate::extended_key::{private_key::ExtendedPrivateKey, public_key::ExtendedPublicKey};
pub use crate::{ pub use crate::{
extended_key::{private_key::ExtendedPrivateKey, public_key::ExtendedPublicKey}, index::{DerivationIndex, Error as IndexError},
index::DerivationIndex, path::{DerivationPath, Error as PathError},
path::DerivationPath, private_key::{PrivateKey, PrivateKeyError},
private_key::PrivateKey, public_key::{PublicKey, PublicKeyError},
public_key::PublicKey,
}; };

View File

@ -147,6 +147,7 @@ pub struct TestPublicKey {
impl TestPublicKey { impl TestPublicKey {
#[doc(hidden)] #[doc(hidden)]
#[allow(dead_code)]
pub fn from_bytes(b: &[u8]) -> Self { pub fn from_bytes(b: &[u8]) -> Self {
Self { Self {
key: b.try_into().unwrap(), key: b.try_into().unwrap(),

View File

@ -15,7 +15,7 @@ use aes_gcm::{
use hkdf::{Hkdf, InvalidLength as HkdfInvalidLength}; use hkdf::{Hkdf, InvalidLength as HkdfInvalidLength};
use keyfork_derive_openpgp::derive_util::{ use keyfork_derive_openpgp::derive_util::{
request::{DerivationAlgorithm, DerivationRequest}, request::{DerivationAlgorithm, DerivationRequest},
DerivationPath, DerivationPath, PathError,
}; };
use keyfork_mnemonic_util::{Mnemonic, MnemonicFromStrError, MnemonicGenerationError, Wordlist}; use keyfork_mnemonic_util::{Mnemonic, MnemonicFromStrError, MnemonicGenerationError, Wordlist};
use keyfork_prompt::{ use keyfork_prompt::{
@ -125,7 +125,7 @@ pub enum Error {
/// An error occurred while parsing a derivation path. /// An error occurred while parsing a derivation path.
#[error("Derivation path: {0}")] #[error("Derivation path: {0}")]
DerivationPath(#[from] keyfork_derive_openpgp::derive_util::path::Error), DerivationPath(#[from] PathError),
/// An error occurred while requesting derivation. /// An error occurred while requesting derivation.
#[error("Derivation request: {0}")] #[error("Derivation request: {0}")]