CubeHash: a simple hash function |
|
Introduction to CubeHashCubeHash is a very simple cryptographic hash function. Here's how CubeHash works.The inputs to CubeHash are
The message is first padded to create a sequence of b-byte input blocks. Padding works as follows: append a 1 bit; then append the minimum possible number of 0 bits to reach a multiple of 8b bits. (The bits in a byte are first 128, then 64, then 32, then 16, then 8, then 4, then 2, then 1.) Implementations restricted to byte-aligned messages can simply append a 128 byte and then the minimum possible number of 0 bytes to reach a multiple of b bytes. CubeHash maintains a 128-byte state. It xors the first b-byte input block into the first b bytes of the state, transforms the state invertibly through r identical rounds, xors the next b-byte input block into the first b bytes of the state, transforms the state invertibly through r identical rounds, xors the next b-byte input block into the first b bytes of the state, transforms the state invertibly through r identical rounds, etc. The 128-byte state is viewed as a sequence of 32 4-byte words x[00000], x[00001], x[00010], x[00011], x[00100], ..., x[11111], each of which is interpreted in little-endian form as a 32-bit integer. A round has the following ten steps:
CubeHash produces the initial state as follows. Set the first three state words x[00000], x[00001], x[00010] to the integers h/8, b, r respectively. Set the remaining state words to 0. Then transform the state invertibly through i rounds. Of course, the implementor can eliminate these transformations at the expense of storage by precomputing the initial state for any particular h,b,r. After all input blocks are handled, CubeHash produces the final hash as follows. Xor the integer 1 into the last state word x[11111]. Transform the state invertibly through f rounds. Finally, output the first h/8 bytes of the state. Overall a round has 32 32-bit additions and 32 32-bit xors, so CubeHashr/b has 32r/b 32-bit additions and 32r/b 32-bit xors for each byte of the padded message; in other words, 128r/b bit additions and 128r/b bit xors for each bit of the padded message. The finalization has 32f 32-bit additions and 32f 32-bit xors, comparable cost to handling fb/r bytes of input. The initialization, if not precomputed, has 32i 32-bit additions and 32i 32-bit xors, comparable cost to handling ib/r bytes of input. My main recommendation is CubeHash512, defined as CubeHash16+16/32+32–512. CubeHash512 uses 16 32-bit additions and 16 32-bit xors for each byte of the padded message. Finalization has comparable cost to handling 16 bytes of input. Initialization has comparable cost to handling 8 bytes of input. VersionThis is version 2010.12.03 of the index.html web page. |