How do rainbow tables solve collisions?
The current highest voted answer doesn't really seem to give a proper response to your question. I'll try to answer both your questions simultaneously.
Same reduction function in every column
Say, you use the same reduction function for every column and have a basic table with 2 rows and 3 columns.
P1 --R--> P1' --R--> P1'' --R--> P1'''
P2 --R--> P2' --R--> P1' --R--> P1''
Here, an --R-->
represents a hashing followed by a reduction. And P1, P2, P1', ...
represent passwords.
As you can see, there was a collision in the second chain. The value P1'
has already been encountered in the first chain.
Notice what happens afterwards.
Since the hashing followed by the reduction of P1'
is exactly the same as in the first chain, we get a value that has already been computed. If we continue this even further, the part of the second chain starting from P1'
becomes an exact copy of the part of the first chain starting from P1'
.
So in effect, this is why collisions are bad. The second chain merged into the first. We have duplicate results in our table, resulting in wasted storage space and computation time.
Different reduction function in every column
This time, let's see what happens if we use a different reduction for every column.
A reduction is represented by --RX-->
where X
is the column number.
P1 --R1--> P1' --R2--> P1'' --R3--> P1'''
P2 --R1--> P2' --R2--> P1' --R3--> P2''
Again, P1'
was encountered in both chains.
However, since the reduction functions are different, the value calculated after P1'
in the second chain won't result in P1''
, as it does in the first chain. This effectively solves the merge issue from the first example.
Note that this doesn't solve every chain merge though. Watch what happens in the following example:
P1 --R1--> P1' --R2--> P1'' --R3--> P1'''
P2 --R1--> P1' --R2--> P1'' --R3--> P1'''
This time a collision happens in the first column of both chains. Since it happens in the same column, every next reduction function will be the same and the chains are merged once again. The probability of this happening is lower though.