zksync_consensus_crypto

Trait ByteFmt

source
pub trait ByteFmt: Sized {
    // Required methods
    fn decode(bytes: &[u8]) -> Result<Self>;
    fn encode(&self) -> Vec<u8>;
}
Expand description

Trait converting a type from/to a sparse byte format. It is roughly equivalent to serde::Serialize + serde::Deserialize, but has additional requirements:

  • binary encoding should be well defined, rather than rely on the internals of the serde::Serializer implementation.
  • encoding should support backward-compatibility. It will be used in building network messages, which might get signed. Note that for signing it is nice to have encoding uniqueness (i.e. decode(b).encode()==b). However it not strictly necessary, because reencoding might be avoided.

Required Methods§

source

fn decode(bytes: &[u8]) -> Result<Self>

Decodes the object from the byte representation.

source

fn encode(&self) -> Vec<u8>

Encodes the object to the byte representation.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl ByteFmt for AggregateSignature

source§

impl ByteFmt for ProofOfPossession

source§

impl ByteFmt for zksync_consensus_crypto::bls12_381::PublicKey

source§

impl ByteFmt for zksync_consensus_crypto::bls12_381::SecretKey

source§

impl ByteFmt for zksync_consensus_crypto::bls12_381::Signature

source§

impl ByteFmt for zksync_consensus_crypto::ed25519::PublicKey

source§

impl ByteFmt for zksync_consensus_crypto::ed25519::SecretKey

source§

impl ByteFmt for zksync_consensus_crypto::ed25519::Signature

source§

impl ByteFmt for Keccak256

source§

impl ByteFmt for zksync_consensus_crypto::secp256k1::PublicKey

source§

impl ByteFmt for zksync_consensus_crypto::secp256k1::SecretKey

source§

impl ByteFmt for zksync_consensus_crypto::secp256k1::Signature