Documentation

CslibFrontier.Crypto.Computational.Signature.WordRandomOracle

Native word forgers in the typed random-oracle signature world #

A native word forger is an oracle machine with two channels: channel false signs a word and channel true hashes a word. Every hash payload is retained as a distinct query, and digest replies use the supplied injective encoding. Signing randomness remains in the shared world, separate from the forger's private coins. The existing total pair decoder handles arbitrary native output, including words that are not canonical pair encodings.

wordEufCmaGame and wordSufCmaGame are the EUF-CMA and SUF-CMA games of such a forger against a scheme whose keys, messages, signatures and hash points are words. The forger gets the public key and signs and hashes adaptively. EUF-CMA requires a verified final message that was never signed; SUF-CMA requires a verified final message-signature pair that was never returned by signing. Signing, hashing and the final verification share one lazily sampled random oracle. EUFCMA and SUFCMA are the corresponding asymptotic notions against uniform oracle-PPT forgers.

The saved-coin adapter returns the empty pair without calls on oversized public keys, and truncates every supplied tape at the original input-dependent machine clock. Its sampling budget depends only on the security parameter. These are bridges between existing models, not a Schnorr security reduction. The scheme's signer and shared oracle remain the existing typed world; this module does not certify their native realization or the complete forking reduction.

Main definitions #

Main results #

References #

Original adapters for the existing native oracle-PPT and typed ROM signature models.

def Cslib.Crypto.Protocols.ROMSignature.wordQuery {Digest : Type} (digestEncoding : Digest ↪ List Bool) :

Route the signing channel and hash channel without decoding or identifying hash payloads.

Route a native word program into the existing typed signature world, retaining its private random sampling. Digest encodings affect replies only; all request words remain distinct.

theorem Cslib.Crypto.Protocols.ROMSignature.run_interpret_routeWordProgram {Digest α : Type} (digestEncoding : Digest ↪ List Bool) (program : Probability.WordOracleComp Bool α) {Store : Type} (handler : (q : List Bool ⊕ List Bool) → StateT Store PMF (ForgerSpec (List Bool) (List Bool) (List Bool) Digest q)) (s : Store) :
ProbOracleComp.runWith handler (routeWordProgram digestEncoding program) s = ProbOracleComp.runWith (fun (request : Bool × List Bool) => OracleComp.interpret handler (wordQuery digestEncoding request.1 request.2)) program s

Routing retains the joint output and state of any typed handler.

theorem Cslib.Crypto.Protocols.ROMSignature.routeWordProgram_runCoins {Digest : Type} {k : ℕ} {Control : Type} (machine : Turing.MultiTapePTM k Bool Control Bool) (digestEncoding : Digest ↪ List Bool) (coins input : List Bool) :
routeWordProgram digestEncoding (machine.runCoins (fun (op : Bool) (word : List Bool) => ProbOracleComp.query (op, word)) coins input) = liftOracleForger (machine.runCoins (wordQuery digestEncoding) coins input)

Native replay and typed routing commute as programs, before choosing any oracle world.

EUF-CMA and SUF-CMA games of native word forgers #

noncomputable def Cslib.Crypto.Protocols.ROMSignature.wordEufCmaGame {Digest SK : Type} [Fintype Digest] [Nonempty Digest] (digestEncoding : Digest ↪ List Bool) (scheme : Scheme (List Bool) SK (List Bool) (List Bool) (List Bool) Digest) (forger : List Bool → Probability.WordOracleComp Bool (List Bool × List Bool)) :

The EUF-CMA game of a native word forger in the random-oracle model, for a scheme whose public keys, messages, signatures and hash points are words. The forger receives the public key, signs words on channel false and hashes words on channel true, with digests encoded by digestEncoding, and finally outputs a message and a signature. Signing, hashing and the final verification share one lazily sampled random oracle. The forger wins when the signature verifies and the message was never asked to be signed; repeated signing requests are allowed. This is eufCmaGame for a forger given as a native program with private randomness (exists_eufCmaGame_savedCoinForger).

