pqlattice 0.1.2__py3-none-any.whl
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.
- pqlattice/__init__.py +6 -0
- pqlattice/_backends/__init__.py +0 -0
- pqlattice/_backends/_fast.py +75 -0
- pqlattice/_backends/_native.py +33 -0
- pqlattice/_backends/_protocol.py +15 -0
- pqlattice/_utils.py +201 -0
- pqlattice/integer/__init__.py +8 -0
- pqlattice/integer/_integer.py +55 -0
- pqlattice/integer/_modintring.py +246 -0
- pqlattice/integer/_modring.py +165 -0
- pqlattice/integer/_primality.py +78 -0
- pqlattice/integer/_primes.py +57 -0
- pqlattice/lattice/__init__.py +44 -0
- pqlattice/lattice/_bkz.py +87 -0
- pqlattice/lattice/_cvp.py +62 -0
- pqlattice/lattice/_embeddings.py +149 -0
- pqlattice/lattice/_gso.py +43 -0
- pqlattice/lattice/_hkz.py +20 -0
- pqlattice/lattice/_lattice.py +137 -0
- pqlattice/lattice/_lll.py +93 -0
- pqlattice/lattice/_svp.py +89 -0
- pqlattice/lattice/embeddings.py +3 -0
- pqlattice/linalg/__init__.py +37 -0
- pqlattice/linalg/_linalg.py +306 -0
- pqlattice/linalg/_modint.py +209 -0
- pqlattice/linalg/_utils.py +167 -0
- pqlattice/polynomial/__init__.py +5 -0
- pqlattice/polynomial/_modpolyqring.py +185 -0
- pqlattice/polynomial/_modpolyring.py +267 -0
- pqlattice/polynomial/_poly.py +250 -0
- pqlattice/polynomial/poly.py +3 -0
- pqlattice/py.typed +0 -0
- pqlattice/random/__init__.py +7 -0
- pqlattice/random/_distribution.py +303 -0
- pqlattice/random/_lattice.py +53 -0
- pqlattice/random/_lwe.py +109 -0
- pqlattice/random/_lwr.py +41 -0
- pqlattice/random/_prime.py +53 -0
- pqlattice/random/distribution.py +3 -0
- pqlattice/settings.py +66 -0
- pqlattice/typing/__init__.py +4 -0
- pqlattice/typing/_types.py +18 -0
- pqlattice/typing/_types_validator.py +57 -0
- pqlattice-0.1.2.dist-info/METADATA +33 -0
- pqlattice-0.1.2.dist-info/RECORD +47 -0
- pqlattice-0.1.2.dist-info/WHEEL +4 -0
- pqlattice-0.1.2.dist-info/licenses/LICENSE +7 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from collections.abc import Callable
|
|
3
|
+
from inspect import signature
|
|
4
|
+
from typing import Any, TypeAliasType, TypeGuard
|
|
5
|
+
|
|
6
|
+
import numpy as np
|
|
7
|
+
from numpy.typing import NDArray
|
|
8
|
+
|
|
9
|
+
from ._types import Matrix, SquareMatrix, Vector
|
|
10
|
+
|
|
11
|
+
logger = logging.getLogger(__name__)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _is_nparray(obj: Any) -> TypeGuard[NDArray[Any]]:
|
|
15
|
+
return isinstance(obj, np.ndarray)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def is_Vector(obj: Any) -> TypeGuard[Vector]:
|
|
19
|
+
return _is_nparray(obj) and len(obj.shape) == 1
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def is_Matrix(obj: Any) -> TypeGuard[Matrix]:
|
|
23
|
+
return _is_nparray(obj) and len(obj.shape) == 2
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def is_SquareMatrix(obj: Any) -> TypeGuard[SquareMatrix]:
|
|
27
|
+
return is_Matrix(obj) and obj.shape[0] == obj.shape[1]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _get_predicate_for_alias[T: TypeAliasType](type_name: T) -> Callable[[T], bool] | None:
|
|
31
|
+
# Bare
|
|
32
|
+
if type_name == Vector:
|
|
33
|
+
return is_Vector
|
|
34
|
+
|
|
35
|
+
if type_name == Matrix:
|
|
36
|
+
return is_Matrix
|
|
37
|
+
|
|
38
|
+
if type_name == SquareMatrix:
|
|
39
|
+
return is_SquareMatrix
|
|
40
|
+
|
|
41
|
+
return None
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def validate_aliases[**P, T](func: Callable[P, T]) -> Callable[P, T]:
|
|
45
|
+
def wrapper(*args: P.args, **kwds: P.kwargs) -> T:
|
|
46
|
+
sig = signature(func)
|
|
47
|
+
bounded_args = sig.bind(*args, **kwds)
|
|
48
|
+
bounded_args.apply_defaults()
|
|
49
|
+
for arg_name, arg_value in bounded_args.arguments.items():
|
|
50
|
+
if expected_type := func.__annotations__.get(arg_name): # There is a type annotation for the argument
|
|
51
|
+
pred = _get_predicate_for_alias(expected_type)
|
|
52
|
+
if pred is not None and not pred(arg_value): # type annotations has a predicate to be checked and predicate is not fullfilled
|
|
53
|
+
raise TypeError(f"func <{func.__name__}>, arg <{arg_name}> val <{arg_value}> arg's type <{type(arg_value)}> predicate for <{expected_type}> failed")
|
|
54
|
+
|
|
55
|
+
return func(*args, **kwds)
|
|
56
|
+
|
|
57
|
+
return wrapper
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pqlattice
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: Add your description here
|
|
5
|
+
Project-URL: Repository, https://github.com/MikolajLH/pqlattice.git
|
|
6
|
+
Project-URL: Documentation, https://mikolajlh.github.io/pqlattice/
|
|
7
|
+
Author-email: Mikołaj Leonhardt <mikolaj.leonhardt@gmail.com>
|
|
8
|
+
License: Copyright (c) 2026, Mikołaj Leonhardt
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Keywords: cryptography,lattice
|
|
17
|
+
Classifier: Intended Audience :: Education
|
|
18
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Classifier: Programming Language :: Python :: 3
|
|
21
|
+
Classifier: Topic :: Security :: Cryptography
|
|
22
|
+
Requires-Python: >=3.12
|
|
23
|
+
Requires-Dist: numpy>=1.26
|
|
24
|
+
Provides-Extra: fast
|
|
25
|
+
Requires-Dist: cysignals>=1.12.6; extra == 'fast'
|
|
26
|
+
Requires-Dist: fpylll>=0.6.4; extra == 'fast'
|
|
27
|
+
Requires-Dist: python-flint>=0.8.0; extra == 'fast'
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# PQLATTICE - Python library for lattice based cryptography and cryptoanalysis
|
|
31
|
+
|
|
32
|
+
[docs](https://mikolajlh.github.io/pqlattice/)
|
|
33
|
+
[pypi](https://pypi.org/project/pqlattice/)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
pqlattice/__init__.py,sha256=1qmfhoERcDVFAnEqxAnYYMoXAdmA_rdc77PiYxEcWSw,298
|
|
2
|
+
pqlattice/_utils.py,sha256=loGsCvkIm9BD5KPjQ0jP4XNtE7SAdJO6ofcYwzsfPfM,6747
|
|
3
|
+
pqlattice/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
pqlattice/settings.py,sha256=wR1KkAJw11_zL99UbJ2aeB49tBDkeFfpsqgfyrzR4KQ,1661
|
|
5
|
+
pqlattice/_backends/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
pqlattice/_backends/_fast.py,sha256=-P49jpEoooTegYl8xJ50zBdkbLAb9WcO9WMM3oYuzN4,2396
|
|
7
|
+
pqlattice/_backends/_native.py,sha256=ELsfemKQBNDIJdzrs0UckG8f8AUlDUeyPNY9bjXOOKs,1020
|
|
8
|
+
pqlattice/_backends/_protocol.py,sha256=vQ0NcG1LS1jv01FnPZuJ95oDmwxRpiZ4RPeANeV9nrQ,526
|
|
9
|
+
pqlattice/integer/__init__.py,sha256=jVeyMM3oMhyOl3jnAZh7scrdp7dAuo71HNUZwA8zHdY,270
|
|
10
|
+
pqlattice/integer/_integer.py,sha256=ewY_Mha1lowj_TigdaK-lwQGfHLh6vPtvkYfpn_6_5A,1144
|
|
11
|
+
pqlattice/integer/_modintring.py,sha256=nkuS3nneh4AvfzWHjVIxJEHhIs1tKSf_uei4wHflnYw,4649
|
|
12
|
+
pqlattice/integer/_modring.py,sha256=MOw-aYeJGcqUszo8akvsLZp8GNEuMoqeqemsxlClexw,3129
|
|
13
|
+
pqlattice/integer/_primality.py,sha256=jvbIWs3cIiQUwCC6xCDoTzIIJK-zX2pKnJbsfHi85Nk,1681
|
|
14
|
+
pqlattice/integer/_primes.py,sha256=SvQoaL4d_K2IWSZziNcCceN7SZc8oVJAjKgscBes6NU,503
|
|
15
|
+
pqlattice/lattice/__init__.py,sha256=FJg16qywUocUvjRwOLvfTVqX3boD6xmOB0zWfaXCSpI,1239
|
|
16
|
+
pqlattice/lattice/_bkz.py,sha256=UtAjXEgIW0phmV6ccPCtyLb-cEI4H41hajQnRLTLH8s,2508
|
|
17
|
+
pqlattice/lattice/_cvp.py,sha256=GpXutUIZJ9X5gNJCjfZP28fu5cxKwOKmFECQGDYvSXw,1558
|
|
18
|
+
pqlattice/lattice/_embeddings.py,sha256=Knw-1zGjcQuKTia44ZaxCp2FVpk1QD_0FcWxkBbIUwc,2601
|
|
19
|
+
pqlattice/lattice/_gso.py,sha256=XjqwoPc7Bzi4fmvykPggssvnb4K9dvnOVFEOZKAl3ek,913
|
|
20
|
+
pqlattice/lattice/_hkz.py,sha256=rEovFP51YBe1krOTzjB_9v_7HbkvC0C4FJ7LiGTqgQQ,401
|
|
21
|
+
pqlattice/lattice/_lattice.py,sha256=areefaC__H1kzDtHr4ruEScnCmeAk8NV_bJXbYVlIyI,2659
|
|
22
|
+
pqlattice/lattice/_lll.py,sha256=LQaVevmYKwjR_qNBoxna4Fbc7R6ThKeKknLt8KlcPek,2322
|
|
23
|
+
pqlattice/lattice/_svp.py,sha256=p36JB2StYy_eSCk97Qd4uHyk8koV0bowlSDol7FMS7o,2342
|
|
24
|
+
pqlattice/lattice/embeddings.py,sha256=csWVyskAx9uJIH1vXnuIl1P97Kb4B49s2wkaG-4VoPU,174
|
|
25
|
+
pqlattice/linalg/__init__.py,sha256=0cU2ln5V7vWNB1mOyOeZ3aBHVW9mH95IZuFRDB-XVG4,952
|
|
26
|
+
pqlattice/linalg/_linalg.py,sha256=-cz-Yfr6WBR3n3u4H1ehkPJ-nl0Ax4s6qGq5h0gFtCE,5511
|
|
27
|
+
pqlattice/linalg/_modint.py,sha256=GZL8HyIfMXT5u2PVXB0-i52cV_VGxKE7M6f1LdDSqbY,4078
|
|
28
|
+
pqlattice/linalg/_utils.py,sha256=gHh8qyT1eqQiG85n8_2geau-DlR4YbKogRBBMGccdA0,2640
|
|
29
|
+
pqlattice/polynomial/__init__.py,sha256=Di_p5MzrNZ0fXLflW20jAkoLhq6aZVQVMQqxGW232QQ,208
|
|
30
|
+
pqlattice/polynomial/_modpolyqring.py,sha256=8T-ve7W5tIbGaVI8VDU4zB3glF01tBsyNkdl903lEEw,4126
|
|
31
|
+
pqlattice/polynomial/_modpolyring.py,sha256=8XfQchTj5wFMW6cFcKiW21QeabcNTsdFltozgwqdVIY,6253
|
|
32
|
+
pqlattice/polynomial/_poly.py,sha256=MJKUO3dJU04PGeM9wNYjCp8olWVIqQmgRaAWHTmCDb8,4229
|
|
33
|
+
pqlattice/polynomial/poly.py,sha256=R8apV6rxcq76s-ISddHde0Nhds3zo11jtNikRLmBKmY,204
|
|
34
|
+
pqlattice/random/__init__.py,sha256=1d81_cGXLmc3qiznD5o2nyLKxml5T49fRHClhsdL0nc,205
|
|
35
|
+
pqlattice/random/_distribution.py,sha256=79Wn8HG2wNWGPOZRlxaUnjQc3yasI4hLUpuwpM2CC5g,8312
|
|
36
|
+
pqlattice/random/_lattice.py,sha256=sNs-wHy53Q5ZUgW6fBgGYPaKFKg17nTWKdNm8KZO2cU,1397
|
|
37
|
+
pqlattice/random/_lwe.py,sha256=-15qN_gCOjE8WmWkrBLFXklV4O-UTE9b_q9Tl1pNaL0,2940
|
|
38
|
+
pqlattice/random/_lwr.py,sha256=Wst5yTuOAipge69p7AyeiKAgeVa4rmmNiEfQQQpRtuk,797
|
|
39
|
+
pqlattice/random/_prime.py,sha256=Hh9MugV3UQ_xcBJXwlQl_wcgElHMLyJuPnxUtyiCGnM,1575
|
|
40
|
+
pqlattice/random/distribution.py,sha256=9M4t9ChWuZ8F59H8_PJNYOXJ9JjH8PPUtOo2nt6r24o,96
|
|
41
|
+
pqlattice/typing/__init__.py,sha256=_ZO3gIm9jwa3A2oYk0HUVEXeHKLDzCtOwdsWMl5Gg0k,318
|
|
42
|
+
pqlattice/typing/_types.py,sha256=-21ep4w1Bd0ucBkMi3434oXpd2IZhPfH0gqukZvXPdQ,357
|
|
43
|
+
pqlattice/typing/_types_validator.py,sha256=2h75iPxLClQbx-msVl02BlqR1FJaGPnLI3v3YIVSjQY,1836
|
|
44
|
+
pqlattice-0.1.2.dist-info/METADATA,sha256=McHlviGDXjHhh5jnmcfAB_cT1k744KyoiIxkMqS-S9o,2126
|
|
45
|
+
pqlattice-0.1.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
46
|
+
pqlattice-0.1.2.dist-info/licenses/LICENSE,sha256=w623ZQyHgeuIEQnEGaQK3PLf1O70nLcD_wjWwd6ltEw,1069
|
|
47
|
+
pqlattice-0.1.2.dist-info/RECORD,,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright (c) 2026, Mikołaj Leonhardt
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|