Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: degree regulairty Minors in MREstimator #223

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions cryptographic_estimators/MREstimator/MRAlgorithms/minors.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from ..mr_helper import minors_polynomial_degree
from ..mr_constants import MR_NUMBER_OF_KERNEL_VECTORS_TO_GUESS, MR_NUMBER_OF_COEFFICIENTS_TO_GUESS


class Minors(MRAlgorithm):
def __init__(self, problem: MRProblem, **kwargs):
"""Construct an instance of Minors estimator.
Expand All @@ -44,6 +43,11 @@ def __init__(self, problem: MRProblem, **kwargs):
super(Minors, self).__init__(problem, **kwargs)

q, m, n, k, r = self.problem.get_parameters()

if k >= (m - r) * (n - r):
raise ValueError(
"It should hold that k < (m - r) * (n - r)")

self.set_parameter_ranges('a', 0, min(n - r, ceil(k / m)))
self.set_parameter_ranges('lv', 0, min(r, k) - 1)
self._name = "Minors"
Expand Down Expand Up @@ -91,7 +95,7 @@ def lv(self):
def _ME_time_memory_complexity_helper_(self, m: int, n_reduced: int, k_reduced: int, r: int, time_mem: str):
out = 0
if k_reduced > 0 and n_reduced > r:
D = minors_polynomial_degree(m, n_reduced, k_reduced, r)
D = minors_polynomial_degree(m, n_reduced, k_reduced, r) + 1
if time_mem == "time":
w = self._w
out = w * log2(binomial(k_reduced + D, D))
Expand All @@ -110,7 +114,7 @@ def _compute_time_complexity(self, parameters: dict):
>>> from cryptographic_estimators.MREstimator.mr_problem import MRProblem
>>> ME = Minors(MRProblem(q=16, m=15, n=15, k=78, r=6))
>>> ME.time_complexity()
143.1769522683363
144.72067178682556
"""
a = parameters[MR_NUMBER_OF_KERNEL_VECTORS_TO_GUESS]
lv = parameters[MR_NUMBER_OF_COEFFICIENTS_TO_GUESS]
Expand Down
10 changes: 5 additions & 5 deletions cryptographic_estimators/MREstimator/mr_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def table(self, show_quantum_complexity=0, show_tilde_o_time=0,
| SupportMinors | 144.0 | 16.1 | {'a': 5, 'lv': 0, 'b': 1, 'nprime': 8, 'variant': 'block_wiedemann'} |
| KernelSearch | 147.7 | 16.1 | {'a': 4, 'lv': 3} |
| BigK | 154.7 | 16.1 | {'a': 5, 'lv': 3} |
| Minors | 143.2 | 16.1 | {'a': 5, 'lv': 0} |
| Minors | 144.7 | 16.1 | {'a': 5, 'lv': 0} |
| BruteForce | 143.8 | 16.1 | {'a': 5, 'lv': 0} |
+---------------+-------+--------+----------------------------------------------------------------------+

Expand All @@ -115,7 +115,7 @@ def table(self, show_quantum_complexity=0, show_tilde_o_time=0,
| SupportMinors | 165.9 | 17.2 | {'a': 8, 'lv': 0, 'b': 2, 'nprime': 8, 'variant': 'block_wiedemann'} |
| KernelSearch | 159.4 | 17.2 | {'a': 8, 'lv': 0} |
| BigK | 230.8 | 17.2 | {'a': 0, 'lv': 0} |
| Minors | 162.5 | 33.0 | {'a': 7, 'lv': 0} |
| Minors | 169.4 | 17.2 | {'a': 9, 'lv': 0} |
| BruteForce | 169.4 | 17.2 | {'a': 9, 'lv': 0} |
+---------------+-------+--------+----------------------------------------------------------------------+

Expand All @@ -131,7 +131,7 @@ def table(self, show_quantum_complexity=0, show_tilde_o_time=0,
| SupportMinors | 209.6 | 21.5 | {'a': 5, 'lv': 0, 'b': 2, 'nprime': 14, 'variant': 'block_wiedemann'} |
| KernelSearch | 207.4 | 17.3 | {'a': 5, 'lv': 0} |
| BigK | 431.1 | 17.3 | {'a': 0, 'lv': 0} |
| Minors | 211.5 | 55.0 | {'a': 4, 'lv': 0} |
| Minors | 216.3 | 17.3 | {'a': 6, 'lv': 0} |
| BruteForce | 216.3 | 17.3 | {'a': 6, 'lv': 0} |
+---------------+-------+--------+-----------------------------------------------------------------------+

Expand All @@ -145,7 +145,7 @@ def table(self, show_quantum_complexity=0, show_tilde_o_time=0,
| SupportMinors | 236.3 | 18.9 | {'a': 8, 'lv': 0, 'b': 2, 'nprime': 11, 'variant': 'block_wiedemann'} |
| KernelSearch | 231.7 | 17.9 | {'a': 8, 'lv': 0} |
| BigK | 351.8 | 17.9 | {'a': 0, 'lv': 0} |
| Minors | 237.6 | 45.7 | {'a': 7, 'lv': 0} |
| Minors | 242.2 | 17.9 | {'a': 9, 'lv': 0} |
| BruteForce | 242.2 | 17.9 | {'a': 9, 'lv': 0} |
+---------------+-------+--------+-----------------------------------------------------------------------+

Expand Down Expand Up @@ -173,7 +173,7 @@ def table(self, show_quantum_complexity=0, show_tilde_o_time=0,
| SupportMinors | 301.2 | 18.9 | {'a': 11, 'lv': 0, 'b': 1, 'nprime': 11, 'variant': 'block_wiedemann'} |
| KernelSearch | 302.8 | 18.9 | {'a': 11, 'lv': 0} |
| BigK | 425.4 | 18.9 | {'a': 0, 'lv': 0} |
| Minors | 307.1 | 60.1 | {'a': 9, 'lv': 0} |
| Minors | 314.9 | 33.2 | {'a': 11, 'lv': 0} |
| BruteForce | 316.0 | 18.9 | {'a': 12, 'lv': 0} |
+---------------+-------+--------+------------------------------------------------------------------------+
"""
Expand Down
4 changes: 3 additions & 1 deletion cryptographic_estimators/MREstimator/mr_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from enum import Enum
from itertools import product
from math import comb as binomial
from math import inf
from sympy import Poly, QQ
from sympy.abc import t
from sympy.polys.matrices import DomainMatrix
Expand Down Expand Up @@ -80,9 +81,10 @@ def minors_series(m, n, k, r):
series = num/den
return series


def minors_polynomial_degree(m, n_reduced, k_reduced, r):
poly = 0
if k_reduced >= (m - r) * (n_reduced - r):
return inf
series = minors_series(m, n_reduced, k_reduced, r)
series_coeffs = list(reversed(Poly(QQ[t].to_sympy(series)).all_coeffs())) # cast from PolyElement to Poly
for D in range(series.degree()):
Expand Down
Loading