TWI804707B - Method and device for preventing a double spend attack and a computer readable memory medium - Google Patents

Method and device for preventing a double spend attack and a computer readable memory medium Download PDF

Info

Publication number
TWI804707B
TWI804707B TW109102248A TW109102248A TWI804707B TW I804707 B TWI804707 B TW I804707B TW 109102248 A TW109102248 A TW 109102248A TW 109102248 A TW109102248 A TW 109102248A TW I804707 B TWI804707 B TW I804707B
Authority
TW
Taiwan
Prior art keywords
transaction
computing power
confirmations
blockchain network
cost
Prior art date
Application number
TW109102248A
Other languages
Chinese (zh)
Other versions
TW202129583A (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 TW109102248A priority Critical patent/TWI804707B/en
Publication of TW202129583A publication Critical patent/TW202129583A/en
Application granted granted Critical
Publication of TWI804707B publication Critical patent/TWI804707B/en

Links

Images

Landscapes

  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)
  • Electrophonic Musical Instruments (AREA)

Abstract

A method for preventing double-spend attacks, including: acquiring transaction information to be traded, the transaction information including a virtual currency type and a transaction quantity; acquiring a currency price according to the virtual currency type; acquiring a transaction value according to the transaction quantity and the currency price; acquiring a unit attack cost of a corresponding blockchain network according to the virtual currency type; adjusting the number of initial confirmations so that the total attack cost is greater than the transaction value, the total attack cost being equal to the initial confirmation times multiplied by the unit attack cost; and submitting a transaction information to the blockchain network. This application also provides a device for preventing double-spend attacks. This application dynamically adjusts the number of confirmations according to the transaction values so that the cost of double-spend attacks is greater than the transaction value, thereby the double-spend attacks can be prevented.

Description

預防雙花攻擊的方法、裝置及電腦可讀存儲介質 Method, device and computer-readable storage medium for preventing double-spend attack

本發明涉及區塊鏈技術領域,具體涉及一種預防雙花攻擊的方法、裝置及電腦可讀存儲介質。 The invention relates to the technical field of block chains, in particular to a method, device and computer-readable storage medium for preventing double-spending attacks.

區塊鏈領域中的加密幣(例如BTC)交易的雙花攻擊(Double Spending),簡單來講就是攻擊者在交易所進行交易變現後,有預謀地控制算力來改寫區塊,使之前的區塊鏈交易失效,但攻擊者已經拿到現金。具體地,交易所大都是依據不同的幣種確定一個固定的確認次數,當交易額度較大時,網路攻擊者會在確認過程中加入超過51%區塊鏈算力,即可在這個較短的確認時間段內,掌握整個區塊鏈的記帳權,將區塊交易內容進行竄改,待交易所確認了本加密幣交易為可信任的交易後,再將算力撤出此區塊鏈,使本加密幣的此次交易失敗,從而使本加密幣回到攻擊者手中,這樣即完成一次雙花攻擊。如果雙花攻擊不能被避免,則會使交易所或者加密幣的接受者蒙受損失,以及破壞加密幣的交易秩序。 The double spending attack (Double Spending) of encrypted currency (such as BTC) transactions in the blockchain field, in simple terms, is that after the attacker realizes the transaction on the exchange, he premeditatedly controls the computing power to rewrite the block, so that the previous The blockchain transaction is invalidated, but the attacker has cash. Specifically, most exchanges determine a fixed number of confirmations based on different currencies. When the transaction amount is large, cyber attackers will add more than 51% of the blockchain computing power in the confirmation process, and they can trade in this relatively large amount. Within a short confirmation period, master the accounting rights of the entire block chain, tamper with the block transaction content, and withdraw the computing power from the block chain after the exchange confirms that the encrypted currency transaction is a trustworthy transaction , so that the transaction of the encrypted currency fails, so that the encrypted currency returns to the attacker, thus completing a double-spend attack. If the double-spend attack cannot be avoided, it will cause losses to the exchange or the recipient of the encrypted currency, and disrupt the transaction order of the encrypted currency.

有鑑於此,本發明提出一種預防雙花攻擊的方法、裝置及電腦可讀存儲介質,以解決上述問題。 In view of this, the present invention proposes a method, device, and computer-readable storage medium for preventing double-spend attacks to solve the above-mentioned problems.

本申請之第一方面提供一種預防雙花攻擊的方法,包括:獲取待交易的交易資訊,所述交易資訊包括虛擬貨幣類型及交易數量;依據所述虛擬貨幣類型獲取貨幣價格;依據所述交易數量與所述貨幣價格獲取交易值;依據所述虛擬貨幣類型獲取對應區塊鏈網路的單位攻擊成本;調整初始確認次數,以使總攻擊成本大於所述交易值,其中所述總攻擊成本等於所述初始確認次數乘以所述單位攻擊成本;向所述區塊鏈網路提交所述交易資訊。 The first aspect of the present application provides a method for preventing double-spending attacks, including: obtaining transaction information to be traded, the transaction information including virtual currency type and transaction quantity; obtaining currency price according to the virtual currency type; according to the transaction The quantity and the currency price obtain the transaction value; obtain the unit attack cost of the corresponding blockchain network according to the virtual currency type; adjust the number of initial confirmations so that the total attack cost is greater than the transaction value, wherein the total attack cost It is equal to the number of times of initial confirmation multiplied by the unit attack cost; submitting the transaction information to the blockchain network.

進一步地,向所述區塊鏈網路提交所述交易資訊之後還包括:獲取完成確認次數;判斷完成確認次數是否達到所述初始確認次數:若為是,則判定交易完成。 Further, after submitting the transaction information to the blockchain network, it also includes: obtaining the number of completion confirmations; judging whether the number of completion confirmations reaches the initial number of confirmations: if yes, then judging that the transaction is completed.

進一步地,其中,若判斷所述完成確認次數未達到所述初始確認次數,則判斷交易過程是否存在錯誤資訊:若為是,終止該交易並發出告警資訊。 Further, if it is determined that the number of completed confirmations has not reached the initial number of confirmations, it is determined whether there is error information in the transaction process: if yes, the transaction is terminated and a warning message is issued.

進一步地,其中“獲取完成確認次數”具體包括:依據所述運算時間獲取查詢時間段;依據所述查詢時間段依次獲取確認完成次數。 Further, the "obtaining the number of completed confirmations" specifically includes: obtaining the query time period according to the operation time; and sequentially obtaining the confirmation completion times according to the query time period.

進一步地,所述方法還包括步驟:依據所述確認完成次數更新交易進度;即時顯示所述交易進度。 Further, the method further includes the steps of: updating the transaction progress according to the confirmed completion times; and displaying the transaction progress in real time.

進一步地,依據所述虛擬貨幣類型獲取對應區塊鏈網路的單位攻擊成本具體包括步驟:依據所述虛擬貨幣類型獲取對應區塊鏈網路的總算力值;計算所述區塊鏈網路的單位算力成本;計算所述區塊鏈網路的每個區塊的運算時間;依據所述運算時間與所述單位算力成本,獲取單位攻擊成本;或依據所述虛擬貨幣類型獲取對應區塊鏈網路中單個區塊鏈節點的最大算力值;計算所述區塊鏈網路的單位算力成本;計算所述區塊鏈網路的每個區塊的運算時間;依據所述最大算力值、所述單位算力成本及所述運算時間獲取單位攻擊成本。 Further, obtaining the unit attack cost of the corresponding blockchain network according to the virtual currency type specifically includes the steps of: obtaining the total computing power value of the corresponding blockchain network according to the virtual currency type; The unit computing power cost; calculate the computing time of each block of the blockchain network; obtain the unit attack cost according to the computing time and the unit computing power cost; or obtain the corresponding The maximum computing power value of a single blockchain node in the blockchain network; calculate the unit computing power cost of the blockchain network; calculate the computing time of each block of the blockchain network; according to the The maximum computing power value, the unit computing power cost and the computing time are used to obtain the unit attack cost.

進一步地,所述方法還包括步驟:週期獲取所述貨幣價格、所述 總算力值、所述單位算力成本、所述運算時間及所述區塊鏈網路中的單個區塊鏈節點的最大算力值;若所述貨幣價格、所述總算力值、所述單位算力成本、所述運算時間或所述區塊鏈網路中的單個區塊鏈節點的最大算力值中的一個或多個發生變化,則對應調整所述初始確認次數。 Further, the method also includes the step of periodically obtaining the currency price, the The total computing power value, the unit computing power cost, the computing time and the maximum computing power value of a single blockchain node in the blockchain network; if the currency price, the total computing power value, the When one or more of the unit computing power cost, the computing time, or the maximum computing power value of a single blockchain node in the blockchain network changes, the number of initial confirmations is correspondingly adjusted.

