validate_ooo_message_value_hash_chain

Function validate_ooo_message_value_hash_chain 

Source
pub fn validate_ooo_message_value_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 value.

It expects the messages to be the JSON encoded message value of shape: { previous: "", author: "", sequence: ..., timestamp: ..., content: {}, signature: "" }

This checks that:

  • The fields (keys) of the message value are in the correct order
  • The hash signature is sha256
  • The message content is canonical base64 (if content is a string)
  • The message value does not exceed 8192 UTF-16 code units when serialized as a JSON string
  • The author of the message value matches the author of the previous message value

This does not check:

  • The signature. See ssb-verify-signatures which lets you to batch verification of signatures
  • The sequence of the message in relation to the previous message
  • That the hash value for previous matches the actual hashed value of the previous message