{'fraction_non_alphanumeric': 0.04366223379521994, 'fraction_numerical': 0.011578164233237237, 'mean_word_length': 4.05254708485062, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 15, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Password Cracking: The Effect of Hash Function Bias on the Average Guesswork

Modern authentication systems store hashed values of passwords of users using cryptographic hash functions. Therefore, to crack a password an attacker needs to guess a hash function input that is mapped to the hashed value, as opposed to the password itself. We call a hash function that maps the same number of inputs to each bin, as \textbf{unbiased}. However, cryptographic hash functions in use have not been proven to be unbiased (i.e., they may have an unequal number of inputs mapped to different bins). A cryptographic hash function has the property that it is computationally difficult to find an input mapped to a bin. In this work we introduce a structured notion of biased hash functions for which we analyze the average guesswork under certain types of brute force attacks. This work shows that the level of security depends on the set of hashed values of valid users as well as the statistical profile of a hash function, resulting from bias. We examine the average guesswork conditioned on the set of hashed values, and model the statistical profile through the empirical distribution of the number of inputs that are mapped to a bin. In particular, we focus on a class of statistical profiles (capturing the bias) , which we call type-class statistical profiles, that has an empirical distribution related to the probability of the type classes defined in the method of types. For such profiles, we show that the average guesswork is related to basic measures in information theory such as entropy and divergence. We use this to show that the effect of bias on the conditional average guesswork is limited compared to other system parameters such as the number of valid users who store their hashed passwords in the system.


I. INTRODUCTION
A password is a means to authenticate users by allowing access only to an authorized user who knows it. Modern systems do not store the password of a valid user in plain text but rather hash it (a many to one mapping) and store its hashed value, which is paired with a user name. This in turn protects the passwords of valid users when the system is compromised [1], [2]. In order to gain access to a system a user provides the system with his user name and his password; the system then calculates its hash value and compares it to the one it has on file.
The most prevalent method of protecting passwords is using cryptographic hash functions whose output can be computed easily but cannot be inverted easily [3], [4], [5], [1], [2]. Essentially, cryptographic hash functions are the "workhorses of modern cryptography" [6] and, among other things, enable systems to protect passwords against attackers that break into their servers. In some cases such as message authentication codes (MAC) [7] it is meaningful to consider keyed hash functions. Keyed hash functions can be viewed as a set of hash functions, where the actual function which is used is determined by the value assigned to the key, which is a secret [8]. A practical keyed hash function that enables the use of off-the-shelf computationally secure hash functions, is a keyed-hash message authentication code (HMAC) [7].
Modern systems store for every user a user name along with a hash value of its password; in this paper the set of hash values of the passwords of valid users is referred to as the set of occupied bins, which is denoted by B. A common assumption that is usually made is that the hash functions are unbiased, that is, every possible output of the hash function has the same number of inputs mapped to it. However, this assumption has not been proved for cryptographic hash functions used in practice, and they can be biased.
The material in this paper was presented in part at the International Symposium on Information Theory (ISIT), 2016. The work of the authors was partially supported by the NSF awards 1740047 and by the UC-NL grant LFR- 18-548554. In this work we define bias based on the statistical profile of a hash function, which is basically the empirical distribution induced by the number of inputs that are mapped to every bin; in this sense bias means that the number of inputs that are mapped to every bin changes across bins. In terms of the set of occupied bins it means that some hash values of passwords are more vulnerable than others (unlike the unbiased case where every element in the set of occupied bins is equally protected). Indeed, this work addresses the question of how bias affects the level of security in terms of password cracking.
A basic type of attacks for cracking passwords are brute force attacks, where an attacker who does not know the structure of the hash function guesses inputs one by one until it finds an input that is mapped to an element in the set of occupied bins. We consider two brute force attacks: A remote attack where an attacker tries to break into an account of a user by guessing an input that has the same hash value as the hash value of the password of that user; and an insider attack, where an attacker has an insider access to all user-names and hash values of their passwords. This enables it to compare the hashed values of his guesses against every element in the set of occupied bins, that is, it should guess an input whose hash value is equal to any of the elements in the set of occupied bins, to satisfy its goal of finding one valid user-name password pair. Note that in both cases, the attacker does not know which inputs (passwords) map to which bin, and can only check by applying the (unknown) hash function.
For brute force attacks, a meaningful measure of the level of security is guesswork. Guesswork is the number of attempts required to successfully guess a secret. The guesswork is a random variable whose probability mass function depends on the statistical profile according to which a secret is chosen (e.g., when there is bias in terms of the way the secret is drawn at random) along with the strategy used for guessing. It was first introduced and analyzed by Massey [9] who lower bounded the average guesswork by the Shannon entropy. Arikan showed that the rate at which any moment of the guesswork increases is actually equal to the Rényi entropy [10], and is larger than the Shannon entropy unless the secret is uniformly distributed in which case both are equal. Guesswork has been analyzed in many other scenarios such as guessing up to a certain level of distortion [11], guessing under source uncertainty with and without side information [12], [13], using guesswork to lower bound the complexity of sequential decoding [10], guesswork for Markov chains [14], guesswork under a certain probability of failure of the attack [15], guesswork for the Shannon cipher system [16] as well as other applications in security [17], [18], [19], [20], [21], [22], [23], [24]. As far as we know there has been no systematic study of guesswork for hash functions.
A hash function is non-injective. Therefore an attacker only has to guess a password that has the same hash value as the original password, and not necessarily the password of the user. In the presence of bias, and under the assumption that the attacker does not know the structure of the hash function, the problem of guesswork for cracking passwords deviates away from the classic definition of guesswork where an attacker is trying to correctly guess the exact secret. The reason for this is that in the problem of password cracking the attacker cannot guess bins (outputs of a hash function) directly. In fact, the attacker can only guess inputs to the hash function, since it does not a-priori know to what bins they are mapped. Note that for crytographic hash functions, finding the inputs corresponding to the particular bin is computationally difficult.
In order to capture the effect of bias on hash functions under brute force attacks we define a new concept, the conditional average guesswork conditioned on the set of occupied bins; in the presence of bias the average guesswork may change as a function of the hash values to which passwords are mapped. Since the conditional average guesswork may change as a function of the set of occupied bins, we define the maximum and the minimum conditional average guesswork (i.e., find the set of occupied bins that maximizes/minimizes the conditional average guesswork). Furthermore, we define the most likely conditional average guesswork, which is basically the conditional average guesswork that is most likely to occur, assuming that passwords and as a result the set of occupied bins are drawn at random. Furthermore, we also consider the unconditional average guesswork, which is basically the average over the conditional average guesswork.
We focus on the type-class statistical profile, where the empirical distribution is the same as the probability of a given type in the method of types, when the dominant type-class is p 1 . The first main result of this paper studies the problem for such a class of statistical profiles using the tools from the method of types [25]. For such a profile, when the most likely (dominant) type-class has distribution p, with a subset of 2 H(p)·m bins out of the entire set of bins (in total 2 m bins when every bin is represented by a binary string of length m), having this distribution. For such hash functions we show that the most likely conditional average guesswork under an insider attack increases like 2 (H(p)−R)·m , where H (p) is the binary Shannon entropy, 2 R·m is the number of users, 0 ≤ R ≤ H (p), and p parameterizes the bias. Furthermore, when R < H (p) /2 the probability for the most likely conditional average guesswork goes to 1 with m.
The expression above reveals an interesting connection between the effect of bias on the level of security and the effect of increasing the number of users in a system. Basically, increasing the number of users has a far greater effect in terms of average guesswork. In addition, the rate at which the conditional average guesswork increases depends on the Shannon entropy rather than Rényi entropy [10], which is the dominated term in classic results on guesswork. We also present a concentration result showing that the most likely conditional average guesswork is also the most likely actual number of guesses, and also that the event where the number of guesses reaches this average is not an atypical event (on the other hand, in classic results on guesswork the event where the number of guesses hits the average guesswork is an atypical event). The mechanism that leads to concentration and why it is different from classical guesswork, is described in Subsection VI-A. Essentially, it results from the fact that there is a super exponential number of possible hash functions, whereas the maximum number of guesses increases exponentially.
Furthermore, the maximum conditional average guesswork as a function of the type-class of the statistical profile increases like 2 m·D(s||p) , where the number of users is 2 R·m = 2 H(s)·m , 1/2 ≤ s ≤ 1, and D (·||·) is the Kullback-Leibler divergence, used above for Bernoulli (s) and Bernoulli (p) distributions. Note that this function is unbounded as a function of p, that is, as p decreases and bias in the hash function increases, the exponent of the maximum conditional average guesswork increases unboundedly (as a function of the number of bins 2 m , not the number of inputs which is always greater). The reason for this is that the non-uniform distribution makes it harder to guess inputs that are mapped to the less likely bins. Other than the results presented above this paper contains more results on the average guesswork under remote and insider attacks. We present however only some of the results in the introduction for clarity.
Another question that this work addresses is whether or not bias can be used to increase the average guesswork. It is shown in this paper that indeed bias can increase the average guesswork as long as there is a backdoor mechanism that the system can use that enables it to map passwords of users to the least likely bins. An efficient backdoor mechanism is presented and it is shown that under a remote attack the average guesswork increases like 2 (2H(p)+D(1−p||p)−R)·m . Note that again, the exponent of the average guesswork increases unboundedly as p decreases (i.e., the bias increases).
Another set of results in this paper analyze the average guesswork for strongly universal hash functions when the key according to which hash functions are chosen is biased. For the case where the binary elements of the key are drawn i.i.d. Bernoulli(p) it is shown that when a backdoor mechanism is in place (similar to the one discussed above) and when considering a target average guesswork, the length of a biased key required to achieve this target is shorter than the length of a key that is drawn uniformly (i.e., i.i.d. Bernoulli(1/2)).
This paper presents new definitions and results on the average guesswork of hash functions. For better understanding of the structure of the paper it is recommended to go to Section VIII, which outlines the main technical results and points to where they can be found. In addition, to better understand the mechanism that leads to concentration and how it is different from classical guesswork, we recommend to go to Subsection VI-A.
The paper is organized as follows. We begin in Section II with background and basic definitions. The attack model is presented in Section III, followed by general expressions for the average guesswork of a bin in Section IV. We then present in Section V bounds on the conditional average guesswork under remote and insider attacks, and the average guesswork along with concentration result in Section VI. The most likely average guesswork is analyzed in Section VII, followed by overview of the results in Section VIII. We present in Section IX the case where hash functions can be modified, and analysis of the average guesswork of strongly universal hash functions in Section X. Finally, Section XI shows that a shorter biased key can achieve the same average guesswork as a longer uniform key.

II. BACKGROUND AND BASIC DEFINITIONS
In this section we present basic definitions and results in the literature that we use throughout the paper.

A. Guesswork
Consider the following game: Bob draws a sample x from a random variable X, and an attacker Alice who does not know x but knows the probability mass function P X (·), tries to guess it. An oracle tells Alice whether her guess is right or wrong.
The number of guesses it takes Alice to guess x successfully is a random variable G (X) (which is termed guesswork) that takes only positive integer values. The optimal strategy of guessing X that minimizes all non negative moments of G (X) is guessing elements in X based on their probabilities in descending order [9], [10], such that G (x) < G (x ′ ) implies p X (x) > p X (x ′ ), i.e. a dictionary attack [26]; where G (x) is the number of guesses after which the attacker guesses x. In this paper we analyze the optimal guesswork and therefore with slight abuse of notations we define G (X) to be the optimal guesswork. It has been shown that E (G (X) ρ ) is dictated by the Rényi entropy [10] For example, when drawing a random vector X of length k, which is independent and identically distributed (i.i.d.) with distribution P = [p 1 , . . . , p M ], the exponential growth rate of the average guesswork scales according to the Rényi entropy H α (X) with parameter α = 1/2 [10]: where H 1 2 (P ) ≥ H (P ) = − x∈X p (x) log (p (x)) which is the Shannon entropy, with equality only for the uniform probability mass function. Furthermore, for any ρ ≥ 0 The definition of guesswork was also extended to the case where the attacker has a side information Y available [10]. In this case the average guesswork for Y = y is defined as G (X|Y = y), and the ρth moment of G (X|Y ) is Arikan [10] has bounded the ρth moment of the optimal guesswork, G (X|Y ), by 1+ρ (6) where M = |X| is the cardinality of X. Furthermore, in [10] it has been shown that when X and Y are identically and independently distributed (i.i.d.), the exponential growth rate of the optimal guesswork is where m is the size of X and Y , and is Rényi's conditional entropy of order 1 1+ρ [10].

B. Method of Types
In this paper we analyze the average guesswork of hash functions based on the method of types [25]. Therefore, we now present 2 basic results in method of types that are used throughout this paper.
Assume a binary vector X of size m, the realization x is of type q in case N (1|x) /m = q where N (1|x) is the number of occurrences of the number 1 in the binary vector x.
The first result is related to the probability of drawing a vector of type q when the underlying probability is i.i.d. Bernoulli(p). Lemma 1 ([25] Theorem 11.1.2). The probability Q (q) = P (N (1|x) /m = q) which is the probability that x is of type q, is equal to where D (q||p) = i q i log (q i /p i ) is the Kullback-Leibler divergence [25].
The next lemma bounds the number of elements for each type.
Lemma 2 ([25] Theorem 11.1.3). The number of elements for which N (1|x) /m = q is bounded by the following terms

C. Hash Functions and their Statistical Profile
A hash function, H F (·), is a mapping from a larger domain A to a smaller range B. In this work we assume that the input is of length n bits whereas the output is m bits long, where n > m. We term the binary string of length m that represents the output of a hash function bin which is denoted by b ∈ {1, . . . , 2 m }.
For the analysis of the average guesswork of hash functions, we define the statistical profile of a hash function which is a probability mass function defined over the set of bins, where each element is defined as the relative number of inputs that are mapped to a bin. For this, we use the following definition throughout the paper. Definition 1 (Statistical profile of a hash function). Consider a hash function H F (·) with an input of size 2 n and an output of size 2 m , where n > m. The statistical profile of H F (·) is denoted by P H , and defined as follows Thus, for every bin P H is the relative number of inputs that are mapped to it.

Definition 2.
A P H -hash function is a hash function H F (·) whose statistical profile is P H . Example 1. When the relative number of inputs that are mapped to a bin is the same across all bins in Remark 1. Basically a P H -hash function can be represented by a bipartite graph, where the degree of every input is one, whereas the degree of every bin b ∈ {1, . . . , 2 m }, divided by 2 n is P H (b). Figure 1 illustrates this. Based on the definition above, a keyed hash function over a set of K hash functions H (·) can be written as follows where k ∈ {1, . . . , K}, and HK (·) is the keyed hash function.
III. THE ATTACK MODEL In this section we define the attack model based on how passwords are stored in systems. We present two types of attacks for this scenario: A remote attack and an insider attack.
The following definitions address the way passwords are stored in a system, and how access to a system is granted.
Definition 4 (Hashed password storage method). We define the method according to which the system stores passwords.
• There are M users registered in the system. • In order to access the system a user provides his user name and password.
• The system does not store the passwords, but rather stores the user names and the hashed values of the passwords. • The system hashes the password.
Definition 5 (Authentication scheme). The following protocol grants a user access.
• The user sends its user name to the system. • The system finds the bin value which is coupled with this user name. • The user types a password; the system hashes the password; if the hashed value matches the bin from the previous bullet, then access is granted.  Overall there are 2 m bins out of which the passwords are mapped to a subset B, which is termed the occupied bins. Note that U N represents user name, and P si represents the password of user i.
Essentially, Definition 6 states that in case we have K users whose passwords are {P s 1 , . . . , P s K }, then their passwords are mapped by a hash function H F (·) to the bins Next, we define two brute-force attack models under which we analyze the average guesswork. The first is a remote attack in which the attacker does not know the set of occupied bins. The second is an insider attack in which an attacker has insider access to the system so that it can see the set of occupied bins and test the hash function directly and compare the hashed values to the values in the set of occupied bins. Figure 4 illustrates the difference between these two types of attacks.
Definition 7 (A remote attack). The following steps define a remote attack: • The attacker does not know what the hash function is, that is, it does not know to which outputs (i.e., bins) the inputs of the hash function are mapped. 2 • The attacker does not know the passwords of the users; it also does not know the set of occupied bins. • The attacker can guess the passwords one by one; it can choose any strategy for guessing the passwords. • The attacker chooses a user name and then guesses passwords one by one. Once the attacker guesses a password that is mapped to the same bin as the password of the user, it has cracked the password and the game is over.

Server
User Names

Hashed Passwords Hash Function Password
User Name Access/No Access Figure 3. The user/attacker enters a user name and a password. The server hashes the password with a hash function, and compares its output to the value that is stored on the server for the user name that was entered. When the values match access is granted; otherwise access is denied.
Basically, Definition 7 states that the attacker does not know the structure of the hash function H F (·) that the system uses (or only knows the degree of the outputs in the bipartite graph representing this hash function, that is, its statistical profile). As an illustrative example consider the case where the attacker targets user 1 whose password P s 1 is mapped to H F (P s 1 ) = b 1 . The attacker can only guess inputs to the hash function one by one until he finds an input P s * such that H F (P s * ) = b 1 = H F (P s 1 ). Note that because the hash function is a many to one mapping, it is possible that P s * = P s 1 .
Definition 8 (An insider attack). We make the same assumptions as in Definition 7 (in particular it still does not know the hash function), with the exception that this time the attacker has insider access so that it can test the hash function directly and compare the hashed values of his guesses to the elements in the set of occupied bins, as it knows the user-name, and hashed password pairs.
• The password is cracked when the attacker finds a password that is mapped to any of the occupied bins.
The attack defined above essentially requires that the attacker finds an input P s * so that H F (P s * ) ∈ {b 1 , . . . , b K }. Note that this can happen even in the case where P s * ∈ {P s 1 , . . . , P s K }.

IV. GENERAL EXPRESSIONS FOR THE AVERAGE GUESSWORK OF A BIN
In this section we present general expression for the average guesswork of guessing an input that is mapped to a bin. We begin by presenting a set of hash functions with the same statistical profile, we then define averaging arguments for the average guesswork, and then we present the average guesswork per bin under these assumptions.
We now define a set of hash functions, consisting of hash functions that have the same statistical profile.  . An illustration of the difference between remote and insider attacks. Note that U N represents a user-name.
Definition 9 (The P H -set of hash functions). The P H -set of hash functions is the set of all hash functions whose statistical profile is P H as given in Definition 1; that is, for any hash function in the set and for every bin b ∈ {1, . . . , 2 m }, the relative number of inputs mapped to b is P H (b); the difference between the hash functions in this set is the actual inputs that are mapped to every bin.
Essentially, Definition 9 states the following: A hash function H * F ∈ P H -set of hash functions, if and only if its statistical profile P H * is equal to P H , that is, Remark 2. The P H -set of hash functions is basically all the bipartite graph representations whose output degrees divided by 2 n give P H (b), for every b ∈ {1, . . . , 2 m }. Therefore, it consists of all possible permutations of edges from inputs to bins that yield P H (b). Essentially, the definition above means that for every hash function H * F ∈ P H -set of hash functions, there is a key value associates with it. Bins Inputsb Permutation Figure 5. A PH-set of hash functions. The outputs (right hand side) are fixed whereas each hash function is a different permutation of the edges that go to the inputs (the left hand side).In terms of keyed hash functions it means that the key chooses a permutation (i.e., a hash function).
We now define the average guesswork for password cracking.
Definition 11 (The guesswork of hash functions). The following are the two types of guesswork that we analyze in this paper.
• The number of guesses of inputs required to find an input that is mapped to a particular bin b is G bin (b), where b ∈ {1, . . . , 2 m }. • Given a set of occupied bins B, the number of guesses of inputs required to find an input that is mapped to any element in B (rather than a particular element) is G insider (B).
This definition is in line with the attack models presented in Definition 7 and Definition 8. Guesswork is a random variable, where the number of guesses depends on a certain source of randomness. The following definition presents the source of randomness for the average guesswork of hash functions given a set of occupied bins.We present two methods for averaging guesswork, the first one is in line with classical guesswork, whereas the second can be used in the context of proof of work (see Remark 3). We put these definitions together as most of the theoretical results in the paper hold for both cases naturally. Furthermore, Equation (14), and Equation (15) illustrate definition 12.
Definition 12 (Averaging Arguments). We define two methods for averaging the number of guesses required to find an input that is mapped to a particular bin b (G bin (b)) as well as to any element in B (G insider (B)).
• A keyed P H -hash function: For any strategy of guessing passwords one by one we average over all hash functions whose statistical profile is P H (as presented in Figure 5). We average by assuming that a key which is uniformly distributed chooses an element form this set of hash functions. • A P H -hash function unknown to the attacker: In this case we average over all strategies of guessing passwords one by one. We assume that every strategy of guessing is equally likely to be chosen. 3 For simplicity let consider E (G bin (b)). Essentially, Definition 12 states that under the keyed P H -hash function assumption we get that for a given strategy of guessing inputs one by one, the average guesswork can be written as where H is the set of all P H -hash functions, and G bin (b|H F ) is the number of guesses required to find an input that is mapped to bin b under this given strategy of guessing inputs. On the other hand, Definition 12 states that under the P H -hash function unknown to the attacker assumption, we get that given a hash function H F (·) whose statistical profile is P H , the average guesswork can be written as where S is the set of all strategies of guessing passwords one by one, and G bin (b|S) is the number of guesses required to find an input that is mapped to bin b under strategy S for the function H F (·).

Remark 3.
Although averaging over all strategies of guessing passwords one by one is not natural for classical guesswork (where the user gets to choose the strategy), it is useful for guessing using nonce in the context of proof of work. In this case the attacker draws an input at random (nonce) at every step as an input to the hash function. This is equivalent to drawing a strategy for guessing passwords one by one.
Theorem 1 (Average number of guesses of a bin). Assume that the attacker guesses inputs to a hash function H F (·) whose statistical profile is P H until it finds an input (any input) that satisfies H F (P s * ) = b 0 , that is, an input that is mapped to bin b 0 . When P H (b 0 ) = 2 −α·m , α > 0, and under the averaging arguments of Definition 12 we get that when n ≥ (1 + ǫ 1 ) · α · m, ǫ 1 > 0, the average guesswork of bin b 0 , G bin (b 0 ), is equal to Sketch of proof. The general idea is that when n is large enough, the probability of finding an input that is mapped to bin b 0 converges to the geometric distribution P H (b) · (1 − P H (b)) i−1 , where i ≥ 1 is the number of guesses. The challenge in showing this lies in the fact that the chance of hitting this bin in the first guess is P H (b 0 ) under the averaging arguments presented in the previous section, whereas as the number of guesses increases the chance of guessing an input that is mapped to b 0 increases. The reason is that the attacker does not repeat his guesses and the ensemble of hash functions is based on permutation of the edges that are connected to the inputs ( Figure 5). When the input size is large enough and P H (b) decreases exponentially with m, the probability of guessing converges to geometric distribution which means that as m increases the average guesswork converges to 1/P H (b 0 ) = 2 α·m . The proof is in Section XIII.

Remark 4.
Note that under the assumptions of Theorem 1, the derivation of the average guesswork under an insider attack E (G insider (B)) is straightforward as long as b∈B P H (b) = 2 −α * ·m , where α * > 0.

FUNCTIONS
We begin this section by defining the conditional average guesswork under insider and remote attacks. We then define a type-class statistical profile that we use in this paper to model bias in hash functions. Finally, we present bounds on the average guesswork for both types of attacks.
In this section we analyze the average guesswork under insider and remote attacks for a type-class statistical profile, which we interchangeably use with the terminology P H -hash functions (the typeclass statistical profile that we consider in this paper is defined in this section). Essentially, this type-class statistical profile enables us to model bias for hash functions and also come up with closed form expressions for the average guesswork that shed light on the effect of bias on the level of security.
First, let us define the average guesswork under remote and insider attacks.
Definition 13 (The conditional average guesswork under a remote attack). Assume that the number of users is 2 R·m , where 0 ≤ R ≤ 1, as presented in Definition 6, and that their passwords are mapped to bins in the set B. The average guesswork under a remote attack conditioned on the set of occupied bins B, E (G remote (B)), is the average number of guesses required to find an input that is mapped to the same bin as the password of a user, averaged over all users.
The following lemma puts in equation form Definition 6.
Lemma 3. The conditional average guesswork under a remote attack for a set of occupied bins B (presented in Definition 6) can be written as follows: Proof. The proof is straight forward based on Definition 13. Remark 5. Note that G insider (B) can be viewed as an extension of G bin (b) to the case where a password has to hit a "super" bin, which is the set of occupied bins.
Remark 6. Note that G insider (B) and G remote (B) are conditioned on the set of occupied bins B, that is, they are a function of B. Basically it means that as B changes their underlying probability mass function as well as their average change too.
In order to find closed form expressions for as well as for E (G insider (B)), and in order to gain better understanding of the effect of bias on the level of security of hashed passwords, we make in Definition 15 an additional assumption about the statistical profile, that it is a type-class statistical profile, with P H specified in Definition 15.

Remark 7.
The results in this paper under the assumption made in Definition 15 also hold for any P H that is permutation of the mappings from b to P H .
Remark 8 (Motivation for analyzing under the method of types). The method of types means that elements in certain subsets of certain volumes are almost equally likely (e.g., in the most likely subset the probability of each element decreases at rate H (p)).
Based on Definition 15, we can express the average guesswork for any bin presented in Theorem 1 as follows.
Theorem 2 (Average number of guesses for each bin). Assume that the attacker guesses inputs of a P H -hash function one by one until it finds one that is mapped to bin b (remote or insider attacks). In this case, under the averaging arguments of Definition 12 we get that when n ≥ (1 + ǫ 1 ) · log (1/p) · m, ǫ 1 > 0, the average guesswork of G bin (b) is equal to where b ∈ {1, . . . , 2 m }, and q (b) = N (1|b) m is the type of b.
Sketch of proof. Similarly to Theorem 1 we show that the probability of hitting a bin converges to geometric distribution. This in turn means that the average guesswork of bin b ∈ {1, . . . , 2 m } can be achieved by assigning α = H (q (b)) + D (q (b) ||p), where this is achieved under the method of types and large deviation theory, which lead to P H (b) ≈ 2 −(H(q(b))+D(q(b)||p))·m . However, unlike Theorem 1 here we want guesswork to converge to geometric distribution for every b ∈ {1, . . . , 2 m }. This in turn leads to the bound n ≥ (1 + ǫ 1 ) · log (1/p) · m. The proof is in Section XIII.
Remark 9. The average guesswork (E (G remote (B)), E (G insider (B))) is a function of the bins stored in the system, that is, a function of the set of occupied bins B. Therefore, unlike guesswork for the classic case, in the case of hashed passwords it is meaningful to consider upper and lower bounds on the average guesswork. This can be expressed through the maximum and minimum average guesswork as a function of B and the number of users. The definition for maximum and minimum average guesswork can be found in Definition 26.
Next, we present bounds for the average guesswork. We assume that each password consists of n bits that are drawn i.i.d. Bernoulli(1/2). The assumption that passwords are drawn uniformly prevents the attacker form preferring one strategy of guessing password over the other, as long as he does not know the structure of the hash function. In order to derive the upper bound we assume that the passwords are mapped to the set of occupied bins that achieves maximum average guesswork, whereas in order to derive the lower bound we assume that passwords are mapped to the set of occupied bins whose average guesswork is minimum. We formally define the maximum and minimum conditional average guesswork in Definition 26.
In the following theorems we make a slight change of notations for representation purposes and write R = H (s), where 1/2 ≤ s ≤ 1.
Theorem 3 (Bounds on the conditional average guesswork under an insider attacks). The average guesswork under an insider attack is bounded as follows: Where we average based on Definition 12.
Sketch of proof. The general idea is bounding the average guesswork based on equation (114), (115) and the method of types, assuming that the set of occupied bins is the set of bins of size |B| = 2 H(s)·m−1 that occupies the 2 H(s)·m−1 bins with highest (lowest) degrees in the bipartite graph that represent P H . Basically, we show that the set of occupied bins whose bins have the highest degrees in P H achieves the maximum average guesswork, whereas the set of occupied bins whose bins have the lowest degrees, achieves the minimum, average guesswork. By finding the conditional average guesswork for these two sets of occupied bins, we come up with the bounds for the average guesswork. We also wish to point out that the the bound n ≥ (1 + ǫ) · m · log (1/p) where ǫ > 0, guarantees that the underlying probability of the conditional guesswork (based on Definition 12) converges to a geometric distribution with parameter P H (B) = b∈B P H (b) for every B; essentially, the log (1/p) guarantees that even after guessing a large number of inputs, the underlying probability of hitting bin b in the next guess is approximately P H (b), where this approximation holds uniformly for every b ∈ {1, . . . , 2 m }. The full proof appears in Section XIII.
Remark 10. The justification for the assumption that users are mapped to unique bins is based on Corollary 2 and Corollary 3 that show that for any practical purpose it is very likely that the passwords are mapped to unique bins. Essentially, the expressions can be modified to also reflect the case where users are not mapped to unique bins; however, this results in less elegant expressions.
We now find bounds for the average guesswork under a remote attack.
Theorem 4 (Bounds on the conditional average guesswork under a remote attack). The average guesswork when averaged according to Definition 12, is bounded by under the following assumptions: • There are 2 H(s)·m−1 users whose passwords are mapped to different (unique) bins, where 1/2 ≤ s ≤ 1; passwords are drawn i.i.d. Bernoulli(1/2). • P H is based on the method of types as presented in Definition 15, where p ≤ 1/2.
Proof. The full proof appears in Section XIII.
Remark 11 (Tightness of the bounds). Note that the bounds in equation (20) and equation (21) are tight in the sense that there exist sets of occupied bins whose average guesswork achieve those appear and lower bounds. In particular, the upper bound is achieved by the set of bins whose degree is maximum in the bipartite graph that represents the P H -set of hash functions, whereas the lower bound is achieved by the bins whose degrees are minimum.
Remark 12. Note that the upper bounds in equation (20) and equation (21) are unbounded functions that increase as p decreases; this means that the average guesswork over a set of 2 m bins can be larger than 2 m . This is possible because the guesses are done over the set of inputs to the hash function, whose size is 2 n combined with the fact that n ≥ log (1/p) · m. In particular, as p decreases these bounds become more asymptotic.
Remark 13. In this subsection we assume that passwords are drawn uniformly. When passwords are biased there is a certain optimal strategy [10] and therefore, there is no use of averaging over all possible strategies (i.e., the P H -hash function unknown to the attacker case in Definition 12); in this case averaging is done over a keyed P H -hash function as presented in Definition 12. Furthermore, similarly to Corollary 6 the average guesswork in this case is equal to the dominant term between the average number of guesses required to guess the password, and the average number of guesses required to guess a password that is mapped to the same bin.

VI. THE AVERAGE GUESSWORK OF TYPE-CLASS STATISTICAL PROFILE HASH FUNCTIONS
In this section we define the probability over the set of occupied bins induced by drawing passwords at random. Furthermore, we present the average guesswork averaged over all passwords under a remote attack as well as a concentration result for G bin (b). Finally, we explain why E (G bin (b)) is not affected by large deviations and show how it is different from classic average guesswork.
The fact that passwords of users are chosen at random induces a probability over the set of occupied bins B. It results from the fact that for a given hash function H F (·), choosing passwords at random leads to certain probability that a set B of occupied bins is occupied. Furthermore, when passwords are drawn uniformly and independently, the probability that these passwords occupy some set of occupied bins is the same across all hash functions in a P H -set of hash functions. These facts are defined and proven bellow.
Definition 16 (Probability over the set of occupied bins). Given a hash function H F (·), the fact that passwords of users are drawn at random according to some probability mass function, induces a probability mass function over the set of occupied bins, which we denote by P Lemma 4. Consider a P H -set of hash functions and assume that passwords of the users are drawn uniformly and independently over the set of inputs to these hash functions. In this case we get Proof. When considering the bipartite representation of every hash function in the P H -set of hash functions, based on Definition 1 of the statistical profile, one can see that the outputs have the same degree profile across bins. The only difference between hash functions in the set is permutations over the connections of edges to the inputs (see Remark 2 as well as Figure 5). The set of occupied bins is essentially a set of bins, and the probability of occupying a certain set of occupied bins B * = {b 1 , . . . , b K } is determined by the number of passwords that hit edges that are connected to bins {b 1 , . . . , b K }. Since passwords are drawn uniformly, permutations over the edges that go to the inputs ( Figure 5) lead to the same probability of hitting edges of the bins {b 1 , . . . , b k }. Therefore, P is the same for every H F ∈ P H -set of hash functions, and can be denoted by P B .
Essentially, Lemma 4 states that all hash functions in the ensemble have the same probability induced over the set of occupied bins as long as passwords are drawn uniformly and independently.
Next, we define the average guesswork, when averaging the conditional average guesswork over all sets of occupied bins.
Definition 17 (The average guesswork over all sets of occupied bins). The average guesswork over all sets of occupied bins is averaging E G remote/insider (B) over all possible sets of occupied bins B through P B . We denote this by E (G P (B)).
Lemma 5 (The average guesswork over the sets of all occupied bins). The average guesswork over all sets of occupied bins under a remote/insider attacks, when the average for every set of occupied bins is done according to Definition 12 is Proof. The proof is straight forward based on Definition 17.
can be viewed as the conditional average guesswork conditioned on the set of occupied bins B, whereas E (G P (B)) can be viewed as the average over the conditional average guesswork, that is, the average guesswork when averaging over all sets of occupied bins.
The next corollary presents the average guesswork under a remote attack when averaging over all passwords/set of occupied bins as presented in equation (23).
Corollary 1 (The Average Guesswork under a remote attack when averaged over all passwords/all sets of occupied bins). When each user chooses its password uniformly and passwords are statistically independent, the average guesswork under a remote attack when averaging over the passwords increases at rate that is equal to lim Sketch of proof. Basically, averaging over all passwords is equivalent to averaging over all possible sets of occupied bins. Based on Lemma 6 the conditional average guesswork under a remote attack can be broken into G bin (b) for every user. This in turn allows us to look at the probability that a password of a user is mapped to a certain bin rather than the entire probability over the set of occupied bins P B . When the passwords of the users are drawn i.i.d. from a uniform distribution the probability that a password is mapped to bin b and its average guesswork is in turn 1/P H (b) is P H (b); multiplying this two terms gives 1 for any b ∈ {1, . . . , 2 m }. The average is achieved by summing over all bins and so the average guesswork is 2 m as there are 2 m bins. This holds for every user and so when averaging over all users we also get that the average guesswork under a remote attack is 2 m . The lower bound on the input size is required so that as m increases the average guesswork converges to The full proof appears in Section XIII.
Remark 15. The fact that the probability that a password is mapped to some bin is the inverse of the average guesswork of that bin, as presented in Corollary 1, leads to average guesswork over all passwords that scales like 2 m which is larger than 2 m·H 1/2 (p) .
Finally, we provide a concentration result for G bin (b) (this also holds for the set of occupied bins).

Theorem 5 (Concentration result under both remote and insider attacks).
− lim where 0 < ǫ 1 < 1 and bin b is of type q (b), under the following assumptions: • P H is based on the method of types as presented in Definition 15, where p ≤ 1/2.
• Averaging according to Definition 12.
Proof. The proof is in Section XIII. A few remarks are in order.
Remark 16. From Theorem 5 we can state that for any P H -hash function and any bin, the fraction of strategies of guessing passwords one by one, for which the number of guesses is smaller than 2 (1−ǫ 1 )·(H(q(b))+D(q(b)||p))·m , decreases like 2 −ǫ 1 ·log(1/p)·m ; in addition, for the P H -set of hash functions, any bin and any strategy of guessing passwords one by one, the fraction of P H -hash functions for which the number of guesses is smaller than Remark 17. The concentration result of Theorem 5 shows that the probability mass function of G bin (b) is concentrated around its mean value E (G bin (b)). This is in contrast with classic average guesswork for guessing a password [10] in which case the probability mass function is concentrated around the typical set in the i.i.d. case, whereas the average guesswork can be derived based on a large deviations argument [14]. On the other hand, when averaging over all passwords as in Corollary 1 we get that the average guesswork E (G P (B)) lies in the tail of the probability mass function similarly to the classic case of [10].
A. Large Deviation Vs. Concentration: Another Difference From Classic Guesswork Theorem 5 along with Theorem 2 show that the probability mass function of G bin (b) is concentrated around its mean value. This is in contrast with classic guesswork [10] where the average guesswork is based on large deviations (i.e., the average lies in the tail of the probability mass function).
In this subsection we explain the mechanism that leads to concentration of the probability mass function of G bin (b) around its mean value, and highlight the differences between this mechanism and the underlying mechanism that enable large deviations to dominate in classic average guesswork (i.e., directly guessing a password).
We begin by explaining why the probability mass function of G bin (b) is centered around its mean value E (G bin (b)). For this let us consider a bin b of type q.
In general the maximum number of guesses is 2 n >> 2 m (i.e., generally, the set of inputs of a hash function is much larger than the set of outputs). We first focus on the case where the number of guesses where p g = 2 −(D(q|p)+H(q))·m , when n ≥ (1 + ǫ) · m · log (1/p) and ǫ > 0; this is based on Theorem 3 and Theorem 4 that show that in this regime the underlying probability of G bin (b) converges to geometric distribution. We later address the case where i g > 2 (1+ǫ)·m·log(1/p) . Theorem 5 shows that the probability that the number of guesses i g < E (G bin (b)) goes to 0. On the other hand, when the number of guesses is in the order of 1/p g = 2 (D(q|p)+H(q))·m , that is, when i g ≈ E (G bin (b)) we get that the first term in (25), (1 − p g ) ig goes to a constant and so in this case ) means that the number of guesses is in the exponential order of the mean value.
When, E (G bin (b)) < i g ≤ 2 (1+ǫ)·m·log(1/p) we get that the first terms in (25) decays super exponentially. In particular, when i g = 2 (D(q|p)+H(q)+δ)·m , where δ > 0 we get that This means that the probability of large deviations in the number of guesses decreases super exponentially, whereas the number of guesses can only increase exponentially. This leads to the fact that large deviations are extremely unlikely in this case, and as a result the probability mass function of The underlying mechanism that leads to super exponential decrease in the probability of large deviations is directly related to the P H -ensemble of hash functions (the fact that there is a super exponential number of such hash functions), and in particular to the bipartite graph presented in Figure 5. When G bin (b) = i g , it means that there are no edges in the bipartite graph that are connected to bin b and that are also connected to any of the first i g − 1 guessed inputs. When n is large enough, and i g > 1/p g the probability of this event decays super exponentially, as for every guess you have a new draw of edges from bin b that can be mapped to the guessed input, the probability that an edge from bin b hits the guessed input decreases exponentially, and the number of guesses that have been made at this point is also exponential.
When i g is in the order of 2 n the super exponential decay has even higher rate than what is presented above, due to the same mechanism as the one discussed in the previous paragraph.
On the other hand, in classic guesswork, the probability of large deviation in the number of guesses under ideal strategy is simply the probability of drawing a password that lies in the tail of the probability mass function of passwords. Since this probability decreases exponentially, and the number of guesses increases exponentially, the average guesswork in the classic case can lie in the tail of its probability mass function.