進一步地,所述方法還包括步驟:若所述區塊鏈網路中至少一個可信任區塊鏈節點的算力值大於其他區塊鏈節點的算力值,則調整初始確認次數為基本確認次數。 Further, the method further includes the step: if the computing power value of at least one trusted blockchain node in the blockchain network is greater than the computing power value of other blockchain nodes, then adjusting the number of initial confirmations to basic confirmation frequency.

本申請之第二方面提供一種預防雙花攻擊的裝置,包括:記憶體,所述記憶體上存儲有若干電腦程式;處理器,所述處理器用於執行所述記憶體中存儲的電腦程式時實現所述的預防雙花攻擊的方法的步驟。 The second aspect of the present application provides a device for preventing double-spending attacks, including: a memory, on which several computer programs are stored; a processor, when the processor is used to execute the computer programs stored in the memory Steps for realizing the method for preventing double-spending attacks.

本申請之第三方面提供一種電腦可讀存儲介質,其上存儲有電腦程式,所述電腦程式被處理器執行時實現所述的預防雙花攻擊的方法。 The third aspect of the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the method for preventing double-spending attacks is implemented.

本發明依據交易值動態調整確認次數,以使雙花攻擊總攻擊成本大於交易值,從而實現預防雙花攻擊,一併藉由調整確認次數,保證大額交易的安全性與小額交易的便捷性。 The present invention dynamically adjusts the number of confirmations based on the transaction value, so that the total attack cost of double-spending attacks is greater than the transaction value, thereby realizing the prevention of double-spending attacks, and by adjusting the number of confirmations together, the security of large-amount transactions and the convenience of small-amount transactions are guaranteed .

100:預防雙花攻擊的裝置 100: A device to prevent double-spending attacks

10:處理器 10: Processor

20:記憶體 20: memory

30:顯示單元 30: Display unit

40:語音單元 40: Speech unit

50:輸入單元 50: input unit

200:預防雙花攻擊的系統 200: A system for preventing double-spending attacks

201:獲取模組 201: Get the module

202:運算模組 202: Operation module

203:調整模組 203: Adjustment module

204:交易模組 204: Trading Module

205:更新模組 205:Update module

206:顯示模組 206: Display module

207:判斷模組 207: Judgment module

208:告警模組 208:Alarm module

圖1係本發明一實施方式中的預防雙花攻擊的裝置的硬體架構示意圖。 FIG. 1 is a schematic diagram of the hardware architecture of a device for preventing double-spending attacks in an embodiment of the present invention.

圖2係本發明一實施方式中的預防雙花攻擊的系統的功能模組示意圖。 FIG. 2 is a schematic diagram of functional modules of a system for preventing double-spending attacks in an embodiment of the present invention.

圖3係本發明一實施方式中的預防雙花攻擊的方法的流程圖。 Fig. 3 is a flowchart of a method for preventing double-spending attacks in an embodiment of the present invention.

為了能夠更清楚地理解本發明的上述目的、特徵與優點,下面結合附圖與具體實施方式對本發明進行詳細描述。需要說明的是,在不衝突的情況下,本申請的實施方式及實施方式中的特徵可以相互組合。 In order to understand the above-mentioned purpose, features and advantages of the present invention more clearly, the present invention will be described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that, in the case of no conflict, the embodiments of the present application and the features in the embodiments can be combined with each other.

在下面的描述中闡述了很多具體細節以便於充分理解本發明,所描述的實施方式僅是本發明一部分實施方式,而不是全部的實施方式。基於本發明中的實施方式,本領域普通技術人員在沒有做出創造性勞動前提下所獲得的所有其它實施方式,都屬於本發明保護的範圍。 In the following description, many specific details are set forth in order to fully understand the present invention, and the described embodiments are only a part of the embodiments of the present invention, but not all of them. Based on the implementation manners in the present invention, all other implementation manners obtained by persons of ordinary skill in the art without making creative efforts belong to the scope of protection of the present invention.

除非另有定義,本文所使用的所有的技術與科學術語與屬於本發明的技術領域的技術人員通常理解的含義相同。本文中在本發明的說明書中所使用的術語只是為了描述具體的實施方式的目的,不是旨在限制本發明。 Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the technical field of the invention. The terms used herein in the description of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit the present invention.

本文所使用的術語“及/或”包括一個或複數相關的所列項目的任意的與所有的組合。 As used herein, the term "and/or" includes any and all combinations of one or a plurality of the associated listed items.

請參閱圖1,為本發明一實施中提供的預防雙花攻擊的裝置的示意圖。 Please refer to FIG. 1 , which is a schematic diagram of a device for preventing double-spending attacks provided in an implementation of the present invention.

在本實施方式中,所述預防雙花攻擊的裝置100包括處理器10、記憶體20、顯示單元30、語音單元40及輸入單元50。 In this embodiment, the device 100 for preventing double-spending attacks includes a processor 10 , a memory 20 , a display unit 30 , a voice unit 40 and an input unit 50 .

所述處理器10可以為中央處理器(CPU,Central Processing Unit),還可以包括其他通用處理器、數位訊號處理器(Digital Signal Processor,DSP)、專用積體電路(Application Specific Integrated Circuit,ASIC)、現成可程式設計閘陣列(Field-Programmable Gate Array,FPGA)或者其他可程式設計邏輯器件、分立門或者電晶體邏輯器件、分立硬體元件等。通用處理器可以是微處理器或者該處理器也可以是任何常規的處理器等,所述處理器10是預防雙花攻擊的裝置100的控制中心,利用各種介面與線路連接整個預防雙花攻擊的裝置100的各個部分。 The processor 10 can be a central processing unit (CPU, Central Processing Unit), and can also include other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC) , Ready-made programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. General-purpose processor can be microprocessor or this processor also can be any conventional processor etc., described processor 10 is the control center of the device 100 of preventing double-spending attack, utilizes various interfaces and lines to connect the whole preventing double-spending attack various parts of the device 100.

所述記憶體20用於存儲預防雙花攻擊的裝置100中的各類資料,例如圖像集、圖像模型等。在本實施方式中,所述記憶體20可以包括但不限於唯讀記憶體(Read-Only Memory,ROM)、隨機記憶體(Random Access Memory,RAM)、可程式設計唯讀記憶體(Programmable Read-Only Memory,PROM)、可擦除可程式設計唯讀記憶體(Erasable Programmable Read-Only Memory,EPROM)、一次可程式設計唯讀記憶體(One-time Programmable Read-Only Memory,OTPROM)、電子擦除式可複寫唯讀記憶體(Electrically-Erasable Programmable Read-Only Memory,EEPROM)、唯讀光碟(Compact Disc Read-Only Memory,CD-ROM)或其他光碟記憶體、磁碟記憶體、磁帶記憶體、或者能夠用於攜帶或存儲資料的電腦可讀的任何其他介質。 The memory 20 is used to store various data in the device 100 for preventing double-spending attacks, such as image sets, image models, and the like. In this embodiment, the memory 20 may include but not limited to a read-only memory (Read-Only Memory, ROM), a random access memory (Random Access Memory, RAM), a programmable read-only memory (Programmable Read -Only Memory, PROM), Erasable Programmable Read-Only Memory (EPROM), One-time Programmable Read-Only Memory (OTPROM), electronic Erasable rewritable read-only memory (Electrically-Erasable Programmable Read-Only Memory, EEPROM), CD-ROM (Compact Disc Read-Only Memory, CD-ROM) or other optical disk memory, disk memory, tape memory media, or any other computer-readable medium that can be used to carry or store data.

所述顯示單元30用於顯示處理器10處理後的各種資訊,例如顯示交易進度,所述顯示單元30可為顯示器、觸控式螢幕等。 The display unit 30 is used to display various information processed by the processor 10 , such as displaying transaction progress, and the display unit 30 can be a monitor, a touch screen, or the like.

所述語音單元40用於播放處理器10處理後的各種資訊,例如播放交易進度,播放告警提示,所述語音單元40為音箱或其他語音設備。 The voice unit 40 is used to play various information processed by the processor 10, such as playing transaction progress and warning prompts. The voice unit 40 is a speaker or other voice equipment.

