2
$\begingroup$

Pardon my terminology, but is there a hashing function of some sort which accepts a string as input and generates a non-textual output of some sort, or perhaps a unique output that can be used to draw a visual representation of the output.

enter image description here

I refer it to as "hash" because the same output should always lead to the same visual representation of the output i.e. behave like a hashing function, even though my use-case is highly tolerable towards collision as its only meant to uniquely identify in a small group of inputs when compared to another small group of inputs, and it need not be absolutely unique across the vast range of inputs that are possible. Though even the slightest change in input, should change the visual output considerably.

Objective: I am exploring the possibilities of using a visual cue derived from random strings that can aid in differentiation and quick identification in a small group. Eg: How CryptoKitties project generates a visual image of a cat by their genome representation which is just a textual input.

Use-case: I am building an air-gapped multi-accounts multi-currency cryptocurrency wallet which is a 2-device system (Vault + Wallet). Vault boots up as an ephemeral instance of OS, so it doesn't store any information across boot instances. So accounts that are once created in vault and imported into wallet using an xpub key and labels are added there. Vault doesn't and can't store any labels associated with the accounts. So when the same accounts are derived on the vault program upon initialization on next boot, I am trying to represent every account (essentially the xpub key by a visual character so that they are matched with the accounts on the wallet by simply looking at them without any communication required.

enter image description here

$\endgroup$
10
  • 1
    $\begingroup$ Welcome to crypto.SE! There are some terminology issues. What's "non-textual"? The output of a hash function is not text; it is a bitstring of specified length (e.g. 256 bits), which can then be transformed into text (e.g. 64 hexadecimal characters, 44 per Base-64). Do you mean image? Would audio (melody) do? Independently: "the same output should always lead to the same visual representation of the output" is characteristic of a function, not specifically of a hash function (which can be defined as a function behaving as if it had been chosen at random among functions with some domains). $\endgroup$
    – fgrieu
    Jun 26, 2020 at 9:40
  • $\begingroup$ Also: do you want similar inputs (e.g. differing only in their very end) to give similar outputs, or on the contrary dissimilar outputs, just as dissimilar inputs would do? Only the later would qualify as a hash. Do you need a recognizable theme (living creatures like CryptoKitties) or would any abstract "representation" do the job? Roughtly, how many different outputs should there be: thousands, millions, billions ($10^9$), trillions ($10^{12}$)…? $\endgroup$
    – fgrieu
    Jun 26, 2020 at 9:46
  • 2
    $\begingroup$ I think the question could be boiled down to "visual encoding of a hash". Example: A $16 \times 16$ grid, if the first bit in the bitstring is a 1, the first grid is black, if the first bit in the bitstring is a 0, the first grid is white, etc. $\endgroup$ Jun 26, 2020 at 9:53
  • 1
    $\begingroup$ @fgrieu Thanks! "Non-textual" can surely be replaced by image in this context. Audio isn't fruitful for my use-case. Since output of a hash function is a bitstring which is then transformed into text, so like Aleksander said I am looking for a visual encoding of a hash perhaps. But a simple 16x16 grid image or QR code isn't sufficient. It definitely needs to be a character like visual that we humans can identify it to be unique on the basis of difference between characteristics of the generated character. It should function exactly like hash, meaning small change results into diff output. $\endgroup$
    – Ashfame
    Jun 26, 2020 at 10:58
  • 3
    $\begingroup$ I’m voting to close this question because Has nothing to do with Cryptography. This is output encoding. $\endgroup$
    – kelalaka
    Jun 26, 2020 at 11:50

1 Answer 1

0
$\begingroup$

This is a pure encoding problem, as @kelalaka said. Take any reasonable hash algorithm like SHA-512. You have all qualities that you mentioned - not reversable, low probability of collisions, etc. What needs top be done, is to encode this hash into a picture.

To algorithm: look for instance at automatic generation of avatars at Stack Exchange to get one of possible simple ideas.

If you use SHA-512: The hash consists of 64 bytes. Consider it as a matrix of 8x8 elements, for each element define 256 values. These 256 values can be a combination of simple elements, e.g. 4 elements each having 4 states.

$\endgroup$
7
  • $\begingroup$ It finally hit me, my function can be two functions internally. One an existing hashing function piping its output into an encoding function responsible for character generation. Thanks everyone for taking the time to help me with this :) I don't follow the explanation you provided in last para, except that certain bits of the hash can be inputs for certain characteristics and then its all put together at render. $\endgroup$
    – Ashfame
    Jun 26, 2020 at 14:02
  • $\begingroup$ What part is not clear? SHA-512 is a sequence of 512 bits. This can be seen as a sequence of 64 bytes x 8 bits. Right? It doesn't matter how represent these byte. It may be a sequence, but you can also put them to a matrix. Make a matrix 8x8. It has 64 elements. In each element put one byte from the hash, in some particular order thaty ou like, e.g. left to right, top down. Each byte is a 8-bit number. You can see that as numbers from 0 to 255. So you have matrix 8x8 and each element is a number between 0 and 255. $\endgroup$
    – mentallurg
    Jun 26, 2020 at 15:58
  • $\begingroup$ Now assign some graphical elements to these numbers. E.g. take 16 figures (square filled, square without filling, circle, triangle, diagonal line, etc.) and 16 colors (red, green, blue, white, ...). Translate numbers to graphical elements, for instance: 0 = square red, 1 = square green, 2 = square blue, ..., 254 = circle green, 255 = circle blue. $\endgroup$
    – mentallurg
    Jun 26, 2020 at 16:07
  • $\begingroup$ The resulting picture will look abstract like many avatars on SE. But I hope you got the idea. To get some meaningful pictures you do basically the same. For instance you take some base pictures (cat, dog, bird, etc.), define what elements are changeable (eyes looking left, eyes looking right, tail to the left, tail to the right, etc.). The approach is thge same. The number of possible combinations of elements for should be $2^{512}$. $\endgroup$
    – mentallurg
    Jun 26, 2020 at 16:12
  • $\begingroup$ By googling open source avatar generator I landed on this, which has an online demo (click random repeatedly for an idea of what it gives). Replacing the RNG of that code with something based on the output of SHA-512 should do. $\endgroup$
    – fgrieu
    Jun 26, 2020 at 16:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.