# Prepare-and-Send Quantum Fully Homomorphic Encryption

This example protocol achieves the functionality of Secure Client- Server Delegated Computation by a method which involves quantum offline and classical offline communication, called Quantum Fully Homomorphic Encryption (QFHE). Offline communication means there is exchange of information is not required throughout the protocol but only once at the start or end of the protocol. It allows the Client to encrypt quantum data in such a way that Server can carry out any arbitrary quantum computations on the encrypted data without having to interact with the encrypting party. It hides the output and input of the computation while Server is allowed to choose the unitary operation for required computation. Thus, the circuit is known to the Server while efforts can be made to hide it from the encrypting party i.e. Client. Based on the existence of classical Homomorphic Encryption (HE) scheme, it comes with properties of correctness, compactness and full homomorphism. QFHE can be used to keep the circuit private to the Server and hidden from the Client unlike UBQC where the circuit is private to the Client and hidden from the Server.

Tags: Two Party,Universal Task, Quantum Functionality, Secure Delegated Quantum Computation, Quantum Offline Communication, Classical Offline Communication, Entanglement, Quantum Gadgets, Garden Hose Model, Prepare and Send Verifiable Quantum Fully Homomorphic Encryption, Classical Fully Homomorphic Encryption for Quantum Circuits.

## Assumptions

• This protocol is secure against malicious adversary setting
• One cannot decrypt the ciphertext without performing the Evaluation step
• A one-time quantum channel from Client to Server
• A one-time quantum channel from Server to Client
• The circuit has a polynomial number of T-Gates.

## Outline

Homomorphic Encryption (HE) schemes can be divided into four stages: Key Generation generates keys for encryption, decryption, and evaluation of the circuit, Encryption encodes the input into a ciphertext using encryption key, Homomorphic Evaluation performs operations (implements the circuit) on the encrypted input using evaluation key and Decryption transforms result of the ciphertext to actual outcome of the circuit using decryption key. This protocol requires Client to prepare and send the quantum states to Server, hence the name, Prepare and Send QFHE. A QFHE scheme is fundamentally different from classical FHE in the aspect that an evaluation key is allowed to be a quantum state in the former case. Also, in the last step decryption for FHE is carried out subsystem by subsystem. This cannot be correct for QFHE as quantum states can be entangled, hence decryption should be carried out on the system as a whole. The QFHE version of encryption is based on quantum one-time pad i.e. randomly applying a Pauli Gate (X, Y, Z, I) in order to hide the input. A Fully Homomorphic Encryption can implement Universal Gates (a set of gates which can implement any quantum circuit). Most of the gates in this set work well with QOTP while for T gates one needs an additional gadget, in order to implement any arbitrary circuit and make the scheme Fully Homomorphic. This adds an additional step called ”Gadget Construction” during Key Generation Stage in this protocol

• Key Generation (QFHE.KeyGen())

This step generates homomorphic key sets consisting of the classical public key for encryption, a classical private key for decryption and a quantum evaluation key for operation on the encrypted input state. If the circuit involves L T gates, Client needs L+1 such key sets for L gadgets and one input state. The Client uses the classical HE Key Generation (HE.KeyGen) to get classical key sets. She stores all the public keys and secret keys in two separate sets (tuples). Quantum evaluation keys consist of the classical evaluation keys and L gadgets. Once constructed, the gadget is also encrypted using all public keys except the first one by the Client. As construction of gadgets takes secret keys (first L) as inputs, the public key used for its encryption should not belong to the same homomorphic key set used to construct the gadget. A classical description of the gadget, useful for evaluation is also encrypted and included in the gadget. Construction and encryption of gadgets is described in the last step.

Finally, Client stores all the gadgets with the classical evaluation key of the corresponding secret key (generated from HE.KeyGen) used to construct the gadget, as the set of quantum evaluation keys. Note that, the gadgets are quantum states and classical evaluation keys are random numbers, the resulting quantum evaluation key is what we call a classical-quantum (CQ) state.