所述輸入單元50用於輸入各種資訊,所述輸入單元50可為鍵盤、觸控式螢幕等。 The input unit 50 is used for inputting various information, and the input unit 50 can be a keyboard, a touch screen, and the like.

在一實施方式中,處理器10、記憶體20、顯示單元30、語音單元40與輸入單元50可集成於一電腦裝置中。在其他實施方式中,顯示單元30、語音單元40與輸入單元50也可以省略。 In one embodiment, the processor 10 , the memory 20 , the display unit 30 , the voice unit 40 and the input unit 50 can be integrated into a computer device. In other embodiments, the display unit 30 , the voice unit 40 and the input unit 50 can also be omitted.

所述預防雙花攻擊的裝置100可以是桌上型電腦、筆記本、掌上型電腦及雲端伺服器等計算設備。本領域技術人員可以理解,所述示意圖僅是預防雙花攻擊的裝置100的示例,並不構成對預防雙花攻擊的裝置100的限定,可以包括比圖示更多或更少的部件,或者組合某些部件,或者不同的部件,例如所述預防雙花攻擊的裝置100還可以包括網路接入設備、匯流排等。 The device 100 for preventing double-spending attacks may be computing devices such as desktop computers, notebooks, palmtop computers, and cloud servers. Those skilled in the art can understand that the schematic diagram is only an example of the device 100 for preventing double-spend attacks, and does not constitute a limitation to the device 100 for preventing double-spend attacks, and may include more or less components than those shown in the illustration, or Combining certain components or different components, for example, the apparatus 100 for preventing double-spending attacks may also include network access devices, bus bars, and the like.

請參閱圖2,為本發明一實施方式中預防雙花攻擊的系統200的功能模組示意圖。 Please refer to FIG. 2 , which is a schematic diagram of functional modules of a system 200 for preventing double-spending attacks in an embodiment of the present invention.

在本實施方式中,預防雙花攻擊的系統200包括有一個或多個程式形式的電腦指令,所述一個或多個程式形式的電腦指令存儲於所述記憶體20中,並由所述處理器10執行,以實現本發明所提供的功能。 In this embodiment, the system 200 for preventing double-spending attacks includes one or more computer instructions in the form of programs, and the one or more computer instructions in the form of programs are stored in the memory 20 and processed by the 10 to implement the functions provided by the present invention.

在本實施方式中,所述預防雙花攻擊的系統200可以被分割成獲取模組201、運算模組202、調整模組203、交易模組204、更新模組205、顯示模組206、判斷模組207及告警模組208。各個功能模組的功能將在下面的實施例中進行詳述。 In this embodiment, the system 200 for preventing double-spending attacks can be divided into an acquisition module 201, an operation module 202, an adjustment module 203, a transaction module 204, an update module 205, a display module 206, a judgment module Module 207 and alarm module 208. The functions of each functional module will be described in detail in the following embodiments.

獲取模組201用於獲取待交易的交易資訊。其中交易資訊包括虛擬貨幣類型及交易數量。 The acquiring module 201 is used to acquire transaction information to be traded. The transaction information includes the virtual currency type and transaction quantity.

在一實施例中,藉由調用輸入單元50,以獲取輸入單元50輸入的資訊。 In one embodiment, the information input by the input unit 50 is acquired by calling the input unit 50 .

獲取模組201還用於依據所述虛擬貨幣類型獲取貨幣價格。 The obtaining module 201 is also used to obtain currency prices according to the type of virtual currency.

其中,貨幣價格可以為實際價格,即本時刻的交易價格,也可以為預估價格,即一個時段內交易價格的平均值。 Among them, the currency price can be the actual price, that is, the transaction price at this moment, or the estimated price, that is, the average value of the transaction price within a period of time.

在一實施例中,獲取預設時間段的多個交易平臺的貨幣價格;計算以獲取平均價格,其中平均價格即為所要求的貨幣價格。 In one embodiment, the currency prices of multiple trading platforms in a preset period of time are obtained; the average price is calculated to obtain the average price, wherein the average price is the required currency price.

運算模組202用於依據交易數量與貨幣價格獲取交易值。其中所述交易值為交易的虛擬貨幣的實際價值,交易值等於交易數量乘以貨幣價格。 The calculation module 202 is used to obtain the transaction value according to the transaction quantity and currency price. Wherein the transaction value is the actual value of the virtual currency traded, and the transaction value is equal to the transaction quantity multiplied by the currency price.

獲取模組201還用於依據所述貨幣類型獲取對應區塊鏈網路的總算力值。 The obtaining module 201 is also used to obtain the total computing power value of the corresponding blockchain network according to the currency type.

其中,算力(也稱雜湊率)是區塊鏈網路處理能力的度量單位,即為電腦(CPU)計算雜湊函數輸出的速度。 Among them, computing power (also known as hash rate) is the unit of measurement for the processing power of the blockchain network, that is, the speed at which the computer (CPU) calculates the output of the hash function.

其中區塊鏈網路的總算力值可以為本時刻的實際算力值,也可以是過去一段時間內的算力平均值,也可以為預估算力值;實際算力值可直接獲取且不限定具體的獲取方式。例如,可根據預設時間內區塊鏈網路的曠工記帳權競爭所耗費的時間以及記帳難度,估算當前算力值;也可檢測本區塊鏈網路上的所有礦機的算力,獲得整體區塊鏈網路的當前算力值。 The total computing power value of the blockchain network can be the actual computing power value at this moment, the average computing power value in the past period of time, or the estimated power value; the actual computing power value can be obtained directly and The specific acquisition method is not limited. For example, the current computing power value can be estimated according to the time spent in the competition for absenteeism and bookkeeping rights in the blockchain network within the preset time and the difficulty of bookkeeping; it can also detect the computing power of all mining machines on the blockchain network to obtain The current computing power value of the overall blockchain network.

運算模組202還用於依據總算力值計算出單位算力成本。 The computing module 202 is also used to calculate the unit computing power cost according to the total computing power value.

具體地,依據總算力值獲取單位算力值,並依據單位算力值、硬體成本、電費成本等計算出單位算力成本,其中硬體成本為礦機的購買成本或租賃成本,電費成本為使用礦機耗費的電量成本。 Specifically, the unit computing power value is obtained according to the total computing power value, and the unit computing power cost is calculated based on the unit computing power value, hardware cost, electricity cost, etc., where the hardware cost is the purchase cost or lease cost of the mining machine, and the electricity cost The electricity cost for using the mining machine.

進一步地,單位算力成本還包括技術成本、人力成本、維護成本等。 Furthermore, the unit cost of computing power also includes technology cost, labor cost, maintenance cost, etc.

運算模組202還用於計算區塊鏈網路中每個區塊的運算時間。 The calculation module 202 is also used to calculate the calculation time of each block in the blockchain network.

其中,以比特幣區塊鏈網路為例,比特幣區塊鏈是10分鐘左右建立一個區塊,並廣播發送給全網路各個節點,但是由於比特幣區塊鏈網路的總算力的波動,新的區塊的建立時間會有不同,例如10分鐘30秒、9分鐘30秒。 Among them, taking the Bitcoin blockchain network as an example, the Bitcoin blockchain creates a block in about 10 minutes and broadcasts it to all nodes in the entire network. However, due to the limited computing power of the Bitcoin blockchain network Fluctuations, the creation time of new blocks will be different, for example, 10 minutes and 30 seconds, 9 minutes and 30 seconds.

其中,該運算時間可為最新一個區塊的建立時間,或是最近一個時間段內多個區塊建立時間的平均值。 Wherein, the calculation time may be the establishment time of the latest block, or the average value of the establishment time of multiple blocks in the latest time period.

運算模組202還用於依據運算時間與單位算力成本,獲取單位攻擊成本。 The computing module 202 is also used to obtain the unit attack cost according to the computing time and the unit computing power cost.

