diff --git a/.envrc b/.envrc new file mode 100644 index 0000000000000000000000000000000000000000..1d953f4bd73593aba0a2af3db2d14178e2b8b9fe --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use nix diff --git a/dilithium.nix b/dilithium.nix new file mode 100644 index 0000000000000000000000000000000000000000..7500c564ce5d05c8378212267d809772e2b1d38c --- /dev/null +++ b/dilithium.nix @@ -0,0 +1,27 @@ +{ + buildPythonPackage, + fetchPypi, + + # propagates + numpy, + pycryptodome, +}: + +buildPythonPackage rec { + pname = "dilithium"; + version = "1.0.6"; + + src = fetchPypi { + inherit pname version; + hash = "sha256-PZeFjvUCuIM3AGpTY/j6Pi9VrpWPYFEBWgltnqWtOeo="; + }; + + propagatedBuildInputs = [ + numpy + pycryptodome + ]; + + pythonImportsCheck = [ + "dilithium" + ]; +} \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000000000000000000000000000000000000..aa074e99e915d5c651f44f22cb6f6c1029c20333 --- /dev/null +++ b/main.py @@ -0,0 +1,7 @@ +import dilithium.dilithium +from dilithium import Dilithium + +d1 = Dilithium(dilithium.dilithium.DEFAULT_PARAMETERS["dilithium3"]) +a, b = d1.keygen([1,2,3,4]) +print(a) +print(b) \ No newline at end of file diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000000000000000000000000000000000000..cab8b677118be0489574166b78b771a5b040e068 --- /dev/null +++ b/shell.nix @@ -0,0 +1,14 @@ +{ + pkgs ? import <nixpkgs> { }, +}: +let + mypython = pkgs.python3.withPackages (python-pkgs: [ + python-pkgs.numpy + (python-pkgs.callPackage ./dilithium.nix { }) + ]); +in +pkgs.mkShell { + buildInputs = [ + mypython + ]; +} \ No newline at end of file