kryptools 1.3.1__tar.gz → 1.3.2__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 (57) hide show
  1. {kryptools-1.3.1 → kryptools-1.3.2}/PKG-INFO +1 -1
  2. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools/Zmod.py +13 -5
  3. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools/__init__.py +1 -1
  4. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools.egg-info/PKG-INFO +1 -1
  5. {kryptools-1.3.1 → kryptools-1.3.2}/pyproject.toml +1 -1
  6. {kryptools-1.3.1 → kryptools-1.3.2}/tests/test_Zmod.py +27 -5
  7. {kryptools-1.3.1 → kryptools-1.3.2}/LICENSE +0 -0
  8. {kryptools-1.3.1 → kryptools-1.3.2}/README.md +0 -0
  9. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools/GF2.py +0 -0
  10. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools/aes.py +0 -0
  11. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools/blockcipher.py +0 -0
  12. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools/code.py +0 -0
  13. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools/conway_polynomials.py +0 -0
  14. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools/des.py +0 -0
  15. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools/dlp.py +0 -0
  16. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools/dlp_bsgs.py +0 -0
  17. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools/dlp_ic.py +0 -0
  18. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools/dlp_qs.py +0 -0
  19. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools/dlp_rho.py +0 -0
  20. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools/ec.py +0 -0
  21. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools/factor.py +0 -0
  22. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools/factor_dix.py +0 -0
  23. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools/factor_ecm.py +0 -0
  24. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools/factor_fmt.py +0 -0
  25. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools/factor_pm1.py +0 -0
  26. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools/factor_qs.py +0 -0
  27. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools/factor_rho.py +0 -0
  28. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools/intfuncs.py +0 -0
  29. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools/keccak.py +0 -0
  30. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools/la.py +0 -0
  31. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools/lat.py +0 -0
  32. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools/nt.py +0 -0
  33. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools/poly.py +0 -0
  34. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools/primes.py +0 -0
  35. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools/sha1.py +0 -0
  36. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools.egg-info/SOURCES.txt +0 -0
  37. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools.egg-info/dependency_links.txt +0 -0
  38. {kryptools-1.3.1 → kryptools-1.3.2}/kryptools.egg-info/top_level.txt +0 -0
  39. {kryptools-1.3.1 → kryptools-1.3.2}/setup.cfg +0 -0
  40. {kryptools-1.3.1 → kryptools-1.3.2}/tests/test_GF2.py +0 -0
  41. {kryptools-1.3.1 → kryptools-1.3.2}/tests/test_aes.py +0 -0
  42. {kryptools-1.3.1 → kryptools-1.3.2}/tests/test_code.py +0 -0
  43. {kryptools-1.3.1 → kryptools-1.3.2}/tests/test_des.py +0 -0
  44. {kryptools-1.3.1 → kryptools-1.3.2}/tests/test_dlog.py +0 -0
  45. {kryptools-1.3.1 → kryptools-1.3.2}/tests/test_ec.py +0 -0
  46. {kryptools-1.3.1 → kryptools-1.3.2}/tests/test_factor.py +0 -0
  47. {kryptools-1.3.1 → kryptools-1.3.2}/tests/test_factor_fmt.py +0 -0
  48. {kryptools-1.3.1 → kryptools-1.3.2}/tests/test_factor_pm1.py +0 -0
  49. {kryptools-1.3.1 → kryptools-1.3.2}/tests/test_factor_qs.py +0 -0
  50. {kryptools-1.3.1 → kryptools-1.3.2}/tests/test_intfuncs.py +0 -0
  51. {kryptools-1.3.1 → kryptools-1.3.2}/tests/test_keccak.py +0 -0
  52. {kryptools-1.3.1 → kryptools-1.3.2}/tests/test_la.py +0 -0
  53. {kryptools-1.3.1 → kryptools-1.3.2}/tests/test_lat.py +0 -0
  54. {kryptools-1.3.1 → kryptools-1.3.2}/tests/test_nt.py +0 -0
  55. {kryptools-1.3.1 → kryptools-1.3.2}/tests/test_poly.py +0 -0
  56. {kryptools-1.3.1 → kryptools-1.3.2}/tests/test_primes.py +0 -0
  57. {kryptools-1.3.1 → kryptools-1.3.2}/tests/test_sha1.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kryptools
3
- Version: 1.3.1
3
+ Version: 1.3.2
4
4
  Summary: Implemenation of same basic algorithms used in cryptography.
5
5
  Author-email: Gerald Teschl <gerald.teschl@univie.ac.at>
6
6
  License: MIT
@@ -98,6 +98,10 @@ class Zmod:
98
98
  "Return a generator of the group Z_n^*."
99
99
  if not self.is_cyclic():
100
100
  return None
101
+ if self.n == 1:
102
+ return self(0)
103
+ if self.n == 2:
104
+ return self(1)
101
105
  for a in range(2, self.n):
102
106
  if gcd(a, self.n) > 1:
