Documentation

CslibFrontier.Crypto.Protocols.UOV.HashAndSignPolyTime.Basic

Word encodings, trapdoor preimage systems, and shared UOV ROM helpers #

Defines framed word encodings and strict parsers, WordTrapdoorPreimageSystem, wordDetScheme, wordSaltedScheme, bounded-preimage typed adapters (toBoundedTyped), and shared polynomial-time list/oracle/sampling utilities used across the UOV ROM reduction modules.

Word-level encodings, decoders, and strict target/salt/preimage parsing #

@[reducible, inline]

Framed word encoding for (word, preimageOpt) pairs such as (salt, xOpt) and (target, xOpt).

@[reducible, inline]

Framed word encoding for trapdoor system arguments (1ⁿ, (key, word)).

@[reducible, inline]

Framed word encoding for ROM verification-query inputs ((1ⁿ, pk), (msg, sig)).

@[reducible, inline]

Framed word encoding for ROM verification-check inputs (((1ⁿ, pk), (msg, sig)), digest).

Partial-style preimage option decoding matching encOption encBits exactly: [] and words not starting with true decode to none, while true :: s decodes to some s.

Canonical membership test for encPair encBits encBits: holds iff w equals the re-encoding of (unframe w, dropFrame w).

Decode a candidate salted signature w : List Bool as raw salt bits and an optional preimage (rBits, xOpt), rejecting malformed framings or salt lengths as (List.replicate sLen false, none).

Decode a candidate salted signature w : List Bool into BitString sLen × Option (List Bool), rejecting malformed framings, salt lengths, or option tags as (fun _ => false, none).

Decode a raw hash query word w into Option (List Bool × BitString sLen), returning some exactly on valid encPair encBits encBits (m, encBitString sLen r) encodings.

Parse a word-level (y, xOpt) oracle answer as (BitString tLen × Option (List Bool)) without rejecting malformed option encodings except as none.

Word-level trapdoor preimage systems, INV, and PS #

Uniform PPT trapdoor-preimage signature core on word keys/preimages and fixed-width bit-string targets BitString (targetLen n).

Word-level target verification for optional preimages.

Typed TrapdoorPreimageSystem induced by sys at parameter n on targets BitString (sys.targetLen n).

Real word PS sample: draw y ← BitString.sampleList (sys.targetLen n) and invert it.

Simulated word PS sample: draw s ← sys.samplePreimage n pk and return (eval n pk s, some s).

theorem Cslib.Crypto.UOV.HashAndSign.WordTrapdoorPreimageSystem.exists_bounds (sys : WordTrapdoorPreimageSystem) :
∃ (keyBound : ℕ → ℕ) (psBound : ℕ → ℕ), Turing.MultiTapeTM.ComputableInPolyTime keyBound Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary ∧ Turing.MultiTapeTM.ComputableInPolyTime psBound Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary ∧ (∀ (n : ℕ), ∀ keys ∈ (sys.keyGen n).eval.support, keys.1.length ≤ keyBound n ∧ keys.2.length ≤ keyBound n) ∧ (∀ (n : ℕ), ∀ keys ∈ (sys.keyGen n).eval.support, ∀ p ∈ (sys.wordSampleRealPair n keys.2).eval.support, (encWordOptPair p).length ≤ psBound n) ∧ ∀ (n : ℕ), ∀ keys ∈ (sys.keyGen n).eval.support, ∀ p ∈ (sys.wordSampleSimPair n keys.1).eval.support, (encWordOptPair p).length ≤ psBound n

Combined polynomial length bound on (1ⁿ, pk, sk) supports for (pk, sk) ← sys.keyGen n together with y (length = sys.targetLen n), (sys.invert n sk y), and (sys.samplePreimage n pk): provides uniform pk.length ≤ keyBound n and encoded PS reply bound psReplyBound n.

@[reducible, inline]

Word-level target preimage inverter (INV adversary): receives (n, (pk, y)) and outputs an optional candidate preimage Option (List Bool).

Typed view of a word preimage inverter at parameter n.

