i0 0.1.6

thei.rs/i0 reference implementation written in rust
Documentation
//! implementation of [i0:3](https://thei.rs/i0:3)

pub mod blake3_512;
pub mod ed25519_blake3;
mod metadata;
pub use metadata::Metadata;

#[cfg(feature = "dig")]
mod dig;
#[cfg(feature = "dig")]
pub use dig::dig;

/// Builds the short and long versions of an [i0:3](https://thei.rs/i0:3) from `Metadata`
pub fn generate(metadata: &Metadata) -> (String, String) {
    let unhashed_det: &[u8] = &[
        metadata.designation.as_bytes(),
        b"-",
        &metadata.timestamp.to_bytes(),
    ]
    .concat();

    let sig = ed25519_blake3::sign(unhashed_det, "i0:3", metadata.seed);
    let short = to_hex(&sig[..4])[..7].to_string();
    let long = z32::encode(&sig[..10]);

    (short, long)
}

fn to_hex(sig: &[u8]) -> String {
    sig.iter().map(|byte| format!("{byte:02x}")).collect()
}