validate_message_value

Function validate_message_value 

Source
pub fn validate_message_value<T: AsRef<[u8]>>(message_bytes: T) -> Result<()>
Expand description

Validate a single message value (in isolation).

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

This does not check:

  • The signature. See ssb-verify-signatures which lets you to batch verification of signatures.
  • Anything to do with the previous message.