noncomputable def Cslib.Crypto.Protocols.ROMSignature.wordSufCmaGame {Digest SK : Type} [Fintype Digest] [Nonempty Digest] (digestEncoding : Digest ↪ List Bool) (scheme : Scheme (List Bool) SK (List Bool) (List Bool) (List Bool) Digest) (forger : List Bool → Probability.WordOracleComp Bool (List Bool × List Bool)) :

The SUF-CMA game of a native word forger in the random-oracle model. It has the same execution and shared random oracle as wordEufCmaGame, but the candidate wins exactly when it verifies and its complete (message, signature) pair was never returned by the signing oracle. Thus a different valid signature on a previously signed message can win, while exact replay cannot. This is the native-program form of the existing typed sufCmaGame.

def Cslib.Crypto.Protocols.ROMSignature.EUFCMA {Digest : ℕ → Type} [(n : ℕ) → Fintype (Digest n)] [∀ (n : ℕ), Nonempty (Digest n)] {SK : Type} (digestEncoding : (n : ℕ) → Digest n ↪ List Bool) (scheme : (n : ℕ) → Scheme (List Bool) SK (List Bool) (List Bool) (List Bool) (Digest n)) :

Existential unforgeability under adaptive chosen-message attack in the random-oracle model (EUF-CMA) of a family of word-interface schemes: every uniform oracle-PPT word forger, run on the unary security parameter and the public key, wins wordEufCmaGame with negligible probability. The digest type, its encoding and the scheme may depend on the security parameter. This is the random oracle version of [BS23], Attack Game 13.1 and Definition 13.2 (pp. 529–530), formed as in Section 8.10.2 (p. 328) and used for full domain hash in Section 13.3 (p. 535): the challenger and the forger share one random function from words to Digest n, sampled lazily, and every word is a message. Neither ROMSignature.Scheme nor digestEncoding carries an efficiency or correctness requirement, where Definition 13.1 (pp. 528–529) asks for efficient algorithms whose signatures verify.

def Cslib.Crypto.Protocols.ROMSignature.SUFCMA {Digest : ℕ → Type} [(n : ℕ) → Fintype (Digest n)] [∀ (n : ℕ), Nonempty (Digest n)] {SK : Type} (digestEncoding : (n : ℕ) → Digest n ↪ List Bool) (scheme : (n : ℕ) → Scheme (List Bool) SK (List Bool) (List Bool) (List Bool) (Digest n)) :

Strong existential unforgeability under adaptive chosen-message attack in the random-oracle model (SUF-CMA) of a family of word-interface schemes. The fresh-pair condition and negligible success requirement are [BonehShoup2023, Attack Game 13.2 and Definition 13.3, p. 530]; this definition specializes them to the shared classical random function described in [BonehShoup2023, Section 8.10.2, pp. 327–329], implemented here by one lazy oracle state. Every uniform oracle-PPT word forger wins wordSufCmaGame with negligible probability. The digest type, its encoding and the scheme may depend on the security parameter. Only the forger carries an efficiency requirement: neither ROMSignature.Scheme nor digestEncoding certifies efficient key generation, signing, verification or digest encoding, so this is an unforgeability property of a supplied scheme family rather than a complete efficient-scheme package. Unlike [BonehShoup2023, Definition 13.1, pp. 528–529], it also does not bundle correctness or finite message and signature spaces: public keys, messages, signatures and query points are arbitrary-length words. Callers must establish correctness and nonvacuity separately. In particular, an always-rejecting scheme can satisfy this predicate vacuously. This is not a QROM notion.

