pub trait CanonicalSerialize: Copy + Serialize + DeserializeOwned {
    type Serializer: SequenceSerializer<Self>;
    type Deserializer: SequenceDeserializer<Self>;
    type ByteReprLen: ArrayLength<u8>;
    type FromBytesError: Error + Send + Sync + 'static;

    fn from_bytes(
        bytes: &GenericArray<u8, Self::ByteReprLen>
    ) -> Result<Self, Self::FromBytesError>; fn to_bytes(&self) -> GenericArray<u8, Self::ByteReprLen>; }
Expand description

Types that implement this trait have a canonical serialization and a fixed serialization size.

Required Associated Types

A way to serialize field elements of this type.

See SequenceSerializer for more info.

A way to deserialize field elements of this type.

See SequenceSerializer for more info.

The number of bytes in the byte representation for this element.

The error that can result from trying to decode an invalid byte sequence.

Required Methods

Deserialize an element from a byte array.

NOTE: for security purposes, this function will accept exactly one byte sequence for each element.

Serialize an element into a byte array.

Consider using Self::Serializer if you need to serialize several field elements.

Implementors