Documentation

CslibFrontier.Crypto.Computational.TreeSignature.CoinHybrid

Tree signatures: from pseudorandom to random coins #

The first step of the security proof of stateless tree signatures ([BS23], Section 14.6.3, proof of Theorem 14.6, "we first replace the PRF F with a random function"). The tree scheme over an indexed scheme S at parameter n draws its node coins from a pseudorandom function F keyed at N n bits (prfCoins F). The EUF-CMA game against it (treeGame, the typed eufCmaExperiment of the certificate-free treeScheme, which has the law of eufCmaGame of TreeSignature.scheme) is compared with the same game where the coins come from a uniform random function on N n bits (treeIdealGame).

The coin adversary treeCoinAdversary runs the forger inside coinRealGame and coinIdealGame: it derives the root key and every node key and signature by coin requests, so under the real coin oracle it plays treeGame and under the ideal one treeIdealGame, exactly (eval_coinRealGame_treeCoinAdversary, eval_coinIdealGame_treeCoinAdversary). Its parameter is the PRF's, N n, so it recovers n with an inverse inv of N and plays nothing at parameters outside the range of N. Pairing n with any polynomial-time budget (coinParam) supplies an injective schedule N strictly above the budget together with a polynomial-time bounded-search left inverse (coinParamInv).

Main definitions #

Main results #

References #

The forging games #

noncomputable def Cslib.Crypto.TreeSignature.treeScheme (S : IndexedSignatureScheme) (T : S.Seeded) (depth : ℕ → ℕ) (coins : List Bool → List Bool → ℕ → List Bool) (n : ℕ) (keys : ProbComp (List Bool × List Bool)) :

The tree algorithms with the coin function coins at parameter n, keys drawn from keys and verification restricted to n-bit messages: the typed scheme of TreeSignature.scheme at n, stated without certificates so that random coins may be substituted.

noncomputable def Cslib.Crypto.TreeSignature.treeGame (S : IndexedSignatureScheme) (T : S.Seeded) (depth keyLen : ℕ → ℕ) (coins : List Bool → List Bool → ℕ → List Bool) (adversary : Forger) (n : ℕ) :

The EUF-CMA experiment of the tree scheme with a coin function, played by the word forger at n.

noncomputable def Cslib.Crypto.TreeSignature.treeGameWith (S : IndexedSignatureScheme) (T : S.Seeded) (depth : ℕ → ℕ) (coins : List Bool → List Bool → ℕ → List Bool) (k : List Bool) (adversary : Forger) (n : ℕ) :

The tree game with a fixed secret k.

theorem Cslib.Crypto.TreeSignature.eval_treeGame (S : IndexedSignatureScheme) (T : S.Seeded) (depth keyLen : ℕ → ℕ) (coins : List Bool → List Bool → ℕ → List Bool) (adversary : Forger) (n : ℕ) :
ProbComp.eval (treeGame S T depth keyLen coins adversary n) = (BitString.uniformList (keyLen n)).bind fun (k : List Bool) => ProbComp.eval (treeGameWith S T depth coins k adversary n)

The tree game samples the secret and plays treeGameWith.

theorem Cslib.Crypto.TreeSignature.eufCmaGame_scheme (S : IndexedSignatureScheme) (T : S.Seeded) (depth keyLen : ℕ → ℕ) {coins : List Bool → List Bool → ℕ → List Bool} (hcoins : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : List Bool × List Bool × ℕ) => match x with | (k, input, length) => coins k input length) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encUnary)) Turing.MultiTapeTM.encBits) (hkeyLen : Turing.MultiTapeTM.ComputableInPolyTime keyLen Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) (hdepth : Turing.MultiTapeTM.ComputableInPolyTime depth Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) (hcap : ∀ (n : ℕ), 2 ≤ S.capacity n) (hdepth_pos : ∀ (n : ℕ), 1 ≤ depth n) (adversary : Forger) (n : ℕ) :
((scheme S T coins keyLen depth hcoins hkeyLen hdepth hcap hdepth_pos).eufCmaGame adversary n).eval = ProbComp.eval (treeGame S T depth keyLen coins adversary n)

The scheme's EUF-CMA game is treeGame.

def Cslib.Crypto.TreeSignature.tableCoins (N : ℕ) (table : BitString N → BitString N) (_k x : List Bool) (L : ℕ) :

Coins read from a random function on N bits at the padded request, ignoring the key.

noncomputable def Cslib.Crypto.TreeSignature.treeIdealGame (S : IndexedSignatureScheme) (T : S.Seeded) (depth N : ℕ → ℕ) (adversary : Forger) (n : ℕ) :

