message: Add some helpers to checksum
diff: +use std::convert::TryFrom;
  +
  use sha2::{Digest, Sha256};
  +use crate::errors::{make_cache_err, VmError};
  +
  /// A SHA-256 checksum of a Wasm blob, used to identify a Wasm code.
  /// This must remain stable since this checksum is stored in the blockchain state.
  ///
  @@ -9,10 +13,6 @@ use sha2::{Digest, Sha256};
  pub struct Checksum([u8; 32]);
  impl Checksum {
  - pub fn from(data: [u8; 32]) -> Self {
  - Checksum(data)
  - }
  -
  pub fn generate(wasm: &[u8]) -> Self {
  Checksum(Sha256::digest(wasm).into())
  }
  @@ -20,6 +20,29 @@ impl Checksum {
  pub fn to_hex(&self) -> String {
  hex::encode(self.0)
  }
  +
  + pub fn to_vec(&self) -> Vec<u8> {
  + self.0.to_vec()
  + }
  +}
  +
  +impl From<[u8; 32]> for Checksum {
  + fn from(data: [u8; 32]) -> Self {
  + Checksum(data)
  + }
  +}
  +
  +impl TryFrom<&[u8]> for Checksum {
  + type Error = VmError;
  +
  + fn try_from(value: &[u8]) -> Result<Self, Self::Error> {
  + if value.len() != 32 {
  + return Err(make_cache_err("Checksum not of length 32"));
  + }
  + let mut data = [0u8; 32];
  + data.copy_from_slice(value);
  + Ok(Checksum(data))
  + }
  }
  #[cfg(test)]
  