TWI757694B - Method of generating true random numbers based on quantum computing - Google Patents

Method of generating true random numbers based on quantum computing Download PDF

Info

Publication number
TWI757694B
TWI757694B TW109105753A TW109105753A TWI757694B TW I757694 B TWI757694 B TW I757694B TW 109105753 A TW109105753 A TW 109105753A TW 109105753 A TW109105753 A TW 109105753A TW I757694 B TWI757694 B TW I757694B
Authority
TW
Taiwan
Prior art keywords
random number
quantum
qubit
classical
random
Prior art date
Application number
TW109105753A
Other languages
Chinese (zh)
Other versions
TW202133056A (en
Inventor
許琇娟
Original Assignee
國立政治大學
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 國立政治大學 filed Critical 國立政治大學
Priority to TW109105753A priority Critical patent/TWI757694B/en
Publication of TW202133056A publication Critical patent/TW202133056A/en
Application granted granted Critical
Publication of TWI757694B publication Critical patent/TWI757694B/en

Links

Images

Abstract

A method of generating true random numbers based on quantum computing is provided. A computer apparatus receives a plurality of classical binary bits generated by measurement of a plurality of qubits from a quantum computer via network and stores the classical binary bits in a storage module, loads and removes the classical binary bits with a length corresponding to a random range from the storage module as a random sequence, executes a process of transforming format on the random sequence for obtaining a random number and outputs the random number. The present disclosed example can effectively provide the true random numbers being unpredictable and without repeatability, and improve the credibility of application based on the random numbers.

Description

基於量子運算的真亂數產生方法 Generating method of true random numbers based on quantum operation

本發明係與量子運算有關,特別有關於基於量子運算的真亂數產生方法。 The present invention is related to quantum operations, and particularly relates to a method for generating true random numbers based on quantum operations.

現有的亂數產生方法多是採用模擬亂數(pseudo random)技術。上述模擬亂數技術是先設定亂數種子(seed),並基於亂數種子來執行亂數演算法,以產生亂數值。 Most of the existing random number generation methods use pseudo random technology. The above simulation random number technology is to set a random number seed (seed) first, and execute a random number algorithm based on the random number seed to generate a random number.

現有的亂數產生方法由於使用固定的亂數種子與亂數演算法來產生亂數,其所產生的多個亂數值之間實際上存在規律,而可被預測與重複。 Since the existing random number generation method uses a fixed random number seed and a random number algorithm to generate random numbers, there is actually a law among the generated random numbers, which can be predicted and repeated.

更進一步地,當亂數值可以被預測或重複時,基於亂數值的應用(如加解密或博奕遊戲)將存在被破解的風險。 Furthermore, when the random value can be predicted or repeated, the application based on the random value (such as encryption and decryption or casino games) will be at risk of being cracked.

是以,現有的模擬亂數產生方法存在上述問題,而亟待更有效的方案被提出。 Therefore, the existing methods for generating analog random numbers have the above problems, and more effective solutions are urgently needed.

本發明之主要目的,係在於提供一種基於量子運算的真亂數產生方法,可產生真亂數。 The main purpose of the present invention is to provide a method for generating true random numbers based on quantum operations, which can generate true random numbers.

為達上述目的,本發明係提供一種基於量子運算的真亂數產生方法,包括以下步驟:a)於電腦設備經由網路自量子電腦接收經由對多個量子位元執行量測所獲得的多個古典位元;b)將多個古典位元儲存於電腦設備的儲存模組;c)基於亂數請求的亂數範圍自儲存模組讀取對應長度的多個古典位元作為亂數數列,並自儲存模組刪除所讀取的多個古典位元;d)對亂數數列執行格式轉換處理以獲得亂數值;及,e)輸出亂數值。 In order to achieve the above-mentioned object, the present invention provides a method for generating true random numbers based on quantum operations, comprising the following steps: a) receiving multiple data obtained by performing measurements on multiple qubits from a quantum computer via a network in a computer device; b) store a plurality of classical bits in the storage module of the computer device; c) read a plurality of classical bits of corresponding length from the storage module based on the random number range requested by the random number as a random number sequence , and delete a plurality of classical bits read from the storage module; d) perform format conversion processing on the random number sequence to obtain random values; and, e) output random values.

本發明可有效產生無法預測且不具重複性的真亂數,而可提升亂數應用的可信度。 The present invention can effectively generate unpredictable and non-repetitive real random numbers, and can improve the reliability of random number applications.

1:電腦設備 1: Computer equipment

100:處理模組 100: Processing modules

101:網路模組 101: Network Modules

102:人機介面 102: Human Machine Interface

103:儲存模組 103: Storage Module

1030:亂數產生程式 1030: Random Number Generation Program

1031:古典位元緩衝區 1031: Classical bit buffer

104:功能模組 104: Function module

2:量子電腦 2: Quantum Computer

20:雲端應用平台 20: Cloud Application Platform

200:量子電腦程式 200: Quantum Computer Program

3:網路 3: Internet

4:外部電腦設備 4: External computer equipment

50-52、70:Hadamard邏輯閘 50-52, 70: Hadamard logic gate

60-62、83:量測邏輯閘 60-62, 83: measurement logic gate

7、8:量子邏輯電路 7, 8: Quantum logic circuits

71、72、81:單控制反邏輯閘 71, 72, 81: single control inverse logic gate

80、82:雙控制反邏輯閘 80, 82: double control inverse logic gate

S10-S14:第一亂數產生步驟 S10-S14: The first random number generation step

S20-S22:忽略誤差量測步驟 S20-S22: Ignore error measurement steps

S30-S32、S40-S43:考量誤差量測步驟 S30-S32, S40-S43: Considering the error measurement steps

S50-S59:第二亂數產生步驟 S50-S59: the second random number generating step

S60-S64:第三亂數產生步驟 S60-S64: The third random number generation step

S70-S72:第四亂數產生步驟 S70-S72: Fourth random number generation step

S80-S81:亂數應用步驟 S80-S81: Random number application steps

圖1為本發明一實施態樣的真亂數產生系統的架構圖。 FIG. 1 is a structural diagram of a true random number generation system according to an embodiment of the present invention.

圖2為本發明第一實施例的真亂數產生方法的流程圖。 FIG. 2 is a flowchart of a method for generating a true random number according to the first embodiment of the present invention.

圖3為本發明第二實施例的真亂數產生方法的部分流程圖。 FIG. 3 is a partial flowchart of a method for generating a true random number according to a second embodiment of the present invention.

圖4為本發明第三實施例的真亂數產生方法的部分流程圖。 FIG. 4 is a partial flowchart of a method for generating a true random number according to a third embodiment of the present invention.

圖5為本發明第四實施例的真亂數產生方法的流程圖。 FIG. 5 is a flowchart of a method for generating a true random number according to a fourth embodiment of the present invention.

圖6為本發明第五實施例的真亂數產生方法的部分流程圖。 FIG. 6 is a partial flowchart of a method for generating a true random number according to a fifth embodiment of the present invention.

圖7為本發明第六實施例的真亂數產生方法的部分流程圖。 FIG. 7 is a partial flowchart of a method for generating a true random number according to a sixth embodiment of the present invention.

圖8為本發明第七實施例的真亂數產生方法的部分流程圖。 FIG. 8 is a partial flowchart of a method for generating a true random number according to a seventh embodiment of the present invention.

圖9為本發明一實施態樣的量子邏輯電路的架構圖。 FIG. 9 is a structural diagram of a quantum logic circuit according to an embodiment of the present invention.

圖10為本發明一實施態樣的量子邏輯電路的架構圖。 FIG. 10 is a structural diagram of a quantum logic circuit according to an embodiment of the present invention.

茲就本發明之數個較佳實施方式,配合圖式,詳細說明如後。 Hereinafter, several preferred embodiments of the present invention will be described in detail in conjunction with the drawings.

目前大部分的電腦設備都是採用古典位元(classical binary bits)作為運算或儲存的最小資料單位。古典位元僅能被設定為0與1的其中之一。 At present, most computer equipments use classical binary bits as the smallest data unit for operation or storage. Classical bits can only be set to one of 0 and 1.

相較於古典位元,量子位元(Qubit)是以向量來加以描述,在運算過程中量子態可以是0也可以是1,而必須經過量測才能獲得確定的量子態(如0或1)。並且,當量子位元處於疊加態(superposition)時,為0的機率與為1的機率皆為50%。 Compared with classical bits, quantum bits (Qubits) are described by vectors, and the quantum state can be 0 or 1 during the operation process, and a definite quantum state (such as 0 or 1) can only be obtained after measurement. ). Also, when the qubit is in a superposition, the probability of being 0 and the probability of being 1 are both 50%.

具體而言,古典位元與量子位元主要具有以下區別: Specifically, classical bits and qubits mainly have the following differences:

