Function ssb_verify_signatures::verify_message_value[][src]

pub fn verify_message_value<T: AsRef<[u8]>>(msg: T) -> Result<(), Error>

Verify the signature of a ssb message.value.

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

Returns Ok(()) if the signature did sign this message, otherwise Err(InvalidSignature)

Example

use ssb_verify_signatures::verify_message_value;
let valid_message_value = r##"{
  "previous": "%IIjwbJbV3WBE/SBLnXEv5XM3Pr+PnMkrAJ8F+7TsUVQ=.sha256",
  "author": "@U5GvOKP/YUza9k53DSXxT0mk3PIrnyAmessvNfZl5E0=.ed25519",
  "sequence": 8,
  "timestamp": 1470187438539,
  "hash": "sha256",
  "content": {
    "type": "contact",
    "contact": "@ye+QM09iPcDJD6YvQYjoQc7sLF/IFhmNbEqgdzQo3lQ=.ed25519",
    "following": true,
    "blocking": false
  },
  "signature": "PkZ34BRVSmGG51vMXo4GvaoS/2NBc0lzdFoVv4wkI8E8zXv4QYyE5o2mPACKOcrhrLJpymLzqpoE70q78INuBg==.sig.ed25519"
}"##;
 let result = verify_message_value(valid_message_value.as_bytes());
 assert!(result.is_ok());