kaichao 8e2b5211b4
Managed data storage for Ratchet state (#21)
* feat: managed persist storage with sqlite

* chore: sync skipped keys

* chore: refactor

* chore: refactor

* chore: clean code

* chore: export skipped keys from state.

* chore: renaming data to record

* chore: remove types from stroage mod file
2026-01-28 14:54:16 +08:00

35 lines
749 B
Markdown

# Double Ratchet
This library provides an implementation of the Double Ratchet algorithm.
## Usage
```rust
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,
```bash
cargo run --example double_ratchet_basic
cargo run --example storage_demo --features storage
cargo run --example storage_demo --features sqlcipher
```
Run Nim FFI example,
```bash
# In the root folder (libchat)
cargo build --release
# In ffi-nim-example folder
nimble run
```