Theory DL_assumption
theory DL_assumption
imports "Sigma_Commit_Crypto.Commitment_Schemes" "Berlekamp_Zassenhaus.Finite_Field"
begin
section ‹The Discrete Logarithm Assumption›
text‹The DL game and advantage as in Definition 2.1 of the original KZG paper
``Constant-Size Commitments to Polynomials and Their Applications'' \<^cite>‹KZG10›.›
locale DL = G : cyclic_group G
for G:: "('a, 'b) cyclic_group_scheme" (structure)
and to_type :: "nat ⇒ ('c::prime_card) mod_ring"
and exp :: "'a ⇒ 'c mod_ring ⇒ 'a"
begin
type_synonym ('grp,'mr) adversary = "'grp ⇒ 'mr mod_ring spmf"
text ‹The discrete Logarithm game›
definition game :: "('a,'c) adversary ⇒ bool spmf" where
"game 𝒜 = TRY do {
a ← sample_uniform (Coset.order G);
a' ← 𝒜 (exp ❙g (to_type a));
return_spmf (to_type a = a')
} ELSE return_spmf False"
text ‹The advantage is that the Adversary wins the game.
For the DL assumption to hold this advantage should be negligible.›
definition advantage :: " ('a,'c) adversary ⇒ real"
where "advantage 𝒜 = spmf (game 𝒜) True"
text ‹An alternative but equivalent game for the DL-game. This alternative game capsulates the
event that the Adversary wins in the assert\_spmf statement.
adapted proof from Sigma\_Commit\_Crypto.Commitment\_Schemes bind\_game\_alt\_def›
lemma game_alt_def:
"game 𝒜 = TRY do {
a ← sample_uniform (Coset.order G);
a' ← 𝒜 (exp ❙g (to_type a));
_::unit ← assert_spmf (to_type a = a');
return_spmf True
} ELSE return_spmf False"
(is "?lhs = ?rhs")
proof -
have "?lhs = TRY do {
a ← sample_uniform (Coset.order G);
TRY do {
a' ← 𝒜 (exp ❙g (to_type a));
TRY do {
return_spmf (to_type a = a')
} ELSE return_spmf False
} ELSE return_spmf False
} ELSE return_spmf False"
unfolding split_def game_def
by(fold try_bind_spmf_lossless2[OF lossless_return_spmf]) simp
also have "… = TRY do {
a ← sample_uniform (Coset.order G);
TRY do {
a' ← 𝒜 (exp ❙g (to_type a));
TRY do {
_ :: unit ← assert_spmf (to_type a = a');
return_spmf True
} ELSE return_spmf False
} ELSE return_spmf False
} ELSE return_spmf False"
by(auto simp add: try_bind_assert_spmf try_spmf_return_spmf1 intro!: try_spmf_cong bind_spmf_cong)
also have "… = ?rhs"
unfolding split_def Let_def
by(fold try_bind_spmf_lossless2[OF lossless_return_spmf]) simp
finally show ?thesis .
qed
lemma game_alt_def2:
"game 𝒜 = TRY do {
a ← map_spmf to_type (sample_uniform (Coset.order G));
a' ← 𝒜 (exp ❙g a);
return_spmf (a = a')
} ELSE return_spmf False"
by (simp add: game_def bind_map_spmf o_def)
end
end