Documentation

QedShareCli.Packed

Share records with the payload as a byte array #

The proven core keeps a share's payload as a List GF256, which costs 24 bytes of memory per byte. PackedRecord is the same record with the payload as a ByteArray (1 byte per byte), and combinePacked is combine reading the bytes straight from the arrays. combinePacked_eq proves it returns exactly what combine returns on the shares of the packed records.

  • setId : UInt32

    Random identifier shared by all shares of one split.

  • k : UInt8

    The threshold of the split.

  • x : GF256

    The share index.

  • The format version.

  • token : List GF256

    The share's token.

  • payload : ByteArray

    The share's payload, one byte per field element.

Instances For

    Pack a record: the same fields, with the payload as a byte array.

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

      The payload of a packed record, as the list the core works on.

      Equations
      Instances For

        The share of a packed record.

        Equations
        Instances For

          Byte b of every position of the payloads, weighted by ws: the interpolation of interpolateShares and interpolateSharesAt, reading the bytes from the arrays.

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

            combine on packed records: the same checks in the same order, and the same result (combinePacked_eq).

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

              The record of a packed record.

              Equations
              Instances For

                combinePacked = combine #

                Unpacking a packed record gives back the record's share.

                The packed payload has one byte per field element.

                theorem QedShare.Cli.get!_payload (p : PackedRecord) (b : Nat) :
                { val := p.payload.get! b } = p.share.ys.getD b 0

                Reading byte b of the array is reading position b of the payload list (0 past the end, in both).

                interpolatePacked with the weights at 0 is interpolateShares.

                interpolatePacked with the weights at z is interpolateSharesAt z.

                combinePacked is combine on the shares of the packed records.

                The plain fields of a packed record are the record's.

                Packing the record of a packed record gives it back.

                Unpacking a packed record gives the record back.

                theorem QedShare.Cli.mapM_map {α β γ ε : Type} (f : α → Except ε β) (g : β → γ) (l : List α) :
                List.mapM (fun (a : α) => Except.map g (f a)) l = Except.map (List.map g) (List.mapM f l)

                mapM in Except of a function followed by a map is mapM of the function, then the map on every result.

                The same, with the result as a byte array #

                combinePacked still returns the rebuilt bytes as a list. combineBytes writes them into a byte array and compares byte arrays, so nothing as long as the secret is ever a list.

                A list of field elements as a byte array.

                Equations
                Instances For

                  Loop for interpolateBytes: bytes b, b + 1, … (n of them) are appended to acc.

                  Equations
                  Instances For

                    interpolatePacked, written into a byte array (interpolateBytes_eq).

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

                      Loop for sameByteArrays: the XOR of each pair of bytes is OR-ed into acc.

                      Equations
                      Instances For

                        sameBytes on byte arrays: equality without stopping at the first difference (sameByteArrays_eq).

                        Equations
                        Instances For

                          combine on packed records, with the rebuilt bytes as a byte array (combineBytes_eq).

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

                            The bytes of a byte array, as a list, as a byte array again.

                            Unpacking packed bytes gives the list back.

                            Reading the bytes of an array one by one gives the list of its bytes.

                            theorem QedShare.Cli.interpolateInto_eq (ws : List GF256) (ps : List PackedRecord) (n b : Nat) (acc : ByteArray) :
                            interpolateInto ws ps n b acc = acc ++ (List.map (fun (b : Nat) => (Poly.dot ws (List.map (fun (p : PackedRecord) => { val := p.payload.get! b }) ps)).val) (List.range' b n)).toByteArray

                            interpolateInto appends the interpolated bytes.

                            theorem QedShare.Cli.diffInto_eq (a b : ByteArray) (n i : Nat) (acc : UInt8) :
                            diffInto a b n i acc = List.foldl (fun (x1 x2 : UInt8) => x1 ||| x2) acc (List.map (fun (i : Nat) => a.get! i ^^^ b.get! i) (List.range' i n))

                            diffInto is the OR of the XORs of the bytes it reads.

                            Loops over a range of bytes #

                            def QedShare.Cli.allBytes (p : UInt8 → Bool) (bs : ByteArray) :
                            Nat → Nat → Bool

                            Do the n bytes from position i all satisfy p?

                            Equations
                            Instances For
                              theorem QedShare.Cli.allBytes_eq (p : UInt8 → Bool) (bs : ByteArray) (n i : Nat) :
                              allBytes p bs n i = (List.map bs.get! (List.range' i n)).all p

                              allBytes is List.all on the bytes it reads.

                              theorem QedShare.Cli.allBytes_all (p : UInt8 → Bool) (a : ByteArray) :

                              allBytes over the whole array is List.all on its bytes.