Implementation of a Generalized-Feistel Cipher for generating random permutations.
Project description
🎲 gfc — fast & lazy random permutations
gfc is a C implementation of a Generalized-Feistel Cipher [1, alg. 3] for generating random permutations.
It uses Speck 64/128 as the random function, and can generate permutations with up to 2^64
elements.
The permutation is computed, and reversed, on-the-fly, without any mutable state and by using very little memory.
Usage
C / C++
API
#include <gfc/gfc.h>
GFC* gfc_init(uint64_t range, uint64_t rounds, uint64_t seed);
void gfc_destroy(GFC* gfc);
uint64_t gfc_decrypt(const GFC* gfc, uint64_t m);
uint64_t gfc_encrypt(const GFC* gfc, uint64_t m);
Example
// main.c
// gcc -Iinclude/ src/gfc.c main.c -o main
#include <assert.h>
#include <gfc/gfc.h>
int main() {
GFC* gfc = gfc_init(65536, 6, 42);
for (uint64_t i = 0; i < 65536; i++) {
uint64_t enc = gfc_encrypt(gfc, i);
uint64_t dec = gfc_decrypt(gfc, enc);
assert(enc != i);
assert(dec == i);
}
gfc_destroy(gfc);
return 0;
}
CMake Integration
cmake_minimum_required(VERSION 3.12)
project(example)
add_subdirectory(gfc)
add_executable(main main.c)
target_link_libraries(main PRIVATE gfc)
git submodule add https://github.com/maxmouchet/gfc.git
mkdir build && cd build
cmake .. && cmake --build .
./main
Python
pip install pygfc
from pygfc import Permutation
# Permutation(range, rounds, seed)
perm = Permutation(2 ** 16, 8, 42)
assert set(perm) == set(range(2 ** 16))
assert all(perm.inv(perm[i]) == i for i in range(2 ** 16))
Dependencies
The Speck implementation is from madmo/speck and is licensed under the ISC license (MIT-compatible).
References
[1] Black, John, and Phillip Rogaway. "Ciphers with arbitrary finite domains." Cryptographers’ track at the RSA conference. Springer, Berlin, Heidelberg, 2002. https://web.cs.ucdavis.edu/~rogaway/papers/subset.pdf
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for pygfc-1.0.5-pp38-pypy38_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 494f39c4c8b4629eed35e6792c16f2893d54baa82ae89b88e9b9a25b1cda82b0 |
|
MD5 | 005544acd32b26f6bf274e8ddc4e3f1b |
|
BLAKE2b-256 | 640d09c66df2bb361afd31a219701afbbed89edebd65e7ddc59e22734da93abf |
Hashes for pygfc-1.0.5-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c93a40950a01884e71009897892f90e3e7f493cd7ed59e93b03095c5a1b81c84 |
|
MD5 | c7dba6ce55e155652488484e5eb074f5 |
|
BLAKE2b-256 | 8c2080af0812a649b13e93bd7b53b0c458e92e5a6321ac2c742f1b72eb9b6fbf |
Hashes for pygfc-1.0.5-pp38-pypy38_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a3a2a92f6513e3b23ccda0fc9f55de523b0038699225aa2dd4b5ba22e6517b3 |
|
MD5 | 3b9c5742e68412b503a4be67d9998682 |
|
BLAKE2b-256 | 92bf12bd99f80e9b0df752b154bd96b0f38d4973252f082adb3bc3c450718f62 |
Hashes for pygfc-1.0.5-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b160e81056770c39ef63c188e332891243210da040dac9ed9e1996bb26e91ba6 |
|
MD5 | 6c9ef6625537665fc7341610f54124cd |
|
BLAKE2b-256 | 4290edadef9296e4bdb543c6953bc85b051dc30e01c507fcfead04f0a0fb3a43 |
Hashes for pygfc-1.0.5-pp37-pypy37_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0e0f07637f9fddd61664e21a20998ecd59c588c9e55a66ec76ca25b68a671d1 |
|
MD5 | 693eb003b9a3db0dc66d036f6255eeb6 |
|
BLAKE2b-256 | c6c5f5e3ec425f67a318feab062cf4f408bc787d02f1d19dc3647e12172a0211 |
Hashes for pygfc-1.0.5-pp37-pypy37_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3dc51ab6345dfc5bc2c7bd6cc7cbd711345d129fa1162a49440790d6b95fda0e |
|
MD5 | 1ee2289abd75e3116bfc4931e59016be |
|
BLAKE2b-256 | 52e8628a7d2edf571793fff5daba8ae1f7736b2a76bd35db92442e98b0a8af3e |
Hashes for pygfc-1.0.5-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 819bb4da04c8b740befa85f1727788164229be094e0fda1a69c02bcc6f2e820d |
|
MD5 | e65ac96f1828142f74156c8080c56a43 |
|
BLAKE2b-256 | e21beaae47f43de95c798d1093a6255f39e83be00d191c8054069c865e2b1beb |
Hashes for pygfc-1.0.5-cp310-cp310-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60efdaabdc8a8e0c02d87f56eecbdbcf53df5a851a700c21b6629c55270f4cad |
|
MD5 | 5bbe077931efe30f598acb6f2970ae00 |
|
BLAKE2b-256 | bc573f3f335185a14a7a83255f8b2466eaa8f8358cd8a4892c0d6fd1b86abf17 |
Hashes for pygfc-1.0.5-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 676d4036eb525de94b7c38f23698392364e50750bef55030b0c792cc723bd2b0 |
|
MD5 | b5f755375d42b98e4cfaa77e15c9f1d5 |
|
BLAKE2b-256 | bad4800d6ad98dce28c28b3410e0d462e174622d37638cf48ae683d77402cb97 |
Hashes for pygfc-1.0.5-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d04e8c0626570999ff9fb4a731b25eae0cf7ce91f5abc83f426cfa2e7e6c275 |
|
MD5 | 44cc06f866693849d606ce185be27c6f |
|
BLAKE2b-256 | 16efb913f47692138000665407acaff6e1a2f35dd5f9abb0f8be75aa1536009b |
Hashes for pygfc-1.0.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce951014fc3c1b7b402d1a349df425a8d06e76c166848f9c0d3e5688f60f22ba |
|
MD5 | 19cb6e36496792fd53bc79ab14629eb2 |
|
BLAKE2b-256 | 0d5ce778e28634aba00c246b1d69e1bcbb806256a2158c83eb991f4b1bf2b5cf |
Hashes for pygfc-1.0.5-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd51b29d43ce80419d89a4094abb8ae18bdf3dd305974e91830035596dfe3f92 |
|
MD5 | 9f4a8cb40c2dad7b782fc0ef66cf8efc |
|
BLAKE2b-256 | bf0d2a0a5a6f755dfd56f6cc300ab33c93a7bf001e09fe8e2f15a0c1f1775508 |
Hashes for pygfc-1.0.5-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 378cee6578989c7567c648092fa67745a430139319f85b2d95558137260ab4c6 |
|
MD5 | a43f283c702d581498ff42e08ca3e4f8 |
|
BLAKE2b-256 | 9df64ad6e70aadb17137fda095c7602c7218ac5f569f563e8aff7035d0ca828c |
Hashes for pygfc-1.0.5-cp39-cp39-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3526a9160b963b5d529b207819595e5438768d038f15b68c116e83dc93ea28f |
|
MD5 | ef8a489dbf7796c5afef25ffae556c43 |
|
BLAKE2b-256 | d077a8609e25e136d9386847350c6860f6aff1b22b0ad0c660db7e276e3d9827 |
Hashes for pygfc-1.0.5-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7464055da80027cd0ec08cfe80352170948075bbf14302bccaedbb769d519df3 |
|
MD5 | bca70208cfc683bff1047e11667361a8 |
|
BLAKE2b-256 | db8d03370c203af3058e81f219d2b7621ed9ad4a0ecf9354b43148fbc6887ca8 |
Hashes for pygfc-1.0.5-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a382419308c5316629d795f6fe0712f515485aabfddb9c80e5a24981a8046054 |
|
MD5 | 339ec3e8c1bd25305284a39b5a72f7c3 |
|
BLAKE2b-256 | ab60cae84fef416d2166d79ecf770a799a78780a85e68c73c41882d04a804644 |
Hashes for pygfc-1.0.5-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | da80f143aead77fb0b741029e179ae24a6569e57e38c7134bebb49745e42d020 |
|
MD5 | 0d7643f0c45d4ec2c5646788e351d0b6 |
|
BLAKE2b-256 | 05d74df925d119841de336ef4edf9494c3925b3b5cd9038febb2d43fb7f5bc80 |
Hashes for pygfc-1.0.5-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6c2e62b31711cf7f9befff6f2b4ca1b67cb3aaad3b2fe3239a91deea6255b9f |
|
MD5 | d3a23dd197a6bbbca61bf26dabfb5489 |
|
BLAKE2b-256 | 02d6199d3a4a82797d9e76f628ece56199d67fdb7cc83f60784ec85cb2745821 |
Hashes for pygfc-1.0.5-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 843797854cb203744536c49d2b3a27eecc7a66216bee5e18852b71a087a8de21 |
|
MD5 | f8d48bf66a61d89825368d139229607e |
|
BLAKE2b-256 | 2990b4f906ab0f5ad1d905cdb9f5dfee9c42312222a88d8ff55cfbf9c8f9fc12 |
Hashes for pygfc-1.0.5-cp38-cp38-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a709a8fb73e7473de24a2ad7e09cda2d5800530b1e5625c31bae1e478db76a8b |
|
MD5 | a8b0bb6a108fc73380e061dbf55a076e |
|
BLAKE2b-256 | 1a378d43f47b8d6afaec1a36657523dbf030b0054fab40dd45b77546aaf76d4b |
Hashes for pygfc-1.0.5-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 991770d4ea13a481cc29491b317cdb3aaf52b7010c0c6296cca6efcd821e0617 |
|
MD5 | 1e298029db4c2122d1624809294f3b2c |
|
BLAKE2b-256 | 48807231c02c74f9df1bb91d648c3212c7fa88ac2f71705f5ac30514d4129b5e |
Hashes for pygfc-1.0.5-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a1ff585e073c9e0a310406073b19b5b836e57bc948cb016658e9f9bcde54520 |
|
MD5 | 389de68bc0fe4e3b5f08b33300f56bee |
|
BLAKE2b-256 | 124991fc7ecdbdc362bf475e9cf44ce3a0f9c67f81d0d233c0a50f42e3618afa |
Hashes for pygfc-1.0.5-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7023d98aa927cf0795850e4dcbc130f37244a8167fd8ff1cf64dbb8b82551dd |
|
MD5 | c93f4752b7b267d578b9130610ed3adc |
|
BLAKE2b-256 | df73b52e93d784d4d637a63eb7f43880a393a7630d652251dc2eb29b4a739398 |
Hashes for pygfc-1.0.5-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2bee293c5dbc6bf2c4059438af0cb78b46d5ca85360e9b4f53ade3f81851f004 |
|
MD5 | 690ef56453424f789bea812ea1da05ad |
|
BLAKE2b-256 | 8df3b0a7964f52aa4534addba487a2ec8698ddaa512c62628e6da9246ff5cda7 |
Hashes for pygfc-1.0.5-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44a089b78a0bb9b7262897215a11e9ce8203f44466b7d6af3528ce76bd361fd1 |
|
MD5 | a6e8a5a6bf431dd866027f1578f5543a |
|
BLAKE2b-256 | 927ec5a088603486dee2744af3f8d70fedc2bdb7b976c61f9c3297283c26157d |
Hashes for pygfc-1.0.5-cp37-cp37m-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fff5aba9369814f2c41b2beab4fa0a423eaabe7329894ded0c1338c329a2b357 |
|
MD5 | 0b30a15e40b88119c8cc7d28930dfc11 |
|
BLAKE2b-256 | 3aafe87661faf4145dae372ef2a71bece67a81774f399b14b3a1f83d629da7d2 |
Hashes for pygfc-1.0.5-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5561bde1b4fdc447c5d05924bbb42c8fb8785e1e37ca4f939c81c296038bd03f |
|
MD5 | cd397fd9beb99daf5e2082e5c859f6fa |
|
BLAKE2b-256 | d396cc3dfa3b7d7f721e9a09805390729648b10423ad02f2dccf16c82fbf5eae |
Hashes for pygfc-1.0.5-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6dc9f4d8da11cb0eb79104a43523ad994a1aa22b870712c2b7a77d47b13440ba |
|
MD5 | ffded526554fe156a16b84b6fc1554c0 |
|
BLAKE2b-256 | a9dc1945d11819cf31a5d8bafca5385226b3207612c88111530396efe93742ba |
Hashes for pygfc-1.0.5-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1d032cd6e6f8b259d85d9c1093912aa6bcbe6b93e5f342c9cfffd7324dd6034 |
|
MD5 | 6a06dff42312b45cd0bdcf7d6a364e59 |
|
BLAKE2b-256 | 401baeff8aa4dde492827f4ece7f2f73dcaad4511444d4327dd2b3196291a9a2 |
Hashes for pygfc-1.0.5-cp36-cp36m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a728d6f0a28713510e40d4a7e365995d72af4f222df4761117a6b3b7330aa2a |
|
MD5 | 89e87a1bb8cd0df15f8cb1a7772424ea |
|
BLAKE2b-256 | b901ca0cd9489d05273857be2fcb4e4c606b4abcb0020a50459d05a271164cb7 |
Hashes for pygfc-1.0.5-cp36-cp36m-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1eaf8ca7542e79b8cc5dce51a26c72ecce01fa1162408f8c1eaf7af84e28f378 |
|
MD5 | 86b1a44d9a680d5e0676d0e463ac83d3 |
|
BLAKE2b-256 | 7cbf2bb43ef56c4ff242c9542d9c30e37109f9cb62cc329fd9e6e57f4a88a200 |
Hashes for pygfc-1.0.5-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c11cb233402171f59706cbfb452754bb5fb3fdcd2c562185a239dec5db620f7 |
|
MD5 | ae1a409c7e53e49a15d0dc2fd8b00ea4 |
|
BLAKE2b-256 | a6b4319bf8a440d8fb1edb68d34b3cc14f022818a2b025b7d1ccc73d0c394c6b |
Hashes for pygfc-1.0.5-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc4635c6feabdf74f6845a60b336234ce50b25bb38d4674cd7814b064dbfa6f7 |
|
MD5 | 6909b13bd46a8d2eb463398a112f3307 |
|
BLAKE2b-256 | ba7a318fb9a25b19e7dcd928af415398388818f89d31a75f7924277a533a689d |
Hashes for pygfc-1.0.5-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 258d2b175401003e68fa8dd3f6eb3f972b06be0942090212709ed23cf98239d1 |
|
MD5 | f7f9848959b5ed07d3e9164beafb9407 |
|
BLAKE2b-256 | 3fc10309a282de267b191170710562fa42422f37d3bf8edc6503fc1a96d0b0bc |