WO2019179258A1 - 一种工作量证明运算芯片优化的方法和系统 - Google Patents
一种工作量证明运算芯片优化的方法和系统 Download PDFInfo
- Publication number
- WO2019179258A1 WO2019179258A1 PCT/CN2019/074497 CN2019074497W WO2019179258A1 WO 2019179258 A1 WO2019179258 A1 WO 2019179258A1 CN 2019074497 W CN2019074497 W CN 2019074497W WO 2019179258 A1 WO2019179258 A1 WO 2019179258A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- data
- node
- bit
- dag
- internal cache
- Prior art date
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/50—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using hash chains, e.g. blockchains or hash trees
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5027—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/06—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols the encryption apparatus using shift registers or memories for block-wise or stream coding, e.g. DES systems or RC4; Hash functions; Pseudorandom sequence generators
- H04L9/0643—Hash functions, e.g. MD5, SHA, HMAC or f9 MAC
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/32—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
- H04L9/3236—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions
- H04L9/3239—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions involving non-keyed hash functions, e.g. modification detection codes [MDCs], MD5, SHA or RIPEMD
Definitions
- the invention relates to the technical field of blockchain, workload proof, encrypted digital coin mining and integrated system, in particular to a method and system for optimizing the operation chip of the ETC mining work.
- Hashing is a type of cryptographic operation that outputs a unique fixed-length binary result based on any size of text or binary input. Even if the input content changes slightly, the output will undergo a significant change. It is almost impossible to derive the input of the hash operation from the output of the hash operation.
- Proof of Work is a consensus mechanism used by mainstream encryption digital coins such as Bitcoin and Ethereum.
- the basic feature is that a large number of hash operations are needed to find the conditions under certain difficulty values. The hash value.
- the mining workload proof algorithm used by a class of encrypted digital coins such as Ethereum is called Ethash.
- the conventional implementation of the algorithm is implemented. Including: GPU-based implementation (see Figure 1) and implementation of a dedicated chip based on an external memory access interface (see Figure 2), both require frequent and large-scale access to external memory, so generally need to configure larger memory, The frequently accessed data in the algorithm is pre-computed and stored, so that the hash operation for the workload proof is completed by directly accessing the pre-stored data in the memory during the execution of the algorithm.
- the algorithm stipulates that as the time passes, the external memory capacity required by the algorithm becomes larger and larger, resulting in higher system complexity and cost.
- the technical problem to be solved by the embodiments of the present invention is to provide a method for optimizing the workload verification computing chip, which is applicable to a type of encrypted digital currency such as Ethereum.
- the method of the present invention comprises the following three key steps: key step 1, pre-generating internal CACHE data; key step 2, generating DAG node data in real time according to pre-generated internal CACHE data; key step 3, generated in real time
- the DAG node data is hashed, and the workload is proved according to the operation result.
- the application provides a method for optimizing the workload verification computing chip, comprising the steps of:
- the internal CACHE data is generated in advance and stored in the internal storage unit;
- the step A comprises:
- A1 obtaining the block number and seed data
- A2 Generate internal CACHE data by hash operation according to the block number and the seed data.
- the step A1 comprises:
- A11 Obtain current block number data, divide the data by a fixed value, obtain epoch number data, and initialize a 256-bit all-zero seed data;
- A12 performing an epoch-order SHA3-256 encryption operation on the seed data to obtain final seed data; wherein the seed data has a length of 256 bits.
- the step A2 comprises:
- A21 Obtain the number of nodes in the internal CACHE data according to the block number, and perform SHA3-512 operation on the seed data to obtain the 0th node of the internal CACHE data, and SHA3 the 0th node of the internal CACHE data.
- the -512 operation obtains the first node, and so on, until the node fills the cell space within the internal CACHE data, and each node has its own unsigned 32-bit node number;
- A22 starting from the 0th node, sequentially performing the 32nd bit of the node on the node to summarize the sum of the internal CACHE data, and obtaining the value as the node number of the CACHE data;
- the previous node of the node and the node value are operated in a bitwise manner; wherein if the node number is 0, the previous node and the node value of the last node of the internal CACHE data are taken. Different operation operation;
- the SHA3-512 operation operation is performed on the result, and the result data is replaced by the node data; the total internal CACHE data is generated 3 times in total.
- the step A22 further comprises: periodically storing the internal CACHE data in the internal storage unit during periodic access to the internal CACHE data.
- the step B comprises:
- the node number is used to count the number of points in the internal CACHE data, and the value is used as the serial number in the CACHE data to obtain the corresponding node value;
- the lower 32 bits of the value are different from the sequence number of the node, and the SHA3-512 encryption operation is performed;
- the step C includes:
- the 256-bit header data transmitted from the mining pool and the self-generated 64-bit random data are spliced into a 320-bit data, and the SHA3-512 encryption operation is performed to obtain a 512-bit source data, and the data is copied twice. Filled with a 1024-bit mixed data, the DAG is indexed from 0 according to the mixed length, and the total number of nodes in the DAG is full_mix;
- the mixed data is indexed from number 0 every 32 bits, and each 32 bits is generated by a FNV operation to generate a 32-bit data, and a total of eight 32-bit data are generated, and spliced into 256-bit data according to the generation order.
- the total capacity of the internal storage unit in step A is not less than 20 MBytes.
- the total capacity of the internal storage unit is 64 MBytes.
- the generating the DAG node data in real time in step B comprises: generating node data of one or more DAG nodes in real time.
- the number of nodes of the DAG node data is 256.
- the step C includes: performing one or more hash operations correspondingly according to the node data of the one or more DAG nodes to perform workload proof.
- the plurality of hash operations are performed simultaneously, and the number of the hash operations is 256.
- the application also provides an optimization system for the workload proof computing chip, based on the above method, comprising:
- Unit 1 one or more internal CACHE data generating units
- Unit 2 one or more internal storage units
- Unit 3 an internal storage access control unit
- Unit 4 one or more DAG node data generating units
- Unit 5 one or more hash operation units
- the internal storage unit is connected to the internal storage access control unit; the internal CACHE data generating unit is connected to the internal storage access control unit; the DAG node data generating unit and the internal storage access control unit Connected; the DAG node data generating unit is connected to the corresponding hash computing unit.
- the internal storage unit is a Static Random Access Memory (SRAM).
- SRAM Static Random Access Memory
- the total capacity of the internal storage unit is not less than 20 MBytes.
- the total capacity of the internal storage unit is 64 MBytes.
- the data output port of each of the internal storage units has a data width of 512 bits.
- the internal storage access control unit is comprised of one or more system crossbar switches.
- the number of the DAG node data generating units is 256.
- the number of the hash operation units is 256.
- the present invention includes the following advantages over the prior art: 1. Elimination of dependence on external memory, thereby reducing system complexity. 2. Reduced system cost. 3. Eliminate a large number of pins with external memory, and the integrated system package based on the method or system is simplified. 4. Products based on this method or system are easy to mass produce.
- FIG. 1 is a schematic diagram of a conventional technical solution based on a GPU and an external memory
- FIG. 2 is a schematic diagram of a prior art technical solution based on a dedicated chip and an external memory
- FIG. 3 is a flowchart of the operation of the present invention.
- FIG. 5 is a flow chart of generating DAG data in the embodiment
- Figure 6 is a flow chart of the workload proof process in the embodiment
- Figure 7 is a schematic diagram of the system in the embodiment.
- a method for optimizing the operation amount of the cryptographic digital coin mining work such as the Ethanol coin including:
- the internal cache data generating unit (refer to FIG. 7) generates internal CACHE data by using a block number and seed data by acquiring a current block number data, and dividing the data by a fixed value to obtain The epoch data simultaneously initializes a 256-bit all-zero seed data; performs an epoch-order SHA3-256 cryptographic operation on the seed data to obtain the final seed data, which is 256 bits in length.
- the internal cache data generating unit obtains the number of nodes inside the internal CACHE data according to the block number, and performs the SHA3-512 operation operation on the seed data to obtain the 0th node of the internal CACHE data, and the internal CACHE data.
- 0 nodes do the SHA3-512 operation to obtain the first node, and so on, until the node fills the cell space in the internal CACHE data, and each node has its own unsigned 32-bit node. Point number.
- Periodic access to internal CACHE data is achieved by an internal storage access control unit (refer to FIG. 7) and internal CACHE data is periodically stored in internal storage units.
- the internal storage unit is a Static Random Access Memory (SRAM). The specific process is as follows: starting from the 0th node, the sum of the lower 32 bits of the node and the sum of the internal CACHE data is taken from all the nodes in turn, and the value is obtained as a node number of the CACHE data to obtain a node value.
- DAG node data generation the DAG node data generating unit (refer to FIG. 7) periodically reads the data in the internal storage unit, and generates DAG node data by one or more hash operations, and the specific process refers to FIG. 5 According to the block number, the DAG data length is obtained.
- the DAG data is consecutively numbered starting from 0 according to the node size from the 0 address, and the number format is unsigned 32 bits as the node number; for each node, the following operations are performed:
- the node number takes the remainder of the summary point in CACHE, and uses this value as the sequence number in the CACHE data to obtain the corresponding node value.
- the hash operation unit (refer to FIG. 7) periodically performs hash operation on the DAG node data, and the output result thereof is used for the Ethash algorithm in the Ethereum blockchain system. Proof of workload, the specific process is shown in Figure 6:
- the operation continuously performs the workload proof operation, such as 16 operation nodes.
- the w-th node can perform traversal operation within 0xw000000000000000 ⁇ 0xwfffffffffff, w takes the value 0x0 ⁇ 0xf) into a 320-bit data, and it is SHA3-512 Encryption operation, obtain a 512-bit source data, use the data to copy twice to fill a 1024-bit mixed data, and index the DAG according to the mixed length (that is, 1024 bits) from 0, and set the total number of nodes in the DAG to be full_mix;
- the mixed data is indexed from number 0 every 32 bits, and each 32 bits are generated by a FNV operation to generate a 32-bit data, and a total of eight 32-bit data are generated, which are spliced into 256-bit data in the order of generation.
- composite data
- one or more internal CACHE data generating units S601 (S6011 to S601N), one internal storage access control unit S602, one or more internal storage units S603 (S6031 to S603N), one or more DAGs
- the node data generating unit S604 (S6041 to S604N), one or more hash operation units S605 (S6051 to S605N).
- the internal CACHE data generating unit S601 is connected to the internal storage access control unit S602;
- the internal storage access control unit S602 is connected to the internal storage unit S603;
- the internal storage unit S603 is connected to the DAG node data generating unit S604;
- the DAG node data generating unit S604 is connected to the hash operation unit S605.
- N(N ⁇ 2) internal CACHE data generating units S601, one internal storage access control unit S602, N(N ⁇ 2) internal storage units S603, N(N ⁇ 2) DAG node data are used.
- the generation unit S604, and the N(N ⁇ 2) hash operation unit S605 are described as an example.
- the internal CACHE data generation unit S601 (S6011 to S601N) periodically obtains the initial seed data (seed), it is hashed.
- the arithmetic processing generates internal CACHE data and stores it in the internal storage unit S603 (S6031 to S603N), and periodically reads the internal CACHE data in the internal storage unit S603 (S6031 to S603N) through the internal storage access control unit S602.
- the DAG node data generating unit S604 (S6041 to S604N) generates DAG node data by one or more hash operations, and periodically performs DAG node data in the hash operation unit S605 (S6051 to S605N).
- the Greek operation the output of which is used to prove the workload of the digital currency.
- the system implementation manner includes: a dedicated integrated system chip and a field programmable gate array FPGA, but the implementation manner is not limited to these types.
Landscapes
- Engineering & Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Power Engineering (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Memory System Of A Hierarchy Structure (AREA)
- Storage Device Security (AREA)
Abstract
本发明提供了一种工作量证明运算芯片优化的方法和系统,涉及区块链、工作量证明、加密数字币挖矿和集成系统技术领域。本发明所述的方法包括如下3个关键步骤,包括步骤:A、预先生成内部CACHE数据,并存储在内部存储单元中;B、根据预先生成的内部CACHE数据,实时生成每次哈希运算需要的DAG结点数据;C、通过实时生成的DAG结点数据进行哈希运算,根据运算结果进行工作量证明。通过这种方法,消除了对外部存储器的依赖,从而降低了系统的复杂度。
Description
本发明涉及区块链、工作量证明、加密数字币挖矿和集成系统技术领域,特别是涉及以太币挖矿工作量证明运算芯片优化的方法和系统。
哈希运算是一类加密运算,它根据任意大小的文本或二进制输入内容,对应输出唯一的固定长度的二进制结果,即使输入内容发生微小的变化,输出也将发生面目全非的重大变化。几乎不可能从哈希运算的输出,反向得出哈希运算的输入。
工作量证明(Proof of Work,简称POW),是比特币、以太币等主流加密数字币采用的一种共识机制,基本特征是需要进行大量的哈希运算,在特定难度值条件下找到符合条件的哈希值。
与比特币所采用的SHA3-256(一种哈希运算)挖矿工作量证明算法不同,以太币等一类加密数字币使用的挖矿工作量证明算法叫Ethash,目前该算法的常规实现方式包括:基于GPU的实现方式(参见图1)和基于带外部访存接口的专用芯片的实现方式(参见图2),均需要频繁且大量地访问外部存储器,因此一般需要配置较大内存,将算法中所需要频繁访问的数据进行预先运算和存储起来,从而在算法执行过程中通过直接访问内存中的预存数据来完成用于工作量证明的哈希运算。而且,算法规定,随着的时间的推移,该算法所需要的外部存储器容量越来越大,导致系统复杂度和成本越来越高。
发明内容
本发明实施例所要解决的技术问题是,提供一种工作量证明运算 芯片优化的方法,适用于以太币等一类加密数字币。本发明所述的方法包括如下3个关键步骤,关键步骤1,预先生成内部CACHE数据;关键步骤2,根据预先生成的内部CACHE数据,实时生成DAG结点数据;关键步骤3,通过实时生成的DAG结点数据进行哈希运算,根据运算结果做工作量证明。通过这种方法,消除了对外部存储器的依赖,从而降低了系统的复杂度,降低了系统成本,消除了大量与外部存储器的引脚,基于该方法或系统的集成系统封装得以简化,基于该方法或系统的产品易于进行大批量生产。具体地:
本申请提供一种工作量证明运算芯片优化的方法,包括步骤:
A、预先生成内部CACHE数据,并存储在内部存储单元中;
B、根据预先生成的内部CACHE数据,实时生成每次哈希运算需要的DAG结点数据;
C、通过实时生成的DAG结点数据进行哈希运算,根据运算结果进行工作量证明。
优选地,所述步骤A包括:
A1、获取区块号及种子数据;
A2、根据所述区块号及种子数据通过哈希运算生成内部CACHE数据。
优选地,所述步骤A1包括:
A11、获取当前区块号数据,将该数据整除一个固定数值,得到纪元号数据,同时初始化一个256位全0的种子数据;
A12、对种子数据做纪元号次SHA3-256加密运算操作,获得最终的种子数据;其中,所述种子数据的长度为256位。
优选地,所述步骤A2包括:
A21、根据区块号获得内部CACHE数据内部的结点个数,并对种子数据做SHA3-512运算操作获得内部CACHE数据的第0个结点,对内部CACHE数据的第0个结点做SHA3-512运算操作获得第1个结点,依此类推,直至结点填充满内部CACHE数据内的单元空间,且此时每个结点都有各自的无符号32位结点序号;
A22、从第0个结点开始依次对所有结点执行取该结点的第32位对内部CACHE数据的总结点数取余,将该值作为CACHE数据的结点序号获得一个结点值;取该结点的前一个结点与结点值按位异做运算操作;其中,若该结点编号为0,则取内部CACHE数据的最后一个结点的前一个结点与结点值按位异做运算操作;
对结果做SHA3-512运算操作,将结果替换该结点数据;共执行3次,生成最终的内部CACHE数据。
优选地,所述步骤A22还包括:在对内部CACHE数据的周期性访问时将内部CACHE数据周期性地存储在内部存储单元中。
优选地,所述步骤B包括:
针对所述无符号32位结点序号中的每个结点:
B1、结点序号对内部CACHE数据中总结点个数取余,并以此值作为CACHE数据中的序号,获取对应结点数值;
B2、该数值低32位与该结点的序号相异或,并做SHA3-512加密运算;
B3、设置一个无符号32位变量i,初始化为0;将序号与i相异或之后获得第32位数据;以及取结点的第(i%16)个32位数据;对这所述第32位数据以及所述第(i%16)个32位数据做FNV运算操作,结果对内部CACHE数据的总结点数取模,结果产生一个新的序号a;其中,(i%16)表示i对16取余;
B4、将该结点的每32位数据与内部CACHE数据的序号为a的结点相应位置的32位做FNV运算操作;其中所述FNV运算操作共16次,总共完成512位,可并行执行;
B5、i值加1,重复执行B3至B4共256次;
B6、对该结点做SHA3-512加密运算,生成最终的DAG结点数据。
优选地,所述步骤C,包括:
C1、将矿池传输来的256位头数据与自产生的64位随机数据拼接成一个320位的数据,对其做SHA3-512加密运算,获得一个512 位源数据,用该数据复制两次充满一个1024位的混合数据,对DAG按混合长度从0开始做索引,设DAG中结点总个数为full_mix;
C2、设置一个无符号32位变量i,初始为0;将源数据的第32位与该变量相异或获得异或之后的第32位数据,取mix的第(i%32)个32位数据,将所述异或之后的第32位数据及所述第(i%32)个32位数据做FNV运算操作,结果对full_mix取余,获得一个结点值index;(i%32)表示i对32取余;
C3、取得DAG中序号为index的2个相邻结点数据——这一步需要读取内部存储单元获得128字节数据;
C4、将混合数据的每32位与DAG中序号为index的2个相邻结点数据的每32位做FNV运算操作共32次,可并行,获得新的混合数据;
C5、i值加1,重复执行C2至C4共64次;
C6、将混合数据按每32位做从编号0开始做索引,每4个32位用FNV运算操作生成一个32位数据,共计生成8个32位数据,按生成顺序拼接为256位数据,记为复合数据;
C7、将复合数据与源数据拼接;其中,所述复合数据在高位;并对拼接值做SHA3_256运算操作,得到最终的结果;其中,若该结果与矿池传输来的target进行比较,满足指定约定要求即为工作量证明计算成功。
优选地,步骤A所述内部存储单元的总容量不小于20MBytes。
优选地,所述内部存储单元的总容量为64MBytes。
优选地,步骤B所述实时生成DAG结点数据,包括:实时同时生成一个或多个DAG结点的结点数据。
优选地,所述DAG结点数据的结点个数为256个。
优选地,所述步骤C,包括:根据所述一个或多个DAG结点的结点数据,相应地进行一个或多个哈希运算,以进行工作量证明。
优选地,所述多个哈希运算同时进行,且所述哈希运算个数为256个。
本申请还提供一种工作量证明运算芯片的优化系统,基于上述的方法,包括:
单元1,一个或多个内部CACHE数据生成单元;
单元2,一个或多个内部存储单元;
单元3,一个内部存储访问控制单元;
单元4,一个或多个DAG结点数据生成单元;
单元5,一个或多个哈希运算单元;
其中,所述内部存储单元与所述内部存储访问控制单元相连;所述内部CACHE数据生成单元与所述内部存储访问控制单元相连;所述DAG结点数据生成单元与所述内部存储访问控制单元相连;所述DAG结点数据生成单元与相应的所述哈希运算单元相连。
优选地,所述内部存储单元为静态随机存取存储器(Static Random-Access Memory,SRAM)。
优选地,所述内部存储单元的总容量为不小于20MBytes。
优选地,所述内部存储单元的总容量为64MBytes。
优选地,每个所述内部存储单元的数据输出端口的数据宽度为512位。
优选地,所述内部存储访问控制单元由一个或多个系统交叉开关构成。
优选地,所述DAG结点数据生成单元的数量为256个。
优选地,所述哈希运算单元的数量为256个。
综上所述,与现有技术相比,本发明包括以下优点:1、消除了对外部存储器的依赖,从而降低了系统的复杂度。2、降低了系统成本。3、消除了大量与外部存储器的引脚,基于该方法或系统的集成系统封装得以简化。4、基于该方法或系统的产品易于进行大批量生产。
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面 将对实施例或现有技术描述中所需要使用的附图做一简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例。
图1是现有基于GPU和外部存储器的技术方案示意图;
图2是现有基于专用芯片和外部存储器的技术方案示意图;
图3是本发明的运算流程图;
图4是实施例中的内部CACHE数据生成流程图;
图5是实施例中的DAG数据生成流程图;
图6是实施例中的工作量证明过程流程图;
图7是实施例中的系统示意图。
下面将结合本申请实施例中的附图对本申请进行说明。
实施例一
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
实施例一
详细介绍本发明实施例提供的一种工作量证明运算芯片优化的方法。
参照图3,提供了以太币等一类加密数字币挖矿工作量证明运算芯片优化的方法,包括:
S101,生成内部CACHE数据,即内部cache数据生成单元(参考图7)使用区块号和seed数据通过哈希运算生成内部CACHE数据:获取当前区块号数据,将该数据整除一个固定数值,得到纪元号数据,同时初始化一个256位全0的种子(seed)数据;对种子数据做纪元号次SHA3-256加密运算操作,获得最终的种子数据,长度为256位。 参照图4,内部cache数据生成单元根据区块号获得内部CACHE数据内部的结点个数,对种子数据做SHA3-512运算操作获得内部CACHE数据的第0个结点,对内部CACHE数据的第0个结点做SHA3-512运算操作获得第1个结点,依此类推,直至结点填充满内部CACHE数据内的单元空间,且此时每个结点都有各自的无符号32位结点序号。通过内部存储访问控制单元(参考图7)实现对内部CACHE数据的周期性访问并将内部CACHE数据周期性地存储在内部存储单元中。所述内部存储单元为静态随机存取存储器(Static Random-Access Memory,SRAM)。具体流程如下,从第0个结点开始依次对所有结点执行取该结点的低32位对内部CACHE数据的总结点数取余,将该值作为CACHE数据的结点序号获得一个结点值;取该结点的前一个结点(如果该结点编号为0,则取内部CACHE数据的最后一个结点),与结点值按位异做运算操作;对结果做SHA3-512运算操作,将结果替换该结点数据;共执行3次,生成最终的内部CACHE数据。
S102,DAG结点数据生成:DAG节点数据生成单元(参考图7)周期性地读取内部存储单元中的数据,通过一次或多次哈希运算,生成DAG结点数据,具体流程参照图5,根据块号获得DAG数据长度,对DAG数据从0地址开始按结点大小从0开始做连续编号,编号格式为无符号32位,作为结点序号;针对每个结点,做如下操作:
(1)结点序号对CACHE中总结点个数取余,并以此值作为CACHE数据中的序号,获取对应结点数值。
(2)该数值低32位与该结点的序号相异或,并做SHA3-512加密运算;
(3)设置一个无符号32位变量i,初始化为0;将序号与i相异或,获得32位数据;取结点的第(i%16)个32位数据;对这两个32位数据做FNV运算操作,结果对内部CACHE数据的总结点数取模,结果产生一个新的序号a;
(4)将该结点的每32位数据与内部CACHE数据的序号为a的结 点相应位置的32位做FNV运算操作(共16次,总共完成512位,可并行执行);
(5)i值加1,重复执行(3)至(4)共256次;
(6)对该结点做SHA3-512加密运算,生成最终结点。
S103,碰撞运算和工作量证明:哈希运算单元(参考图7)对DAG结点数据周期性地进行哈希运算,其输出结果,用于以太坊区块链系统中的Ethash算法出块的工作量证明,具体过程参照图6:
(1)将矿池传输来的256位头数据与自产生的64位随机数据(实际处理中将根据并行处理的计算单元序号将此64bit范围均分,各自结点在所属范围内按增1运算不断进行工作量证明运算,如16个运算结点,w号结点可在0xw000000000000000~0xwfffffffffffffff内进行遍历运算,w取值0x0~0xf)拼接成一个320位的数据,对其做SHA3-512加密运算,获得一个512位源数据,用该数据复制两次充满一个1024位的混合数据,对DAG按混合长度(即1024bit)从0开始做索引,设DAG中结点总个数为full_mix;
(2)设置一个无符号32位变量i,初始为0;将源数据的低32位与该变量相异或,取mix的第(i%32)个32位数据,将这两个32位数据做FNV运算操作,结果对full_mix取余,获得一个结点值index;
(3)取得DAG中序号为index的2个相邻结点数据——这一步需要读取内部存储单元获得128字节数据;
(4)将混合数据的每32位与DAG中序号为index的2个相邻结点数据的每32位做FNV运算操作(共32次,可并行),获得新的混合数据;
(5)i值加1,重复执行(2)至(4)共64次;
(6)将混合数据按每32位做从编号0开始做索引,每4个32位用FNV运算操作生成一个32位数据,共计生成8个32位数据,按生成顺序拼接为256位数据,记为复合数据:
(7)将复合数据与源数据拼接(复合数据在高位),对拼接值做SHA3_256运算操作,得到最终结果。若该结果与矿池传输来的target 进行比较,满足某种约定要求即为计算成功。
实施例二
详细介绍本发明实施例提供的一种工作量证明运算芯片优化的系统。
参照图7,具体包括:一个或多个内部CACHE数据生成单元S601(S6011至S601N)、一个内部存储访问控制单元S602、一个或多个内部存储单元S603(S6031至S603N)、一个或多个DAG结点数据生成单元S604(S6041至S604N)、一个或多个哈希运算单元S605(S6051至S605N)。
所述内部CACHE数据生成单元S601和内部存储访问控制单元S602相连;
所述内部存储访问控制单元S602和内部存储单元S603相连;
所述内部存储单元S603和DAG结点数据生成单元S604相连;
所述DAG结点数据生成单元S604和哈希运算单元S605相连。
本实施例中以N(N≧2)个内部CACHE数据生成单元S601,一个内部存储访问控制单元S602,N(N≧2)个内部存储单元S603,N(N≧2)个DAG结点数据生成单元S604,以及N(N≧2)个哈希运算单元S605为例介绍,在内部CACHE数据生成单元S601(S6011至S601N)周期性地获得初始种子数据(seed)后,对其进行哈希运算处理,生成内部CACHE数据,并存储于内部存储单元S603(S6031至S603N),通过内部存储访问控制单元S602,周期性地读取内部存储单元S603(S6031至S603N)中的内部CACHE数据,在DAG结点数据生成单元S604(S6041至S604N)中通过一次或多次哈希运算,生成DAG结点数据,在哈希运算单元S605(S6051至S605N)中对DAG结点数据周期性地进行哈希运算,其输出结果,用于加密数字币的工作量证明。
基于本发明上述系统的实施例中,其系统实现方式包括:专用集成系统芯片、现场可编程门阵列FPGA,但实现方式不限于这些类型。
上面描述的内容可以单独地或者以各种方式组合起来实施,而这些变型方式都在本发明的保护范围之内。
以上实施例仅用以说明本发明的技术方案而非限制,仅仅参照较佳实施例对本发明进行了详细说明。本领域的普通技术人员应当理解,可以对本发明的技术方案进行修改或者等同替换,而不脱离本发明技术方案的精神和范围,均应涵盖在本发明的权利要求范围当中。
Claims (21)
- 一种工作量证明运算芯片优化的方法,其特征在于,包括步骤:A、预先生成内部CACHE数据,并存储在内部存储单元中;B、根据预先生成的内部CACHE数据,实时生成每次哈希运算需要的DAG结点数据;C、通过实时生成的DAG结点数据进行哈希运算,根据运算结果进行工作量证明。
- 根据权利要求1所述的方法,其特征在于,所述步骤A包括:A1、获取区块号及种子数据;A2、根据所述区块号及种子数据通过哈希运算生成内部CACHE数据。
- 根据权利要求2所述的方法,其特征在于,所述步骤A1包括:A11、获取当前区块号数据,将该数据整除一个固定数值,得到纪元号数据,同时初始化一个256位全0的种子数据;A12、对种子数据做纪元号次SHA3-256加密运算操作,获得最终的种子数据;其中,所述种子数据的长度为256位。
- 根据权利要求2所述的方法,其特征在于,所述步骤A2包括:A21、根据区块号获得内部CACHE数据内部的结点个数,并对种子数据做SHA3-512运算操作获得内部CACHE数据的第0个结点,对内部CACHE数据的第0个结点做SHA3-512运算操作获得第1个结点,依此类推,直至结点填充满内部CACHE数据内的单元空间,且此时每个结点都有各自的无符号32位结点序号;A22、从第0个结点开始依次对所有结点执行取该结点的第32位对内部CACHE数据的总结点数取余,将该值作为CACHE数据的结点序号获得一个结点值;取该结点的前一个结点与结点值按位异做运算操作;其中,若该结点编号为0,则取内部CACHE数据的最后一个结点的前一个结点与结点值按位异做运算操作;对结果做SHA3-512运算操作,将结果替换该结点数据;共执行 3次,生成最终的内部CACHE数据。
- 根据权利要求4所述的方法,其特征在于,所述步骤A22还包括:在对内部CACHE数据的周期性访问时将内部CACHE数据周期性地存储在内部存储单元中。
- 根据权利要求4所述的方法,其特征在于,所述步骤B包括:针对所述无符号32位结点序号中的每个结点:B1、结点序号对内部CACHE数据中总结点个数取余,并以此值作为CACHE数据中的序号,获取对应结点数值;B2、该数值低32位与该结点的序号相异或,并做SHA3-512加密运算;B3、设置一个无符号32位变量i,初始化为0;将序号与i相异或之后获得第32位数据;以及取结点的第(i%16)个32位数据;对这所述第32位数据以及所述第(i%16)个32位数据做FNV运算操作,结果对内部CACHE数据的总结点数取模,结果产生一个新的序号a;其中,(i%16)表示i对16取余;B4、将该结点的每32位数据与内部CACHE数据的序号为a的结点相应位置的32位做FNV运算操作;其中所述FNV运算操作共16次,总共完成512位,可并行执行;B5、i值加1,重复执行B3至B4共256次;B6、对该结点做SHA3-512加密运算,生成最终的DAG结点数据。
- 根据权利要求6所述的方法,其特征在于,所述步骤C,包括:C1、将矿池传输来的256位头数据与自产生的64位随机数据拼接成一个320位的数据,对其做SHA3-512加密运算,获得一个512位源数据,用该数据复制两次充满一个1024位的混合数据,对DAG按混合长度从0开始做索引,设DAG中结点总个数为full_mix;C2、设置一个无符号32位变量i,初始为0;将源数据的第32位与该变量相异或获得异或之后的第32位数据,取mix的第(i%32) 个32位数据,将所述异或之后的第32位数据及所述第(i%32)个32位数据做FNV运算操作,结果对full_mix取余,获得一个结点值index;(i%32)表示i对32取余;C3、取得DAG中序号为index的2个相邻结点数据——这一步需要读取内部存储单元获得128字节数据;C4、将混合数据的每32位与DAG中序号为index的2个相邻结点数据的每32位做FNV运算操作共32次,可并行,获得新的混合数据;C5、i值加1,重复执行C2至C4共64次;C6、将混合数据按每32位做从编号0开始做索引,每4个32位用FNV运算操作生成一个32位数据,共计生成8个32位数据,按生成顺序拼接为256位数据,记为复合数据;C7、将复合数据与源数据拼接;其中,所述复合数据在高位;并对拼接值做SHA3_256运算操作,得到最终的结果;其中,若该结果与矿池传输来的target进行比较,满足指定约定要求即为工作量证明计算成功。
- 根据权利要求1所述的方法,其特征在于,步骤A所述内部存储单元的总容量不小于20Mbytes。
- 根据权利要求8所述的方法,其特征在于,所述内部存储单元的总容量为64Mbytes。
- 根据权利要求1所述的方法,其特征在于,步骤B所述实时生成每次哈希运算需要的DAG结点数据,包括:实时同时生成一个或多个DAG结点的结点数据。
- 根据权利要求10所述的方法,其特征在于,所述DAG结点数据的结点个数为256个。
- 根据权利要求10所述的方法,其特征在于,所述步骤C,包括:根据所述一个或多个DAG结点的结点数据,相应地进行一个或多个哈希运算,以进行工作量证明。
- 根据权利要求12所述的方法,其特征在于,所述多个哈希 运算同时进行,且所述哈希运算个数为256个。
- 一种工作量证明运算芯片优化的系统,基于权利要求1-13任一项所述的方法,其特征在于,包括:单元1,一个或多个内部CACHE数据生成单元;单元2,一个或多个内部存储单元;单元3,一个内部存储访问控制单元;单元4,一个或多个DAG结点数据生成单元;单元5,一个或多个哈希运算单元;其中,所述内部存储单元与所述内部存储访问控制单元相连;所述内部CACHE数据生成单元与所述内部存储访问控制单元相连;所述DAG结点数据生成单元与所述内部存储访问控制单元相连;所述DAG结点数据生成单元与相应的所述哈希运算单元相连。
- 根据权利要求14所述的系统,其特征在于,所述内部存储单元为静态随机存取存储器。
- 根据权利要求15所述的系统,其特征在于,所述内部存储单元的总容量不小于20MBytes。
- 根据权利要求16所述的系统,其特征在于,所述内部存储单元的总容量为64MBytes。
- 根据权利要求14所述的系统,其特征在于,每个所述内部存储单元的数据输出端口的数据宽度为512位。
- 根据权利要求14所述的系统,其特征在于,所述内部存储访问控制单元由一个或多个系统交叉开关构成。
- 根据权利要求14所述的系统,其特征在于,所述DAG结点数据生成单元的数量为256个。
- 根据权利要求14所述的系统,其特征在于,所述哈希运算单元的数量为256个。
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810244178.9A CN108491269A (zh) | 2018-03-23 | 2018-03-23 | 一种工作量证明运算芯片优化的方法和电路 |
CN201810244178.9 | 2018-03-23 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2019179258A1 true WO2019179258A1 (zh) | 2019-09-26 |
Family
ID=63319618
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2019/074497 WO2019179258A1 (zh) | 2018-03-23 | 2019-02-01 | 一种工作量证明运算芯片优化的方法和系统 |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN108491269A (zh) |
WO (1) | WO2019179258A1 (zh) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112214448A (zh) * | 2020-10-10 | 2021-01-12 | 中科声龙科技发展(北京)有限公司 | 异质集成工作量证明运算芯片的数据动态重构电路及方法 |
Families Citing this family (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108491269A (zh) * | 2018-03-23 | 2018-09-04 | 中科声龙科技发展(北京)有限公司 | 一种工作量证明运算芯片优化的方法和电路 |
CN109412814A (zh) * | 2018-09-27 | 2019-03-01 | 国网天津市电力公司 | 一种能源区块链中对抗算力集中的方法 |
CN109522739B (zh) * | 2018-10-09 | 2020-11-20 | 北京医拍智能科技有限公司 | 一种基于区块链哈希算法的抗攻击处理方法及装置 |
TWI676134B (zh) * | 2018-12-03 | 2019-11-01 | 資富電子股份有限公司 | 用於以查表法為基礎之區塊鏈中工作量證明的加速演算架構 |
CN110569021B (zh) * | 2019-09-06 | 2023-09-12 | 湖南天河国云科技有限公司 | 一种抗asic挖矿的工作量证明方法 |
CN113282803B (zh) * | 2021-06-17 | 2022-06-17 | 浙江毫微米科技有限公司 | 工作量证明算法优化方法、装置、计算机设备和存储介质 |
CN113282802B (zh) * | 2021-06-17 | 2022-06-24 | 浙江毫微米科技有限公司 | 工作量证明算法优化方法、装置、计算机设备和存储介质 |
CN114003552B (zh) * | 2021-12-30 | 2022-03-29 | 中科声龙科技发展(北京)有限公司 | 工作量证明运算方法、工作量证明芯片及上位机 |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20160210263A1 (en) * | 2012-11-21 | 2016-07-21 | International Business Machines Corporation | Scheduling and execution of dag-structured computation on rdma-connected clusters |
CN106897351A (zh) * | 2016-12-29 | 2017-06-27 | 北京瑞卓喜投科技发展有限公司 | 有向无环图型区块链的生成方法及系统 |
CN107579814A (zh) * | 2017-08-03 | 2018-01-12 | 北京比特大陆科技有限公司 | 工作量证明的计算方法的装置、计算芯片、挖矿机 |
CN108491269A (zh) * | 2018-03-23 | 2018-09-04 | 中科声龙科技发展(北京)有限公司 | 一种工作量证明运算芯片优化的方法和电路 |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US10796000B2 (en) * | 2016-06-11 | 2020-10-06 | Intel Corporation | Blockchain system with nucleobase sequencing as proof of work |
CN107342980B (zh) * | 2017-06-05 | 2020-05-19 | 杭州云象网络技术有限公司 | 一种公有链节点工作量证明的可信验证方法及系统 |
-
2018
- 2018-03-23 CN CN201810244178.9A patent/CN108491269A/zh active Pending
-
2019
- 2019-02-01 WO PCT/CN2019/074497 patent/WO2019179258A1/zh active Application Filing
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20160210263A1 (en) * | 2012-11-21 | 2016-07-21 | International Business Machines Corporation | Scheduling and execution of dag-structured computation on rdma-connected clusters |
CN106897351A (zh) * | 2016-12-29 | 2017-06-27 | 北京瑞卓喜投科技发展有限公司 | 有向无环图型区块链的生成方法及系统 |
CN107579814A (zh) * | 2017-08-03 | 2018-01-12 | 北京比特大陆科技有限公司 | 工作量证明的计算方法的装置、计算芯片、挖矿机 |
CN108491269A (zh) * | 2018-03-23 | 2018-09-04 | 中科声龙科技发展(北京)有限公司 | 一种工作量证明运算芯片优化的方法和电路 |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112214448A (zh) * | 2020-10-10 | 2021-01-12 | 中科声龙科技发展(北京)有限公司 | 异质集成工作量证明运算芯片的数据动态重构电路及方法 |
CN112214448B (zh) * | 2020-10-10 | 2024-04-09 | 声龙(新加坡)私人有限公司 | 异质集成工作量证明运算芯片的数据动态重构电路及方法 |
Also Published As
Publication number | Publication date |
---|---|
CN108491269A (zh) | 2018-09-04 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2019179258A1 (zh) | 一种工作量证明运算芯片优化的方法和系统 | |
US20200177366A1 (en) | Homomorphic data encryption method and apparatus for implementing privacy protection | |
US20200412544A1 (en) | Devices and circuitry for computing hash values | |
KR102137956B1 (ko) | 블록 마이닝 방법 및 장치 | |
US20200067695A1 (en) | Hardware masked substitution box for the data encryption standard | |
WO2019218730A1 (zh) | 一种工作量证明运算芯片核心计算部件的优化系统及方法 | |
US10320558B2 (en) | Method and apparatus for a secure and deduplicated write once read many virtual disk | |
US10833847B2 (en) | Cryptographic hash generated using data parallel instructions | |
JP2017515195A (ja) | 断熱量子計算を介してデジタル論理制約問題を解く | |
CN113221193B (zh) | 基于gpu的sm2数字签名与验签快速实现方法及系统 | |
CN108768656B (zh) | 一种基于哈希算法的数据校验方法 | |
CN108959168B (zh) | 基于片上内存的sha512全流水电路及其实现方法 | |
JP2016535310A (ja) | 素数の生成および記憶のための方法および装置 | |
TW202143076A (zh) | 用於執行散列算法的電路和方法 | |
CN116318660A (zh) | 一种消息扩展与压缩方法及相关装置 | |
TW201624268A (zh) | 輸入-相依隨機數產生裝置及其方法 | |
Shen et al. | High-throughput GPU implementation of Dilithium post-quantum digital signature | |
Têtu et al. | A standalone FPGA-Based miner for Lyra2REv2 cryptocurrencies | |
US20210226775A1 (en) | Memory optimization for nested hash operations | |
Vandervelden et al. | SHA 3 and Keccak variants computation speeds on constrained devices | |
Mihaljevic et al. | A family of fast dedicated one-way hash functions based on linear cellular automata over GF (q) | |
KR20050065976A (ko) | Sha-1 해쉬값 연산 장치 및 방법 | |
JP2008136193A (ja) | 署名生成装置、署名検証装置、それらの方法及びプログラム | |
Shoufan et al. | A novel cryptoprocessor architecture for chained Merkle signature scheme | |
WO2023000577A1 (zh) | 一种数据压缩方法、装置及电子设备和存储介质 |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 19770556 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
32PN | Ep: public notification in the ep bulletin as address of the adressee cannot be established |
Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 19.01.2021) |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 19770556 Country of ref document: EP Kind code of ref document: A1 |