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.
Files changed (28) hide show
  1. {kryptools-0.6 → kryptools-0.7}/PKG-INFO +1 -1
  2. {kryptools-0.6 → kryptools-0.7}/kryptools/Zmod.py +6 -0
  3. {kryptools-0.6 → kryptools-0.7}/kryptools/la.py +2 -2
  4. {kryptools-0.6 → kryptools-0.7}/kryptools/poly.py +21 -6
  5. {kryptools-0.6 → kryptools-0.7}/kryptools.egg-info/PKG-INFO +1 -1
  6. {kryptools-0.6 → kryptools-0.7}/pyproject.toml +1 -1
  7. {kryptools-0.6 → kryptools-0.7}/LICENSE +0 -0
  8. {kryptools-0.6 → kryptools-0.7}/README.md +0 -0
  9. {kryptools-0.6 → kryptools-0.7}/kryptools/__init__.py +0 -0
  10. {kryptools-0.6 → kryptools-0.7}/kryptools/dlp.py +0 -0
  11. {kryptools-0.6 → kryptools-0.7}/kryptools/dlp_bsgs.py +0 -0
  12. {kryptools-0.6 → kryptools-0.7}/kryptools/dlp_ic.py +0 -0
  13. {kryptools-0.6 → kryptools-0.7}/kryptools/dlp_qs.py +0 -0
  14. {kryptools-0.6 → kryptools-0.7}/kryptools/dlp_rho.py +0 -0
  15. {kryptools-0.6 → kryptools-0.7}/kryptools/ec.py +0 -0
  16. {kryptools-0.6 → kryptools-0.7}/kryptools/factor.py +0 -0
  17. {kryptools-0.6 → kryptools-0.7}/kryptools/factor_dix.py +0 -0
  18. {kryptools-0.6 → kryptools-0.7}/kryptools/factor_ecm.py +0 -0
  19. {kryptools-0.6 → kryptools-0.7}/kryptools/factor_fmt.py +0 -0
  20. {kryptools-0.6 → kryptools-0.7}/kryptools/factor_pm1.py +0 -0
  21. {kryptools-0.6 → kryptools-0.7}/kryptools/factor_qs.py +0 -0
  22. {kryptools-0.6 → kryptools-0.7}/kryptools/lat.py +0 -0
  23. {kryptools-0.6 → kryptools-0.7}/kryptools/nt.py +0 -0
  24. {kryptools-0.6 → kryptools-0.7}/kryptools/primes.py +0 -0
  25. {kryptools-0.6 → kryptools-0.7}/kryptools.egg-info/SOURCES.txt +0 -0
  26. {kryptools-0.6 → kryptools-0.7}/kryptools.egg-info/dependency_links.txt +0 -0
  27. {kryptools-0.6 → kryptools-0.7}/kryptools.egg-info/top_level.txt +0 -0
  28. {kryptools-0.6 → kryptools-0.7}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kryptools
3
- Version: 0.6
3
+ Version: 0.7
4
4
  Summary: Implemenation of same basic algorithms used in cryptography.
5
5
  Author-email: Gerald Teschl <gerald.teschl@univie.ac.at>
6
6
  Project-URL: Homepage, https://github.com/teschlg/kryptools
@@ -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
- for i in range(len(coeff) - 1, 0, -1):
20
- if coeff[i]:
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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kryptools
3
- Version: 0.6
3
+ Version: 0.7
4
4
  Summary: Implemenation of same basic algorithms used in cryptography.
5
5
  Author-email: Gerald Teschl <gerald.teschl@univie.ac.at>
6
6
  Project-URL: Homepage, https://github.com/teschlg/kryptools
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "kryptools"
3
- version = "0.6"
3
+ version = "0.7"
4
4
  authors = [
5
5
  { name="Gerald Teschl", email="gerald.teschl@univie.ac.at" },
6
6
  ]
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