Module zebra_chain::serialization

source ยท
Expand description

Consensus-critical serialization.

This module contains four traits: ZcashSerialize and ZcashDeserialize, analogs of the Serde Serialize and Deserialize traits but intended for consensus-critical Zcash serialization formats, and WriteZcashExt and ReadZcashExt, extension traits for io::Read and io::Write with utility functions for reading and writing data (e.g., the Bitcoin variable-integer format).

Modulesยง

  • Arbitrary data generation for serialization proptests
  • compact_size ๐Ÿ”’
    Types and serialization for the Bitcoin CompactSize format.
  • constraint ๐Ÿ”’
    Serialization constraint helpers.
  • date_time ๐Ÿ”’
    DateTime types with specific serialization invariants.
  • error ๐Ÿ”’
    Errors for Zcash consensus-critical serialization.
  • read_zcash ๐Ÿ”’
  • serde_helpers ๐Ÿ”’
  • SHA256d, a.k.a., double SHA2, a.k.a., 2 SHA 2 Furious
  • write_zcash ๐Ÿ”’
  • zcash_deserialize ๐Ÿ”’
    Converting bytes into Zcash consensus-critical data structures.
  • zcash_serialize ๐Ÿ”’
    Converting Zcash consensus-critical data structures into bytes.

Structsยง

  • A Vec<T> wrapper that ensures there is at least one T in the vector.
  • An arbitrary CompactSize-encoded field. Used for flags, arbitrary counts, and sizes that span multiple blocks.
  • A CompactSize-encoded field that is limited to MAX_PROTOCOL_MESSAGE_LEN. Used for sizes or counts of objects that are sent in network messages.
  • A date and time, represented by a 32-bit number of seconds since the UNIX epoch.
  • An unsigned time duration, represented by a 32-bit number of seconds.
  • A fake writer helper used to get object lengths without allocating RAM.

Enumsยง

Constantsยง

Traitsยง

  • Extends Read with methods for writing Zcash/Bitcoin types.
  • Blind preallocation of a Vec<T: TrustedPreallocate> is based on a bounded length. This is in contrast to blind preallocation of a generic Vec<T>, which is a DOS vector.
  • Extends Write with methods for writing Zcash/Bitcoin types.
  • Consensus-critical deserialization for Zcash.
  • Helper for deserializing more succinctly via type inference
  • Consensus-critical serialization for Zcash.

Functionsยง