qseckey 0.1.2
QSECKEY: Quantum Secure Key generation library for classical KMS integration
Requires Python: >=3.7

# QSecKey
An application for securely distributing cryptographic keys from a QKD system to applications across a distributed network.

# Objective
The design will adhere to the ETSI GS QKD 014 standard, ensuring seamless integration of the Key Management System (KMS) with a QKD simulator to efficiently generate, manage, and distribute cryptographic keys across the network. This proposed interface is capable of storing QKD keys and can be sent to the application entities upon request. 


# Components
- Secure Application Entities(SAEs): These entities can request for keys from KME based on the requirement.
- Key Management Entities(KMEs): These entities are Point of contact for SAEs to request keys which are generated by the QKDEs.
- Quantum Key distribution Entities(QKDEs): These entities will be running the bb84/Key generation algorithm on Quantum simulator to generate and share the keys in a distributed network.

# Architecture and Algorithm Walkthrough
https://docs.google.com/document/d/14FPwCqk0Pru6AEgg1vNN2Zz7vKAVvZKS_mIe-GKriFs/edit?usp=sharing

# Entities:
- Connection DB: Stores details such as application_id, QoS data, Master SAE ID, Slave SAE ID, Master KME ID, Slave KME ID, available keys, key size, and other relevant information. The KMS server will periodically check this db and request the QKD application server to generate the keys in the background.
- Key Storage: Contains application_id, key_id, and key_data for storing generated keys.
- QKD Application Server: Acts as an interface between the KMS server and the Quantum Device/Simulator, handling processing and logical operations related to key generation and storage.
- Quantum Simulator and Link: Connects to a quantum simulator, processes qubit information, and shares the results with the QKD application server or another quantum device via a quantum link.


# usage
 - Application server running in docker environment
 - python module



## Application server running in docker environment

# Prerequisites
- Docker
- Docker Compose


## Build using Docker Compose
Run the following command to build the application:
```sh
docker-compose up --build
```

# RUN:

## Register Entity and Start Key Generation
```sh
curl --location 'http://localhost:8000/register_connection' \
--header 'Content-Type: application/json' \
--data '{
  "source_KME_ID": "sender_app",
  "target_KME_ID": "receiver_app",
  "master_SAE_ID": "ghi",
  "slave_SAE_ID": "jk3"
}'

```
Optional: 
key_size : The size of keys generated by QKD (This can be specified later during Get Key method where if the specified key_size is greater than default the KME will merge smaller keys to generate larger)
max_keys_count : The count of keys required on the server storage

## Request key From Master SAE

```sh
curl --location 'http://127.0.0.1:8000/get_key?slave_host=jkl&key_size=128' \
--data ''
```

Optional:
key_size

## Request Key From Slave SAE

```sh
curl --location 'http://127.0.0.1:8001/get_key?key_id=9cf3af44-5f17-4d9b-afd6-b8e8cb055db1' \
--data ''
```



## Python Module


## Usage

```python
from qseckey import initialize, register_connection, get_key

initialize({"MAX_KEYS_COUNT": 100})
register_connection({...})
get_key(key_id="abc123")