Documentation

CslibFrontier.Crypto.Computational.Pairing

Pairing-group infrastructure #

Infrastructure for cryptographic pairing groups, after [BS23], Section 15.4 (Definition 15.2 and equation (15.7), p. 625), where a pairing is an efficiently computable bilinear map e : G₀ × G₁ → GT between cyclic groups of the same prime order q, with generators g₀ and g₁ of the source groups, such that e(g₀, g₁) generates the target group GT.

PairingGroupFamily states this for a family of groups indexed by public parameters, as PrimeOrderGroupFamily does for one group. The first source group is a PrimeOrderGroupFamily, which supplies the parameters, their encoding and the order. The second source group and the target group are PrimeOrderGroupFamily.Companions of it: further groups of the same order over the same parameters, each with its own generator, encoding and polynomial-time operations. The pairing is a ZMod q-bilinear map for each choice of parameters, together with a function on encodings that computes it in polynomial time.

Groups are written additively, as in PrimeOrderGroupFamily: the source's u ^ α is α • u, its u · u' is u + u' and its identity is 0. Bilinearity is stated as linearity over ZMod q in each argument (PairingGroupFamily.pair_smul_smul, PairingGroupFamily.pair_smul_generator_smul_generator for (15.7)), and non-degeneracy as the equation pair d g₀ g₁ = gT for the generator gT that the target group carries (PairingGroupFamily.pair_generator_ne_zero). Using the supporting algebraic equivalence biadditive_iff_apply_smul_generator (after the remark following (15.7) on p. 625), bilinearOfSmulGenerator and PairingGroupFamily.ofSmulGenerator build the ZMod q-bilinear pairing and family directly from a plain map satisfying the generator product rule (15.7).

A companion is a prime-order group family of its own (Companion.toFamily), so DiscreteLog (and, for clients importing CslibFrontier.Crypto.Computational.DiffieHellman, CDH and DDH) are stated for the second source group and for the target group as they are for the first, and Companion forwards fun_prop rules for encoded group operations. A family is a companion of itself (PrimeOrderGroupFamily.self); a pairing is symmetric when its second source group is the first one, P.G₁ = P.G₀.self.

This module provides pairing-group definitions and supporting infrastructure only; it constructs no elliptic-curve pairing and states no hardness assumption or published theorem endpoint. Co-CDH and decision BDH, BLS signatures, pairing-based identity-based encryption, and tripartite/multilinear Diffie–Hellman key exchange ([BS23], Sections 15.4–15.6 and 15.8) are tracked in #640 and #5739.

Main definitions #

Main results #

References #

A further family of cyclic groups over the public parameters of F: for each d : F.Desc a group Carrier d of the same prime order F.order d, with its own generator, encoding and polynomial-time operations on encoded elements. The second source group and the target group of a pairing are companions of the first source group.

@[instance_reducible]

Equality of elements of a companion, decided on their injective encodings.

@[reducible, inline]

A companion of F as a prime-order group family of its own, with the parameters, their encoding and the orders of F. The assumptions DiscreteLog, CDH and DDH for a companion are those of C.toFamily.

@[reducible, inline]

F as a companion of itself: the same groups, generators, encodings and operations. A pairing P is symmetric when P.G₁ = P.G₀.self.

The encoded generator of a companion at computed group parameters.

The encoded identity of a companion at computed group parameters.

The encoded sum of computed elements of a companion.

The encoded multiple of a computed element of a companion by a computed natural number.

