kaichao 10940321ff
Encode ratchet sate for serialization (#20)
* feat: costom encode for double ratchet

* chore: correct capacity

* chore: refactor reference

* chore: reader for parse bytes

* chore: extract reader

* chore: example with persist state.

* chore: update example

* chore: implement serde compatibility.

* chore: as_bytes

* chore: zerorize the secrec material

* chore: use as_types to return reference for static key.

* chore: extract example from basic demo
2026-01-29 09:19:52 +08:00

30 lines
642 B
Rust

use thiserror::Error;
/// Errors produced by the Double Ratchet protocol
#[derive(Debug, Error, Clone, PartialEq, Eq)]
pub enum RatchetError {
#[error("ciphertext too short")]
CiphertextTooShort,
#[error("invalid nonce")]
InvalidNonce,
#[error("decryption failed")]
DecryptionFailed,
#[error("message replay detected")]
MessageReplay,
#[error("too many skipped messages")]
TooManySkippedMessages,
#[error("missing remote DH key")]
MissingRemoteDhKey,
#[error("missing receiving chain")]
MissingReceivingChain,
#[error("deserialization failed")]
DeserializationFailed,
}