validate_ooo_message_hash_chain

Function validate_ooo_message_hash_chain 

Source
pub fn validate_ooo_message_hash_chain<T: AsRef<[u8]>, U: AsRef<[u8]>>(
    message_bytes: T,
    previous_msg_bytes: Option<U>,
) -> Result<()>
Expand description

Validate an out-of-order message.

It expects the messages to be the JSON encoded message of shape: {key: "", value: {...}}

This checks that:

  • the author has not changed
  • the actual hash matches the hash claimed in key
  • the message contains the correct fields

This does not check:

  • the signature. See ssb-verify-signatures which lets you to batch verification of signatures.
  • the sequence increments by 1 compared to previous
  • the actual hash of the previous message matches the hash claimed in previous

previous_msg_bytes will be None only when message_bytes is the first message by that author.