nimiq / identicons

Nimiq Identicons
https://nimiq.github.io/identicons/
MIT License
33 stars 9 forks source link

Hash algorithm buggy #8

Closed riptl closed 5 years ago

riptl commented 5 years ago

Problem

__Iqons._hash is really buggy.__ In short, it generates a formatted decimal number (as string) from a text but returns %.1f instead of %013.1f.

The code that uses the hash always assumes the string length to be 15 (13 places left of the comma), when in reality it's 14 with a 10% chance, 13 with a 1% chance, 12 with 0.1%, and so on.

This is an issue because the code takes the characters (digits) of the hash and recombines them to new numbers that serve as indices etc. It's especially painful for the naming concept #6.

Example of bad hash

Test here.

image

Note that this is different from bottom-10, which is the floating Iqon.

Fixes

I have three suggestions on how to fix it

Suggestion 1:

Suggestion 2:

Suggestion 3:

riptl commented 5 years ago

Other buggy addresses (black/undefined accent)

Note: These addresses are invalid (IBAN checksum)

riptl commented 5 years ago

Valid Address

Account: NQ85 QV2J N3DM UNE1 AKMQ TK3C HYKP 5Q1F P4NR https://nimiq.watch/#NQ85+QV2J+N3DM+UNE1+AKMQ+TK3C+HYKP+5Q1F+P4NR

image image

Don't send NIMs, I don't have the private key for that addr ;)