theorem Cslib.Crypto.Protocols.ROMSignature.EUFCMA.negligible {Digest : ℕ → Type} [(n : ℕ) → Fintype (Digest n)] [∀ (n : ℕ), Nonempty (Digest n)] {SK : Type} {digestEncoding : (n : ℕ) → Digest n ↪ List Bool} {scheme : (n : ℕ) → Scheme (List Bool) SK (List Bool) (List Bool) (List Bool) (Digest n)} (h : EUFCMA digestEncoding scheme) (forger : ℕ → List Bool → Probability.WordOracleComp Bool (List Bool × List Bool)) (hforger : Probability.IsOraclePPT (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) forger) :
Negligible fun (n : ℕ) => (wordEufCmaGame (digestEncoding n) (scheme n) (forger n)).succProbability

EUF-CMA security gives negligible forgery probability for every oracle-PPT word forger.

theorem Cslib.Crypto.Protocols.ROMSignature.EUFCMA.of_negligible {Digest : ℕ → Type} [(n : ℕ) → Fintype (Digest n)] [∀ (n : ℕ), Nonempty (Digest n)] {SK : Type} {digestEncoding : (n : ℕ) → Digest n ↪ List Bool} {scheme : (n : ℕ) → Scheme (List Bool) SK (List Bool) (List Bool) (List Bool) (Digest n)} (h : ∀ (forger : ℕ → List Bool → Probability.WordOracleComp Bool (List Bool × List Bool)), Probability.IsOraclePPT (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) forger → Negligible fun (n : ℕ) => (wordEufCmaGame (digestEncoding n) (scheme n) (forger n)).succProbability) :
EUFCMA digestEncoding scheme

Establish EUF-CMA security by bounding every oracle-PPT word forger's success probability.

theorem Cslib.Crypto.Protocols.ROMSignature.SUFCMA.negligible {Digest : ℕ → Type} [(n : ℕ) → Fintype (Digest n)] [∀ (n : ℕ), Nonempty (Digest n)] {SK : Type} {digestEncoding : (n : ℕ) → Digest n ↪ List Bool} {scheme : (n : ℕ) → Scheme (List Bool) SK (List Bool) (List Bool) (List Bool) (Digest n)} (h : SUFCMA digestEncoding scheme) (forger : ℕ → List Bool → Probability.WordOracleComp Bool (List Bool × List Bool)) (hforger : Probability.IsOraclePPT (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) forger) :
Negligible fun (n : ℕ) => (wordSufCmaGame (digestEncoding n) (scheme n) (forger n)).succProbability

SUF-CMA security gives negligible fresh-pair forgery probability for every oracle-PPT word forger.

theorem Cslib.Crypto.Protocols.ROMSignature.SUFCMA.of_negligible {Digest : ℕ → Type} [(n : ℕ) → Fintype (Digest n)] [∀ (n : ℕ), Nonempty (Digest n)] {SK : Type} {digestEncoding : (n : ℕ) → Digest n ↪ List Bool} {scheme : (n : ℕ) → Scheme (List Bool) SK (List Bool) (List Bool) (List Bool) (Digest n)} (h : ∀ (forger : ℕ → List Bool → Probability.WordOracleComp Bool (List Bool × List Bool)), Probability.IsOraclePPT (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) forger → Negligible fun (n : ℕ) => (wordSufCmaGame (digestEncoding n) (scheme n) (forger n)).succProbability) :
SUFCMA digestEncoding scheme

Establish SUF-CMA security by bounding every oracle-PPT word forger's success probability.

theorem Cslib.Crypto.Protocols.ROMSignature.succProbability_wordEufCmaGame_le_wordSufCmaGame {Digest SK : Type} [Fintype Digest] [Nonempty Digest] (digestEncoding : Digest ↪ List Bool) (scheme : Scheme (List Bool) SK (List Bool) (List Bool) (List Bool) Digest) (forger : List Bool → Probability.WordOracleComp Bool (List Bool × List Bool)) :
(wordEufCmaGame digestEncoding scheme forger).succProbability ≤ (wordSufCmaGame digestEncoding scheme forger).succProbability

