enigma-identity 0.1.0

Enigma Identity: local identity + X3DH bundle + shared secret derivation
Documentation
use crate::{x3dh_initiate, x3dh_respond, LocalIdentity};

#[test]
fn x3dh_shared_secret_matches_between_initiator_and_responder() {
    let bob = LocalIdentity::new("bob").unwrap();
    let bob_bundle = bob.bundle();

    let (initiation, alice_secret) = x3dh_initiate(&bob_bundle).unwrap();
    let bob_secret = x3dh_respond(&bob.responder_keys(), &initiation).unwrap();

    assert_eq!(alice_secret.as_bytes(), bob_secret.as_bytes());
}

#[test]
fn x3dh_initiate_rejects_invalid_bundle() {
    let bob = LocalIdentity::new("bob").unwrap();
    let mut bundle = bob.bundle();
    bundle.signed_prekey_signature[0] ^= 0xFF;
    assert!(x3dh_initiate(&bundle).is_err());
}