VII. THE MOST LIKELY CONDITIONAL AVERAGE GUESSWORK OF TYPE-CLASS STATISTICAL PROFILE HASH FUNCTIONS
In this section we define and analyze the most likely conditional average guesswork under both remote and insider attacks.
The results of this section conbined with the results of Section V provide quantifiable bounds for the effect of bias as well as the effect of the number of users, on the conditional average guesswork of a hash function. Furthermore, these results show that increasing the number of stored hashed passwords of users has a far greater effect on the average guesswork than bias.
The next definitions present the most likely conditional average guesswork, based on the fact that the conditional average guesswork is a function of the set of occupied bins B, and the fact that drawing passwords at random induces certain probability on the set of occupied bins, P B , as presented in Definition 16 and Lemma 4.
Essentially, some sets of occupied bins have the same conditional average guesswork; given a certain conditional average guesswork value, we are interested in the probability of drawing a set of occupied bins whose conditional average guesswork is equal to that value, that is, the probability of drawing a set of occupied bins B 0 , whose conditional average guesswork is E G remote/insider (B 0 ) = a. In particular, we are interested in the conditional average guesswork whose value is the most likely in terms of drawing a set of occupied bins that achieves this value.
Definition 18 (The most likely conditional average guesswork). Given that the number of users is |B|, the most likely conditional average guesswork under a remote/insider attack is the most probable average number of guesses required to break into the system; the probability of a conditional average number of guesses is determined by P B , and the sets of occupied bins whose conditional average guesswork is equal to this number of guesses.
For analysis simplicity, we focus on sets of occupied bins that consist of unique elements; we show in Corollary 2 and Corollary 3 that when passwords are drawn uniformly and independently it is very likely that the set of occupied bins consists of unique elements.
Lemma 6 (The most likely conditional average guesswork over sets of occupied bins consisting of unique elements). The most likely conditional average guesswork as a function of the sets of occupied bins of size |B| = A that consist of unique elements is arg max when averaging the guesswork according to definition 12, and passwords are drawn at random according to a probability mass function that induces P B as presented in Definition 16.
Proof. Basically the conditional average guesswork is a function of the set of occupied bins B. Furthermore, certain sets of occupied bins can have the same conditional average guesswork. Therefore, it is a question of what is the most probable group (or set) of sets of occupied bins whose guesswork is the same. This leads to equation (27).
Remark 18. |B 0 | = A in Lemma 6 represents the number of users. Therefore, the most likely average guesswork depends on A, as shown in the expressions in Corollary 2 and Corollary 3. We now find the most likely conditional average guesswork as presented in Lemma 6 when the elements in the set of occupied bins are unique. Again, for representation purposes we denote the number of users Corollary 2 (The most likely conditional average guesswork under an insider attacks). When the number of users is |B| = 2 H(s)·m , the most likely conditional average guesswork under an insider attack as presented in Lemma 6 increases like as long as 0 ≤ 1 − s ≤ p and p ≤ 1/2. In addition, we get the following: • The probability that all passwords are mapped to different bins of type q such that 0 • In this case the average guesswork E (G insider (B)) increases like 2 m·(H(q)+D(q||p)−H(s)) .
• The most likely conditional average guesswork is achieved when q = p (with probability that goes to 1). • When p ≤ 1 − s ≤ 1/2 the most likely conditional average guesswork is again achieved when q = p; in this case the exponent of the conditional average guesswork is equal to 0.
This is achieved under the following assumptions: • Passwords are drawn i.i.d. Bernoulli(1/2), and the elements in B are unique.
• P H defined based on the method of types and presented in Definition 15.
Finally, we average based on Definition 12.
Sketch of proof. The general idea behind the proof is that the guesswork is a function of the set of occupied bins B. Based on Theorem 2 it can be shown that for every set of occupied bins that are in the typical set of P H , the average guesswork is the same. Using Lemma 1 and the method of types it can be shown that for the typical set q = p we get P H (b) = 2 −m·H(p) , in which case the average guesswork increases like 2 m·(H(p)−H(s)) . Furthermore, when |B| ≤ 2 H(p)·m and passwords are drawn i.i.d. Bernoulli(1/2) the probability that the set of occupied bins is in the typical set of P H goes to 1. The full proof appears in Section XIII.
Remark 19. Corollary 2 shows that when 0 ≤ 1 − s ≤ p it is most likely that B consists of unique bins of type p (with probability that goes to 1), in which case the average guesswork increases like 2 m·(H(p)−H(s)) .
Remark 20 (The effect of bias vs. the effect of the number of users). The effect of the number of users on the average guesswork is far greater than the effect of bias, that is, as the number of users increases the average guesswork decreases at a higher rate than the one when the number of users remains constant and bias increases. In order to illustrate this statement let us focus on the rate at which the most likely average guesswork increases, H (p) − H (s), where 0 ≤ 1 − s ≤ p (although it holds for the bounds of Theorem 3 as well). First, let us focus on the effect of increasing the number of users on the average guesswork. The first derivative of H (p) − H (s) with respect to p is which is equal to zero at p = 1/2 (i.e., when there is no bias). In addition, the first derivative around p = 1/2 is very small and therefore bias has a little effect on the average guesswork. On the other hand the rate at which the number of users increases is H (s), and so the average guesswork decreases linearly with H (s). This in turn shows that change in bias does not affect the average guesswork to the same extent as change in the number of users. We illustrate this observation in Table I.
Next, we find the most likely average guesswork under remote attacks.
Corollary 3 (The most likely conditional average guesswork under a remote attack). When the number of users is |B| = 2 H(s)·m , the most likely conditional average guesswork under a remote attack as presented in Lemma 6 increases like as long as 0 ≤ 1 − s ≤ p and p ≤ 1/2. In addition, we get the following: • The probability that all passwords are mapped to different bins of type q such that 0 ≤ 1−s < q ≤ p, decreases like e −2 m·(2·H(s)−H(q)) × 2 −m·D(q||p)·2 H(s)·m .
• In this case the average guesswork of any of the users E (G bin (b)) as well as E (G remote (B)) increase like 2 m·(H(q)+D(q||p)) . • The most likely conditional average guesswork is achieved when q = p (with probability that goes to 1). This is achieved under the following assumptions: • Passwords are drawn i.i.d. Bernoulli(1/2), and the elements in B are unique.
• P H is based on the method of types as Defined in Definition 15.
Finally, the average is done in accordance with Definition 12.
Proof. The full proof appears in Section XIII.

VIII. OVERVIEW OF THE RESULTS
In this section we outline the main results presented in the paper and reference the relevant theorems and definitions in the paper, so that the motivation and the essence of the results can stand out.

A. Hashing Passwords, Brute Force Attacks, and Bias
Modern systems do not store the passwords of their users in plain text but rather hash them (a many to one mapping) and store their hash value, which is paired with a user name, as described in Figure 3 and presented in Definition 5. This in turn protects the passwords of users when the system is compromised. In order to gain access to a system a user provides the system with his user name and his password; the system then calculates its hash value and compares it to the one stored in the system.
The set of bins to which the passwords of the users are mapped is termed the set of occupied bins and denoted by B. This is presented in Definition 6 and Figure 2.
In a brute force attack an adversary who does not know the structure of the hash function, and therefore does not know which inputs map to which bins, guesses inputs one by one in order to find an input that is mapped to an element in B (one of the hash values stored in the system), that is, a hash value of a password of a valid user. This sort of attacks deviate away from classic works on guesswork, which consider attacks where an attacker has to find the password of a user (go to Subsection II-A for background on classic guesswork). The reason for this is that in password cracking the attacker does not know the hash function and so cannot directly guess specific bin values, but rather guess inputs, and it does not know to what outputs they are mapped. Indeed, in Theorem 14 we analyze the case where the attacker does know the hash function and also therefore knows the inputs mapping to each bin, thereby it can guess bins directly (i.e., cracking passwords over a broken hash function); in this case we show that the average guesswork is very similar to classic guesswork.
In this work we consider two types of brute force attacks: A remote attack and an insider attack. These attacks are presented in Figure 4 and defined in Definition 7 and Definition 8 respectively. In a remote attack the adversary targets a specific user and has to find an input that is mapped to the element in B that is paired with that user (i.e., the hash value of his password). Whereas under an insider attack an adversary (who knows the set of user-names and hashed passwords) has to find an input whose hash value matches any of the hash values that are stored in the system, that is, it is not targeting a specific user. Clearly, the chance of success of an insider attack is higher than a remote attack; the reason is that given a set of occupied bins the attacker has to find an input that is mapped to any of the bins in this set, whereas in a remote attack he has to target a certain bin in the set that is paired with a user name. This is because for an insider attack, it just needs one password that maps to any of the known hashed values, then as it knows all user-name and hashed passwords, it has compromised the system. For a remote attacker, it needs to find a password that maps to a specific bin (or hashed value) that is associated with a user-name.
We now discuss bias in hash functions. A hash function maps a large set of inputs to a set of smaller size, where the elements in the output are termed bins. When it comes to cryptographic hash functions and in particular password hashing functions, it is assumed for every bin that it is hard to find an input that is mapped to a bin. One of the most basic assumptions to support this is that a hash function is not biased, that is, the same number of inputs is mapped to any of the bins. However, in practical cryptographic hash functions it has never been proven that this assumption holds.
In this work we represent bias based on the statistical profile of a hash function. As presented in Figure  1 a hash function can be represented by a bipartite graph. The degree distribution [27] of the bins (the outputs) is the statistical profile of the hash function. The reason for this is that the set of degrees of the outputs can be normalized to a probability mass function as shown in Definition 1.
When there is no bias and the set of bins is of size 2 m , we get that the number of mappings per bin is the same across all bins and so the statistical profile is a uniform PMF, that is, 2 −m for any b ∈ {1, . . . , 2 m }.
We will use the statistical profile of a hash function to calculate the average guesswork per bin as well as under remote and insider attacks.