例如,若本區塊鏈網路包括100個總算力,則攻擊者發起雙花攻擊,至少控制本區塊鏈網路中的超過50%的算力,例如51個算力,交易者發起一個交易之後,交易者向全區塊鏈網路發送一個真交易單,攻擊者產生一個假交易單,並利用共識機制中“少數服從多數”的原則,以實現假交易單取代真交易單並寫入主區塊鏈的區塊中,真交易單將被其他目標服務節點刪除或篡改。該雙花 攻擊需要的單位攻擊成本為P0=p1*51*p2,p1為每次成功交易成功確認所需的時間,也即每個新的區塊建立所需的時間,p2為單位算力的成本。 For example, if the blockchain network includes 100 total computing power, the attacker initiates a double-spend attack, at least controlling more than 50% of the computing power in the blockchain network, such as 51 computing power, the trader initiates a After the transaction, the trader sends a real transaction ticket to the entire blockchain network, and the attacker generates a fake transaction ticket, and uses the principle of "minority obeys the majority" in the consensus mechanism to replace the real transaction ticket with the fake transaction ticket and write In the block of the main blockchain, the real transaction order will be deleted or tampered with by other target service nodes. The double spend The unit attack cost required for the attack is P0=p1*51*p2, p1 is the time required for successful confirmation of each successful transaction, that is, the time required for each new block to be established, and p2 is the cost per unit of computing power.

運算模組202還用於依據所述虛擬貨幣類型獲取對應區塊鏈網路中單個區塊鏈節點的最大算力值;計算所述區塊鏈網路的單位算力成本;計算所述區塊鏈網路中每個區塊的運算時間;依據所述最大算力值、所述單位算力成本與所述運算時間獲取單位攻擊成本。 The operation module 202 is also used to obtain the maximum computing power value of a single blockchain node in the corresponding blockchain network according to the virtual currency type; calculate the unit computing power cost of the blockchain network; calculate the area The computing time of each block in the block chain network; the unit attack cost is obtained according to the maximum computing power value, the unit computing power cost and the computing time.

具體地,獲取對應區塊鏈網路中單個區塊鏈節點的最大算力值、所述單位算力成本與所述運算時間,則具有該最大算力值的該區塊鏈節點具有獲取該區塊鏈網路中記帳權的最大概率最大,攻擊者的單位攻擊則將單位攻擊成本不小於具有該最大算力值的節點的成本即可,即單位攻擊成本不小於最大算力值乘以單位算力成本及運算時間。 Specifically, obtain the maximum computing power value of a single blockchain node in the corresponding blockchain network, the unit computing power cost and the computing time, then the blockchain node with the maximum computing power value has the ability to obtain the The maximum probability of the accounting right in the blockchain network is the highest, and the unit attack cost of the attacker should not be less than the cost of the node with the maximum computing power value, that is, the unit attack cost should not be less than the maximum computing power value multiplied by Unit computing power cost and computing time.

調整模組203用於調整初始確認次數,以使總攻擊成本大於交易值。 The adjustment module 203 is used to adjust the number of initial confirmations so that the total attack cost is greater than the transaction value.

其中所述總攻擊成本等於所述初始確認次數乘以所述單位攻擊成本。 The total attack cost is equal to the multiplication of the initial confirmation times by the unit attack cost.

其中確認表示該交易被區塊鏈網路所記錄並確認,若初始確認次數為N,當交易發生時,記錄該筆交易的區塊將進行第一次確認,並在該區塊之後的鏈上的每一個區塊進行N-1確認。所有這些確認與交易都在區塊鏈上加上了時間戳記,使其不可逆轉且無法篡改。如果達到初始確認次數,則可以判斷本次交易成功。 The confirmation indicates that the transaction is recorded and confirmed by the blockchain network. If the initial number of confirmations is N, when the transaction occurs, the block recording the transaction will be confirmed for the first time, and the chain after the block will be confirmed for the first time. N-1 confirmations are performed on each block above. All these confirmations and transactions are time-stamped on the blockchain, making them irreversible and immutable. If the number of initial confirmations is reached, it can be judged that the transaction is successful.

依據單位攻擊成本及交易值調整初始確認次數,使總攻擊成本大於交易值,其中雙花攻擊總的成本為P,其中P=P0*N且P>M,其中N為確認次數,M為交易值。 Adjust the number of initial confirmations based on the unit attack cost and transaction value, so that the total attack cost is greater than the transaction value. The total cost of the double-spending attack is P, where P=P0*N and P>M, where N is the number of confirmations, and M is the transaction value.

在另一實施例中,調整模組203還用於依據週期獲得的貨幣價格、所述總算力值、所述單位算力成本、所述運算時間及所述區塊鏈網路中的單個 區塊鏈節點的最大算力值,若所述貨幣價格、所述總算力值、所述單位算力成本、所述運算時間或所述區塊鏈網路中的單個區塊鏈節點的最大算力值中的一個或多個發生變化,則對應調整初始確認次數。 In another embodiment, the adjustment module 203 is also used to obtain the currency price, the total computing power value, the unit computing power cost, the computing time, and the individual computing power in the blockchain network according to the cycle. The maximum computing power value of the blockchain node, if the currency price, the total computing power value, the unit computing power cost, the computing time or the maximum value of a single blockchain node in the blockchain network If one or more of the computing power values change, the number of initial confirmations will be adjusted accordingly.

由於區塊鏈虛擬貨幣交易時間比較長,在該交易時間段內影響交易值的因素較多,例如虛擬幣價格暴漲、礦機租金波動、電費調整、總算力值激增等,則需要依據最新的虛擬貨幣價格計算以獲取交易值或單位攻擊成本,並依據交易值或單位攻擊成本調整初始確認次數,以使總攻擊成本大於交易值。其中該週期可以依據設備能力及該時間段內虛擬貨幣價格波動進行同調整,例如,週期可為五分鐘。 Due to the relatively long trading time of blockchain virtual currency, there are many factors that affect the transaction value during this trading time period, such as skyrocketing virtual currency prices, fluctuations in mining machine rent, electricity bill adjustments, and surges in total computing power. The virtual currency price is calculated to obtain the transaction value or unit attack cost, and adjust the number of initial confirmations according to the transaction value or unit attack cost, so that the total attack cost is greater than the transaction value. The cycle can be adjusted according to the capability of the equipment and the price fluctuation of the virtual currency within the time period. For example, the cycle can be five minutes.

在另一實施例中,若區塊鏈網路中至少一個可信任區塊鏈節點的算力值大於其他區塊鏈節點的算力值,調整模組203還用於調整初始確認次數為基本確認次數。基本確認次數為交易完成的最少確認次數,例如區塊鏈網路或交易所規定的至少六次確認完成為一次交易,則基本確認次數為6次,其中可信任區塊鏈節點可以為交易者本身的區塊鏈節點,也可為交易者信任的其他區塊鏈節點。 In another embodiment, if the computing power of at least one trusted blockchain node in the blockchain network is greater than the computing power of other blockchain nodes, the adjustment module 203 is also used to adjust the number of initial confirmations to the basic number of confirmations. The number of basic confirmations is the minimum number of confirmations for the completion of a transaction. For example, if at least six confirmations are required by the blockchain network or an exchange to complete a transaction, then the number of basic confirmations is 6. Among them, trusted blockchain nodes can be traders Its own blockchain node can also be other blockchain nodes trusted by traders.

進一步地,初始確認次數不小於基本確認次數。 Further, the number of initial confirmations is not less than the number of basic confirmations.

交易模組204用於向區塊鏈網路提交交易資訊。 The transaction module 204 is used to submit transaction information to the blockchain network.

具體地,向區塊鏈網路廣播交易資訊,以使新的區塊記錄該交易資訊。 Specifically, the transaction information is broadcast to the blockchain network, so that a new block records the transaction information.

獲取模組201還用於獲取確認完成次數。 The obtaining module 201 is also used to obtain the confirmation completion times.

具體地,獲取發佈廣播資訊之後區塊鏈網路新建的區塊資料,進而獲取對應的確認完成次數。 Specifically, obtain the newly created block information of the blockchain network after the broadcast information is released, and then obtain the corresponding confirmation completion times.

在一實施例中,依據所述運算時間獲取查詢時間段,依據所述查詢時間段依次獲取確認完成次數。 In an embodiment, the query time period is obtained according to the operation time, and the confirmation completion times are sequentially obtained according to the query time period.

具體地,比特幣區塊鏈是10分鐘左右建立一個區塊,則第一個10分鐘可查詢第一次確認,第二個10分鐘可查詢第二次確認,依據時間段順序查詢,減少系統更新時間,減少等待時間,節省伺服器運算資源、降低成本。 Specifically, the Bitcoin blockchain takes about 10 minutes to create a block, so the first confirmation can be queried in the first 10 minutes, and the second confirmation can be queried in the second 10 minutes. Update time, reduce waiting time, save server computing resources, and reduce costs.

