5 releases

0.1.5 Oct 24, 2021
0.1.4 Jul 20, 2021
0.1.3 Jun 18, 2021
0.1.1 May 24, 2021
0.1.0 May 24, 2021

#1308 in Cryptography

Download history 279/week @ 2024-07-22 109/week @ 2024-07-29 17/week @ 2024-08-05 63/week @ 2024-08-12 23/week @ 2024-08-19 32/week @ 2024-08-26 132/week @ 2024-09-02 47/week @ 2024-09-09 45/week @ 2024-09-16 207/week @ 2024-09-23 95/week @ 2024-09-30 86/week @ 2024-10-07 22/week @ 2024-10-14 51/week @ 2024-10-21 44/week @ 2024-11-04

118 downloads per month
Used in kem

MIT license

29KB
611 lines

Crate License Coverage Status Workflow Status Maintenance

x3dh-ke

Implementation of X3DH

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.

Example Usage:

Standard:

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)

Serialize and Deserialize

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())

Strip Private Key

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

WASM

This crate supports WASM. In order to do that, enable the wasm feature.

Current version: 0.1.3

License: MIT

Dependencies

~3.5MB
~66K SLoC