Dictionary searches against a hash oracle #
Offline dictionary attacks (18.1)–(18.3) of [BS23], Section 18.3.1.2–18.3.1.3
(pp. 721–723), together with the salted and secret-salt forms of Section 18.4.1–18.4.2
(pp. 724–726), modeled as programs with oracle access to H : X → Y.
dictionarySearch input accept D queries the oracle at input w for each w in D in list order
and stops at the first candidate whose reply satisfies accept. dictionaryPreimageSearch
specializes accept to equality with vk ((18.1)). dictionaryTable builds the preprocessing
table of (H (input w), w) pairs ((18.2)), and dictionaryBatchSearch runs one table lookup
per entry of F ((18.3)). dictionaryInverter turns dictionaryPreimageSearch into a PMF
inverter for inversionExperiment.
This formalization differs from the book's presentation as follows:
- List order.
Dis aList Psearched in list order rather than an unordered set; aFinsetdictionary is handled viaFinset.toList. - Exact oracle-query counts.
His an oracle and cost isOracleComp.IsQueryBounded, giving exact boundsD.lengthandF.length * D.lengthinstead ofO(|D|)andO(|D| × |F|). - Failure output. Searches return
Option P(nonewhen no candidate passes), where(18.1)prints no output and(18.2)prints "fail". - Parameterized input and test.
dictionarySearchtakesinput : P → Xandaccept : Y → Bool;(18.1)isinput := idandaccept := fun y => decide (y = vk), whileinput := (·, salt)gives the salted search. - Hash-keyed table.
dictionaryTablestores(H (input w), w)rather than(w, H(w))and is read byList.lookup. Lookups, comparisons, andacceptare uncounted; no constant-time lookup is claimed. - Batch bound.
(18.3)'s "attack timeO(|F|)" appears only asD.lengthoracle calls regardless ofF;O(|D| + |F|)vsO(|D| × |F|)appears as two upper bounds, without claiming the second bound is attained for every input. - Weak-secret distribution.
le_inversionExperiment_dictionaryInverterformalizes choosing a weak secret from an arbitrary distributionμover a small dictionary; the resulting probability lower boundμ.toOuterMeasure {pw | pw ∈ D} ≤ ...is this library's (the book states no probability, only the pointwise claim on p. 722 that ifpw ∈ Dthe adversary obtainspwor somepw'withH(pw) = H(pw')in timeO(|D|)). - Total
PMFinverter.dictionaryInverterreturnsdefaultwhen the search fails;[Inhabited P]is needed only there. - Recovering
pwitself. Returningpw(rather than somew ∈ DwithH (input w) = vk) is proved only underSet.InjOnofw ↦ H (input w)onD; "in all likelihood" is not claimed. - Salts and peppers. Salt and pepper spaces are parameters of the test instances; the book's
factor
4096ispeppers.length. - Universe
Type. All types live inType(0), asOracleComprequires.
No machine-time bound is certified here: comparisons, accept, and List.lookup are free, and no
polynomial-time certificate is stated (D is a parameter, and efficiency means "D.length oracle
evaluations").
Main definitions #
Cslib.Crypto.dictionarySearch: offline search(18.1)overDwith derived inputinputand reply testaccept.Cslib.Crypto.dictionaryTable: preprocessing phase of(18.2)producing(H (input w), w)pairs.Cslib.Crypto.dictionaryPreimageSearch: search(18.1)specialized to testingy = vk.Cslib.Crypto.dictionaryBatchSearch: batch search(18.3)building one table and looking up every entry ofF.Cslib.Crypto.dictionaryInverter:PMFinverter obtained by runningdictionaryPreimageSearchagainstH, returningdefaultonnone.
Main results #
Cslib.Crypto.evalPure_dictionarySearch: output characterization ofdictionarySearchagainstH(List.find?).Cslib.Crypto.isQueryBounded_dictionarySearch,Cslib.Crypto.not_isQueryBounded_dictionarySearch,Cslib.Crypto.queriesSatisfy_dictionarySearch: at mostD.lengthoracle calls on every path, all atinput wforw ∈ D; no smaller bound holds whenacceptrejects some reply.Cslib.Crypto.exists_evalPure_dictionarySearch_of_mem,Cslib.Crypto.evalPure_dictionarySearch_of_unique: success when the secret lies inDand passesaccept.Cslib.Crypto.evalPure_dictionaryTable,Cslib.Crypto.isQueryBounded_dictionaryTable,Cslib.Crypto.lookup_evalPure_dictionaryTable: table correctness, costD.length, and equivalence ofList.lookupwithdictionaryPreimageSearch.Cslib.Crypto.evalPure_dictionaryBatchSearch,Cslib.Crypto.isQueryBounded_dictionaryBatchSearch,Cslib.Crypto.isQueryBounded_mapM_dictionaryPreimageSearch: batch search matches separate searches inD.lengthcalls vsF.length * D.length.Cslib.Crypto.le_inversionExperiment_dictionaryInverter,Cslib.Crypto.dictionarySearch_inverts: for any secret distributionμ, the search winsinversionExperimentwith probability at leastμ {pw | pw ∈ D}using at mostD.lengthcalls on every challenge.
References #
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, Section 18.3.1.2–18.3.1.3, pp. 721–723, and Section 18.4.1–18.4.2, pp. 724–726.
The search (18.1) with any derived input and any test of the reply: for each candidate w of
D in order, ask the oracle at input w and stop at the first w whose reply passes
accept.
Against H, the search returns the first candidate that passes.
Cost of (18.1). At most one oracle call per candidate, on every path.
The search asks the oracle only at inputs of candidates.
An output is a candidate of the dictionary that passes the test.
The search fails exactly when no candidate passes.
Success of (18.1). If the secret is in the dictionary and passes the test, the search returns a candidate that passes: the secret, or another candidate the test cannot tell from it.
When only the secret passes, the search returns the secret.
One step of the search.
Preprocessing phase of (18.2). The list of pairs (H (input w), w) for w in D, in the
order of D and keyed by the hash, so that the attack phase is List.lookup.
Against H, the table lists each candidate with its hash.
Cost of the preprocessing phase. One oracle call per candidate.
The search (18.1): the first w in D with H (input w) = vk. With input := id this is the
book's procedure; input := (·, salt) is its salted form.
The book's claim after (18.1): if pw ∈ D, the search on vk = H(pw) returns pw or some
pw' with H(pw') = H(pw).
Attack phase of (18.2). Looking vk up in the table of D returns what the search (18.1)
returns. The lookup is core's List.lookup, a function of the table and vk alone: it has no
access to the oracle.
The batch search (18.3). One table, then one lookup for each entry of F.
The batch search answers each entry as a separate search (18.1) would.
Cost of (18.3). D.length oracle calls, whatever the number of entries.
Cost of separate searches. Running (18.1) once per entry, each entry e with its own
derived input (for example its own salt), costs at most F.length * D.length calls.
The search as an inverter for pw ↦ H (input pw): it returns default when the search
fails.
The inverter is the search (18.1) evaluated against H: the program that
isQueryBounded_dictionarySearch bounds.
Weak secrets. For any distribution μ of the secret, the search wins the inversion
experiment for pw ↦ H (input pw) at least as often as the secret lies in the dictionary.
The dictionary search against a weak secret. [BS23], Section 18.3.1.2 (p. 722)
states that if pw ∈ D, the adversary obtains pw or some pw' with H(pw) = H(pw') in time
O(|D|). Here, for every H, every derived input, and a secret drawn from an arbitrary
distribution μ on P, the search (18.1) over D makes at most D.length evaluations of H
on every challenge and wins inversionExperiment for pw ↦ H (input pw) with probability at
least μ.toOuterMeasure {pw | pw ∈ D} (this probability form is original to this library, not in
the book).