Skip to main content

canonicalize

Function canonicalize 

Source
pub fn canonicalize(bytes: &[u8]) -> Result<Vec<u8>, CanonicalError>
Expand description

Re-encode arbitrary CBOR bytes into their canonical form. Used on the receive path: decode what arrived, then verify a signature against the canonical re-encoding.

The result is a fixed point: canonicalizing it again returns the same bytes. Input holding a negative bignum (tag 3) below -2^127 is refused with CanonicalError::Deserialize, because its canonical form is one the decoder cannot read back; the decoder already refuses that value written as a definite-length bignum, and this refuses it however else it was framed.