一、量子位元的量子態是歸一化(Normalized)的向量來加以描述,可用抽象的狄拉克標記(Dirac Notation)來加以表示,即|0〉與|1〉;古典位元則是以數值0或1來加以描述。 1. The quantum state of a qubit is described by a normalized vector, which can be represented by an abstract Dirac Notation, namely |0> and |1>; classical bits are represented by A value of 0 or 1 is used to describe it.

二、因為量子態是向量,單一量子位元可以處於|0〉與|1〉的線性疊加;古典位元則無法以疊加態描述。 Second, because the quantum state is a vector, a single qubit can be in a linear superposition of |0> and |1>; a classical bit cannot be described by a superposition state.

三、當多個量子位元彼此有交互作用時,則處於量子糾纏態,即其中一個量子位元狀態改變時,會瞬間影響另一個量子位元;多個古典位元之間則彼此獨立,沒有交互作用。 3. When multiple qubits interact with each other, they are in a state of quantum entanglement, that is, when the state of one qubit changes, it will instantly affect the other qubit; multiple classical bits are independent of each other, There is no interaction.

四、量子位元的量測結果與所選擇的量測基底有關,量測基底可以影響量測結果各個量測結果(量子態)的機率;古典位元則不需進行量測。更進一步地,目前已有相關技術提出:經由採用適當的量測基底,來使量子位元的不同量測結果(如0與1)具有相同的機率,即可隨機產生0與1。並且,前述使量子位元的不同量測結果具有相同的機率屬於量子運算領域的常見技術,於此不再贅述。 Fourth, the measurement results of qubits are related to the selected measurement substrate, and the measurement substrate can affect the probability of each measurement result (quantum state) of the measurement result; the classical bit does not need to be measured. Furthermore, it has been proposed in the related art that 0 and 1 can be randomly generated by using an appropriate measurement substrate so that different measurement results (eg, 0 and 1) of the qubit have the same probability. In addition, the above-mentioned making different measurement results of qubits have the same probability is a common technique in the field of quantum computing, and will not be repeated here.

首請參閱圖1,為本發明一實施態樣的真亂數產生系統的架構圖。 First, please refer to FIG. 1 , which is a structural diagram of a real random number generation system according to an embodiment of the present invention.

為解決現有的模擬亂數可被預測與重複的問題,本發明是提出一種真亂數產生方法,是運用於圖1所示的真亂數產生系統。本發明的真亂數產生方法可基於量子運算來產生隨機的古典位元,以產生真亂數。並且,由於量子位元的量測結果具有真實隨機性,即不可被預測與重複,其量測結果可以用來產生真亂數。 In order to solve the problem that the existing analog random numbers can be predicted and repeated, the present invention proposes a real random number generation method, which is applied to the true random number generation system shown in FIG. 1 . The true random number generation method of the present invention can generate random classical bits based on quantum operations to generate true random numbers. Moreover, since the measurement results of qubits are truly random, that is, unpredictable and repeatable, the measurement results can be used to generate real random numbers.

具體而言,本發明的真亂數產生系統主要包括電腦設備1與至少一台量子電腦2(圖1以多台量子電腦2為例)。 Specifically, the true random number generation system of the present invention mainly includes a computer device 1 and at least one quantum computer 2 (a plurality of quantum computers 2 are taken as an example in FIG. 1 ).

電腦設備1為通用電腦(如智慧型手機、筆記型電腦、平板電腦、個人電腦、智慧型穿戴設備等等電子電腦或傳統電腦),主要是由大量積體電路組成,並用以基於古典位元(0與1)執行運算與資料儲存。 Computer equipment 1 is a general-purpose computer (such as smart phones, notebook computers, tablet computers, personal computers, smart wearable devices, and other electronic computers or traditional computers), which are mainly composed of a large number of integrated circuits and are used based on classical bits. (0 and 1) perform operations and data storage.

各量子電腦2是基於量子位元執行運算與資料儲存。量子電腦2是屬於量子運算領域的常見電腦設備,其細節架構與運作原理於此不再贅述。 Each quantum computer 2 performs operations and data storage based on qubits. Quantum computer 2 is a common computer device in the field of quantum computing, and its detailed architecture and operating principles will not be repeated here.

於一實施態樣中,量子電腦2是作為雲端伺服器,來經由量子運算提供指定的雲端服務。具體而言,量子電腦2可包括雲端應用平台20,雲端應用平台20可用來執行用以實現量子演算法的量子電腦程式200,藉以提供前述雲端服務(如經由量子演算法產生隨機的古典位元)。 In one embodiment, the quantum computer 2 is used as a cloud server to provide specified cloud services through quantum computing. Specifically, the quantum computer 2 may include a cloud application platform 20, and the cloud application platform 20 may be used to execute a quantum computer program 200 for implementing quantum algorithms, thereby providing the aforementioned cloud services (eg, generating random classical bits through quantum algorithms) ).

電腦設備1主要包括網路模組101、人機介面102、儲存模組103及電性連接上述模組的處理模組100。 The computer equipment 1 mainly includes a network module 101, a human-machine interface 102, a storage module 103, and a processing module 100 electrically connected to the above-mentioned modules.

網路模組101(如行動網路模組或Wi-Fi網路模組等等)用以連接網路3(如網際網路),並可透過網路3連接遠端的量子電腦2以進行資料傳輸(如請求/接收隨機的古典位元)。 The network module 101 (such as a mobile network module or a Wi-Fi network module, etc.) is used to connect to the network 3 (such as the Internet), and can connect to the remote quantum computer 2 through the network 3 to Perform data transfers (eg request/receive random classical bits).

人機介面102可包含輸入裝置(如鍵盤、滑鼠及/或觸控板等等)與輸出裝置(如喇叭、指示燈及/或顯示器等等),並用來與用戶進行互動(如呈現後述的亂數值)。 The human-machine interface 102 may include input devices (eg, keyboard, mouse, and/or touchpad, etc.) and output devices (eg, speakers, indicator lights, and/or displays, etc.), and is used to interact with the user (eg, presentations described later). random value).

儲存模組103可包括暫態電腦可讀取媒體(如RAM)與非暫態電腦可讀取媒體(如ROM、快閃記憶體、固態硬碟、磁碟硬碟等等),並用以儲存資料。 The storage module 103 may include a transient computer-readable medium (such as RAM) and a non-transitory computer-readable medium (such as ROM, flash memory, solid state drive, magnetic hard disk, etc.), and is used for storage material.

於一實施態樣中,非暫態電腦可讀取媒體可包括亂數產生程式1030。電腦程式1030記錄有電腦可執行之程式碼,當處理模組100執行前述程式碼後,可執行後述的本發明各實施例的真亂數產生方法。 In one embodiment, the non-transitory computer-readable medium may include the random number generator 1030 . The computer program 1030 records a computer-executable program code. After the processing module 100 executes the aforementioned program code, the method for generating a random number according to various embodiments of the present invention described later can be executed.

於一實施態樣中,儲存模組103更包括一古典位元緩衝區(buffer)1031。古典位元緩衝區1031可為暫態電腦可讀取媒體或非暫態電腦可讀取媒體,不加以限定,並用以儲存自量子電腦2所收到的古典位元。 In one embodiment, the storage module 103 further includes a classical bit buffer 1031 . The classical bit buffer 1031 can be a transient computer-readable medium or a non-transitory computer-readable medium, which is not limited, and is used for storing classical bits received from the quantum computer 2 .

處理模組100(如CPU、MCU、GPU或其他處理器)用以控制電腦設備1的各模組運作。 The processing module 100 (eg, CPU, MCU, GPU or other processors) is used to control the operation of each module of the computer device 1 .

於一實施態樣中,電腦設備1更包括一或多個功能模組104(圖1以一個功能模組104為例)。功能模組104電性連接處理模組100,用以實現特定功能。 In one embodiment, the computer device 1 further includes one or more functional modules 104 (one functional module 104 is taken as an example in FIG. 1 ). The function module 104 is electrically connected to the processing module 100 for realizing a specific function.

舉例來說,當功能模組104為照相機時,可拍攝所在環境的影像並提供給處理模組100進行處理;當功能模組104為人員偵測器(如PIR感測器)時,可偵測人員是否進入所在環境;當功能模組104為博弈機台時,可依據處理模組100所提供的資料(如亂數值)進行運作;當功能模組104為安全模組(如加/解密模組或驗證模組)時,可對資料進行加/解密或驗證。 For example, when the functional module 104 is a camera, an image of the environment can be captured and provided to the processing module 100 for processing; when the functional module 104 is a person detector (such as a PIR sensor), it can detect Whether the tester enters the environment; when the function module 104 is a gaming machine, it can operate according to the data (such as random values) provided by the processing module 100; when the function module 104 is a security module (such as encryption/decryption) module or verification module), the data can be encrypted/decrypted or verified.

