you can use a 3 round feistel network as a generic PRP with a set size of any even number of bits.Daniel Shawul wrote:It can be slow as hell since it is done one time. Can you give an example of a PRP that can generate permutation of [0..N] integers where N can be as big as a million?kbhearn wrote:How fast does it need to be? If it can have some computational overhead to iterate through a random partition then you could use a pseudorandom permutation and not need to store the results of the permutation, just use it to translate indexes as you need them. Changing the key would give you a different partitioning.
i.e. translate indexes 0->N/k through a PRP, repeat for next N/k if you want another partition, the PRP guarantees that each starting index will correspond to a unique finishing index.
Then you can convert the n-bit PRP to a PRP from 0...N by running any index > N through the PRP again until you get an index < N (hence you want to keep the order close).
i.e. if 1 million was your N, then you'd use 20 bits for your base PRP.
and if index 3 happens to map to 1031000 which is outside your set, then you'd rerun it and map from 1031000 instead, ultimately it results in a PRP with an arbitrary range - at worst you have to run the PRP an average of 4 times per index if your N is (2^a) + 1 which would require a base PRP of size 2^(a+2) when a is even. when a is odd it'd just be 2^(a+1)