Documentation

CslibFrontier.Crypto.Computational.DiscreteLog.Interpolation

Lagrange interpolation, and interpolation in the exponent, in polynomial time #

Lemma 22.1 of [BS23] says that the value at a point j* of a polynomial of degree less than t over Z_q is a fixed combination ∑ λ_j ω(j) of its values at t distinct nodes, and that the coefficients λ_j are efficiently computable from the nodes and j*. Corollary 22.2 says that in a group of prime order q the element h^{ω(j*)} can be efficiently computed from the nodes, j* and the elements h^{ω(j)}. This file proves both efficiency clauses, for functions that are tied to the identities.

The identities over an arbitrary field, without cost statements, are Lagrange.eval_eq_sum_eval_basis_mul_eval and Lagrange.eval_smul_eq_sum_eval_basis_smul.

Differences from the book:

Main definitions #

Main results #

References #

The interpolation coefficient on natural numbers #

The Lagrange interpolation coefficient at the point x of the node j among nodes, computed modulo q on natural numbers: the product of (j - j')⁻¹ (x - j') over the nodes j' that differ from j modulo q, each factor computed by extractNat.

theorem Cslib.Crypto.PrimeOrderGroupFamily.lagrangeWeightNat_cast {q : ℕ} [Fact (Nat.Prime q)] (nodes : List ℕ) (j x : ℕ) :
↑(lagrangeWeightNat q nodes j x) = (List.map (fun (j' : ℕ) => if ↑j' = ↑j then 1 else (↑x - ↑j') / (↑j - ↑j')) nodes).prod

Modulo a prime q, lagrangeWeightNat is the product of the quotients (x - j') / (j - j') over the nodes j' that differ from j modulo q. No hypothesis on the nodes is needed.

theorem Cslib.Crypto.PrimeOrderGroupFamily.lagrangeWeightNat_cast_eq_eval_basis {q : ℕ} [Fact (Nat.Prime q)] {nodes : List ℕ} (hnodes : (List.map Nat.cast nodes).Nodup) {j : ℕ} (hj : j ∈ nodes) (x : ℕ) :

Modulo a prime q, for nodes that are distinct modulo q and a node j among them, lagrangeWeightNat is the value at x of the Lagrange basis polynomial of j: the coefficient of Lagrange.eval_basis. Both hypotheses are needed.

theorem Cslib.Crypto.PrimeOrderGroupFamily.eval_eq_sum_lagrangeWeightNat_mul_eval {q : ℕ} [Fact (Nat.Prime q)] {nodes : List ℕ} (hnodes : (List.map Nat.cast nodes).Nodup) {f : Polynomial (ZMod q)} (hf : f.degree < ↑nodes.length) (x : ℕ) :
Polynomial.eval (↑x) f = (List.map (fun (j : ℕ) => ↑(lagrangeWeightNat q nodes j x) * Polynomial.eval (↑j) f) nodes).sum

Lemma 22.1 of [BS23] for the computed coefficients: for a prime q, nodes that are distinct modulo q and a polynomial f over ZMod q of degree less than the number of nodes, the value of f at any point x is the combination of its values at the nodes with the coefficients lagrangeWeightNat q nodes j x. These coefficients are computable in polynomial time when q is the order of a group of a family (computableInPolyTime_lagrangeWeightNat).

The efficiency clause of Lemma 22.1 of [BS23]: the coefficient lagrangeWeightNat modulo the group order is computable in polynomial time from the group description, the list of nodes, the node and the point, all computed from the input. No hypothesis on the nodes is needed.

Interpolation in the exponent #

The combination ∑ λ_j • h_j of the group elements h_j of the pairs (j, h_j), with the coefficients λ_j = lagrangeWeightNat of their nodes at the point x modulo the group order. This is the book's ∏ (h^{ω(j)})^{λ_j} ([BS23], Corollary 22.2), written additively.

theorem Cslib.Crypto.PrimeOrderGroupFamily.lagrangeCombine_eval_smul {F : PrimeOrderGroupFamily} (d : F.Desc) {nodes : List ℕ} (hnodes : (List.map Nat.cast nodes).Nodup) {f : Polynomial (ZMod (F.order d))} (hf : f.degree < ↑nodes.length) (x : ℕ) (h : F.Carrier d) :
F.lagrangeCombine d x (List.map (fun (j : ℕ) => (j, Polynomial.eval (↑j) f • h)) nodes) = Polynomial.eval (↑x) f • h

Corollary 22.2 of [BS23] for the computed combination, written additively: from the elements f(j) • h at nodes that are distinct modulo the group order, lagrangeCombine gives f(x) • h, for a polynomial f of degree less than the number of nodes. Its encoding is computable in polynomial time (computableInPolyTime_encode_lagrangeCombine).

The efficiency clause of Corollary 22.2 of [BS23]: the encoding of lagrangeCombine is computable in polynomial time from the group description, the point and the list of pairs (j, F.encode d h_j) of nodes and encoded group elements, all computed from the input. The elements must be group elements: the input is their encodings, not arbitrary words.