Word-level uniform target inversion (INV) experiment.

Word-level preimage resistance (INV, [KosugeXagawa2022], Section 2.2, Figure 3, and Definition 4, pp. 8–9): every uniform classical strict-PPT WordPreimageInverter succeeds in wordTargetGame with negligible probability.

@[reducible, inline]

Word-level preimage simulatability (PS) distinguisher: queries the Unit oracle for an encoded (y, xOpt) pair and outputs a Boolean bit.

Typed view of a WordPSDistinguisher at parameter n, encoding oracle answers (y, xOpt) via encPair encBits (encOption encBits).

Real word PS experiment (b = 0).

Word-level preimage simulatability (PS, novel to this library; closest source: [KosugeXagawa2022], Section 2.3, Figure 4 (PS) and Definition 7, p. 10): wordPsGameReal and wordPsGameSim are indistinguishable to every uniform classical strict oracle-PPT WordPSDistinguisher.

Implies [KosugeXagawa2022] Definition 7 (PS): a 1-query distinguisher checking xOpt.isSome forces negligible invert failure probability, so retrying none shifts a q-query view negligibly, and dropping y recovers Fig. 4. The converse fails for samplers that fail non-negligibly on valid conditional distributions (for instance, for a system where eval ∘ samplePreimage is uniform on targets, a sampler returning none with probability 1 / 2 and otherwise matching samplePreimage conditioned on eval: Fig. 4's retry hides the failures, while xOpt.isSome separates the no-retry games). Unlike Fig. 4, real samples keep none failures without retrying and expose (y, xOpt) rather than xOpt alone. The accompanying test suite exhibits both a satisfiable identity system and a constant-none failing instance.

Why it is plausible. Any trapdoor sampler whose conditional invert law matches samplePreimage up to negligible distinguishing advantage and whose none failure rate is negligible satisfies WordPreimageSimulatable as well as Definition 7.

Shared polynomial-time word cache, reply decoding, and query-domain helpers #

Decode a word-level (y, xOpt) oracle reply preserving raw target bits bounded by tLen.

Boolean validity check matching parseSaltedQuery? sLen w |>.isSome.

@[reducible, inline]

Finite subtype of bit words of length at most m, used to restrict preimage spaces at fixed security parameter n.

Instances For

    Finiteness of BoundedWord m via its injection into BitString m × Fin (m + 1).

    Polynomial upper bound on preimage lengths produced by sys.invert n.

    Clip an optional word preimage to BoundedWord bound, rejecting longer words as none.

    Idealized per-target random inversion table sampled from sys.invert and clipped at sysInvBound sys n.

    Word ROM signature schemes (wordDetScheme and wordSaltedScheme) #

    @[reducible, inline]

    Non-dependent secret key type for wordDetScheme: (sk, invTable) where invTable maps raw target words to optional preimages.

    Deterministic unsalted word-level ROM hash-and-sign scheme backed by sys. The secret key carries a truly random preimage-inversion table (wordInvTable, with no PRF derandomization and no retry on none), so signing is idealized rather than polynomial-time.

    Salted word-level ROM hash-and-sign scheme backed by sys and salt bit width saltLen n. Per-signature signing coins carry a uniform salt and a truly random preimage-inversion table (wordInvTable, with no PRF derandomization and no retry on none), so signing is idealized rather than polynomial-time.

    Completeness of wordDetScheme: when (sys.toTyped n).InvertCorrect holds, every signature produced by wordDetScheme sys n verifies under the same random-oracle cache.

    theorem Cslib.Crypto.UOV.HashAndSign.wordSaltedScheme_correct (sys : WordTrapdoorPreimageSystem) (saltLen : ℕ → ℕ) (hcorr : ∀ (n : ℕ), (sys.toTyped n).InvertCorrect) (n : ℕ) :
    (wordSaltedScheme sys saltLen n).Correct

    Completeness of wordSaltedScheme: when (sys.toTyped n).InvertCorrect holds, every signature produced by wordSaltedScheme sys saltLen n verifies under the same random-oracle cache.