Documentation

CslibFrontier.Crypto.Protocols.AnonymousToken.RandomTargetPolyTime

Polynomial-time random-target reduction witnesses for anonymous tokens #

This module provides uniform strict oracle-PPT realizations, an original extracted-model word-level security theorem, and a query-bounded transfer lemma for Cslib.Crypto.AnonymousToken.reduceRedemptions (CslibFrontier/Crypto/Protocols/AnonymousToken/RandomTarget.lean).

Word-level adversaries operate on uniform List Bool encodings over a typed message family Message n and challenge count N n varying with the security parameter n : ℕ:

Main definitions #

Main results #

Query-bounded transfer lemma #

Encodings and checked claim-list decoders #

theorem Cslib.Crypto.AnonymousToken.encRedemptionPayload_message_budget {M : Type} (encM : M ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Payload M Unit} :
Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ (encRedemptionPayload encM) S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).message) encIn✝ encM S✝
@[reducible, inline]

The tuple of the fields of encRedemptionPayload.

theorem Cslib.Crypto.AnonymousToken.encRedemptionPayload_message_polyTime {M : Type} (encM : M ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → Payload M Unit} :
Turing.MultiTapeTM.ComputableInPolyTime g✝ encIn✝ (encRedemptionPayload encM) → Turing.MultiTapeTM.ComputableInPolyTime (fun (c : γ✝) => (g✝ c).message) encIn✝ encM
theorem Cslib.Crypto.AnonymousToken.encRedemptionPayload_opening_budget {M : Type} (encM : M ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Payload M Unit} :

Encode a unit-opening redemption payload (message, ()) with encUnit opening.

theorem Cslib.Crypto.AnonymousToken.encRedemptionPayload_mk_budget {M : Type} (encM : M ↪ List Bool) {γ : Type} {encIn : γ ↪ List Bool} {budget : γ → ℕ} {x0 : γ → M} {x1 : γ → Unit} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn encM budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn Turing.MultiTapeTM.encUnit budget) :
Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { message := x0 x, opening := x1 x }) encIn (encRedemptionPayload encM) budget
theorem Cslib.Crypto.AnonymousToken.encRedemptionPayload_mk_polyTime {M : Type} (encM : M ↪ List Bool) {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → M} {x1 : γ → Unit} (h0 : Turing.MultiTapeTM.ComputableInPolyTime x0 encIn encM) (h1 : Turing.MultiTapeTM.ComputableInPolyTime x1 encIn Turing.MultiTapeTM.encUnit) :
Turing.MultiTapeTM.ComputableInPolyTime (fun (x : γ) => { message := x0 x, opening := x1 x }) encIn (encRedemptionPayload encM)
theorem Cslib.Crypto.AnonymousToken.encRedemptionPayload_mk_inO {M : Type} (encM : M ↪ List Bool) {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → M} {T0 S0 : γ → ℕ} {x1 : γ → Unit} {T1 S1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn encM T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn Turing.MultiTapeTM.encUnit T1 S1) :
Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { message := x0 x, opening := x1 x }) encIn (encRedemptionPayload encM) (fun (x : γ) => T0 x + T1 x) fun (x : γ) => S0 x + S1 x
theorem Cslib.Crypto.AnonymousToken.encRedemptionToken_payload_polyTime {M : Type} (encM : M ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → Token M Unit (List Bool)} :
theorem Cslib.Crypto.AnonymousToken.encRedemptionToken_signature_budget {M : Type} (encM : M ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Token M Unit (List Bool)} :
@[reducible, inline]

The tuple of the fields of encRedemptionToken.

