Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Examples/OneTimePad.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/-
Copyright (c) 2024 Devon Tuma. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Devon Tuma
Authors: Devon Tuma, Quang Dao
-/
import VCVio.CryptoFoundations.SymmEncAlg
import VCVio.OracleComp.Constructions.BitVec
Expand Down
44 changes: 44 additions & 0 deletions ToMathlib/Data/ENNReal/SumSquares.lean
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,48 @@ lemma sq_sum_le_card_mul_sum_sq {ι' : Type*}
Finset.mul_sum]
_ = 2 * (↑s.card * ∑ i ∈ s, f i ^ 2) := by rw [← two_mul]

private lemma tsum_mul_tsum_eq {α : Type*} (g h : α → ℝ≥0∞) :
(∑' a, g a) * (∑' b, h b) = ∑' a, ∑' b, g a * h b := by
rw [← ENNReal.tsum_mul_right]; congr 1; ext a
exact ENNReal.tsum_mul_left.symm

lemma sq_tsum_le_tsum_mul_tsum {α : Type*} (w f : α → ℝ≥0∞) :
(∑' a, w a * f a) ^ 2 ≤ (∑' a, w a) * ∑' a, w a * f a ^ 2 := by
rw [sq, tsum_mul_tsum_eq, tsum_mul_tsum_eq]
have h2 : (2 : ℝ≥0∞) ≠ 0 := two_ne_zero
have h2' : (2 : ℝ≥0∞) ≠ ⊤ := by norm_num
suffices h : 2 * ∑' a, ∑' b, (w a * f a) * (w b * f b) ≤
2 * ∑' a, ∑' b, w a * (w b * f b ^ 2) by
calc ∑' a, ∑' b, (w a * f a) * (w b * f b)
_ = 2⁻¹ * (2 * ∑' a, ∑' b, (w a * f a) * (w b * f b)) := by
rw [← mul_assoc, ENNReal.inv_mul_cancel h2 h2', one_mul]
_ ≤ 2⁻¹ * (2 * ∑' a, ∑' b, w a * (w b * f b ^ 2)) := by gcongr
_ = ∑' a, ∑' b, w a * (w b * f b ^ 2) := by
rw [← mul_assoc, ENNReal.inv_mul_cancel h2 h2', one_mul]
calc 2 * ∑' a, ∑' b, (w a * f a) * (w b * f b)
_ = ∑' a, ∑' b, 2 * ((w a * f a) * (w b * f b)) := by
rw [← ENNReal.tsum_mul_left]; congr 1; ext
rw [← ENNReal.tsum_mul_left]
_ ≤ ∑' a, ∑' b, (w a * (w b * f b ^ 2) + w b * (w a * f a ^ 2)) := by
gcongr with a b
calc 2 * ((w a * f a) * (w b * f b))
_ = w a * w b * (2 * f a * f b) := by ring
_ ≤ w a * w b * (f a ^ 2 + f b ^ 2) := by
gcongr; exact two_mul_le_add_sq (f a) (f b)
_ = w a * (w b * f b ^ 2) + w b * (w a * f a ^ 2) := by ring
_ = (∑' a, ∑' b, w a * (w b * f b ^ 2)) +
∑' a, ∑' b, w b * (w a * f a ^ 2) := by
simp_rw [← ENNReal.tsum_add]
_ = (∑' a, ∑' b, w a * (w b * f b ^ 2)) +
∑' b, ∑' a, w b * (w a * f a ^ 2) := by
congr 1; exact ENNReal.tsum_comm
_ = 2 * ∑' a, ∑' b, w a * (w b * f b ^ 2) := by rw [two_mul]

lemma sq_tsum_le_tsum_sq {α : Type*} (w f : α → ℝ≥0∞) (hw : ∑' a, w a ≤ 1) :
(∑' a, w a * f a) ^ 2 ≤ ∑' a, w a * f a ^ 2 :=
calc (∑' a, w a * f a) ^ 2
_ ≤ (∑' a, w a) * ∑' a, w a * f a ^ 2 := sq_tsum_le_tsum_mul_tsum w f
_ ≤ 1 * ∑' a, w a * f a ^ 2 := by gcongr
_ = ∑' a, w a * f a ^ 2 := one_mul _

end ENNReal
2 changes: 1 addition & 1 deletion VCVio/CryptoFoundations/AsymmEncAlg.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/-
Copyright (c) 2024 Devon Tuma. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Devon Tuma
Authors: Devon Tuma, Quang Dao
-/
import VCVio.CryptoFoundations.SecExp
import VCVio.OracleComp.ProbComp
Expand Down
18 changes: 16 additions & 2 deletions VCVio/CryptoFoundations/FiatShamir.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/-
Copyright (c) 2024 Devon Tuma. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Devon Tuma
Authors: Devon Tuma, Quang Dao
-/
import VCVio.CryptoFoundations.SigmaAlg
import VCVio.CryptoFoundations.SignatureAlg
Expand Down Expand Up @@ -52,7 +52,21 @@ def FiatShamir (sigmaAlg : SigmaAlg X W PC SC Ω P p)
(StateT ((M × PC →ₒ Ω).QueryCache) ProbComp)
StateT.run' (simulateQ (idImpl + ro) comp) ∅
lift_probComp := monadLift
exec_lift_probComp c := by sorry
exec_lift_probComp c := by
let ro : QueryImpl (M × PC →ₒ Ω)
(StateT ((M × PC →ₒ Ω).QueryCache) ProbComp) := randomOracle
let idImpl := (QueryImpl.ofLift unifSpec ProbComp).liftTarget
(StateT ((M × PC →ₒ Ω).QueryCache) ProbComp)
change StateT.run' (simulateQ (idImpl + ro) (monadLift c)) ∅ = c
rw [show simulateQ (idImpl + ro) (monadLift c) = simulateQ idImpl c by
simpa [MonadLift.monadLift] using
(QueryImpl.simulateQ_add_liftComp_left (impl₁' := idImpl) (impl₂' := ro) c)]
have hid : ∀ t s, (idImpl t).run' s = query t := by
intro t s
rfl
simpa using
(StateT_run'_simulateQ_eq_self (so := idImpl) (h := hid) (oa := c)
(s := (∅ : (M × PC →ₒ Ω).QueryCache)))

namespace FiatShamir

Expand Down
295 changes: 275 additions & 20 deletions VCVio/CryptoFoundations/Fork.lean

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/-
Copyright (c) 2024 Devon Tuma. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Devon Tuma
Authors: Devon Tuma, Quang Dao
-/
import VCVio.CryptoFoundations.HardnessAssumptions.HardHomogeneousSpace

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/-
Copyright (c) 2024 Devon Tuma. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Devon Tuma
Authors: Devon Tuma, Quang Dao
-/
import VCVio.CryptoFoundations.SecExp
import VCVio.OracleComp.ProbComp
Expand Down
2 changes: 1 addition & 1 deletion VCVio/CryptoFoundations/SecExp.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/-
Copyright (c) 2024 Devon Tuma. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Devon Tuma
Authors: Devon Tuma, Quang Dao
-/
import VCVio.OracleComp.ExecutionMethod
import VCVio.OracleComp.ProbComp
Expand Down
2 changes: 1 addition & 1 deletion VCVio/CryptoFoundations/SignatureAlg.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/-
Copyright (c) 2024 Devon Tuma. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Devon Tuma
Authors: Devon Tuma, Quang Dao
-/
import VCVio.CryptoFoundations.SecExp
import VCVio.OracleComp.ProbComp
Expand Down
2 changes: 1 addition & 1 deletion VCVio/CryptoFoundations/SymmEncAlg.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/-
Copyright (c) 2024 Devon Tuma. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Devon Tuma
Authors: Devon Tuma, Quang Dao
-/
import VCVio.CryptoFoundations.SecExp
import VCVio.EvalDist.Prod
Expand Down
2 changes: 1 addition & 1 deletion VCVio/EvalDist/Defs/Basic.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/-
Copyright (c) 2025 Devon Tuma. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Devon Tuma
Authors: Devon Tuma, Quang Dao
-/
import VCVio.EvalDist.Defs.Support

Expand Down
2 changes: 1 addition & 1 deletion VCVio/EvalDist/Instances/OptionT.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/-
Copyright (c) 2025 Devon Tuma. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Devon Tuma
Authors: Devon Tuma, Quang Dao
-/
import ToMathlib.Control.OptionT
import VCVio.EvalDist.Option
Expand Down
2 changes: 1 addition & 1 deletion VCVio/EvalDist/List.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/-
Copyright (c) 2024 Devon Tuma. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Devon Tuma
Authors: Devon Tuma, Quang Dao
-/
import VCVio.EvalDist.Defs.NeverFails
import ToMathlib.General
Expand Down
2 changes: 1 addition & 1 deletion VCVio/EvalDist/Monad/Basic.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/-
Copyright (c) 2025 Devon Tuma. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Devon Tuma
Authors: Devon Tuma, Quang Dao
-/
import VCVio.EvalDist.Defs.Basic

Expand Down
2 changes: 1 addition & 1 deletion VCVio/EvalDist/Monad/Seq.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/-
Copyright (c) 2025 Devon Tuma. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Devon Tuma
Authors: Devon Tuma, Quang Dao
-/
import VCVio.EvalDist.Monad.Map

Expand Down
2 changes: 1 addition & 1 deletion VCVio/OracleComp/Coercions/Add.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/-
Copyright (c) 2024 Devon Tuma. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Devon Tuma
Authors: Devon Tuma, Quang Dao
-/
import VCVio.OracleComp.Coercions.SubSpec
import VCVio.OracleComp.ProbComp
Expand Down
2 changes: 1 addition & 1 deletion VCVio/OracleComp/Coercions/SubSpec.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/-
Copyright (c) 2024 Devon Tuma. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Devon Tuma
Authors: Devon Tuma, Quang Dao
-/
import VCVio.OracleComp.SimSemantics.SimulateQ
import VCVio.OracleComp.EvalDist
Expand Down
2 changes: 1 addition & 1 deletion VCVio/OracleComp/Constructions/GenerateSeed.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/-
Copyright (c) 2024 Devon Tuma. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Devon Tuma
Authors: Devon Tuma, Quang Dao
-/
import VCVio.OracleComp.Constructions.Replicate
import VCVio.OracleComp.Constructions.SampleableType
Expand Down
2 changes: 1 addition & 1 deletion VCVio/OracleComp/Constructions/SampleableType.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/-
Copyright (c) 2024 Devon Tuma. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Devon Tuma
Authors: Devon Tuma, Quang Dao
-/
import VCVio.OracleComp.ProbComp
import VCVio.EvalDist.BitVec
Expand Down
2 changes: 1 addition & 1 deletion VCVio/OracleComp/EvalDist.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/-
Copyright (c) 2025 Devon Tuma. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Devon Tuma
Authors: Devon Tuma, Quang Dao
-/
import VCVio.EvalDist.Defs.NeverFails
import VCVio.EvalDist.Instances.OptionT
Expand Down
2 changes: 1 addition & 1 deletion VCVio/OracleComp/OracleComp.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/-
Copyright (c) 2024 Devon Tuma. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Devon Tuma
Authors: Devon Tuma, Quang Dao
-/
import VCVio.OracleComp.OracleQuery
import ToMathlib.PFunctor.Free
Expand Down
2 changes: 1 addition & 1 deletion VCVio/OracleComp/ProbComp.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/-
Copyright (c) 2024 Devon Tuma. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Devon Tuma
Authors: Devon Tuma, Quang Dao
-/
import VCVio.OracleComp.EvalDist
import Batteries.Control.OptionT
Expand Down
2 changes: 1 addition & 1 deletion VCVio/OracleComp/QueryTracking/CachingOracle.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/-
Copyright (c) 2024 Devon Tuma. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Devon Tuma
Authors: Devon Tuma, Quang Dao
-/
import VCVio.OracleComp.QueryTracking.Structures
import VCVio.OracleComp.SimSemantics.Constructions
Expand Down
2 changes: 1 addition & 1 deletion VCVio/OracleComp/QueryTracking/CountingOracle.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/-
Copyright (c) 2024 Devon Tuma. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Devon Tuma
Authors: Devon Tuma, Quang Dao
-/
import VCVio.OracleComp.QueryTracking.Structures
import VCVio.OracleComp.SimSemantics.WriterT
Expand Down
2 changes: 1 addition & 1 deletion VCVio/OracleComp/QueryTracking/LoggingOracle.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/-
Copyright (c) 2024 Devon Tuma. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Devon Tuma
Authors: Devon Tuma, Quang Dao
-/
import VCVio.OracleComp.SimSemantics.WriterT
import VCVio.OracleComp.SimSemantics.Constructions
Expand Down
Loading