Documentation

QedShare.Shamir.Split

Splitting a secret #

Each secret byte s gets its own polynomial f(x) = s + r₁·x + … + r_{k−1}·x^{k−1}, where r₁ … r_{k−1} are random. Share i (for i = 1 … n) is the point x = i together with the values of all those polynomials at x.

split is pure: the random coefficients are an argument. Only the CLI reads the OS random number generator. Theorems can therefore talk about every possible choice of randomness.

The share indices 1, 2, …, n as field elements.

Equations
Instances For
    def QedShare.Shamir.ValidRand (p : Params) (len : Nat) (rand : List Poly) :

    Randomness of the right shape for p and a secret of length len: one list of k − 1 coefficients per secret byte.

    Equations
    Instances For
      @[instance_reducible]
      instance QedShare.Shamir.instDecidableValidRand (p : Params) (len : Nat) (rand : List Poly) :
      Decidable (ValidRand p len rand)

      Deciding ValidRand with List.all, which runs as a loop. (The generic instance for ∀ r ∈ rand, … recurses once per secret byte and can overflow the stack on large secrets.)

      Equations
      def QedShare.Shamir.shareAt (secret : List GF256) (rand : List Poly) (x : GF256) :

      The share at index x: the value at x of every byte's polynomial s :: r.

      Equations
      Instances For

        Why split refused to run.

        • badRandomness : SplitError

          The randomness does not have one list of k − 1 coefficients per secret byte.

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

            Split secret into p.n shares with threshold p.k, using the random coefficients rand (one list of k − 1 coefficients per secret byte).

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

              Facts about indices #

              theorem QedShare.Shamir.mem_indices {n : Nat} {x : GF256} :
              x ∈ indices n ↔ ∃ (i : Nat), i < n ∧ x = { val := (i + 1).toUInt8 }

              The share indices of a split are 1, 2, …, n.

              There are exactly n share indices.

              theorem QedShare.Shamir.indices_ne_zero {n : Nat} (hn : n ≤ 255) {x : GF256} (hx : x ∈ indices n) :
              x ≠ 0

              No share index is 0 (as long as n ≤ 255).

              theorem QedShare.Shamir.indices_nodup {n : Nat} (hn : n ≤ 255) :

              The share indices are distinct (as long as n ≤ 255).

              Facts about split #

              theorem QedShare.Shamir.split_eq {p : Params} {secret : List GF256} {rand : List Poly} {shares : List Share} (h : split p secret rand = Except.ok shares) :
              ValidRand p secret.length rand ∧ shares = List.map (shareAt secret rand) (indices p.n)

              If split succeeds, it returns exactly the shares at indices 1 … n.

              theorem QedShare.Shamir.split_length {p : Params} {secret : List GF256} {rand : List Poly} {shares : List Share} (h : split p secret rand = Except.ok shares) :
              shares.length = p.n ∧ ∀ (sh : Share), sh ∈ shares → sh.ys.length = secret.length

              split returns exactly n shares, each with one payload value per secret byte.

              theorem QedShare.Shamir.split_no_zero_index {p : Params} {secret : List GF256} {rand : List Poly} {shares : List Share} (h : split p secret rand = Except.ok shares) (sh : Share) :
              sh ∈ shares → sh.x ≠ 0

              No share produced by split has index x = 0 (the share at 0 would be the secret).

              theorem QedShare.Shamir.split_distinct_indices {p : Params} {secret : List GF256} {rand : List Poly} {shares : List Share} (h : split p secret rand = Except.ok shares) :
              (List.map (fun (x : Share) => x.x) shares).Nodup

              All share indices produced by one split are distinct.