Skip to content

feat(Crypto): define PRGs and their security definition - #876

Open
SamuelSchlesinger wants to merge 1 commit into
leanprover:mainfrom
SamuelSchlesinger:samschlesinger/pseudorandom-generators
Open

feat(Crypto): define PRGs and their security definition#876
SamuelSchlesinger wants to merge 1 commit into
leanprover:mainfrom
SamuelSchlesinger:samschlesinger/pseudorandom-generators

Conversation

@SamuelSchlesinger

@SamuelSchlesinger SamuelSchlesinger commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator

Formalizes Boneh-Shoup's definitions of PRGs and proves the impossibility of making an extending PRG against an arbitrary adversary. Takes the approach of #766 by defining the construction and proving the impossibility in certain contexts, motivating the future computational security definitions.

Composed with Astra using Codex based on some code that I had written by hand.

@SamuelSchlesinger
SamuelSchlesinger force-pushed the samschlesinger/pseudorandom-generators branch from 033593d to 013616a Compare September 5, 2026 21:53
@SamuelSchlesinger SamuelSchlesinger changed the title feat(Crypto): define PRG security against admissible adversaries feat(Crypto): define PRGs and their security definition Sep 5, 2026

@Shreyas4991 Shreyas4991 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial comments. Not all are "required" of course. I would recommend taking a close took at all uses of classical. GPT has a tendency to play it too safe by inserting classical anywhere and everywhere.

Comment on lines +38 to +44
abbrev Family (Seed Output : ℕ → Type*) := ∀ n, Generator (Seed n) (Output n)

namespace Family

variable {Seed Output : ℕ → Type*}
variable [∀ n, Fintype (Seed n)] [∀ n, Nonempty (Seed n)]
variable [∀ n, Fintype (Output n)] [∀ n, Nonempty (Output n)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are Generators arbitrary types? Couldn't they just be instances of a structure. Then if the structure got a Fintype or Finite instance, there would be no need to declare [forall n, Fintype (Seed n)] etc. This is just a design comment.

/-- An unbounded adversary tests whether its input is in the generator's range.
It is not assumed to be admissible for a computationally restricted class. -/
noncomputable def rangeAdversary (G : Generator Seed Output) : Adversary Output := by
classical

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this actually needed here? To me it sounds like
:= fun output => PMF.pure (decide (output ∈ Set.range G)) might work

/-- Zero-error security against arbitrary tests is equivalent to exactly uniform output. -/
theorem secure_zero_iff_outputDist_eq_uniform (G : Generator Seed Output) :
G.Secure (fun _ => True) 0 ↔ G.outputDist = PMF.uniformOfFintype Output := by
classical

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems better to explicitly declare what Props need to be Decidable than use classical.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants