Documentation

CslibFrontier.Crypto.Computational.GUOAccumulator

The accumulator from a group of unknown order: correctness and aggregation #

The accumulator of [BS23], §10.9 (pp. 421–423), which the book calls the GUO accumulator, in the group (ℤ/Nℤ)ˣ with a base g; the modulus, the base and every group element are natural numbers. Alice commits to a finite set S of elements of a type X, through a hash H : X → ℕ, by c = g ^ E with E = ∏ x ∈ S, H x (construction (10.5), p. 421). Adding an element x ∉ S raises the commitment to the power H x (p. 421). A membership proof for x is b = g ^ (E / H x), which Bob checks by b ^ H x = c. A non-membership proof is a pair (b, γ) with β * H x + γ * E = 1 and b = g ^ β, which Bob checks by b ^ H x * c ^ γ = g (pp. 421–422). One group element π_T = g ^ (E / ∏ x ∈ T, H x) proves T ⊆ S (p. 423); two membership proofs for elements with coprime hashes combine into one by Shamir's trick, and the aggregate splits back into the two proofs (p. 422).

The source's claims map to Lean as follows.

Main definitions #

Main results #

Implementation notes #

The statements differ from the book's as follows.

guoCommit and guoSubsetWitness take a Finset. Alice computes E from a list of elements as the product of their hashes, which for a list without duplicates is guoExponent of its elements (List.prod_toFinset). computableInPolyTime_guoExponent_toFinset and computableInPolyTime_guoCommit_toFinset certify E and the commitment from any list, whose duplicates they erase before multiplying; the certificates for her non-membership proof take E as an input and compose with the first. Her membership proofs guoSubsetWitness are not certified from a list.

References #

def Cslib.Crypto.guoExponent {X : Type u_1} (H : X → ℕ) (S : Finset X) :

The exponent E = H(x₁) ⋯ H(xₙ) of construction (10.5) in [BS23], §10.9, p. 421, for the set S = {x₁, …, xₙ} and the hash H.

def Cslib.Crypto.guoCommit {X : Type u_1} (N g : ℕ) (H : X → ℕ) (S : Finset X) :

The commitment c = g ^ E to the set S in (ℤ/Nℤ)ˣ, construction (10.5) in [BS23], §10.9, p. 421.

Bob's check b ^ e = c modulo N of a proof b against the commitment c ([BS23], §10.9, pp. 421–423). For a membership proof of x, e = H x; for an aggregate proof of a set T, e is the product of the hashes of its elements.

def Cslib.Crypto.guoSubsetWitness {X : Type u_1} [DecidableEq X] (N g : ℕ) (H : X → ℕ) (S T : Finset X) :

Alice's proof π_T that T ⊆ S: g to the product of the hashes of the elements of S \ T. For T ⊆ S and nonzero hashes this is the book's g ^ (E / ∏ x ∈ T, H x) ([BS23], §10.9, p. 423); T = {x} is the membership proof π_x (p. 421), and T = {x, y} is the aggregate π_xy (p. 422).

theorem Cslib.Crypto.guoCommit_insert {X : Type u_1} [DecidableEq X] (N g : ℕ) (H : X → ℕ) {S : Finset X} {x : X} (hx : x ∉ S) :
guoCommit N g H (insert x S) = Turing.MultiTapeTM.powMod N (guoCommit N g H S) (H x)

The accumulator is dynamic ([BS23], §10.9, p. 421): for x ∉ S, the commitment to insert x S is the commitment c to S raised to the power H x.

theorem Cslib.Crypto.guoVerifySubset_subsetWitness {X : Type u_1} [DecidableEq X] (N g : ℕ) (H : X → ℕ) {S T : Finset X} (hT : T ⊆ S) :

Alice's proof that T ⊆ S verifies against the commitment to S, with the product of the hashes of the elements of T as exponent ([BS23], §10.9, p. 423).