A native word forger wins EUF-CMA with probability at most its SUF-CMA probability. Both games use the identical key law, forger execution, signing transcript, and shared random-oracle cache; only the final freshness test changes.

theorem Cslib.Crypto.Protocols.ROMSignature.SUFCMA.eufCma {Digest : ℕ → Type} [(n : ℕ) → Fintype (Digest n)] [∀ (n : ℕ), Nonempty (Digest n)] {SK : Type} {digestEncoding : (n : ℕ) → Digest n ↪ List Bool} {scheme : (n : ℕ) → Scheme (List Bool) SK (List Bool) (List Bool) (List Bool) (Digest n)} (h : SUFCMA digestEncoding scheme) :
EUFCMA digestEncoding scheme

Native ROM SUF-CMA security implies native ROM EUF-CMA security for the same scheme family.

Saved-coin replay #

@[reducible, inline]

Input (1ⁿ, pk, tape) of a saved-coin replay (savedWordReplay): the security parameter n in unary, then the public key and the saved coin tape as bit words. The parameter and the public key are framed.

def Cslib.Crypto.Protocols.ROMSignature.savedWordReplay {k : ℕ} {Control Query : Type} {spec : OracleSpec Query} (machine : Turing.MultiTapePTM k Bool Control Bool) (query : Bool → List Bool → OracleComp spec (List Bool)) (c d keyC keyD : ℕ) :

Guard the public input, truncate the saved tape, and decode the output, with the original external channels supplied explicitly. Malformed output uses the existing total pair decoder.

The complete guarded, truncated, decoded replay is strict oracle-PPT in its full input, including the security parameter, public key, and arbitrary saved tape.

@[reducible, inline]

The raw calls of a native word forger: a channel bit and a request word, answered by a word.

theorem Cslib.Crypto.Protocols.ROMSignature.savedWordReplay_eq_interpret {k : ℕ} {Control Query : Type} {spec : OracleSpec Query} (machine : Turing.MultiTapePTM k Bool Control Bool) (query : Bool → List Bool → OracleComp spec (List Bool)) (c d keyC keyD : ℕ) (input : ℕ × List Bool × List Bool) :
savedWordReplay machine query c d keyC keyD input = OracleComp.interpret (fun (request : Bool × List Bool) => query request.1 request.2) (savedWordReplay machine (fun (op : Bool) (word : List Bool) => OracleComp.query (op, word)) c d keyC keyD input)

Every guarded replay is the replay with raw calls, interpreted by its channel calls.

theorem Cslib.Crypto.Protocols.ROMSignature.isQueryBounded_savedWordReplay {k : ℕ} {Control Query : Type} {spec : OracleSpec Query} (machine : Turing.MultiTapePTM k Bool Control Bool) (query : Bool → List Bool → OracleComp spec (List Bool)) (hquery : ∀ (op : Bool) (word : List Bool), (query op word).IsQueryBounded 1) (c d keyC keyD n : ℕ) (pk coins : List Bool) :
(savedWordReplay machine query c d keyC keyD (n, pk, coins)).IsQueryBounded (Probability.savedCoinBudget c d keyC keyD n)

A guarded replay whose channel calls each make at most one call makes at most savedCoinBudget calls, for every public key and every saved tape.

noncomputable def Cslib.Crypto.Protocols.ROMSignature.savedCoinForger {Digest : Type} {k : ℕ} {Control : Type} (machine : Turing.MultiTapePTM k Bool Control Bool) (digestEncoding : Digest ↪ List Bool) (c d keyC keyD n : ℕ) :

Use the existing total pair decoder after native replay. Oversized keys make no calls; all coin tapes, including overlong ones outside the sampling support, are truncated before replay.

