Skip to main content

A Qiskit-based library for transpiling quantum circuits into blind counterparts for applications in quantum homomorphic encryption and universal blind quantum computation.

Project description

Blind Transpiler: An open-source library for quantum homomorphic encryption and universal blind quantum computation

License DOI

Blind quantum computation (BQC) allows a limited-capability client to perform complex quantum computation on a remote server without revealing input, output, or computation. This primitive solves a problem of cryptography called 'Secure Delegated Computation'.

This cryptographic primitive enables application in various area like quantum homorphic encryption, secure quantum approximation algorithm, quantum private query, quantum multi-party computation, secret sharing protocols, blind factorization, quantum searachable encryption, among many other.

This python library presents first software tools to convert any quantum circuit written in Qiskit to its blind counterpart, allowing rapid prototyping of application of BQC cryptography.

Highlights

The library generates the circuit, which can be simulated in client-server architecture, where client is assumed to have the capability to perform $X$, $Z$, $Swap$ and $Measure$ The library can implement four types of blind transpilation:

  1. qhe: quantum homomorphic encryption translation of the given circuit, which hides client's data on server. This approach is capable of handling parametric gates like $R_z(\theta)$.
  2. ubqc: universal blind translation of the given circuit, which hides client's data and computing algorithm on the server using a resource state based on recursive rotation gates. This approach is capable of handling parametric gates like $R_z(\theta)$.
  3. fdqc: universal blind translation based on resource state based on ordered set of universal gates. This approach converts parametric gates to nonparametric resource for blind transpilation, as it cannot handle the parametric gates natively.
  4. ssdqc: universal blind translation based on fixed rotation gate universal resource set. This approach converts parametric gates to nonparametric resource for blind transpilation, as it cannot handle the parametric gates natively.

Get Started

blind_transpiler is an open source qiskit-based library for rapid prototyping of quantum homomorphic encryption and universal blind quantum computation in circuit-based model.

Library Outline

Install using pypi

The blind_transpiler library can be installed using pypi as:

pip install blind-transpiler

To install directly from source, (collect zip file of program from supplemantary material)

# Install the package (from the root of the folder)
pip install .

Creating your first program

Let's take a simple circuit of GHZ state:

from qiskit import QuantumCircuit
qc = QuantumCircuit(3)
qc.h(0)
qc.cx(0,1)
qc.cx(1,2)
qc.measure_all()

The circuit will be given as: Original Circuit

Let us also define a simulator for the circuit

def run_circuit(circ):
    backend = AerSimulator()
    shots = 1000
    t_circ = transpile(circ, backend)
    results = backend.run(t_circ, shots=shots).result()
    return results

If we run the circuit of GHZ state defined above on the qiskit simulator, we will see the output as:

Original Output

This circuit can be converted to its equivalent blind circuit using blind_transpiler library as:

from blind_transpiler import BQC
bqc = BQC()
bqc_instructions = bqc.generate_bqc(circ=qc, format='qhe')

This bqc_instruction objects contains the sequence of gate and the instruction to delegate then in the client-server architecture. We can try four different format, namely, qhe, ubqc, fdqc, ssdqc.

For more control on the encryption process, we can explicitly estimated the size of encryption key and generate it using any random process, or library defined process as:

from blind_transpiler import BQC
bqc = BQC()
key_size = bqc.estimate_keysize(format='qhe', circ=qc)
keys =  bqc.generate_random_key(key_size=key_size, key_style='rand')
bqc_instructions  = bqc.generate_bqc(circ=circ, format ='qhe', keys=keys)

The object bqc_instructions can be probed to get the various parameters associated with delegation as:

print(bqc_instrucion.n_client_gates)
print(bqc_instrucion.n_server_gates)
print(bqc_instrucion.n_secure_gates)
print(bqc_instrucion.n_communication_rounds)

The object bqc_instructions is virtually a collection of modified gate object which can be further probes for additional information as:

for elem in bqc_instructions:
    print(elem.op_type)
    print(elem.conditional)
    print(elem.gate)

Here, op_type defines the type of operation that the given instruction perform. For instance, it can be a client operated gate, or server delegated gate, or it might be gate necessary for encryption or decryption. conditional give the value of boolean variable which can be $0$, meaning the gate in not needed in final conversion or $1$, gate is needed in final execution based on the encryption key given. gate is the object of Qiskit instruction class which will actually be appended if the circuit is delegated to the server.

The object bqc_instructions can further be use to simulate the result be generating Qiskit circuit for this objection

blind_circ = bqc_instructions.to_circuit(const_type='complete', show_barrier=True) 

