Documentation

Cryptlib.Protocols.GroupComm.GroupChatKatzenqt1.AckCodec

The Acks field of a group chat message #

Acknowledged members are named by roster index, as a list of index bytes or a bitmap, whichever is shorter, followed by one v-byte value each in ascending index order. See "Rosters" in the group chat spec. Bytes are natural numbers here, each < 256.

The bits of byte j of the bitmap for idx, counted from the least significant: index i is bit 7 - i % 8 of byte i / 8.

Equations
Instances For

    Ascending roster indexes as a list or a bitmap, whichever is shorter.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      Whether a list naming is no longer than the bitmap for the same members.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For

        What precedes count values. strict also refuses a list where the bitmap is shorter, which the spec does not ask for.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          The field for acks, pairs of roster index and value in ascending order of index.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For

            The acknowledgements a field carries, or none when it is malformed.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For

              What a sender may encode: ascending roster indexes, each one byte, each value v bytes.

              Instances For

                Lemmas #

                theorem Cryptlib.Protocols.GroupComm.GroupChatKatzenqt1.AckCodec.filter_range_eq {l : List ℕ} {n : ℕ} (hs : List.Pairwise (fun (x1 x2 : ℕ) => x1 < x2) l) (hl : ∀ x ∈ l, x < n) (p : ℕ → Bool) (hp : ∀ x < n, p x = true ↔ x ∈ l) :

                The members of a strictly ascending list below n, read off 0..n-1 in order, are the list.

                theorem Cryptlib.Protocols.GroupComm.GroupChatKatzenqt1.AckCodec.setBits_bitmap {idx : List ℕ} {w : ℕ} (hs : List.Pairwise (fun (x1 x2 : ℕ) => x1 < x2) idx) (hl : ∀ x ∈ idx, x < w * 8) :
                setBits (bitmap idx w) = idx
                theorem Cryptlib.Protocols.GroupComm.GroupChatKatzenqt1.AckCodec.chunks_flatten {v : ℕ} {vals : List (List ℕ)} :
                (∀ a ∈ vals, a.length = v) → chunks v vals.flatten vals.length = vals

                Decoding undoes encoding #

                Decoding undoes encoding, under either parser, whenever a value is longer than the longest naming.

                Only then: a value of 32 bytes or fewer is misread #

                Without a count, decoding undoes encoding for every acknowledgement set exactly when values exceed 32 bytes.

                theorem Cryptlib.Protocols.GroupComm.GroupChatKatzenqt1.AckCodec.le_of_getLast? {l : List ℕ} (hs : List.Pairwise (fun (x1 x2 : ℕ) => x1 < x2) l) {last : ℕ} (h : l.getLast? = some last) {x : ℕ} (hx : x ∈ l) :
                x ≤ last

                A strictly ascending list's last element is at least every element.

                theorem Cryptlib.Protocols.GroupComm.GroupChatKatzenqt1.AckCodec.nameMembers_setBits {naming : List ℕ} (hbytes : ∀ b ∈ naming, b < 256) (hne : naming ≠ []) (hlast : naming.getLast? ≠ some 0) (hcount : naming.length < (setBits naming).length) :
                nameMembers (setBits naming) = naming

                Under the strict parser, a well-formed bitmap is the bitmap of the members it marks.

                theorem Cryptlib.Protocols.GroupComm.GroupChatKatzenqt1.AckCodec.encodeUncounted_decodeUncounted {v : ℕ} {field : List ℕ} {acks : List (ℕ × List ℕ)} (hbytes : ∀ b ∈ field, b < 256) (h : decodeUncounted true v field = some acks) :
                WF v acks ∧ encodeUncounted acks = field

                Under the strict parser, a field that decodes is the encoding of its well-formed result.

                The spec's parser is malleable; a strict one is not #

                The members 0, 1 and 2, named by a list where the bitmap 0xe0 is shorter, with three 33-byte values: the spec's parser accepts it, but encodeUncounted would write the bitmap.

                Counted field #

                Values shorter than the longest naming need an explicit count, so the field begins with the count less one; an empty field acknowledges no one.

                The acknowledgements a field carries, or none when it is malformed.

                Equations
                Instances For
                  theorem Cryptlib.Protocols.GroupComm.GroupChatKatzenqt1.AckCodec.readMembers_nameMembers (strict : Bool) {idx : List ℕ} (hs : List.Pairwise (fun (x1 x2 : ℕ) => x1 < x2) idx) (hlt : ∀ x ∈ idx, x < rosterMax) :
                  readMembers strict (nameMembers idx) idx.length = some idx

                  Ascending roster indexes, named by nameMembers, read back as themselves.

                  theorem Cryptlib.Protocols.GroupComm.GroupChatKatzenqt1.AckCodec.readMembers_strict_some {naming : List ℕ} {count : ℕ} {idx : List ℕ} (hbytes : ∀ b ∈ naming, b < 256) (h : readMembers true naming count = some idx) :
                  idx.length = count ∧ List.Pairwise (fun (x1 x2 : ℕ) => x1 < x2) idx ∧ (∀ i ∈ idx, i < rosterMax) ∧ nameMembers idx = naming

                  What the strict parser reads before count values: count ascending roster indexes, named exactly as nameMembers names them.

                  A sender acknowledges at most rosterMax members, so the count less one fits in a byte.

                  theorem Cryptlib.Protocols.GroupComm.GroupChatKatzenqt1.AckCodec.decode_encode (strict : Bool) (v : ℕ) {acks : List (ℕ × List ℕ)} (h : WF v acks) :
                  decode strict v (encode acks) = some acks

                  Decoding undoes encoding, under either parser, for values of every size.

                  theorem Cryptlib.Protocols.GroupComm.GroupChatKatzenqt1.AckCodec.encode_decode {v : ℕ} {field : List ℕ} {acks : List (ℕ × List ℕ)} (hbytes : ∀ b ∈ field, b < 256) (h : decode true v field = some acks) :
                  WF v acks ∧ encode acks = field

                  Under the strict parser, a field that decodes is the encoding of its well-formed result.

                  The members 0, 1 and 2, named by a list where the bitmap 0xe0 is shorter, with three 8-byte values: the spec's parser accepts it, but encode would write the bitmap.

                  Values: Idx64, little-endian #

                  The number little-endian bytes spell.

                  Equations
                  Instances For

                    The field for acks, pairs of roster index and Idx64.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For

                        What a sender may encode: ascending roster indexes, each one byte, each value an Idx64.

                        Instances For
                          theorem Cryptlib.Protocols.GroupComm.GroupChatKatzenqt1.AckCodec.map_le_fromLE {acks : List (ℕ × ℕ)} (h : ∀ a ∈ acks, a.2 < 2 ^ 64) :
                          List.map (fun (a : ℕ × List ℕ) => (a.1, fromLE a.2)) (List.map (fun (a : ℕ × ℕ) => (a.1, le idxSize a.2)) acks) = acks

                          Decoding undoes encoding for Idx64 values.

                          theorem Cryptlib.Protocols.GroupComm.GroupChatKatzenqt1.AckCodec.encodeIdx64_decodeIdx64 {field : List ℕ} {acks : List (ℕ × ℕ)} (hbytes : ∀ b ∈ field, b < 256) (h : decodeIdx64 true field = some acks) :
                          WFIdx64 acks ∧ encodeIdx64 acks = field

                          For Idx64 values, under the strict parser, a field that decodes is the encoding of its well-formed result.