The tree game with coins from a uniform random function on N n bits.

The tree algorithms with coins from an oracle #

Request L coins for x from the coin oracle, keeping at most L bits.

The key pair of node path, from requested coins.

The signature of msg at index u by node path holding sk, from requested coins.

One step of the chain along leaf: the next bit is the one after the current path.

Certify the path to the parent of leaf, a leaf of depth depth n.

Sign msg: when msg has length n, sample a uniform leaf, certify the chain to its parent, and sign msg there; otherwise return [].

The signing handler of the simulated game: sign through the coin oracle and log the message.

The tree game at parameter n, played against the coin oracle.

noncomputable def Cslib.Crypto.TreeSignature.treeCoinAdversary (S : IndexedSignatureScheme) (T : S.Seeded) (depth N inv : ℕ → ℕ) (adversary : Forger) :

The coin adversary: at the PRF's parameter M, recover n with inv and simulate the tree game there; outside the range of N, output false.

Exact simulation with deterministic coins #

The coin function read off a deterministic coin oracle on request words.

noncomputable def Cslib.Crypto.TreeSignature.evalDet (c : List Bool → List Bool) {α : Type} (program : Probability.WordOracleComp Unit α) :
PMF α

The law of an oracle program whose coin requests are answered by the deterministic function c on request words, with fresh private coins.

@[simp]
@[simp]
theorem Cslib.Crypto.TreeSignature.evalDet_bind (c : List Bool → List Bool) {α β : Type} (program : Probability.WordOracleComp Unit α) (next : α → Probability.WordOracleComp Unit β) :
evalDet c (program >>= next) = (evalDet c program).bind fun (a : α) => evalDet c (next a)
@[simp]
theorem Cslib.Crypto.TreeSignature.evalDet_map (c : List Bool → List Bool) {α β : Type} (f : α → β) (program : Probability.WordOracleComp Unit α) :
evalDet c (f <$> program) = PMF.map f (evalDet c program)
@[simp]
@[simp]
theorem Cslib.Crypto.TreeSignature.evalDet_sample (c : List Bool → List Bool) {α : Type} (program : ProbComp α) :
evalDet c (ProbOracleComp.sample program) = program.eval
theorem Cslib.Crypto.TreeSignature.evalDet_signAtO {S : IndexedSignatureScheme} {T : S.Seeded} {c : List Bool → List Bool} (hc : ∀ (x : List Bool) (L : ℕ), (c ((Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encUnary) (x, L))).length ≤ L) (k path sk : List Bool) (u : ℕ) (msg : List Bool) :
evalDet c (signAtO S T path sk u msg) = PMF.pure (signAt S T (coinsOf c) k path sk u msg)

With deterministic coins, the oracle signer is the signer of the tree scheme under any secret key word (n, k): the coins do not depend on k.

theorem Cslib.Crypto.TreeSignature.evalDet_simulateTreeGame {S : IndexedSignatureScheme} {T : S.Seeded} {depth : ℕ → ℕ} {c : List Bool → List Bool} (hc : ∀ (x : List Bool) (L : ℕ), (c ((Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encUnary) (x, L))).length ≤ L) (adversary : Forger) (n : ℕ) (k : List Bool) :
evalDet c (simulateTreeGame S T depth adversary n) = ProbComp.eval (treeGameWith S T depth (coinsOf c) k adversary n)

With deterministic coins, the simulated game is the tree game under any secret k.

The tree game depends on the coins at the secret only #

