ssb-crypto 0.2.3

Crypto primitives used by Secure Scuttlebutt
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use crate::{NetworkAuth, NetworkKey};
use sodiumoxide::crypto::auth;

pub fn authenticate(k: &NetworkKey, m: &[u8]) -> NetworkAuth {
    let a = auth::authenticate(m, &auth::Key(k.0));
    NetworkAuth(a.0)
}

pub fn verify(k: &NetworkKey, a: &NetworkAuth, m: &[u8]) -> bool {
    auth::verify(&auth::Tag(a.0), m, &auth::Key(k.0))
}

pub fn generate_key() -> NetworkKey {
    let k = auth::gen_key();
    NetworkKey(k.0)
}