cryptomute icon indicating copy to clipboard operation
cryptomute copied to clipboard

Use unbalanced feistel ciphers to improve performance

Open ioleo opened this issue 8 years ago • 0 comments

Currently the cipher operates on 2n powers of 2, becouse to produce a balanced feistel cipher an even number of bits (divisible into 2) is required. However this costs performance, becouse to make sure the output is smaller than maxValue we have to repeat encryption/decryption until the result fits. The larger the gap between 0 and minValue and maxValue and 2n - the more iterations on average it will take.

Luby and Rackoff have proved that if we use the next power of 2 greater or equal to maxValue the number of operations (on average) required to produce the result will be 2.

Current implementation uses the "closest EVEN" power of 2.

This is probably not a big issue, as this library is blazingly fast anyways, but should be investigated.

ioleo avatar Feb 17 '16 10:02 ioleo