theorem Cslib.Crypto.AnonymousToken.encRedemptionToken_mk_polyTime {M : Type} (encM : M ↪ List Bool) {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → Payload M Unit} {x1 : γ → List Bool} (h0 : Turing.MultiTapeTM.ComputableInPolyTime x0 encIn (encRedemptionPayload encM)) (h1 : Turing.MultiTapeTM.ComputableInPolyTime x1 encIn Turing.MultiTapeTM.encBits) :
Turing.MultiTapeTM.ComputableInPolyTime (fun (x : γ) => { payload := x0 x, signature := x1 x }) encIn (encRedemptionToken encM)
theorem Cslib.Crypto.AnonymousToken.encRedemptionToken_mk_budget {M : Type} (encM : M ↪ List Bool) {γ : Type} {encIn : γ ↪ List Bool} {budget : γ → ℕ} {x0 : γ → Payload M Unit} {x1 : γ → List Bool} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn (encRedemptionPayload encM) budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn Turing.MultiTapeTM.encBits budget) :
Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { payload := x0 x, signature := x1 x }) encIn (encRedemptionToken encM) budget
theorem Cslib.Crypto.AnonymousToken.encRedemptionToken_payload_budget {M : Type} (encM : M ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Token M Unit (List Bool)} :
Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ (encRedemptionToken encM) S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).payload) encIn✝ (encRedemptionPayload encM) S✝
theorem Cslib.Crypto.AnonymousToken.encRedemptionToken_mk_inO {M : Type} (encM : M ↪ List Bool) {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → Payload M Unit} {T0 S0 : γ → ℕ} {x1 : γ → List Bool} {T1 S1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn (encRedemptionPayload encM) T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn Turing.MultiTapeTM.encBits T1 S1) :
Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { payload := x0 x, signature := x1 x }) encIn (encRedemptionToken encM) (fun (x : γ) => T0 x + T1 x) fun (x : γ) => S0 x + S1 x

Encode a unit-opening redemption token (payload, signature) with bit-string signature.

@[reducible, inline]

Encode a list of unit-opening redemption tokens.

Word-level one-more preimage claim pairing a challenge slot index with a candidate signature word.

  • index : ℕ

    Challenged slot index (encoded in binary encNat).

  • preimage : List Bool

    Candidate preimage/signature bit string (encBits).

theorem Cslib.Crypto.AnonymousToken.encWordClaim_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget x0 : γ → ℕ} {x1 : γ → List Bool} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn Turing.MultiTapeTM.encNat budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn Turing.MultiTapeTM.encBits budget) :
Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { index := x0 x, preimage := x1 x }) encIn encWordClaim budget
@[reducible, inline]

The tuple of the fields of encWordClaim.

theorem Cslib.Crypto.AnonymousToken.encWordClaim_index_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → WordClaim} :

Encode a WordClaim (index with encNat, preimage with encBits; identical word layout to encPair encNat encBits).

theorem Cslib.Crypto.AnonymousToken.encWordClaim_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 T0 S0 : γ → ℕ} {x1 : γ → List Bool} {T1 S1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn Turing.MultiTapeTM.encNat T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn Turing.MultiTapeTM.encBits T1 S1) :
Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { index := x0 x, preimage := x1 x }) encIn encWordClaim (fun (x : γ) => T0 x + T1 x) fun (x : γ) => S0 x + S1 x
theorem Cslib.Crypto.AnonymousToken.encWordClaim_preimage_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → WordClaim} :
@[reducible, inline]

Encode a list of binary-indexed WordClaim values.

Public (pk, targets) input passed to word-level redemption and one-more adversaries.

  • pk : List Bool

    Encoded public key word (encBits).

  • targets : List (List Bool)

    Encoded list of N n challenge target words (encList encBits).

theorem Cslib.Crypto.AnonymousToken.encWordTargetsInput_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → List Bool} {T0 S0 : γ → ℕ} {x1 : γ → List (List Bool)} {T1 S1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn Turing.MultiTapeTM.encBits T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encBits) T1 S1) :
Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { pk := x0 x, targets := x1 x }) encIn encWordTargetsInput (fun (x : γ) => T0 x + T1 x) fun (x : γ) => S0 x + S1 x
theorem Cslib.Crypto.AnonymousToken.encWordTargetsInput_pk_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → WordTargetsInput} :

Encode a WordTargetsInput (pk with encBits, targets with encList encBits; identical word layout to encPair encBits (encList encBits)).

Checked claim-list decoder at challenge size N: processes any bit string w through the total decoder Decoder.list (Decoder.pair Decoder.nat Decoder.bits) (so malformed non-codewords still yield decoded pairs depending on w), and rejects the entire claim list (none) whenever any decoded pair has out-of-range index i ≥ N.

