Skip to content
This repository was archived by the owner on Feb 21, 2022. It is now read-only.
This repository was archived by the owner on Feb 21, 2022. It is now read-only.

Use unbalanced feistel ciphers to improve performance #8

@ioleo

Description

@ioleo

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions