Documentation

Cryptlib.Protocols.BACAP.Position

BACAP positions: a capability bound to one box on its stream #

A cap paired with an index from another stream addresses a box nobody writes to. A position carries a proof Reaches cap.messageBoxIndex index that rules this out.

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

    The ratchet as an iterate #

    advanceIndexTo is the ratchet iterated up to the target, or none going backwards.

    Streams #

    idx is k ratchet steps on from start, for some k that does not overflow idx64.

    Equations
    Instances For
      theorem Cryptlib.Protocols.BACAP.Types.Reaches.idx64 {start idx : MessageBoxIndex} (h : Reaches start idx) :
      ∃ (k : ℕ), idx.idx64.toNat = start.idx64.toNat + k ∧ ratchet^[k] start = idx
      theorem Cryptlib.Protocols.BACAP.Types.Reaches.iterate {start idx : MessageBoxIndex} (h : Reaches start idx) (j : ℕ) (hj : idx.idx64.toNat + j < 2 ^ 64) :
      Reaches start (ratchet^[j] idx)

      Why a BACAP operation refused its input. openFailed covers both a bad signature and an AEAD failure.

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

          idx with a proof it is on the stream from start, or why not.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            theorem Cryptlib.Protocols.BACAP.Types.checkReaches_ok_iff (start idx : MessageBoxIndex) :
            (∃ (p : PLift (Reaches start idx)), checkReaches start idx = Except.ok p) ↔ ∃ k ≤ maxContainsWalk, start.idx64.toNat + k < 2 ^ 64 ∧ ratchet^[k] start = idx

            checkReaches accepts exactly the indices a bounded number of ratchet steps on.

            Contains #

            contains accepts idx iff idx is the cap's index ratcheted at most maxContainsWalk times.

            Opening a box #

            The all-zero box ID, which a reply carries when the box was empty.

            Equations
            Instances For

              Check the box is the one rc and this index derive under ctx, then verify and decrypt. The check rejects a tombstone signed for another box.

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

                openForContext only succeeds for the box the cap and index derive.

                theorem Cryptlib.Protocols.BACAP.Types.openForContext_encrypt (wc : WriteCap) (m : MessageBoxIndex) (ctx pt : ByteArray) (hz : (m.encryptForContext wc ctx pt).1 ≠ zeroBox) :
                m.openForContext wc.readCap ctx (m.encryptForContext wc ctx pt).1 (m.encryptForContext wc ctx pt).2.1 (m.encryptForContext wc ctx pt).2.2 = Except.ok pt

                An encrypted box opens to its plaintext at its own index, unless its box ID is all zeros.

                A tombstone opens as empty at its own box, unless that box ID is all zeros.

                Positions #

                A read cap and one box on its stream.

                Instances For

                  A write cap and one box on its stream.

                  Instances For

                    The position of the cap's own index.

                    Equations
                    Instances For

                      The position of the cap's own index.

                      Equations
                      Instances For

                        The position of idx, after checking it is on this cap's stream.

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

                          The position of idx, after checking it is on this cap's stream.

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

                            The next box, or none at the end of the index space.

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

                              The box at target, or none if that is behind this one.

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

                                The next box, or none at the end of the index space.

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

                                  The box at target, or none if that is behind this one.

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

                                    next moves a position exactly as nextIndex moves its index.

                                    advanceTo moves a position exactly as advanceIndexTo moves its index.

                                    The read position of the same box.

                                    Equations
                                    Instances For

                                      Verify and decrypt the box at this position. See MessageBoxIndex.openForContext.

                                      Equations
                                      Instances For

                                        Returns (box ID, ciphertext, signature).

                                        Equations
                                        Instances For

                                          A write position's tombstone opens as empty at its own read position.

                                          Every position addresses a box on its cap's stream.

                                          Serialization: the cap's bytes followed by the index's #

                                          Decode a position, checking its index is on its cap's stream.

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

                                            Decode a position, checking its index is on its cap's stream.

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