Whenever the underlying raw pair parse of w consists of pairs (i, sig) with i < N (including when w is a malformed non-codeword), wordClaimListDecoder N w accepts and produces the corresponding Fin N claims.

@[simp]
theorem Cslib.Crypto.AnonymousToken.wordClaimListDecoder_encWordClaimList_map {α : Type} (N : ℕ) (xs : List α) (idx : α → Fin N) (sig : α → List Bool) :
wordClaimListDecoder N (encWordClaimList (List.map (fun (x : α) => { index := ↑(idx x), preimage := sig x }) xs)) = some (List.map (fun (x : α) => { index := idx x, preimage := sig x }) xs)

wordClaimListDecoder round-trips identically on every encoded list of valid Fin N claims.

Any out-of-range claim c with c.index ≥ N causes wordClaimListDecoder N to reject the entire encoded claim list (none).

Word adversaries, games, and reduceRedemptionsWord #

@[reducible, inline]

A word-level extracted redemption adversary receives (n, encWordTargetsInput ⟨pk, ys⟩), queries Unit × List Bool for bit-string signatures, and outputs unit-opening word tokens.

@[reducible, inline]

A word-level chosen-target one-more adversary receives (n, encWordTargetsInput ⟨pk, ys⟩), queries Unit × List Bool for bit-string signatures, and outputs an encoded encWordClaimList.

def Cslib.Crypto.AnonymousToken.WordRedemptionAdversary.toTyped {Message : Type} {encM : Message ↪ List Bool} (dec : Turing.MultiTapeTM.Decoder encM) (N : ℕ) (A : WordRedemptionAdversary) (n : ℕ) :
List Bool → (Fin N → List Bool) → ProbOracleComp (fun (x : List Bool) => List Bool) (List (Token Message Unit (List Bool)))

Convert a word-level redemption adversary to a typed adversary at security parameter n by processing every output token message through the total decoder dec : Decoder encM (so malformed message words yield whatever typed message dec.decode returns rather than being rejected as parse errors under a PartialDecoder).

Convert a word-level one-more adversary to a typed one-more adversary at security parameter n via wordClaimListDecoder N. Every non-codeword output is processed as the claim list returned by the underlying total decoder Decoder.list (Decoder.pair Decoder.nat Decoder.bits), and any decoded claim with an out-of-range index i ≥ N causes wordClaimListDecoder N to return none, which maps to [] (failing Signature.oneMoreAccept since budget + 1 ≥ 1).

noncomputable def Cslib.Crypto.AnonymousToken.extractedRedemptionWordGame (S : WordSignatureScheme) (N : ℕ → ℕ) (targets : (n : ℕ) → List Bool → ProbComp (Fin (N n) → List Bool)) (Message : ℕ → Type) [(n : ℕ) → DecidableEq (Message n)] (encM : (n : ℕ) → Message n ↪ List Bool) (dec : (n : ℕ) → Turing.MultiTapeTM.Decoder (encM n)) (slot : (n : ℕ) → Message n ↪ Fin (N n)) (budget : ℕ → ℕ) (A : WordRedemptionAdversary) (n : ℕ) :

Word-level extracted redemption experiment at security parameter n. Adversaries receive the full encWordTargetsInput ⟨pk, List.ofFn targets⟩ vector of length ≥ N n, and token messages are processed through dec n : Decoder (encM n).

noncomputable def Cslib.Crypto.AnonymousToken.oneMoreWordGame (S : WordSignatureScheme) (N : ℕ → ℕ) (targets : (n : ℕ) → List Bool → ProbComp (Fin (N n) → List Bool)) (budget : ℕ → ℕ) (B : WordOneMoreAdversary) (n : ℕ) :

Word-level chosen-target one-more experiment at security parameter n. Adversaries receive the full encWordTargetsInput ⟨pk, List.ofFn targets⟩ vector of length ≥ N n (so IsOraclePPT runtime is polynomial in n + N n, corresponding to PPT security when N n is polynomially bounded), and output words are processed through wordClaimListDecoder (N n).