B. Defining Average Guesswork for Hash Functions
In this work we derive the average guesswork for every bin as well as the average guesswork under remote and insider attacks, under certain assumptions about the statistical profile of a hash function. Therefore, a question that may come to mind is what is the source of randomness over which we average, that is, what are the averaging arguments.
The first source of randomness is the probability according to which users choose their passwords; the second source of randomness can be either a key in a keyed hash function or alternatively the strategy according to which an attacker guesses passwords one by one; this two sources of randomness are presented in Definition 12.
First, we assume that users draw their passwords independently and uniformly over the set of inputs. This assumption can be partially supported by the use of passwords managers. Furthermore, in Subsection IX-B we analyze the case where passwords are biased.
The first averaging argument says that we average over all hash functions of a certain degree distribution, where the degree of each bin is fixed (i.e., permutation over the connection of edges to inputs in the bipartite graph as illustrated in Figure 5). Essentially, this is the same as considering a keyed hash function that is biased, where all elements in the set of hash functions have the same statistical profile.
The second averaging argument (which provides an alternative to the first one) considers a hash function with a given statistical profile and averages over all strategies of guessing passwords one by one, that is, over all brute force attacks. We wish to point out that this averaging method is meaningful when passwords are drawn uniformly, however it falls short when passwords are biased (as in this case an attacker is likely to favor a certain strategy over the others). However, this averaging argument comes handy when considering guessing using nonce in the context of proof of work. In this case the attacker draws an input at random (nonce) at every step as an input to the hash function. This is equivalent to drawing a strategy for guessing passwords one by one.
Under these averaging arguments we present in Definition 11 the average guesswork of a bin G bin (b). Basically, when there is bias, this average varies across bins as a function of the statistical profile (i.e., as a function of b). In Theorem 1 we show that when there are 2 m bins and the normalized degree (number of inputs mapping to it normalized by the total number of inputs) of of bin b 0 is 2 −α·m , where α > 0, the average guesswork of this bin E (G bin (b 0 )) = 2 α·m , which is the average number of guesses to find the input mapping to this particular bin. Note that the underlying probability mass function of G bin (b) as well as its average are not dependent on the passwords or the probability according to which they are drawn, but rather on the structure (statistical profile) of the hash function.
Since the attacker does not know the hash function, and there is bias (non uniform statistical profile), it is meaningful in our problem to define the conditional average guesswork, conditioned on the set of occupied bins B. Essentially, the conditional average guesswork changes as a function of the set of occupied bins due to bias. In this case users draw their passwords uniformly and these passwords are mapped to a certain set of occupied bins B. Another measure that we analyze is the average guesswork (i.e., the unconditional average guesswork), which is basically the average over the conditional average guesswork and the average is taken over the set of occupied bins.
In terms of the conditional average guesswork under remote and insider attacks we answer the following questions under the assumption that the set of occupied bins consists of A unique elements i.e., |B| = A, and a given statistical profile: • What is the set of occupied bins B whose conditional average guesswork is maximum; what is the maximum conditional average guesswork (see Definition 26).
• What is the set B whose conditional average guesswork is minimum; what is the minimum conditional average guesswork (see Definition 26).
• What is the most likely conditional average guesswork, that is, what is the most likely group of sets of occupied bins that have the same conditional average guesswork, and what is their conditional average guesswork (see Definition 18 and Figure 6). Furthermore, when considering the average over the passwords that users choose or alternatively averaging over all possible sets of occupied bins, we answer the following question: • What is the average guesswork when averaging over all possible sets of bins B. This is presented in Definition 17.

