i0 0.2.2

thei.rs/i0 reference implementation written in rust
Documentation
//! Tiny implementation of ed25519 with SHA-512 swapped for BLAKE3
//! This is needed to generate an [i0:3](https://thei.rs/i0:3) and should NOT be used standalone

use crate::v3::blake3_512::Blake3_512;
use curve25519_dalek::Scalar;
use curve25519_dalek::edwards::{CompressedEdwardsY, EdwardsPoint};

/// Gets the R-component of an ed25519 signature with SHA-512 swapped for BLAKE3
pub fn sign(msg: &[u8], ctx: &str, seed: &[u8; 32]) -> [u8; 32] {
    let hash_prefix = &Blake3_512::expand_sk(seed, ctx)[32..];

    let mut h = Blake3_512::new();
    h.update(hash_prefix);
    h.update(msg);
    let r = Scalar::from_hash(h);
    let r_up: CompressedEdwardsY = EdwardsPoint::mul_base(&r).compress();

    r_up.to_bytes()
}