A generalised Feistel cipher that implements format-preserving encryption, bijectively mapping
For this implementation of the generalised Feistel cipher, the selection of parameters
where
It follows that the upper bound of cycle-walking iterations
With an input domain
According to [3], performing
We do a little empirical testing to show the randomness of permutations generated by GFC-FPE.
The following figure shows the permuted indices (y-axis) for each input (x-axis) in a domain of size
The following figure plots 10 instances of GFC-FPE outputs with the same configuration as above, but using a different 256-bit random seed for each instance.
[1] John Black and Phillip Rogaway. 2002. Ciphers with arbitrary finite domains. In Topics in Cryptology—CT-RSA 2002: The Cryptographers’ Track at the RSA Conference 2002 San Jose, CA, USA, February 18–22, 2002 Proceedings, Springer, 114–130.
[2] Bruce Schneier and John Kelsey. 2005. Unbalanced Feistel networks and block cipher design. In Fast Software Encryption: Third International Workshop Cambridge, UK, February 21–23 1996 Proceedings, Springer, 121–144.
[3] Michael Luby and Charles Rackoff. 1988. How to construct pseudorandom permutations from pseudorandom functions. SIAM Journal on Computing 17, 2 (1988), 373–386.
[4] Viet Tung Hoang and Phillip Rogaway. 2010. On Generalized Feistel Networks. In CRYPTO, Springer, 613–630.
[5] Vitalik Buterin. 2018. feistel_shuffle.py
. In ethereum/research.