noqtis 0.1.1__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.
- noqtis-0.1.1/LICENSE +71 -0
- noqtis-0.1.1/MANIFEST.in +7 -0
- noqtis-0.1.1/NOTICE +9 -0
- noqtis-0.1.1/PKG-INFO +198 -0
- noqtis-0.1.1/README.md +169 -0
- noqtis-0.1.1/noqtis/__init__.py +396 -0
- noqtis-0.1.1/noqtis/_alg.py +95 -0
- noqtis-0.1.1/noqtis/_err.py +73 -0
- noqtis-0.1.1/noqtis/_noqtis.pyi +42 -0
- noqtis-0.1.1/noqtis/dsse.py +63 -0
- noqtis-0.1.1/noqtis/kem.py +38 -0
- noqtis-0.1.1/noqtis/keyfile.py +148 -0
- noqtis-0.1.1/noqtis/py.typed +0 -0
- noqtis-0.1.1/noqtis/sign.py +73 -0
- noqtis-0.1.1/noqtis.egg-info/PKG-INFO +198 -0
- noqtis-0.1.1/noqtis.egg-info/SOURCES.txt +108 -0
- noqtis-0.1.1/noqtis.egg-info/dependency_links.txt +1 -0
- noqtis-0.1.1/noqtis.egg-info/top_level.txt +1 -0
- noqtis-0.1.1/pyproject.toml +66 -0
- noqtis-0.1.1/setup.cfg +4 -0
- noqtis-0.1.1/setup.py +103 -0
- noqtis-0.1.1/src/ext.c +774 -0
- noqtis-0.1.1/src/nq.map +6 -0
- noqtis-0.1.1/tests/conftest.py +49 -0
- noqtis-0.1.1/tests/tcap.py +141 -0
- noqtis-0.1.1/tests/tcap2.py +236 -0
- noqtis-0.1.1/tests/tcli.py +119 -0
- noqtis-0.1.1/tests/thash.py +60 -0
- noqtis-0.1.1/tests/tkem.py +65 -0
- noqtis-0.1.1/tests/tkeyfile.py +135 -0
- noqtis-0.1.1/tests/tsig.py +160 -0
- noqtis-0.1.1/vendor/include/noqtis.h +438 -0
- noqtis-0.1.1/vendor/src/aead/aead.h +95 -0
- noqtis-0.1.1/vendor/src/aead/aes.c +146 -0
- noqtis-0.1.1/vendor/src/aead/ccp.c +280 -0
- noqtis-0.1.1/vendor/src/aead/gcm.c +198 -0
- noqtis-0.1.1/vendor/src/api/kem.c +223 -0
- noqtis-0.1.1/vendor/src/api/sig.c +409 -0
- noqtis-0.1.1/vendor/src/cap/cap.h +209 -0
- noqtis-0.1.1/vendor/src/cap/chk.c +2269 -0
- noqtis-0.1.1/vendor/src/cap/dsse.c +192 -0
- noqtis-0.1.1/vendor/src/cap/jw.c +349 -0
- noqtis-0.1.1/vendor/src/cap/ks.c +173 -0
- noqtis-0.1.1/vendor/src/cap/misc.c +301 -0
- noqtis-0.1.1/vendor/src/cap/mk.c +114 -0
- noqtis-0.1.1/vendor/src/cap/seal.c +411 -0
- noqtis-0.1.1/vendor/src/cap/ts.c +331 -0
- noqtis-0.1.1/vendor/src/cap/walk.c +776 -0
- noqtis-0.1.1/vendor/src/cap/xop.c +47 -0
- noqtis-0.1.1/vendor/src/cls/bn.c +186 -0
- noqtis-0.1.1/vendor/src/cls/bn.h +56 -0
- noqtis-0.1.1/vendor/src/cls/cls.h +122 -0
- noqtis-0.1.1/vendor/src/cls/ec.c +422 -0
- noqtis-0.1.1/vendor/src/cls/key.c +283 -0
- noqtis-0.1.1/vendor/src/cls/rsa.c +164 -0
- noqtis-0.1.1/vendor/src/core/core.c +128 -0
- noqtis-0.1.1/vendor/src/core/int.h +96 -0
- noqtis-0.1.1/vendor/src/core/json.c +601 -0
- noqtis-0.1.1/vendor/src/core/json.h +61 -0
- noqtis-0.1.1/vendor/src/core/lk.h +46 -0
- noqtis-0.1.1/vendor/src/core/rand.c +71 -0
- noqtis-0.1.1/vendor/src/der/chain.c +398 -0
- noqtis-0.1.1/vendor/src/der/der.c +762 -0
- noqtis-0.1.1/vendor/src/der/der.h +169 -0
- noqtis-0.1.1/vendor/src/der/rev.c +499 -0
- noqtis-0.1.1/vendor/src/der/tsp.c +790 -0
- noqtis-0.1.1/vendor/src/der/tsp.h +120 -0
- noqtis-0.1.1/vendor/src/der/x509.c +1109 -0
- noqtis-0.1.1/vendor/src/der/x509.h +280 -0
- noqtis-0.1.1/vendor/src/drbg/drbg.c +198 -0
- noqtis-0.1.1/vendor/src/drbg/drbg.h +78 -0
- noqtis-0.1.1/vendor/src/ed/ed.c +471 -0
- noqtis-0.1.1/vendor/src/ed/ed.h +49 -0
- noqtis-0.1.1/vendor/src/hash/h.h +158 -0
- noqtis-0.1.1/vendor/src/hash/hash.c +159 -0
- noqtis-0.1.1/vendor/src/hash/hkdf.c +56 -0
- noqtis-0.1.1/vendor/src/hash/hmac.c +128 -0
- noqtis-0.1.1/vendor/src/hash/sha1.c +118 -0
- noqtis-0.1.1/vendor/src/hash/sha2.c +274 -0
- noqtis-0.1.1/vendor/src/hash/sha3.c +164 -0
- noqtis-0.1.1/vendor/src/hqc/code.c +358 -0
- noqtis-0.1.1/vendor/src/hqc/hqc.h +61 -0
- noqtis-0.1.1/vendor/src/hqc/hqci.h +63 -0
- noqtis-0.1.1/vendor/src/hqc/kem.c +460 -0
- noqtis-0.1.1/vendor/src/hqc/mul.c +120 -0
- noqtis-0.1.1/vendor/src/mldsa/md.h +147 -0
- noqtis-0.1.1/vendor/src/mldsa/mldsa.h +95 -0
- noqtis-0.1.1/vendor/src/mldsa/msk.c +801 -0
- noqtis-0.1.1/vendor/src/mldsa/poly.c +377 -0
- noqtis-0.1.1/vendor/src/mldsa/sign.c +488 -0
- noqtis-0.1.1/vendor/src/mlkem/kem.c +560 -0
- noqtis-0.1.1/vendor/src/mlkem/mdec.c +779 -0
- noqtis-0.1.1/vendor/src/mlkem/mlkem.h +81 -0
- noqtis-0.1.1/vendor/src/mlkem/ring.h +108 -0
- noqtis-0.1.1/vendor/src/noqtis.map +12 -0
- noqtis-0.1.1/vendor/src/slh/hsh.c +162 -0
- noqtis-0.1.1/vendor/src/slh/in.h +120 -0
- noqtis-0.1.1/vendor/src/slh/slh.c +321 -0
- noqtis-0.1.1/vendor/src/slh/slh.h +97 -0
- noqtis-0.1.1/vendor/src/slh/tree.c +307 -0
- noqtis-0.1.1/vendor/src/tls/api.c +194 -0
- noqtis-0.1.1/vendor/src/tls/crt.c +359 -0
- noqtis-0.1.1/vendor/src/tls/ct.c +412 -0
- noqtis-0.1.1/vendor/src/tls/hs.c +918 -0
- noqtis-0.1.1/vendor/src/tls/ks.c +90 -0
- noqtis-0.1.1/vendor/src/tls/rec.c +359 -0
- noqtis-0.1.1/vendor/src/tls/tls.h +309 -0
- noqtis-0.1.1/vendor/src/xdh/hyb.c +61 -0
- noqtis-0.1.1/vendor/src/xdh/x25519.c +222 -0
- noqtis-0.1.1/vendor/src/xdh/xdh.h +61 -0
noqtis-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/
|
|
2
|
+
|
|
3
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
4
|
+
|
|
5
|
+
1. Definitions.
|
|
6
|
+
|
|
7
|
+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
|
8
|
+
|
|
9
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
10
|
+
|
|
11
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
12
|
+
|
|
13
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
14
|
+
|
|
15
|
+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
16
|
+
|
|
17
|
+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
18
|
+
|
|
19
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
|
20
|
+
|
|
21
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
22
|
+
|
|
23
|
+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
24
|
+
|
|
25
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
26
|
+
|
|
27
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
28
|
+
|
|
29
|
+
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
30
|
+
|
|
31
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
32
|
+
|
|
33
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
34
|
+
|
|
35
|
+
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
36
|
+
|
|
37
|
+
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
38
|
+
|
|
39
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
|
40
|
+
|
|
41
|
+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
42
|
+
|
|
43
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
|
44
|
+
|
|
45
|
+
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
|
46
|
+
|
|
47
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
|
48
|
+
|
|
49
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
50
|
+
|
|
51
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
52
|
+
|
|
53
|
+
END OF TERMS AND CONDITIONS
|
|
54
|
+
|
|
55
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
56
|
+
|
|
57
|
+
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
|
|
58
|
+
|
|
59
|
+
Copyright 2026 Vansh Singh Ruhela (rootcoder007)
|
|
60
|
+
|
|
61
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
|
|
62
|
+
|
|
63
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
64
|
+
|
|
65
|
+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
66
|
+
|
|
67
|
+
---- LLVM Exceptions to the Apache 2.0 License ----
|
|
68
|
+
|
|
69
|
+
As an exception, if, as a result of your compiling your source code, portions of this Software are embedded into an Object form of such source code, you may redistribute such embedded portions in such Object form without complying with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
|
|
70
|
+
|
|
71
|
+
In addition, if you combine or link compiled forms of this Software with software that is licensed under the GPLv2 ("Combined Software") and if a court of competent jurisdiction determines that the patent provision (Section 3), the indemnity provision (Section 9) or other Section of the License conflicts with the conditions of the GPLv2, you may retroactively and prospectively choose to deem waived or otherwise exclude such Section(s) of the License, but only in their entirety and only with respect to the Combined Software.
|
noqtis-0.1.1/MANIFEST.in
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
2
|
+
# the sdist builds on its own: the vendored C library comes with it
|
|
3
|
+
graft vendor
|
|
4
|
+
include src/ext.c src/nq.map LICENSE NOTICE README.md
|
|
5
|
+
include noqtis/py.typed noqtis/*.pyi
|
|
6
|
+
graft tests
|
|
7
|
+
global-exclude *.o *.so *.pyd *.pyc __pycache__
|
noqtis-0.1.1/NOTICE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
noqtis
|
|
2
|
+
Copyright 2026 Vansh Singh Ruhela (rootcoder007)
|
|
3
|
+
|
|
4
|
+
This product is licensed under the Apache License, Version 2.0, with
|
|
5
|
+
LLVM Exceptions (SPDX: Apache-2.0 WITH LLVM-exception); see LICENSE.
|
|
6
|
+
|
|
7
|
+
The test vectors in tests/vectors are not part of the licensed code:
|
|
8
|
+
the NIST ACVP vectors are works of the United States government and the
|
|
9
|
+
Wycheproof vectors are Apache-2.0 (see tests/vectors/SOURCES.md).
|
noqtis-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: noqtis
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Post-quantum signatures, KEMs and sealed file capsules (ML-DSA, SLH-DSA, ML-KEM, HQC) in one C library
|
|
5
|
+
Author: Vansh Singh Ruhela
|
|
6
|
+
License-Expression: Apache-2.0 WITH LLVM-exception
|
|
7
|
+
Project-URL: Homepage, https://github.com/rootcoder007/noqtis
|
|
8
|
+
Project-URL: Source, https://github.com/rootcoder007/noqtis/tree/main/bindings/py
|
|
9
|
+
Project-URL: Issues, https://github.com/rootcoder007/noqtis/issues
|
|
10
|
+
Project-URL: Security, https://github.com/rootcoder007/noqtis/blob/main/SECURITY.md
|
|
11
|
+
Keywords: post-quantum,pqc,ml-dsa,slh-dsa,ml-kem,hqc,fips-203,fips-204,fips-205,signature,provenance
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Operating System :: MacOS
|
|
16
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
17
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
18
|
+
Classifier: Programming Language :: C
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
21
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
22
|
+
Classifier: Topic :: Security :: Cryptography
|
|
23
|
+
Classifier: Typing :: Typed
|
|
24
|
+
Requires-Python: >=3.9
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
License-File: NOTICE
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# noqtis for Python
|
|
31
|
+
|
|
32
|
+
Post-quantum signatures, key encapsulation, hashes and sealed file
|
|
33
|
+
capsules, from the [noqtis](https://github.com/rootcoder007/noqtis) C
|
|
34
|
+
library. The library is compiled into the package: no runtime
|
|
35
|
+
dependencies, and wheels for Linux (glibc and musl), macOS and Windows on
|
|
36
|
+
x86-64 and arm64, one abi3 wheel per platform for CPython 3.9 and later.
|
|
37
|
+
|
|
38
|
+
| Family | Algorithms | Standard |
|
|
39
|
+
|---|---|---|
|
|
40
|
+
| Signatures | ML-DSA-44/65/87 | FIPS 204 |
|
|
41
|
+
| | SLH-DSA-SHA2 and SLH-DSA-SHAKE, 128/192/256, s and f | FIPS 205 |
|
|
42
|
+
| | Ed25519; hybrids ML-DSA-44/65/87+Ed25519 (both parts must verify) | RFC 8032 |
|
|
43
|
+
| KEMs | ML-KEM-512/768/1024 | FIPS 203 |
|
|
44
|
+
| | HQC-128/192/256 | HQC round 4 |
|
|
45
|
+
| Hashes | SHA-224 ... SHA-512/256, SHA3-224 ... SHA3-512, SHAKE128/256, HMAC | FIPS 180-4, FIPS 202 |
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
pip install noqtis # or: uv add noqtis
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Signatures
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from noqtis import sign
|
|
55
|
+
|
|
56
|
+
pk, sk = sign.keygen("ML-DSA-65")
|
|
57
|
+
sig = sign.sign("ML-DSA-65", sk, b"message", ctx=b"app-v1")
|
|
58
|
+
assert sign.verify("ML-DSA-65", pk, b"message", sig, ctx=b"app-v1")
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
- `keygen(alg, seed=None)` returns `(pk, sk)`; a seed gives the
|
|
62
|
+
standard's deterministic key pair.
|
|
63
|
+
- `sign(alg, sk, msg, ctx=b"", deterministic=False, prehash=None)`:
|
|
64
|
+
`prehash="SHA-512"` (or any name from `noqtis.hashes()`) selects
|
|
65
|
+
HashML-DSA / HashSLH-DSA; `msg` is still the message.
|
|
66
|
+
- `verify(...)` returns `True` or `False`; it never raises for a bad or
|
|
67
|
+
malformed signature.
|
|
68
|
+
|
|
69
|
+
## Key encapsulation
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
from noqtis import kem
|
|
73
|
+
|
|
74
|
+
pk, sk = kem.keygen("ML-KEM-768")
|
|
75
|
+
ct, ss = kem.encap("ML-KEM-768", pk)
|
|
76
|
+
assert kem.decap("ML-KEM-768", sk, ct) == ss
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
A tampered ciphertext decapsulates to an unrelated secret rather than an
|
|
80
|
+
error (implicit rejection, as FIPS 203 requires).
|
|
81
|
+
|
|
82
|
+
## Hashes
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
import noqtis
|
|
86
|
+
|
|
87
|
+
noqtis.hash("SHA3-256", b"abc")
|
|
88
|
+
noqtis.hash("SHAKE256", b"abc", 100) # 100 bytes of output
|
|
89
|
+
noqtis.hmac("SHA-256", b"key", b"data")
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Capsules
|
|
93
|
+
|
|
94
|
+
A capsule is a folder sealed with a manifest of every file in it
|
|
95
|
+
(`noqtis.json`) and a post-quantum signature over it (`noqtis.sig`).
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
import noqtis
|
|
99
|
+
|
|
100
|
+
pk, sk = noqtis.sign.keygen("ML-DSA-65")
|
|
101
|
+
noqtis.seal("results/", sk, pk, meta={"project": "survey-2026"})
|
|
102
|
+
|
|
103
|
+
report = noqtis.check("results/", pk)
|
|
104
|
+
print(report.ok) # True only if every check passed
|
|
105
|
+
for row in report.rows: # (check, ok, detail)
|
|
106
|
+
print(row)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Without `pk`, `check` trusts the key inside the seal and its report says
|
|
110
|
+
so. `anchors=[der, ...]` requires an RFC 3161 timestamp under one of the
|
|
111
|
+
given TSA certificates.
|
|
112
|
+
|
|
113
|
+
### Format 2, proofs and lineage
|
|
114
|
+
|
|
115
|
+
`seal(..., format=2)` adds a Merkle tree over the files to the manifest
|
|
116
|
+
and signs its head. `prove` then shows some files to a reader without
|
|
117
|
+
the names or digests of the others:
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
noqtis.seal("results/", sk, pk, format=2)
|
|
121
|
+
proof = noqtis.prove("results/", ["tables/t1.csv"]) # bytes (JSON)
|
|
122
|
+
noqtis.check(proof=proof, pk=pk).ok # the proof alone
|
|
123
|
+
noqtis.check("results/", pk, proof=proof).ok # and the files
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
`seal(..., inputs=["raw/", ("cleaned", "clean/")])` records the capsules
|
|
127
|
+
this one was made from, by id (`noqtis.capid(dir)`, 32 bytes);
|
|
128
|
+
`check(dir, pk, lineage=["raw/", "clean/"])` finds each input among those
|
|
129
|
+
folders and checks it, to 64 levels. `check(dir, pk, only=["a.csv"])`
|
|
130
|
+
checks just those files (a "partial" row says so). `noqtis.files(dir)`
|
|
131
|
+
lists what the manifest holds, `File(path, size, sha256)`, with nothing
|
|
132
|
+
checked.
|
|
133
|
+
|
|
134
|
+
### Key statements
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
st = noqtis.rotate(old_sk, old_pk, new_sk, new_pk, reason="yearly")
|
|
138
|
+
noqtis.check("results/", old_pk, keys=[st]).ok # sealed by the new key
|
|
139
|
+
rv = noqtis.revoke(old_sk, old_pk, at=1767225600)
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
A statement (bytes, or a file path) needs `pk`, the trusted key. With
|
|
143
|
+
it, `check` accepts a seal by a key the trusted key was rotated to, and
|
|
144
|
+
requires a verified timestamp from before a seal key was rotated away or
|
|
145
|
+
revoked. Ed25519 alone cannot make statements.
|
|
146
|
+
|
|
147
|
+
## DSSE envelopes
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
from noqtis import dsse
|
|
151
|
+
|
|
152
|
+
env = dsse.sign("ML-DSA-65", sk, pk, "application/vnd.in-toto+json", stmt)
|
|
153
|
+
dsse.verify("ML-DSA-65", pk, env) # Signed(type, payload), or None
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
The envelope (in-toto and SLSA's signing wrapper) is canonical JSON with
|
|
157
|
+
one signature over the pre-authentication encoding; its keyid is the hex
|
|
158
|
+
SHA-256 of `pk`. `verify` returns `None` when no signature verifies and
|
|
159
|
+
raises `DecodeError` for text that is not an envelope.
|
|
160
|
+
|
|
161
|
+
## Key files
|
|
162
|
+
|
|
163
|
+
`noqtis.keyfile` reads and writes the text key files `noqtis keygen`
|
|
164
|
+
makes (`noqtis-key-1 <alg> <pub|sec>`, then base64), as strictly as the
|
|
165
|
+
command-line tool reads them:
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
from noqtis import keyfile
|
|
169
|
+
|
|
170
|
+
k = keyfile.read("me", "sec") # Key(alg, kind, key); "me.pub" for pub
|
|
171
|
+
noqtis.sign.sign(k.alg, k.key, b"a message")
|
|
172
|
+
|
|
173
|
+
pk, sk = noqtis.sign.keygen("ML-DSA-65")
|
|
174
|
+
keyfile.write("you", "ML-DSA-65", "sec", sk) # owner-only, no overwrite
|
|
175
|
+
keyfile.write("you.pub", "ML-DSA-65", "pub", pk)
|
|
176
|
+
text = keyfile.encode("ML-DSA-65", "pub", pk) # the same text, as a str
|
|
177
|
+
assert keyfile.decode(text).key == pk
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
`write` never replaces a file unless `force=True`. Python's base64 is not
|
|
181
|
+
constant time: decode secret key files where timing is not observable.
|
|
182
|
+
|
|
183
|
+
## Errors
|
|
184
|
+
|
|
185
|
+
Every failure raises a subclass of `noqtis.NoqtisError`, one per library
|
|
186
|
+
error code: `ArgError`, `BufError`, `VerifyError`, `DecodeError`,
|
|
187
|
+
`RandError`, `MemError`, `FileError`, `UnsupportedError`, `LimitError`,
|
|
188
|
+
`StateError`. Each has `.code`, the library's `NQE*` value.
|
|
189
|
+
|
|
190
|
+
## Notes
|
|
191
|
+
|
|
192
|
+
- Inputs may be `bytes`, `bytearray` or `memoryview`; outputs are `bytes`.
|
|
193
|
+
Python cannot wipe `bytes`, so secret keys and shared secrets you hold
|
|
194
|
+
in Python live until the garbage collector frees them.
|
|
195
|
+
- Long operations release the GIL, so threads sign and verify in parallel.
|
|
196
|
+
- The package is typed (`py.typed`).
|
|
197
|
+
|
|
198
|
+
Licensed under Apache-2.0 WITH LLVM-exception.
|
noqtis-0.1.1/README.md
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# noqtis for Python
|
|
2
|
+
|
|
3
|
+
Post-quantum signatures, key encapsulation, hashes and sealed file
|
|
4
|
+
capsules, from the [noqtis](https://github.com/rootcoder007/noqtis) C
|
|
5
|
+
library. The library is compiled into the package: no runtime
|
|
6
|
+
dependencies, and wheels for Linux (glibc and musl), macOS and Windows on
|
|
7
|
+
x86-64 and arm64, one abi3 wheel per platform for CPython 3.9 and later.
|
|
8
|
+
|
|
9
|
+
| Family | Algorithms | Standard |
|
|
10
|
+
|---|---|---|
|
|
11
|
+
| Signatures | ML-DSA-44/65/87 | FIPS 204 |
|
|
12
|
+
| | SLH-DSA-SHA2 and SLH-DSA-SHAKE, 128/192/256, s and f | FIPS 205 |
|
|
13
|
+
| | Ed25519; hybrids ML-DSA-44/65/87+Ed25519 (both parts must verify) | RFC 8032 |
|
|
14
|
+
| KEMs | ML-KEM-512/768/1024 | FIPS 203 |
|
|
15
|
+
| | HQC-128/192/256 | HQC round 4 |
|
|
16
|
+
| Hashes | SHA-224 ... SHA-512/256, SHA3-224 ... SHA3-512, SHAKE128/256, HMAC | FIPS 180-4, FIPS 202 |
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
pip install noqtis # or: uv add noqtis
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Signatures
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from noqtis import sign
|
|
26
|
+
|
|
27
|
+
pk, sk = sign.keygen("ML-DSA-65")
|
|
28
|
+
sig = sign.sign("ML-DSA-65", sk, b"message", ctx=b"app-v1")
|
|
29
|
+
assert sign.verify("ML-DSA-65", pk, b"message", sig, ctx=b"app-v1")
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
- `keygen(alg, seed=None)` returns `(pk, sk)`; a seed gives the
|
|
33
|
+
standard's deterministic key pair.
|
|
34
|
+
- `sign(alg, sk, msg, ctx=b"", deterministic=False, prehash=None)`:
|
|
35
|
+
`prehash="SHA-512"` (or any name from `noqtis.hashes()`) selects
|
|
36
|
+
HashML-DSA / HashSLH-DSA; `msg` is still the message.
|
|
37
|
+
- `verify(...)` returns `True` or `False`; it never raises for a bad or
|
|
38
|
+
malformed signature.
|
|
39
|
+
|
|
40
|
+
## Key encapsulation
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
from noqtis import kem
|
|
44
|
+
|
|
45
|
+
pk, sk = kem.keygen("ML-KEM-768")
|
|
46
|
+
ct, ss = kem.encap("ML-KEM-768", pk)
|
|
47
|
+
assert kem.decap("ML-KEM-768", sk, ct) == ss
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
A tampered ciphertext decapsulates to an unrelated secret rather than an
|
|
51
|
+
error (implicit rejection, as FIPS 203 requires).
|
|
52
|
+
|
|
53
|
+
## Hashes
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
import noqtis
|
|
57
|
+
|
|
58
|
+
noqtis.hash("SHA3-256", b"abc")
|
|
59
|
+
noqtis.hash("SHAKE256", b"abc", 100) # 100 bytes of output
|
|
60
|
+
noqtis.hmac("SHA-256", b"key", b"data")
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Capsules
|
|
64
|
+
|
|
65
|
+
A capsule is a folder sealed with a manifest of every file in it
|
|
66
|
+
(`noqtis.json`) and a post-quantum signature over it (`noqtis.sig`).
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
import noqtis
|
|
70
|
+
|
|
71
|
+
pk, sk = noqtis.sign.keygen("ML-DSA-65")
|
|
72
|
+
noqtis.seal("results/", sk, pk, meta={"project": "survey-2026"})
|
|
73
|
+
|
|
74
|
+
report = noqtis.check("results/", pk)
|
|
75
|
+
print(report.ok) # True only if every check passed
|
|
76
|
+
for row in report.rows: # (check, ok, detail)
|
|
77
|
+
print(row)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Without `pk`, `check` trusts the key inside the seal and its report says
|
|
81
|
+
so. `anchors=[der, ...]` requires an RFC 3161 timestamp under one of the
|
|
82
|
+
given TSA certificates.
|
|
83
|
+
|
|
84
|
+
### Format 2, proofs and lineage
|
|
85
|
+
|
|
86
|
+
`seal(..., format=2)` adds a Merkle tree over the files to the manifest
|
|
87
|
+
and signs its head. `prove` then shows some files to a reader without
|
|
88
|
+
the names or digests of the others:
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
noqtis.seal("results/", sk, pk, format=2)
|
|
92
|
+
proof = noqtis.prove("results/", ["tables/t1.csv"]) # bytes (JSON)
|
|
93
|
+
noqtis.check(proof=proof, pk=pk).ok # the proof alone
|
|
94
|
+
noqtis.check("results/", pk, proof=proof).ok # and the files
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
`seal(..., inputs=["raw/", ("cleaned", "clean/")])` records the capsules
|
|
98
|
+
this one was made from, by id (`noqtis.capid(dir)`, 32 bytes);
|
|
99
|
+
`check(dir, pk, lineage=["raw/", "clean/"])` finds each input among those
|
|
100
|
+
folders and checks it, to 64 levels. `check(dir, pk, only=["a.csv"])`
|
|
101
|
+
checks just those files (a "partial" row says so). `noqtis.files(dir)`
|
|
102
|
+
lists what the manifest holds, `File(path, size, sha256)`, with nothing
|
|
103
|
+
checked.
|
|
104
|
+
|
|
105
|
+
### Key statements
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
st = noqtis.rotate(old_sk, old_pk, new_sk, new_pk, reason="yearly")
|
|
109
|
+
noqtis.check("results/", old_pk, keys=[st]).ok # sealed by the new key
|
|
110
|
+
rv = noqtis.revoke(old_sk, old_pk, at=1767225600)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
A statement (bytes, or a file path) needs `pk`, the trusted key. With
|
|
114
|
+
it, `check` accepts a seal by a key the trusted key was rotated to, and
|
|
115
|
+
requires a verified timestamp from before a seal key was rotated away or
|
|
116
|
+
revoked. Ed25519 alone cannot make statements.
|
|
117
|
+
|
|
118
|
+
## DSSE envelopes
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
from noqtis import dsse
|
|
122
|
+
|
|
123
|
+
env = dsse.sign("ML-DSA-65", sk, pk, "application/vnd.in-toto+json", stmt)
|
|
124
|
+
dsse.verify("ML-DSA-65", pk, env) # Signed(type, payload), or None
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
The envelope (in-toto and SLSA's signing wrapper) is canonical JSON with
|
|
128
|
+
one signature over the pre-authentication encoding; its keyid is the hex
|
|
129
|
+
SHA-256 of `pk`. `verify` returns `None` when no signature verifies and
|
|
130
|
+
raises `DecodeError` for text that is not an envelope.
|
|
131
|
+
|
|
132
|
+
## Key files
|
|
133
|
+
|
|
134
|
+
`noqtis.keyfile` reads and writes the text key files `noqtis keygen`
|
|
135
|
+
makes (`noqtis-key-1 <alg> <pub|sec>`, then base64), as strictly as the
|
|
136
|
+
command-line tool reads them:
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
from noqtis import keyfile
|
|
140
|
+
|
|
141
|
+
k = keyfile.read("me", "sec") # Key(alg, kind, key); "me.pub" for pub
|
|
142
|
+
noqtis.sign.sign(k.alg, k.key, b"a message")
|
|
143
|
+
|
|
144
|
+
pk, sk = noqtis.sign.keygen("ML-DSA-65")
|
|
145
|
+
keyfile.write("you", "ML-DSA-65", "sec", sk) # owner-only, no overwrite
|
|
146
|
+
keyfile.write("you.pub", "ML-DSA-65", "pub", pk)
|
|
147
|
+
text = keyfile.encode("ML-DSA-65", "pub", pk) # the same text, as a str
|
|
148
|
+
assert keyfile.decode(text).key == pk
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
`write` never replaces a file unless `force=True`. Python's base64 is not
|
|
152
|
+
constant time: decode secret key files where timing is not observable.
|
|
153
|
+
|
|
154
|
+
## Errors
|
|
155
|
+
|
|
156
|
+
Every failure raises a subclass of `noqtis.NoqtisError`, one per library
|
|
157
|
+
error code: `ArgError`, `BufError`, `VerifyError`, `DecodeError`,
|
|
158
|
+
`RandError`, `MemError`, `FileError`, `UnsupportedError`, `LimitError`,
|
|
159
|
+
`StateError`. Each has `.code`, the library's `NQE*` value.
|
|
160
|
+
|
|
161
|
+
## Notes
|
|
162
|
+
|
|
163
|
+
- Inputs may be `bytes`, `bytearray` or `memoryview`; outputs are `bytes`.
|
|
164
|
+
Python cannot wipe `bytes`, so secret keys and shared secrets you hold
|
|
165
|
+
in Python live until the garbage collector frees them.
|
|
166
|
+
- Long operations release the GIL, so threads sign and verify in parallel.
|
|
167
|
+
- The package is typed (`py.typed`).
|
|
168
|
+
|
|
169
|
+
Licensed under Apache-2.0 WITH LLVM-exception.
|