From 84777eab2ca7de0a464aba69ca2b246e29a8bf80 Mon Sep 17 00:00:00 2001 From: Johannes_Hitzinger <johannes.hitzinger@h-da.de> Date: Thu, 5 Dec 2024 10:37:13 +0100 Subject: [PATCH] initial commit with dilithium working via nix dont create new venv, handle "which python" path as venv --- .envrc | 1 + dilithium.nix | 27 +++++++++++++++++++++++++++ main.py | 7 +++++++ shell.nix | 14 ++++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 .envrc create mode 100644 dilithium.nix create mode 100644 main.py create mode 100644 shell.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..1d953f4 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use nix diff --git a/dilithium.nix b/dilithium.nix new file mode 100644 index 0000000..7500c56 --- /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 0000000..aa074e9 --- /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 0000000..cab8b67 --- /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 -- GitLab