Documentation

CompPoly.Data.Bytes.Codec

Fixed-width byte codecs #

ByteCodec F is a fixed-width byte encoding of F with a decoder that succeeds on every encoding. Its single law, ofBytes?_toBytes, makes toBytes injective, and from it the protocol-facing classes follow for free: HasSize F UInt8, Serialize F ByteArray with Serialize.IsInjective, DeserializeOption, and Serde, together with the same for Vector UInt8 (width F).

The encoding is a property of the value, not of the carrier: two carriers of the same field must give the same bytes for the same element. Scalar fields derive their codec from CanonicalNat (ByteCodec.ofCanonicalNat, in CompPoly.Data.Bytes.CanonicalNat); composite types such as extensions and degree-bounded polynomials concatenate the codecs of their parts.

class CompPoly.ByteCodec (F : Type u) :

A fixed-width byte encoding of F whose decoder recovers every encoded element.

Instances
    @[simp]
    theorem CompPoly.ByteCodec.toBytes_inj {F : Type u} [ByteCodec F] {x y : F} :

    The encoding as a ByteArray of size width F.

    Instances For

      Decode a ByteArray, failing unless it has size width F and encodes an element.

      Instances For

        Derived protocol interfaces #

        @[instance_reducible]
        @[instance_reducible]
        @[instance_reducible]