theorem Cslib.Crypto.guoVerifySubset_singleton {X : Type u_1} [DecidableEq X] (N g : ℕ) (H : X → ℕ) {S : Finset X} {x : X} (hx : x ∈ S) :
guoVerifySubset N (guoCommit N g H S) (H x) (guoSubsetWitness N g H S {x}) = true

Correctness of membership proofs ([BS23], §10.9, pp. 421–422): for x ∈ S, Alice's proof π_x verifies against the commitment to S.

theorem Cslib.Crypto.guoVerifySubset_pair {X : Type u_1} [DecidableEq X] (N g : ℕ) (H : X → ℕ) {S : Finset X} {x y : X} (hx : x ∈ S) (hy : y ∈ S) (hxy : x ≠ y) :
guoVerifySubset N (guoCommit N g H S) (H x * H y) (guoSubsetWitness N g H S {x, y}) = true

Alice's aggregate proof π_xy for distinct x, y ∈ S verifies against the commitment to S with the exponent H x * H y ([BS23], §10.9, p. 422).

An aggregate proof splits ([BS23], §10.9, p. 422): if b passes Bob's check with the exponent e * f, then b ^ f mod N passes it with the exponent e.

theorem Cslib.Crypto.guoVerifySubset_commonRoot {N c e f b₁ b₂ : ℕ} (hef : e.Coprime f) (hc : c.Coprime N) (h₁ : guoVerifySubset N c e b₁ = true) (h₂ : guoVerifySubset N c f b₂ = true) :
guoVerifySubset N c (e * f) (commonRoot N e f b₁ b₂) = true

Anyone can aggregate two membership proofs ([BS23], §10.9, pp. 422–423): if b₁ and b₂ pass Bob's check against a unit c with coprime exponents e and f, then Shamir's trick commonRoot (Theorem 10.6) yields a proof that passes it with the exponent e * f.

def Cslib.Crypto.guoVerifyNonMem (N g c h b : ℕ) (γ : ℤ) :

Bob's check of a non-membership proof (b, γ) for an element with hash h against the commitment c ([BS23], §10.9, pp. 421–422): c is a unit modulo N, the book's c ∈ G, and b ^ h * c ^ γ = g. For γ < 0 the check compares b ^ h with g * c ^ |γ|, so no inverse is computed.

The coefficient k = -γ of Alice's non-membership proof for an element with hash h against the exponent E ([BS23], §10.9, p. 421): the inverse of -E modulo h, computed by the extended Euclidean algorithm BinaryGcd.modInv. When 0 < h and Nat.Coprime h E, h divides k * E + 1, so β * h + γ * E = 1 for γ = -k and β = (k * E + 1) / h.

The group element b = g ^ β of Alice's non-membership proof for an element with hash h against the exponent E ([BS23], §10.9, p. 421), with β = (guoNonMemCoeff h E * E + 1) / h.

theorem Cslib.Crypto.guoNonMemCoeff_lt {h : ℕ} (hh : 0 < h) (E : ℕ) :

Alice's coefficient satisfies |γ| < h, a slightly sharper form of the book's |γ| ≤ H(x) ([BS23], §10.9, p. 421).

theorem Cslib.Crypto.guoVerifyNonMem_witness {N g h E : ℕ} (hg : g.Coprime N) (hh : 0 < h) (hcop : h.Coprime E) :

Correctness of non-membership proofs ([BS23], §10.9, pp. 421–422): if g is a unit modulo N, 0 < h and gcd(h, E) = 1, then Alice's proof (guoNonMemWitness N g h E, -guoNonMemCoeff h E) passes Bob's check against c = g ^ E.

theorem Cslib.Crypto.coprime_guoExponent {X : Type u_1} {H : X → ℕ} {S : Finset X} {x : X} (hx : Nat.Prime (H x)) (hS : ∀ y ∈ S, Nat.Prime (H y)) (hne : ∀ y ∈ S, H y ≠ H x) :
(H x).Coprime (guoExponent H S)

For a prime H x distinct from the hashes of the elements of S, which are prime too, H x is coprime to the exponent E of S ([BS23], §10.9, p. 422).