103
107
  continue
@@ -109,17 +113,21 @@ class Zmod:
109
113
  "Return a generator for all generators of the group Z_n^*."
110
114
  a = self.generator()
111
115
  if a is not None:
116
+ yield a
112
117
  self.order()
113
- for j in range(1, self.group_order):
118
+ for j in range(2, self.group_order):
114
119
  if gcd(j, self.group_order) == 1:
115
120
  yield a**j
116
121
 
117
122
  def star(self) -> list:
118
123
  "Return a generator for all elements of the group Z_n^*."
119
- yield self(1)
120
- for a in range(2, self.n):
121
- if gcd(a, self.n) == 1:
122
- yield self(a)
124
+ if self.n == 1:
125
+ yield self(0)
126
+ else:
127
+ yield self(1)
128
+ for a in range(2, self.n):
129
+ if gcd(a, self.n) == 1:
130
+ yield self(a)
123
131
 
124
132
 
125
133
  class ZmodPoint:
@@ -5,7 +5,7 @@ Implemenation of same basic algorithms used in cryptography.
5
5
  __author__ = "Gerald Teschl"
6
6
  __copyright__ = "Copyright 2024-2025, Gerald Teschl"
7
7
  __license__ = "MIT License"
8
- __version__ = "1.3.1"
8
+ __version__ = "1.3.2"
9
9
  __email__ = "Gerald.Teschl@univie.ac.at"
10
10
 
11
11
  from .nt import egcd, cf, convergents, legendre_symbol, jacobi_symbol, sqrt_mod, euler_phi, carmichael_lambda, moebius_mu, is_carmichael_number, order, crt
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kryptools
3
- Version: 1.3.1
3
+ Version: 1.3.2
4
4
  Summary: Implemenation of same basic algorithms used in cryptography.
5
5
  Author-email: Gerald Teschl <gerald.teschl@univie.ac.at>
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "kryptools"
3
- version = "1.3.1"
3
+ version = "1.3.2"
4
4
  authors = [
5
5
  { name="Gerald Teschl", email="gerald.teschl@univie.ac.at" },
6
6
  ]
@@ -1,6 +1,6 @@
1
1
  import pytest
2
2
  from math import gcd
3
- from kryptools import Zmod, euler_phi
3
+ from kryptools import Zmod, euler_phi, is_prime
4
4
 
5
5
 
6
6
  def test_Zmod_ops():
@@ -70,9 +70,14 @@ def test_Zmod_methods():
70
70
 
71
71
 
72
72
  def test_Zmod_order():
73
- for n in range(2, 10):
74
- Z_n = Zmod(n)
75
- assert Z_n.order() == euler_phi(n)
73
+ for n in range(1, 100):
74
+ o = euler_phi(n)
75
+ assert Zmod(n).order() == o
76
+ assert len(list(Zmod(n).star())) == o
77
+
78
+ def test_Zmod_field():
79
+ for n in range(1, 100):
80
+ assert Zmod(n).is_field() == is_prime(n)
76
81
 
77
82
 
78
83
  OEIS_A033948 = [1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 13, 14, 17, 18, 19, 22, 23, 25, 26, 27,
@@ -80,7 +85,24 @@ OEIS_A033948 = [1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 13, 14, 17, 18, 19, 22, 23, 25,
80
85
  79, 81, 82, 83, 86, 89, 94, 97, 98, 101, 103, 106, 107, 109, 113, 118, 121, 122, 125,
81
86
  127, 131, 134, 137, 139]
82
87
 
83
-
84
88
  def test_Zmod_cyclic():
85
89
  for n in range(2, OEIS_A033948[-1]+1):
86
90
  assert Zmod(n).is_cyclic() == (n in OEIS_A033948)
91
+
92
+ OEIS_A046145 = [0, 1, 2, 3, 2, 5, 3, 0, 2, 3, 2, 0, 2, 3, 0, 0, 3, 5, 2, 0, 0, 7, 5, 0, 2, 7, 2, 0, 2, 0, 3, 0, 0, 3, 0,
93
+ 0, 2, 3, 0, 0, 6, 0, 3, 0, 0, 5, 5, 0, 3, 3, 0, 0, 2, 5, 0, 0, 0, 3, 2, 0, 2, 3, 0, 0, 0, 0, 2, 0, 0, 0,
94
+ 7, 0, 5, 5, 0, 0, 0, 0, 3, 0, 2, 7, 2, 0, 0, 3, 0, 0, 3, 0]
95
+
96
+ def test_Zmod_generator():
97
+ for j, a in enumerate(OEIS_A046145):
98
+ aa = Zmod(j+1).generator()
99
+ if aa is None:
100
+ aa = 0
101
+ assert a == int(aa)
102
+
103
+ def test_Zmod_generators():
104
+ for n in range(1, 100):
105
+ if Zmod(n).is_cyclic():
106
+ assert len(list(Zmod(n).generators())) == euler_phi(euler_phi(n))
107
+ else:
108
+ assert list(Zmod(n).generators()) == []
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
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes