qiskit-community / qiskit-hackathon-korea-22

35 stars 18 forks source link

Quantum cryptanalysis using Quantum Neural Network(QNN) and Quantum Machine Leaning(QML) #22

Open starj1023 opened 2 years ago

starj1023 commented 2 years ago

Abstract

In recent years, the application of machine learning and deep learning to classical cryptanalysis is an active research field. In this project, we perform quantum cryptanalysis that combines quantum with machine learning and artificial neural network. To the best of our knowledge, our work is the first attempt in the world to apply QNN(Quantum Neural Network) and QML(Quantum Machine Learning) to cryptanalysis. Finally, for evaluation between classical and quantum, we implement and compare three types of cryptanalysis: classic, quantum and hybrid. During this hackathon, we found interesting results for quantum cryptanalysis using QML and QNN.

Members

Hyunji Kim, Kyungbae Jang, Yeajun Kang, Wonwoong Kim, Sejin Lim, Seyoung Yoon, Yujin Oh

Related Works

Cryptanalysis is the analysis of the security of cryptographic algorithms in cryptography. In general, cryptanalysis analyzes the resistance against various possible attacks on cryptographic algorithms. One of the principles of secure cryptographic design is that plaintext-ciphertext pairs should be indistinguishable.

In cryptography, a distinguishing attack is any form of cryptanalysis on data encrypted by a cipher that allows an attacker to distinguish the encrypted data from random data. (See https://en.wikipedia.org/wiki/Distinguishing_attack) In this project, we perform quantum cryptanalysis, classical cryptanalysis, and hybrid(quantum & classic) cryptanalysis.

The security evaluation of cryptographic algorithms is carried out by analyzing attacks that can be performed on classical computers. However, since the best cryptanalysis tool called quantum computer has appeared, the security of existing cryptographic algorithms needs to be reevaluated. The most well-known quantum attacks on cryptography are the Shor's algorithm for public key cryptography and the Grover algorithm for symmetric key cryptography. For this reason, studies on the application of Grover's algorithm and Shor's algorithm to cryptography are being proposed.

Grover's algorithm in cryptanalysis

Shor's algorithm in cryptanalysis

On the other hand, machine learning and deep learning are recently applied to classical cryptanalysis, but there is no case where quantum is combined. In this project we do this.

Our works

We apply this hybrid neural network to the problem of classifying whether ciphertext-plaintext pairs are correct or random bit pairs. An ideal encryption algorithm should not be able to find any correlation between plaintext and ciphertext. Our hybrid neural network finds real plaintext-ciphertext pairs when random bit pairs and plaintext-ciphertext pairs generated by an encryption algorithm are input. Since it is a binary classification problem that determines whether it is real or fake, our hybrid neural network maintains the existing binary classification structure using 1 qubit(Figure 1).

Figure 1. Quantum circuit as layer(1-qubit)

We perform quantum cry5ptography analysis on the following encryption algorithms: Caesar, Vigenere, Simple-DES, and PRESENT-Toy. If the trained neural network correctly distinguishes the real plaintext-ciphertext pair, the security of the encryption algorithm is evaluated as weak. Conversely, if it is difficult to distinguish, the security is evaluated as high.

First, four encryption algorithms are implemented in Python to generate plaintext-ciphertext pairs for training. The generated plaintext-ciphertext pairs are labeled as 1 (real) and random bit pairs are generated for fake data, which are labeled as 0 (fake). For cryptanalysis of the reduced encryption algorithm, a total of 150 data of 75 8-bit plaintext-ciphertext pairs and 75 fake bit pairs are used(Figure 2). The layer is modified for 16-bit input (plaintext-ciphertext) and one more layer is added for accuracy. This is shown in Figure 3.

Figure 2. Part of the training data(1 is a real plaintext-ciphertext pair, 0 is a fake bit pair, csv file)

image

Figure 3. Network structure

We also have control over qubits, either through a linear option to entangle a qubit with one next qubit, or a pull option to entangle a qubit with all qubits that follow it. The smaller the circuit depth, the shorter the execution time and the higher the accuracy, so we use the linear option. Through this, a quantum circuit as a kernel of QSVM is constructed and used for training.

By repeatedly executing the designed quantum circuit, the parameters of the circuit are updated. Measurement is performed on each qubit to determine the state of the qubit with a single value. the qubits of circuit are measured multiple times to classify them with high probability. Finally, the trained circuit is used as a classifier.

Evaluation

Figure 4. Classical Neural Network loss graph

Figure 5. Hybrid Neural Network loss graph

Table 1 is the performance of the same trained hybrid and classical neural networks. The hybrid neural network provides good accuracy with few epochs. (If it is the same epoch, the accuracy of the hybrid is higher) Table 2 is the performance for more data(250). Also, with fewer epochs, the hybrid neural network provides higher accuracy than the classical neural network.

One thing to point out is the accuracy of PRESENT. PRESENT has lower accuracy(50%) in both classic and hybrid. This means that the plaintext-ciphertext pair generated by PRESENT is difficult to distinguish from a fake bit pair, which means that it is cryptographically secure. The classification model generated by this hybrid neural network is effective for cryptographic analysis. *For QuantumNN,8 qubits are used. Because, in the case of 8-bit plaintext and ciphertext, 16 qubits are required. However, since the kernel is turned off during circuit execution, a 4-bit dataset is used.

Table 1. Performance(150 data)

Table 2. Performance(250 data)

image

Conclusion

In this project, we performed quantum cryptography analysis that combines quantum, machine learning, and neural networks. We also analyzed three types of cryptanalysis(classic, hybrid and quantum) and compared their performance. Our work will be the basis for applying quantum neural networks and quantum machine learning to cryptanalysis. From data generation to model evaluation, the codes used are all available online, and quantum cryptography researchers can leverage it.

Future works

In QNN, we plan to use fewer qubits by applying dimensionality reduction techniques such as qubit reuploading or PCA. For hybrid networks, hyperparameter tuning is required to achieve higher performance in the future.

GitHub repo(Source code)

https://github.com/starj1023/2022-Hackathon

KangSquad commented 2 years ago

참여합니다 ~~

Sebbange commented 2 years ago

참여합니다 :)