theorem Cslib.Crypto.biadditive_iff_apply_smul_generator {G₀ : Type u_1} {G₁ : Type u_2} {GT : Type u_3} [AddCommGroup G₀] [AddCommGroup G₁] [AddCommGroup GT] {q : ℕ} [Module (ZMod q) G₀] [Module (ZMod q) G₁] [Module (ZMod q) GT] {g₀ : G₀} {g₁ : G₁} (h₀ : Function.Surjective fun (α : ZMod q) => α • g₀) (h₁ : Function.Surjective fun (β : ZMod q) => β • g₁) (e : G₀ → G₁ → GT) :
((∀ (u u' : G₀) (v : G₁), e (u + u') v = e u v + e u' v) ∧ ∀ (u : G₀) (v v' : G₁), e u (v + v') = e u v + e u v') ↔ ∀ (α β : ZMod q), e (α • g₀) (β • g₁) = (α * β) • e g₀ g₁

Supporting algebraic step for bilinearOfSmulGenerator (after [BS23], Section 15.4, equation (15.7), p. 625): between ZMod q-modules generated by g₀ and g₁, a map e is additive in each argument if and only if e (α • g₀) (β • g₁) = (α * β) • e g₀ g₁ for all α and β.

def Cslib.Crypto.bilinearOfSmulGenerator {G₀ : Type u_1} {G₁ : Type u_2} {GT : Type u_3} [AddCommGroup G₀] [AddCommGroup G₁] [AddCommGroup GT] {q : ℕ} [Module (ZMod q) G₀] [Module (ZMod q) G₁] [Module (ZMod q) GT] {g₀ : G₀} {g₁ : G₁} (h₀ : Function.Surjective fun (α : ZMod q) => α • g₀) (h₁ : Function.Surjective fun (β : ZMod q) => β • g₁) (e : G₀ → G₁ → GT) (he : ∀ (α β : ZMod q), e (α • g₀) (β • g₁) = (α * β) • e g₀ g₁) :
G₀ →ₗ[ZMod q] G₁ →ₗ[ZMod q] GT

Construct a ZMod q-bilinear map between ZMod q-modules generated by g₀ and g₁ from a plain function e satisfying the generator product rule e (α • g₀) (β • g₁) = (α * β) • e g₀ g₁ (after [BS23], Section 15.4, equation (15.7), p. 625).

@[simp]
theorem Cslib.Crypto.bilinearOfSmulGenerator_apply {G₀ : Type u_1} {G₁ : Type u_2} {GT : Type u_3} [AddCommGroup G₀] [AddCommGroup G₁] [AddCommGroup GT] {q : ℕ} [Module (ZMod q) G₀] [Module (ZMod q) G₁] [Module (ZMod q) GT] {g₀ : G₀} {g₁ : G₁} (h₀ : Function.Surjective fun (α : ZMod q) => α • g₀) (h₁ : Function.Surjective fun (β : ZMod q) => β • g₁) (e : G₀ → G₁ → GT) (he : ∀ (α β : ZMod q), e (α • g₀) (β • g₁) = (α * β) • e g₀ g₁) (u : G₀) (v : G₁) :
((bilinearOfSmulGenerator h₀ h₁ e he) u) v = e u v

Evaluating bilinearOfSmulGenerator recovers the underlying function e.

A family of pairing groups ([BS23], Section 15.4, Definition 15.2, p. 625): for each choice of public parameters d, groups G₀ d, G₁ d and GT d of the same prime order q with generators g₀, g₁ and gT, and a bilinear map pair d : G₀ d → G₁ d → GT d with pair d g₀ g₁ = gT, computable in polynomial time on encodings.

The source groups are G₀ and G₁ and the target group is GT. Groups are written additively, so bilinearity is linearity over ZMod q in each argument. The source names e(g₀, g₁) as the generator gT of the target group; here GT carries a generator, which its polynomial-time operations use, and pair_generator states that it is the pairing of the two generators.

@[reducible, inline]
abbrev Cslib.Crypto.PairingGroupFamily.ofSmulGenerator (G₀ : PrimeOrderGroupFamily) (G₁ GT : G₀.Companion) (pair : (d : G₀.Desc) → G₀.Carrier d → G₁.Carrier d → GT.Carrier d) (hpair : ∀ (d : G₀.Desc) (α β : ZMod (G₀.order d)), pair d (α • G₀.generator d) (β • G₁.generator d) = (α * β) • GT.generator d) (pairEncoded : G₀.Desc × List Bool × List Bool → List Bool) (pairEncoded_encode : ∀ (d : G₀.Desc) (u : G₀.Carrier d) (v : G₁.Carrier d), pairEncoded (d, G₀.encode d u, G₁.encode d v) = GT.encode d (pair d u v)) (computableInPolyTime_pairEncoded : Turing.MultiTapeTM.ComputableInPolyTime pairEncoded (encDescBitsPair G₀.encDesc) Turing.MultiTapeTM.encBits) :

Construct a PairingGroupFamily from a plain pairing function pair satisfying the generator product rule pair d (α • g₀) (β • g₁) = (α * β) • gT (after [BS23], Section 15.4, equation (15.7), p. 625), deriving ZMod q-bilinearity via bilinearOfSmulGenerator and pair_generator at α = β = 1.

theorem Cslib.Crypto.PairingGroupFamily.pair_smul_smul (P : PairingGroupFamily) {d : P.G₀.Desc} (α β : ZMod (P.G₀.order d)) (u : P.G₀.Carrier d) (v : P.G₁.Carrier d) :
((P.pair d) (α • u)) (β • v) = (α * β) • ((P.pair d) u) v

Scalars of both arguments of a pairing multiply: the source's e(u ^ α, v ^ β) = e(u, v) ^ (α · β).

The identity e(g₀ ^ α, g₁ ^ β) = e(g₀, g₁) ^ (α · β) of [BS23], (15.7), first equality (p. 625), with e(g₀, g₁) written as the generator of the target group.

The pairing of the two generators is not the identity of the target group.

theorem Cslib.Crypto.PairingGroupFamily.computableInPolyTime_encode_pair (P : PairingGroupFamily) {α : Type} {enc : α ↪ List Bool} {d : α → P.G₀.Desc} {u : (a : α) → P.G₀.Carrier (d a)} {v : (a : α) → P.G₁.Carrier (d a)} (hd : Turing.MultiTapeTM.ComputableInPolyTime d enc P.G₀.encDesc) (hu : Turing.MultiTapeTM.ComputableInPolyTime (fun (a : α) => P.G₀.encode (d a) (u a)) enc Turing.MultiTapeTM.encBits) (hv : Turing.MultiTapeTM.ComputableInPolyTime (fun (a : α) => P.G₁.encode (d a) (v a)) enc Turing.MultiTapeTM.encBits) :
Turing.MultiTapeTM.ComputableInPolyTime (fun (a : α) => P.GT.encode (d a) (((P.pair (d a)) (u a)) (v a))) enc Turing.MultiTapeTM.encBits

The encoded pairing of computed elements.