pub struct DecryptionRatchet;Expand description
Message ratchet for decryption with support for handling lost or out-of-order messages.
§Out-of-order handling
Out-of-order messages cause the ratchet to “jump” ahead and keep “unused” keys persisted until they’re used eventually.
In this example our chain has a length of 2 at the moment a message for generation 4 arrives out of order (we’ve expected generation 2). Now we pre-generate the keys for the “jumped” messages (generation 2 and 3) and keep them persisted for later. We decrypt the new message for generation 4 with the regular, now “latest”, chain state.
0
1 <- Current chain "head"
2
3
4 <- New chain "head" after receiving message @ generation 4§Tolerance limits
Developers can and should set bounds to how much a decryption ratchet can tolerate messages arriving out of order, that is, into the “future” and into the “past”. Setting these “window” limits has implications for the forward secrecy of an application as unused keys stay around for a while. A setting should be picked wisely based on the network’s reliability to deliver and order messages and security requirements.
Implementations§
Source§impl DecryptionRatchet
impl DecryptionRatchet
pub fn init(secret: Secret<MESSAGE_KEY_SIZE>) -> DecryptionRatchetState
Sourcepub fn secret_for_decryption(
y: DecryptionRatchetState,
generation: Generation,
maximum_forward_distance: u32,
ooo_tolerance: u32,
) -> Result<(DecryptionRatchetState, RatchetKeyMaterial), RatchetError>
pub fn secret_for_decryption( y: DecryptionRatchetState, generation: Generation, maximum_forward_distance: u32, ooo_tolerance: u32, ) -> Result<(DecryptionRatchetState, RatchetKeyMaterial), RatchetError>
Returns a secret from the ratchet for decryption. Throws an error if requested secret is out of bounds.
§Limits Configuration
- Out-of-order (ooo) tolerance: This parameter defines a window for which decryption secrets are kept. This is useful in case the ratchet cannot guarantee that all application messages have total order within an epoch. Use this carefully, since keeping decryption secrets affects forward secrecy within an epoch.
- Maximum forward distance: This parameter defines how many incoming messages can be skipped. This is useful if the application drops messages.