NZ Algorithm

A block

NZ operates on blocks of data consisting of 256 bytes.

Figure representing a block of data for NZ encoding algorithm

Figure 1 : representation of a block of data for NZ encoding algorithm

Master key

A master key is made from 4 components:

  • k: is an array of 256 unique bytes. No value can be repeated, every values must be represented.
  • a: 64 bit unsigned int used in the pseudo random number generator.
  • b: 64 bit unsigned int used in the pseudo random number generator.
  • c: 64 bit unsigned int used in the pseudo random number generator.
  • s: block number sequence offset.
Figure representing a key for NZ algorithm

Figure 2 : Structure and components of an NZ key.

Block specific data generation

Block Number

Each block encoding/decoding require block specific data derived from current block number. The block number is current sequence number starting with 1 plus the key offset (key component s).

Block Entropy

Each block requires the computation of 257 bytes of fully deterministic entropy. This is computed using the function get_block_entropy. This function uses components a, b, c with the block number to compute the data. See details in source code.

Block Key

Each block requires a unique key. Only component k is computed for the block key. This is generated using function get_block_key. See details in source code.

Block encoding

Permutation

The first pass of block encoding is the permutation. This step is done using the block key. Every nth element of the data block is exchanged with the element in data block at position indicated by the nth element of the block key.

Masking

The second pass of block encoding is the masking. This step uses the first 256 elements of the block entropy data to perform XOR operation on permutated block data.

Inflate 4x

The third pass is using the inflate 4x algorithm using the master key to randomize the data more. This is completely optional, it is kept for historical reason more than security reason.