3

Let msg be some data we want to hash using an arbitrary digest size algorithm such as blake2b. From that hash, we would like to compute a checksum field with n decimal digits.

If we suppose that the hash algorithm has a perfect distribution, we would like to design the checksum with a probability of collision as low as possible, ideally 1/10n.

Let n be in the range 1..10 (1 digit checksum to 10 digits checksum).

For each value of n, what would be the safest way to calculate a checksum of size n?

More specifically, what size of digest should we aim for every size of n and how should we reduce the value of the hash h to a decimal number.

E.g.: For n = 2 (2 checksum digits):

a) digest_size = 1, checksum formula = h mod 100

b) digest_size = 4, checksum formula = h mod 97

If the formula used to reduce the hash h to a checksum is h mod p, are there optimal values of p and digest_size for each value of n?

Patriot
  • 3,162
  • 3
  • 20
  • 66
User314
  • 31
  • 1

0 Answers0