4

I'm confused about whether the following hash function is collision resistant. $x \sqsubseteq y $ denotes that x is equal to y or x precedes y.

$ H:\{0, 1\}^* \rightarrow \{0, 1\}^n$

If $x \sqsubseteq y $ then $h(x) \sqsubseteq h(y) $

Does this mean H is collision resistant?

2 Answers2

8

Does this mean H is collision resistant?

No, it cannot be collision resistant.

Consider $H(x)$ over all possible values $x \in \{ 0, 1 \}^k$ for $k \ggg n$. There are $2^k$ possible inputs, and only $2^n$ possible outputs; furthermore, the preimages for any specific output must be contiguous.

Hence, if we consider $x$ stepping from the minimal possible value $0^k$ through consecutive values to the maximal value $1^k$, then $H(x)$ must be split up into (at most) $2^{n}$ ranges, where any two inputs in the same range will generate the same output; for those $2^k$ inputs, there are at most $2^n-1$ places where adjacent inputs produce different outputs.

Hence, if we select a random $r \in \{ 0, 1 \}^{k-1}$, and consider $H( r \mathbin\Vert 0 ), H( r \mathbin\Vert 1)$, then with high probability (at least $1 - 2^{n - k - 1}$), those two hashes will be the same, and that's a collision...

Squeamish Ossifrage
  • 48,392
  • 3
  • 116
  • 223
poncho
  • 147,019
  • 11
  • 229
  • 360
  • 1
    Thank you! This helps a lot. Why is the probability $1 - 2^{n-k-1} $ ? I'm having a little difficulty understanding that part. –  Nov 07 '17 at 19:10
  • @ProgammGurl: does the additional text I inserted help? – poncho Nov 07 '17 at 19:29
1

As @poncho points out, $H$ is not a collision resistant hash function: here's a simpler argument. Since $H$ is monotonous (i.e., If $x⊑y$ then $h(x)⊑h(y)$), one can find a collision through a binary search (on the space $\{0,1\}^n$). The idea is to check whether the value of the hash of $x\in\{0,1\}^n$ is greater than $x$ and then depending on the hash recursively search either the left half or right half of the space. If you don't find a collision at the end of the search (which means that $H$ is identity on $\{0,1\}^n$), return $1^n$ and $1\|0^n$ as the collision.

ckamath
  • 5,188
  • 2
  • 21
  • 41