top of page

Advancing Cryptographic Security: Integrating Quantum Entropy Systems for Random Key Generation with IBM Qiskit

Updated: Jul 19


QRNG simulation using Python



As you see, by my posts, recently, I am deeply involved in the cybersecurity aspects of quantum computing. For fun, I intend to build a prototype hardware and software system focused on providing a turnkey solution that can operate off the grid, generating an unlimited number of keys for various applications. These include network security, secure video and audio conferencing, simulations such as Monte Carlo simulations that require truly random numbers, and many different uses in the gaming industry.


This system would be incredibly valuable to market, but developing it involves a massive amount of work. Fortunately, I have plenty of time and am committed to building it. The system will have quantum key generation capabilities and will ultimately host a secure communication app within the turnkey solution.


Who are my customers? The entire world!


So, prusuing this project, a few weeks ago, I decided to build a simple interface for generating random keys. The keys can be 128-bit, 256-bit, or 512-bit, generated using classical methods via a Python script on a desktop PC. While this method is reliable and the keys are complex, they are still potentially breakable because they use classical encryption.

My ultimate goal is to generate keys randomly using quantum entropy sources. Such keys would be more secure because, according to the laws of quantum mechanics, not even a quantum computer can predict or break these numbers before they are measured. This would make the keys truly random and extremely difficult to break.


So, how do we achieve this? The more authentically random the keys are, the harder they are to break. There are various quantum random number generators (QRNGs) available, including USB, PCI, and rack-mounted devices. To prove the concept, I designed a simple system to generate 128-bit, 256-bit, and 512-bit keys using classical methods. The same method can be adapted to use quantum sources. My next project is to integrate quantum sources into the same code and publish it online.

Quantum entropy systems come with public documentation, offering unique ways to generate reliable cryptographic security that is theoretically secure against future quantum computers.


Here's the code structure for the project. It includes two main modules: Index.html for the basic interface and app.py for the logic. The directory structure is also provided.

  1. Create a folder named "Projects" on your root directory.

  2. Install Python and IBM Qiskit, following the default options. Verify the installation, ensuring there are no errors, and then reboot your desktop.

  3. Open PowerShell with admin rights on Windows 10 and run the following commands:



Run powershell with Admin rights on Windows 10.

C:\

MD projects

C:\projects

cd projects

md QKG


Assuming you have a virtual environment setup, activate it. I mean Install Python for your Desktop Windows. Everything is online.


Then (example in my machine)

.\venv\Scripts\Activate


So, from powershell promnpt - everything should be on your path


pip install qiskit qiskit-aer flask matplotlib pylatexenc


mkdir templates static keys circuits

you are going to need all these folders under QKG folder


Then save these 2 files, the Index.html in template folder and app.py in QKG folders. I included both attached to this post ready to download.




Download the PY app here (Link provided with this post. Look the bottom of this post)

Here is how it can look if you add the dark background and also allow user to select the colors for building keys and gates.


The end results can look like this. This simple application can generate cryptographic keys and build quantum gates using IBM Qiskit. My next objective is to integrate a Quantum Entropy system into this application. I am currently exploring options to obtain either a USB or PCI card that supports quantum key generation.

Integrating a Quantum Entropy system will enhance the security and randomness of the generated keys, making them resistant to even the most advanced classical and quantum attacks. This will involve using hardware that leverages the principles of quantum mechanics to produce truly random numbers, which can then be used to create cryptographic keys.

I am committed to sharing my findings and progress with the community. Once I have successfully integrated the Quantum Entropy system and verified its functionality, I will publish my research and the updated application here for free. This will include detailed documentation, source code, and instructions on how to set up and use the system.

Stay tuned for updates on this exciting project, as I continue to push the boundaries of cryptographic security using quantum technology.


Try to generate keys, play with the selections





Download and rename to Index.html and put it in the template folder

Save this to app .py file

use Notepad to grab this code and save to a app.py in your QKG folder



My system does not allow to move .py files!


Cut from here:


from flask import Flask, render_template, request, send_from_directory

import os

import datetime

from qiskit import QuantumCircuit


app = Flask(__name__)


@app.route('/')

def index():

return render_template('index.html')


@app.route('/generate_keys', methods=['POST'])

def generate_keys():

key_size = request.form['key_size']

count = int(request.form['count'])

keys = []

for _ in range(count):

key = os.urandom(int(key_size) // 8)

keys.append(key.hex())

filename = f'keys_{key_size}bit_{datetime.datetime.now().strftime("%Y%m%d%H%M%S")}.txt'

with open(os.path.join('keys', filename), 'w') as f:

for key in keys:

f.write(f"{key}\n")

return f'Keys generated and saved as {filename}'


@app.route('/generate_circuit', methods=['POST'])

def generate_circuit():

gate = request.form['gate']

qubit = request.form.get('qubit')

if qubit:

qubit = int(qubit)

circuit = QuantumCircuit(1)

if gate == 'h':

circuit.h(qubit)

elif gate == 'x':

circuit.x(qubit)

elif gate == 'y':

circuit.y(qubit)

elif gate == 'z':

circuit.z(qubit)


# Save the circuit as a drawing

filename = f'circuit_{datetime.datetime.now().strftime("%Y%m%d%H%M%S")}.png'

try:

circuit.draw(output='mpl', filename=os.path.join('circuits', filename))

return f'Circuit saved as {filename}'

except Exception as e:

return f"Error saving circuit: {e}"


else:

return "Qubit value is missing. Please provide a valid qubit value."


if __name__ == '__main__':

if not os.path.exists('keys'):

os.makedirs('keys')

if not os.path.exists('circuits'):

os.makedirs('circuits')

app.run(port=5000, debug=True)


Cut from top of this code to here above this line

And then Paste it into Notepad and save as app.py in the the folder that subfolders are residing

 

Thank you for reading my post. If you have a suggestion for the project, let me know. I am adding a few more features to the project like drawing the circuits on the screen so you can follow your logic better. It is fun! Ultimately, I am drawing and building my own circuits and gates and can actually build something, anything on a real quantum Computer. For example, i love to be able to build my own solutions on eaither ionQ ion trapping system or the IBM Qiskit.










16 views

Comentarios


bottom of page