於一實施態樣中,真亂數產生系統更包括外部電腦設備4。外部電腦設備4(如博弈機台、具有加/解密功能的儲存裝置或加/解密裝置等等)為通用電腦並連接網路3。外部電腦設備4可經由網路3自電腦設備1取得資料(如控制指令 或亂數值),並依據所收到的資料進行運轉(如產生博弈結果、執行資料加/解密,等等)。 In one embodiment, the real random number generation system further includes an external computer device 4 . The external computer device 4 (such as a gaming machine, a storage device with encryption/decryption function, or an encryption/decryption device, etc.) is a general-purpose computer and is connected to the network 3 . The external computer device 4 can obtain data (such as control commands) from the computer device 1 via the network 3 or random values), and operate according to the received data (such as generating game results, performing data encryption/decryption, etc.).

請一併參閱圖2,為本發明第一實施例的真亂數產生方法的流程圖。本實施例的真亂數產生方法包括以下步驟。 Please also refer to FIG. 2 , which is a flowchart of a method for generating a true random number according to the first embodiment of the present invention. The method for generating a true random number in this embodiment includes the following steps.

步驟S10:電腦設備1的處理模組100控制網路模組101經由網路3自量子電腦2接收多個古典位元。具體而言,量子電腦2可對多個量子位元執行量測來獲得隨機產生的多個古典位元,並將這些古典位元傳送至電腦設備1。 Step S10 : the processing module 100 of the computer device 1 controls the network module 101 to receive a plurality of classical bits from the quantum computer 2 via the network 3 . Specifically, the quantum computer 2 can perform measurement on a plurality of qubits to obtain a plurality of randomly generated classical bits, and transmit these classical bits to the computer device 1 .

步驟S11:處理模組100將所收到的多個古典位元儲存於儲存模組103的古典位元緩衝區1031。 Step S11 : the processing module 100 stores the received classical bits in the classical bit buffer 1031 of the storage module 103 .

步驟S12:處理模組100基於亂數請求的亂數範圍(如1至10,或-100至-100等等)自儲存模組103的古典位元緩衝區1031讀取對應長度的多個古典位元作為亂數數列,並自古典位元緩衝區1031刪除所讀取的多個古典位元,即刪除已使用的古典位元。 Step S12: The processing module 100 reads a plurality of classical bits of the corresponding length from the classical bit buffer 1031 of the storage module 103 based on the random number range (eg, 1 to 10, or -100 to -100, etc.) of the random number request. The bits are used as a random number sequence, and a plurality of classical bits read from the classical bit buffer 1031 are deleted, that is, the used classical bits are deleted.

步驟S13:處理模組100對亂數數列執行格式轉換處理以獲得亂數值。 Step S13: The processing module 100 performs format conversion processing on the random number sequence to obtain random values.

於一實施例中,處理模組100依據亂數請求所要求的亂數格式(如1補數(1's complement)、2補數(2's complement)、十進位或十六進位等等)對亂數數列執行格式轉換,以產生格式相符的亂數值。 In one embodiment, the processing module 100 processes the random number according to the random number format (such as 1's complement, 2's complement, decimal or hexadecimal, etc.) required by the random number request. Sequences perform format conversion to produce garbled values that match the format.

於一實施例中,處理模組100是直接將亂數數列自二進位轉換進位 In one embodiment, the processing module 100 directly converts the random number sequence from binary to carry

步驟S14:處理模組100輸出亂數值。具體而言,處理模組100可經由人機介面102顯示亂數值、讀出亂數值,或者,經由網路模組101與網路3將亂數值傳送至外部電腦設備4,不加以限定。 Step S14: The processing module 100 outputs random values. Specifically, the processing module 100 can display the random value, read the random value through the man-machine interface 102, or transmit the random value to the external computer device 4 through the network module 101 and the network 3, which is not limited.

藉此,本發明可有效產生無法預測且不具重複性的真亂數,而可提升亂數應用的可信度。 In this way, the present invention can effectively generate unpredictable and non-repetitive real random numbers, and can improve the reliability of random number applications.

於一例子中,若亂數請求是要求0至127(亂數範圍)之間的五個亂數(亂數數量),則處理模組100是自古典位元緩衝區1031每次讀取8個古典位元(8位元可表示十進位的0至127的所有正整數)作為一個亂數數列以計算一個亂數值,並執行五次前述讀取與計算(共40位元)以獲得五個亂數值。 In an example, if the random number request requires five random numbers (number of random numbers) between 0 and 127 (random number range), the processing module 100 reads 8 random numbers from the classical bit buffer 1031 at a time. classical bits (8 bits can represent all positive integers from 0 to 127 in decimal) as a random number sequence to calculate a random value, and perform the aforementioned reading and calculation five times (40 bits in total) to obtain five random value.

於另一例子中,若亂數請求是要求-4至+4(亂數範圍)之間的1個亂數(亂數數量),則處理模組100是自古典位元緩衝區1031讀取4個古典位元作為亂數數列(4位元可表示十進位的-7至+7的所有整數值)以計算一個亂數值,並於亂數值超出亂數範圍時(如為-5或6),再次執行讀取與計算,直到所獲得的亂數值滿足亂數範圍。 In another example, if the random number request is for a random number (number of random numbers) between -4 and +4 (random number range), the processing module 100 reads from the classical bit buffer 1031 4 classical bits are used as a random number sequence (4 bits can represent all integer values from -7 to +7 in decimal) to calculate a random value, and when the random value exceeds the random number range (such as -5 or 6) ), read and calculate again until the obtained random value meets the random number range.

於一實施例中,古典位元緩衝區1031是一個先進先出(First In First out)的記憶體(如暫存器(register)、緩衝器(buffer)或快閃記憶體(flash memory)等等),步驟S11是以先進先出的方式來儲存多個古典位元至古典位元緩衝區1031,而步驟S12是以先進先出的方式來自古典位元緩衝區1031讀取多個古典位元。換句話說,最早被存入的古典位元緩衝區1031的古典位元(組)會最早被讀出。 In one embodiment, the classical bit buffer 1031 is a first-in-first-out memory (such as a register, a buffer, a flash memory, etc.) etc.), step S11 is to store a plurality of classical bits in the classical bit buffer 1031 in a first-in, first-out manner, and step S12 is to read a plurality of classical bits from the classical bit buffer 1031 in a first-in, first-out manner Yuan. In other words, the classical bit (group) of the classical bit buffer 1031 that is stored the earliest will be read out the earliest.

於一實施例中,電腦設備1可不斷重複執行步驟S10-S11來填滿古典位元緩衝區1031。藉此,當電腦設備1收到亂數請求時,可直接執行步驟S12-S14來輸出亂數值,而可節省步驟S10-S11的等待時間。 In one embodiment, the computer device 1 can repeatedly perform steps S10 - S11 to fill up the classical bit buffer 1031 . In this way, when the computer device 1 receives a random number request, it can directly execute steps S12-S14 to output the random value, thereby saving the waiting time of steps S10-S11.

於一實施例中,電腦設備1是於收到亂數請求時,才執行步驟S10-S11以取得隨機的古典位元,並接著執行步驟S12-S14以輸出亂數值。 In one embodiment, the computer device 1 executes steps S10-S11 to obtain random classical bits only when receiving a random number request, and then executes steps S12-S14 to output a random value.

續請一併參閱圖1至圖3,圖3為本發明第二實施例的真亂數產生方法的部分流程圖。圖3是用以對圖2的步驟S10做更詳盡的說明。 Please refer to FIG. 1 to FIG. 3 together. FIG. 3 is a partial flowchart of a method for generating a true random number according to a second embodiment of the present invention. FIG. 3 is used to describe step S10 of FIG. 2 in more detail.

於本實施例中,為提升量子位元的量測效率,是直接忽略量子電腦的誤差,而直接進行量測並使用量測結果來產生亂數值。 In this embodiment, in order to improve the measurement efficiency of the qubit, the error of the quantum computer is directly ignored, and the measurement is directly performed and the measurement result is used to generate a random value.

具體而言,步驟S10可包括以下步驟S20-S22。 Specifically, step S10 may include the following steps S20-S22.

步驟S20:量子電腦2對各量子位元分別執行Hadamard邏輯閘操作以使各量子位元變為疊加態。Hadamard邏輯閘操作為量子運算領域的常見技術,主要是用以將量子位元變為為疊加態(即處於|0〉與|1〉的線性疊加),其計算細節於此不再贅述。 Step S20 : the quantum computer 2 performs the Hadamard logic gate operation on each qubit respectively, so that each qubit becomes a superposition state. The Hadamard logic gate operation is a common technique in the field of quantum computing, and is mainly used to turn qubits into a superposition state (ie, in a linear superposition of |0> and |1>), and the details of its calculation will not be repeated here.