theorem Cslib.Crypto.TreeSignature.nodeKey_congr {S : IndexedSignatureScheme} {T : S.Seeded} {coins coins' : List Bool → List Bool → ℕ → List Bool} {k k' : List Bool} (h : ∀ (x : List Bool) (L : ℕ), coins k x L = coins' k' x L) (n : ℕ) (path : List Bool) :
nodeKey S T coins n k path = nodeKey S T coins' n k' path
theorem Cslib.Crypto.TreeSignature.signAt_congr {S : IndexedSignatureScheme} {T : S.Seeded} {coins coins' : List Bool → List Bool → ℕ → List Bool} {k k' : List Bool} (h : ∀ (x : List Bool) (L : ℕ), coins k x L = coins' k' x L) (path sk : List Bool) (u : ℕ) (msg : List Bool) :
signAt S T coins k path sk u msg = signAt S T coins' k' path sk u msg
theorem Cslib.Crypto.TreeSignature.certify_congr {S : IndexedSignatureScheme} {T : S.Seeded} {coins coins' : List Bool → List Bool → ℕ → List Bool} {k k' : List Bool} (h : ∀ (x : List Bool) (L : ℕ), coins k x L = coins' k' x L) (n : ℕ) (bits : List Bool) :
certify S T coins n k bits = certify S T coins' n k' bits
theorem Cslib.Crypto.TreeSignature.signWithLeaf_congr {S : IndexedSignatureScheme} {T : S.Seeded} {coins coins' : List Bool → List Bool → ℕ → List Bool} {k k' : List Bool} (h : ∀ (x : List Bool) (L : ℕ), coins k x L = coins' k' x L) (n : ℕ) (leaf msg : List Bool) :
signWithLeaf S T coins n k leaf msg = signWithLeaf S T coins' n k' leaf msg
theorem Cslib.Crypto.TreeSignature.sign_congr {S : IndexedSignatureScheme} {T : S.Seeded} {depth : ℕ → ℕ} {coins coins' : List Bool → List Bool → ℕ → List Bool} {k k' : List Bool} (h : ∀ (x : List Bool) (L : ℕ), coins k x L = coins' k' x L) (n : ℕ) (msg : List Bool) :
theorem Cslib.Crypto.TreeSignature.treeGameWith_congr {S : IndexedSignatureScheme} {T : S.Seeded} {depth : ℕ → ℕ} {coins coins' : List Bool → List Bool → ℕ → List Bool} {k k' : List Bool} (h : ∀ (x : List Bool) (L : ℕ), coins k x L = coins' k' x L) (adversary : Forger) (n : ℕ) :
ProbComp.eval (treeGameWith S T depth coins k adversary n) = ProbComp.eval (treeGameWith S T depth coins' k' adversary n)

The tree game under a secret depends on the coins at that secret only.

theorem Cslib.Crypto.TreeSignature.eval_treeGame_tableCoins {S : IndexedSignatureScheme} {T : S.Seeded} {depth : ℕ → ℕ} (keyLen : ℕ → ℕ) (M : ℕ) (table : BitString M → BitString M) (adversary : Forger) (n : ℕ) :
ProbComp.eval (treeGame S T depth keyLen (tableCoins M table) adversary n) = ProbComp.eval (treeGameWith S T depth (tableCoins M table) [] adversary n)

Since tableCoins ignores the secret key, treeGame with tableCoins has the same law as treeGameWith at [] for any key-length schedule.

The coin games of the coin adversary #

theorem Cslib.Crypto.TreeSignature.treeCoinAdversary_apply {S : IndexedSignatureScheme} {T : S.Seeded} {depth N inv : ℕ → ℕ} (hinv : ∀ (n : ℕ), inv (N n) = n) (adversary : Forger) (n : ℕ) (aux : List Bool) :
treeCoinAdversary S T depth N inv adversary (N n) aux = simulateTreeGame S T depth adversary n

The coin adversary at N n plays the simulated game at n.

Evaluating against a stateless deterministic coin oracle is evalDet.

theorem Cslib.Crypto.TreeSignature.eval_coinRealGame_treeCoinAdversary {S : IndexedSignatureScheme} {T : S.Seeded} {depth N : ℕ → ℕ} (family : List Bool → List Bool → List Bool) {inv : ℕ → ℕ} (hinv : ∀ (n : ℕ), inv (N n) = n) (adversary : Forger) (n : ℕ) :
(coinRealGame family (treeCoinAdversary S T depth N inv adversary) (N n)).eval = ProbComp.eval (treeGame S T depth N (prfCoins family) adversary n)

Real coins: the coin adversary in the real coin game at N n plays the tree game with coins prfCoins family.

theorem Cslib.Crypto.TreeSignature.eval_coinIdealGame_treeCoinAdversary {S : IndexedSignatureScheme} {T : S.Seeded} {depth N inv : ℕ → ℕ} (hinv : ∀ (n : ℕ), inv (N n) = n) (adversary : Forger) (n : ℕ) :
(coinIdealGame (treeCoinAdversary S T depth N inv adversary) (N n)).eval = (treeIdealGame S T depth N adversary n).eval

Random coins: the coin adversary in the ideal coin game at N n plays the tree game with coins from a uniform random function on N n bits.

The hybrid bound #

theorem Cslib.Crypto.TreeSignature.succProbability_treeGame_le {S : IndexedSignatureScheme} {T : S.Seeded} {depth N : ℕ → ℕ} (family : List Bool → List Bool → List Bool) {inv : ℕ → ℕ} (hinv : ∀ (n : ℕ), inv (N n) = n) (adversary : Forger) (n : ℕ) :
Game.succProbability (ProbComp.eval (treeGame S T depth N (prfCoins family) adversary n)) ≤ Game.succProbability (treeIdealGame S T depth N adversary n).eval + Game.advantage (coinRealGame family (treeCoinAdversary S T depth N inv adversary) (N n)).eval (coinIdealGame (treeCoinAdversary S T depth N inv adversary) (N n)).eval

