kryptools 0.6__tar.gz → 0.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {kryptools-0.6 → kryptools-0.7}/PKG-INFO +1 -1
- {kryptools-0.6 → kryptools-0.7}/kryptools/Zmod.py +6 -0
- {kryptools-0.6 → kryptools-0.7}/kryptools/la.py +2 -2
- {kryptools-0.6 → kryptools-0.7}/kryptools/poly.py +21 -6
- {kryptools-0.6 → kryptools-0.7}/kryptools.egg-info/PKG-INFO +1 -1
- {kryptools-0.6 → kryptools-0.7}/pyproject.toml +1 -1
- {kryptools-0.6 → kryptools-0.7}/LICENSE +0 -0
- {kryptools-0.6 → kryptools-0.7}/README.md +0 -0
- {kryptools-0.6 → kryptools-0.7}/kryptools/__init__.py +0 -0
- {kryptools-0.6 → kryptools-0.7}/kryptools/dlp.py +0 -0
- {kryptools-0.6 → kryptools-0.7}/kryptools/dlp_bsgs.py +0 -0
- {kryptools-0.6 → kryptools-0.7}/kryptools/dlp_ic.py +0 -0
- {kryptools-0.6 → kryptools-0.7}/kryptools/dlp_qs.py +0 -0
- {kryptools-0.6 → kryptools-0.7}/kryptools/dlp_rho.py +0 -0
- {kryptools-0.6 → kryptools-0.7}/kryptools/ec.py +0 -0
- {kryptools-0.6 → kryptools-0.7}/kryptools/factor.py +0 -0
- {kryptools-0.6 → kryptools-0.7}/kryptools/factor_dix.py +0 -0
- {kryptools-0.6 → kryptools-0.7}/kryptools/factor_ecm.py +0 -0
- {kryptools-0.6 → kryptools-0.7}/kryptools/factor_fmt.py +0 -0
- {kryptools-0.6 → kryptools-0.7}/kryptools/factor_pm1.py +0 -0
- {kryptools-0.6 → kryptools-0.7}/kryptools/factor_qs.py +0 -0
- {kryptools-0.6 → kryptools-0.7}/kryptools/lat.py +0 -0
- {kryptools-0.6 → kryptools-0.7}/kryptools/nt.py +0 -0
- {kryptools-0.6 → kryptools-0.7}/kryptools/primes.py +0 -0
- {kryptools-0.6 → kryptools-0.7}/kryptools.egg-info/SOURCES.txt +0 -0
- {kryptools-0.6 → kryptools-0.7}/kryptools.egg-info/dependency_links.txt +0 -0
- {kryptools-0.6 → kryptools-0.7}/kryptools.egg-info/top_level.txt +0 -0
- {kryptools-0.6 → kryptools-0.7}/setup.cfg +0 -0
|
@@ -106,6 +106,9 @@ class ZmodPoint:
|
|
|
106
106
|
def __neg__(self) -> "ZmodPoint":
|
|
107
107
|
return self.__class__(-self.x, self.ring)
|
|
108
108
|
|
|
109
|
+
def __pos__(self) -> "ZmodPoint":
|
|
110
|
+
return self
|
|
111
|
+
|
|
109
112
|
def __sub__(self, other: "ZmodPoint") -> "ZmodPoint":
|
|
110
113
|
if isinstance(other, self.__class__):
|
|
111
114
|
if self.ring != other.ring:
|
|
@@ -151,6 +154,9 @@ class ZmodPoint:
|
|
|
151
154
|
return self.__class__(pow(self.x, scalar, self.ring.n), self.ring)
|
|
152
155
|
return NotImplemented
|
|
153
156
|
|
|
157
|
+
def __abs__(self) -> int:
|
|
158
|
+
return abs(self.sharp())
|
|
159
|
+
|
|
154
160
|
def sharp(self):
|
|
155
161
|
"Returns a symmetric (w.r.t. 0) representative."
|
|
156
162
|
tmp = (self.ring.n - 1) // 2
|
|
@@ -99,12 +99,12 @@ class Matrix:
|
|
|
99
99
|
return self.matrix == other.matrix
|
|
100
100
|
|
|
101
101
|
def map(self, func):
|
|
102
|
-
"Apply a function to all elements in place"
|
|
102
|
+
"Apply a function to all elements in place."
|
|
103
103
|
for row in self.matrix:
|
|
104
104
|
row[:] = map(func, row)
|
|
105
105
|
|
|
106
106
|
def applyfunc(self, func):
|
|
107
|
-
"Apply a function to all elements"
|
|
107
|
+
"Apply a function to all elements."
|
|
108
108
|
tmp = self[:,:]
|
|
109
109
|
tmp.map(func)
|
|
110
110
|
return tmp
|
|
@@ -16,11 +16,11 @@ class Poly:
|
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
18
|
def __init__(self, coeff: list, ring = None, modulus: list = None):
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
self.coeff = list(coeff)
|
|
20
|
+
for i in range(len(self.coeff) - 1, 0, -1):
|
|
21
|
+
if self.coeff[i]:
|
|
21
22
|
break
|
|
22
|
-
coeff.pop(i)
|
|
23
|
-
self.coeff = coeff
|
|
23
|
+
self.coeff.pop(i)
|
|
24
24
|
self.modulus = modulus
|
|
25
25
|
if ring:
|
|
26
26
|
self.map(ring)
|
|
@@ -86,14 +86,18 @@ class Poly:
|
|
|
86
86
|
def __bool__(self):
|
|
87
87
|
return bool(self.degree()) or bool(self.coeff[0])
|
|
88
88
|
|
|
89
|
-
def degree(self):
|
|
89
|
+
def degree(self) -> int:
|
|
90
90
|
"Return the degree."
|
|
91
91
|
return len(self.coeff) - 1
|
|
92
92
|
|
|
93
93
|
def map(self, func):
|
|
94
|
-
"Apply a given function to all coefficients."
|
|
94
|
+
"Apply a given function to all coefficients in place."
|
|
95
95
|
self.coeff = list(map(func, self.coeff))
|
|
96
96
|
|
|
97
|
+
def applyfunc(self, func) -> "Poly":
|
|
98
|
+
"Apply a function to all coefficients."
|
|
99
|
+
return self.__class__(list(map(func, self.coeff)), modulus=self.modulus)
|
|
100
|
+
|
|
97
101
|
def _check_type(self, other):
|
|
98
102
|
return isinstance(other, int) or (isinstance(other, Number) and isinstance(self.coeff[0], Number)) or type(other) == type(self.coeff[0])
|
|
99
103
|
|
|
@@ -129,6 +133,9 @@ class Poly:
|
|
|
129
133
|
def __neg__(self) -> "Poly":
|
|
130
134
|
return Poly([-s for s in self.coeff], modulus=self.modulus)
|
|
131
135
|
|
|
136
|
+
def __pos__(self) -> "Poly":
|
|
137
|
+
return self
|
|
138
|
+
|
|
132
139
|
def __sub__(self, other: "Poly") -> "Poly":
|
|
133
140
|
if not isinstance(other, self.__class__):
|
|
134
141
|
if self._check_type(other):
|
|
@@ -213,6 +220,14 @@ class Poly:
|
|
|
213
220
|
res *= tmp
|
|
214
221
|
return res
|
|
215
222
|
|
|
223
|
+
def max(self) -> int:
|
|
224
|
+
"Maximum of the absolute value of all coefficients."
|
|
225
|
+
return max([abs(c) for c in self.coeff])
|
|
226
|
+
|
|
227
|
+
def sum(self) -> int:
|
|
228
|
+
"Sum of the absolute value of all coefficients."
|
|
229
|
+
return sum([abs(c) for c in self.coeff])
|
|
230
|
+
|
|
216
231
|
def __floordiv__(self, other: "Poly") -> "Poly":
|
|
217
232
|
return self.divmod(other)[0]
|
|
218
233
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|