relay-crypto 0.2.0-alpha.0

The crypto library for the Relay Ecosystem.
Documentation
1
2
3
4
5
6
7
8
9
10
use ciborium::into_writer;
use serde::Serialize;

use relay_core::envelope::EnvelopeError;

pub fn canonical_cbor<T: Serialize>(value: &T) -> Result<Vec<u8>, EnvelopeError> {
    let mut buf = Vec::new();
    into_writer(value, &mut buf).map_err(|e| EnvelopeError::EncodingError(e.to_string()))?;
    Ok(buf)
}