chore: rename to kytz

This commit is contained in:
nazeh
2023-12-10 13:20:42 +03:00
parent 70061dffe6
commit 0ec3c5acbe
16 changed files with 142 additions and 24 deletions

87
Cargo.lock generated
View File

@@ -90,6 +90,18 @@ dependencies = [
"rand",
]
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
[[package]]
name = "blake2"
version = "0.10.6"
@@ -224,6 +236,27 @@ dependencies = [
"subtle",
]
[[package]]
name = "dirs-next"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1"
dependencies = [
"cfg-if",
"dirs-sys-next",
]
[[package]]
name = "dirs-sys-next"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d"
dependencies = [
"libc",
"redox_users",
"winapi",
]
[[package]]
name = "generic-array"
version = "0.14.7"
@@ -259,6 +292,7 @@ dependencies = [
"bessie",
"bytes",
"clap",
"dirs-next",
"rand",
"thiserror",
"z32",
@@ -270,6 +304,17 @@ version = "0.2.150"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
[[package]]
name = "libredox"
version = "0.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8"
dependencies = [
"bitflags 2.4.1",
"libc",
"redox_syscall",
]
[[package]]
name = "password-hash"
version = "0.5.0"
@@ -335,6 +380,26 @@ dependencies = [
"getrandom",
]
[[package]]
name = "redox_syscall"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
dependencies = [
"bitflags 1.3.2",
]
[[package]]
name = "redox_users"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4"
dependencies = [
"getrandom",
"libredox",
"thiserror",
]
[[package]]
name = "strsim"
version = "0.10.0"
@@ -408,6 +473,28 @@ version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-sys"
version = "0.52.0"

View File

@@ -1,6 +1,6 @@
[workspace]
members = [
"kytes",
"kytz",
]
# See: https://github.com/rust-lang/rust/issues/90148#issuecomment-949194352

View File

@@ -1,4 +1,5 @@
# Kytes
# Kytz
> Soaring in the Cloud, but you pull the strings.
Kytz (pronounced Kites) is a set of tools and standards to enable user agency and credible exit.

View File

@@ -1,9 +1,9 @@
# Seed
Kytes seed is an encrypted seed encoded as URI as follows:
Kytz seed is an encrypted seed encoded as URI as follows:
```
kytes:seed:<suffix>
kytz:seed:<suffix>
```
The `suffix` is a `z-base32` encoded bytes as follows:

View File

@@ -1,9 +0,0 @@
#![allow(unused)]
mod crypto;
mod error;
// Exports
pub use crate::error::Error;
// Alias Result to be the crate Result.
pub type Result<T, E = Error> = core::result::Result<T, E>;

View File

@@ -6,19 +6,20 @@ description = "Soaring in the Cloud, but you pull the strings."
license = "MIT"
[dependencies]
argon2 = "0.5.2"
bessie = "0.0.1"
bytes = "1.5.0"
rand = "0.8.5"
thiserror = "1.0.50"
z32 = "1.0.2"
# cli
clap = { version = "4.4.11", optional = true, features = ["derive"] }
argon2 = "0.5.2"
thiserror = "1.0.50"
bessie = "0.0.1"
dirs-next = { version = "2.0.0", optional = true }
[features]
default = ["cli"]
cli = ["clap"]
cli = ["clap", "dirs-next"]
[[bin]]
name = "kytes"

25
kytz/src/cli/config.rs Normal file
View File

@@ -0,0 +1,25 @@
//! Configuration for the Kytz CLI.
use std::path::{Path, PathBuf};
use crate::{Error, Result};
/// Name of directory that wraps all kytz files in a given application directory
const KYTZ_DIR: &str = "kytz";
/// Returns the path to the user's kytz config directory.
pub fn kytz_config_root() -> Result<PathBuf> {
// if let Some(val) = env::var_os("IROH_CONFIG_DIR") {
// return Ok(PathBuf::from(val));
// }
let cfg = dirs_next::config_dir().ok_or_else(|| {
Error::Generic("operating environment provides no directory for configuration".to_string())
})?;
Ok(cfg.join(KYTZ_DIR))
}
/// Path that leads to a file in the iroh config directory.
pub fn kytz_config_path(file_name: impl AsRef<Path>) -> Result<PathBuf> {
let path = kytz_config_root()?.join(file_name);
Ok(path)
}

1
kytz/src/cli/mod.rs Normal file
View File

@@ -0,0 +1 @@
pub mod config;

View File

@@ -1,4 +1,4 @@
//! Manage Kytes seed files.
//! Manage Kytz seed files.
//!
//! Seed file contains a seed encrypted with a strong passphrase.
@@ -15,7 +15,7 @@ use crate::{
Error, Result,
};
const SEED_SCHEME: &[u8] = b"kytes:seed:";
const SEED_SCHEME: &[u8] = b"kytz:seed:";
const VERSION: u8 = 0;
const KNOWN_VERSIONS: [u8; 1] = [0];
@@ -41,7 +41,7 @@ pub fn encrypt_seed(seed: &Key, passphrase: &str) -> Bytes {
pub fn decrypt_seed(seed_file: Bytes, passphrase: &str) -> Result<Vec<u8>> {
if !seed_file.starts_with(SEED_SCHEME) {
return Err(Error::Generic("Not a Kytes seed".to_string()));
return Err(Error::Generic("Not a Kytz seed".to_string()));
}
let suffix = z32::decode(&seed_file[SEED_SCHEME.len()..])
@@ -51,9 +51,7 @@ pub fn decrypt_seed(seed_file: Bytes, passphrase: &str) -> Result<Vec<u8>> {
match version {
0 => decrypted_seed_v0(&suffix, passphrase),
_ => Err(Error::Generic(
"Unknown kytes seed file version".to_string(),
)),
_ => Err(Error::Generic("Unknown Kytz seed file version".to_string())),
}
}

View File

@@ -1,7 +1,10 @@
//! Main Crate Error
// Alias Result to be the crate Result.
pub type Result<T, E = Error> = core::result::Result<T, E>;
#[derive(thiserror::Error, Debug)]
/// Kytes crate error enum.
/// Kytz crate error enum.
pub enum Error {
/// For starter, to remove as code matures.
#[error("Generic error: {0}")]

5
kytz/src/lib.rs Normal file
View File

@@ -0,0 +1,5 @@
#![allow(unused)]
mod crypto;
mod error;
pub use crate::error::{Error, Result};

View File

@@ -1,5 +1,10 @@
use clap::{Parser, Subcommand};
mod cli;
mod error;
pub use crate::error::{Error, Result};
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
struct Cli {
@@ -29,6 +34,7 @@ enum Commands {
}
fn main() {
dbg!(cli::config::kytz_config_path("seed.kytz").unwrap());
let cli = Cli::parse();
// You can check the value provided by positional arguments, or option arguments