Skip to content

Commit

Permalink
chore: rename to kytz
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuhvi committed Dec 10, 2023
1 parent 70061df commit 0ec3c5a
Show file tree
Hide file tree
Showing 16 changed files with 142 additions and 24 deletions.
87 changes: 87 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
members = [
"kytes",
"kytz",
]

# See: https://github.com/rust-lang/rust/issues/90148#issuecomment-949194352
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 2 additions & 2 deletions design/seed.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
9 changes: 0 additions & 9 deletions kytes/src/lib.rs

This file was deleted.

9 changes: 5 additions & 4 deletions kytes/Cargo.toml → kytz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
25 changes: 25 additions & 0 deletions kytz/src/cli/config.rs
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions kytz/src/cli/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod config;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 4 additions & 6 deletions kytes/src/crypto/seed.rs → kytz/src/crypto/seed.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Manage Kytes seed files.
//! Manage Kytz seed files.
//!
//! Seed file contains a seed encrypted with a strong passphrase.
Expand All @@ -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];
Expand All @@ -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()..])
Expand All @@ -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())),
}
}

Expand Down
5 changes: 4 additions & 1 deletion kytes/src/error.rs → kytz/src/error.rs
Original file line number Diff line number Diff line change
@@ -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}")]
Expand Down
5 changes: 5 additions & 0 deletions kytz/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#![allow(unused)]
mod crypto;
mod error;

pub use crate::error::{Error, Result};
6 changes: 6 additions & 0 deletions kytes/src/main.rs → kytz/src/main.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0ec3c5a

Please sign in to comment.