Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fb7b05c

Browse files
author
Jens Alich
committedMar 10, 2025
make sboxU an installable python package via pip and nix
1 parent 075232f commit fb7b05c

13 files changed

+219
-7748
lines changed
 

‎.gitignore

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1+
# ignore build output
2+
build/
13
# ignore compiled files
24
*.pyc
35
*.so
4-
sboxU/sboxU_cython/cpp_ccz.cpp
5-
sboxU/sboxU_cython/cpp_diff_lin.cpp
6-
sboxU/sboxU_cython/cpp_equiv.cpp
7-
sboxU/sboxU_cython/cpp_fp.cpp
8-
sboxU/sboxU_cython/cpp_utils.cpp
9-
sboxU/sboxU_cython/cpp_diff_lin_no_fp_lat.cpp
10-
sboxU/sboxU_cython/build/
6+
/sboxU/sboxU_cython/cpp_ccz.cpp
7+
/sboxU/sboxU_cython/cpp_diff_lin.cpp
8+
/sboxU/sboxU_cython/cpp_equiv.cpp
9+
/sboxU/sboxU_cython/cpp_fp.cpp
10+
/sboxU/sboxU_cython/cpp_utils.cpp
11+
/sboxU/sboxU_cython/cpp_diff_lin_no_fp_lat.cpp
12+
/sboxU/sboxU_cython/cpp_equiv_approx.cpp
1113
# ignore automatically generated files
1214
*~
13-

‎default.nix

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
packageName,
3+
packageVersion,
4+
5+
buildPythonPackage,
6+
7+
# build-system
8+
gcc,
9+
setuptools_scm,
10+
cython,
11+
}:
12+
13+
let
14+
in buildPythonPackage rec {
15+
pname = packageName;
16+
version = packageVersion;
17+
pyproject = true;
18+
build-system = [ setuptools_scm ];
19+
src = ./.;
20+
21+
propagatedBuildInputs = [
22+
gcc
23+
cython
24+
];
25+
26+
# pythonImportsCheck = [ packageName ]; # we currently build using python and not sage, thus import checking is not possible
27+
28+
meta = {
29+
description = "SAGE/Python functions useful for studying S-boxes and Boolean functions such as computing the DDT, computing the Walsh spectrum, affine equivalence testing...";
30+
homepage = "https://github.com/lpp-crypto/sboxU";
31+
};
32+
}
33+

‎flake.lock

+27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎flake.nix

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
description = "SAGE/Python functions useful for studying S-boxes and Boolean functions such as computing the DDT, computing the Walsh spectrum, affine equivalence testing...";
3+
4+
inputs = {
5+
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-24.05";
6+
};
7+
8+
outputs = { self, nixpkgs }: let
9+
system = "x86_64-linux";
10+
pkgs = import nixpkgs { inherit system; };
11+
packageName = "sboxU";
12+
packageVersion = "1.0.0";
13+
in {
14+
15+
packages."${system}" = {
16+
"${packageName}" = pkgs.python3Packages.callPackage ./default.nix {
17+
inherit packageName packageVersion;
18+
};
19+
20+
default = self.packages."${system}"."${packageName}";
21+
22+
overlay = (final: prev: {
23+
pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [
24+
(final: prev: {
25+
"${packageName}" = self.packages."${system}".default;
26+
})
27+
];
28+
});
29+
};
30+
31+
devShell."${system}" = let
32+
pkgs = import nixpkgs {
33+
inherit system;
34+
overlays = [ self.packages."${system}".overlay ];
35+
};
36+
37+
customSage = pkgs.sage.override {
38+
requireSageTests = false;
39+
extraPythonPackages = ps: with ps; [
40+
ps."${packageName}"
41+
];
42+
};
43+
customPython = with pkgs; (pkgs.sage.withPackages (ps: [
44+
ps."${packageName}"
45+
]));
46+
47+
packages = [ customSage ];
48+
in pkgs.mkShell {
49+
inherit packages;
50+
};
51+
52+
};
53+
}
54+

‎pyproject.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = [ "setuptools", "wheel", "cython" ]
3+
build-backend = "setuptools.build_meta"

‎sboxU/sboxU_cython/cpp_ccz.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Time-stamp: <2023-12-05 10:36:16 leo>
33

44
import os
5-
from sboxu_cpp_no_fp_lat cimport *
5+
from sboxU.sboxU_cython.sboxu_cpp_no_fp_lat cimport *
66
from math import log
77

88

‎sboxU/sboxU_cython/cpp_diff_lin.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import os
55
from libcpp cimport bool
66
from libcpp.vector cimport vector
77
from libc.stdint cimport int64_t, uint64_t
8-
from sboxu_cpp cimport *
8+
from sboxU.sboxU_cython.sboxu_cpp cimport *
99
import os
1010
from sage.all import Integer
1111

‎sboxU/sboxU_cython/cpp_equiv.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Time-stamp: <2023-01-04 15:57:08 lperrin>
33

44
import os
5-
from sboxu_cpp_no_fp_lat cimport *
5+
from sboxU.sboxU_cython.sboxu_cpp_no_fp_lat cimport *
66

77
def linear_equivalence_fast(l0, l1, all_mappings):
88
return linear_equivalence_cpp(l0, l1, all_mappings)

0 commit comments

Comments
 (0)
Please sign in to comment.