theorem Cslib.Crypto.Protocols.ROMSignature.routeWordProgram_savedWordReplay {Digest : Type} {k : ℕ} {Control : Type} (machine : Turing.MultiTapePTM k Bool Control Bool) (digestEncoding : Digest ↪ List Bool) (c d keyC keyD n : ℕ) (pk coins : List Bool) :
routeWordProgram digestEncoding (savedWordReplay machine (fun (op : Bool) (word : List Bool) => ProbOracleComp.query (op, word)) c d keyC keyD (n, pk, coins)) = liftOracleForger ((savedCoinForger machine digestEncoding c d keyC keyD n).forge pk coins)

The efficient native guarded replay is exactly the typed fixed-coin forger after channel routing, including the oversized-key branch and total decoding of arbitrary output words.

theorem Cslib.Crypto.Protocols.ROMSignature.isQueryBounded_wordQuery {Digest : Type} (digestEncoding : Digest ↪ List Bool) (op : Bool) (word : List Bool) :
(wordQuery digestEncoding op word).IsQueryBounded 1

Signing and hashing each cost at most one external call in the word routing.

theorem Cslib.Crypto.Protocols.ROMSignature.callBounded_savedCoinForger {Digest : Type} {k : ℕ} {Control : Type} (machine : Turing.MultiTapePTM k Bool Control Bool) (digestEncoding : Digest ↪ List Bool) (c d keyC keyD n : ℕ) :
(savedCoinForger machine digestEncoding c d keyC keyD n).CallBounded (Probability.savedCoinBudget c d keyC keyD n) (Probability.savedCoinBudget c d keyC keyD n)

The fixed-coin forger has uniform signing and hash budgets for every key and every tape.

theorem Cslib.Crypto.Protocols.ROMSignature.exists_savedCoinForger {gen : ℕ → ProbComp (List Bool × List Bool)} {keyC keyD : ℕ} (hgen : ∀ (n : ℕ), ∀ keys ∈ (gen n).eval.support, keys.1.length ≤ keyC * (n + 1) ^ keyD) {program : ℕ → List Bool → Probability.WordOracleComp Bool (List Bool × List Bool)} (hprogram : Probability.IsOraclePPT (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) program) :
∃ (k : ℕ) (Control : Type) (_ : Finite Control) (machine : Turing.MultiTapePTM k Bool Control Bool) (c : ℕ) (d : ℕ), Probability.IsOraclePPTOn encReplayInput (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) (savedWordReplay machine (fun (op : Bool) (word : List Bool) => ProbOracleComp.query (op, word)) c d keyC keyD) ∧ ∀ (n : ℕ), ∀ keys ∈ (gen n).eval.support, ∀ (Digest : Type) (digestEncoding : Digest ↪ List Bool) (Store : Type) (handler : (q : List Bool ⊕ List Bool) → StateT Store PMF (ForgerSpec (List Bool) (List Bool) (List Bool) Digest q)) (s : Store), ProbOracleComp.runWith handler (routeWordProgram digestEncoding (program n keys.1)) s = (savedCoinForger machine digestEncoding c d keyC keyD n).coins.bind fun (coins : (savedCoinForger machine digestEncoding c d keyC keyD n).Coins) => ProbOracleComp.runWith handler (liftOracleForger ((savedCoinForger machine digestEncoding c d keyC keyD n).forge keys.1 coins)) s

An actual uniform native forger has a key-independent saved-coin adapter. The key-size guard is a polynomial bound keyC * (n + 1) ^ keyD on the supported public keys, which a strict-PPT key generator supplies through IsPPTOn.length_le. Equality retains the complete state of every typed signing/hash handler; in particular the handler's own randomness is not pre-sampled here.