theorem Cslib.Crypto.exists_collision_of_not_coprime_guoExponent {X : Type u_1} {H : X → ℕ} {S : Finset X} {x : X} (hx : Nat.Prime (H x)) (hS : ∀ y ∈ S, Nat.Prime (H y)) (hxS : x ∉ S) (h : ¬(H x).Coprime (guoExponent H S)) :
∃ y ∈ S, y ≠ x ∧ H y = H x

The book's argument that correctness relies on the collision resistance of H ([BS23], §10.9, p. 422), stated as an explicit collision: if x ∉ S, the hashes are prime and gcd(H(x), E) ≠ 1, then some y ∈ S with y ≠ x has H y = H x.

theorem Cslib.Crypto.guoVerifyNonMem_guoCommit {X : Type u_1} (N g : ℕ) {H : X → ℕ} {S : Finset X} {x : X} (hg : g.Coprime N) (hx : Nat.Prime (H x)) (hS : ∀ y ∈ S, Nat.Prime (H y)) (hne : ∀ y ∈ S, H y ≠ H x) :
guoVerifyNonMem N g (guoCommit N g H S) (H x) (guoNonMemWitness N g (H x) (guoExponent H S)) (-↑(guoNonMemCoeff (H x) (guoExponent H S))) = true

Correctness of non-membership proofs for a committed set ([BS23], §10.9, pp. 421–422): if g is a unit modulo N, H x is prime and distinct from the hashes of the elements of S, which are prime too, then Alice's non-membership proof for x passes Bob's check against the commitment to S.

def Cslib.Crypto.guoForgeryRoot (N a b : ℕ) (γ : ℤ) :

The root b * a ^ γ mod N computed from a membership proof a and a non-membership proof (b, γ) for one element ([BS23], §10.9, p. 422). For γ < 0, a ^ γ is (a⁻¹) ^ |γ| with a⁻¹ = BinaryGcd.modInv a N.

theorem Cslib.Crypto.powMod_guoForgeryRoot {N g c h a b : ℕ} {γ : ℤ} (hmem : guoVerifySubset N c h a = true) (hnon : guoVerifyNonMem N g c h b γ = true) :

The algebra of the book's security argument ([BS23], §10.9, p. 422): if a passes Bob's membership check and (b, γ) his non-membership check for the same hash h and commitment c, then guoForgeryRoot N a b γ is an h-th root of g modulo N. There is no hypothesis on N, g or h.

Polynomial-time certificates #

Bob's membership and subset check is computable in polynomial time whenever N, c, e and b are, as natural numbers on encNat.

Bob's non-membership check is computable in polynomial time whenever N, g, c, h and b are, as natural numbers on encNat, and γ is, as an integer on encIntBin.

Alice's exponent E for the set of elements of a list is computable in polynomial time whenever the list is, on encList encX, and H is, with binary values. The machine erases the list's duplicates (eraseDupsByWithInput) and multiplies the hashes along the result (binary_prod); for a list without duplicates, E is that product (List.prod_toFinset). The list certificate comes first, so that fun_prop can infer the element encoding.

Alice's commitment to the set of elements of a list is computable in polynomial time whenever N and g are, as natural numbers on encNat, the list is, on encList encX, and H is, with binary values: computableInPolyTime_powMod applied to computableInPolyTime_guoExponent_toFinset.

Alice's non-membership coefficient guoNonMemCoeff h E, the natural number -γ on encNat, is computable in polynomial time whenever h and E are, as natural numbers on encNat.

Alice's coefficient γ = -guoNonMemCoeff h E, as an integer on encIntBin, is computable in polynomial time whenever h and E are, as natural numbers on encNat. This is the form of γ in guoVerifyNonMem_witness and computableInPolyTime_guoVerifyNonMem.

Alice's non-membership group element is computable in polynomial time whenever N, g, h and E are, as natural numbers on encNat.

The root guoForgeryRoot is computable in polynomial time whenever N, a and b are, as natural numbers on encNat, and γ is, as an integer on encIntBin.