# What is the best way to show a (long) number for comparison?

How to represent visually a number (like a key or hash) on a screen for visual comparison with another representation of that number on another screen (or another window) in such way that it would be very hard for an adversary (who knows the correct answer) to convince the user that different numbers are equal?

The applications would typically be to display a hash for the purpose of reliable but not to cumbersome user verification.

REMARK:

In the discussion, a "moved goalpost" was described as: "How to display two numbers for comparison when an attacker knows one number and can control the other, and the user isn't willing to look at more than a few characters?"

That's almost the question: the question is how to graphically show these numbers, for the purpose of visual comparison, as users probably will not want to carefully compare more than a few hex digits (or more than the first two).

• I hope this doesn't just get suggestions and opinion answers. I already have one. (Insert a space between every four hexadecimal characters.) Citing results from a formal experiment would be much more interesting. Commented Dec 10, 2019 at 23:28
• Identicons are an existing solution here. Commented Dec 10, 2019 at 23:47
• OpenSSH used randomart (ASCII) image for this purpose. If you need to write an application that uses this kind of visual hash, there's a number of alternatives for random visual hashes that have similar properties for use in graphical key comparison. Commented Dec 11, 2019 at 3:49
– user163495
Commented Dec 11, 2019 at 6:56
• github.com/drhus/awesome-identicons Commented Dec 11, 2019 at 10:37

Display one number directly below the other. Slowly move the two numbers on top of one another until they overlap. If they perfectly co-inside, they're the same number.

For bonus points, make one number in yellow, another in blue. Combined they make green.

• This won't work on different screens... Commented Dec 11, 2019 at 10:20
• @ThoriumBR print the two numbers on transparency paper, and compare them. The inherent problem with this question is that it implies you have a lazy end user without a tool to compare them. The only real solution is to invent a tool since humans are just bad at this task, and computers good. Commented Dec 11, 2019 at 15:41

Shower thoughts: train a Neural Network to generate 64x64 pixel faces (or cats, or flags, or flowers), using some properties of the numbers (a hash, a log, the remainder of a division by some prime). As soon as the network generates good looking faces (or flags, or cats), use it to transform the numbers into icons.

To avoid second pre-image attacks, add a second neural network trained to generate a different kind of icon, trained with a different dataset. Have both generating images based on the number, and show both icons to the user.

Show the icons to the user. It will be easy to tell if the numbers are the same, and will be very difficult to an adversary to bruteforce the generation algorithm without getting all your training data. Generating a similar image on both generators without the training data will be practically impossible, even if the attacker controls both numbers.

• This alone doesn't necessarily do a great job, or even a good one. You need to actually preserve the important properties of hashes. For instance, it should be second pre-image resistant, so that knowing an input value shouldn't allow us to create a second output image that looks similar to the first one. As a pathologically-bad example, a naïvely-trained neural net could produce nothing but unique-yet-similar faces. This would be worse than useless from a security perspective. Commented Dec 11, 2019 at 3:30
• That's why it needs proper training. Using 2 dissimilar networks (one generates cats, other generates people) will be second pre-image resistant, as it's almost impossible to both generate similar icons for the same different numbers. Commented Dec 11, 2019 at 10:17
• I really don't think there's any compelling reason to invoke NNs here. Existing graphical approaches don't use them, and using something like an NN only makes it more difficult to prove beyond a reasonable doubt that outputs will be visually distinct for one-bit differences in the input. Commented Dec 11, 2019 at 20:05