def Cslib.Crypto.AnonymousToken.WordOneMoreUnforgeable (S : WordSignatureScheme) (N : ℕ → ℕ) (targets : (n : ℕ) → List Bool → ProbComp (Fin (N n) → List Bool)) (budget : ℕ → ℕ) :

Word-level chosen-target one-more unforgeability (novel to this library; closest source [BBB+26a], Definition 3.1, printed p. 7). Differs from [BBB+26a] Definition 3.1 in four respects: (1) adversaries run in the uniform strict oracle-PPT class IsOraclePPT encBits rather than non-uniform PPT; (2) targets is an explicit caller sampler rather than independent uniform target words (so colliding targets violate this premise); (3) oneMoreWordGame hands the full encoded target vector List.ofFn targets (length ≥ N n) in the input word, so adversary clocks are polynomial in n + N n (representing PPT one-more unforgeability when N n is polynomially bounded, whereas super-polynomial N n allows 2^{O(n)}-time adversaries); and (4) claim outputs are processed via the lenient total decoder wordClaimListDecoder (rejecting any index i ≥ N n, while decoding malformed bit words via Decoder.list (Decoder.pair Decoder.nat Decoder.bits)). No implication to or from [BBB+26a] Definition 3.1 is established here; it holds unconditionally at the pigeonhole boundary N n = 1 < budget n + 1 (wordOneMoreUnforgeable_one_slot), fails on colliding targets (not_wordOneMoreUnforgeable_constTargets), and for N n ≥ budget n + 1 with efficient targets proving it unconditionally would imply one-way functions.

Uniform word-level realization of RandomTarget.reduceRedemptions: runs A n input, keeps the first budget n + 1 tokens, maps each token's message word via binary slotWord n into a WordClaim, and encodes the claim list with encWordClaimList.

Efficiency and query certificates for reduceRedemptionsWord #

Input-uniform signing-query admissibility for word adversaries: adversary n input makes at most q signing-oracle queries on every input : List Bool. Unlike Game.WithinQueries (which only constrains input = []) and unlike IsOraclePPT, this bounds signing-oracle calls across all (pk, targets) inputs without bounding computational runtime.

reduceRedemptionsWord preserves WithinWordQueries with the exact same query budget.

Exact PMF correspondence and security reductions #

theorem Cslib.Crypto.AnonymousToken.eval_oneMoreWordGame_reduceRedemptionsWord_eq (S : WordSignatureScheme) (N : ℕ → ℕ) (targets : (n : ℕ) → List Bool → ProbComp (Fin (N n) → List Bool)) (budget : ℕ → ℕ) (slotWord : ℕ → List Bool → ℕ) (n : ℕ) {Message : Type} {encM : Message ↪ List Bool} (dec : Turing.MultiTapeTM.Decoder encM) (slot : Message ↪ Fin (N n)) (hslot : ∀ (w : List Bool), slotWord n w = ↑(slot (dec.decode w))) (A : WordRedemptionAdversary) :
(oneMoreWordGame S N targets budget (reduceRedemptionsWord budget slotWord A) n).eval = ProbComp.eval (Signature.oneMoreExperiment (S.toScheme n) (targets n) (budget n) (reduceRedemptions slot (budget n) (WordRedemptionAdversary.toTyped dec (N n) A n)))

oneMoreWordGame played by reduceRedemptionsWord budget slotWord A has the exact PMF law of Signature.oneMoreExperiment played by RandomTarget.reduceRedemptions whenever slotWord n w = (slot n ((dec n).decode w)).val.

theorem Cslib.Crypto.AnonymousToken.extractedRedemptionWordGame_succProbability_le (S : WordSignatureScheme) (N : ℕ → ℕ) (targets : (n : ℕ) → List Bool → ProbComp (Fin (N n) → List Bool)) (Message : ℕ → Type) [(n : ℕ) → DecidableEq (Message n)] (encM : (n : ℕ) → Message n ↪ List Bool) (dec : (n : ℕ) → Turing.MultiTapeTM.Decoder (encM n)) (slot : (n : ℕ) → Message n ↪ Fin (N n)) (budget : ℕ → ℕ) (slotWord : ℕ → List Bool → ℕ) (hslot : ∀ (n : ℕ) (w : List Bool), slotWord n w = ↑((slot n) ((dec n).decode w))) (A : WordRedemptionAdversary) (n : ℕ) :
Game.succProbability (extractedRedemptionWordGame S N targets Message encM dec slot budget A n).eval ≤ Game.succProbability (oneMoreWordGame S N targets budget (reduceRedemptionsWord budget slotWord A) n).eval