• Encryption (QFHE.Enc()) This step is used to encrypt the quantum input into a quantum cipher-text (secret text) using the first public key which has not been used for gadget construction. Every input qubit state is quantum one time padded by the Client, using two classical random bits, one of which decided the operation of Pauli-X and the other operation of Pauli-Z gate on the qubit state. She also encrypts the classical random bits (called pad key) with the same public key using classical HE (HE.Enc) and hence stores it with the corresponding encrypted qubit state as a classical-quantum state. She then sends this CQ state, encrypted pad key, public key tuple, and evaluation key tuple to Server.
• Circuit Evaluation (QFHE.Eval()) This step operates the circuit on the encrypted input state and updates the encrypted classical information using the evaluation key. As stated earlier, any circuit can be implemented using a set of Universal Gates. This set consists of Clifford Gates and T gates.

The Clifford group gates may affect a single qubit or multiple qubits but they follow a simple set of rules for updation of the encrypted classical information (pad key), given in the pseudocode. The server operates the circuit and with each gate in the circuit, it updates the encrypted classical description.
On the other hand, T gates affect only single qubits but one needs to make use of the gadgets constructed during key generation. The issue with T gates is that it adds an additional Phase gate (P) depending on the classical random bit used for QOTP in the previous step. As P gates do not commute like Pauli-X and Pauli-Z, so they need to be corrected before applying the next gate by the Server. This would reveal the pad key used for QOTP to the Server. Hence, to avoid this, the Client constructed gadgets, which apply an Inverse Phase operator or Identity on a qubit after every T-Gate, depending on the encrypted bit without leaking any information about the pad key. Thus, after applying a T gate on a qubit, P error is removed using a gadget as follows. Out of 2m EPR pairs, some qubits are measured pairwise including the input qubit with/without error and excluding one qubit entangled with one of the measured qubits. Input qubit is thus, transferred to this last unmeasured qubit, according to one-bit teleportation. Following are the steps to get the correct output qubit.

• Generate Measurement (QFHE.GenMeasurement()) The encrypted one pad key bit which determines phase gate error and the classical information of the gadget is used to determine a measurement order. Private key tells which qubits are entangled, thus, using the location of inverse phase gates, the qubits needed to be measured are decided. If one-pad key bit indicates a phase error then the measurement order of qubits includes an EPR pair with a phase gate else not.
• Gadget Correction (QFHE.Measurement()) Server performs the required measurements. The last unmeasured qubit is corrected input qubit. The qubit is one time padded with pad key determined by Client’s measurement outcomes, encrypted with the public key used for the gadget and Server’s measurement outcomes. Hence, it is still hidden from the Server.
• Recryption (QFHE.Rec()) Server recrypts pad key of the qubit with the same public key that encrypts the corrected output state i.e. the one used for the corresponding gadget. Then, he updates the encrypted pad key according to the T Gate (similar to what is done for the Clifford Gate), Client’s encrypted measurement outcomes and Server’s (his) measurement outcomes.

The server performs all the Clifford and T gates in the circuit following the respective procedure given above. Finally, he is left with the one time padded quantum output of the computation together with the required classical pad key encrypted with the public key of the gadget used for the last T gate, the last public key in the set. The server sends both the quantum state and classical encryptions to the Client.

• Decryption (QFHE.Dec()) The Client uses the last secret key in the set, which was not used to create any gadget (Gadgets used 0-(L-1) secret keys only) and decrypts sent encryptions to obtain the pad key. The pad key thus obtained determines the Pauli operations on the sent quantum state to obtain the final and correct outcome of the computation. The client performs the required operations on individual qubits of the quantum state and gets the output of his computation.

## Requirements

• Network Stage: Quantum Memory
• Required Network Parameters:
• ${\displaystyle \epsilon _{j}}$, which measures the error due to noisy operations.
• Number of communication rounds
• Circuit depth
• Number of physical qubits used
• Client should be able to generate and store entanglement in order to make quantum gadgets, perform Bell measurement, perform quantum one time pad, process and store classical quantum states.
• Quantum offline channel
• Classical offline channel
• A classical HE scheme is required
• Server should be able to store entangled states, perform all Clifford and T gates.

## Properties

• Indistinguishability under Chosen Plaintext Attacks by an adversary with quantum computational powers(q-IND-CPA). If FHE is q-IND-CPA secure then this protocol is q-IND-CPA secure. It means that an adversary cannot distinguish between ciphertext from a message and a ciphertext from an arbitrary quantum state such as ${\displaystyle |0\rangle \langle 0|}$
• Correctness. This protocol is perfectly correct such that,

${\displaystyle Pr[QFHE.Dec_{s_{k}}(QFHE.Eval_{evk}^{C}(HE.Enc_{p_{k}}(x)))\neq C(x)]\leq \eta (k)}$
, where ${\displaystyle \eta _{k}}$ is a negligible function.Note that, negligible function $\eta(n)$ is a function such that for every positive integer d, ${\displaystyle \eta (n)<1/n^{d}}$, for big enough n. This means that if the protocol is followed it results in the same output as when the circuit is operated on the input states directly with overwhelming probability.

• Compactness. If HE is compact then this protocol is compact. The complexity of applying QFHE.Dec on the results of QFHE.Eval is at most p(k), where p(k) is a polynomial dependent only on the security parameter k. This implies that decryption is independent of the size of the quantum circuit for evaluation.
• Circuit Privacy. This protocol is not circuit private as it does not guarantee that the client cannot gain information about the circuit evaluated i.e. the circuit is not private to one party and unknown to another. It can make the circuit private to the evaluator (Server) and hidden from the Client apart from the necessary leakage the output states gives if one uses circuit private HE for the protocol.

Full Homomorphism. This scheme is fully homomorphic for circuits with polynomial sized T gates

## Notation

• ${\displaystyle \mathrm {k} }$, security parameter
• ${\displaystyle \mathrm {L} }$, number of T gates in the evaluation circuit
• ${\displaystyle \mathrm {n} }$, dimension of input qubit
• ${\displaystyle \mathrm {pk_{i},sk_{i},evk_{i}} }$, ${\displaystyle \mathrm {i_{th}} }$ homomorphic key set generated from HE.KeyGen(). Public key for encryption, secret key for decryption, evaluation function key, respectively for given k, the security parameter.
• ${\displaystyle \Gamma _{pk_{i+1}}(\mathrm {sk_{i}} )}$, Gadget using ${\displaystyle \mathrm {i_{t}h} }$ secret key (${\displaystyle sk_{i}}$) and encrypted by ${\displaystyle \mathrm {(i+1)_{th}} }$ public key (${\displaystyle \mathrm {pk_{i+1}} }$)
• ${\displaystyle \sigma }$, single qubit state
• ${\displaystyle \rho =|\psi \rangle \langle \psi |}$, here ${\displaystyle \rho }$ is the density matrix of quantum state ${\displaystyle |\psi \rangle }$
• ${\displaystyle \rho }$, n-qubit input state, where n is determined by the Client
• ${\displaystyle \rho }$(HE.Encpk(a)), a is encrypted with public key pk and is represented by density matrix ρ
• p, location of inverse phase gate
• x,z measurement outcome sets of Client for her Bell Pair measurements.
• ${\displaystyle x',z'}$ measurement outcome sets of Server for his Gadget measurement.
• ${\displaystyle {\tilde {x}}^{[i]}}$, resulting ciphertext one gets for an input ${\displaystyle i^{th}}$ element of array x or ${\displaystyle i^{th}}$ bit of key x after the Encrypting it with ${\displaystyle i^{th}}$ of public key string, pk.

## Protocol Description

### Stage 1 Client’s Preparation

Key Generation (QFHE.KeyGen(1k,1L))

• Input: No. of T gates (L), Security Parameter (k),
• Output: L+1 evaluation keys (encrypted Gadgets, classical HE evaluation key), L+1 public keys, L+1 secret keys
1. For i = 0 to L
1. Client executes ${\displaystyle (pk_{i},sk_{i},evk_{i})\leftarrow {\text{HE.KeyGen}}(1^{\kappa })}$ to obtain ${\displaystyle L+1}$ independent classical homomorphic key sets.
2. She sets the public key to be the tuple ${\displaystyle (pk_{i})_{i=0}^{L}}$.
3. She sets the secret key to be the tuple ${\displaystyle (sk_{i})_{i=0}^{L}}$.
4. For i = 0 to L-1
1. Client runs the procedure ${\displaystyle {\text{QFHE.GenGadget}}_{pk_{i+1}}(sk_{i})}$ to create the gadget ${\displaystyle \Gamma _{pk_{i+1}}(sk_{i})}$.
5. Client sets the evaluation key to be the set of all gadgets created in the previous step (including their encrypted classical information), plus the tuple ${\displaystyle (evk_{i})_{i=0}^{L}}$. The resulting evaluation key is the classical-quantum (CQ) state
${\displaystyle \bigotimes _{i=0}^{L-1}{\Big (}\Gamma _{pk_{i+1}}(sk_{i})\otimes |evk_{i}\rangle \langle evk_{i}|)}$

