Skip to content

Commit

Permalink
Merge branch 'develop' into feature/add_kat_tests_parallelization
Browse files Browse the repository at this point in the history
  • Loading branch information
Javierverbel authored Mar 4, 2025
2 parents 65a69df + 074984a commit bda32fb
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 88 deletions.
27 changes: 19 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractiv
ENV SAGE_PKGS=/usr/share/sagemath/installed
FROM ubuntu:24.10
ENV DEBIAN_FRONTEND=noninteractive

WORKDIR "/home/cryptographic_estimators/"
RUN apt update && apt install -y sagemath && pip install toml
# Avoid the download and installation of dependencies on rebuild;
# but without harcoding them

RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
python3-venv \
&& rm -rf /var/lib/apt/lists/*

# Create and activate virtual environment
RUN python3 -m venv ../venv
ENV PATH="../venv/bin:$PATH"

# # Avoid the download and installation of dependencies on rebuild;
# # but without harcoding them
RUN pip install toml
COPY ./pyproject.toml ./
COPY ./scripts/generate_requirements.py ./scripts/
RUN python3 scripts/generate_requirements.py
RUN sage -python3 -m pip install -r requirements.txt && rm -r ./*
RUN pip install -r requirements.txt && rm -r ./*
COPY . .
RUN sage -python3 -m pip install --no-deps .
RUN pip install --no-deps .
11 changes: 6 additions & 5 deletions cryptographic_estimators/SDEstimator/SDAlgorithms/bjmm_dw.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@
inf,
)
from scipy.special import binom as binom_sp
from scipy.optimize import fsolve
from scipy.optimize import root
from warnings import filterwarnings
from types import SimpleNamespace
from ..sd_constants import *


filterwarnings("ignore", category=RuntimeWarning)


Expand Down Expand Up @@ -220,10 +221,10 @@ def f(x):
)

l1_val = int(
fsolve(
root(
f,
2 * log2((binom(par.p, par.p // 2) * binom(k // 2 - par.p, par.p1 - par.p // 2))),
)[0]
2 * log2((binom(par.p, par.p // 2) * binom(k // 2 - par.p, par.p1 - par.p // 2))),method='hybr'
).x[0]
)
except ValueError:
return -1
Expand All @@ -245,7 +246,7 @@ def f(x):
x = float(x)
return log2(list_size) + 2 * log2(binom_sp(x, par.w2) + 1) - 2 * x

l2_val = int(fsolve(f, 50)[0])
l2_val = int(root(f, log2(list_size)/2,method='hybr').x[0])
except ValueError:
return -1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def inverse_binary_entropy(v: float):
if v < 0.00001:
return 0

return fsolve(lambda x: v - (-x * log2(x) - (1 - x) * log2(1 - x)), 0.0000001)[0]
return fsolve(lambda x: v - (-x[0] * log2(x[0]) - (1 - x[0]) * log2(1 - x[0])), 0.0000001)[0]


def binary_entropy(c: float):
Expand Down
13 changes: 7 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
[build-system]
requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.2"]
requires = ["setuptools>=45", "wheel"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]

[project]
name = "cryptographic_estimators"
#license = "Apache-2.0"
Expand Down Expand Up @@ -39,11 +37,14 @@ Documentation = "https://github.com/Crypto-TII/CryptographicEstimators/blob/main
Repository = "https://github.com/Crypto-TII/CryptographicEstimators"
Issues = "https://github.com/Crypto-TII/CryptographicEstimators/issues"

[tool.setuptools]
packages = ["cryptographic_estimators", "tests"]
[tool.setuptools.packages.find]
where = ["."] # Look for packages starting from the current directory
include = ["cryptographic_estimators*"] # Include any package/module that starts with "cryptographic_estimators"
namespaces = true # Properly handle nested package structures

[tool.setuptools.package-data]
cryptographic_estimators = ["*"]
"*" = ["*"] # Include all files in all discovered packages
cryptographic_estimators = ["**/*"] # The "**" means "recursive", so it includes files in subdirectories

[tool.pytest.ini_options]
addopts = "-v --import-mode=importlib"
Expand Down
2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

66 changes: 0 additions & 66 deletions setup.py

This file was deleted.

0 comments on commit bda32fb

Please sign in to comment.