foxmath 0.20.1__tar.gz → 0.20.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.
- {foxmath-0.20.1/src/foxmath.egg-info → foxmath-0.20.2}/PKG-INFO +3 -2
- {foxmath-0.20.1 → foxmath-0.20.2}/README.md +2 -1
- {foxmath-0.20.1 → foxmath-0.20.2}/pyproject.toml +1 -1
- {foxmath-0.20.1 → foxmath-0.20.2}/src/foxmath/foxmath.py +5 -5
- {foxmath-0.20.1 → foxmath-0.20.2/src/foxmath.egg-info}/PKG-INFO +3 -2
- {foxmath-0.20.1 → foxmath-0.20.2}/tests/test_cryptosystems.py +6 -0
- {foxmath-0.20.1 → foxmath-0.20.2}/LICENSE +0 -0
- {foxmath-0.20.1 → foxmath-0.20.2}/setup.cfg +0 -0
- {foxmath-0.20.1 → foxmath-0.20.2}/src/foxmath/__init__.py +0 -0
- {foxmath-0.20.1 → foxmath-0.20.2}/src/foxmath.egg-info/SOURCES.txt +0 -0
- {foxmath-0.20.1 → foxmath-0.20.2}/src/foxmath.egg-info/dependency_links.txt +0 -0
- {foxmath-0.20.1 → foxmath-0.20.2}/src/foxmath.egg-info/entry_points.txt +0 -0
- {foxmath-0.20.1 → foxmath-0.20.2}/src/foxmath.egg-info/top_level.txt +0 -0
- {foxmath-0.20.1 → foxmath-0.20.2}/tests/test_cli.py +0 -0
- {foxmath-0.20.1 → foxmath-0.20.2}/tests/test_foxmath.py +0 -0
- {foxmath-0.20.1 → foxmath-0.20.2}/tests/test_mersenne.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: foxmath
|
|
3
|
-
Version: 0.20.
|
|
3
|
+
Version: 0.20.2
|
|
4
4
|
Summary: Minimalist CLI & library for number theory and cryptography: Shanks's SQUFOF, Quadratic Sieve & Dixon factoring, Lenstra ECM, Pollard p-1, Lucas-Lehmer Mersenne tests, Fermat factor, RSA & Diffie-Hellman cryptosystems, BSGS discrete log, arithmetic functions (mu, sigma, tau), Jacobi symbol, Tonelli-Shanks, elliptic curves, CRT, and continued fractions.
|
|
5
5
|
Author-email: Abhrankan Chakrabarti <abhrankan@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -42,7 +42,7 @@ Built with curiosity — for students, tinkerers, and crypto/math enthusiasts.
|
|
|
42
42
|
- Jacobi symbol (jacobi)
|
|
43
43
|
- Solovay–Strassen probabilistic primality test (solovay)
|
|
44
44
|
- Modular square root via Tonelli-Shanks (sqrtmod)
|
|
45
|
-
-
|
|
45
|
+
- Miller-Rabin primality test: deterministic for n < 3.3 × 10²⁴ via 13 bases, strong probable prime above (isprime)
|
|
46
46
|
- Prime factorization via Pollard's rho & trial division (factor)
|
|
47
47
|
- Discrete logarithm solver via Baby-step Giant-step (dlog)
|
|
48
48
|
- Euler's totient φ(n) and Carmichael λ(n) (totient)
|
|
@@ -309,6 +309,7 @@ Time: 68 µs
|
|
|
309
309
|
```
|
|
310
310
|
|
|
311
311
|
```bash
|
|
312
|
+
# Exact deterministic for n < 3.3e24; strong probable prime above
|
|
312
313
|
foxmath isprime 104729
|
|
313
314
|
```
|
|
314
315
|
```
|
|
@@ -23,7 +23,7 @@ Built with curiosity — for students, tinkerers, and crypto/math enthusiasts.
|
|
|
23
23
|
- Jacobi symbol (jacobi)
|
|
24
24
|
- Solovay–Strassen probabilistic primality test (solovay)
|
|
25
25
|
- Modular square root via Tonelli-Shanks (sqrtmod)
|
|
26
|
-
-
|
|
26
|
+
- Miller-Rabin primality test: deterministic for n < 3.3 × 10²⁴ via 13 bases, strong probable prime above (isprime)
|
|
27
27
|
- Prime factorization via Pollard's rho & trial division (factor)
|
|
28
28
|
- Discrete logarithm solver via Baby-step Giant-step (dlog)
|
|
29
29
|
- Euler's totient φ(n) and Carmichael λ(n) (totient)
|
|
@@ -290,6 +290,7 @@ Time: 68 µs
|
|
|
290
290
|
```
|
|
291
291
|
|
|
292
292
|
```bash
|
|
293
|
+
# Exact deterministic for n < 3.3e24; strong probable prime above
|
|
293
294
|
foxmath isprime 104729
|
|
294
295
|
```
|
|
295
296
|
```
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "foxmath"
|
|
7
|
-
version = "0.20.
|
|
7
|
+
version = "0.20.2"
|
|
8
8
|
description = "Minimalist CLI & library for number theory and cryptography: Shanks's SQUFOF, Quadratic Sieve & Dixon factoring, Lenstra ECM, Pollard p-1, Lucas-Lehmer Mersenne tests, Fermat factor, RSA & Diffie-Hellman cryptosystems, BSGS discrete log, arithmetic functions (mu, sigma, tau), Jacobi symbol, Tonelli-Shanks, elliptic curves, CRT, and continued fractions."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = {text = "MIT"}
|
|
@@ -2395,12 +2395,12 @@ def dh_derive(private_key: int, peer_public_key: int, p: int) -> int:
|
|
|
2395
2395
|
"""Derive Diffie-Hellman shared secret: S = peer_public_key^private_key mod p."""
|
|
2396
2396
|
if not isinstance(private_key, int) or not isinstance(peer_public_key, int) or not isinstance(p, int):
|
|
2397
2397
|
raise TypeError("private_key, peer_public_key, and p must be integers")
|
|
2398
|
-
if p <=
|
|
2399
|
-
raise ValueError("Modulus p must be greater than
|
|
2398
|
+
if p <= 3:
|
|
2399
|
+
raise ValueError("Modulus p must be greater than 3")
|
|
2400
2400
|
if private_key < 1:
|
|
2401
2401
|
raise ValueError("private_key must be >= 1")
|
|
2402
|
-
if peer_public_key
|
|
2403
|
-
raise ValueError(f"peer_public_key must satisfy
|
|
2402
|
+
if peer_public_key <= 1 or peer_public_key >= p - 1:
|
|
2403
|
+
raise ValueError(f"peer_public_key must satisfy 2 <= key <= p - 2 (got {peer_public_key})")
|
|
2404
2404
|
return pow(peer_public_key, private_key, p)
|
|
2405
2405
|
|
|
2406
2406
|
def dh_crack(g: int, public_key: int, p: int) -> int:
|
|
@@ -2847,7 +2847,7 @@ def main():
|
|
|
2847
2847
|
sqrt.add_argument("a", type=int, help="Integer a")
|
|
2848
2848
|
sqrt.add_argument("p", type=int, help="Odd prime p")
|
|
2849
2849
|
|
|
2850
|
-
prime_cmd = subparsers.add_parser("isprime", help="
|
|
2850
|
+
prime_cmd = subparsers.add_parser("isprime", help="Miller-Rabin primality test (exact for n < 3.3e24)")
|
|
2851
2851
|
prime_cmd.add_argument("n", type=int, help="Integer to test")
|
|
2852
2852
|
|
|
2853
2853
|
factor_cmd = subparsers.add_parser("factor", help="Prime factorization into prime powers")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: foxmath
|
|
3
|
-
Version: 0.20.
|
|
3
|
+
Version: 0.20.2
|
|
4
4
|
Summary: Minimalist CLI & library for number theory and cryptography: Shanks's SQUFOF, Quadratic Sieve & Dixon factoring, Lenstra ECM, Pollard p-1, Lucas-Lehmer Mersenne tests, Fermat factor, RSA & Diffie-Hellman cryptosystems, BSGS discrete log, arithmetic functions (mu, sigma, tau), Jacobi symbol, Tonelli-Shanks, elliptic curves, CRT, and continued fractions.
|
|
5
5
|
Author-email: Abhrankan Chakrabarti <abhrankan@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -42,7 +42,7 @@ Built with curiosity — for students, tinkerers, and crypto/math enthusiasts.
|
|
|
42
42
|
- Jacobi symbol (jacobi)
|
|
43
43
|
- Solovay–Strassen probabilistic primality test (solovay)
|
|
44
44
|
- Modular square root via Tonelli-Shanks (sqrtmod)
|
|
45
|
-
-
|
|
45
|
+
- Miller-Rabin primality test: deterministic for n < 3.3 × 10²⁴ via 13 bases, strong probable prime above (isprime)
|
|
46
46
|
- Prime factorization via Pollard's rho & trial division (factor)
|
|
47
47
|
- Discrete logarithm solver via Baby-step Giant-step (dlog)
|
|
48
48
|
- Euler's totient φ(n) and Carmichael λ(n) (totient)
|
|
@@ -309,6 +309,7 @@ Time: 68 µs
|
|
|
309
309
|
```
|
|
310
310
|
|
|
311
311
|
```bash
|
|
312
|
+
# Exact deterministic for n < 3.3e24; strong probable prime above
|
|
312
313
|
foxmath isprime 104729
|
|
313
314
|
```
|
|
314
315
|
```
|
|
@@ -193,10 +193,16 @@ class TestDhDerive(unittest.TestCase):
|
|
|
193
193
|
def test_invalid_parameters_raise(self):
|
|
194
194
|
with self.assertRaises(ValueError):
|
|
195
195
|
dh_derive(12, 100, 100) # peer pub >= p
|
|
196
|
+
with self.assertRaises(ValueError):
|
|
197
|
+
dh_derive(12, 99, 100) # peer pub == p - 1 (trivial secret)
|
|
198
|
+
with self.assertRaises(ValueError):
|
|
199
|
+
dh_derive(12, 1, 100) # peer pub == 1 (trivial secret)
|
|
196
200
|
with self.assertRaises(ValueError):
|
|
197
201
|
dh_derive(12, 0, 100) # peer pub < 1
|
|
198
202
|
with self.assertRaises(ValueError):
|
|
199
203
|
dh_derive(0, 50, 100) # priv < 1
|
|
204
|
+
with self.assertRaises(ValueError):
|
|
205
|
+
dh_derive(12, 50, 3) # p <= 3
|
|
200
206
|
with self.assertRaises(TypeError):
|
|
201
207
|
dh_derive("12", 50, 100)
|
|
202
208
|
|
|
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
|