Encryption(QFHE.Enc())

• Input: Quantum Input state density matrix (${\displaystyle \rho }$) (say composed of n single qubit states, ${\displaystyle \sigma }$)
• Output: Encrypted pad keys:${\displaystyle \{{\tilde {a}}^{[0]}...{\tilde {a}}^{[n]}}$,${\displaystyle {\tilde {b}}^{[i]}...{\tilde {b}}^{[n]}\}}$; QOTP state: ${\displaystyle X^{a^{[1]}}Z^{b^{[1]}}\otimes .....\otimes X^{a^{[n]}}Z^{b^{[n]}}\rho Z^{b^{[1]}}X^{a^{[1]}}\otimes .....\otimes X^{a^{[n]}}Z^{b^{[n]}}}$
1. For i=1 to n
1. Client chooses pad keys a,b ${\displaystyle \epsilon _{R}\{0,1\}}$
2. She quantum one time pads the single qubit by applying $X^aZ^b$ on the single qubit state. ${\displaystyle X^{a}Z^{b}\sigma Z^{b}X^{a}\leftarrow \sigma }$
3. She encrypts the pad keys using one bit for each of a and b from the public key string ${\displaystyle pk_{0}}$ using HE.Enc. (${\displaystyle {\tilde {a}}^{[i]},{\tilde {b}}^{[i]}}$)=(HE.Enc${\displaystyle _{pk_{0}^{[i]}}(a^{[i]}}$),HE.Enc${\displaystyle _{pk_{0}^{[i]}}(b^{[i]}))\leftarrow }$ (a,b)
4. She apprehends encrypted pad keys to the one time padded quantum state to obtain CQ state,

${\displaystyle \sum _{a,b\epsilon \{0,1\}}{\frac {1}{4}}\rho (HE.Enc_{pk_{0}^{[i]}}(a^{[i]}),HE.Enc_{pk_{0}^{[i]}}(b^{[i]}))\otimes X^{a}Z^{b}\sigma Z^{b}X^{a}}$

1. Client sends encryptions (${\displaystyle {\tilde {a}}^{[i]},{\tilde {b}}^{[i]}}$) and the quantum one time padded (QOTP) state${\displaystyle X^{a^{[1]}}Z^{b^{[1]}}\otimes .....\otimes X^{a^{[n]}}Z^{b^{[n]}}\rho Z^{b^{[1]}}X^{a^{[1]}}\otimes .....\otimes X^{a^{[n]}}Z^{b^{[n]}}\forall i}$, to the Server with the evaluation keys and public keys.

Gadget Construction (${\displaystyle {\text{QFHE.GenGadget}}_{pk_{i+1}}(sk_{i})}$)