更新模組205用於依據所述確認完成次數更新交易進度。 The updating module 205 is used for updating the transaction progress according to the confirmation completion times.

例如,藉由已完成的確認次數計算交易進度,例如確認次數為5,已完成確認次數為1,則交易進度為20%。 For example, the transaction progress is calculated by the completed number of confirmations. For example, if the number of confirmations is 5 and the number of completed confirmations is 1, then the transaction progress is 20%.

顯示模組206用於即時顯示交易進度。 The display module 206 is used for real-time display of transaction progress.

在一實施例中,藉由進度條或在進度數值顯示交易進度。 In one embodiment, the transaction progress is displayed by a progress bar or a progress value.

判斷模組207用於判斷確認完成次數是否達到初始確認次數。 The judging module 207 is used for judging whether the number of confirmation completions reaches the initial number of confirmations.

具體地,判斷該區塊鏈網路中新增區塊的數量是否等於初始確認次數。 Specifically, it is judged whether the number of newly added blocks in the blockchain network is equal to the number of initial confirmation times.

判斷模組207還用於判斷所述交易過程是否存在錯誤資訊。 The judging module 207 is also used for judging whether there is error information in the transaction process.

在一實施例中,錯誤資訊為惡意節點篡改區塊中記錄的交易資訊,例如,交易人發佈的交易資訊為“A將虛擬貨幣轉至B”,惡意節點將區塊中的交易資訊修改為“A將虛擬貨幣轉至A”。 In one embodiment, the wrong information is that the malicious node tampers with the transaction information recorded in the block. For example, the transaction information issued by the trader is "A transfers the virtual currency to B", and the malicious node modifies the transaction information in the block as "A transfers the virtual currency to A".

交易模組204還用於終止交易。 The transaction module 204 is also used to terminate transactions.

在一實施例中,當完成確認次數達到初始確認次數之前,區塊鏈中區塊產生錯誤資訊,例如惡意節點篡改交易資訊,交易模組204終止正在進行的交易,避免財產損失,即區塊鏈網路中交易失敗,終止線下交易或虛擬貨幣相關聯的交易,例如未收到虛擬貨幣,則停止向交易人轉帳。 In one embodiment, when the number of completed confirmations reaches the initial number of confirmations, the blocks in the block chain generate error information, such as malicious nodes tampering with transaction information, the transaction module 204 terminates the ongoing transaction to avoid property loss, that is, the block If the transaction fails in the chain network, the offline transaction or the transaction associated with the virtual currency will be terminated. For example, if the virtual currency is not received, the transfer to the trader will be stopped.

告警模組208用於發送告警資訊。 The alarm module 208 is used for sending alarm information.

在一實施例中,告警模組208藉由調用語音單元40播放告警資訊。 In one embodiment, the alarm module 208 plays the alarm information by invoking the voice unit 40 .

請參閱圖3,為本發明一個實施方式提供的預防雙花攻擊的流程圖。根據不同的需求,該流程圖中步驟的順序可以改變,某些步驟可以省略。為了便於說明,僅示出了與本發明實施例相關的部分。 Please refer to FIG. 3 , which is a flow chart of preventing double-spending attacks provided by an embodiment of the present invention. According to different requirements, the order of the steps in the flowchart can be changed, and some steps can be omitted. For ease of description, only parts related to the embodiments of the present invention are shown.

如圖3所示,所述預防雙花攻擊的方法包括以下步驟。 As shown in Fig. 3, the method for preventing double-spending attack includes the following steps.

步驟S1:獲取交易資訊。 Step S1: Obtain transaction information.

其中交易資訊為待交易的資訊,該交易資訊包括虛擬貨幣類型及交易數量。 The transaction information is information to be traded, and the transaction information includes virtual currency type and transaction quantity.

其中所述虛擬貨幣為比特幣、乙太幣等,但不限於此。 Wherein said virtual currency is Bitcoin, Ether, etc., but not limited thereto.

在一實施例中,交易資訊還包括交易價格,該價格為虛擬貨幣買方或賣方對於該虛擬貨幣所擬定的價格,可以理解,該價格可能與各個交易平臺所定的價格不符合。 In one embodiment, the transaction information also includes a transaction price, which is the price proposed by the buyer or seller of the virtual currency for the virtual currency. It can be understood that the price may not match the price set by each trading platform.

步驟S2:依據所述虛擬貨幣類型獲取貨幣價格。 Step S2: Obtain the currency price according to the virtual currency type.

其中,貨幣價格可以為實際價格,即本時刻的交易價格,也可以為預估價格,即一個時段內交易價格的平均值。 Among them, the currency price can be the actual price, that is, the transaction price at this moment, or the estimated price, that is, the average value of the transaction price within a period of time.

在一實施例中,步驟S2具體包括步驟:獲取預設時間段的多個交易平臺的貨幣價格;對多個貨幣價格進行計算以獲取平均價格,其中平均價格即為所要求的貨幣價格。 In one embodiment, step S2 specifically includes the steps of: obtaining currency prices of multiple trading platforms in a preset time period; calculating multiple currency prices to obtain an average price, wherein the average price is the required currency price.

步驟S3:依據所述交易數量與所述貨幣價格獲取交易值。 Step S3: Obtain a transaction value according to the transaction quantity and the currency price.

其中所述交易值為交易的虛擬貨幣的實際價值,等於交易數量乘以貨幣價格。 Wherein the transaction value is the actual value of the virtual currency traded, which is equal to the transaction quantity multiplied by the currency price.

步驟S4:依據所述貨幣類型獲取對應區塊鏈網路的總算力值。 Step S4: Obtain the total computing power value of the corresponding blockchain network according to the currency type.

其中,算力是比特幣網路處理能力的度量單位,即為電腦計算雜湊函數輸出的速度。 Among them, computing power is the unit of measurement for the processing power of the Bitcoin network, that is, the speed at which the computer calculates the output of the hash function.

其中區塊鏈網路的總算力值可以為本時刻的實際算力值,也可以是過去一段時間內的算力平均值,也可以為預估算力值;實際算力值可直接獲取且不限定具體的獲取方式。例如,可根據預設時間內區塊鏈網路的曠工記帳權競爭所耗費的時間以及記帳難度,估算當前算力值;也可檢測本區塊鏈網路上的所有礦機的算力,獲得整體區塊鏈網路的當前算力值。 The total computing power value of the blockchain network can be the actual computing power value at this moment, the average computing power value in the past period of time, or the estimated power value; the actual computing power value can be obtained directly and The specific acquisition method is not limited. For example, the current computing power value can be estimated according to the time spent in the competition for absenteeism and bookkeeping rights in the blockchain network within the preset time and the difficulty of bookkeeping; it can also detect the computing power of all mining machines on the blockchain network to obtain The current computing power value of the overall blockchain network.

步驟S5:依據所述總算力值計算出單位算力成本。 Step S5: Calculate the unit computing power cost according to the total computing power value.

具體地,依據總算力值獲取單位算力值,並依據單位算力值、硬體成本、電費成本等計算出單位算力成本,其中硬體成本為礦機的購買成本或租賃成本,電費成本為使用礦機耗費的電量成本。 Specifically, the unit computing power value is obtained according to the total computing power value, and the unit computing power cost is calculated based on the unit computing power value, hardware cost, electricity cost, etc., where the hardware cost is the purchase cost or lease cost of the mining machine, and the electricity cost The electricity cost for using the mining machine.

進一步地,單位算力成本還包括技術成本、人力成本、維護成本等。 Furthermore, the unit cost of computing power also includes technology cost, labor cost, maintenance cost, etc.

步驟S6:計算所述區塊鏈網路中每個區塊的運算時間。 Step S6: Calculate the operation time of each block in the blockchain network.

其中,以比特幣區塊鏈網路為例,比特幣區塊鏈是10分鐘左右建立一個區塊,並廣播發送給全網路各個節點,但是由於比特幣區塊鏈網路的總算力的波動,新的區塊的建立時間也會有波動,例如10分鐘30秒、9分鐘30秒。 Among them, taking the Bitcoin blockchain network as an example, the Bitcoin blockchain creates a block in about 10 minutes and broadcasts it to all nodes in the entire network. However, due to the limited computing power of the Bitcoin blockchain network Fluctuations, the creation time of new blocks will also fluctuate, for example, 10 minutes and 30 seconds, 9 minutes and 30 seconds.

