Labyrinth is the equivalent of a one-way hash function, and scales to messages of arbitrary size. The building block of Labyrinth is a recursive, iterative function that is equivalent to the compression function in a hash function. The message is used as a "map" and the ledger itself as the topography that the "map" traverses, outputting a random number that can be understood as the message getting "lost" in a labyrinth, unable to find its way back (a one-way function. )
The Labyrinth is computed on the state (s) of the ledger (l), the state s, recorded together with the hash, and hashes are verified on state s.
The message (m) in bits, represented as a number, is the Initialization Vector (IV) for a "treasureMap" (t) that maps to a point (x) in the ledger (l), treasureMap modulo ledger, x = t%l. This point (x), recursively, maps to a bit (d) in the treasureMap, d = n+ x%t, where n is a nonce that is incremented every iteration of the labyrinth function. The bit d is stored in memory, and the treasureMap is bit-shifted d>>1. The bit d is transformed with a XOR operation, d ⊕ (x+t)%2, and the value loaded onto the last bit of treasureMap, previously set to 0 by the bit-shift operation. The nonce n is incremented by 1, n += 1. The function is repeated Math.ceil(log2(m)) times.
To get outputs of fixed size, the output can be split into blocks of fixed size, and the blocks combined with XOR operation.