aleshaq-sdk 0.1.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.
- aleshaq_sdk-0.1.0/.github/workflows/publish.yml +38 -0
- aleshaq_sdk-0.1.0/.gitignore +32 -0
- aleshaq_sdk-0.1.0/LICENSE +21 -0
- aleshaq_sdk-0.1.0/PKG-INFO +200 -0
- aleshaq_sdk-0.1.0/README.md +139 -0
- aleshaq_sdk-0.1.0/examples/networking/entanglement_distribution.py +33 -0
- aleshaq_sdk-0.1.0/examples/networking/simple_network.py +23 -0
- aleshaq_sdk-0.1.0/examples/primitives/bell_ibm_runtime.py +62 -0
- aleshaq_sdk-0.1.0/examples/primitives/bell_state.py +15 -0
- aleshaq_sdk-0.1.0/examples/primitives/phase_estimation.py +35 -0
- aleshaq_sdk-0.1.0/examples/primitives/qft.py +33 -0
- aleshaq_sdk-0.1.0/examples/protocols/bb84.py +12 -0
- aleshaq_sdk-0.1.0/examples/protocols/bb84_ibm_runtime.py +78 -0
- aleshaq_sdk-0.1.0/examples/protocols/superdense_coding.py +9 -0
- aleshaq_sdk-0.1.0/examples/protocols/teleportation.py +18 -0
- aleshaq_sdk-0.1.0/examples/qec/repetition_code.py +24 -0
- aleshaq_sdk-0.1.0/examples/qec/repetition_ibm_runtime.py +59 -0
- aleshaq_sdk-0.1.0/examples/qec/syndrome_detection.py +21 -0
- aleshaq_sdk-0.1.0/pyproject.toml +67 -0
- aleshaq_sdk-0.1.0/src/aleshaq/__init__.py +21 -0
- aleshaq_sdk-0.1.0/src/aleshaq/networking/__init__.py +52 -0
- aleshaq_sdk-0.1.0/src/aleshaq/networking/channels/__init__.py +6 -0
- aleshaq_sdk-0.1.0/src/aleshaq/networking/channels/classical_channel.py +58 -0
- aleshaq_sdk-0.1.0/src/aleshaq/networking/channels/quantum_channel.py +72 -0
- aleshaq_sdk-0.1.0/src/aleshaq/networking/entanglement/__init__.py +15 -0
- aleshaq_sdk-0.1.0/src/aleshaq/networking/entanglement/link.py +153 -0
- aleshaq_sdk-0.1.0/src/aleshaq/networking/exceptions.py +23 -0
- aleshaq_sdk-0.1.0/src/aleshaq/networking/network.py +106 -0
- aleshaq_sdk-0.1.0/src/aleshaq/networking/nodes/__init__.py +5 -0
- aleshaq_sdk-0.1.0/src/aleshaq/networking/nodes/node.py +79 -0
- aleshaq_sdk-0.1.0/src/aleshaq/networking/protocols/__init__.py +8 -0
- aleshaq_sdk-0.1.0/src/aleshaq/networking/protocols/entanglement_distribution.py +133 -0
- aleshaq_sdk-0.1.0/src/aleshaq/networking/routing/__init__.py +6 -0
- aleshaq_sdk-0.1.0/src/aleshaq/networking/routing/router.py +101 -0
- aleshaq_sdk-0.1.0/src/aleshaq/networking/routing/topology.py +69 -0
- aleshaq_sdk-0.1.0/src/aleshaq/primitives/__init__.py +75 -0
- aleshaq_sdk-0.1.0/src/aleshaq/primitives/circuits/__init__.py +6 -0
- aleshaq_sdk-0.1.0/src/aleshaq/primitives/circuits/composition.py +49 -0
- aleshaq_sdk-0.1.0/src/aleshaq/primitives/circuits/oracle.py +76 -0
- aleshaq_sdk-0.1.0/src/aleshaq/primitives/estimation/__init__.py +5 -0
- aleshaq_sdk-0.1.0/src/aleshaq/primitives/estimation/phase.py +93 -0
- aleshaq_sdk-0.1.0/src/aleshaq/primitives/exceptions.py +27 -0
- aleshaq_sdk-0.1.0/src/aleshaq/primitives/execution/__init__.py +15 -0
- aleshaq_sdk-0.1.0/src/aleshaq/primitives/execution/backend.py +115 -0
- aleshaq_sdk-0.1.0/src/aleshaq/primitives/states/__init__.py +10 -0
- aleshaq_sdk-0.1.0/src/aleshaq/primitives/states/basis.py +31 -0
- aleshaq_sdk-0.1.0/src/aleshaq/primitives/states/bell.py +45 -0
- aleshaq_sdk-0.1.0/src/aleshaq/primitives/states/ghz.py +57 -0
- aleshaq_sdk-0.1.0/src/aleshaq/primitives/states/w_state.py +50 -0
- aleshaq_sdk-0.1.0/src/aleshaq/primitives/transforms/__init__.py +6 -0
- aleshaq_sdk-0.1.0/src/aleshaq/primitives/transforms/phase.py +28 -0
- aleshaq_sdk-0.1.0/src/aleshaq/primitives/transforms/qft.py +86 -0
- aleshaq_sdk-0.1.0/src/aleshaq/protocols/__init__.py +76 -0
- aleshaq_sdk-0.1.0/src/aleshaq/protocols/communication/__init__.py +21 -0
- aleshaq_sdk-0.1.0/src/aleshaq/protocols/communication/superdense.py +108 -0
- aleshaq_sdk-0.1.0/src/aleshaq/protocols/communication/teleportation.py +119 -0
- aleshaq_sdk-0.1.0/src/aleshaq/protocols/cryptographic/__init__.py +20 -0
- aleshaq_sdk-0.1.0/src/aleshaq/protocols/cryptographic/b92.py +124 -0
- aleshaq_sdk-0.1.0/src/aleshaq/protocols/cryptographic/bb84.py +181 -0
- aleshaq_sdk-0.1.0/src/aleshaq/protocols/cryptographic/decoy_state.py +300 -0
- aleshaq_sdk-0.1.0/src/aleshaq/protocols/cryptographic/e91.py +184 -0
- aleshaq_sdk-0.1.0/src/aleshaq/protocols/distributed/__init__.py +8 -0
- aleshaq_sdk-0.1.0/src/aleshaq/protocols/distributed/secret_sharing.py +118 -0
- aleshaq_sdk-0.1.0/src/aleshaq/protocols/exceptions.py +23 -0
- aleshaq_sdk-0.1.0/src/aleshaq/protocols/execution/__init__.py +24 -0
- aleshaq_sdk-0.1.0/src/aleshaq/protocols/execution/backend.py +198 -0
- aleshaq_sdk-0.1.0/src/aleshaq/protocols/execution/benchmark.py +138 -0
- aleshaq_sdk-0.1.0/src/aleshaq/protocols/execution/calibration.py +167 -0
- aleshaq_sdk-0.1.0/src/aleshaq/py.typed +1 -0
- aleshaq_sdk-0.1.0/src/aleshaq/qec/__init__.py +75 -0
- aleshaq_sdk-0.1.0/src/aleshaq/qec/codes/__init__.py +17 -0
- aleshaq_sdk-0.1.0/src/aleshaq/qec/codes/base.py +57 -0
- aleshaq_sdk-0.1.0/src/aleshaq/qec/codes/bit_flip.py +17 -0
- aleshaq_sdk-0.1.0/src/aleshaq/qec/codes/phase_flip.py +96 -0
- aleshaq_sdk-0.1.0/src/aleshaq/qec/codes/repetition.py +127 -0
- aleshaq_sdk-0.1.0/src/aleshaq/qec/codes/shor.py +142 -0
- aleshaq_sdk-0.1.0/src/aleshaq/qec/codes/steane.py +131 -0
- aleshaq_sdk-0.1.0/src/aleshaq/qec/decoders/__init__.py +7 -0
- aleshaq_sdk-0.1.0/src/aleshaq/qec/decoders/base.py +25 -0
- aleshaq_sdk-0.1.0/src/aleshaq/qec/decoders/lookup.py +41 -0
- aleshaq_sdk-0.1.0/src/aleshaq/qec/decoders/majority.py +57 -0
- aleshaq_sdk-0.1.0/src/aleshaq/qec/exceptions.py +23 -0
- aleshaq_sdk-0.1.0/src/aleshaq/qec/execution/__init__.py +21 -0
- aleshaq_sdk-0.1.0/src/aleshaq/qec/execution/backend.py +118 -0
- aleshaq_sdk-0.1.0/src/aleshaq/qec/execution/calibration.py +100 -0
- aleshaq_sdk-0.1.0/src/aleshaq/qec/noise/__init__.py +5 -0
- aleshaq_sdk-0.1.0/src/aleshaq/qec/noise/models.py +63 -0
- aleshaq_sdk-0.1.0/src/aleshaq/qec/simulation/__init__.py +5 -0
- aleshaq_sdk-0.1.0/src/aleshaq/qec/simulation/experiment.py +158 -0
- aleshaq_sdk-0.1.0/src/aleshaq/qec/syndrome/__init__.py +5 -0
- aleshaq_sdk-0.1.0/src/aleshaq/qec/syndrome/extraction.py +55 -0
- aleshaq_sdk-0.1.0/tests/test_circuits.py +62 -0
- aleshaq_sdk-0.1.0/tests/test_codes.py +135 -0
- aleshaq_sdk-0.1.0/tests/test_communication.py +61 -0
- aleshaq_sdk-0.1.0/tests/test_cryptographic.py +86 -0
- aleshaq_sdk-0.1.0/tests/test_decoders.py +58 -0
- aleshaq_sdk-0.1.0/tests/test_distributed.py +37 -0
- aleshaq_sdk-0.1.0/tests/test_estimation.py +75 -0
- aleshaq_sdk-0.1.0/tests/test_network.py +224 -0
- aleshaq_sdk-0.1.0/tests/test_network_hardening.py +70 -0
- aleshaq_sdk-0.1.0/tests/test_noise.py +30 -0
- aleshaq_sdk-0.1.0/tests/test_primitives_execution.py +50 -0
- aleshaq_sdk-0.1.0/tests/test_protocols_execution.py +73 -0
- aleshaq_sdk-0.1.0/tests/test_qec_execution.py +63 -0
- aleshaq_sdk-0.1.0/tests/test_simulation.py +57 -0
- aleshaq_sdk-0.1.0/tests/test_states.py +134 -0
- aleshaq_sdk-0.1.0/tests/test_transforms.py +72 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
pypi-publish:
|
|
10
|
+
name: Upload release to PyPI
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
environment:
|
|
13
|
+
name: pypi
|
|
14
|
+
url: https://pypi.org/p/aleshaq-sdk
|
|
15
|
+
permissions:
|
|
16
|
+
id-token: write # Wajib untuk OIDC Trusted Publishing ke PyPI
|
|
17
|
+
contents: read
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- name: Checkout source code
|
|
21
|
+
uses: actions/checkout@v4
|
|
22
|
+
|
|
23
|
+
- name: Set up Python
|
|
24
|
+
uses: actions/setup-python@v5
|
|
25
|
+
with:
|
|
26
|
+
python-version: "3.11"
|
|
27
|
+
|
|
28
|
+
- name: Install build dependencies
|
|
29
|
+
run: |
|
|
30
|
+
python -m pip install --upgrade pip
|
|
31
|
+
python -m pip install build
|
|
32
|
+
|
|
33
|
+
- name: Build binary wheel and source tarball
|
|
34
|
+
run: python -m build
|
|
35
|
+
|
|
36
|
+
- name: Publish package to PyPI
|
|
37
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
38
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.py[cod]
|
|
3
|
+
*$py.class
|
|
4
|
+
*.so
|
|
5
|
+
*.egg-info/
|
|
6
|
+
*.egg
|
|
7
|
+
dist/
|
|
8
|
+
build/
|
|
9
|
+
.eggs/
|
|
10
|
+
*.whl
|
|
11
|
+
*.venv/
|
|
12
|
+
venv/
|
|
13
|
+
.env
|
|
14
|
+
.venv
|
|
15
|
+
env/
|
|
16
|
+
|
|
17
|
+
.pytest_cache/
|
|
18
|
+
.coverage
|
|
19
|
+
htmlcov/
|
|
20
|
+
.tox/
|
|
21
|
+
.nox/
|
|
22
|
+
|
|
23
|
+
*.ipynb_checkpoints/
|
|
24
|
+
.mypy_cache/
|
|
25
|
+
.ruff_cache/
|
|
26
|
+
|
|
27
|
+
.idea/
|
|
28
|
+
.vscode/
|
|
29
|
+
*.swp
|
|
30
|
+
*.swo
|
|
31
|
+
*~
|
|
32
|
+
.DS_Store
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Naufal Ziyaadaturrahman
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: aleshaq-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Aleshnatt Quantum SDK: Comprehensive toolkit for quantum primitives, error correction, networking, and protocols.
|
|
5
|
+
Project-URL: Homepage, https://github.com/naufaziy/aleshaq
|
|
6
|
+
Project-URL: Repository, https://github.com/naufaziy/aleshaq
|
|
7
|
+
Author: Naufal Ziyaadaturrahman
|
|
8
|
+
License: MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2026 Naufal Ziyaadaturrahman
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
Keywords: bb84,qec,qiskit,qkd,quantum,quantum-computing,quantum-cryptography,quantum-error-correction,quantum-information,quantum-networking,teleportation
|
|
31
|
+
Classifier: Development Status :: 3 - Alpha
|
|
32
|
+
Classifier: Intended Audience :: Developers
|
|
33
|
+
Classifier: Intended Audience :: Science/Research
|
|
34
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
35
|
+
Classifier: Programming Language :: Python :: 3
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
40
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
41
|
+
Classifier: Topic :: Security :: Cryptography
|
|
42
|
+
Requires-Python: >=3.9
|
|
43
|
+
Requires-Dist: numpy
|
|
44
|
+
Requires-Dist: qiskit>=2.0
|
|
45
|
+
Provides-Extra: all
|
|
46
|
+
Requires-Dist: qbraid>=0.6.0; extra == 'all'
|
|
47
|
+
Requires-Dist: qiskit-aer; extra == 'all'
|
|
48
|
+
Requires-Dist: qiskit-ibm-runtime>=0.18.0; extra == 'all'
|
|
49
|
+
Provides-Extra: dev
|
|
50
|
+
Requires-Dist: build; extra == 'dev'
|
|
51
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
52
|
+
Requires-Dist: qiskit-aer; extra == 'dev'
|
|
53
|
+
Requires-Dist: twine; extra == 'dev'
|
|
54
|
+
Provides-Extra: ibm
|
|
55
|
+
Requires-Dist: qiskit-ibm-runtime>=0.18.0; extra == 'ibm'
|
|
56
|
+
Provides-Extra: qbraid
|
|
57
|
+
Requires-Dist: qbraid>=0.6.0; extra == 'qbraid'
|
|
58
|
+
Provides-Extra: sim
|
|
59
|
+
Requires-Dist: qiskit-aer; extra == 'sim'
|
|
60
|
+
Description-Content-Type: text/markdown
|
|
61
|
+
|
|
62
|
+
# Aleshnatt Quantum SDK (`aleshaq-sdk`)
|
|
63
|
+
|
|
64
|
+
[](LICENSE)
|
|
65
|
+
[](https://www.python.org/downloads/)
|
|
66
|
+
[](https://qiskit.org/)
|
|
67
|
+
|
|
68
|
+
**Aleshnatt Quantum SDK** (`aleshaq`) is a modular, production-grade Python toolkit for quantum computing, quantum error correction, quantum networking, and quantum cryptographic protocols. Built natively on Qiskit.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 📦 Architecture & Packages
|
|
73
|
+
|
|
74
|
+
`aleshaq` unites the full quantum information stack into four cohesive modules:
|
|
75
|
+
|
|
76
|
+
```text
|
|
77
|
+
┌────────────────────────────────────────────────────────────────────────┐
|
|
78
|
+
│ aleshaq-sdk (Top-Level) │
|
|
79
|
+
├────────────────────────────────────────────────────────────────────────┤
|
|
80
|
+
│ 1. aleshaq.primitives │ Bell/GHZ/W States, QFT, QPE, Oracles, Backend │
|
|
81
|
+
├────────────────────────┼───────────────────────────────────────────────┤
|
|
82
|
+
│ 2. aleshaq.qec │ Stabilizers (Shor, Steane), Decoders, Noise │
|
|
83
|
+
├────────────────────────┼───────────────────────────────────────────────┤
|
|
84
|
+
│ 3. aleshaq.networking │ Nodes, Quantum Channels, Swapping, Routing │
|
|
85
|
+
├────────────────────────┼───────────────────────────────────────────────┤
|
|
86
|
+
│ 4. aleshaq.protocols │ QKD (BB84, B92, E91, Decoy), Teleportation │
|
|
87
|
+
└────────────────────────────────────────────────────────────────────────┘
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## 🚀 Installation
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# Base SDK installation:
|
|
96
|
+
pip install aleshaq-sdk
|
|
97
|
+
|
|
98
|
+
# With local simulation (Qiskit Aer):
|
|
99
|
+
pip install "aleshaq-sdk[sim]"
|
|
100
|
+
|
|
101
|
+
# With hardware providers (IBM Quantum Runtime & qBraid):
|
|
102
|
+
pip install "aleshaq-sdk[ibm]"
|
|
103
|
+
pip install "aleshaq-sdk[qbraid]"
|
|
104
|
+
|
|
105
|
+
# Complete installation with all dependencies:
|
|
106
|
+
pip install "aleshaq-sdk[all]"
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## ⚡ Quick Start
|
|
112
|
+
|
|
113
|
+
### 1. Quantum Primitives (`aleshaq.primitives`)
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
from aleshaq.primitives import bell_state, ghz_state, qft, phase_estimation
|
|
117
|
+
|
|
118
|
+
# Prepare a Bell state (|Φ⁺⟩) circuit
|
|
119
|
+
qc_bell = bell_state(0)
|
|
120
|
+
print(qc_bell)
|
|
121
|
+
|
|
122
|
+
# Generate a 3-qubit Quantum Fourier Transform circuit
|
|
123
|
+
qc_qft = qft(n_qubits=3, do_swaps=True)
|
|
124
|
+
print(qc_qft)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### 2. Quantum Error Correction (`aleshaq.qec`)
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
from aleshaq.qec import SteaneCode, LookupTableDecoder, extract_syndrome
|
|
131
|
+
|
|
132
|
+
# Instantiate the 7-qubit Steane [[7,1,3]] code
|
|
133
|
+
code = SteaneCode()
|
|
134
|
+
encoder_circuit = code.encode()
|
|
135
|
+
|
|
136
|
+
# Extract stabilizer syndromes
|
|
137
|
+
syndrome_qc = code.syndrome_circuit()
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### 3. Quantum Networking (`aleshaq.networking`)
|
|
141
|
+
|
|
142
|
+
```python
|
|
143
|
+
from aleshaq.networking import QuantumNetwork, Node
|
|
144
|
+
from aleshaq.networking.protocols import EntanglementDistribution
|
|
145
|
+
|
|
146
|
+
# Build a 3-node quantum network
|
|
147
|
+
net = QuantumNetwork("Aleshnatt-Network")
|
|
148
|
+
alice = Node("Alice", qubit_capacity=4)
|
|
149
|
+
repeater = Node("Repeater", qubit_capacity=4)
|
|
150
|
+
bob = Node("Bob", qubit_capacity=4)
|
|
151
|
+
|
|
152
|
+
net.add_node(alice)
|
|
153
|
+
net.add_node(repeater)
|
|
154
|
+
net.add_node(bob)
|
|
155
|
+
net.connect(alice, repeater, length_km=10.0)
|
|
156
|
+
net.connect(repeater, bob, length_km=10.0)
|
|
157
|
+
|
|
158
|
+
# Distribute entanglement over multi-hop routing
|
|
159
|
+
dist = EntanglementDistribution(net)
|
|
160
|
+
res = dist.distribute("Alice", "Bob")
|
|
161
|
+
print(f"End-to-end fidelity: {res.fidelity:.4f}")
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### 4. Quantum Protocols & Cryptography (`aleshaq.protocols`)
|
|
165
|
+
|
|
166
|
+
```python
|
|
167
|
+
from aleshaq.protocols import BB84, DecoyStateBB84, Teleportation
|
|
168
|
+
|
|
169
|
+
# Run BB84 QKD Simulation
|
|
170
|
+
bb84 = BB84(n_bits=500, eavesdropper_present=False, seed=42)
|
|
171
|
+
result = bb84.run()
|
|
172
|
+
print(f"Sifted key length: {len(result.sifted_key_alice)}, QBER: {result.qber}")
|
|
173
|
+
|
|
174
|
+
# Run Decoy-State BB84 with Photon-Number Splitting (PNS) detection
|
|
175
|
+
decoy = DecoyStateBB84(n_rounds=1000, mu=0.5, nu=0.1, simulate_pns_attack=False)
|
|
176
|
+
decoy_res = decoy.run()
|
|
177
|
+
print(f"PNS Attack Detected: {decoy_res.pns_attack_detected}")
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## 🛠️ Development & Testing
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
# Clone the repository
|
|
186
|
+
git clone https://github.com/naufaziy/aleshaq.git
|
|
187
|
+
cd aleshaq
|
|
188
|
+
|
|
189
|
+
# Install in editable mode with development tools
|
|
190
|
+
pip install -e ".[dev]"
|
|
191
|
+
|
|
192
|
+
# Run tests
|
|
193
|
+
pytest
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## 📄 License
|
|
199
|
+
|
|
200
|
+
This project is licensed under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# Aleshnatt Quantum SDK (`aleshaq-sdk`)
|
|
2
|
+
|
|
3
|
+
[](LICENSE)
|
|
4
|
+
[](https://www.python.org/downloads/)
|
|
5
|
+
[](https://qiskit.org/)
|
|
6
|
+
|
|
7
|
+
**Aleshnatt Quantum SDK** (`aleshaq`) is a modular, production-grade Python toolkit for quantum computing, quantum error correction, quantum networking, and quantum cryptographic protocols. Built natively on Qiskit.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 📦 Architecture & Packages
|
|
12
|
+
|
|
13
|
+
`aleshaq` unites the full quantum information stack into four cohesive modules:
|
|
14
|
+
|
|
15
|
+
```text
|
|
16
|
+
┌────────────────────────────────────────────────────────────────────────┐
|
|
17
|
+
│ aleshaq-sdk (Top-Level) │
|
|
18
|
+
├────────────────────────────────────────────────────────────────────────┤
|
|
19
|
+
│ 1. aleshaq.primitives │ Bell/GHZ/W States, QFT, QPE, Oracles, Backend │
|
|
20
|
+
├────────────────────────┼───────────────────────────────────────────────┤
|
|
21
|
+
│ 2. aleshaq.qec │ Stabilizers (Shor, Steane), Decoders, Noise │
|
|
22
|
+
├────────────────────────┼───────────────────────────────────────────────┤
|
|
23
|
+
│ 3. aleshaq.networking │ Nodes, Quantum Channels, Swapping, Routing │
|
|
24
|
+
├────────────────────────┼───────────────────────────────────────────────┤
|
|
25
|
+
│ 4. aleshaq.protocols │ QKD (BB84, B92, E91, Decoy), Teleportation │
|
|
26
|
+
└────────────────────────────────────────────────────────────────────────┘
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 🚀 Installation
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# Base SDK installation:
|
|
35
|
+
pip install aleshaq-sdk
|
|
36
|
+
|
|
37
|
+
# With local simulation (Qiskit Aer):
|
|
38
|
+
pip install "aleshaq-sdk[sim]"
|
|
39
|
+
|
|
40
|
+
# With hardware providers (IBM Quantum Runtime & qBraid):
|
|
41
|
+
pip install "aleshaq-sdk[ibm]"
|
|
42
|
+
pip install "aleshaq-sdk[qbraid]"
|
|
43
|
+
|
|
44
|
+
# Complete installation with all dependencies:
|
|
45
|
+
pip install "aleshaq-sdk[all]"
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## ⚡ Quick Start
|
|
51
|
+
|
|
52
|
+
### 1. Quantum Primitives (`aleshaq.primitives`)
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
from aleshaq.primitives import bell_state, ghz_state, qft, phase_estimation
|
|
56
|
+
|
|
57
|
+
# Prepare a Bell state (|Φ⁺⟩) circuit
|
|
58
|
+
qc_bell = bell_state(0)
|
|
59
|
+
print(qc_bell)
|
|
60
|
+
|
|
61
|
+
# Generate a 3-qubit Quantum Fourier Transform circuit
|
|
62
|
+
qc_qft = qft(n_qubits=3, do_swaps=True)
|
|
63
|
+
print(qc_qft)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 2. Quantum Error Correction (`aleshaq.qec`)
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
from aleshaq.qec import SteaneCode, LookupTableDecoder, extract_syndrome
|
|
70
|
+
|
|
71
|
+
# Instantiate the 7-qubit Steane [[7,1,3]] code
|
|
72
|
+
code = SteaneCode()
|
|
73
|
+
encoder_circuit = code.encode()
|
|
74
|
+
|
|
75
|
+
# Extract stabilizer syndromes
|
|
76
|
+
syndrome_qc = code.syndrome_circuit()
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 3. Quantum Networking (`aleshaq.networking`)
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from aleshaq.networking import QuantumNetwork, Node
|
|
83
|
+
from aleshaq.networking.protocols import EntanglementDistribution
|
|
84
|
+
|
|
85
|
+
# Build a 3-node quantum network
|
|
86
|
+
net = QuantumNetwork("Aleshnatt-Network")
|
|
87
|
+
alice = Node("Alice", qubit_capacity=4)
|
|
88
|
+
repeater = Node("Repeater", qubit_capacity=4)
|
|
89
|
+
bob = Node("Bob", qubit_capacity=4)
|
|
90
|
+
|
|
91
|
+
net.add_node(alice)
|
|
92
|
+
net.add_node(repeater)
|
|
93
|
+
net.add_node(bob)
|
|
94
|
+
net.connect(alice, repeater, length_km=10.0)
|
|
95
|
+
net.connect(repeater, bob, length_km=10.0)
|
|
96
|
+
|
|
97
|
+
# Distribute entanglement over multi-hop routing
|
|
98
|
+
dist = EntanglementDistribution(net)
|
|
99
|
+
res = dist.distribute("Alice", "Bob")
|
|
100
|
+
print(f"End-to-end fidelity: {res.fidelity:.4f}")
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### 4. Quantum Protocols & Cryptography (`aleshaq.protocols`)
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
from aleshaq.protocols import BB84, DecoyStateBB84, Teleportation
|
|
107
|
+
|
|
108
|
+
# Run BB84 QKD Simulation
|
|
109
|
+
bb84 = BB84(n_bits=500, eavesdropper_present=False, seed=42)
|
|
110
|
+
result = bb84.run()
|
|
111
|
+
print(f"Sifted key length: {len(result.sifted_key_alice)}, QBER: {result.qber}")
|
|
112
|
+
|
|
113
|
+
# Run Decoy-State BB84 with Photon-Number Splitting (PNS) detection
|
|
114
|
+
decoy = DecoyStateBB84(n_rounds=1000, mu=0.5, nu=0.1, simulate_pns_attack=False)
|
|
115
|
+
decoy_res = decoy.run()
|
|
116
|
+
print(f"PNS Attack Detected: {decoy_res.pns_attack_detected}")
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## 🛠️ Development & Testing
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
# Clone the repository
|
|
125
|
+
git clone https://github.com/naufaziy/aleshaq.git
|
|
126
|
+
cd aleshaq
|
|
127
|
+
|
|
128
|
+
# Install in editable mode with development tools
|
|
129
|
+
pip install -e ".[dev]"
|
|
130
|
+
|
|
131
|
+
# Run tests
|
|
132
|
+
pytest
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## 📄 License
|
|
138
|
+
|
|
139
|
+
This project is licensed under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""Distribute entanglement across a multi-hop network."""
|
|
2
|
+
|
|
3
|
+
from aleshaq.networking import Node
|
|
4
|
+
from aleshaq.networking.entanglement import EntanglementManager
|
|
5
|
+
from aleshaq.networking.routing import Topology
|
|
6
|
+
from aleshaq.networking.protocols import EntanglementDistribution
|
|
7
|
+
|
|
8
|
+
# Build a linear chain: A — B — C — D
|
|
9
|
+
topology = Topology()
|
|
10
|
+
nodes = [Node("A"), Node("B"), Node("C"), Node("D")]
|
|
11
|
+
for n in nodes:
|
|
12
|
+
topology.add_node(n)
|
|
13
|
+
for i in range(len(nodes) - 1):
|
|
14
|
+
topology.add_edge(nodes[i], nodes[i + 1])
|
|
15
|
+
|
|
16
|
+
manager = EntanglementManager()
|
|
17
|
+
|
|
18
|
+
# Each direct link has fidelity 0.95, each swap operation has fidelity 0.98
|
|
19
|
+
protocol = EntanglementDistribution(
|
|
20
|
+
topology, manager,
|
|
21
|
+
link_fidelity=0.95,
|
|
22
|
+
swap_fidelity=0.98,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
result = protocol.distribute(nodes[0], nodes[-1])
|
|
26
|
+
|
|
27
|
+
print(f"Source: {result.source.name}")
|
|
28
|
+
print(f"Destination: {result.destination.name}")
|
|
29
|
+
print(f"Path: {[n.name for n in result.path]}")
|
|
30
|
+
print(f"Success: {result.success}")
|
|
31
|
+
if result.link:
|
|
32
|
+
print(f"End-to-end fidelity: {result.link.fidelity:.4f}")
|
|
33
|
+
print(f"Generation (swaps): {result.link.generation}")
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Build a simple three-node quantum network and find paths."""
|
|
2
|
+
|
|
3
|
+
from aleshaq.networking import QuantumNetwork, Node
|
|
4
|
+
|
|
5
|
+
network = QuantumNetwork("example")
|
|
6
|
+
|
|
7
|
+
alice = Node("alice")
|
|
8
|
+
bob = Node("bob")
|
|
9
|
+
charlie = Node("charlie")
|
|
10
|
+
|
|
11
|
+
network.add_node(alice)
|
|
12
|
+
network.add_node(bob)
|
|
13
|
+
network.add_node(charlie)
|
|
14
|
+
|
|
15
|
+
network.connect(alice, bob, loss_probability=0.05, length_km=50.0)
|
|
16
|
+
network.connect(bob, charlie, loss_probability=0.08, length_km=80.0)
|
|
17
|
+
|
|
18
|
+
print(f"Network nodes: {[n.name for n in network.nodes]}")
|
|
19
|
+
print(f"Channels: {len(network.quantum_channels)}")
|
|
20
|
+
|
|
21
|
+
path = network.find_path(alice, charlie)
|
|
22
|
+
if path:
|
|
23
|
+
print(f"Path alice → charlie: {[n.name for n in path]}")
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Prepare and measure Bell states on real IBM Quantum Runtime hardware.
|
|
3
|
+
|
|
4
|
+
Requirements:
|
|
5
|
+
pip install "aleshaq-sdk[ibm]"
|
|
6
|
+
export QISKIT_IBM_TOKEN="your-ibm-quantum-api-token"
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
import sys
|
|
11
|
+
|
|
12
|
+
from qiskit import transpile
|
|
13
|
+
|
|
14
|
+
from aleshaq.primitives import bell_state
|
|
15
|
+
from aleshaq.primitives.exceptions import MissingCredentialsError
|
|
16
|
+
from aleshaq.primitives.execution import get_ibm_backend
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def main() -> None:
|
|
20
|
+
token = os.environ.get("QISKIT_IBM_TOKEN") or os.environ.get("IBM_QUANTUM_TOKEN")
|
|
21
|
+
if not token:
|
|
22
|
+
print("=" * 70, file=sys.stderr)
|
|
23
|
+
print("ERROR: IBM Quantum credentials not found.", file=sys.stderr)
|
|
24
|
+
print("To run against real IBM Quantum hardware:", file=sys.stderr)
|
|
25
|
+
print(" 1. Obtain an API token from https://quantum.ibm.com", file=sys.stderr)
|
|
26
|
+
print(" 2. Set your environment variable:", file=sys.stderr)
|
|
27
|
+
print(" export QISKIT_IBM_TOKEN='<your_token>'", file=sys.stderr)
|
|
28
|
+
print("=" * 70, file=sys.stderr)
|
|
29
|
+
sys.exit(1)
|
|
30
|
+
|
|
31
|
+
print("Connecting to IBM Quantum Runtime...")
|
|
32
|
+
try:
|
|
33
|
+
backend_name = os.environ.get("QISKIT_IBM_BACKEND")
|
|
34
|
+
backend = get_ibm_backend(backend_name=backend_name, least_busy=not bool(backend_name), min_qubits=2)
|
|
35
|
+
print(f"Connected to IBM Quantum backend: {backend.name}")
|
|
36
|
+
except MissingCredentialsError as exc:
|
|
37
|
+
print(f"Authentication failed: {exc}", file=sys.stderr)
|
|
38
|
+
sys.exit(1)
|
|
39
|
+
except Exception as exc:
|
|
40
|
+
print(f"Failed to connect to IBM Quantum: {exc}", file=sys.stderr)
|
|
41
|
+
sys.exit(1)
|
|
42
|
+
|
|
43
|
+
# 1. Prepare |Φ⁺⟩ Bell state circuit
|
|
44
|
+
qc = bell_state(0)
|
|
45
|
+
qc.measure_all()
|
|
46
|
+
|
|
47
|
+
# 2. Transpile and execute on hardware
|
|
48
|
+
print(f"\n--- Executing |Φ⁺⟩ Bell state circuit on {backend.name} ---")
|
|
49
|
+
t_qc = transpile(qc, backend)
|
|
50
|
+
job = backend.run(t_qc, shots=4096)
|
|
51
|
+
result = job.result()
|
|
52
|
+
counts = result.get_counts()
|
|
53
|
+
|
|
54
|
+
print("\n--- Measurement Counts ---")
|
|
55
|
+
print(counts)
|
|
56
|
+
p_00 = counts.get("00", 0) / 4096
|
|
57
|
+
p_11 = counts.get("11", 0) / 4096
|
|
58
|
+
print(f"Correlated pair fraction (|00⟩ + |11⟩): {p_00 + p_11:.2%}")
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
if __name__ == "__main__":
|
|
62
|
+
main()
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""Prepare and verify Bell states using aleshaq.primitives."""
|
|
2
|
+
|
|
3
|
+
from qiskit_aer import AerSimulator
|
|
4
|
+
from aleshaq.primitives.states import bell_state
|
|
5
|
+
|
|
6
|
+
sim = AerSimulator()
|
|
7
|
+
|
|
8
|
+
for pair in range(4):
|
|
9
|
+
circuit = bell_state(pair)
|
|
10
|
+
circuit.measure_all()
|
|
11
|
+
|
|
12
|
+
result = sim.run(circuit, shots=4096, seed_simulator=42).result()
|
|
13
|
+
counts = result.get_counts()
|
|
14
|
+
|
|
15
|
+
print(f"Bell state {circuit.name}: {counts}")
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""Phase estimation example: estimate the eigenphase of the T gate.
|
|
2
|
+
|
|
3
|
+
The T gate has eigenvalue e^{iπ/4} for eigenstate |1⟩, so the
|
|
4
|
+
phase φ = 1/8.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from qiskit.circuit import QuantumCircuit
|
|
8
|
+
from qiskit_aer import AerSimulator
|
|
9
|
+
|
|
10
|
+
from aleshaq.primitives.estimation import phase_estimation, interpret_phase
|
|
11
|
+
|
|
12
|
+
# T gate as a unitary circuit
|
|
13
|
+
t_gate = QuantumCircuit(1, name="T")
|
|
14
|
+
t_gate.t(0)
|
|
15
|
+
|
|
16
|
+
# Eigenstate |1⟩
|
|
17
|
+
eigenstate = QuantumCircuit(1)
|
|
18
|
+
eigenstate.x(0)
|
|
19
|
+
|
|
20
|
+
# Build QPE circuit with 4 bits of precision
|
|
21
|
+
qpe_circuit = phase_estimation(t_gate, precision=4, eigenstate_prep=eigenstate)
|
|
22
|
+
print(f"QPE circuit: {qpe_circuit.num_qubits} qubits, depth {qpe_circuit.depth()}")
|
|
23
|
+
|
|
24
|
+
# Run on simulator
|
|
25
|
+
from qiskit import transpile
|
|
26
|
+
sim = AerSimulator()
|
|
27
|
+
transpiled_circuit = transpile(qpe_circuit, sim)
|
|
28
|
+
result = sim.run(transpiled_circuit, shots=4096, seed_simulator=42).result()
|
|
29
|
+
|
|
30
|
+
phases = interpret_phase(result.get_counts(), precision=4)
|
|
31
|
+
for phase, count in sorted(phases.items(), key=lambda x: -x[1]):
|
|
32
|
+
print(f" φ = {phase:.4f} (count: {count})")
|
|
33
|
+
|
|
34
|
+
dominant = max(phases, key=phases.get)
|
|
35
|
+
print(f"\nEstimated phase: {dominant:.4f} (expected: 0.1250)")
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""Apply QFT and its inverse, verifying the roundtrip."""
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
from qiskit.circuit import QuantumCircuit
|
|
5
|
+
from qiskit.quantum_info import Statevector
|
|
6
|
+
|
|
7
|
+
from aleshaq.primitives.transforms import qft, inverse_qft
|
|
8
|
+
|
|
9
|
+
n = 3
|
|
10
|
+
|
|
11
|
+
# Start with a known computational basis state
|
|
12
|
+
initial = QuantumCircuit(n)
|
|
13
|
+
initial.x(0) # |001⟩
|
|
14
|
+
|
|
15
|
+
sv_initial = Statevector.from_instruction(initial)
|
|
16
|
+
print(f"Initial state: {sv_initial}")
|
|
17
|
+
|
|
18
|
+
# Apply QFT
|
|
19
|
+
combined = QuantumCircuit(n)
|
|
20
|
+
combined.compose(initial, inplace=True)
|
|
21
|
+
combined.compose(qft(n), inplace=True)
|
|
22
|
+
|
|
23
|
+
sv_transformed = Statevector.from_instruction(combined)
|
|
24
|
+
print(f"After QFT: {sv_transformed}")
|
|
25
|
+
|
|
26
|
+
# Apply inverse QFT — should recover the original state
|
|
27
|
+
combined.compose(inverse_qft(n), inplace=True)
|
|
28
|
+
|
|
29
|
+
sv_recovered = Statevector.from_instruction(combined)
|
|
30
|
+
print(f"After QFT†: {sv_recovered}")
|
|
31
|
+
|
|
32
|
+
fidelity = np.abs(np.vdot(sv_initial.data, sv_recovered.data)) ** 2
|
|
33
|
+
print(f"Fidelity with initial state: {fidelity:.10f}")
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""BB84 QKD simulation example."""
|
|
2
|
+
|
|
3
|
+
from aleshaq.protocols.cryptographic import BB84
|
|
4
|
+
|
|
5
|
+
protocol = BB84(n_bits=100, seed=42)
|
|
6
|
+
result = protocol.run()
|
|
7
|
+
|
|
8
|
+
print(f"Total qubits sent: {len(result.alice_bits)}")
|
|
9
|
+
print(f"Sifted key length: {len(result.sifted_key_alice)}")
|
|
10
|
+
print(f"QBER: {result.qber:.4f}")
|
|
11
|
+
print(f"Keys match: {result.sifted_key_alice == result.sifted_key_bob}")
|
|
12
|
+
print(f"First 20 sifted key bits: {result.sifted_key_alice[:20]}")
|