其中,該運算時間可為最新一個區塊的建立時間,或是最近一個時間段內多個區塊建立時間的平均值。 Wherein, the calculation time may be the establishment time of the latest block, or the average value of the establishment time of multiple blocks in the latest time period.

步驟S7:依據所述運算時間與所述單位算力成本,獲取單位攻擊成本。 Step S7: According to the operation time and the unit computing power cost, the unit attack cost is obtained.

例如,若本區塊鏈網路包括100個總算力,則攻擊者發起雙花攻擊,至少控制本區塊鏈網路中的超過50%的算力,例如51個算力,交易者發起一個交易之後,交易者向全區塊鏈網路發送一個真交易單,攻擊者產生一個假交易單,並利用共識機制中“少數服從多數”的原則,以實現假交易單取代真交易單並寫入主區塊鏈的區塊中,真交易單將被其他目標服務節點刪除。 For example, if the blockchain network includes 100 total computing power, the attacker initiates a double-spend attack, at least controlling more than 50% of the computing power in the blockchain network, such as 51 computing power, the trader initiates a After the transaction, the trader sends a real transaction ticket to the entire blockchain network, and the attacker generates a fake transaction ticket, and uses the principle of "minority obeys the majority" in the consensus mechanism to replace the real transaction ticket with the fake transaction ticket and write In the block of the main blockchain, the real transaction order will be deleted by other target service nodes.

該雙花攻擊需要的單位攻擊成本為P0=p1*51*p2,p1為每次成功交易成功確認所需的時間,也即每個新的區塊建立所需的時間,p2為單位算力的成本。 The unit attack cost required for this double-spending attack is P0=p1*51*p2, p1 is the time required for each successful transaction to be confirmed successfully, that is, the time required for each new block to be established, and p2 is the unit computing power the cost of.

在另一實施例中,單位攻擊成本的具體步驟包括:依據所述虛擬貨幣類型獲取對應區塊鏈網路中單個區塊鏈節點的最大算力值;計算所述區塊鏈網路的單位算力成本;計算所述區塊鏈網路中每個區塊的運算時間;依據所述最大算力值、所述單位算力成本與所述運算時間獲取單位攻擊成本。 In another embodiment, the specific steps of the unit attack cost include: obtaining the maximum computing power value of a single blockchain node in the corresponding blockchain network according to the virtual currency type; calculating the unit of the blockchain network computing power cost; calculating the computing time of each block in the blockchain network; obtaining the unit attack cost according to the maximum computing power value, the unit computing power cost and the computing time.

具體地,獲取對應區塊鏈網路中單個區塊鏈節點的最大算力值、所述單位算力成本與所述運算時間,則具有該最大算力值的區塊鏈節點具有獲取該區塊鏈網路中記帳權的最大概率,攻擊者的單位攻擊成本不小於具有該最大算力值的節點的成本即可,即單位攻擊成本不小於最大算力值乘以單位算力成本及運算時間。 Specifically, obtain the maximum computing power value of a single blockchain node in the corresponding blockchain network, the unit computing power cost and the computing time, then the blockchain node with the maximum computing power value has the right to obtain the area The maximum probability of accounting rights in the block chain network, the unit attack cost of the attacker is not less than the cost of the node with the maximum computing power value, that is, the unit attack cost is not less than the maximum computing power value multiplied by the unit computing power cost and calculation time.

步驟S8:調整初始確認次數,以使所述總攻擊成本大於所述交易值。 Step S8: Adjust the number of initial confirmations so that the total attack cost is greater than the transaction value.

其中所述總攻擊成本等於所述初始確認次數乘以所述單位攻擊成本。 The total attack cost is equal to the multiplication of the initial confirmation times by the unit attack cost.

其中確認表示該交易被區塊鏈網路所記錄並確認,若確認次數為N,當交易發生時,記錄該筆交易的區塊將進行第一次確認,並在該區塊之後的鏈上的每一個區塊進行N-1確認。所有這些確認與交易都在區塊鏈上加上了時間戳記,使其不可逆轉且無法篡改。如果達到初始確認次數,則可以判斷本次交易成功。 The confirmation indicates that the transaction is recorded and confirmed by the blockchain network. If the number of confirmations is N, when the transaction occurs, the block recording the transaction will be confirmed for the first time, and will be confirmed on the chain after the block. N-1 confirmations are performed for each block of . All these confirmations and transactions are time-stamped on the blockchain, making them irreversible and immutable. If the number of initial confirmations is reached, it can be judged that the transaction is successful.

依據單位攻擊成本及交易值調整初始確認次數,使總攻擊成本大於交易值,其中雙花攻擊總的成本為P,其中P=P0*N且P>M,其中N為確認次數,M為交易值。 Adjust the number of initial confirmations based on the unit attack cost and transaction value, so that the total attack cost is greater than the transaction value. The total cost of the double-spending attack is P, where P=P0*N and P>M, where N is the number of confirmations, and M is the transaction value.

在另一實施例中,步驟S8之後還包括步驟:若區塊鏈網路中至少一個可信任區塊鏈節點的算力值大於其他區塊鏈節點的算力值,則調整初始確認次數為基本確認次數。 In another embodiment, after step S8, a step is also included: if the computing power value of at least one trusted blockchain node in the blockchain network is greater than the computing power value of other blockchain nodes, then adjusting the number of initial confirmations is Basic number of confirmations.

其中基本確認次數為交易完成的最少確認次數,例如,區塊鏈網路或交易所規定的至少六次確認完成為一次交易,則基本確認次數為6次,保證安全交易的算力為可信任區塊鏈節點具有超過50%的算力。其中可信任區塊鏈節點可以為交易人本身的區塊鏈節點,也可以交易人信任的區塊鏈節點。 Among them, the number of basic confirmations is the minimum number of confirmations for transaction completion. For example, if at least six confirmations required by the blockchain network or the exchange are completed as one transaction, then the number of basic confirmations is 6 times, and the computing power to ensure safe transactions is trustworthy Blockchain nodes have more than 50% computing power. The trusted blockchain node can be the blockchain node of the trader itself, or a blockchain node trusted by the trader.

在另一實施例中,還包括步驟:週期獲取貨幣價格、所述總算力值、所述單位算力成本、所述運算時間及所述區塊鏈網路中的單個區塊鏈節點的最大算力值;若所述貨幣價格、所述總算力值、所述單位算力成本、所述運算時間或所述區塊鏈網路中的單個區塊鏈節點的最大算力值中的一個或多個發生變化,則對應調整初始確認次數。 In another embodiment, it also includes the step of periodically obtaining the currency price, the total computing power value, the unit computing power cost, the computing time and the maximum value of a single blockchain node in the blockchain network. computing power value; if one of the currency price, the total computing power value, the unit computing power cost, the computing time or the maximum computing power value of a single blockchain node in the blockchain network or more changes, the initial number of confirmations will be adjusted accordingly.

由於區塊鏈虛擬貨幣交易時間比較長,在該交易時間段內影響交易值的因素較多,例如虛擬幣價格暴漲、礦機租金波動、電費調整、總算力值激增等,則需要依據調整因素計算以獲取交易值或單位攻擊成本,並依據交易值或單位攻擊成本調整初始確認次數,以使總攻擊成本大於交易值。進一步地,初始確認次數不小於基本確認次數。 Due to the relatively long trading time of blockchain virtual currency, there are many factors that affect the transaction value during this trading time period, such as skyrocketing virtual currency prices, fluctuations in mining machine rent, electricity bill adjustments, and surges in total computing power, etc., which need to be adjusted based on factors Calculate to obtain the transaction value or unit attack cost, and adjust the number of initial confirmations according to the transaction value or unit attack cost, so that the total attack cost is greater than the transaction value. Further, the number of initial confirmations is not less than the number of basic confirmations.

步驟S9:向所述區塊鏈網路提交交易資訊。 Step S9: Submit transaction information to the blockchain network.

具體地,向區塊鏈網路廣播交易資訊,以使新的區塊記錄該交易資訊。 Specifically, the transaction information is broadcast to the blockchain network, so that a new block records the transaction information.

步驟S10:獲取確認完成次數。 Step S10: Obtain the confirmation completion times.

具體地,獲取發佈廣播資訊之後區塊鏈網路新建的區塊資料,進而獲取對應的確認完成次數。 Specifically, obtain the newly created block information of the blockchain network after the broadcast information is released, and then obtain the corresponding confirmation completion times.