From pseudorandom to random coins: the forging probability against the tree scheme with coins from family is at most the forging probability with coins from a random function, plus the coin-game advantage of treeCoinAdversary at the PRF's parameter N n.

theorem Cslib.Crypto.TreeSignature.succProbability_treeGame_le_prf {S : IndexedSignatureScheme} {T : S.Seeded} {depth N : ℕ → ℕ} (family : List Bool → List Bool → List Bool) {inv : ℕ → ℕ} (hinv : ∀ (n : ℕ), inv (N n) = n) (adversary : Forger) (n : ℕ) :
Game.succProbability (ProbComp.eval (treeGame S T depth N (prfCoins family) adversary n)) ≤ Game.succProbability (treeIdealGame S T depth N adversary n).eval + Game.advantage (prfRealGame id family (coinDistinguisher (treeCoinAdversary S T depth N inv adversary)) (N n)).eval (prfIdealGame id id (coinDistinguisher (treeCoinAdversary S T depth N inv adversary)) (N n)).eval

From pseudorandom to random coins, in PRF advantage: the hybrid loss equals the PRF distinguishing advantage of coinDistinguisher (treeCoinAdversary …) at N n.

theorem Cslib.Crypto.TreeSignature.negligible_advantage_treeCoinAdversary_of_isOraclePPT {S : IndexedSignatureScheme} {T : S.Seeded} {depth N : ℕ → ℕ} (family : List Bool → List Bool → List Bool) {inv : ℕ → ℕ} (hF : PseudorandomFunction family) (hN : ∀ (n : ℕ), n ≤ N n) {adversary : Forger} (hB : Probability.IsOraclePPT Turing.MultiTapeTM.encBool (treeCoinAdversary S T depth N inv adversary)) :
Negligible fun (n : ℕ) => Game.advantage (coinRealGame family (treeCoinAdversary S T depth N inv adversary) (N n)).eval (coinIdealGame (treeCoinAdversary S T depth N inv adversary) (N n)).eval

The coin-game advantage of the coin adversary, read at N n, is negligible in n for a pseudorandom function and n ≤ N n, provided that the coin adversary is oracle-PPT (hB). This is an algebraic helper: exists_negligible_treeGame_le discharges hB with isOraclePPT_treeCoinAdversary.

Efficiency of the coin adversary #

A coin request with efficiently computed request and count is strict oracle PPT.

Polynomial bounds on derived keys and signatures #

A bound on a derived signature by a node whose secret key has length at most K, at an index at most 1, on a message of length at most L.

A reply to a coin request has at most the requested length.

Both components of a derived node key are bounded by savedCoinBudget.

A derived signature is bounded by sigBound.

theorem Cslib.Crypto.TreeSignature.sigBound_mono {cs ds cB dB K K' L L' : ℕ} (hK : K ≤ K') (hL : L ≤ L') :
sigBound cs ds cB dB K L ≤ sigBound cs ds cB dB K' L'

sigBound is monotone in both bounds.

Injective parameter schedule above any coin budget #

Pair n with budget n + 1 to obtain an injective PRF parameter schedule satisfying n ≤ coinParam budget n and budget n < coinParam budget n, without assuming budget is monotone.

Bounded-search left inverse of coinParam budget.

theorem Cslib.Crypto.TreeSignature.le_coinParam (budget : ℕ → ℕ) (n : ℕ) :
n ≤ coinParam budget n
theorem Cslib.Crypto.TreeSignature.lt_coinParam (budget : ℕ → ℕ) (n : ℕ) :
budget n < coinParam budget n
@[simp]
theorem Cslib.Crypto.TreeSignature.coinParamInv_coinParam (budget : ℕ → ℕ) (n : ℕ) :
coinParamInv budget (coinParam budget n) = n

The hybrid, with a negligible error #

Pseudorandom coins may be replaced by random coins: for a pseudorandom function, an oracle-PPT forger, polynomial-time depth, N with n ≤ N n and a polynomial-time left inverse inv of N, the forging probability against the tree scheme with coins prfCoins family exceeds the forging probability with random coins by a negligible function.

Pseudorandom coins at coinParam budget: for any polynomial-time unary budget, instantiating the PRF parameter at coinParam budget replaces prfCoins family with random function coins up to a negligible error, with no separate left-inverse hypothesis.