步驟S21:量子電腦2對疊加態的各量子位元分別執行量測處理以量測各量子位元的量子態來獲得一個古典位元。藉由對多個量子位元分別執行量測,量子電腦2可產生多個古典位元。 Step S21: The quantum computer 2 performs measurement processing on each qubit in the superposition state, respectively, to measure the quantum state of each qubit to obtain a classical bit. The quantum computer 2 can generate a plurality of classical bits by separately performing measurements on a plurality of qubits.

於一實施例中,為了獲得較佳的執行效率,量子電腦2每次是對三個量子位元分別執行量測來獲得三個古典位元,但不以此限定,亦可對五個量子位元分別執行量測來獲得五個古典位元,等等。 In an embodiment, in order to obtain better execution efficiency, the quantum computer 2 performs measurements on three qubits each time to obtain three classical bits, but it is not limited to this, and can also measure five qubits. The bits are measured separately to obtain five classical bits, and so on.

步驟S22:量子電腦2經由網路3傳送所獲得的多個古典位元至電腦設備1。 Step S22 : the quantum computer 2 transmits the obtained classical bits to the computer device 1 via the network 3 .

藉此,本發明可有效自量子位元經由量測獲得古典位元。 Thus, the present invention can effectively obtain classical bits from qubits through measurement.

請一併參閱圖9,為本發明一實施態樣的量子邏輯電路的架構圖。前述步驟S20-S21可使用圖9所示的量子邏輯電路來加以表示。更進一步地,前述量子電腦程式200可用來實現圖9所示的量子邏輯電路。 Please also refer to FIG. 9 , which is a structural diagram of a quantum logic circuit according to an embodiment of the present invention. The aforementioned steps S20-S21 can be represented by the quantum logic circuit shown in FIG. 9 . Furthermore, the aforementioned quantum computer program 200 can be used to implement the quantum logic circuit shown in FIG. 9 .

於圖9的例子中,是對三個量子位元q0-q2進行量測,來獲得三筆量測結果(C),即三個古典位元。 In the example of FIG. 9, three qubits q0-q2 are measured to obtain three measurement results (C), namely, three classical bits.

具體而言,於本例子中,三個量子位元q0-q2是先分別通過Hadamard邏輯閘50-52來變為疊加態。接著,通過量測邏輯閘60-62對疊加態的三個量子位元q0-q2的量子態進行量測,以自量子位元q0獲得第零古典位元、自量子位元q1獲得第一古典位元、並自量子位元q2獲得第二古典位元(即控制線C的輸出)。 Specifically, in this example, the three qubits q0-q2 first pass through the Hadamard logic gates 50-52 to become superposition states. Next, the quantum states of the three qubits q0-q2 in the superposition state are measured by the measurement logic gates 60-62, so as to obtain the zeroth classical bit from the qubit q0 and obtain the first classical bit from the qubit q1 A classical bit, and a second classical bit (ie, the output of control line C) is obtained from qubit q2.

請一併參閱圖1、圖2及圖4,圖4為本發明第三實施例的真亂數產生方法的部分流程圖。圖4是用以對圖2的步驟S10做更詳盡的說明。 Please refer to FIG. 1 , FIG. 2 and FIG. 4 together. FIG. 4 is a partial flowchart of a method for generating a true random number according to a third embodiment of the present invention. FIG. 4 is used to describe step S10 of FIG. 2 in more detail.

量子位元容易受外界干擾(如熱雜訊)而產生誤差(如位元翻轉誤差,bit-flip error,如量子態|0〉受干擾而變成|1〉),而造成降低量測結果的品質。 Qubits are susceptible to external disturbances (such as thermal noise), resulting in errors (such as bit flip errors, bit-flip errors, such as quantum state |0> being disturbed and becoming |1>), which will reduce the measurement results. quality.

對此,於本實施例中,為排除上述誤差的影響,是將多個量子位元(做為區別,下稱工作量子位元)作為量子位元組(如兩個工作量子位元為一組量子位元組,或者五個工作量子位元為一組量子位元組),不加以限定),並對各量子位元組來執行量測以獲得一個古典位元(即本實施例是以多個量子位元來產生一個古典位元),來提升量測結果的品質。 In this regard, in this embodiment, in order to eliminate the influence of the above errors, a plurality of qubits (as a distinction, hereinafter referred to as working qubits) are used as a qubit group (for example, two working qubits are one set of qubits, or five working qubits as a set of qubits), without limitation), and perform measurements on each qubit to obtain a classical bit (that is, this embodiment is use multiple qubits to generate a classical bit) to improve the quality of the measurement results.

具體而言,步驟S10可包括以下步驟S30-S32。 Specifically, step S10 may include the following steps S30-S32.

步驟S30:量子電腦2使量子位元組的多個工作量子位變為糾纏態。於糾纏態下,多個工作量子位元的量子態會相互影響。 Step S30: The quantum computer 2 makes the multiple working qubits of the qubit group become entangled. In an entangled state, the quantum states of multiple working qubits interact with each other.

並且,於沒有誤差的情況下,多個工作量子位元的量子態會因相互影響而相同。於存在位元翻轉誤差的情況下,其中一個(或以上)的工作量子位元的量子態會因翻轉而與其他工作量子位元的量子態不同。 And, in the absence of error, the quantum states of multiple working qubits will be the same due to mutual influence. In the presence of a bit flip error, the quantum state of one (or more) working qubits can be flipped to be different from the quantum states of the other working qubits.

步驟S31:量子電腦2依據糾纏態的多個工作量子位元的多個量子態決定一個古典位元。 Step S31: The quantum computer 2 determines a classical bit according to the multiple quantum states of the multiple working qubits in the entangled state.

於一實施例中,是量測糾纏態的多個工作量子位元的多個量子態,依據多個量子態採用多數決來決定古典位元。舉例來說,若三個工作量子位元經量測的量子態分別為0、0、1,則基於多數決,古典位元會被設定為0(多數)。上述原理在於,量子位元發生誤差的機率是小於正常狀態的機率。 In one embodiment, a plurality of quantum states of a plurality of working qubits in an entangled state are measured, and a majority vote is used to determine a classical bit according to the plurality of quantum states. For example, if the measured quantum states of the three working qubits are 0, 0, and 1, the classical bit is set to 0 (majority) based on a majority vote. The above principle is that the probability of error in the qubit is smaller than the probability of the normal state.

於一實施例中,各量子位元組除了多個工作量子位元外,更包括輔助量子位元作為誤差校正碼(error correcting code)。 In one embodiment, in addition to a plurality of working qubits, each qubit group further includes auxiliary qubits as error correcting codes.

值得一提的是,經發明人的反覆實驗,三個工作量子位元可以具有最佳的糾纏態,而可以用來產生最佳的量測結果。對此,後續說明是以三個工作量子位元為例,但不應以此限定本發明的量子位元組的多個工作量子位元的數量(亦可為二個、五個或九個等等)。 It is worth mentioning that, after repeated experiments by the inventors, the three working qubits can have the best entangled state and can be used to produce the best measurement results. In this regard, the following description takes three working qubits as an example, but this should not limit the number of multiple working qubits in the qubit group of the present invention (it can also be two, five or nine). and many more).

具體而言,本實施例的步驟S31可包括步驟S40-S43。步驟S40:量子電腦2對第一個工作量子位元、第二個工作量子位元及輔助量子位元執行雙控制反邏輯閘操作,以影響輔助量子位元的量子態。 Specifically, step S31 in this embodiment may include steps S40-S43. Step S40: The quantum computer 2 performs a double-controlled inverse logic gate operation on the first working qubit, the second working qubit and the auxiliary qubit, so as to affect the quantum state of the auxiliary qubit.

步驟S41:量子電腦2對第一個工作量子位元及第二個工作量子位元執行單控制反邏輯閘操作,以影響第二工作量子位元的量子態。 Step S41: The quantum computer 2 performs a single-controlled inverse logic gate operation on the first working qubit and the second working qubit, so as to affect the quantum state of the second working qubit.

步驟S42:量子電腦2對第二個工作量子位元、第三個工作量子位元及輔助量子位元執行雙控制反邏輯閘操作,以再次影響輔助量子位元的量子態。 Step S42: The quantum computer 2 performs a double-controlled inverse logic gate operation on the second working qubit, the third working qubit and the auxiliary qubit, so as to affect the quantum state of the auxiliary qubit again.

步驟S43:量子電腦2對輔助量子位元的量子態執行量測處理以獲得一個古典位元。 Step S43: The quantum computer 2 performs measurement processing on the quantum state of the auxiliary qubit to obtain a classical bit.

接著,執行步驟S32:量子電腦2經由網路3傳送所獲得的一個古典位元至電腦設備1。 Next, step S32 is performed: the quantum computer 2 transmits the obtained classical bit to the computer device 1 via the network 3 .

