Chapter 11
Exercise 11.1-1
Available in the latest revision of the IM.
Exercise 11.1-2
Available in the latest revision of the IM.
Exercise 11.1-3
Available in the latest revision of the IM.
Exercise 11.1-4
Available in the latest revision of the IM.
Setting T[k]=nil is redundant (see the sequence of assignments for deletion in the IM).
Exercise 11.2-1
Available in the latest revision of the IM.
Exercise 11.2-2
We start with an empty table . Elements which appear to the left in the table have been added later.
0
1
10, 19, 28
2
20
3
12
4
5
5
6
33, 15
7
8
17
Exercise 11.2-3
Available in the latest revision of the IM.
Exercise 11.2-4
Available in the latest revision of the IM.
Exercise 11.2-5
Available in the latest revision of the IM.
Exercise 11.2-6
Available in the latest revision of the IM.
Exercise 11.3-1
Available in the latest revision of the IM.
Exercise 11.3-2
Available in the latest revision of the IM.
The solution in the IM doesn't take into account the fact that the key is encoded as a radix-128 number. So, the correct way to calculate the hash value is to apply Horner's rule and compute it iteratively. Let's assume that the key is represented as a sequence of characters in big-endian format.
// Snippet of pseudocode to calculate h(k)
h = 0
for i = 1 to r:
// Multiplying by 128 is shifting left by 7 positions.
h = ((h << 7) + s[i]) mod mExercise 11.3-3
Available in the latest revision of the IM.
The solution in the IM is incomplete, since it doesn't answer the last question from this exercise. A cryptographic hash function must ensure that any permutation of characters generate a different hash value. Otherwise, someone could rearrange a document without breaking a message digest used in a digital signature. Imagine an adversary being able to rearrange the bank account number and/or amount of a digitally signed transaction.
Exercise 11.3-4
61 → 700 62 → 318 63 → 936 64 → 554 65 → 172
Exercise 11.3-5
Available in the latest revision of the IM.
Exercise 11.3-6
The size of our family of hash functions is , as we have choices to select . We need to calculate the probability of a collision for distinct keys and . This probability is over the picks of . Observe that
which gives
We have the following equalities all taken modulo
Following the hint from the book, according to Exercise 31.4-4 the above polynomial can have at most distinct zeros modulo . In other words, at most choices of can lead to a collision. Therefore, our family of hash functions is -universal for .
Exercise 11.4-1
Use VisuAlgo and select linear probing in the top menu bar. Choose the option in the left sidebar to create an empty hash table with slots and elements and press Go. Afterward, select the command to insert elements 10,22,31,4,15,28,17,88,59 and press Go.
For double hashing, the above website uses a different auxiliary hash function , so we cannot use it here. The hash table is filled as follows:
Exercise 11.4-2
Hash-Delete expects the key to be present in the hash table. Otherwise, there should be another check against nil for the returned index.
Hash-Delete(T, k)
i = Hash-Search(T, k)
T[i] = DELETEDThe Hash-Insert procedure from the book requires a slight change in 4 line as follows:
if T[q] == nil or T[q] == DELETEDThe Hash-Search doesn't need any change.
Exercise 11.4-3
Available in the latest revision of the IM.
Exercise 11.4-4
Instead of doing integral approximation (see page 300) we simply use the definition of the th harmonic humber.
Exercise 11.4-5
This directly follows from Theorem 31.20, since .
Exercise 11.4-6
Enter solve 1/(1-x)=2/x ln(1/(1-x)) in WolframAlpha to get by clicking on the Approximate form button inside the Result pane.
Exercise 11.5-1
is an identity function, which is obviously injective. If we prove that is injective (base case), then for is also injective by induction on . Note that the composition of two bijections is again a bijection (see solution for Exercise B.3-4).
We know that the function only rearranges the bits of an input independently of it's value, therefore .
Suppose, for the sake of contradiction, that there are two distinct inputs and such that . WLOG assume that , otherwise, exchange them. Thus, we have
We have reached a contradiction, since is odd and . Recall that both and are -bit words, hence . Consequently, is injective.
Exercise 11.5-2
A random oracle is equivalent to an independent uniform hash function family. Let us take 5 distinct keys . Each will be independently and uniformly mapped by a random oracle to a slot in the range . There are possible mappings, each with an equal probability of occurrence . Thus, a random oracle is 5-independent according to the definition from the book on page 288.
Since a random oracle guarantees independence for any number of distinct inputs, it inherently satisfies 5-independence. 5-independence is a weaker condition than full independence; a fully independent function trivially satisfies -independence for all .
Exercise 11.5-3
At least rounds are required to trigger an avalanche effect potentially affecting any bit of the output to flip. In the illustration below, light red colored cells could be affected by flips in previous rounds. After 3 rounds, all cells are marked red, hence may be impacted by flipping a single bit of the input value . Observe that flipping the most-significant bit of only impacts the most-significant bit of in the first round. Any other bit of can only make the situation better. Hence, we consider a flip in bit position as the worst-case scenario. Note that round 0 is an identity function, so it is essentially the key itself. Each round consists of two parts: the upper is and the lower is of the corresponding round.
Problem 11-1
Available in the latest revision of the IM.
Problem 11-2
Available in the latest revision of the IM.
Problem 11-3
Available in the latest revision of the IM.
Problem 11-4
a.
Arbitrarily pick two distinct keys . If is 2-independent, then we can have different pairs of hash values with equal probability of occurrence . Collisions are denoted by pairs for . Therefore, the probability of a collision for two distinct keys is . Consequently, is universal.
b.
First, we show that is universal. Arbitrarily pick two distinct keys . They must differ in at least one component. WLOG let it happen at index . For a collision to occur, with a randomly picked hash function , we must have . Using the definition of we get
Observe that and implies that has a multiplicative inverse modulo . Therefore,
Notice that is fully determined based on the choice of , and other components of . Thus, the probability of a collision is , since for a randomly selected -tuple , there are possible values at index and only one leads to a collision. Furthermore, if then all coefficients , associated with corresponding nonzero terms , simultaneously satisfy (1) (just set . This shows that is universal.
Following the hint from the book, it is easy to see that always hashes to zero. Therefore, the condition to have unique pairs of hash values, with equal probability of occurrence, for any two distinct keys is not satisfied. Consequently, is not 2-independent.
c.
Taking the hint from the book, let's see what happens to as and range over . The same reasoning will also apply to . Let , since we keep all other parameters fixed. This constant has no influence on the subsequent analysis.
We must show that can take any value from and equal number of distinct pairs map to each such output. There are two cases to consider:
If then each value of produces a unique hash output, so it may range over . For every we can freely assign possible values to . In other words, distinct pairs map to each distinct hash value.
Otherwise, according to theorem 31.20, we know that , since is relatively prime to . In this case, the parameter only shifts the full sequence of values generated by . There are such shifts. Thus, the output may range over and again distinct pairs map to each distinct hash value.
We can conclude that is 2-independent.
d.
Since is 2-independent, we can have different pairs of hash values, with equal probability of occurrence , for two distinct keys . The adversary may fool Bob, assuming that , if , where denotes the shared hash function between Alice and Bob. All the adversary can do is to find a hash function such that , hoping that it will also collide on with . There are pairs of possible hash values whose first component is . The probability that will also generate the same second component as for is . Therefore, no matter how much computing power the adversary has, her/his probability of success is at most .
As a side note, the previous analysis may also be carried out in an opposite direction. Namely, to ask what is the probability that Alice and Bob had selected a random hash function that hashes to the same value as for . Among those that produce for only th generate for . So, we arrive at the same conclusion.
Last updated