1. Generate ${\displaystyle 4m}$ EPR pairs (${\displaystyle |\phi \rangle ={\frac {1}{\sqrt {2}}}(00+11))}$, ${\displaystyle \{(a_{1},b_{1}),...,(a_{4m},b_{4m})\}}$
2. Choose ${\displaystyle 2m}$ pairs ${\displaystyle \epsilon \{a_{1},a_{2},....,a_{4m}\}}$ using sk
1. If ${\displaystyle (sk=0)}$ then ${\displaystyle \{(a_{1},a_{2}),(a_{2},a_{3}),...,(a_{4m-1},a_{4m})\}}$
2. If ${\displaystyle (sk=1)}$ then ${\displaystyle \{(a_{1},a_{3}),(a_{2},a_{4}),...,(a_{4m-2},a_{4m})\}}$
3. For j=1 to 2m,
1. Choose p[j] ${\displaystyle \epsilon _{R}\{0,1\}}$
2. Perform Bell Measurement on ${\displaystyle j^{th}}$ pair with an extra ${\displaystyle (P^{\dagger })^{p}}$ operation, get outcomes (x[j],z[j])
3. Thus, new EPR pairs are
1. If ${\displaystyle (sk=0)}$ then ${\displaystyle \{(b_{1},b_{2}),(b_{2},b_{3}),...,(b_{4m-1},b_{4m})\}}$
2. If ${\displaystyle (sk=1)}$ then ${\displaystyle \{(b_{1},b_{3}),(b_{2},b_{4}),...,(b_{4m-2},b_{4m})\}}$
4. Denote the ${\displaystyle 2m}$ entangled pairs be denoted by ${\displaystyle \{(s_{1},t_{1}),(s_{2},t_{2}),...,(s_{2m},t_{2m})\}}$, such that
5. The classical information of gadget be g(sk)${\displaystyle =(\{(s_{1},t_{1}),(s_{2},t_{2}),...,(s_{2m},t_{2m}),p,sk\}}$.
6. The quantum state of gadget can be written as ${\displaystyle \gamma _{x,z}(g(sk))=\pi _{j=1}^{m}X^{x[i]}Z^{z[i]}(P^{\dagger }){p[i]}|\phi \rangle \langle \phi |_{s_{j}t_{j}}(P^{\dagger }){p[i]}Z^{z[i]}X^{x[i]}}$
4. Encrypt (x[j],z[j]), p[j] for all j and sk using ${\displaystyle pk_{i+1}}$. Resulting Gadget is the classical-quantum (CQ) state,

${\displaystyle \Gamma _{pk_{i+1}}(sk_{i})=\rho (HE.Enc_{pk_{i+1}}(g(sk))\otimes {\frac {1}{2^{2m}}}\sum _{x,z\epsilon \{0,1\}^{m}}\rho (HE.Enc_{pk_{i+1}}(x,z)\otimes \gamma _{x,z}(g(sk))}$

### Stage 2 Server’s Computation

Circuit's Evaluation (QFHE.Eval())

• Input: public key tuple ${\displaystyle (pk_{i})_{i=0}^{L}}$, Evaluation key tuple, Encrypted Pad key (${\displaystyle \{{\tilde {a}}^{[0]}...{\tilde {a}}^{[n]}}$, ${\displaystyle {\tilde {b}}^{[i]}...{\tilde {b}}^{[n]}\}}$), QOTP Input State (${\displaystyle X^{a^{[1]}}Z^{b^{[1]}}\otimes .....\otimes X^{a^{[n]}}Z^{b^{[n]}}\rho Z^{b^{[1]}}X^{a^{[1]}}\otimes .....\otimes X^{a^{[n]}}Z^{b^{[n]}}}$)
• Output: QOTP Circuit Output State (${\displaystyle X^{a'^{[1]}}Z^{b'^{[1]}}\otimes .....\otimes X^{a'^{[k]}}Z^{b'^{[k]}}\rho 'Z^{b'^{[1]}}X^{a'^{[1]}}\otimes .....\otimes X^{a'^{[k]}}Z^{b'^{[k]}}}$), Corresponding Encrypted Pad key (${\displaystyle {\tilde {a'}},{\tilde {b'}}}$)=(HE.Eval${\displaystyle _{evk_{L}}^{\text{C}}({\tilde {a}}}$),HE.Eval${\displaystyle _{evk_{L}}^{\text{C}}({\tilde {b}}}$))

Let the Circuit be denoted by C and the gates be ${\displaystyle c_{i}}$

1. For all i, ${\displaystyle c_{i}}$ gate is applied on qubit m and the ${\displaystyle m_{th}}$ bits of pad key ${\displaystyle ({\tilde {a}}^{[m]},{\tilde {b}}^{[m]})}$ are updated to ${\displaystyle ({\tilde {a}}'^{[m]},{\tilde {b}}'^{[m]})}$ as follows.
1. If ${\displaystyle c_{i}=\{P,H,CNOT\}}$, a Clifford gate then ${\displaystyle c_{i}X^{a^{[m]}}Z^{b^{[m]}}\psi =X^{a'^{[m]}}Z^{b'^{[m]}}c_{i}\psi }$)
1. if ${\displaystyle c_{i}=}$H then: ${\displaystyle ({\tilde {a}}^{[m]},{\tilde {b}}^{[m]})\rightarrow ({\tilde {b}}^{[m]},{\tilde {a}}^{[m]})}$ (Hadamard tranforms X gate into Z and Z into X)
2. if ${\displaystyle c_{i}=}$P then: ${\displaystyle ({\tilde {a}}^{[m]},{\tilde {b}}^{[m]})\rightarrow ({\tilde {a}}^{[m]},{\tilde {a}}^{[m]}\oplus {\tilde {b}}^{[m]})}$
3. if ${\displaystyle c_{i}=}$CNOT with m as target bit and n as control bit then: ${\displaystyle ({\tilde {a}}^{[m]},{\tilde {b}}^{[m]};{\tilde {a}}^{[n]},{\tilde {b}}^{[n]})\rightarrow ({\tilde {a}}^{[m]},{\tilde {b}}^{[m]}\oplus {\tilde {b}}^{[n]};{\tilde {a}}^{[m]}\oplus {\tilde {a}}^{[n]},{\tilde {b}}^{[n]})}$
2. If ${\displaystyle c_{i}=T_{j}}$ gate then: ${\displaystyle (T_{j}X^{a^{[m]}}Z^{b^{[m]}}\psi =P^{a^{[m]}}X^{a^{[m]}}Z^{b^{[m]}}T_{j}\psi )}$
1. Generate Measurement M${\displaystyle \leftarrow }$ QFHE.GenMeasurement(${\displaystyle {\tilde {a}}^{[m]},\Gamma _{pk_{j+1}}(sk_{j}),evk_{j})}$
2. Gadget Correction${\displaystyle (X^{a'^{[m]}}Z^{b'^{[m]}}T_{j})\psi \leftarrow }$ QFHE.Measurement(M, ${\displaystyle P^{a^{[m]}}X^{a^{[m]}}Z^{b^{[m]}}T_{j}\psi )}$
3. Server gets measurement outcome x',z'
4. Recryption Server recrypts one-pad key using pk${\displaystyle _{k+1}}$ (${\displaystyle {\tilde {a''}}^{[m]},{\tilde {b''}}^{[m]})\leftarrow }$ QFHE.Rec${\displaystyle _{pk_{k+1}}({\tilde {a}}^{[m]},{\tilde {b}}^{[m]})}$
5. Server updates the recrypted key using x,z and x',z'. (${\displaystyle {\tilde {a'}}^{[m]},{\tilde {b'}}^{[m]})\leftarrow ({\tilde {a''}}^{[m]},{\tilde {b''}}^{[m]}}$)
3. Server sends the updated encryption and QOTP output state to Client.

### Stage 3 Client’s Correction

Decryption (QFHE.Dec())

• Input: QOTP Circuit Output State (${\displaystyle X^{a'^{[1]}}Z^{b'^{[1]}}\otimes .....\otimes X^{a'^{[k]}}Z^{b'^{[k]}}\rho 'Z^{b'^{[1]}}X^{a'^{[1]}}\otimes .....\otimes X^{a'^{[k]}}Z^{b'^{[k]}}}$), Corresponding Encrypted Pad key (${\displaystyle {\tilde {a'}},{\tilde {b'}}}$)
• Output: Final outcome of the computation C${\displaystyle \rho }$C${\displaystyle ^{\dagger }=\rho '}$
1. Client uses ${\displaystyle sk_{L}}$ to restore the pad key from sent encryption: (${\displaystyle {a'}^{[i]},{b'}^{[i]}}$)=(HE.Dec${\displaystyle _{sk_{L}^{[i]}}(a'^{[i]}}$),HE.Dec${\displaystyle _{pk_{L}^{[i]}}(b'^{[i]}))}$
2. Client uses pad key and operates ${\displaystyle X^{a'^{[i]}}Z^{b'^{[i]}}}$ on single qubits i separately just like encryption.
1. Let single qubit representation of the output state be ${\displaystyle X^{a'^{[i]}}Z^{b'^{[i]}}\sigma 'Z^{b'^{[i]}}X^{a'^{[i]}}}$, then operation of Pauli X,Z gates as above yields ${\displaystyle \sigma '}$
3. Client repeats this for all single qubits and hence gets the quantum state ${\displaystyle \rho '}$, final outcome of the computation.