藉此,本發明可有效校正量子位元的誤差,而提升量子位元的隨機性,並獲得品質更好的隨機數。 Thereby, the present invention can effectively correct the error of the qubit, improve the randomness of the qubit, and obtain a random number with better quality.

請一併參閱圖10,為本發明一實施態樣的量子邏輯電路的架構圖。圖4的步驟S30可使用圖10所示的量子邏輯電路7來加以實現,步驟S40-S43可使用圖10所示的量子邏輯電路8來加以實現。更進一步地,前述量子電腦程式200可用來實現圖10所示的量子邏輯電路7、8。 Please also refer to FIG. 10 , which is a structural diagram of a quantum logic circuit according to an embodiment of the present invention. Step S30 in FIG. 4 can be implemented using the quantum logic circuit 7 shown in FIG. 10 , and steps S40 to S43 can be implemented using the quantum logic circuit 8 shown in FIG. 10 . Furthermore, the aforementioned quantum computer program 200 can be used to implement the quantum logic circuits 7 and 8 shown in FIG. 10 .

於圖10的例子中,是對三個工作量子位元q0-q2及輔助量子位元a0進行邏輯運算,並將輔助量子位元a0的最終的量測結果(C)作為第零古典位元。 In the example of Fig. 10, logical operations are performed on the three working qubits q0-q2 and the auxiliary qubit a0, and the final measurement result (C) of the auxiliary qubit a0 is used as the zeroth classical bit. .

於量子邏輯電路7中,工作量子位元q0-q2被變為糾纏態。具體而言,通過Hadamard邏輯閘70來使工作量子位元q0變為疊加態,通過單控制反邏輯閘71使工作量子位元q0-q1糾纏,並通過單控制反邏輯閘72使工作量子位元q0、q2糾纏。 In the quantum logic circuit 7, the working qubits q0-q2 are turned into an entangled state. Specifically, the working qubit q0 is brought into a superposition state by the Hadamard logic gate 70, the working qubit q0-q1 is entangled by the single-controlled inverse logic gate 71, and the working qubit is made by the single-controlled inverse logic gate 72. Elements q0, q2 are entangled.

接著,於量子邏輯電路8中,糾纏態的工作量子位元q0-q2糾纏至輔助量子位元a0,並以輔助量子位元的量子態來獲得古典位元。具體而言,以工作量子位元q0、q1為控制位元,以輔助量子位元a0為目標位元執行雙控制反邏輯閘80;以工作量子位元q1為控制位元,以工作量子位元q1為目標位元執行單控制反邏輯閘81;以工作量子位元q1、q2為控制位元,以輔助量子位元a0為目標位元執行雙控制反邏輯閘82。藉此,工作量子位元q1、q2、q3會糾纏輔助量子位元a0,即輔助量子位元a0的量子態可以用來反應工作量子位元q1、q2、q3的量子態。 Next, in the quantum logic circuit 8, the working qubits q0-q2 of the entangled state are entangled with the auxiliary qubit a0, and the quantum state of the auxiliary qubit is used to obtain a classical bit. Specifically, take the working qubits q0 and q1 as the control bits, and take the auxiliary qubit a0 as the target bit to implement the double-controlled inverse logic gate 80; take the working qubit q1 as the control bit, and take the working qubit The element q1 is the target bit to implement the single-controlled inverse logic gate 81; the working qubits q1 and q2 are used as the control bits, and the auxiliary qubit a0 is used as the target bit to implement the double-controlled inverse logic gate 82. In this way, the working qubits q1, q2, and q3 will entangle the auxiliary qubit a0, that is, the quantum state of the auxiliary qubit a0 can be used to reflect the quantum states of the working qubits q1, q2, and q3.

最後,通過量測邏輯閘83對輔助量子位元a0的量子態進行量測來獲得第零古典位元(即控制線C的輸出)。 Finally, the quantum state of the auxiliary qubit a0 is measured by the measurement logic gate 83 to obtain the zeroth classical bit (ie, the output of the control line C).

續請一併參閱圖1至圖5,圖5為本發明第四實施例的真亂數產生方法的流程圖。於本實施例中,古典位元的補充(對應圖2的步驟S10-S11,即圖5的步驟S50-S54)與亂數的產生(對應圖2的步驟S12-S14,即圖5的步驟S55-S59)是獨立執行(可先後執行或平行處理),而沒有執行順序關係。 Please refer to FIG. 1 to FIG. 5 together. FIG. 5 is a flowchart of a method for generating a true random number according to a fourth embodiment of the present invention. In this embodiment, the addition of classical bits (corresponding to steps S10-S11 in FIG. 2, namely steps S50-S54 in FIG. 5) and the generation of random numbers (corresponding to steps S12-S14 in FIG. 2, that is, steps in FIG. 5) S55-S59) are independently executed (sequentially executed or processed in parallel), and there is no execution sequence relationship.

此外,於本實施例中,用戶可設定(或由電腦設備1自動設定)補充條件,當補充條件滿足時,電腦設備1會自動補充古典位元緩衝區1031的古典位元。 In addition, in this embodiment, the user can set (or automatically set by the computer device 1 ) the supplementary condition, and when the supplementary condition is satisfied, the computer device 1 will automatically supplement the classical bits of the classical bit buffer 1031 .

步驟S50:電腦設備1產生古典位元產生請求,並經由網路3發送古典位元產生請求至量子電腦2的雲端應用平台20。 Step S50 : the computer device 1 generates a classical bit generation request, and sends the classical bit generation request to the cloud application platform 20 of the quantum computer 2 via the network 3 .

步驟S51:量子電腦對多個量子位元執行量測以獲得隨機產生的多個古典位元,並經由網路3回傳這些古典位元至電腦設備1。 Step S51 : the quantum computer performs measurement on a plurality of qubits to obtain a plurality of randomly generated classical bits, and returns these classical bits to the computer device 1 via the network 3 .

於一實施例中,古典位元產生請求包括用戶資訊,雲端應用平台20是於用戶資訊通過驗證時,才執行步驟S51的處理。 In one embodiment, the classical bit generation request includes user information, and the cloud application platform 20 executes the process of step S51 only when the user information is verified.

步驟S52:電腦設備1將所收到的古典位元儲存於古典位元緩衝區1031。 Step S52 : the computer device 1 stores the received classical bits in the classical bit buffer 1031 .

步驟S53:電腦設備1判斷預設的補充條件是否滿足,補充條件可預存於儲存模組103中。 Step S53 : the computer device 1 determines whether the preset supplementary condition is satisfied, and the supplementary condition may be pre-stored in the storage module 103 .

於一實施例中,補充條件可為古典位元緩衝區1031的可用空間大於預設值(即剩餘的古典位元過少)、預設時間間隔經過(如10分鐘)、每次連上網路3時及/或每次收到亂數請求時,不加以限定。 In one embodiment, the supplementary conditions may be that the free space of the classical bit buffer 1031 is greater than a predetermined value (ie, the remaining classical bits are too few), the predetermined time interval has elapsed (such as 10 minutes), and each time the network is connected 3 Time and/or each time a random number request is received, without limitation.

若電腦設備1判斷預設的補充條件滿足,則再次執行步驟S50-S53以再次為古典位元緩衝區1031補充古典位元。 If the computer device 1 determines that the preset replenishment conditions are satisfied, steps S50 - S53 are performed again to replenish the classical bits to the classical bit buffer 1031 again.

若電腦設備1判斷預設的補充條件不滿足,則執行步驟S54:電腦設備1判斷是否結束補充功能(如用戶關閉補充功能或者與網路3中斷連接等等)。 If the computer device 1 determines that the preset supplementary condition is not satisfied, step S54 is executed: the computer device 1 determines whether to end the supplementary function (eg, the user closes the supplementary function or disconnects from the network 3 , etc.).

若電腦設備1判斷不須結束補充功能,則再次執行步驟S53。若電腦設備1判斷結束補充功能,則結束方法。 If the computer device 1 determines that the supplementary function does not need to be terminated, step S53 is performed again. When the computer device 1 determines that the supplementary function is terminated, the method is terminated.

前述實施例中,一旦網路3的連接中斷且古典位元緩衝區3所儲存的的古典位元用盡,電腦設備1將會無法產生亂數值,而造成用戶不便。 In the aforementioned embodiment, once the connection of the network 3 is interrupted and the classical bits stored in the classical bit buffer 3 are used up, the computer device 1 will not be able to generate random values, which will cause inconvenience to the user.

為解決上述問題,本實施例進一步提出一種混合提供真亂數與模擬亂數的功能,主要是由執行步驟S55-S59來實現。 In order to solve the above problem, this embodiment further proposes a function of providing real random numbers and simulated random numbers in a mixed manner, which is mainly realized by executing steps S55-S59.

