Skip to content

Commit

Permalink
Feat/new estimator script (#59)
Browse files Browse the repository at this point in the history
* feat: new script to create estimators

* feat: create script for new estimator template

* delete old create estimator scripts

* refactor: delete dummy estimator from input_dictionary

* refactor: update problem template

* refactor: update estimator template

* refactor: update algorithm template

* refactor: update estimator templates

* refactor: update create estimator scripts

* refactor: change Dummy estimator to its original version

* refactor: delete created estimator as example

---------

Co-authored-by: ariane <[email protected]>
  • Loading branch information
0fprod and arianezf authored Apr 4, 2023
1 parent bfbb854 commit 223c5ff
Show file tree
Hide file tree
Showing 45 changed files with 803 additions and 414 deletions.
2 changes: 1 addition & 1 deletion cryptographic_estimators/DummyEstimator/dummy_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __repr__(self):
"""
"""
par1, par2 = self.get_parameters()
rep = "dummy problem with (problem_parameter1, problem_parameter2) = " \
rep = "Dummy problem with (problem_parameter1, problem_parameter2) = " \
+ "(" + str(par1) + "," + str(par2) + ")"

return rep
17 changes: 17 additions & 0 deletions cryptographic_estimators/LEEstimator/LEAlgorithms/bbps.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# ****************************************************************************
# Copyright 2023 Technology Innovation Institute
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# ****************************************************************************

from ..le_algorithm import LEAlgorithm
from ..le_problem import LEProblem
from ..le_constants import *
Expand Down
17 changes: 17 additions & 0 deletions cryptographic_estimators/LEEstimator/LEAlgorithms/beullens.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# ****************************************************************************
# Copyright 2023 Technology Innovation Institute
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# ****************************************************************************

from ..le_algorithm import LEAlgorithm
from ..le_problem import LEProblem
from ..le_constants import *
Expand Down
17 changes: 17 additions & 0 deletions cryptographic_estimators/LEEstimator/LEAlgorithms/leon.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# ****************************************************************************
# Copyright 2023 Technology Innovation Institute
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# ****************************************************************************

from ..le_algorithm import LEAlgorithm
from ..le_problem import LEProblem
from ...PEEstimator import Leon as PELeon
Expand Down
17 changes: 17 additions & 0 deletions cryptographic_estimators/LEEstimator/le_constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# ****************************************************************************
# Copyright 2023 Technology Innovation Institute
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# ****************************************************************************

from enum import Enum


Expand Down
17 changes: 17 additions & 0 deletions cryptographic_estimators/LEEstimator/le_helper.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# ****************************************************************************
# Copyright 2023 Technology Innovation Institute
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# ****************************************************************************

from math import log2, inf, \
comb as binomial

Expand Down
17 changes: 17 additions & 0 deletions cryptographic_estimators/PEEstimator/PEAlgorithms/beullens.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# ****************************************************************************
# Copyright 2023 Technology Innovation Institute
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# ****************************************************************************

from ..pe_algorithm import PEAlgorithm
from ..pe_problem import PEProblem
from ..pe_constants import *
Expand Down
17 changes: 17 additions & 0 deletions cryptographic_estimators/PEEstimator/PEAlgorithms/leon.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# ****************************************************************************
# Copyright 2023 Technology Innovation Institute
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# ****************************************************************************

from ...PEEstimator.pe_algorithm import PEAlgorithm
from ...PEEstimator.pe_problem import PEProblem
from ...base_algorithm import optimal_parameter
Expand Down
17 changes: 17 additions & 0 deletions cryptographic_estimators/PEEstimator/PEAlgorithms/ssa.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# ****************************************************************************
# Copyright 2023 Technology Innovation Institute
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# ****************************************************************************

from ...PEEstimator.pe_algorithm import PEAlgorithm
from ...PEEstimator.pe_problem import PEProblem
from math import log, log2
Expand Down
17 changes: 17 additions & 0 deletions cryptographic_estimators/PEEstimator/pe_constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# ****************************************************************************
# Copyright 2023 Technology Innovation Institute
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# ****************************************************************************

from enum import Enum

PE_CODE_LENGTH = "code length"
Expand Down
17 changes: 17 additions & 0 deletions cryptographic_estimators/PEEstimator/pe_helper.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# ****************************************************************************
# Copyright 2023 Technology Innovation Institute
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# ****************************************************************************

from math import comb as binomial, log2, factorial
from random import randint

Expand Down
17 changes: 17 additions & 0 deletions cryptographic_estimators/PKEstimator/PKAlgorithms/kmp.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# ****************************************************************************
# Copyright 2023 Technology Innovation Institute
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# ****************************************************************************

from ..pk_algorithm import PKAlgorithm
from ..pk_problem import PKProblem
from ..pk_constants import *
Expand Down
17 changes: 17 additions & 0 deletions cryptographic_estimators/PKEstimator/PKAlgorithms/sbc.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# ****************************************************************************
# Copyright 2023 Technology Innovation Institute
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# ****************************************************************************

from ..pk_algorithm import PKAlgorithm
from ..pk_problem import PKProblem
from ..pk_constants import *
Expand Down
17 changes: 17 additions & 0 deletions cryptographic_estimators/PKEstimator/pk_constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# ****************************************************************************
# Copyright 2023 Technology Innovation Institute
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# ****************************************************************************

from enum import Enum


Expand Down
17 changes: 17 additions & 0 deletions cryptographic_estimators/PKEstimator/pk_helper.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# ****************************************************************************
# Copyright 2023 Technology Innovation Institute
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# ****************************************************************************

from math import log2, comb as binomial, factorial, inf


Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# ****************************************************************************
# Copyright 2023 Technology Innovation Institute
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# ****************************************************************************


import collections
from .scipy_model import ScipyModel
Expand All @@ -30,13 +30,17 @@ def __init__(self, par_names: list, problem: SDProblem, iterations, accuracy):
super().__init__(par_names, problem, iterations, accuracy)

def _build_model_and_set_constraints(self):
self.L1 = lambda x: binomial_approximation(self.rate(x) / 2, x.p / 2) + binomial_approximation(x.l / 2, x.pl / 2)
self.L1 = lambda x: binomial_approximation(
self.rate(x) / 2, x.p / 2) + binomial_approximation(x.l / 2, x.pl / 2)

self.constraints = [
{'type': 'ineq', 'fun': self._inject_vars(lambda x: self.rate(x) - x.p)},
{'type': 'ineq', 'fun': self._inject_vars(
lambda x: self.rate(x) - x.p)},
{'type': 'ineq', 'fun': self._inject_vars(lambda x: x.l - x.pl)},
{'type': 'ineq', 'fun': self._inject_vars(lambda x: (1. - self.rate(x) - x.l) - (self.w(x) - x.p - x.pl))},
{'type': 'ineq', 'fun': self._inject_vars(lambda x: self.w(x) - x.p - x.pl)},
{'type': 'ineq', 'fun': self._inject_vars(lambda x: (
1. - self.rate(x) - x.l) - (self.w(x) - x.p - x.pl))},
{'type': 'ineq', 'fun': self._inject_vars(
lambda x: self.w(x) - x.p - x.pl)},
]

def _memory(self, x):
Expand All @@ -50,7 +54,8 @@ def _time_perms(self, x):
binomial_approximation(1., self.w(x))
- binomial_approximation(self.rate(x), x.p)
- binomial_approximation(x.l, x.pl)
- binomial_approximation(1 - self.rate(x) - x.l, self.w(x) - x.p - x.pl)
- binomial_approximation(1 - self.rate(x) -
x.l, self.w(x) - x.p - x.pl)
- self.nsolutions
)

Expand Down
Loading

0 comments on commit 223c5ff

Please sign in to comment.