libchat/double-ratchets
kaichao 74695877fa
Split storage crate to abstract database layer (#30)
* feat: shared storage crate

* chore: remove backup codes

* chore: remove feature gates

* chore: clean out of order demo

* chore: refactor create session

* chore: shorten error name

* chore: clean errors

* chore: remove table exist check

* chore: remove unused traits

* chore: remove unused functions.

* chore: use tempfile for examples
2026-02-03 09:39:02 +08:00
..

Double Ratchet

This library provides an implementation of the Double Ratchet algorithm.

Usage

let shared_secret = [42u8; 32];
let bob_dh = DhKeyPair::generate();

let mut alice = RatchetState::init_sender(shared_secret, bob_dh.public);
let mut bob = RatchetState::init_receiver(shared_secret, bob_dh);

let (ciphertext, header) = alice.encrypt_message(b"Hello Bob!");
let plaintext = bob.decrypt_message(&ciphertext, header);

Run examples,

cargo run --example double_ratchet_basic

cargo run --example storage_demo --features storage
cargo run --example storage_demo --features sqlcipher

Run Nim FFI example,

# In the root folder (libchat)
cargo build --release
# In ffi-nim-example folder
nimble run