步驟S55:電腦設備1判斷是否收到任一亂數請求。如自外部電腦設備4收到亂數請求或用戶經由人機介面102輸入亂數請求。 Step S55: The computer device 1 determines whether any random number request is received. For example, the random number request is received from the external computer device 4 or the user inputs the random number request through the human-machine interface 102 .

若電腦設備1判斷未收到任何亂數請求,則再次執行步驟S55。 If the computer device 1 determines that no random number request has been received, step S55 is performed again.

若電腦設備1收到亂數請求,則執行步驟S56:電腦設備1判斷是否連接網路3,而可以執行步驟S50-S52的古典位元的補充。 If the computer device 1 receives the random number request, step S56 is executed: the computer device 1 determines whether the network 3 is connected, and the classical bit supplementation of steps S50-S52 can be performed.

若電腦設備1判斷連接網路3,則執行步驟S57:電腦設備1執行真亂數產生程序(如圖2的步驟S12-S14),以獲得屬於真亂數的亂數值。 If the computer device 1 determines that the network 3 is connected, step S57 is executed: the computer device 1 executes a true random number generating program (steps S12-S14 in FIG. 2 ) to obtain a random value belonging to a true random number.

若電腦設備1判斷未連接網路3,則執行步驟S58:電腦設備1進一步判斷古典位元緩衝區1031目前所儲存的剩餘的多個古典位元的總長度是否滿足此亂數請求的亂數範圍及/或亂數數量。 If the computer device 1 determines that the network 3 is not connected, step S58 is executed: the computer device 1 further determines whether the total length of the remaining classical bits currently stored in the classical bit buffer 1031 satisfies the random number of the random number request range and/or number of random numbers.

舉例來說,若古典位元緩衝區1031僅剩下39位元,但亂數範圍為0至1023(即每個亂數值需10位元),且需要5個亂數值,即總共需要50位元,則電腦設備1可判定古典位元不足產生所有亂數。 For example, if there are only 39 bits left in the classical bit buffer 1031, but the random numbers range from 0 to 1023 (that is, each random value requires 10 bits), and 5 random values are required, that is, a total of 50 bits are required , the computer device 1 can determine that the classical bits are insufficient to generate all random numbers.

舉例來說,若古典位元緩衝區1031僅剩下4096位元,但亂數範圍為0至1048575(即每個亂數值需20位元),且需要10個亂數值,即總共需要2000位元,則電腦設備1可判定古典位元足夠產生所有亂數。 For example, if the classical bit buffer 1031 has only 4096 bits left, but the random number ranges from 0 to 1048575 (that is, each random value requires 20 bits), and requires 10 random values, that is, a total of 2000 bits are required , the computer device 1 can determine that the classical bits are sufficient to generate all random numbers.

若電腦設備1判斷古典位元緩衝區1031剩餘的古典位元足夠,則執行步驟S57以產生真亂數。 If the computer device 1 determines that the classical bits remaining in the classical bit buffer 1031 are sufficient, step S57 is executed to generate a true random number.

若電腦設備1判斷古典位元緩衝區1031剩餘的古典位元不足夠,則執行步驟S59:電腦設備1基於該亂數請求的該亂數範圍執行模擬亂數產生程序以產生多個模擬亂數位元作為亂數數列,並對亂數序列執行格式轉換處理來獲得格式符合的亂數值。 If the computer device 1 determines that the classical bits remaining in the classical bit buffer 1031 are not enough, step S59 is executed: the computer device 1 executes the simulated random number generation program based on the random number range requested by the random number to generate a plurality of simulated random number bits The element is used as a random number sequence, and the format conversion process is performed on the random number sequence to obtain a random value that conforms to the format.

藉此,本發明可隨時提供用戶亂數值,並於連接網路3時提供高品質的真亂數。 In this way, the present invention can provide user random numbers at any time, and provide high-quality real random numbers when the network 3 is connected.

值得一提的是,步驟S58並非本實施例的必要步驟。於一實施例中,本發明的真亂數產生方法亦可被修改為於判斷未連接網路3(步驟S56,否)時,直接執行模擬亂數產生程序(步驟S59)。 It is worth mentioning that step S58 is not a necessary step in this embodiment. In one embodiment, the real random number generation method of the present invention can also be modified to directly execute the simulated random number generation program (step S59 ) when it is determined that the network 3 is not connected (step S56 , No).

於一實施例中,電腦設備1可設置量子邏輯電路(如圖9或圖10所述的量子邏輯電路,亦可經由將一份量子電腦程式200移至電腦設備1執行來加以實 現)。於步驟S59中,電腦設備1是經由量子邏輯電路來於本地端模擬執行量子演算法(如前述真亂數產生程序)來獲得亂數。 In one embodiment, the computer device 1 can be provided with a quantum logic circuit (such as the quantum logic circuit shown in FIG. 9 or FIG. 10 , or it can be implemented by moving a quantum computer program 200 to the computer device 1 for execution. now). In step S59, the computer device 1 obtains random numbers by simulating and executing a quantum algorithm (such as the aforementioned true random number generating program) at the local end through the quantum logic circuit.

請一併參閱圖1至圖6,圖6為本發明第五實施例的真亂數產生方法的部分流程圖。於本實施例中,進一步提供一種亂數篩選功能。用戶可於亂數請求中設定亂數條件(如不連號或不重複等等),電腦設備1會依據所設定的亂數條件來篩選所產生的亂數值。 Please refer to FIG. 1 to FIG. 6 together. FIG. 6 is a partial flowchart of a method for generating a true random number according to a fifth embodiment of the present invention. In this embodiment, a random number filtering function is further provided. The user can set a random number condition (such as no consecutive numbers or no repetition, etc.) in the random number request, and the computer device 1 will filter the generated random number value according to the set random number condition.

具體而言,本實施例的真亂數產生方法包括以下步驟。 Specifically, the method for generating a true random number in this embodiment includes the following steps.

步驟S60:電腦設備1接受亂數請求。亂數請求中設定有亂數條件與亂數數量。 Step S60: The computer device 1 accepts the random number request. The random number request includes the random number condition and the random number quantity.

步驟S61:電腦設備1執行亂數產生程序以產生一個亂數值。亂數產生程序可為前述真亂數產生程序、模擬亂數產生程序或兩個混搭,不加以限定。 Step S61: The computer device 1 executes a random number generating program to generate a random value. The random number generating program may be the aforementioned real random number generating program, an analog random number generating program, or a combination of the two, which is not limited.

步驟S62:電腦設備1判斷所產生的亂數值是否符合亂數條件。 Step S62: The computer device 1 determines whether the generated random value meets the random number condition.

以亂數條件是不連號為例,電腦設備1判斷所產生的亂數值是否與先前產生的其他亂數值為連號(如先前已產生亂數值3,若本次產生亂數值2,則可判定為連號,若本次產生亂數值1,則可判定為不連號)。 Taking the random number condition as an example of non-consecutive numbers, the computer device 1 determines whether the generated random number is a consecutive number with other previously generated random numbers (for example, the random number 3 has been generated before, if the random number 2 is generated this time, it can be It is judged to be a consecutive number. If a random value of 1 is generated this time, it can be judged to be a non-consecutive number).

以亂數條件是不重覆為例,電腦設備1判斷所產生的亂數值是否與先前產生的其他亂數值為連號(如先前已產生亂數值13,若本次又產生亂數值13,而可判定為重複;若本次產生亂數值7,而可判定為不重複)。 Taking the random number condition as non-repetition as an example, the computer device 1 determines whether the generated random value is consecutive with other previously generated random values (for example, the random value 13 has been generated before, if the random value 13 is generated this time, and It can be determined to be repeated; if a random value of 7 is generated this time, it can be determined to be non-repetitive).

若電腦設備1判斷所產生的亂數值符合亂數條件,則執行步驟S64。 If the computer device 1 determines that the generated random value meets the random number condition, step S64 is executed.

若電腦設備1判斷所產生的亂數值不符合亂數條件,則執行步驟S63:電腦設備1刪除此不符條件的亂數值。 If the computer device 1 determines that the generated random value does not meet the random number condition, step S63 is executed: the computer device 1 deletes the random value that does not meet the condition.

接著執行步驟S64:電腦設備1判斷已產生的和條件的亂數值的數量是否達到亂數數量。 Next, step S64 is executed: the computer device 1 determines whether the number of generated random numbers of the sum condition reaches the number of random numbers.

若尚未達到亂數數量,則再次執行步驟S61;否則,電腦設備1輸出所有亂數並結束本次執行。 If the number of random numbers has not been reached, step S61 is performed again; otherwise, the computer device 1 outputs all random numbers and ends this execution.