在一實施例中,步驟S10具體包括如下:依據所述運算時間獲取查詢時間段;依據所述查詢時間段依次獲取確認完成次數。 In an embodiment, step S10 specifically includes the following steps: acquiring a query time period according to the operation time; and sequentially acquiring confirmation completion times according to the query time period.

具體地,比特幣區塊鏈是10分鐘建立一個區塊,則第一個10分鐘可查詢第一次確認,第二個10分鐘可查詢第二次確認,依據時間段順序查詢,減少系統更新時間,減少等待時間,節省伺服器運算資源、降低成本。 Specifically, the Bitcoin blockchain creates a block in 10 minutes, then the first confirmation can be queried in the first 10 minutes, and the second confirmation can be queried in the second 10 minutes, and the query is based on the order of the time period to reduce system updates Time, reduce waiting time, save server computing resources, and reduce costs.

進一步地,所述方法還包括步驟:依據所述確認完成次數更新交易進度;即時顯示所述交易進度。 Further, the method further includes the steps of: updating the transaction progress according to the confirmed completion times; and displaying the transaction progress in real time.

例如,藉由已完成的確認次數計算交易進度,例如確認次數為5,已完成確認次數為1,則交易進度為20%。 For example, the transaction progress is calculated by the completed number of confirmations. For example, if the number of confirmations is 5 and the number of completed confirmations is 1, then the transaction progress is 20%.

藉由顯示單元即時顯示交易進度。 The transaction progress is displayed in real time through the display unit.

步驟S11:判斷確認完成次數是否達到初始確認次數。 Step S11: Judging whether the number of confirmation completions has reached the initial number of confirmations.

具體地,判斷該區塊鏈網路中新增區塊的數量是否等於初始確認次數。 Specifically, it is judged whether the number of newly added blocks in the blockchain network is equal to the number of initial confirmation times.

若為是,進入步驟S12;若為否,進入步驟S13。 If yes, go to step S12; if no, go to step S13.

步驟S12:判定交易完成。 Step S12: It is determined that the transaction is completed.

進一步地,步驟S12還包括步驟:查看交易資訊,並判斷交易是否正常:若正常,則提示交易完成;若非正常,則發送告警指示。 Further, step S12 also includes the step of: checking the transaction information, and judging whether the transaction is normal: if it is normal, prompting that the transaction is completed; if not, sending an alarm indication.

步驟S13:判斷所述交易過程是否存在錯誤資訊。 Step S13: Determine whether there is error information in the transaction process.

在一實施例中,區塊鏈網路中惡意節點利用記帳權修改區塊中的交易內容,例如交易內容中將“A匯款至B”修改為“A匯款至C”。 In one embodiment, malicious nodes in the blockchain network use accounting rights to modify the transaction content in the block, for example, in the transaction content, "A remits money to B" is changed to "A remits money to C".

在另一實施例中,區塊鏈網路中的惡意節點作為交易節點一併向網路中廣播兩筆交易,一筆交易發給自己(為了提高攻擊成功率,這筆交易增加足夠的手續費),一筆交易發給買方或賣方。由於發送給自己的交易中含有較高的手續費,會被礦工打包成區塊的概率比較高。 In another embodiment, the malicious node in the blockchain network acts as a transaction node and broadcasts two transactions to the network, and one transaction is sent to itself (in order to improve the attack success rate, this transaction adds enough handling fee ), a transaction is issued to a buyer or seller. Since the transaction sent to itself contains a higher handling fee, the probability of being packaged into a block by miners is relatively high.

若為否,進入步驟S11。 If not, go to step S11.

若為是,執行步驟S14:終止該交易。 If yes, execute step S14: terminate the transaction.

例如,在區塊鏈網路中的線上交易失敗,則終止線下交易或虛擬貨幣相關聯的交易,例如未收到虛擬貨幣,則停止向交易人轉帳。 For example, if the online transaction in the blockchain network fails, the offline transaction or the transaction associated with the virtual currency will be terminated. For example, if the virtual currency is not received, the transfer to the trader will be stopped.

步驟S15:發出告警資訊。 Step S15: sending out warning information.

藉由聲光、語音、人機界面等形式發送告警資訊,以通知相關負責人處理該異常情況。 Send alarm information in the form of sound and light, voice, human-machine interface, etc., to notify the relevant person in charge to deal with the abnormal situation.

上述預防雙花攻擊的方法與裝置依據交易值及總攻擊成本調整確認次數,以使總攻擊成本大於交易值,從而預防雙花攻擊的產生,以保證大額交易的安全性,一併減少小額交易的確認次數,以減少小額交易的交易時間,從而增加小額交易的便利性。 The above-mentioned method and device for preventing double-spending attacks adjusts the number of confirmations according to the transaction value and the total attack cost, so that the total attack cost is greater than the transaction value, thereby preventing the occurrence of double-spend attacks, ensuring the security of large-amount transactions, and reducing small-amount transactions. The number of transaction confirmations to reduce the transaction time of small transactions, thereby increasing the convenience of small transactions.

進一步地,上述預防雙花攻擊的方法與裝置藉由即時顯示或語音播報交易進度,以使交易者即時瞭解交易狀態,還藉由發現即時檢測交易資訊,以判斷交易資訊中是否存在錯誤資訊,並將錯誤資訊藉由告警資訊提醒,以實現及時終止交易,減少或避免交易損失。 Further, the above-mentioned method and device for preventing double-spend attacks use real-time display or voice broadcast of the transaction progress to enable traders to know the transaction status in real time, and detect whether there is any wrong information in the transaction information by detecting the transaction information in real time. And the error information is reminded by the alarm information, so as to realize the timely termination of the transaction and reduce or avoid the transaction loss.

本發明所提供的方法,不需要更動區塊鏈的架構與演算流程,易於實現。 The method provided by the present invention does not need to change the architecture and calculation process of the block chain, and is easy to implement.

對於本領域技術人員而言,顯然本發明不限於上述示範性實施例的細節,而且在不背離本發明的精神或基本特徵的情況下,能夠以其他的具體形式實現本發明。因此,無論從哪一點來看,均應將實施例看作是示範性的,而且是非限制性的,本發明的範圍由所附請求項而不是上述說明限定,因此旨在將落在請求項的等同要件的含義與範圍內的所有變化涵括在本發明內。不應將請求項中的任何附圖標記視為限制所涉及的請求項。此外,顯然“包括”一詞不排除其他器或步驟,單數不排除複數。 It will be apparent to those skilled in the art that the invention is not limited to the details of the above-described exemplary embodiments, but that the invention can be embodied in other specific forms without departing from the spirit or essential characteristics of the invention. Therefore, no matter from any point of view, the embodiments should be regarded as exemplary and non-restrictive, and the scope of the present invention is defined by the appended claims rather than the above description, so it is intended to All changes within the meaning and range of equivalents of the elements are included in the present invention. Any reference sign in a claim should not be construed as limiting the claim to which it relates. Furthermore, it is obvious that the word "comprising" does not exclude other means or steps, and the singular does not exclude the plural.

以上所述,僅為本發明的較佳實施例,並非是對本發明作任何形式上的限定。另外,本領域技術人員還可在本發明精神內做其它變化,當然,這些依據本發明精神所做的變化,都應包含在本發明所要求保護的範圍之內。 The above descriptions are only preferred embodiments of the present invention, and are not intended to limit the present invention in any form. In addition, those skilled in the art can also make other changes within the spirit of the present invention. Of course, these changes made according to the spirit of the present invention should be included within the scope of protection claimed by the present invention.

S1-S15:步驟 S1-S15: Steps

Claims (7)