C. The average Guesswork under the type-class statistical profile
In order to derive closed form expressions for the average guesswork under remote and insider attacks we model bias (statistical profile) by using the distribution of type-classes from the method of types. We assume a natural mapping from bins to the statistical profile, that is, when considering the binary representation of bin b we get P H (b) = 2 −m·(H(q)+D(q||p)) , where 0 < p < 1/2 and q = (# ones in b)/m. This means that the number of edges of bin b divided by the total number of edges in the bipartite graph is P H (b).
For type-class statistical profile, given in equation (31), we get that bins of the same type have the same degree/probability (at least in terms of their exponent). This in turn means that under equation (31) we get sets of bins that are biased and are equally likely. In particular, every bin in the typical set has normalized degree that decreases like 2 −m·H(p) and there are 2 m·H(p) such bins. Therefore, under this assumption we get that the hash function is biased towards a certain subset of bins, whose elements are (approximately) uniformly distributed within the set. This is presented in Lemma 1 and Lemma 2.
We wish to point out that under both remote and insider attacks, the average guesswork does not change when considering permutation of the degree distribution; the average guesswork E G remote/insider (B) remains the same up to permutation over the set of occupied bins. In terms of the example given in Figure 1 it means that considering the degree distribution We begin by presenting the average guesswork per bin E (G bin (b)) for a type-class statistical profile. In this case, when bin b is of type q and the input size is large enough we get that E (G bin (b)) increases like 1/P H (b) = 2 m·(H(q)+D(q||p)) for large m, which is nothing but the average over geometric distribution, where the probability of success is P H (b). This is presented in Theorem 2.
Next, we focus on the conditional average guesswork under an insider attack in order to highlight our results on the most likely conditional average guesswork as well as the maximum and minimum conditional average guesswork. For all of this cases we assume that the number of users is 2 R·m = 2 m·H(s) , where 1/2 ≤ s ≤ 1, and |B| = 2 R·m . Furthermore, we assume that the passwords of the users are mapped to unique bins 4 .
The most likely conditional average guesswork in this case increases like 2 m·(H(p)−R) , when 0 ≤ R ≤ H (p). Furthermore, when 0 ≤ R ≤ H (p) /2 the probability for the most likely conditional average guesswork goes to 1 (the probability presented in equation (27)), that is, the probability that all elements in B are unique and the average guesswork is 2 m·(H(p)−R) goes to 1. This result is presented in Corollary 2. Note that Corollary 2 also shows that the probability of hitting the most likely average guesswork scales super exponentially.
In Remark 20 we show that the effect of increasing R (i.e., the number of users) is far greater than increasing bias (when p deviates away from 1/2) in terms of the exponent of the average guesswork.
We now present the maximum conditional average guesswork under an insider attack. In this case the conditional average guesswork increases like 2 m·D(s||p) . This is achieved when passwords are mapped to the 2 m·R = 2 m·H(s) bins with lowest degrees, where 1/2 ≤ s ≤ 1. Interestingly enough, as p decreases basically the exponent D (s||p) increases unboundedly as it becomes less likely for an attacker to hit these bins. We present this result in Theorem 3. Note that the chance of drawing a set of occupied bins of size |B| = 2 R·m that is mapped to the least likely bins decreases super exponentially in m.
The minimum conditional average guesswork when |B| = 2 R·m is also presented in Theorem 3. In this case as long as 0 ≤ R ≤ H (p) the conditional average guesswork under an insider attack increases like 2 m·D(1−s||p) , where again R = H (s). This function does not increase unboundedly as p decreases.
We wish to point out that in this subsection we do not average over all possible sets of occupied bins (or alternatively over the passwords), but rather use the averaging arguments of Definition 12.

D. How is it Different from Classical Results on Guesswork?
We now consider the case where averaging over all sets of occupied bins or alternatively averaging over the conditional average guesswork as presented in Definition 17 and Lemma 5 and denoted by E (G P (B)). Note that this is equivalent to averaging over all passwords.
We focus on the average guesswork under a remote attack. In this case the conditional average guesswork increases like 2 H(p)·m (this is presented in Corollary 3), when every element of the set of occupied bins is in the typical set. When R < H (p) /2 we get that the probability that every bin of the set of occupied bins is in the typical set and is unique goes to 1.
Furthermore, the results of Theorem 5 show that the probability that the conditional average guesswork is smaller than 2 m·H(p) goes to zero. Indeed, the conditional average guesswork is concentrated around its mean value (i.e., concentrated around 2 H(p)·m ), when every element in the set of occupied bins is in the typical set and 0 ≤ R < H (p) /2. This is in contrast with classical results on average guesswork (see [10] as well as Subsection II-A), where it is shown that the average guesswork, when guessing a secret directly, lies in the tail of the probability function of guesswork, which means that in the classic case the probability mass function is not concentrated around its mean value Subsection VI-A presents the mechanism that leads to concentration of the probabilty function of G bin (b). Essentially, it shows that it is related to the fact that the tail of the probability function decays super-exponentially because of the number of hash functions in the P H -set of hash functions, which is super-exponential.
On the other hand, when averaging over all passwords (basically over all sets of occupied bins) and passwords are drawn uniformly i.i.d. we get that the average guesswork E (G P (B)) increases like 2 m which is exactly the average guesswork when there is no bias. This result is presented in Corollary 1.  Therefore, we say that E (G P (B)) is a measure that is too crude to quantify the effect of bias on the average guesswork of hash functions. In this sense the conditional average guesswork presented in the previous subsection captures the effect of bias better than averaging over all elements including the set of occupied bins. It also means that the when 0 ≤ R ≤ H (p) /2, the random variable G P (B) is concentrated around 2 H(p)·m , whereas its average lies in the tail of its probability mass function. This is similar to results on the average guesswork in the classic case [15]. This is also illustrated in Figure 7.

E. Using Bias to Increase the Average Guesswork
Another question that may come to mind is whether bias can be used to increase the average guesswork of hash functions. As we show in Theorem 6 indeed bias can increase the average guesswork as long as there is a backdoor mechanism (such as the one presented in Definition 25) that maps password to the least likely set of occupied bins. In this case the average guesswork under a remote attack increases like 2 (2·H(p)+D(1−p||p)−R)·m ; this function increases unboundedly as p decreases. This is also illustrated in Figure 9. We wish to point out that as p decreases, the size of inputs to the hash functions required for this result to hold also increases, and so there is no contradiction in the fact that the average guesswork increases unboundedly as 2 n >> 2 (2·H(p)+D(1−p||p)−R)·m , that is, the set of inputs to the hash function is much larger than the average guesswork.

IX. THE AVERAGE GUESSWORK OF A MODIFIED P H -HASH FUNCTION
In this section we again analyze the average guesswork of the P H -hash function of Section V with the exception that a centralized procedure maps the passwords of the users to the least likely bins. We show that in this case the average guesswork can increase unboundedly as a function of bias.
We begin by defining a centralized procedure that maps the password of the users to the least likely bins. We then find the average guesswork under both a remote and an insider attacks, when passwords are drawn uniformly. Finally, we quantify how bias in drawing the passwords of the users affects the average guesswork.

Definition 19 (bin allocation).
Assume that the number of users M = 2 m·H(s)−1 ≤ 2 m , the bin allocation method is defined as follows. For each user a procedure allocates a different bin b ∈ {1, . . . , 2 m } according to the following method: The first user receives the least likely bin (i.e., when considering any hash function, this is the bin that has the smallest fraction of mappings; when considering a universal set of hash functions, this is the all ones bin), the second user receives the second least likely bin, whereas the last user receives the Mth least likely bin.
Three remarks regarding bins allocation are in order.

Remark 21.
In Definition 25 we present a "backdoor" mechanism that efficiently implements the bins allocation procedure presented in Definition 19, without decreasing the average guesswork.

Remark 22.
In Definition 19 we state that when two users have different passwords, they are mapped to different bins. In general, this is required in order for the backdoor mechanism discussed in remark 21 not to decrease the average guesswork.
Remark 23. mapping passwords to the least likely bins, either based on the fractions of mappings or on the distribution of the key when considering a keyed hash function, is essential for using bias to increase the average guesswork.
Corollary 4. Assume that the attacker guesses inputs of a P H -hash function one by one until it finds one that is mapped to bin b (remote or insider attacks). In this case, under the averaging arguments of Definition 12 and when bins are allocated to users according to Definition 19 we get for n ≥ (1 + ǫ) · m · (log (1/p) + H (s)) where ǫ > 0; the average guesswork of bin b ∈ {1, . . . , where q (b) is the type of bin b ∈ {1, . . . , 2 m } and averaging is done according to Definition 12.
Proof. The proof is similar to the poof of Theorem 2 with the exception that here bin allocation is in place. In order to make sure that bin allocation does not affect the average guesswork the minimum input length increases from n ≥ (1 + ǫ 1 ) · log (1/p) · m bits to n ≥ (1 + ǫ) · m · (log (1/p) + H (s)). The proof appears in Section XII.

A. The Case where Passwords are Drawn Uniformly
We begin by finding the average guesswork across users under a remote attack when the passwords are drawn uniformly, followed by a concentration result. We then consider an insider attack in which the attacker tries to find a password that is mapped to any of the assigned bins.
Proof. The full proof appears in Section XII. Figure 8 illustrates the above result. where 0 < ǫ 1 < 1.
Proof. The proof is in Section XII. Figure 9 illustrates the intuition behind the above results. Bins Inputsb Figure 9. Due to unbalance, there is only one mapping from the set of inputs to the solid black binb (the solid black line). Hence, the average number of guesses required to find a password that is mapped to it, is larger than the average number of guesses of the other bins, that is, the average guesswork ofb is larger than the average guesswork of the others. Proof.
The full proof appears in Section XII.  (3) is the dominant one. Since in this case the optimal strategy is guessing passwords based on their probabilities in descending order [10], the optimal average guesswork should be averaged over a keyed P H -hash function (i.e., not over all possible strategies of guessing passwords).
Corollary 6 (Biased passwords). Under the following assumptions. When passwords are guessed based on their probabilities in descending order, the average guesswork of a user who is mapped to bin b ∈ B, averaged over a keyed P H -hash function as in Definition 12 is equal to .

(36)
Furthermore, the average guesswork across users is and when lim m→∞ n m H (θ) > log (1/p). Proof. The full proof appears in Section XII.
We now give an illustrative example for the result above.
Example 2. Consider the case where n = (1 + ǫ) · log (1/p) · m and every user out of the 2 H(s)·m−1 users draws his password i.i.d. Bernoulli(θ). In this case, when 2 (1 + ǫ) · log (1/p) · H √ θ √ θ+ √ 1−θ < H (s) + D (s||p) the rate at which the average guesswork across users increases equals (1 + ǫ)·log (1/p)·H 1/2 (θ), whereas when (1 + ǫ) · log (1/p) · H (θ) > log (1/p) the rate is equal to Remark 25. Example 2 highlights the fact that based on the relation between n and m (i.e., the rate at which n grows compared to m), the bias in the hash function (parameterized by p), and the bias in drawing the passwords (parameterized by θ), we get a shift in the exponent of the average guesswork. When passwords are drawn from sufficiently biased distribution compared to the ratio n/m and to p we get that the most likely event that determines the average guesswork is the case where the attacker simply guesses the password of the user; in this case the average guesswork is the same as classic average guesswork. For example, when the password of the user is P s, and the hashed value of the password is H F (P s), is it very likely in this case that the attacker manages to guess an input n * = P s so that H F (n * ) = H F (P s). On the other hand, in the case where the bias in drawing passwords is not that severe, the most likely event that dominates the average guesswork is that the attacker manages to guess an input that is mapped to the same bin as the password of the user; therefore, in this case we get that the average guesswork deviates from classic results. Essentially, it means that when the bias in drawing passwords is not that severe, the most likely event is that the attacker guesses an input n * = P s so that H F (n * ) = H F (P s).

X. THE AVERAGE GUESSWORK OF A STRONGLY UNIVERSAL SET OF HASH FUNCTIONS
In this section we derive the average guesswork for strongly universal set of hash functions when the key is drawn i.i.d. Bernoulli(p), 0 < p ≤ 1/2. In Subsection X-A we derive the average guesswork for any bin as a function of the bias p. Then, in Subsection X-B we calculate the average guesswork as a function of the number of users and the bias. Furthermore, we present the backdoor mechanism to allocate bins. Finally, in Subsection X-C we analyze the guesswork when the hash function is not modified.
We begin by defining strongly universal set of hash functions [8], which is nothing but the set of all hash functions with an input of length n bits and an output of length m bits.
Definition 20. A strongly universal set of hash functions is the set H f (k) (·) , where k is a key of size m · 2 n , f (k) is a bijection, and {H i (·)}, i ∈ {1, . . . , m · 2 n }, is the set of all hash function with input of length n bits and output of length m bits.
We now define the mapping of keys to hash functions that we consider in this work for biased keys.
Definition 21. When the key is broken into 2 n segments of size m such that k = {k 1 , . . . , k 2 n } . (39) we state that the mapping g (·) leads to the following mapping from keys to hash functions In this work, when considering biased keys we assume the mapping g (·). Figure 10 illustrates the definition presented above.
Remark 26. Note that the set of hash functions presented in Definition 9 is a subset of a strongly universal set of hash functions.  Figure 10. The definition of the keyed hash function that we analyze in this paper. When the input equals i, the output is equal to the ith segment of the key, that is, ki. Essentially, this is a strongly universal set of hash functions.
Remark 27. Note that the mapping defined in equations (39), (40) from the set of keys to the set of all possible hash functions, is a strongly universal set of hash functions. Any other mapping that is a bijection from the set of keys to the set of all possible hash function also constitutes a strongly universal set of hash functions. Essentially, in section XI we show that this mapping along with a biased key achieves better performance than an unbiased key with any mapping that is a bijection (see Corollary 9 for the average guesswork of an unbiased key and any mapping that is a bijection). A biased key with other mappings may also lead to better performance than the one achieved with an unbiased key; however, we have been able to quantify the average guesswork for the mapping defined in equations (39), (40).
In terms of the knowledge the attacker has under a remote and an insider attacks defined in Definition 7 and Definition 8 respectively, when the system uses the universal set of hash functions defined in equations (39), (40), we make two additional assumptions: The key is drawn i.i.d. Bernoulli(p); and the attacker knows the distribution according to which the key is drawn, but it does not know the actual realization of the key.

A. The Guesswork of Each Bin
In this subsection we derive the guesswork for each bin, when the key is i.i.d. Bernoulli(p). Assume a strongly universal set of hash functions as defined equations (39), (40). Note that although in Definition 22 we describe procedure according to which bins are allocated, this procedure is different from the backdoor mechanism which is given in Definition 23. . . , 2 m } according to the following method: The first user receives the least likely bin (i.e., the all ones bin), the second user receives the second least likely bin, whereas the last user receives the ⌊2 H(s)·m−1 ⌋th least likely bin. Then, assuming L b passwords are mapped to bin b, the procedure uniformly draws a password from {1, . . . , |L b |}. In the case when |L b | = 0, the bin is not mapped to any password and we assume that the average guesswork is equal to zero.
A remark is in order regarding the case where a user has no password.
Remark 28. Note that the backdoor mechanism presented in Definition 23 does not allow a scenario where a user has no password. As shown in Theorem 11, this does not affect the average guesswork.
The next lemma proves that the order according to which the attacker guesses passwords, does not affect the average guesswork. Lemma 7. For any bin b, the average guesswork is not affected by the order according to which the attacker guesses passwords one by one, when averaging over all possible keys.
Proof. Consider a certain bin b ∈ {1, . . . , 2 m }. The attacker knows the probability mass function according to which the key is drawn. It also knows the set of bins allocated to the ⌊2 H(s)·m−1 ⌋ users, as presented in Definition 19. However, it does not know the actual realizations, and therefore the mapping from passwords to bins. Hence, from symmetry arguments, any strategy according to which the attacker guesses passwords one by one results in the same average guesswork, when averaging over all possible keys.
Based on Lemma 7 we assume without loss of generality that the attacker guesses passwords one by one in ascending order. Now, we can derive the average guesswork for any bin b.
Theorem 8 (Average number of guesses for each bin). Assume that the attacker tries to guess a password that is mapped to bin b. In this case when n ≥ (1 + ǫ 1 ) · log (1/p) · m, ǫ 1 > 0, the average guesswork of Proof. Based on Lemma 7 and without loss of generality we assume that the attacker guesses passwords one by one in ascending order. Essentially, in order to crack bin b the attacker has to find a password that is mapped to this bin. The proof relies on the observation that the chance of success in the lth guess (i.e., the first time a password which is mapped to bin b is guessed) is drawn according to the following geometric distribution where P K (·) is the probability mass function of a vector of length m that is drawn i.i.d. Bernoulli(p). The probability that bin b is not mapped to any password is Since P K (b) ≥ p m , we can state that as long as n ≥ (1 + ǫ 1 ) · log (1/p) · m where ǫ 1 > 0, the probability for this event vanishes exponentially fast and therefore does not affect the average guesswork; furthermore, we assume that when this event occurs, it takes zero guesses for the attacker to crack the bin, such that this event does not even add up to the average guesswork. We wish to stress that the "backdoor" procedure presented in Definition 23 does not allow for a situation where a user does not have a password. The mean value of (42) is equal to Assuming bin b is of type q (b) = N (1|b) m , and that the key is drawn i.i.d. Bernoulli(p), we get from Lemma 1 that By assigning the equation above in (44) we get (41). Now, we show that the average guesswork converges uniformly to 2 m·(H(q(b))+D(q(b)||p)) , ∀b.
Corollary 7. The average guesswork uniformly converges to 1/P K (b) across bins. The difference is upper bounded by the following term.
The next theorem shows that the guesswork concentrates around its mean value.
Theorem 9 (Concentration). The probability of finding a password that is mapped to bin b in less than 2 m·l guesses, where l ≤ n, is upper bounded by Therefore, whenever l < H (q (b)) + D (q (b) ||p) the probability of success in less than 2 m·l attempts decays to zero.
Proof. Based on the fact that the guesswork has a geometric distribution, we get that the chance of success within 2 m·l guesses is equal to The upper bound for P G bin (b) ≤ 2 m·l is obtained by assigning P K (b) = 2 −m(H(q(b))+D(q(b)||p)) to the following inequality Therefore, when l < H (q (b)) + D (q (b) ||p) the probability of finding a password that is mapped to bin b goes to zero.
Remark 29. Note that although the number of passwords scales exponentially with n (i.e., there are 2 n passwords), the average number of guesses scales with the size of the bins m. This is due to the fact that cracking a password requires finding a password which is mapped to the same bin as the true password.

B. The Average Guesswork for Cracking a Password of a User under Bins Allocation
We later use the solution to the following optimization problem, in order to derive the optimal average guesswork for cracking a password of a user.
where the optimal solution occurs at q = 1 − p. Furthermore, 2 · H (p) + D (1 − p||p) is a positive and unbounded function that monotonically increases as p decreases.
Proof. First let us break down the expression in (53).
The above expression is a concave function as a function of q as it is the summation of two concave functions; hence, this function has a maximal value. By calculating the first derivative and making it equal to zero we get Equality holds only when q = 1 − p. By assigning it to the expression on the left hand side in (53) we get the desired result.
We now quantify the number of mappings from passwords to each bin.
Lemma 9. Following the definition in equations (39), (40), assume that k i is the mapping from the ith password to the range of the hash function, where k i ∈ {1, . . . , 2 m } and i ∈ {1, . . . , 2 n }. In this case Proof. Essentially 1 b (k i ) is a random variable whose mean value is equal to P K (b) and variance value is smaller than 1. Furthermore, 1 b (k i ), i ∈ {1, . . . , 2 n } are all i.i.d. random variables. Therefore, we get (56) from Chebyshev's inequality.
Now we can derive the maximal average guesswork.
Theorem 10 (The average number of guesses). Let us denote the number of users by ⌊2 H(s)·m−1 ⌋, where s ∈ [1/2, 1] is a parameter. The exponential rate at which the optimal average guesswork increases as a function of m is equal to where n ≥ (1 + ǫ 1 ) · m · log (1/p), ǫ 1 > 0.
Proof. The general idea behind the proof is to write the average in terms of summation over types, and then use the fact that a vector of length m has up to m types in order to bound the average by the most dominant term among the m types. First let us define the set of all possible bins {b 1 , . . . , b 2 m } such that P K (b i ) ≥ P K (b j ) if and only if j < i; therefore, according to Definition 19 b 1 is assigned to the first user, whereas b 2 H(s)·m goes to the 2 H(s)·m−1 th user. The average guesswork when the attacker chooses a user name to attack, uniformly from 1, . . . , 2 H(s)·m−1 , is equal to where ǫ (m, n, q (b i )) = 2 m·(H(q(b))+D(q(b)||p)) + 2 n · e −2 n−m·(H(q(b))+D(q(b)||p)) in accordance with Corollary 7. Note that the term above takes into consideration the event when a mapping to b does not occur within the 2 n inputs; this probability is multiplied by zero guesses, which leads to the expression in equation (58). Based on the method of types [25] every bin in b 1 , . . . , 2 H(s)·m−1 , which is the set of bins that are allocated to the 2 H(s)·m−1 users, is of type and only if i < j. Therefore, from Lemma 1 and Lemma 2 we can rewrite the summation such that is goes across types, such that we can bound the average guesswork by the following terms The number of types is equal to the size of each bin, and therefore there are only m types; furthermore, the elements in the summations above all are non-negative. Hence, when n ≥ (1 + ǫ 1 ) · m · log (1/p) and m ≫ 1 the following terms bound the average guesswork.
We are interested in the rate at which the guesswork grows, which based on the above bound is equal to The function 2 · H (q) + D (q||p) is concave as a function of q, with a maximal value at q = 1 − p as shown in Lemma 8. Therefore, when (1 − p) ≤ s ≤ 1 the maximal value is obtained at q = s; whereas Note that n ≥ log (1/p) ≥ H (q) + D (q||p) for 0 ≤ q ≤ 1 which leads to the elimination of ǫ (n, m, q). These arguments conclude the proof.
We now present a backdoor mechanism that enables to modify a hash function efficiently without decreasing the average guesswork.
Remark 30 (A Back door Mechanism for Allocating bins). Essentially, in order for a procedure to allocate bins to the users, it first allocates a bin to a user, and then maps the password of this user to this bin; furthermore, there is a certain chance that because of the key realization, there is no mapping to a specific bin. This operation is as exhaustive as cracking the bin itself. In order for the system to allocate bins efficiently it has to use a backdoor that enables it to allocate bins without the need to crack the hash function as well as without compromising the security of the system (i.e., maintaining the same average guesswork). In Definition 23 and Theorem 11 we present a back door mechanism that satisfies both of these requirements. Now we define a back door mechanism that enables to plant mappings in an efficient way without compromising the security level of the hash function.
• For each user choose a different bin according to the procedure described in Definition 19 (i.e., the first user gets the least likely bin b 1 , the second user receives the second least likely bin b 2 , and the 2 H(s)·m−1 th user receives b 2 H(s)·m−1 ). • Each of the users from the first to the 2 H(s)·m−1 th draws a password uniformly by drawing n bits i.i.d. Bernoulli(1/2). • For each user, if the number that was drawn g ∈ {1, . . . , 2 n } has not been drawn by any of the users that have bins that are less likely than the current bin, then replace k g with the bin number allocated to the user. • In the case when another user who is coupled with a less likely bin, has drawn g: Do not change the value of the key again (i.e., k g is changed only once by the user who is coupled with the least likely bin among the bins of the users whose password is g). Instead, change the bin allocated to the user to the least likely bin among the bins allocated to users whose password is g. Therefore, k g is changed only once, to the least likely bin that is mapped to g. Figure 11 illustrates the back door mechanism.
Original Key User's Password: i User's bin:b New Key Figure 11. The backdoor mechanism. When the password of the user is equal to i, and no other user who is coupled with a bin that is less likely than the bin of the user, has come up with this password, the ith segment of the key is replaced with the bin that is coupled with the user. In the case when another user who is coupled with a less likely bin, has already come up with the exact same password, the more likely bin of the user (and not the key) changes to the bin of the other user.
Theorem 11. The optimal average guesswork when allocating bins using the back door mechanism given in Definition 23 is the same as the guesswork from Theorem 10 and is equal to Proof. The general idea behind the proof is that the back door procedure described in Definition 23 cannot add more than one mapping to each bin. Therefore, given any strategy of guessing passwords one by one, we show that the chance of drawing a password (in the backdoor procedure) that decreases the number of guesses bellow the average guesswork vanishes exponentially fast.
First, a few words are in order regarding the effect of the backdoor procedure presented in Definition 23. The procedure cannot add more than one mapping to each bin. This is due to the fact that when a password that is mapped to a specific bin is drawn, then the mapping is changed to the bin of the user for which the password was drawn. Furthermore, if the same password is drawn more than once by several users, then the mapping does not change again; at worst more than one user is mapped to the same bin (the probability that two users have the same password is the same as the probability of a collision, and is equal to 2 −n ). When a collision occurs, the mapping to the least likely bin among the bins that are coupled with these users, is the one assigned to all these users. Therefore, collision does not decrease the average guesswork.
Following what we have discussed above, for any strategy we are interested in the probability of drawing a password which is guessed within a smaller number of attempts than the average guesswork (i.e., given any strategy of guessing passwords one by one, what is the probability that the backdoor mechanism decreases the number of guesses bellow the average guesswork). When this event occurs we assume that the number of guesses required to break the strongly universal set of hash functions is zero. When there are 2 H(s)·m−1 users, the set of type q (b) = max (s, 1 − p) bounds the average guesswork as shown in equation (60). Therefore, it is sufficient to focus on the bins of this type; as even when the guesswork of bins of other type is equal to zero, the average guesswork remains the same.
Without loss of generality let us focus on the case when passwords are guessed one by one in ascending order; the following argument holds for any other strategy of guessing passwords. For every user, the backdoor mechanism draws a password uniformly. When n ≥ (1 + ǫ 1 ) · m · log (1/p) as defined in Theorem 10, the probability of drawing a password that is guesses within a smaller number of attempts than (1 + ǫ 2 ) · m · log (1/p) where 0 < ǫ 2 < ǫ 1 is Thus, for each bin of type q (b) = max (s, 1 − p), the average guesswork is multiplied by a factor 1 − 2 −(ǫ 1 −ǫ 2 )·log(1/p)·m that approaches 1 exponentially fast as m increases. Therefore, the average guesswork is not affected by the back door mechanism. The only difference compared to Theorem 10 is that now the decay of ǫ (n, m, 1 − p) in is dictated by ǫ 2 instead of ǫ 1 .
Remark 31. Note that the procedure for allocating bins which is described in Definition 23, does not require knowledge of the key in order to achieve the average guesswork of Theorem 11. The back door mechanism requires only knowledge of which bins are the least likely to occur based on the probability mass function according to which the key is drawn.

C. The Average Guesswork when Bins are not Allocated to Users
In this subsection we show that when the users choose their own passwords, without changing the hash function accordingly, the average guesswork of the strongly universal set of hash functions (averaged over all passwords) is equal to 2 m for any p.
Definition 24 (No bins allocation). When bins are not allocated to users each user chooses his own password, without modifying the hash function. The server stores the bin to which a password is mapped. Proof. From Theorem 8 and equation (44) we can state that the average guesswork for each bin is equal to From Corollary 7 we know that the right hand side of the equation above goes to zero when n ≥ (1 + ǫ 1 ) · m · log (1/p). When a user chooses a password uniformly over {1, . . . , 2 n }, and the key is drawn i.i.d. Bernoulli(p), the probability of average guesswork that is equal to E (G (b)) (i.e., the probability of drawing a password that is mapped to b) is equal to P K (b). Hence, we get that the average guesswork is equal to which leads to lim m→∞ log (E (G D (B))) = 1.
Remark 32. Note that when the least likely bins are allocated to the users (e.g., bins are allocated as in Definition 23), the fact that there is a very small number of mappings to these bins, enables to achieve a better average guesswork with a shorter biased key (as we show in the next section). However, when the bins are not allocated (i.e., the hash function is not modified), the chance of drawing a password that is mapped to a certain bin is equal to the probability of mapping a password to the very same bin. Therefore, in this case there is a small probability of drawing a bin that has a very small number of passwords mapped to it. This leads to an average guesswork that grows like 2 m .
XI. UNIFORM KEYS VERSUS BIASED KEYS: SIZE AND STORAGE REQUIREMENTS In this section we show that when the average guesswork is larger than the number of users, the minimal size of a biased key that achieves the average guesswork above with a universal set of hash functions defined in equations (39), (40), is smaller than the size of a uniform key (i.e., a key which is i.i.d. Bernoulli(1/2)) that achieves the same guesswork for the same number of users, with any mapping from the set of keys to the set of hash functions. Furthermore, we show that the storage space required to store the bins of all users is also significantly smaller. We wish to point out that this holds when the passwords of the users are mapped to the least likely bins, that is, bins allocation as defined in Definition 23 is in place.
First, we show that the average guesswork of biased keys is larger than the average guesswork of any strongly universal set of hash functions whose key is drawn i.i.d. according to Bernoulli(1/2), that is, any mappings from the set of keys to the set of hash functions would lead to the same guesswork when the key is uniform.
Corollary 9. When n ≥ m, the guesswork of any strongly universal set of hash functions whose key is with equality only when p = 1/2; where f (·) is a bijection from the set of keys to the set of all possible hash functions. Therefore, whenever 0 < p < 1/2, the average guesswork of the strongly universal set of hash functions defined in equations (39), (40), is larger than the one achieved by any mapping f (·) over a balanced key.
Proof. When the key is drawn i.i.d. Bernoulli(1/2) the problem of finding the average guesswork can be regarded as a counting problem. Since f (·) is a bijection, the number of functions for which the ith password is mapped to the jth bin is the same for any i and j. Furthermore, when l mappings are revealed, the set of keys decreases by a factor of 2 l·m and the remaining mappings are still balanced. Therefore, for any bin the chance of cracking a password in the lth guess is a geometric distribution that equals to 2 −m · (1 − 2 −m ) l−1 , l ≥ 0; this holds whenever f (·) is a bijection. Hence, the rate at which the average guesswork increases when n ≥ (1 + ǫ) · m and ǫ > 0, is equal to whereas from Theorem 10 we get that with equality only when p = 1/2, where the second inequality results from the fact that 2 · H (p) + D (1 − p||p) decreases as p approaches 1/2, and is equal to 2 at p = 1/2.
We now decrease the minimal size of the input, n, such that when 1/2 ≤ s ≤ (1 − p), the average guesswork is smaller than the one in (57); by decreasing n, we later show that in some cases the size of a biased key required to achieve a certain average guesswork, is significantly smaller than the size of an unbiased key that achieves the same guesswork.
Lemma 10. When the number of users is 2 H(s)·m−1 , n = (1 + ǫ 1 ) · m · (H (s) + D (s||p)) where 1/2 ≤ s ≤ 1, and the key is drawn i.i.d. Bernoulli(p), the average guesswork increases at rate that is equal to Proof. The general idea behind the proof is related to the fact that when the number of users is 2 m·H(s)−1 , and the users are coupled with the 2 m·H(s)−1 least likely bins, the average guesswork of any user is larger than or equal to 2 m·(·H(s)+D(s||p)) as long as n ≥ (1 + ǫ 1 ) · m · log (1/p); this follows from Theorem 8, the fact that s ≤ q (b i ) ≤ 1 where i ∈ 1, . . . , 2 m·H(s)−1 , and also because the backdoor mechanism does not decrease the guesswork of any bin. However, here we consider the case when the input is equal to n = (1 + ǫ 1 ) · m · (H (s) + D (s||p)), for which some of the assumptions above may not hold. Therefore, we examine two cases: The case where q (b i ) = s as well as s < q (b i ) ≤ 1. Once we show that for both cases the rate at which the average guesswork increases is larger than or equal to H (s) + D (s||p), we can also show that the average guesswork across all users increases at this rate. For q (b i ) = s the size of the input supports the average guesswork, and so following along the same lines as Theorem 10 and Theorem 11, we get that the average guesswork of these bins increases at rate H (s) + D (s||p).
For s < q (b i ) ≤ 1 the probability of a mapping to these bins is . Therefore, the average guesswork of these elements has to be larger than or equal to the case when q (b i ) = s. In fact, when ǫ 1 is small enough and n = (1 + ǫ 1 ) · m · (H (s) + D (s||p)), the probability that there is a mapping to bin b i within the 2 n inputs goes to zero, and so the only occurrences of b i is due to the backdoor mechanism; the backdoor mechanism achieves average guesswork that increases at rate (1 + ǫ 1 )·(H (s) + D (s||p)) when the password is drawn uniformly in accordance with Definition 23 (again, following the same lines as Theorem 11).
Remark 33. In order to show that a shorter biased key achieves the same guesswork that a longer balanced key achieves we need to find the actual guesswork and not only the rate at which it increases. The next lemma resolves this issue. Therefore, we get that Proof. Let us start by proving the inequality in (71). When n = (1 + ǫ 1 ) · m · (H (s) + D (s||p)), the probability of a bin of type q (b) > s to be mapped by the key to any password decreases according to the expression this is because of the fact that when q (b) > s the term (H (q (b)) + D (q (b) ||p)) > (H (s) + D (s||p)).
The back door mechanism in Definition 23 plants a mapping by drawing a password uniformly. Therefore, we get with probability (1 − γ 1 (s, p, m)) where γ 1 (s, p, m) decays to zero exponentially fast (i.e., with probability that approaches 1 very quickly), that when q (b) > s the problem of cracking a bin is as hard as guessing the mapping created by the back door mechanism. Since in this case the password is uniformly distributed over all possible passwords (i.e., 2 n possibilities), it can be easily shown that the average guesswork is equal to 2 n 2 ≥ 2 (H(s)+D(s||p))·m when m ≥ m 0 . Finally, by assigning the right parameters to equations (41), (46) when q (b) = s, the average guesswork is lower bounded by Hence, the average guesswork over all users (or alternatively all bins for which s ≤ q (b) ≤ 1) is lower bounded by the term in equation (71).
In the case when the key is uniform, (72) is proven by assigning the right parameters in equation (41) and keeping in mind that when the key is uniform and f (·) is a bijection, the average guesswork is the same for any bin. These arguments prove the equality in equation (72).
Remark 34. Note that when s = 1/2, the number of users is m/2 i=1 m i . Thus, in this case as m increases we get that By doing so we do not allocate bins that have an average guesswork which is smaller than the total average guesswork. Furthermore, in our analysis we restrict the size of the input, n, to be proportional to m. However, in practice n can be much larger. This can be achieved by simply duplicating the mappings for the first (H (s) + D (s||p)) · m inputs over and over again. By doing so the number of inputs can increase as much as needed, whereas the size of the key and the total average guesswork remain the same. Finally, by allocating a bin to each user and performing the back door procedure in Definition 23, the chance of collision between any two users is the same as the chance of collision for a strongly universal hash function with a uniform key, that has the same average guesswork, that is, 2 n .
We now show that when the average guesswork is larger than the number of users, a biased key which "beamforms" to the subset of users, requires a key of smaller size than an unbiased key that achieves the same level of security. Proof. From Corollary 9 and Lemma 11 we get that when the key is drawn i.i.d. Bernoulli(1/2), the average guesswork is determined by the size of the output. Therefore, in order to achieve an average guesswork that equals 2 m·(H(s)+D(s||p)) the size of the output must be (H (s) + D (s||p)) · m. In addition n = (1 + ǫ 1 ·) (H (s) + D (s||p)) and so the size of the key is equal to |k u | = (H (s) + D (s||p)) · m · 2 (1+ǫ 1 )·m·(H(s)+D(s||p)) . For the case when the key is drawn i.i.d. Bernoulli(p), we get from Lemma 11 that an output of size m achieves the desired guesswork. Hence, in this case the size of the key is |k b | = m · 2 (1+ǫ 1 )·m·(H(s)+D(s||p)) Finally, in order to allocate bins according to the method in Definition 23 each user has a key of size n, and since there are 2 H(s)·m users the size of the key required to draw passwords is (1 + ǫ 1 ) · (H (s) + D (s||p)) · m · 2 H(s)·m .
Corollary 10. When the number of users is equal to 2 H(s)·m−1 and the average guesswork increases at rate (H (s) + D (s||p)), the ratio between the size of an unbiased key and a biased key which is drawn Bernoulli(p), when both keys achieve the average guesswork above, is Proof. The proof results from the fact that In the next corollary we find the minimal size of a key that enables to achieve through bias, a desired average guesswork that is larger than the number of users.
Corollary 11. When there are 2 m−1 users and the desired average guesswork increases at rate α > 1, the key of minimal size is drawn Bernoulli(p 0 ) such that A universal set of hash functions defined in equations (39), (40), whose output is of size m achieves the average guesswork above.
Proof. From Corollary 9 and Lemma 11 we know that when α > 1 and the key is i.i.d. Bernoulli(1/2), the size of the output has to be α · m in order to achieve an average guesswork 2 α·m . Since in this case the size of the input has to be larger than α · m, the size of an unbiased key that achieves the desired average guesswork is α · m · 2 α·m . From Lemma 11 we also know that for any biased key that achieves average guesswork 2 α·m the size of the input has to be at least α · m. However, the size of the output can in fact be smaller than α · m. Essentially, we can define the output as m ′ such that number of users 2 m−1 = 2 H(s 0 )·m ′ −1 and m ′ < α · m, where 1/2 ≤ s 0 ≤ 1. The size of the key in this case is equal to m ′ · 2 α·m . The minimal value of m ′ that still enables to allocate a different bin to each user is m ′ = m (i.e., s = 1/2). In this case the size of the key is m · 2 α·m ; this key is drawn i.i.d. Bernoulli(p 0 ) such that Figure 12. When the number of users is 2 m−1 , and the average guesswork is equal to 2 α·m , the size of a biased key is α > 1 times smaller than a uniform key, where α = 1 + D (1/2||p). Note that in order to achieve an average guesswork 2 α·m , the output of a strongly universal set of hash functions has to be of size α · m when the key is unbiased, whereas when the key is biased the output can reduce to m bits, as long as the number of users is no larger than 2 m−1 .
larger than a biased key which is i.i.d. Bernoulli(p 0 ) that achieves the same average guesswork with the universal set of hash functions defined in subsection II-C equations (39), (40), where p 0 satisfies Proof. The proof follows directly from Corollary 10 and Corollary 11 of section XI. Figure 12 illustrates Theorem 13. Now, we show that biased keys also require smaller space to store the bins on the server.
Corollary 12. When the number of users is 2 H(s)·m−1 and the average guesswork is equal to 2 m·(H(s)+D(s||p)) , a biased key which is drawn Bernoulli(p) requires to store 2 H(s)·m−1 bins of size m each, whereas an unbiased key requires to store 2 H(s)·m−1 bins of size (H (s) + D (s||p))·m. Therefore, under the constraints above a biased key decreases the storage space by a factor of (H (s) + D (s||p)). The average stored space can be reduced further to H (p) · m · 2 H(s)·m−1 through entropy encoding.
Proof. The proof is straight forward and results from the fact that when considering a biased key the output is H (s) + D (s||p) times smaller than the output when the key is unbiased.
A remark is in order regarding the results above.
Remark 35. Note that the results above apply to strongly universal sets of hash functions, which are balanced sets. On the other hand in sections XII and XIII we consider sets of hash functions which are not balanced, that is, the size of a conditional set depends on the actual values of the bins on which it is conditioned; for example, if a fraction of (1 − P K (b 0 )) mappings is revealed such that none of these mappings map to b 0 , then the remaining fraction of P k (b 0 ) mappings are all mapped to b 0 . Hence, in this case the conditional set is of size 1.
XII. PROOFS OF THE RESULTS OF SECTION IX We first calculate the guesswork when bins are not allocated to the users, and for any bin the attacker knows of a password that is mapped to it.
Theorem 14 (Guesswork of a broken hash function). When each user draws his password uniformly over (1, . . . , 2 n ) as in Definition 24, and for every bin the attacker knows of a password that is mapped to it, the ρth moment of the guesswork of every user is (80) When P H is defined based on the method of types as presented in Definition 15, the ρth moment of the guesswork increases at rate that is equal to where H 1/(1+ρ) (p) is the Rényi entropy which is defined in equation (2).
Proof. We assume that for every bin the attacker knows of a password that is mapped to it. Therefore, the problem of guessing a password reduces to the problem of guessing the correct bin for each user.
Since each user chooses the password uniformly over {1, . . . , 2 n }, the chance of it being mapped to bin b ∈ {1, . . . , 2 m } is P H (b). Hence, the problem is reduced to the guesswork problem that is analyzed in [10]. We get the average guesswork that is stated above by following the same lines as [10] .
Remark 36. Essentially, the result of Theorem 14 captures the average time required to crack a hash function when a key stretching mechanism [28] is used in order to protect a system against passwords cracking. For example, when ρ = 2, it means that the time that elapses between attempts increases quadratically.
Remark 37. When passwords are not drawn uniformly, the optimal strategy of guessing passwords one by one is to first calculate the probability of each bin by summing the probabilities over all passwords that are mapped to this bin, and then guessing bins according to their probabilities in descending order.
We begin by defining a back door procedure for any hash function.
Definition 25. The back door mechanism for modifying a hash function is defined as follows.
• For each user choose a different bin according to the procedure described in Definition 19 (i.e., the first user gets the least likely bin b 1 , the second user receives the second least likely bin b 2 , and the 2 H(s)·m−1 th user receives b 2 H(s)·m−1 ). • Each of the users from the first to the 2 H(s)·m−1 th draws a password uniformly by drawing n bits i.i.d. Bernoulli(1/2). • For each user, if the number that was drawn g ∈ {1, . . . , 2 n } has not been drawn by any of the users that have bins that are less likely than the current bin, then replace the mapping of g with a mapping from g to the bin assigned to the user. • In the case when another user who is assigned to a less likely bin, has drawn g: Do not change the value of the mapping of g again (i.e., the mapping from g is changed only once by the user who is coupled with the least likely bin among the bins of the users whose password is g). Instead, change the bin allocated to the user to the least likely bin among the bins allocated to users whose password is g. Therefore, the mapping from g is changed only once, to the least likely bin that is mapped to g.
We are now ready to prove Theorem 6.
The proof of Theorem 6. The underlying idea behind the proof is to lower bound the average guesswork by upper bounding the probability of finding a password that cracks the bin at each round; we upper bound the probability by incorporating the maximal number of mappings that the backdoor mechanism can add to each bin as well as the number of unsuccessful guesses that have been made so far. We start by proving this theorem for any P H -hash function when averaged over all possible strategies of guessing passwords one by one, and we then show this also for the P H -set of hash functions and for any strategy. Then, in order to prove the equality rather than just an upper bound, we show that the probability that the number of mappings eliminated by the backdoor mechanism affects the fraction of mappings, is small to the extent that does not allow the average to grow beyond the lower bound discussed above.
Since the attacker does not know the mappings of the hash function, there is no reason for it to favor any guessing strategy over the other. Hence, we average over all strategies of guessing passwords one by one; essentially, this is equivalent to averaging over all possible permutations of the inputs, assuming that the permutations are uniformly distributed. This can be achieved by first drawing a random variable uniformly over {1, . . . , 2 n }, then drawing a random variable over the remaining 2 n − 1 possibilities, etc.
We now wish to lower bound the average guesswork by upper bounding P H (b). In order to lower bound the average guesswork we consider only the first (1 + ǫ 1 ) · m · log (1/p) guesses when averaging, where 0 < ǫ 1 < ǫ. Clearly the number of guesses can be greater than the term above and may go up to 2 n . Furthermore, we observe that after k unsuccessful guesses, the chance of guessing bin b is P H (b) · 2 n 2 n −k where 0 ≤ k ≤ (1 − P H (b)) 2 n . In addition, the back door procedure of Definition 25 can add one mapping at most to each bin. Thus, we can upper bound the probability by get the inequality The equality is achieved based on the following arguments. Assume that the backdoor mechanism eliminates l mappings to bin b. In order for the inequality in (89) to turn to equality, l has to increase at a rate that is smaller than 2 n · P H (b). Therefore, since there are 2 H(s)·m−1 users, whenever n ≥ (1 + ǫ) · (log (1/p) + H (s)), l cannot affect the rate at which 2 n · P H (b) increases.
Furthermore, this theorem also applies to the case when averaging over the P H -set of hash functions for any strategy of guessing passwords one by one (i.e., for any fixed strategy, the average is performed over the set of hash functions). This is due to the fact that any P H -hash function can be represented by a bipartite graph (e.g., Figure 9) for which averaging over the order according to which nodes that represent the domain, are chosen while keeping the edges fixed, leads to the same result as averaging over the order of the edges connected to these nodes while choosing the nodes in any order. The effect of the backdoor procedure given in Definition 25 is similar. When considering a user who is mapped to bin b ∈ B, the other users can only decrease the number of mappings to this bin. Based on the arguments presented in this proof, the other users cannot increase the average guesswork. Furthermore, the user can add up to one mapping, which does not affect the average guesswork.
The proof of Corollary 4. The proof is straightforward based on the proof of Theorem 6.
The proof of Theorem 7. We are interested in upper bounding the probability where P (i) As P H (b) < P Following along the same lines as the proof of Theorem 6 we know that the ratio lim m→∞ Note that the result above also applies to the case when P r G bin (b) ≤ 2 (1−ǫ 1 )·(H(q(b))+D(q(b)||p))·m ≤ lim m→∞ 1 − (1 − P H (b)) 2 (1−ǫ 1 )·(H(q(b))+D(q(b)||p))·m = 0 This result also applies to the case when averaging over the P H -set of hash functions and considering any strategy of guessing passwords one by one. It results from the same arguments that are given in Theorem 6; the backdoor mechanism can add no more than one mapping which is drawn uniformly over the set of passwords. Therefore, the same bounds and arguments hold for this case as well. This concludes the proof.
Equations (37) and (38) follow in a straightforward fashion when either 2 n·H √ θ √ θ+ √ 1−θ is smaller than the minimal average guesswork, that is, smaller than 2 m·(H(s)+D(s||p)) ; or when n m · H (θ) is larger than the maximal rate at which the average guesswork increases (i.e., larger than log (1/p)).
We now prove Corollary 5.
The proof of Corollary 5. In order to calculate the average guesswork for guessing a password that is mapped to any bin that is allocated to any user, we first need to bound the probability P B which is the probability of guessing such a password in the first guess (i.e., the fraction of mappings to any of those bins). Since P B is the probability of guessing a password that is mapped to any of the assigned bins, we get where B is the set of assigned bins as in Definition 19. Therefore, based on Lemma 1, Lemma 2, the fact that there are m types, and the fact that the number of users M = 2 H(s)·m−1 < 2 H(s)·m as well as the fact that max 1/2≤s≤q≤1 D (q||p) = D (s||p) when p ≤ 1/2; P B can be bounded by 1 (m + 1) 2 · 2 −m·D(s||p) ≤ P B ≤ m · 2 −m·D(s||p) .
Next, similarly to the proof of Theorem 6 equation (82) we can further bound the probability of success after k unsuccessful guesses by where P (k) B is the probability of guessing a password that is mapped to any b ∈ B, after k unsuccessful guesses; and m · 2 m·H(s) takes into consideration the fact that the backdoor mechanism from Definition 25 may add a mapping to each bin. Similarly to (83) we can lower bound the guesswork by where m 0 = (1 + ǫ 1 ) · m · log (1/p), 0 < ǫ 1 < ǫ. Since P (2 m 0 ) B ≤ P B 1 + (m + 1) 2 · m · 2 −ǫ·log(1/p)·m 1 − 2 −m·log(1/p)·(ǫ−ǫ 1 ) .
Hence, for the exact same arguments as the ones in Theorem 6 we can state that The equality is achieved based on similar arguments to the ones provided in the proof of Theorem 6; the number of mappings that other users remove in the backdoor mechanism is negligible. Furthermore, these results also apply to the case when averaging over the P H -set of hash functions and considering any strategy of guessing passwords one by one. It results from the same arguments that are given in Theorem 6; each user in B can add no more than one mapping, and the total number of mappings does not affect the average guesswork, as shown in equation (113). XIII. PROOFS OF THE RESULTS OF SECTIONS IV AND V Before deriving upper and lower bounds for the conditional average guesswork let us formally define these measures.
Definition 26 (The maximum and minimum conditional average guesswork). Given that the set of occupied bins is of size |B| and consists of unique elements (i.e., the bins in the set are different), the minimum and maximum conditional average guesswork, conditioned on the set of occupied bins, are defined as follows: • The maximum conditional average guesswork is the maximum average number of guesses required to break into the system under a remote or an insider attack, where the maximum is taken over all sets of occupied bins of size |B|. • The minimum conditional average guesswork is the minimum number of guesses required to break into the system under a remote or an insider attack, where the minimum is taken over all sets of occupied bins of size |B|.
Lemma 12 (The maximum and minimum conditional average guesswork). The maximum and minimum conditional average guesswork under a remote (insider) attack when the size of the set of occupied bins is A and it consists of unique elements can be written as follows: and min where averaging is done according to Definition 12.
Proof. The proof is straight forward based on Definition 26.
Remark 38. In order to achieve the maximum/minimum average guesswork the users have to draw passwords that are mapped to the set of occupied bins that maximizes/minimizes equation (114)/ (115).
The probability for this event can be very low.
Remark 39 (The set of occupied bins the maximizes/minimizes that conditional average guesswork). When averaging over a keyed P H -hash function, for every element in this set of hash functions, users draw passwords that are mapped to the set of occupied bins that maximizes/minimizes equation (114)/ (115).
In order to upper bound the rate at which the average guesswork increases we consider the case where all users are mapped to the 2 H(s)·m−1 most likely bins. This in turn enables us to give an upper bound to the average guesswork by considering the results for the case of bins allocation. The lower bound is derived by assuming that the users are mapped to the 2 H(s)·m−1 most likely bins.
We begin by proving Theorem 5.
proof of Theorem 5. This result follows directly from equation (88) which lower bounds the probability when bins are allocated, by using the probability when there is no bins allocation.
Next, we prove Theorem 3 proof of Theorem 3. The upper bound follows directly from Corollary 5 as the average guesswork with bins allocation is equal to the result when considering the most likely bins. The lower bound is based on the assumption that the users are mapped to the 2 H(s)·m−1 most likely bins. This leads to the following optimization problem min 0≤q≤1−s D (q||p) where 1/2 ≤ s ≤ 1. The minimal value is achieved at q = p ≤ 1/2, and is equal to 0. Therefore, the lower bound is equal to Finally, because there is no backdoor procedure that modify the hash function, the results hold for n ≥ (1 + ǫ) · m · log 1/p. This concludes the proof.
We now prove Corollary 2.
(121) Furthermore the smallest rate at which the probability decreases is achieved when q = p and is equal to e −2 m·(2·H(1−s)−H(p)) . (122) Based on arguments similar to the ones in Theorem 3 we get that when all users are mapped to bins of type q the probability of finding a password that is mapped to any of the bins is 2 −m(H(q)+D(q||p)−H(1−s)) and therefore the average guesswork increases like 2 m(H(q)+D(q||p)−H(1−s)) . In the case when q = p we get that the average guesswork increase like 2 m(H(p)−H(1−s)) Finally, when q < 1 − s ≤ 1/2 the most probable event is when all passwords are mapped to bins of type p in which case the average guesswork does not increase exponentially, that is, the rate at which it increases is equal to zero.
Next, we now prove Corollary 3.
proof of Corollary 3. The probability that the users are mapped to a particular type q follows along the same lines as the proof of Corollary 2. When all users are mapped to bins of type q, the probability of guessing a password that is mapped to a bin of a user is the same across users and is equal to 2 −m·(H(q)+D(q||p)) , and therefore the average guesswork is equal to 2 m·(H(q)+D(q||p)) .
proof of Theorem 4. The upper bound follows directly from Theorem 6 as the average guesswork with bins allocation is equal to the result of averaging across the most likely bins. Because there is no backdoor procedure that modify the hash function, the results hold for n ≥ (1 + ǫ) · m · log 1/p.
The lower bound is based on the assumption that the users are mapped to the 2 H(s)·m−1 most likely bins. By arguments similar to Theorem 10 we arrive at the following optimization problem max 0≤q≤1−s 2 · H (q) + D (q||p) where 1/2 ≤ s ≤ 1. In lemma 8 it is shown that 2 · H (q) + D (q||p) is a concave function whose maximal value is at q = 1 − p ≥ 1/2. Hence, when 0 ≤ q ≤ 1 − s ≤ 1/2 the maximal value is achieved for q = 1 − s and is equal to 2 · H (1 − s) + D (1 − s||p) = 2 · H (s) + D (1 − s||p). This concludes the proof.
Proof of Theorem 1. The proof is along the same lines as Theorem 6 equations (82)-(88).
Proof of Theorem 2. The proof is along the same lines as Theorem 6 equations (82)-(88).
Proof of Corollary 1. When n ≥ (1 + ǫ) · m · log (1/p) the proof follows along the same line as Corollary 8 XIV. SUMMARY In this work we define and derive the average guesswork for hash functions. We define the conditional average guesswork as a function of the set of occupied bins. We also find the most likely conditional average guesswork as well as the maximum and minimum conditional average guesswork. We reveal an interesting connection between the effect of bias and the number of users on the level of security, and quantify the average guesswork of hash functions by using basic information theoretic measures.
Furthermore, we show that when the hash function can be modified by a backdoor mechanism, bias can increase the average guesswork unboundedly.