anubis-wormhole 1.0.0

A post-quantum secure file transfer tool based on the Magic Wormhole protocol.
Documentation
#![cfg(feature = "spake2")]
use spake2::{Ed25519Group, Identity, Password, SPAKE2};

pub struct Spake2Result {
    pub key: Vec<u8>,
    pub transcript_piece: Vec<u8>,
}

pub enum SpakeRole { A, B }

pub fn run_spake2(code: &str, role: SpakeRole) -> Spake2Result {
    let password = Password::from(code.as_bytes());
    match role {
        SpakeRole::A => {
            let (msg_a, state_a) = SPAKE2::<Ed25519Group>::start_a(&password, &Identity::new(&[]), &Identity::new(&[]));
            // In a real flow, msg_a goes to B and msg_b comes back. Here we just return transcript piece.
            let mut t = Vec::new();
            t.extend_from_slice(msg_a.as_bytes());
            // Placeholder: caller must complete with msg_b to get key. This module provides types only.
            Spake2Result { key: Vec::new(), transcript_piece: t }
        }
        SpakeRole::B => {
            let (msg_b, state_b) = SPAKE2::<Ed25519Group>::start_b(&password, &Identity::new(&[]), &Identity::new(&[]));
            let mut t = Vec::new();
            t.extend_from_slice(msg_b.as_bytes());
            Spake2Result { key: Vec::new(), transcript_piece: t }
        }
    }
}