續請一併參閱圖1至圖7,圖7為本發明第六實施例的真亂數產生方法的部分流程圖。於本實施例中,進一步提供一種觸發功能。電腦設備1於被觸發後才會接受設定亂數請求,並據以產生亂數值。 Please refer to FIG. 1 to FIG. 7 together. FIG. 7 is a partial flowchart of a method for generating a true random number according to a sixth embodiment of the present invention. In this embodiment, a trigger function is further provided. The computer device 1 will only accept the request for setting random numbers after being triggered, and generate random values accordingly.

具體而言,本實施例的真亂數產生方法包括以下步驟。 Specifically, the method for generating a true random number in this embodiment includes the following steps.

步驟S70:電腦設備1判斷預設的觸發條件是否滿足,觸發條件可預存於儲存模組103中。 Step S70 : the computer device 1 determines whether the preset trigger condition is satisfied, and the trigger condition may be pre-stored in the storage module 103 .

於一實施例中,觸發條件可為自外部電腦設備4收到亂數請求。 In one embodiment, the trigger condition may be a random number request received from the external computer device 4 .

於一實施例中,功能模組104為照相機,用以不斷拍攝環境影像,並傳送至處理模組100(或送至雲端伺服器執行AI人臉辨識),以偵測並辨識人臉。前述觸發條件可為偵測到人臉,或者人臉通過辨識驗證。 In one embodiment, the functional module 104 is a camera, which continuously captures environmental images and sends them to the processing module 100 (or to a cloud server for AI face recognition) to detect and recognize human faces. The aforementioned trigger condition may be that a human face is detected, or the human face has passed the identification verification.

於一實施例中,功能模組104為PIR感測器,用以於感測到用戶時觸發訊號。前述觸發條件可為收到PIR感測器的觸發訊號,即偵測到用戶。 In one embodiment, the function module 104 is a PIR sensor for triggering a signal when a user is detected. The aforementioned trigger condition may be receiving a trigger signal from the PIR sensor, that is, detecting a user.

若電腦設備1判斷觸發條件不滿足,則再次執行步驟S70以持續判斷。 If the computer device 1 determines that the trigger condition is not satisfied, step S70 is performed again to continue the determination.

若電腦設備1判斷觸發條件滿足,則執行步驟S71:電腦設備1經由人機介面102接受用戶的亂數請求操作,並依據亂數請求操作設定亂數請求。 If the computer device 1 determines that the trigger condition is satisfied, step S71 is executed: the computer device 1 accepts the user's random number request operation via the man-machine interface 102 , and sets the random number request according to the random number request operation.

於一實施例中,前述亂數請求操作是輸入亂數範圍、亂數個數及/或亂數條件,但不加以限定。 In an embodiment, the aforementioned random number request operation is to input a random number range, a random number and/or a random number condition, but it is not limited thereto.

步驟S72:電腦設備1基於亂數請求產生對應的一或多個亂數值(亂數值的產生方式如前所述,於此不再贅述)。 Step S72 : the computer device 1 generates one or more corresponding random values based on the random number request (the method of generating the random values is as described above, and will not be repeated here).

藉此,用戶可經由觸發電腦設備1來使電腦設備1快速進入可接受操作的狀態,而有效提升輸入請求的效率。 In this way, the user can make the computer device 1 quickly enter an acceptable operation state by triggering the computer device 1 , thereby effectively improving the efficiency of inputting requests.

續請一併參閱圖1至圖8,圖8為本發明第七實施例的真亂數產生方法的部分流程圖。本發明所產生的一或多個亂數值可應用於不同領域,如資訊安全、遊戲與博弈等等。 Please refer to FIG. 1 to FIG. 8 together. FIG. 8 is a partial flowchart of a method for generating a true random number according to a seventh embodiment of the present invention. The one or more random values generated by the present invention can be applied to different fields, such as information security, games and games, and so on.

具體而言,電腦設備1可於產生亂數值後執行步驟S80或S81來應用所產生的亂數值。 Specifically, the computer device 1 may perform step S80 or S81 to apply the generated random value after generating the random value.

步驟S80:電腦設備1基於所產生的亂數值執行加密處理。 Step S80: The computer device 1 performs encryption processing based on the generated random value.

於一實施例中,電腦設備1可基於亂數值產生加密金鑰,並以此加密金鑰配合對應的加密演算法(如OpenSSL)來對資料或設備進行軟體加密。 In one embodiment, the computer device 1 can generate an encryption key based on the random value, and use the encryption key to cooperate with a corresponding encryption algorithm (eg, OpenSSL) to perform software encryption on the data or the device.

步驟S81:電腦設備1基於所產生的亂數值計算遊戲結果。 Step S81: The computer device 1 calculates the game result based on the generated random value.

於一實施例中,遊戲為骰子遊戲,電腦設備1是產生1-6之間的亂數值作為電子骰的點數,但不以此限定,所有使用亂數的遊戲皆可運用本發明所產生的真亂數來提升隨機性。 In one embodiment, the game is a dice game, and the computer device 1 generates random numbers between 1-6 as the points of the electronic dice, but not limited to this, all games using random numbers can be generated by using the present invention. the true random numbers to improve randomness.

綜上所述,本發明所產生的亂數值是具有極佳的可用性。並且,由於本發明所產生的是真亂數,無法被預測與重複,更進一步提升了加密的安全性與遊戲的公平性。 In conclusion, the random value generated by the present invention has excellent usability. Moreover, since the generated random numbers of the present invention cannot be predicted and repeated, the security of encryption and the fairness of the game are further improved.

以上所述僅為本發明之較佳具體實例,非因此即侷限本發明之專利範圍,故舉凡運用本發明內容所為之等效變化,均同理皆包含於本發明之範圍內,合予陳明。 The above description is only a preferred specific example of the present invention, and therefore does not limit the scope of the patent of the present invention. Therefore, all equivalent changes made by using the content of the present invention are all included in the scope of the present invention. bright.

S10-S14:第一亂數產生步驟 S10-S14: The first random number generation step

Claims (9)