This will result in a quantum circuit written in Qiskit, which in our case will look like: Blind Circuit This circuit when simulate over client-server architecture will result in the output as desired by original circuit: Correct Delegated Output

However, if we delegate the circuit without proper decryption, we will get output unrelated to the original output. The output can be generated over $1000$ random key values as:

blind_format = 'qhe'
const_type = 'encrypt_only'
n_samples = 1000

bqc_trial = BQC()
estimated_key_size = bqc_trial.estimate_keysize(format=blind_format, circ=qc)
random_sample_key_space =  generate_binary_samples(n_samples,estimated_key_size)
n_clbits = circ.num_clbits
output = {output_key: 0 for output_key in [format(i, f'0{n_clbits}b') for i in range(2**n_clbits)]}

for keys in tqdm(random_sample_key_space):
    blind_circ, _ = blind_transpiler(circ=circ,blind_format=blind_format, const_type=const_type, keys=keys)
    results = run_circuit(blind_circ).get_counts()
    for k in results.keys():
        output[k] = results[k]

return output

The output over $1000$ random keys will be: Blind Output

Developer Notes:

The library is designed to be modular, reusable and robust against changes in Qiskit primitive. This is done by dividing the architecture of library in four different layers:

  1. Layer 0 (Qiskit Primitives): This the qiskit interface which uses QuantumCircuit and qiskit.circuit.library primitives to function properly.
  2. Layer 1 (I/O Primitives): This layer primarly interface with the qiskit layer and orchestrate the process of blind transpilation. (The library can also be extended to other quantum programming primitives with minimal refactoring in this layer)
  3. Layer 2 (Controllers): This layer defines the algorithms that controll the transpilation with rules written in transpilation library. (Developers can easily add new protocols of blind quantum computation in this layer, enhancing the functionallity).
  4. Layer 3 (Transaltors): This layer contains the rules of transpilation that are used by controller to transpile the circuit to its blind counterpart. (New rules of transpilation can be written here, or existing rules can be used to create new controllers).

A complete documentation of the library describing each feature is given in index.html file of documentation folder.

The UML-like relationship between the modules can be visualize as: UML Like Relationship

The folder structure of the code is:

blind_transpiler/
|
├──README.md
├──tests            # contain testcases for library
├──documentation     # contain html documentation of the library
├──.gitignore
├──CONTRIBUTIONS.md
├──LICENSE
├──NOTICE
├──pyproject.toml     # contain configuration files for library installation
├──requirements.txt
├──blind_transpiler/
    │
    ├── __init__.py          
    ├── global_value_store.py       # controller of the tests
    ├── essentials       # contains the class in which the output is given
    │   └── bop.py
    │   └── bqc_instruction.py
    ├── controllers       # has the orchestrator of library and controller for various protocols
    │   └── base.py
    │   └── orchestrator.py
    │   └── qhe.py
    │   └── ubqc.py
    │   └── fdqc.py
    │   └── ssdqc.py
    ├── translators       # defines the translation rules for various protocols
    │   └── base.py
    │   └── homomorphicTranslator.py
    │   └── universalRecursiveRotationTranslator.py
    │   └── universalOrderedSetTranslator.py
    │   └── universalFixedRotationTranslator.py

Licence

blind_transpiler is licensed under the Apache 2.0 license.

Acknowledgments

This project builds using features of the Qiskit open-source quantum computing framework.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

blind_transpiler-1.0.0.tar.gz (35.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

blind_transpiler-1.0.0-py3-none-any.whl (41.9 kB view details)

Uploaded Python 3

File details

Details for the file blind_transpiler-1.0.0.tar.gz.

File metadata

  • Download URL: blind_transpiler-1.0.0.tar.gz
  • Upload date:
  • Size: 35.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for blind_transpiler-1.0.0.tar.gz
Algorithm Hash digest
SHA256 dcd3f3c7a6e0a9f72a4001dc13930b0bdc2525a88e1db3c38fe8d3afd1625943
MD5 437d8c92449f380ab0598532a757edf2
BLAKE2b-256 601d71c14ead8cb6c180b7125e168f1b0affedf41618d5ed6a0c5b692fb669a3

See more details on using hashes here.

File details

Details for the file blind_transpiler-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for blind_transpiler-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 55296d3e48ed7458c0fce6d0bdeff42883273f4d66d6ad9a4a7106594863d253
MD5 4a6f27af9c07019e7405de3c03526e10
BLAKE2b-256 35780f9a8088b98779533e8edc7cadc052c7fef8c794a17443679202989f90ee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page