keyforkd: swap minicbor for serde + bincode

This commit is contained in:
Ryan Heywood 2023-08-25 02:47:54 -05:00
parent 067de52e4b
commit a9209ee36a
Signed by: ryan
GPG Key ID: 8E401478A3FBEF72
5 changed files with 39 additions and 46 deletions

69
Cargo.lock generated
View File

@ -41,6 +41,15 @@ dependencies = [
"rustc-demangle",
]
[[package]]
name = "bincode"
version = "1.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"
dependencies = [
"serde",
]
[[package]]
name = "bip39"
version = "2.0.0"
@ -276,10 +285,11 @@ dependencies = [
name = "keyforkd"
version = "0.1.0"
dependencies = [
"bincode",
"dirs",
"keyfork-frame",
"keyfork-mnemonic-util",
"minicbor",
"serde",
"thiserror",
"tokio",
"tower",
@ -327,26 +337,6 @@ version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
[[package]]
name = "minicbor"
version = "0.19.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7005aaf257a59ff4de471a9d5538ec868a21586534fff7f85dd97d4043a6139"
dependencies = [
"minicbor-derive",
]
[[package]]
name = "minicbor-derive"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1154809406efdb7982841adb6311b3d095b46f78342dd646736122fe6b19e267"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "miniz_oxide"
version = "0.7.1"
@ -431,7 +421,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.29",
"syn",
]
[[package]]
@ -542,9 +532,23 @@ checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
[[package]]
name = "serde"
version = "1.0.183"
version = "1.0.186"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c"
checksum = "9f5db24220c009de9bd45e69fb2938f4b6d2df856aa9304ce377b3180f83b7c1"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.186"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ad697f7e0b65af4983a4ce8f56ed5b357e8d3c36651bf6a7e13639c17b8e670"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_json"
@ -608,17 +612,6 @@ dependencies = [
"windows-sys 0.48.0",
]
[[package]]
name = "syn"
version = "1.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "syn"
version = "2.0.29"
@ -647,7 +640,7 @@ checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.29",
"syn",
]
[[package]]
@ -702,7 +695,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.29",
"syn",
]
[[package]]
@ -754,7 +747,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.29",
"syn",
]
[[package]]

View File

@ -11,10 +11,11 @@ tracing = ["tower/tracing", "tokio/tracing", "dep:tracing", "dep:tracing-subscri
multithread = ["tokio/rt-multi-thread"]
[dependencies]
bincode = "1.3.3"
dirs = "5.0.1"
keyfork-frame = { version = "0.1.0", path = "../keyfork-frame" }
keyfork-mnemonic-util = { version = "0.1.0", path = "../keyfork-mnemonic-util" }
minicbor = { version = "0.19.1", features = ["derive", "std"] }
serde = { version = "1.0.186", features = ["derive"] }
thiserror = "1.0.47"
tokio = { version = "1.32.0", features = ["io-util", "macros", "rt", "io-std", "net", "fs", "signal"] }
tower = { version = "0.4.13", features = ["tokio", "util"] }

View File

@ -13,11 +13,11 @@ use tracing_subscriber::{
};
mod error;
mod service;
mod server;
mod service;
use error::KeycloakdError;
use service::Keyforkd;
use server::UnixServer;
use service::Keyforkd;
type Result<T, E = Box<dyn std::error::Error>> = std::result::Result<T, E>;

View File

@ -11,7 +11,7 @@ async fn read_path_from_socket(
socket: &mut UnixStream,
) -> Result<DerivablePath, Box<dyn std::error::Error + Send>> {
let data = try_decode_from(socket).await.unwrap();
let path: DerivablePath = minicbor::decode(&data[..]).unwrap();
let path: DerivablePath = bincode::deserialize(&data[..]).unwrap();
Ok(path)
}

View File

@ -1,14 +1,13 @@
use std::{future::Future, pin::Pin, task::Poll, sync::Arc};
use keyfork_mnemonic_util::Mnemonic;
use minicbor::{Decode, Encode};
use tower::Service;
use thiserror::Error;
use serde::{Serialize, Deserialize};
#[derive(Encode, Decode, Clone, Debug)]
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct DerivablePath {
#[n(0)]
path: Vec<Vec<u8>>,
pub(crate) path: Vec<Vec<u8>>,
}
// TODO: move DerivablePath into a models crate for clients to produce?