一種基於量子運算的真亂數產生方法,包括:a)於一電腦設備經由網路自一量子電腦接收經由對多個量子位元執行量測所獲得的多個古典位元;b)將多個古典位元儲存於該電腦設備的一儲存模組;c)於收到一亂數請求且連接網路時,基於該亂數請求的一亂數範圍自該儲存模組讀取對應長度的該多個古典位元作為一亂數數列,並自該儲存模組刪除所讀取的該多個古典位元;d)於收到該亂數請求且未連接網路時,基於該亂數請求的該亂數範圍執行一模擬亂數產生程序以產生多個模擬亂數位元作為該亂數數列;e)對該亂數數列執行一格式轉換處理以獲得一亂數值;及f)輸出該亂數值。 A method for generating true random numbers based on quantum operations, comprising: a) receiving a plurality of classical bits obtained by performing measurements on a plurality of qubits from a quantum computer in a computer device via a network; The classical bits are stored in a storage module of the computer equipment; c) when a random number request is received and the network is connected, based on the random number range of the random number request, the corresponding length of the storage module is read from the storage module. The plurality of classical bits are used as a random number sequence, and the plurality of read classical bits are deleted from the storage module; d) when the random number request is received and the network is not connected, based on the random number The requested random number range executes an analog random number generating program to generate a plurality of analog random number bits as the random number sequence; e) performs a format conversion process on the random number sequence to obtain a random value; and f) outputs the random number Random values. 如請求項1所述之基於量子運算的真亂數產生方法,其中該步驟a)包括以下步驟:a11)於該量子電腦上對各該量子位元分別執行Hadamard邏輯閘操作以使各該量子位元變為疊加態;a12)對疊加態的各該量子位元分別執行量測處理以獲得該多個古典位元;及a13)經由網路傳送該多個古典位元至該電腦設備。 The method for generating true random numbers based on quantum operations as described in claim 1, wherein the step a) comprises the following steps: a11) respectively performing Hadamard logic gate operations on each of the qubits on the quantum computer to make each of the quantum The bit becomes a superposition state; a12) performing measurement processing on each of the qubits in the superposition state to obtain the plurality of classical bits; and a13) transmitting the plurality of classical bits to the computer device via a network. 如請求項1所述之基於量子運算的真亂數產生方法,其中該步驟a)是對各量子位元組來執行量測以獲得一個該古典位元,各該量子位元組包括至少二個該量子位元。 The method for generating true random numbers based on quantum operations as described in claim 1, wherein the step a) is to perform measurement on each qubit group to obtain one of the classical bits, and each qubit group includes at least two this qubit. 如請求項3所述之基於量子運算的真亂數產生方法,其中該步驟a)包括以下步驟:a21)於該量子電腦上使該量子位元組的該多個工作量子位元變為糾纏態;a22)依據糾纏態的該多個工作量子位元的多個量子態決定一個該古典位元;及a23)經由網路傳送該古典位元至該電腦設備。 The method for generating true random numbers based on quantum operations as described in claim 3, wherein the step a) comprises the following steps: a21) on the quantum computer, the plurality of working qubits of the qubit group become entangled a22) determining a classical bit according to a plurality of quantum states of the plurality of working qubits of the entangled state; and a23) transmitting the classical bit to the computer device via a network. 如請求項4所述之基於量子運算的真亂數產生方法,其中該步驟a22)是量測糾纏態的該多個工作量子位元的該多個量子態,依據該多個量子態採用多數決來決定該古典位元。 The method for generating true random numbers based on quantum operations as described in claim 4, wherein the step a22) is to measure the plurality of quantum states of the plurality of working qubits in the entangled state, and adopt majority according to the plurality of quantum states decision to determine the classical bit. 如請求項4所述之基於量子運算的真亂數產生方法,其中各該量子位元組更包括一輔助量子位元,且係包括三個該工作量子位元;該步驟a22)更包括以下步驟:a221)對第一個該工作量子位元、第二個該工作量子位元及該輔助量子位元執行一雙控制反邏輯閘操作;a222)對第一個該工作量子位元及第二個該工作量子位元執行一單控制反邏輯閘操作;a223)對第二個該工作量子位元、第三個該工作量子位元及該輔助量子位元執行該雙控制反邏輯閘操作;及a224)對該輔助量子位元執行量測處理以獲得一個該古典位元。 The method for generating true random numbers based on quantum operations as described in claim 4, wherein each of the qubit groups further includes an auxiliary qubit, and includes three of the working qubits; the step a22) further includes the following Steps: a221) perform a double control inverse logic gate operation on the first working qubit, the second working qubit and the auxiliary qubit; a222) perform a double control inverse logic gate operation on the first working qubit and the first working qubit and the auxiliary qubit; Two of the working qubits perform a single control inverse gate operation; a223) perform the double control inverse gate operation on the second of the working qubit, the third of the working qubit and the auxiliary qubit and a224) perform a measurement process on the auxiliary qubit to obtain one of the classical bits. 如請求項1所述之基於量子運算的真亂數產生方法,其中該步驟b)是以先進先出的方式來儲存該多個古典位元至該儲存模組,該步驟c)是以先進先出的方式來自該儲存模組讀取該多個古典位元。 The method for generating true random numbers based on quantum operations as claimed in claim 1, wherein the step b) is to store the plurality of classical bits in the storage module in a first-in, first-out manner, and the step c) is to use an advanced The first-out approach comes from the storage module reading the plurality of classical bits. 如請求項1所述之基於量子運算的真亂數產生方法,其中更包括以下步驟: g)基於該亂數請求的一亂數數量重複執行該步驟c)與該步驟d)的至少其中之一與該步驟f)以產生數量符合該亂數數量的該多個亂數值,並於任一該亂數值不符該亂數請求的一亂數條件時,刪除該亂數值。 The method for generating true random numbers based on quantum operations as described in claim 1, further comprising the following steps: g) Repeatedly executing at least one of the step c) and the step d) and the step f) based on a random number requested by the random number to generate the random numbers whose number is consistent with the random number, and in If any of the random values does not meet the random number condition of the random number request, delete the random value. 如請求項1所述之基於量子運算的真亂數產生方法,其中該步驟c)更包括一步驟c1)於收到該亂數請求、未連接網路且該儲存模組所儲存的該多個古典位元的總長度滿足該亂數範圍時,自該儲存模組讀取該多個古典位元作為該亂數數列,並自該儲存模組刪除所讀取的該多個古典位元;該步驟d)是於收到該亂數請求、未連接網路且該儲存模組所儲存的該多個古典位元的總長度不足該亂數範圍時,基於該亂數請求的該亂數範圍執行該模擬亂數產生程序。 The method for generating true random numbers based on quantum operations as described in claim 1, wherein the step c) further includes a step c1) after receiving the random number request, not connected to the network and the multiplicity stored in the storage module When the total length of the classical bits satisfies the random number range, read the classical bits from the storage module as the random number sequence, and delete the read classical bits from the storage module ; This step d) is when the random number request is received, the network is not connected, and the total length of the plurality of classical bits stored in the storage module is less than the random number range, the random number request based on the random number request. The analog random number generation program is executed in the number range.
TW109105753A 2020-02-21 2020-02-21 Method of generating true random numbers based on quantum computing TWI757694B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW109105753A TWI757694B (en) 2020-02-21 2020-02-21 Method of generating true random numbers based on quantum computing

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW109105753A TWI757694B (en) 2020-02-21 2020-02-21 Method of generating true random numbers based on quantum computing

Publications (2)

Publication Number Publication Date
TW202133056A TW202133056A (en) 2021-09-01
TWI757694B true TWI757694B (en) 2022-03-11

Family

ID=78777436

Family Applications (1)

Application Number Title Priority Date Filing Date
TW109105753A TWI757694B (en) 2020-02-21 2020-02-21 Method of generating true random numbers based on quantum computing

Country Status (1)

Country Link
TW (1) TWI757694B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TWI826040B (en) * 2022-10-12 2023-12-11 財團法人工業技術研究院 Quantum circuit design method and apparatus

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1190278B1 (en) * 2000-03-09 2006-10-18 STMicroelectronics S.r.l. Method and hardware architecture for controlling a process or for processing data based on quantum soft computing
CN102955855A (en) * 2012-10-30 2013-03-06 河南理工大学 Palm print database search method based on quantum algorithms
CN109934351A (en) * 2019-03-06 2019-06-25 南京航空航天大学 A kind of quantum learning aid algorithm and the modified fuzzy sliding mode controlling method based on quantum learning aid algorithm
CN110134369A (en) * 2019-04-15 2019-08-16 深圳市纽创信安科技开发有限公司 Randomizer, random number generation method and chip
CN111461335A (en) * 2020-04-03 2020-07-28 合肥本源量子计算科技有限责任公司 Noise-containing single-quantum logic gate implementation method and device based on MPI (Multi-processor interface) multi-process

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1190278B1 (en) * 2000-03-09 2006-10-18 STMicroelectronics S.r.l. Method and hardware architecture for controlling a process or for processing data based on quantum soft computing
US7383235B1 (en) * 2000-03-09 2008-06-03 Stmicroelectronic S.R.L. Method and hardware architecture for controlling a process or for processing data based on quantum soft computing
CN102955855A (en) * 2012-10-30 2013-03-06 河南理工大学 Palm print database search method based on quantum algorithms
CN109934351A (en) * 2019-03-06 2019-06-25 南京航空航天大学 A kind of quantum learning aid algorithm and the modified fuzzy sliding mode controlling method based on quantum learning aid algorithm
CN110134369A (en) * 2019-04-15 2019-08-16 深圳市纽创信安科技开发有限公司 Randomizer, random number generation method and chip
CN111461335A (en) * 2020-04-03 2020-07-28 合肥本源量子计算科技有限责任公司 Noise-containing single-quantum logic gate implementation method and device based on MPI (Multi-processor interface) multi-process

Also Published As

Publication number Publication date
TW202133056A (en) 2021-09-01

Similar Documents

Publication Publication Date Title
US10630492B2 (en) Device and method for testing a physically unclonable function
CN111967609B (en) Model parameter verification method, device and readable storage medium
JP6277734B2 (en) Information processing program, information processing apparatus, and information processing method
CN109614790B (en) Lightweight authentication equipment and authentication method based on feedback loop PUF
TW202107305A (en) Model parameter determination method and device and electronic equipment
EP3542261B1 (en) Method for performing a trustworthiness test on a random number generator
WO2021135638A1 (en) Method and apparatus for detecting whether image is tampered with, and electronic device
WO2022033219A1 (en) Face liveness detection method, system and apparatus, computer device, and storage medium
TWI757694B (en) Method of generating true random numbers based on quantum computing
US20200110906A1 (en) Encryption circuit for performing virtual encryption operations
TW201710953A (en) Electronic device and system and method of controlling access to the same
TWI769603B (en) Image processing method and computer readable medium thereof
CN107133517B (en) Data recovery method based on data encryption and calculation in memory
Avvaru et al. Predicting hard and soft-responses and identifying stable challenges of MUX PUFs using ANNs
CN111126214A (en) Living body detection method and apparatus, computer device, and computer-readable storage medium
WO2022087829A1 (en) Data processing circuit, data processing method, and electronic device
Hamburg Understanding intel’s ivy bridge random number generator
CN112882951A (en) Vehicle small program testing method, device, equipment, storage medium and program product
CN111209050A (en) Method and device for switching working mode of electronic equipment
Pan et al. Side-channel analysis-based model extraction on intelligent CPS: An information theory perspective
KR20200017038A (en) Apparatus and method for message authentication
US20230177154A1 (en) Sparse Encodings for Control Signals
CN112016632B (en) Model joint training method, device, equipment and storage medium
US11621852B1 (en) System and method for providing a multiple-operation transaction to a blockchain
TWI692731B (en) Object position determination circuit