dnjsdnde commented 2 years ago

참여합니다!

yudini commented 2 years ago

참여합니다!

0sophy1 commented 2 years ago

제가 태그한 분들 모두 멤버 맞는지 확인해 주세요! 멤버 더안받으시면 member-wanted 떼드립니다

khj1594012 commented 2 years ago

참가하고싶습니다

sejinlim1107 commented 2 years ago

참가합니닷!!

starj1023 commented 2 years ago

@0sophy1 안녕하세요. 아래 멤버까지해서 총 7입니다! @khj1594012 @sejinlim1107

dnjsdnde commented 2 years ago

넵 확인하였습니다!감사합니다! -------- 원본 이메일 --------발신: Soyoung Shin @.> 날짜: 22/2/7 오후 11:27 (GMT+09:00) 받은 사람: qiskit-community/qiskit-hackathon-korea-22 @.> 참조: dnjsdnde @.>, Assign @.> 제목: Re: [qiskit-community/qiskit-hackathon-korea-22] Quantum cryptanalysis using Quantum Neural Network(QNN) (Issue #22)

백경현 박사님이 멘토하시기로 했습니다 :)

—Reply to this email directly, view it on GitHub, or unsubscribe.Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you were assigned.Message ID: @.***>

0sophy1 commented 2 years ago

이 프로젝트 발표자님! 저에게 이메일 주소 보내주세요! 슬랙에 Sophy! 최종 발표준비에 필요합니다

khj1594012 commented 2 years ago

안녕하세요! 발표자 이메일 주소는 @.*** 입니다.

감사합니다!

2022년 2월 10일 (목) 오전 9:53, Soyoung Shin @.***>님이 작성:

이 프로젝트 발표자님! 저에게 이메일 주소 보내주세요! 슬랙에 Sophy! 최종 발표준비에 필요합니다

— Reply to this email directly, view it on GitHub https://github.com/qiskit-community/qiskit-hackathon-korea-22/issues/22#issuecomment-1034368555, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANVZYE5VFTJ43MHGMCZQ263U2MD7DANCNFSM5NW4EURA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were assigned.Message ID: @.*** com>

0sophy1 commented 2 years ago

안녕하세요! 발표자 이메일 주소는 @.*** 입니다. 가려져서 안보여요!! ㅎㅎ 슬랙으로 부탁드립니다

starj1023 commented 2 years ago

안녕하세요 저희 팀장님이 #22 Assignees 멤버에서 잘못 눌러 나가신 것 같습니다. 죄송합니다만 혹시 다시 추가해주실 수 있을까요..? 팀장님은 @khj1594012 입니다!

khj1594012 commented 2 years ago

감사합니다!

Mouhamedaminegarrach commented 1 year ago

Hello @starj1023 , I'm a quantum crypto enthusiast and i found the work of the project is really good !!! but i can't run it on my laptop, can you share with me the CVS file of the dataset of each algorithm? This is my email: mouhamed.garrch@gmail.com Thanks in advance, really appreciate your help :)