keyforkd: extract DerivablePath

This commit is contained in:
Ryan Heywood 2023-08-25 04:27:16 -05:00
parent a9209ee36a
commit da96ea94bd
Signed by: ryan
GPG Key ID: 8E401478A3FBEF72
7 changed files with 46 additions and 24 deletions

8
Cargo.lock generated
View File

@ -253,6 +253,13 @@ version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
[[package]]
name = "keyfork-derive-util"
version = "0.1.0"
dependencies = [
"serde",
]
[[package]]
name = "keyfork-frame"
version = "0.1.0"
@ -287,6 +294,7 @@ version = "0.1.0"
dependencies = [
"bincode",
"dirs",
"keyfork-derive-util",
"keyfork-frame",
"keyfork-mnemonic-util",
"serde",

View File

@ -3,6 +3,7 @@
members = [
"keyfork-mnemonic-generate",
"keyfork-mnemonic-util",
"keyfork-derive-util",
"keyforkd",
"keyfork-frame"
]

View File

@ -0,0 +1,9 @@
[package]
name = "keyfork-derive-util"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serde = { version = "1.0.186", features = ["derive"] }

View File

@ -0,0 +1,24 @@
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct DerivablePath {
pub(crate) path: Vec<u32>,
}
// TODO: move DerivablePath into a models crate for clients to produce?
/*
impl DerivablePath {
pub fn new(input: &[&[u8]]) -> DerivablePath {
DerivablePath {
path: input
.iter()
.map(|&word| {
// perform path validation
word.to_vec()
})
.collect(),
}
}
}
*/

View File

@ -13,6 +13,7 @@ multithread = ["tokio/rt-multi-thread"]
[dependencies]
bincode = "1.3.3"
dirs = "5.0.1"
keyfork-derive-util = { version = "0.1.0", path = "../keyfork-derive-util" }
keyfork-frame = { version = "0.1.0", path = "../keyfork-frame" }
keyfork-mnemonic-util = { version = "0.1.0", path = "../keyfork-mnemonic-util" }
serde = { version = "1.0.186", features = ["derive"] }

View File

@ -1,5 +1,6 @@
use crate::service::{DerivablePath, DerivationError, Keyforkd};
use crate::service::{DerivationError, Keyforkd};
use keyfork_frame::asyncext::{try_decode_from, try_encode_to};
use keyfork_derive_util::DerivablePath;
use std::{io::Error, path::{Path, PathBuf}};
use tokio::net::{UnixListener, UnixStream};
use tower::{Service, ServiceExt};

View File

@ -1,31 +1,9 @@
use std::{future::Future, pin::Pin, task::Poll, sync::Arc};
use keyfork_mnemonic_util::Mnemonic;
use keyfork_derive_util::DerivablePath;
use tower::Service;
use thiserror::Error;
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct DerivablePath {
pub(crate) path: Vec<Vec<u8>>,
}
// TODO: move DerivablePath into a models crate for clients to produce?
/*
impl DerivablePath {
pub fn new(input: &[&[u8]]) -> DerivablePath {
DerivablePath {
path: input
.iter()
.map(|&word| {
// perform path validation
word.to_vec()
})
.collect(),
}
}
}
*/
#[derive(Clone, Debug)]
pub struct Keyforkd {