一種預防雙花攻擊的方法,其改良在於,所述方法包括:獲取待交易的交易資訊,所述交易資訊包括虛擬貨幣類型及交易數量;依據所述虛擬貨幣類型獲取貨幣價格;依據所述交易數量與所述貨幣價格獲取交易值;依據所述虛擬貨幣類型獲取對應區塊鏈網路的單位攻擊成本;調整初始確認次數,以使總攻擊成本大於所述交易值,其中所述總攻擊成本等於所述初始確認次數乘以所述單位攻擊成本;及向所述區塊鏈網路提交所述交易資訊;其中,“依據所述虛擬貨幣類型獲取對應區塊鏈網路的單位攻擊成本”具體包括:依據所述虛擬貨幣類型獲取對應區塊鏈網路的總算力值;計算所述區塊鏈網路的單位算力成本;計算所述區塊鏈網路的每個區塊的運算時間;依據所述運算時間與所述單位算力成本,獲取單位攻擊成本;或依據所述虛擬貨幣類型獲取對應區塊鏈網路中單個區塊鏈節點的最大算力值;計算所述區塊鏈網路的單位算力成本;計算所述區塊鏈網路的每個區塊的運算時間;依據所述最大算力值、所述單位算力成本及所述運算時間獲取單位攻擊成本;其中,所述方法還包括步驟:週期獲取所述貨幣價格、所述總算力值、所述單位算力成本、所述運算時間及所述區塊鏈網路中的單個區塊鏈節點的最大算力值; 若所述貨幣價格、所述總算力值、所述單位算力成本、所述運算時間或所述區塊鏈網路中的單個區塊鏈節點的最大算力值中的一個或多個發生變化,則對應調整所述初始確認次數;其中,所述方法還包括步驟:若所述區塊鏈網路中至少一個可信任區塊鏈節點的算力值大於其他區塊鏈節點的算力值,則調整初始確認次數為基本確認次數,所述基本確認次數為交易完成的最少確認次數。 A method for preventing double-spending attacks, the improvement of which is that the method includes: obtaining transaction information to be traded, the transaction information including virtual currency type and transaction quantity; obtaining currency prices according to the virtual currency type; according to the transaction The quantity and the currency price obtain the transaction value; obtain the unit attack cost of the corresponding blockchain network according to the virtual currency type; adjust the number of initial confirmations so that the total attack cost is greater than the transaction value, wherein the total attack cost Equal to the number of times of initial confirmation multiplied by the unit attack cost; and submit the transaction information to the blockchain network; wherein, "obtain the unit attack cost of the corresponding blockchain network according to the virtual currency type" It specifically includes: obtaining the total computing power value of the corresponding blockchain network according to the virtual currency type; calculating the unit computing power cost of the blockchain network; calculating the operation of each block of the blockchain network time; obtain the unit attack cost based on the operation time and the unit computing power cost; or obtain the maximum computing power value of a single blockchain node in the corresponding blockchain network according to the virtual currency type; calculate the area The unit computing power cost of the blockchain network; calculate the computing time of each block of the blockchain network; obtain the unit attack cost according to the maximum computing power value, the unit computing power cost and the computing time ; Wherein, the method also includes the step of periodically obtaining the currency price, the total computing power value, the unit computing power cost, the computing time and the single blockchain node in the blockchain network Maximum computing power value; If one or more of the currency price, the total computing power value, the unit computing power cost, the computing time or the maximum computing power value of a single blockchain node in the blockchain network occurs change, then correspondingly adjust the number of initial confirmations; wherein, the method also includes a step: if the computing power value of at least one trusted blockchain node in the blockchain network is greater than the computing power of other blockchain nodes value, adjust the initial number of confirmations to the basic number of confirmations, and the number of basic confirmations is the minimum number of confirmations for transaction completion. 如請求項1所述之預防雙花攻擊的方法,其中,向所述區塊鏈網路提交所述交易資訊之後還包括:獲取完成確認次數;判斷完成確認次數是否達到所述初始確認次數:若為是,則判定交易完成。 The method for preventing double-spend attacks as described in claim 1, wherein, after submitting the transaction information to the blockchain network, it further includes: obtaining the number of completion confirmations; judging whether the number of completion confirmations reaches the initial number of confirmations: If yes, it is determined that the transaction is completed. 如請求項2所述之預防雙花攻擊的方法,其中,若所述完成確認次數未達到所述初始確認次數,則判斷交易過程是否存在錯誤資訊:若為是,終止該交易並發出告警資訊。 The method for preventing double-spending attacks as described in Claim 2, wherein, if the number of completion confirmations does not reach the number of initial confirmations, it is judged whether there is error information in the transaction process: if yes, the transaction is terminated and an alarm message is issued . 如請求項2所述之預防雙花攻擊的方法,其中,“獲取完成確認次數”具體包括:依據所述運算時間獲取查詢時間段;依據所述查詢時間段依次獲取確認完成次數。 The method for preventing double-spending attacks as described in Claim 2, wherein "obtaining the number of completed confirmations" specifically includes: obtaining the query time period according to the operation time; and sequentially obtaining the number of confirmation completions according to the query time period. 如請求項4所述之預防雙花攻擊的方法,其中,所述方法還包括步驟:依據所述確認完成次數更新交易進度;即時顯示所述交易進度。 The method for preventing double-spending attacks as described in Claim 4, wherein the method further includes the steps of: updating the transaction progress according to the number of confirmed completions; and displaying the transaction progress in real time. 一種預防雙花攻擊的裝置,其改良在於,包括:記憶體,所述記憶體上存儲有若干電腦程式;處理器,所述處理器用於執行所述記憶體中存儲的電腦程式時實現如請求項1至5任一項所述的預防雙花攻擊的方法的步驟。 A device for preventing double-spending attacks, which is improved in that it includes: a memory, on which several computer programs are stored; a processor, which is used to execute the computer programs stored in the memory to implement The steps of the method for preventing double-spending attacks described in any one of items 1 to 5. 一種電腦可讀存儲介質,其改良在於,其上存儲有電腦程式,所述電腦程式被處理器執行時實現如請求項1至5中任一項所述的預防雙花攻擊的方法。 A computer-readable storage medium, the improvement of which is that a computer program is stored thereon, and when the computer program is executed by a processor, the method for preventing double-spending attacks as described in any one of claims 1 to 5 is implemented.
TW109102248A 2020-01-21 2020-01-21 Method and device for preventing a double spend attack and a computer readable memory medium TWI804707B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW109102248A TWI804707B (en) 2020-01-21 2020-01-21 Method and device for preventing a double spend attack and a computer readable memory medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW109102248A TWI804707B (en) 2020-01-21 2020-01-21 Method and device for preventing a double spend attack and a computer readable memory medium

Publications (2)

Publication Number Publication Date
TW202129583A TW202129583A (en) 2021-08-01
TWI804707B true TWI804707B (en) 2023-06-11

Family

ID=78282723

Family Applications (1)

Application Number Title Priority Date Filing Date
TW109102248A TWI804707B (en) 2020-01-21 2020-01-21 Method and device for preventing a double spend attack and a computer readable memory medium

Country Status (1)

Country Link
TW (1) TWI804707B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109508968A (en) * 2018-10-25 2019-03-22 常州唯康信息科技有限公司 Block catenary system and its control method

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109508968A (en) * 2018-10-25 2019-03-22 常州唯康信息科技有限公司 Block catenary system and its control method

Also Published As

Publication number Publication date
TW202129583A (en) 2021-08-01

Similar Documents

Publication Publication Date Title
WO2020155789A1 (en) Blockchain-based certificate storage method and apparatus
EP3776437B1 (en) Blockchain-based asset transfer method and apparatus, and electronic device
EP3594884A1 (en) Electronic bill management method, device, and storage medium
US20200118131A1 (en) Database transaction compliance
US20180075422A1 (en) Financial management systems and methods
TWM561279U (en) Blockchain system and node server for processing strategy model scripts of financial assets
CN106530088A (en) Method for trading stock product based on block chain security nodes
CN111309594B (en) System testing method, device, equipment and storage medium
WO2019127532A1 (en) Blockchain-based crowdfunding information processing method and device, storage medium and electronic device
WO2020015635A1 (en) Distributed voting system, method and apparatus, and computer device and readable storage medium
TW202026997A (en) Blockchain-based product purchase method and apparatus
US20190378162A1 (en) Systems and methods for enforcing advertising standards and digital advertisement measurements
TW202042138A (en) Blockchain-based payment method and device
CN110597916B (en) Data processing method and device based on block chain, storage medium and terminal
TW201935299A (en) Blockchain system, node server and method for processing strategy model scripts of financial assets
WO2018192931A1 (en) Delivery versus payment mechanism
CN110738783A (en) System, method, device, equipment and readable storage medium for updating voting data
CN111292057A (en) Service processing method based on block chain
CN110941840B (en) Data processing method, system and terminal
EP4143689A1 (en) Blockchain network risk management universal blockchain data model
CN110838067B (en) Real estate transaction data processing method, device, server and storage medium
CN111274597A (en) Data processing method and equipment
TWI804707B (en) Method and device for preventing a double spend attack and a computer readable memory medium
CN112016114B (en) Intelligent contract generating method based on cryptocurrency, related equipment and storage medium
CN113222590B (en) Method, apparatus and computer readable storage medium for preventing double-flower attack