Finite success-probability reduction for the word-level redemption game against oneMoreWordGame.

theorem Cslib.Crypto.AnonymousToken.succWithin_extractedRedemptionWordGame_withinQueries (S : WordSignatureScheme) (N : ℕ → ℕ) (targets : (n : ℕ) → List Bool → ProbComp (Fin (N n) → List Bool)) (Message : ℕ → Type) [(n : ℕ) → DecidableEq (Message n)] (encM : (n : ℕ) → Message n ↪ List Bool) (dec : (n : ℕ) → Turing.MultiTapeTM.Decoder (encM n)) (slot : (n : ℕ) → Message n ↪ Fin (N n)) (budget : ℕ → ℕ) (slotWord : ℕ → List Bool → ℕ) (hslot : ∀ (n : ℕ) (w : List Bool), slotWord n w = ↑((slot n) ((dec n).decode w))) {ε : ℕ → ℕ → NNReal} (hOneMore : Game.SuccWithin (fun (B : WordOneMoreAdversary) (n : ℕ) => (oneMoreWordGame S N targets budget B n).eval) WithinWordQueries ε) :
Game.SuccWithin (fun (A : WordRedemptionAdversary) (n : ℕ) => (extractedRedemptionWordGame S N targets Message encM dec slot budget A n).eval) WithinWordQueries ε

Query-bounded transfer lemma (Game.SuccWithin over WithinWordQueries): any concrete q-query bound ε n q for oneMoreWordGame transfers to extractedRedemptionWordGame with loss 1, error 0, and identical signing-query budget q. This lemma bounds signing-oracle calls only (not computational runtime), unlike negligible_extractedRedemptionWordGame_of_wordOneMoreUnforgeable, which enforces uniform strict IsOraclePPT encBits.

theorem Cslib.Crypto.AnonymousToken.negligible_extractedRedemptionWordGame_of_wordOneMoreUnforgeable (S : WordSignatureScheme) (N : ℕ → ℕ) (targets : (n : ℕ) → List Bool → ProbComp (Fin (N n) → List Bool)) (Message : ℕ → Type) [(n : ℕ) → DecidableEq (Message n)] (encM : (n : ℕ) → Message n ↪ List Bool) (dec : (n : ℕ) → Turing.MultiTapeTM.Decoder (encM n)) (slot : (n : ℕ) → Message n ↪ Fin (N n)) (budget : ℕ → ℕ) (slotWord : ℕ → List Bool → ℕ) (hOneMore : WordOneMoreUnforgeable S N targets budget) (hbudget : Turing.MultiTapeTM.ComputableInPolyTime (fun (n : ℕ) => budget n + 1) Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) (hslot : Turing.MultiTapeTM.ComputableInPolyTime (fun (p : ℕ × List Bool) => slotWord p.1 p.2) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encNat) (hslotEq : ∀ (n : ℕ) (w : List Bool), slotWord n w = ↑((slot n) ((dec n).decode w))) (A : WordRedemptionAdversary) (hA : Probability.IsOraclePPT (encRedemptionTokenList Turing.MultiTapeTM.encBits) A) :
Negligible fun (n : ℕ) => Game.succProbability (extractedRedemptionWordGame S N targets Message encM dec slot budget A n).eval

Original asymptotic word-level redemption step in the extracted random-target model: assuming WordOneMoreUnforgeable S N targets budget against uniform strict IsOraclePPT encBits adversaries (representing PPT one-more hardness when N n is polynomially bounded, since oneMoreWordGame passes List.ofFn targets in the input word), and polynomial-time n ↦ budget n + 1 and slotWord, every uniform strict IsOraclePPT adversary A has negligible success probability in extractedRedemptionWordGame.