Crates.io | x3dh-ke |
lib.rs | x3dh-ke |
version | 0.1.5 |
source | src |
created_at | 2021-05-24 16:20:06.051274 |
updated_at | 2021-10-24 17:39:40.237742 |
description | Implementation of X3DH |
homepage | https://github.com/Decentrailzed-Communication-System/x3dh-ke |
repository | https://github.com/Decentrailzed-Communication-System/x3dh-ke |
max_upload_size | |
id | 401466 |
size | 43,683 |
Implementation of extended triple diffie hellman written in Rust, as described by Signal. WARNING! This crate hasn't been reviewed and may include serious faults. Use with care.
use x3dh_ke::{IdentityKey, SignedPreKey, EphemeralKey, OneTimePreKey, Key, x3dh_a, x3dh_b};
let ika = IdentityKey::default();
let ikas = ika.strip();
let ikb = IdentityKey::default();
let ikbs = ikb.strip();
let spkb = SignedPreKey::default();
let spkbs = spkb.strip();
let eka = EphemeralKey::default();
let ekas = eka.strip();
let opkb = OneTimePreKey::default();
let opkbs = opkb.strip();
let signature = ikb.sign(&spkbs.pk_to_bytes());
let cka = x3dh_a(&signature, &ika, &spkbs, &eka, &ikbs, &opkbs).unwrap();
let ckb = x3dh_b(&ikas, &spkb, &ekas, &ikb, &opkb);
assert_eq!(cka, ckb)
Every key described by this library can be turned into bytes and created from them too.
use x3dh_ke::{IdentityKey, Key};
let ika = IdentityKey::default();
let data = ika.to_bytes();
let ikr = IdentityKey::from_bytes(&data).unwrap();
assert_eq!(ika.to_bytes(), ikr.to_bytes())
To share a key, the private part has to be striped previously from that.
use x3dh_ke::{IdentityKey, Key};
let ika = IdentityKey::default();
let _iks = ika.strip(); // Without private key
This crate supports WASM. In order to do that, enable the wasm
feature.
Current version: 0.1.3
License: MIT