kryptoon 1.0.0__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.
- kryptoon-1.0.0/.github/workflows/publish.yml +114 -0
- kryptoon-1.0.0/.gitignore +6 -0
- kryptoon-1.0.0/Cargo.toml +52 -0
- kryptoon-1.0.0/PKG-INFO +160 -0
- kryptoon-1.0.0/license.md +24 -0
- kryptoon-1.0.0/pyproject.toml +23 -0
- kryptoon-1.0.0/readme.md +145 -0
- kryptoon-1.0.0/security.md +15 -0
- kryptoon-1.0.0/source/kryptoon/__init__.py +3 -0
- kryptoon-1.0.0/source/kryptoon/__init__.pyi +3 -0
- kryptoon-1.0.0/source/kryptoon/classic/__init__.py +3 -0
- kryptoon-1.0.0/source/kryptoon/classic/__init__.pyi +3 -0
- kryptoon-1.0.0/source/kryptoon/classic/encode/__init__.py +11 -0
- kryptoon-1.0.0/source/kryptoon/classic/encode/__init__.pyi +11 -0
- kryptoon-1.0.0/source/kryptoon/classic/encode/__internal__.py +11 -0
- kryptoon-1.0.0/source/kryptoon/classic/encode/__internal__.pyi +9 -0
- kryptoon-1.0.0/source/kryptoon/classic/hash/__init__.py +25 -0
- kryptoon-1.0.0/source/kryptoon/classic/hash/__init__.pyi +25 -0
- kryptoon-1.0.0/source/kryptoon/classic/hash/__internal__.py +305 -0
- kryptoon-1.0.0/source/kryptoon/classic/hash/__internal__.pyi +177 -0
- kryptoon-1.0.0/source/kryptoon/classic/phf/__init__.py +13 -0
- kryptoon-1.0.0/source/kryptoon/classic/phf/__init__.pyi +13 -0
- kryptoon-1.0.0/source/kryptoon/classic/phf/__internal__.py +129 -0
- kryptoon-1.0.0/source/kryptoon/classic/phf/__internal__.pyi +73 -0
- kryptoon-1.0.0/source/kryptoon/quantum/__init__.py +3 -0
- kryptoon-1.0.0/source/kryptoon/quantum/__init__.pyi +3 -0
- kryptoon-1.0.0/source/kryptoon/quantum/dsa/__init__.py +11 -0
- kryptoon-1.0.0/source/kryptoon/quantum/dsa/__init__.pyi +11 -0
- kryptoon-1.0.0/source/kryptoon/quantum/dsa/__internal__.py +550 -0
- kryptoon-1.0.0/source/kryptoon/quantum/dsa/__internal__.pyi +390 -0
- kryptoon-1.0.0/source/kryptoon/quantum/kem/__init__.py +11 -0
- kryptoon-1.0.0/source/kryptoon/quantum/kem/__init__.pyi +11 -0
- kryptoon-1.0.0/source/kryptoon/quantum/kem/__internal__.py +526 -0
- kryptoon-1.0.0/source/kryptoon/quantum/kem/__internal__.pyi +365 -0
- kryptoon-1.0.0/source/rust/backend/classic/encode/internal.rs +18 -0
- kryptoon-1.0.0/source/rust/backend/classic/encode/mod.rs +2 -0
- kryptoon-1.0.0/source/rust/backend/classic/hash/internal.rs +304 -0
- kryptoon-1.0.0/source/rust/backend/classic/hash/mod.rs +2 -0
- kryptoon-1.0.0/source/rust/backend/classic/mod.rs +4 -0
- kryptoon-1.0.0/source/rust/backend/classic/phf/internal.rs +92 -0
- kryptoon-1.0.0/source/rust/backend/classic/phf/mod.rs +2 -0
- kryptoon-1.0.0/source/rust/backend/mod.rs +3 -0
- kryptoon-1.0.0/source/rust/backend/quantum/dsa/internal.rs +111 -0
- kryptoon-1.0.0/source/rust/backend/quantum/dsa/mod.rs +2 -0
- kryptoon-1.0.0/source/rust/backend/quantum/kem/internal.rs +89 -0
- kryptoon-1.0.0/source/rust/backend/quantum/kem/mod.rs +2 -0
- kryptoon-1.0.0/source/rust/backend/quantum/mod.rs +3 -0
- kryptoon-1.0.0/source/rust/library.rs +35 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
name: GitHub Workflow
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
id-token: write
|
|
10
|
+
contents: write
|
|
11
|
+
attestations: write
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
linux:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
strategy:
|
|
17
|
+
matrix:
|
|
18
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v4
|
|
21
|
+
- uses: actions/setup-python@v5
|
|
22
|
+
with:
|
|
23
|
+
python-version: ${{ matrix.python-version }}
|
|
24
|
+
- name: Maturin build
|
|
25
|
+
uses: PyO3/maturin-action@v1
|
|
26
|
+
with:
|
|
27
|
+
command: build
|
|
28
|
+
args: --release --out pypi
|
|
29
|
+
- name: Upload
|
|
30
|
+
uses: actions/upload-artifact@v4
|
|
31
|
+
with:
|
|
32
|
+
name: wheels-linux-py${{ matrix.python-version }}
|
|
33
|
+
path: pypi
|
|
34
|
+
|
|
35
|
+
windows:
|
|
36
|
+
runs-on: windows-latest
|
|
37
|
+
strategy:
|
|
38
|
+
matrix:
|
|
39
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
40
|
+
steps:
|
|
41
|
+
- uses: actions/checkout@v4
|
|
42
|
+
- uses: actions/setup-python@v5
|
|
43
|
+
with:
|
|
44
|
+
python-version: ${{ matrix.python-version }}
|
|
45
|
+
- name: Maturin build
|
|
46
|
+
uses: PyO3/maturin-action@v1
|
|
47
|
+
with:
|
|
48
|
+
command: build
|
|
49
|
+
args: --release --out pypi
|
|
50
|
+
- name: Upload
|
|
51
|
+
uses: actions/upload-artifact@v4
|
|
52
|
+
with:
|
|
53
|
+
name: wheels-windows-py${{ matrix.python-version }}
|
|
54
|
+
path: pypi
|
|
55
|
+
|
|
56
|
+
macos:
|
|
57
|
+
runs-on: macos-latest
|
|
58
|
+
strategy:
|
|
59
|
+
matrix:
|
|
60
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
61
|
+
steps:
|
|
62
|
+
- uses: actions/checkout@v4
|
|
63
|
+
- uses: actions/setup-python@v5
|
|
64
|
+
with:
|
|
65
|
+
python-version: ${{ matrix.python-version }}
|
|
66
|
+
- name: Maturin build
|
|
67
|
+
uses: PyO3/maturin-action@v1
|
|
68
|
+
with:
|
|
69
|
+
command: build
|
|
70
|
+
args: --release --out pypi
|
|
71
|
+
- name: Upload
|
|
72
|
+
uses: actions/upload-artifact@v4
|
|
73
|
+
with:
|
|
74
|
+
name: wheels-macos-py${{ matrix.python-version }}
|
|
75
|
+
path: pypi
|
|
76
|
+
|
|
77
|
+
sdist:
|
|
78
|
+
runs-on: ubuntu-latest
|
|
79
|
+
steps:
|
|
80
|
+
- uses: actions/checkout@v4
|
|
81
|
+
- name: Maturin sdist
|
|
82
|
+
uses: PyO3/maturin-action@v1
|
|
83
|
+
with:
|
|
84
|
+
command: sdist
|
|
85
|
+
args: --out pypi
|
|
86
|
+
- name: Upload
|
|
87
|
+
uses: actions/upload-artifact@v4
|
|
88
|
+
with:
|
|
89
|
+
name: wheels-sdist
|
|
90
|
+
path: pypi
|
|
91
|
+
|
|
92
|
+
release:
|
|
93
|
+
name: Release
|
|
94
|
+
runs-on: ubuntu-latest
|
|
95
|
+
needs:
|
|
96
|
+
- linux
|
|
97
|
+
- windows
|
|
98
|
+
- macos
|
|
99
|
+
- sdist
|
|
100
|
+
steps:
|
|
101
|
+
- uses: actions/download-artifact@v4
|
|
102
|
+
with:
|
|
103
|
+
path: artifacts
|
|
104
|
+
- name: Generate artifact attestation
|
|
105
|
+
uses: actions/attest-build-provenance@v2
|
|
106
|
+
with:
|
|
107
|
+
subject-path: "artifacts/wheels-*/*"
|
|
108
|
+
- name: Publish to PyPI
|
|
109
|
+
uses: PyO3/maturin-action@v1
|
|
110
|
+
env:
|
|
111
|
+
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
|
|
112
|
+
with:
|
|
113
|
+
command: upload
|
|
114
|
+
args: --non-interactive --skip-existing artifacts/wheels-*/*
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "kryptoon"
|
|
3
|
+
version = "1.0.0"
|
|
4
|
+
edition = "2024"
|
|
5
|
+
|
|
6
|
+
authors = ["Anonymous <224859321+bitmolester@users.noreply.github.com>"]
|
|
7
|
+
description = "Python Cryptography"
|
|
8
|
+
keywords = ["python", "cryptography"]
|
|
9
|
+
|
|
10
|
+
license = "Unlicense"
|
|
11
|
+
readme = "readme.md"
|
|
12
|
+
|
|
13
|
+
homepage = "https://github.com/bitmolester/kryptoon"
|
|
14
|
+
documentation = "https://github.com/bitmolester/kryptoon"
|
|
15
|
+
repository = "https://github.com/bitmolester/kryptoon"
|
|
16
|
+
|
|
17
|
+
[lib]
|
|
18
|
+
crate-type = ["cdylib"]
|
|
19
|
+
path = "source/rust/library.rs"
|
|
20
|
+
|
|
21
|
+
[dependencies.pyo3]
|
|
22
|
+
version = "0.25.1"
|
|
23
|
+
features = ["extension-module"]
|
|
24
|
+
|
|
25
|
+
[dependencies.oqs]
|
|
26
|
+
version = "0.11.0"
|
|
27
|
+
default-features = false
|
|
28
|
+
features = ["sigs", "kems"]
|
|
29
|
+
|
|
30
|
+
[dependencies.argon2]
|
|
31
|
+
version = "0.5.3"
|
|
32
|
+
|
|
33
|
+
[dependencies.rand]
|
|
34
|
+
version = "0.8.0"
|
|
35
|
+
|
|
36
|
+
[dependencies.blake3]
|
|
37
|
+
version = "1.8.2"
|
|
38
|
+
|
|
39
|
+
[dependencies.bcrypt]
|
|
40
|
+
version = "0.17.0"
|
|
41
|
+
|
|
42
|
+
[dependencies.ripemd]
|
|
43
|
+
version = "0.1.3"
|
|
44
|
+
|
|
45
|
+
[dependencies.bs58]
|
|
46
|
+
version = "0.5.1"
|
|
47
|
+
|
|
48
|
+
[dependencies.sha3]
|
|
49
|
+
version = "0.10.8"
|
|
50
|
+
|
|
51
|
+
[profile.release]
|
|
52
|
+
overflow-checks = true
|
kryptoon-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: kryptoon
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
5
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
6
|
+
Classifier: Programming Language :: Rust
|
|
7
|
+
Summary: Python Cryptography
|
|
8
|
+
Keywords: python,cryptography
|
|
9
|
+
Home-Page: https://github.com/bitmolester/kryptoon
|
|
10
|
+
Author-email: Anonymous <224859321+bitmolester@users.noreply.github.com>
|
|
11
|
+
License: Unlicense
|
|
12
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
13
|
+
Project-URL: Source Code, https://github.com/bitmolester/kryptoon
|
|
14
|
+
|
|
15
|
+
# 🔐 Python Cryptography
|
|
16
|
+
|
|
17
|
+
A blazing-fast cryptography library for Python, built on Rust.
|
|
18
|
+
|
|
19
|
+
Supports an extensive set of **post-quantum** digital signature algorithms (DSA) and key encapsulation mechanisms (KEM).
|
|
20
|
+
|
|
21
|
+
#### 🚀 Classic cryptography algorithms are also supported!
|
|
22
|
+
|
|
23
|
+
## ⚡ Features
|
|
24
|
+
- ✅ Dozens of NIST PQC candidates
|
|
25
|
+
- 🦀 Rust core for speed and safety
|
|
26
|
+
- 📦 Easy installation via [`pip`](https://pip.pypa.io)
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
### 🧬 Supported Algorithms
|
|
30
|
+
|
|
31
|
+
## 💻 Classic
|
|
32
|
+
### Encoding
|
|
33
|
+
- #### Base58
|
|
34
|
+
### Hashing
|
|
35
|
+
- #### Blake3
|
|
36
|
+
- #### Keccak
|
|
37
|
+
- #### Ripemd
|
|
38
|
+
### Password Hashing
|
|
39
|
+
- #### Argon2
|
|
40
|
+
- #### Bcrypt
|
|
41
|
+
|
|
42
|
+
## 🛰️ Quantum
|
|
43
|
+
|
|
44
|
+
### 🛡️ KEM
|
|
45
|
+
- #### Bike
|
|
46
|
+
- #### ClassicMcEliece
|
|
47
|
+
- #### Hqc
|
|
48
|
+
- #### Kyber
|
|
49
|
+
- #### MLKEM
|
|
50
|
+
- #### NtruPrime
|
|
51
|
+
- #### FrodoKem
|
|
52
|
+
|
|
53
|
+
### ✍️ DSA
|
|
54
|
+
- #### Cross
|
|
55
|
+
- #### Dilithium
|
|
56
|
+
- #### Falcon
|
|
57
|
+
- #### Mayo
|
|
58
|
+
- #### MLDSA
|
|
59
|
+
- #### Sphincs
|
|
60
|
+
- #### Uov
|
|
61
|
+
|
|
62
|
+
### ❔ Examples
|
|
63
|
+
|
|
64
|
+
#### DSA Example
|
|
65
|
+
```python
|
|
66
|
+
from kryptoon.quantum.dsa import Algorithm, KeyPair
|
|
67
|
+
|
|
68
|
+
# Step 1: Generate a new key pair (secret key and public key) using the MLDSA87 algorithm.
|
|
69
|
+
alicesk, alicepk = KeyPair(Algorithm.MLDSA.MLDSA87)
|
|
70
|
+
|
|
71
|
+
# Step 2: Restore (import) the secret key from its raw bytes.
|
|
72
|
+
# This simulates loading a saved secret key from storage.
|
|
73
|
+
secretkey = KeyPair(Algorithm.MLDSA.MLDSA87, secretkey=alicesk.secretkey)
|
|
74
|
+
|
|
75
|
+
# Step 3: Restore (import) the public key from its raw bytes.
|
|
76
|
+
# This simulates loading a saved public key from storage.
|
|
77
|
+
publickey = KeyPair(Algorithm.MLDSA.MLDSA87, publickey=alicepk.publickey)
|
|
78
|
+
|
|
79
|
+
# --- Alternative: Combined Key Import ---
|
|
80
|
+
# You can also restore both keys at once using a single call.
|
|
81
|
+
# This is useful when both the secret and public keys are available together.
|
|
82
|
+
secretkey, publickey = KeyPair(
|
|
83
|
+
Algorithm.MLDSA.MLDSA87,
|
|
84
|
+
secretkey=alicesk.secretkey,
|
|
85
|
+
publickey=alicepk.publickey
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
# Step 4: Prepare the message to be signed (convert string to bytes).
|
|
89
|
+
message = "Hello".encode()
|
|
90
|
+
|
|
91
|
+
# Step 5: Sign the message using the secret key.
|
|
92
|
+
signature = secretkey.sign(message=message)
|
|
93
|
+
|
|
94
|
+
# Step 6: Verify the signature using the public key.
|
|
95
|
+
valid = publickey.verify(signature=signature, message=message)
|
|
96
|
+
|
|
97
|
+
# Step 7: Ensure that the signature is valid.
|
|
98
|
+
# If the verification fails, the program will raise an error.
|
|
99
|
+
assert valid, "Signature verification failed!"
|
|
100
|
+
|
|
101
|
+
# Step 8: Display the original message (decoded back to string).
|
|
102
|
+
print(f"Message: [{message.decode()}]")
|
|
103
|
+
|
|
104
|
+
# Display the last 64 hex characters
|
|
105
|
+
print(f"Signature: [{signature.hex()[-64:]}]")
|
|
106
|
+
print(f"SecretKey: [{alicesk.secretkey.hex()[-64:]}]")
|
|
107
|
+
print(f"PublicKey: [{alicepk.publickey.hex()[-64:]}]")
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### KEM Example
|
|
111
|
+
```python
|
|
112
|
+
from kryptoon.quantum.kem import Algorithm, KeyPair
|
|
113
|
+
|
|
114
|
+
# Step 1: Generate key pairs for Alice and Bob using MLKEM1024 algorithm
|
|
115
|
+
alicesk, alicepk = KeyPair(Algorithm.MLKEM.MLKEM1024)
|
|
116
|
+
_bobsk, _bobpk = KeyPair(Algorithm.MLKEM.MLKEM1024)
|
|
117
|
+
|
|
118
|
+
# --- Key Export ---
|
|
119
|
+
# Export Alice's keys as bytes (simulate saving keys)
|
|
120
|
+
alice_secret_bytes = alicesk.secretkey
|
|
121
|
+
alice_public_bytes = alicepk.publickey
|
|
122
|
+
|
|
123
|
+
# Export Bob's keys as bytes (simulate saving keys)
|
|
124
|
+
bob_secret_bytes = _bobsk.secretkey
|
|
125
|
+
bob_public_bytes = _bobpk.publickey
|
|
126
|
+
|
|
127
|
+
# --- Key Import ---
|
|
128
|
+
# Re-import Alice's keys from bytes
|
|
129
|
+
alicesk_restored = KeyPair(Algorithm.MLKEM.MLKEM1024, secretkey=alice_secret_bytes)
|
|
130
|
+
alicepk_restored = KeyPair(Algorithm.MLKEM.MLKEM1024, publickey=alice_public_bytes)
|
|
131
|
+
|
|
132
|
+
# Re-import Bob's keys from bytes
|
|
133
|
+
bobsk_restored = KeyPair(Algorithm.MLKEM.MLKEM1024, secretkey=bob_secret_bytes)
|
|
134
|
+
bobpk_restored = KeyPair(Algorithm.MLKEM.MLKEM1024, publickey=bob_public_bytes)
|
|
135
|
+
|
|
136
|
+
# Step 2: Bob encapsulates a shared secret using Alice's public key
|
|
137
|
+
bobss, bobct = alicepk_restored.encapsulate()
|
|
138
|
+
|
|
139
|
+
# Step 3: Alice decapsulates the ciphertext using her secret key to recover the shared secret
|
|
140
|
+
alicess = alicesk_restored.decapsulate(bobct)
|
|
141
|
+
|
|
142
|
+
# Step 4: Verify that both shared secrets match
|
|
143
|
+
assert alicess == bobss, "Shared secrets do not match!"
|
|
144
|
+
|
|
145
|
+
# Step 5: Print results
|
|
146
|
+
print(f"Alice's Shared Secret: [{alicess.hex()}]")
|
|
147
|
+
print(f"Bob's Shared Secret: [{bobss.hex()}]")
|
|
148
|
+
|
|
149
|
+
# Display the last 64 hex characters
|
|
150
|
+
print(f"SecretKey: [{alicesk_restored.secretkey.hex()[-64:]}]")
|
|
151
|
+
print(f"PublicKey: [{alicepk_restored.publickey.hex()[-64:]}]")
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### 📦 Install
|
|
155
|
+
```shell
|
|
156
|
+
pip install kryptoon
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### 🥳 Enjoy!
|
|
160
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
4
|
+
distribute this software, either in source code form or as a compiled
|
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
|
6
|
+
means.
|
|
7
|
+
|
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
|
9
|
+
of this software dedicate any and all copyright interest in the
|
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
|
11
|
+
of the public at large and to the detriment of our heirs and
|
|
12
|
+
successors. We intend this dedication to be an overt act of
|
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
|
14
|
+
software under copyright law.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
|
|
24
|
+
For more information, please refer to <https://unlicense.org/>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "kryptoon"
|
|
3
|
+
authors = [{name = "Anonymous", email = "224859321+bitmolester@users.noreply.github.com"}]
|
|
4
|
+
dynamic = ["version", "description", "readme", "license", "keywords", "urls"]
|
|
5
|
+
|
|
6
|
+
classifiers = [
|
|
7
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
8
|
+
"Programming Language :: Python :: Implementation :: PyPy",
|
|
9
|
+
"Programming Language :: Rust",
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
[build-system]
|
|
13
|
+
requires = ["maturin>=1.0,<2.0"]
|
|
14
|
+
build-backend = "maturin"
|
|
15
|
+
|
|
16
|
+
[tool.maturin]
|
|
17
|
+
python-source = "source"
|
|
18
|
+
python-packages = ["kryptoon"]
|
|
19
|
+
module-name = "kryptoon.__internal__"
|
|
20
|
+
exclude = ["Cargo.lock"]
|
|
21
|
+
skip-auditwheel = false
|
|
22
|
+
bindings = "pyo3"
|
|
23
|
+
strip = true
|
kryptoon-1.0.0/readme.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# 🔐 Python Cryptography
|
|
2
|
+
|
|
3
|
+
A blazing-fast cryptography library for Python, built on Rust.
|
|
4
|
+
|
|
5
|
+
Supports an extensive set of **post-quantum** digital signature algorithms (DSA) and key encapsulation mechanisms (KEM).
|
|
6
|
+
|
|
7
|
+
#### 🚀 Classic cryptography algorithms are also supported!
|
|
8
|
+
|
|
9
|
+
## ⚡ Features
|
|
10
|
+
- ✅ Dozens of NIST PQC candidates
|
|
11
|
+
- 🦀 Rust core for speed and safety
|
|
12
|
+
- 📦 Easy installation via [`pip`](https://pip.pypa.io)
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
### 🧬 Supported Algorithms
|
|
16
|
+
|
|
17
|
+
## 💻 Classic
|
|
18
|
+
### Encoding
|
|
19
|
+
- #### Base58
|
|
20
|
+
### Hashing
|
|
21
|
+
- #### Blake3
|
|
22
|
+
- #### Keccak
|
|
23
|
+
- #### Ripemd
|
|
24
|
+
### Password Hashing
|
|
25
|
+
- #### Argon2
|
|
26
|
+
- #### Bcrypt
|
|
27
|
+
|
|
28
|
+
## 🛰️ Quantum
|
|
29
|
+
|
|
30
|
+
### 🛡️ KEM
|
|
31
|
+
- #### Bike
|
|
32
|
+
- #### ClassicMcEliece
|
|
33
|
+
- #### Hqc
|
|
34
|
+
- #### Kyber
|
|
35
|
+
- #### MLKEM
|
|
36
|
+
- #### NtruPrime
|
|
37
|
+
- #### FrodoKem
|
|
38
|
+
|
|
39
|
+
### ✍️ DSA
|
|
40
|
+
- #### Cross
|
|
41
|
+
- #### Dilithium
|
|
42
|
+
- #### Falcon
|
|
43
|
+
- #### Mayo
|
|
44
|
+
- #### MLDSA
|
|
45
|
+
- #### Sphincs
|
|
46
|
+
- #### Uov
|
|
47
|
+
|
|
48
|
+
### ❔ Examples
|
|
49
|
+
|
|
50
|
+
#### DSA Example
|
|
51
|
+
```python
|
|
52
|
+
from kryptoon.quantum.dsa import Algorithm, KeyPair
|
|
53
|
+
|
|
54
|
+
# Step 1: Generate a new key pair (secret key and public key) using the MLDSA87 algorithm.
|
|
55
|
+
alicesk, alicepk = KeyPair(Algorithm.MLDSA.MLDSA87)
|
|
56
|
+
|
|
57
|
+
# Step 2: Restore (import) the secret key from its raw bytes.
|
|
58
|
+
# This simulates loading a saved secret key from storage.
|
|
59
|
+
secretkey = KeyPair(Algorithm.MLDSA.MLDSA87, secretkey=alicesk.secretkey)
|
|
60
|
+
|
|
61
|
+
# Step 3: Restore (import) the public key from its raw bytes.
|
|
62
|
+
# This simulates loading a saved public key from storage.
|
|
63
|
+
publickey = KeyPair(Algorithm.MLDSA.MLDSA87, publickey=alicepk.publickey)
|
|
64
|
+
|
|
65
|
+
# --- Alternative: Combined Key Import ---
|
|
66
|
+
# You can also restore both keys at once using a single call.
|
|
67
|
+
# This is useful when both the secret and public keys are available together.
|
|
68
|
+
secretkey, publickey = KeyPair(
|
|
69
|
+
Algorithm.MLDSA.MLDSA87,
|
|
70
|
+
secretkey=alicesk.secretkey,
|
|
71
|
+
publickey=alicepk.publickey
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
# Step 4: Prepare the message to be signed (convert string to bytes).
|
|
75
|
+
message = "Hello".encode()
|
|
76
|
+
|
|
77
|
+
# Step 5: Sign the message using the secret key.
|
|
78
|
+
signature = secretkey.sign(message=message)
|
|
79
|
+
|
|
80
|
+
# Step 6: Verify the signature using the public key.
|
|
81
|
+
valid = publickey.verify(signature=signature, message=message)
|
|
82
|
+
|
|
83
|
+
# Step 7: Ensure that the signature is valid.
|
|
84
|
+
# If the verification fails, the program will raise an error.
|
|
85
|
+
assert valid, "Signature verification failed!"
|
|
86
|
+
|
|
87
|
+
# Step 8: Display the original message (decoded back to string).
|
|
88
|
+
print(f"Message: [{message.decode()}]")
|
|
89
|
+
|
|
90
|
+
# Display the last 64 hex characters
|
|
91
|
+
print(f"Signature: [{signature.hex()[-64:]}]")
|
|
92
|
+
print(f"SecretKey: [{alicesk.secretkey.hex()[-64:]}]")
|
|
93
|
+
print(f"PublicKey: [{alicepk.publickey.hex()[-64:]}]")
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
#### KEM Example
|
|
97
|
+
```python
|
|
98
|
+
from kryptoon.quantum.kem import Algorithm, KeyPair
|
|
99
|
+
|
|
100
|
+
# Step 1: Generate key pairs for Alice and Bob using MLKEM1024 algorithm
|
|
101
|
+
alicesk, alicepk = KeyPair(Algorithm.MLKEM.MLKEM1024)
|
|
102
|
+
_bobsk, _bobpk = KeyPair(Algorithm.MLKEM.MLKEM1024)
|
|
103
|
+
|
|
104
|
+
# --- Key Export ---
|
|
105
|
+
# Export Alice's keys as bytes (simulate saving keys)
|
|
106
|
+
alice_secret_bytes = alicesk.secretkey
|
|
107
|
+
alice_public_bytes = alicepk.publickey
|
|
108
|
+
|
|
109
|
+
# Export Bob's keys as bytes (simulate saving keys)
|
|
110
|
+
bob_secret_bytes = _bobsk.secretkey
|
|
111
|
+
bob_public_bytes = _bobpk.publickey
|
|
112
|
+
|
|
113
|
+
# --- Key Import ---
|
|
114
|
+
# Re-import Alice's keys from bytes
|
|
115
|
+
alicesk_restored = KeyPair(Algorithm.MLKEM.MLKEM1024, secretkey=alice_secret_bytes)
|
|
116
|
+
alicepk_restored = KeyPair(Algorithm.MLKEM.MLKEM1024, publickey=alice_public_bytes)
|
|
117
|
+
|
|
118
|
+
# Re-import Bob's keys from bytes
|
|
119
|
+
bobsk_restored = KeyPair(Algorithm.MLKEM.MLKEM1024, secretkey=bob_secret_bytes)
|
|
120
|
+
bobpk_restored = KeyPair(Algorithm.MLKEM.MLKEM1024, publickey=bob_public_bytes)
|
|
121
|
+
|
|
122
|
+
# Step 2: Bob encapsulates a shared secret using Alice's public key
|
|
123
|
+
bobss, bobct = alicepk_restored.encapsulate()
|
|
124
|
+
|
|
125
|
+
# Step 3: Alice decapsulates the ciphertext using her secret key to recover the shared secret
|
|
126
|
+
alicess = alicesk_restored.decapsulate(bobct)
|
|
127
|
+
|
|
128
|
+
# Step 4: Verify that both shared secrets match
|
|
129
|
+
assert alicess == bobss, "Shared secrets do not match!"
|
|
130
|
+
|
|
131
|
+
# Step 5: Print results
|
|
132
|
+
print(f"Alice's Shared Secret: [{alicess.hex()}]")
|
|
133
|
+
print(f"Bob's Shared Secret: [{bobss.hex()}]")
|
|
134
|
+
|
|
135
|
+
# Display the last 64 hex characters
|
|
136
|
+
print(f"SecretKey: [{alicesk_restored.secretkey.hex()[-64:]}]")
|
|
137
|
+
print(f"PublicKey: [{alicepk_restored.publickey.hex()[-64:]}]")
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### 📦 Install
|
|
141
|
+
```shell
|
|
142
|
+
pip install kryptoon
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### 🥳 Enjoy!
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
### Supported Versions
|
|
4
|
+
|
|
5
|
+
This section outlines the versions of the project that are actively maintained and receive security updates.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
| Version | Supported |
|
|
9
|
+
| ------- | ------------------ |
|
|
10
|
+
| 1.0.x | :white_check_mark: |
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
### Reporting a Vulnerability
|
|
14
|
+
|
|
15
|
+
If you find a security vulnerability in this project, please report it by opening an issue on the project’s issue tracker.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# IMPORT
|
|
2
|
+
from kryptoon import __internal__ as _internal # type: ignore
|
|
3
|
+
|
|
4
|
+
# MAIN
|
|
5
|
+
def b58encode(buffer: bytes) -> bytes:
|
|
6
|
+
result = _internal.b58encode(buffer) #type: ignore
|
|
7
|
+
return result # type: ignore
|
|
8
|
+
|
|
9
|
+
def b58decode(buffer: bytes) -> bytes:
|
|
10
|
+
result = _internal.b58decode(buffer) #type: ignore
|
|
11
|
+
return result # type: ignore
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# IMPORT
|
|
2
|
+
from kryptoon.classic.hash.__internal__ import (
|
|
3
|
+
Blake3,
|
|
4
|
+
Ripemd128,
|
|
5
|
+
Ripemd160,
|
|
6
|
+
Ripemd256,
|
|
7
|
+
Ripemd320,
|
|
8
|
+
Keccak224,
|
|
9
|
+
Keccak256,
|
|
10
|
+
Keccak384,
|
|
11
|
+
Keccak512
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
# MAIN
|
|
15
|
+
__all__: list[str] = [
|
|
16
|
+
"Blake3",
|
|
17
|
+
"Ripemd128",
|
|
18
|
+
"Ripemd160",
|
|
19
|
+
"Ripemd256",
|
|
20
|
+
"Ripemd320",
|
|
21
|
+
"Keccak224",
|
|
22
|
+
"Keccak256",
|
|
23
|
+
"Keccak384",
|
|
24
|
+
"Keccak512"
|
|
25
|
+
]
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# IMPORT
|
|
2
|
+
from kryptoon.classic.hash.__internal__ import (
|
|
3
|
+
Blake3,
|
|
4
|
+
Ripemd128,
|
|
5
|
+
Ripemd160,
|
|
6
|
+
Ripemd256,
|
|
7
|
+
Ripemd320,
|
|
8
|
+
Keccak224,
|
|
9
|
+
Keccak256,
|
|
10
|
+
Keccak384,
|
|
11
|
+
Keccak512
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
# MAIN
|
|
15
|
+
__all__: list[str] = [
|
|
16
|
+
"Blake3",
|
|
17
|
+
"Ripemd128",
|
|
18
|
+
"Ripemd160",
|
|
19
|
+
"Ripemd256",
|
|
20
|
+
"Ripemd320",
|
|
21
|
+
"Keccak224",
|
|
22
|
+
"Keccak256",
|
|
23
|
+
"Keccak384",
|
|
24
|
+
"Keccak512"
|
|
25
|
+
]
|