theorem Cslib.Crypto.Protocols.ROMSignature.exists_eufCmaGame_savedCoinForger {gen : ℕ → ProbComp (List Bool × List Bool)} {keyC keyD : ℕ} (hgen : ∀ (n : ℕ), ∀ keys ∈ (gen n).eval.support, keys.1.length ≤ keyC * (n + 1) ^ keyD) {program : ℕ → List Bool → Probability.WordOracleComp Bool (List Bool × List Bool)} (hprogram : Probability.IsOraclePPT (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) program) :
∃ (k : ℕ) (Control : Type) (_ : Finite Control) (machine : Turing.MultiTapePTM k Bool Control Bool) (c : ℕ) (d : ℕ), Probability.IsOraclePPTOn encReplayInput (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) (savedWordReplay machine (fun (op : Bool) (word : List Bool) => ProbOracleComp.query (op, word)) c d keyC keyD) ∧ ∀ (n : ℕ) (Digest : Type) [inst : Fintype Digest] [inst_1 : Nonempty Digest] (digestEncoding : Digest ↪ List Bool) (scheme : Scheme (List Bool) (List Bool) (List Bool) (List Bool) (List Bool) Digest), scheme.keyGen = (gen n).eval → (savedCoinForger machine digestEncoding c d keyC keyD n).CallBounded (Probability.savedCoinBudget c d keyC keyD n) (Probability.savedCoinBudget c d keyC keyD n) ∧ wordEufCmaGame digestEncoding scheme (program n) = eufCmaGame scheme (savedCoinForger machine digestEncoding c d keyC keyD n)

The native private-random word forger and its explicit-coin adapter give exactly the same EUF-CMA game: wordEufCmaGame of the forger is eufCmaGame of the adapter. Signing, hash queries, and final verification share one memoized world; freshness excludes only signing the final message, so repeated signing queries are allowed. One native replay machine and clock work for every digest type and encoding, which may therefore vary with the security parameter. The supported public keys need only a polynomial length bound keyC * (n + 1) ^ keyD. This bridge does not assert unforgeability or a discrete-log reduction.

theorem Cslib.Crypto.Protocols.ROMSignature.exists_sufCmaGame_savedCoinForger {gen : ℕ → ProbComp (List Bool × List Bool)} {keyC keyD : ℕ} (hgen : ∀ (n : ℕ), ∀ keys ∈ (gen n).eval.support, keys.1.length ≤ keyC * (n + 1) ^ keyD) {program : ℕ → List Bool → Probability.WordOracleComp Bool (List Bool × List Bool)} (hprogram : Probability.IsOraclePPT (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) program) :
∃ (k : ℕ) (Control : Type) (_ : Finite Control) (machine : Turing.MultiTapePTM k Bool Control Bool) (c : ℕ) (d : ℕ), Probability.IsOraclePPTOn encReplayInput (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) (savedWordReplay machine (fun (op : Bool) (word : List Bool) => ProbOracleComp.query (op, word)) c d keyC keyD) ∧ ∀ (n : ℕ) (Digest : Type) [inst : Fintype Digest] [inst_1 : Nonempty Digest] (digestEncoding : Digest ↪ List Bool) (scheme : Scheme (List Bool) (List Bool) (List Bool) (List Bool) (List Bool) Digest), scheme.keyGen = (gen n).eval → (savedCoinForger machine digestEncoding c d keyC keyD n).CallBounded (Probability.savedCoinBudget c d keyC keyD n) (Probability.savedCoinBudget c d keyC keyD n) ∧ wordSufCmaGame digestEncoding scheme (program n) = sufCmaGame scheme (savedCoinForger machine digestEncoding c d keyC keyD n)

The native private-random word forger and its explicit-coin adapter give exactly the same SUF-CMA game: wordSufCmaGame of the forger is sufCmaGame of the adapter. Signing, hash queries, and final verification share one memoized world; freshness excludes the complete returned message-signature pairs, so a different valid signature on a signed message may win while exact replay cannot. The signing and hash call bounds remain separate components of CallBounded. One replay machine and clock work for every digest type and encoding, which may vary with the security parameter. This bridge asserts neither SUF-CMA security nor a reduction to an ML-DSA assumption.