Circuit Architecture
By introducing the design of extraction units and temporary storage units into the circuit architecture, the problem of the large size of the traditional Scrypt algorithm proof-of-work circuit structure is solved, and the storage space saving and computing efficiency improvement are achieved.
Patent Information
- Application Number
- CN201910067872.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-01-24
- Publication Date
- 2025-04-01
- Estimated Expiration
- 2039-01-24
AI Technical Summary
The traditional circuit structure that implements the proof of work of the Scrypt algorithm has a large volume due to the large storage space, making it difficult to effectively save storage space.
A circuit architecture is proposed, including a control module, an operation module and a storage module. By extracting part of the data in the first data as storage data, the number of stored data is reduced, and when the corresponding first data cannot be found, the data in the temporary storage unit and the storage module are used for iterative calculations to generate the next second data.
By reducing the amount of stored data, the space occupied by the storage module in the circuit structure is saved, the volume of the circuit structure is reduced, and the computing efficiency is improved.
Smart Images

Figure CN109799961B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of blockchain technology, and more particularly to a circuit architecture. Background Art
[0002] In the proof-of-work method of blockchain technology, the first stage of the Scrypt algorithm proof-of-work method generates a set amount of first data, and in the second stage, the first data is randomly used to generate second data. The amount of first data is large, which occupies a large storage space, making the circuit architecture used to implement the Scrypt algorithm proof-of-work method larger in volume. Summary of the invention
[0003] In view of this, the present disclosure proposes a circuit architecture to solve the problem that the circuit structure of the traditional Scrypt algorithm proof-of-work method has a large volume due to excessive storage space.
[0004] According to one aspect of the present disclosure, a circuit architecture is provided, wherein the circuit architecture is used to perform a Scrypt algorithm proof-of-work task, wherein the circuit architecture comprises a control module, a computing module, and a storage module, wherein the control module comprises an extraction unit, and the computing module comprises a temporary storage unit.
[0005] During the first stage of the control module controlling the operation module to execute the task, the extraction unit is used to extract part of the first data and store the data in the storage module as storage data, wherein the amount of the storage data is less than the amount of the first data;
[0006] In the second stage process in which the control module controls the computing module to execute the task, the control module is used to:
[0007] When the first data corresponding to the current second data cannot be found in the stored data, storing the current second data in the temporary storage unit;
[0008] The operation module is controlled to obtain the next second data of the current second data according to the storage data in the storage module and the current second data in the temporary storage unit.
[0009] In a possible implementation, the control module is used to control the operation module to obtain the next second data of the current second data according to the storage data in the storage module and the current second data, including:
[0010] The control module is used to control the operation module to determine the first data corresponding to the current second data according to the storage data in the storage module that is closest to the current second data; and to obtain the next second data of the current second data according to the first data corresponding to the current second data in the storage module and the current second data in the temporary storage unit.
[0011] In a possible implementation manner, the first data is an ordered sequence, and the extraction unit is further configured to:
[0012] Determining a storage address of the stored data according to a sequence number of the stored data;
[0013] The control module is also used for:
[0014] Generate an index address according to data at a preset digit in the current second data;
[0015] The index address is searched in the storage address, and the first data corresponding to the current second data is determined according to the search result.
[0016] In a possible implementation, the control module is used to control the operation module to determine the first data corresponding to the current second data according to the storage data in the storage module that is closest to the current second data, including:
[0017] The control module is used to control the operation module to determine the difference between the storage address in the storage module closest to the index address and the index address; according to the number of iterations determined by the difference, the storage data in the storage address closest to the index address is iteratively operated to obtain the first data corresponding to the index address.
[0018] In a possible implementation, the extraction unit is used to extract part of the data from the first data and store it in the storage module as the storage data, including any one of the following:
[0019] The extraction unit is used to extract the storage data from the first data according to a preset extraction interval and store it in the storage module;
[0020] The extraction unit is used to extract the storage data in the first data according to a preset sequence number range and store it in the storage module;
[0021] The extraction unit is used to randomly extract a preset number of storage data from the first data and store them in the storage module.
[0022] In the disclosed embodiment, when the first data corresponding to the current second data cannot be found in each storage data, the operation module can, under the control of the control module, determine the first data corresponding to the current second data according to the storage data closest to the current second data in the storage module; and obtain the next second data of the current second data according to the first data corresponding to the current second data in the storage module and the current second data in the temporary storage unit. Each second data can be calculated based on the storage data, saving the space occupied by the storage module in the circuit structure.
[0023] Further features and aspects of the present disclosure will become apparent from the following detailed description of exemplary embodiments with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate exemplary embodiments, features, and aspects of the disclosure and, together with the description, serve to explain the principles of the disclosure.
[0025] Figure 1 A block diagram showing a circuit architecture according to an embodiment of the present disclosure;
[0026] Figure 2 A block diagram showing a circuit architecture for executing a Scrypt algorithm proof-of-work task according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0027] Various exemplary embodiments, features and aspects of the present disclosure will be described in detail below with reference to the accompanying drawings. The same reference numerals in the accompanying drawings represent elements with the same or similar functions. Although various aspects of the embodiments are shown in the accompanying drawings, the drawings are not necessarily drawn to scale unless otherwise specified.
[0028] The word “exemplary” is used exclusively herein to mean “serving as an example, example, or illustration.” Any embodiment described herein as “exemplary” is not necessarily to be construed as preferred or advantageous over other embodiments.
[0029] In addition, in order to better illustrate the present disclosure, numerous specific details are given in the following specific embodiments. It should be understood by those skilled in the art that the present disclosure can also be implemented without certain specific details. In some examples, methods, means, components and circuits well known to those skilled in the art are not described in detail in order to highlight the subject matter of the present disclosure.
[0030] Figure 1 A block diagram of a circuit architecture according to an embodiment of the present disclosure is shown, wherein the circuit architecture is used to perform the task of proof of work of the Scrypt algorithm, such as Figure 1As shown, the circuit architecture includes a control module 10, a computing module 20, and a storage module 30. The control module 10 includes an extraction unit 11, and the computing module 20 includes a temporary storage unit 21.
[0031] During the first stage of the control module 10 controlling the computing module 20 to execute a task, the extraction unit 11 is used to extract part of the first data as storage data and store it in the storage module 30, and the amount of the storage data is less than the amount of the first data.
[0032] In the second stage process in which the control module 10 controls the computing module 20 to perform a task, the control module 10 is used to:
[0033] When the first data corresponding to the current second data cannot be found in the stored data, the current second data is stored in the temporary storage unit 21;
[0034] The control operation module 20 obtains the next second data of the current second data according to the storage data in the storage module 30 and the current second data in the temporary storage unit 21 .
[0035] In one possible implementation, proof of work is an important mechanism for achieving system consistency. Proof of work requires participants to pay a certain amount of computing resources to prove that they have completed a certain amount of work. In the Scrypt algorithm, proof of work includes a first stage and a second stage. In the first stage, the Scrypt algorithm performs iterative calculations based on random numbers and HASH functions to obtain a preset number of first data, for example, 1024 first data. In the second stage, the Scrypt algorithm performs iterative calculations based on the first data and the HASH function to obtain the second data. In the process of obtaining each second data, the N+1th second data is obtained based on the first data corresponding to the Nth second data and the Nth second data.
[0036] In the circuit architecture for performing the Scrypt algorithm workload proof task, in the first stage, the control module can control the operation module to obtain first data after operating the random number using the HASH function, and store the first data in the storage module. The first data in the storage module have a cascade relationship.
[0037] For example, in the first stage, the control module can control the operation module to obtain the first first data after using the HASH function to operate according to the random number 1. The control module can control the operation module to obtain the second first data after using the HASH function to operate the first first data. The control module can control the operation module to obtain a preset number of first data after performing multiple operations using the HASH function. And each first data is stored in the storage module. In the second stage, the control module controls the operation module to generate the second data, and the first data generated in the first stage is randomly used to generate the second data. In the traditional method, all the first data are stored in the storage module, resulting in the storage module needing to occupy a large amount of space in the circuit structure. In order to save storage space, in this embodiment, the extraction unit in the control module can extract part of the data from the first data and store it in the storage module as storage data, which can save the space occupied by the storage module in the circuit structure.
[0038] In a possible implementation, the amount of stored data is less than the amount of first data, because the second data needs to use the first data randomly. When the first data required by the computing module to calculate the second data is not stored, it needs to be calculated based on the stored data, thereby consuming the computing resources of the computing module and reducing the computing efficiency. The amount of stored data can be determined based on the two requirements of saving storage space and ensuring computing efficiency.
[0039] In a possible implementation, the extraction unit is used to extract part of the data from the first data and store it in the storage module as storage data, including any one of the following:
[0040] The extraction unit is used to extract the storage data from the first data according to a preset extraction interval and store it in the storage module.
[0041] The extraction unit is used to extract the storage data in the first data according to a preset sequence number range and store it in the storage module.
[0042] The extraction unit is used to randomly extract a preset number of storage data from the first data and store them in the storage module.
[0043] In a possible implementation, an extraction interval may be preset. For example, the preset extraction interval may be three first data. The extraction unit may extract the first first data, the fourth first data, the eighth first data, and so on, until the last stored data is extracted for storage. In the calculation process of the operation module calculating each second data, the first data will be used randomly, and the storage sequence extracted according to the extraction interval can extract the stored data more evenly in the first data, so that the probability of the stored data being used is equivalent.
[0044] In a possible implementation, there is a cascade relationship between each first data, and each first data can form a sequence. The sequence numbers between each first data can be determined according to the generation order of the first data. The extraction unit can extract the storage data in the first data according to a preset sequence number range. For example, there are 1024 first data in total, and the first data in the sequence number ranges of 1-50, 100-150, 200-250... can be extracted as the storage data. The extraction unit can extract the storage data according to multiple sequence number ranges, or it can extract the storage data according to one sequence number range. The present disclosure does not limit the number of sequence number ranges, nor does it limit the length of each sequence number range.
[0045] In a possible implementation, the extraction unit may randomly extract a preset number of storage data from the first data for storage. For example, if there are 1024 first data in total, the extraction unit may randomly extract 256 storage data, for example, the first, fifth, fifteenth first data, etc. may be randomly extracted as storage data.
[0046] In a possible implementation, in the second stage, the operation module can, under the control of the control module, use the HASH function to perform operations according to the first data and the random number to obtain each second data. For example, in the second stage, the operation module can use the HASH function to perform operations according to the last first data or according to the random number 2 to obtain the first second data. The operation module can use the HASH function to operate the first second data to obtain the operation result of the first second data, can determine the first data corresponding to the first second data, can perform an XOR operation on the first data corresponding to the first second data and the operation result of the first second data to obtain the second second data. The operation module can use the HASH function to operate the second data to obtain the operation result of the second second data, can determine a first data corresponding to the second second data, can perform an XOR operation on the first data corresponding to the second second data and the operation result of the second second data to obtain the third second data. And so on, until a preset number of second data is obtained. For example, 1024 second data are obtained.
[0047] In a possible implementation, the operation module can obtain the first data corresponding to the current second data according to the data on the digit set in the current second data and the preset data conversion rule under the control of the control module. The data conversion rule can be determined according to the demand, and the present disclosure does not limit this. Since there is a cascade relationship between the first data, the operation module can obtain the first data corresponding to any second data through calculation according to any first data. The first data corresponding to each second data can be obtained according to the stored data.
[0048] In a possible implementation, the second data have a cascade relationship. Using the method in the embodiment of the present disclosure, the last second data is calculated, and the calculated last second data is output to other operation steps of the proof-of-work part in the Scrypt algorithm to complete the proof-of-work in the Scrypt algorithm. It can be understood by those skilled in the art that the specific second data is output to other steps in the Scrypt algorithm to complete the relevant description of the proof-of-work of the Scrypt algorithm can refer to the prior art.
[0049] In a possible implementation, the stored data is part of the first data. The first data corresponding to the current second data may be the stored data or may not be the stored data. When the first data corresponding to the current second data is the stored data, it can be directly used for calculating the current second data after being extracted from the stored data of the storage module.
[0050] In a possible implementation, when the first data corresponding to the current second data cannot be found in the stored data, the operation module can store the current second data in the temporary storage unit under the control of the control module. The operation module can determine the first data corresponding to the current second data after calculating using a HASH function based on the closest stored data.
[0051] In this embodiment, the circuit architecture for executing the Scrypt algorithm proof-of-work task includes a control module, a computing module, and a storage module. The control module includes an extraction unit, and the computing module includes a temporary storage unit. The extraction unit is used to extract part of the data in the first data and store it in the storage module as storage data. The computing module is used to store the current second data in the temporary storage unit when the first data corresponding to the current second data cannot be found in the storage data; according to the storage data in the storage module and the current second data in the temporary storage unit, the next second data of the current second data is obtained. The extraction unit can reduce the space occupied by the storage module in the circuit structure. The temporary storage unit can enable the storage data extracted by the extraction unit to be used to generate the second data. The extraction unit and the temporary storage unit can reduce the storage area of the circuit structure.
[0052] In a possible implementation, the control module 10 is used to control the computing module 20 to obtain the next second data of the current second data according to the storage data in the storage module 30 and the current second data, including:
[0053] The control module 10 is used to control the operation module 20 to determine the first data corresponding to the current second data according to the storage data closest to the current second data in the storage module 30; and obtain the next second data of the current second data according to the first data corresponding to the current second data in the storage module 30 and the current second data in the temporary storage unit 21.
[0054] In a possible implementation, the stored data closest to the current second data can be determined based on the closest stored data among the sequence numbers less than the sequence numbers of the first data corresponding to the current second data. For example, among the sequence numbers less than 14, the HASH function can be used to perform cascade calculations based on the first data with the closest sequence number of 11 to obtain the first data with the sequence number of 14 corresponding to the current second data. For example, the sequence number of the first data corresponding to the current second data is 14, and the sequence numbers of the first data in the stored data are 1, 6, 11, 16, etc., respectively. Among the sequence numbers less than 14, the 11th first data closest to the sequence number 14 can be determined as the closest stored data. The HASH function can be used to perform cascade calculations on the stored data with the sequence number of 11 to obtain the first data with the sequence number of 14 corresponding to the current second data.
[0055] In a possible implementation, the operation module 20 can use the HASH function to operate the current second data in the temporary storage unit 21 to obtain an operation result under the control of the control module 10. The operation module 30 can perform an XOR operation on the first data corresponding to the current second data and the operation result to obtain the next second data of the current second data.
[0056] In this embodiment, when the first data corresponding to the current second data cannot be found in each storage data, the operation module can, under the control of the control module, determine the first data corresponding to the current second data according to the storage data closest to the current second data in the storage module; and obtain the next second data of the current second data according to the first data corresponding to the current second data in the storage module and the current second data in the temporary storage unit. Each second data can be calculated based on the storage data, which reduces the storage space required for the first data and also saves the area of the circuit structure.
[0057] In a possible implementation, the first data is an ordered sequence, and the extraction unit 11 is further configured to:
[0058] Determine the storage address of the stored data according to the sequence number of the stored data;
[0059] The control module is also used to:
[0060] Generate an index address according to data at a preset digit in the current second data;
[0061] The index address is searched in the storage address, and the first data corresponding to the current second data is determined according to the search result.
[0062] In a possible implementation, the extraction unit may determine the sequence number of the stored data according to the sequence number of the first data. For example, when the first data with sequence numbers 1, 10, 15, and 20 are used as the stored data, the sequence numbers of the stored data are also 1, 10, 15, and 20. The sequence number of the stored data may be used as the storage address of the stored data. That is, the storage addresses of each stored data are 1, 10, 15, and 20.
[0063] In a possible implementation, the index address of the current second data can be generated by taking 2 as the base and the data at the preset digits in the current second data as the index. For example, the number of first data is 1024. 1024 results can be obtained by taking 2 as the base and the data at the last 10 digits in the second data as the index, which can correspond to 1024 first data. The number and position of the preset digits can be determined according to requirements.
[0064] In a possible implementation, the control module may search for an index address in a storage address. If the index address is found in the storage address, the storage data at the same storage address as the index address may be determined as the first data corresponding to the current second data. If the index address is not found in the storage address, the storage data at the storage address closest to the index address may be searched in the storage addresses less than the index address, and the first data corresponding to the current second data may be obtained through cascade calculation. For example, if the index address is 14 and the storage addresses are 1, 5, 10, and 15, the first data at the storage address 14 may be obtained through cascade calculation based on the storage data at the storage address 10.
[0065] In this embodiment, the storage address of the stored data is determined according to the serial number of the stored data, the index address is generated according to the data at the preset digit in the current second data, the index address is searched in the storage address, and the first data corresponding to the current second data is determined according to the search result. Through the storage address and the index address, the search process of the first data corresponding to the current second data can be made simple and reliable.
[0066] In a possible implementation, the control module 10 is used to control the computing module 20 to determine the first data corresponding to the current second data according to the storage data closest to the current second data in the storage module 30, including:
[0067] The control module 10 is used to control the operation module 20 to determine the difference between the storage address closest to the index address in the storage module 30 and the index address; according to the number of iterations determined by the difference, the storage data in the storage address closest to the index address is iteratively operated to obtain the first data corresponding to the index address.
[0068] In a possible implementation, the storage address closest to the index address can be determined among the storage addresses smaller than the index address. The difference between the closest storage address and the index address can be calculated. For example, the index address is 14, and the storage addresses of the storage data are 1, 5, 10, 15, 20, ... The storage address 10 can be determined as the closest storage address, and the difference is determined to be 14-10=4.
[0069] In a possible implementation, since the first data have a cascade relationship, the storage data in the closest storage address can be iteratively calculated according to the difference to obtain the first data corresponding to the index address. For example, if the difference is 4, the storage data in the closest storage address can be iteratively calculated four times using the HASH function to obtain the first data corresponding to the index address.
[0070] In this embodiment, the control module can control the calculation module to determine the difference between the closest storage address and the index address; according to the number of iterations determined by the difference, the storage data in the closest storage address is iteratively calculated to obtain the first data corresponding to the index address. By determining the number of iterations according to the difference, the first data corresponding to the current second data can be conveniently calculated according to the storage data.
[0071] Figure 2 A block diagram of a circuit architecture for performing a Scrypt algorithm workload proof task according to an embodiment of the present disclosure is shown as follows: Figure 2 The circuit architecture shown includes a control module, a storage module and a computing module.
[0072] In the storage module, SRAM, static random access memory, is included.
[0073] The operation module includes multiple MUX units, temporary storage units (Delaydepth=N+d), XOR units and delay units (DelayDepthed). The main functions implemented by the control module include: extraction unit, read control unit, data path control unit and handshake unit.
[0074] The extraction unit and the control module realize the write address and write enable control of the SRAM through the sram_ctl unit, thereby extracting part of the data in the first data as the storage data.
[0075] A read control unit can realize the conversion from data to address, including in the method of the embodiment of the present disclosure, the read control function can read the first data corresponding to the current second data when the stored data read hits, or when the first data corresponding to the current second data is not hit in the stored data, read the closest stored data in the stored data.
[0076] The data path control unit can select data for each MUX according to the time beat in the first stage and the second stage. Figure 2 The mux_sels unit implementation shown in . Figure 2 The connection between the mux_sels unit and each mux in the operation module is not shown.
[0077] The handshake unit can realize the handshake with external data. Figure 2 The relevant units of this part of the function are not shown in FIG. Figure 2 When the circuit architecture shown is used to perform the Scrypt algorithm workload proof task, the data flow is described as follows:
[0078] In the first stage, the initial value is input to MUX B0 via MUX A and the delay unit, and then input to MUX C from MUX B0, and the first data is obtained after being calculated by the calculation unit after MUX C. At the same time, the initial value is input to SRAM from B_int via MUXA for storage.
[0079] In the first stage, the first first data is input into MUX B0 via MUX A and the delay unit, and then input into MUX C via MUX B0, and the second first data is obtained after being calculated by the calculation unit at the back end of MUX C. By analogy, a preset number of first data is obtained. Among them, the control module extracts part of the first data as storage data from the first data and stores it in the SRAM.
[0080] In the second stage, when the storage data extracted from the SRAM is the first data corresponding to the current second data, the current second data is input into the XOR unit via MUXA and the delay unit, and the storage data extracted from the SRAM is input into MUXD, and then the XOR unit performs an XOR operation on the storage data input into MUXD and the current second data input into the delay unit, and the output result of the XOR unit is input into MUXC, and then after operation by the calculation unit at the back end of MUXC, a second data written to the current second data is obtained.
[0081] In the second stage, when the stored data extracted from the SRAM is not the first data corresponding to the current second data, the current second data is input to MUX B1 via MUXA and the delay unit, and then input to the temporary storage unit via MUX B1 for temporary storage.
[0082] The storage data extracted from the SRAM is input into MUXB0. The storage data output by MUXB0 is input into MUXC and the calculation unit. According to the number of iterations determined by the difference between the address of the storage data and the address of the first data corresponding to the current second data, the calculation result of the calculation unit is iteratively calculated through MUXB0, MUXC and the calculation unit until the first data corresponding to the current second data is calculated. The obtained first data corresponding to the current second data is input into the XOR unit through the delay unit, and the XOR unit performs an XOR operation on the first data corresponding to the current second data and the current second data input by the temporary storage unit. The output result of the XOR unit is then input into MUXC, and after being calculated by the calculation unit at the back end of MUX C, the next second data of the current second data is obtained.
[0083] The flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the systems, methods and computer program products according to multiple embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of an instruction, and a module, a program segment or a part of an instruction contains one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions. The above has described various embodiments of the present disclosure, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Without departing from the scope and spirit of the various embodiments described, many modifications and changes are obvious to those of ordinary skill in the art. The terms used herein are chosen to best explain the principles of the embodiments, practical applications or technical improvements to technologies in the marketplace, or to enable others of ordinary skill in the art to understand the embodiments disclosed herein.
Claims
1. A circuit architecture for performing a Scrypt algorithm proof-of-work task, characterized in that: The circuit architecture includes a control module, a computing module, and a storage module. The control module includes an extraction unit, and the computing module includes a temporary storage unit. During the first phase of the control module controlling the operation module to execute the task, the extraction unit is used to extract part of the first data according to a preset sequence number range or randomly and store it in the storage module as storage data, and the amount of the storage data is less than the amount of the first data; In the second stage process in which the control module controls the computing module to execute the task, the control module is used to: When the first data corresponding to the current second data cannot be found in the stored data, storing the current second data in the temporary storage unit; Control the operation module to perform cascade calculation using a HASH function according to the closest storage data in the storage module whose sequence number is smaller than the sequence number of the first data corresponding to the current second data, so as to determine the first data corresponding to the current second data; According to the first data corresponding to the current second data in the storage module and the current second data in the temporary storage unit, the first data corresponding to the current second data and the result of the cascade calculation of the HASH function are XORed to obtain the next second data of the current second data.
2. The architecture according to claim 1, characterized in that The first data is an ordered sequence, and the extraction unit is further used for: Determining a storage address of the stored data according to a sequence number of the stored data; The control module is also used for: Generate an index address according to data at a preset digit in the current second data; The index address is searched in the storage address, and the first data corresponding to the current second data is determined according to the search result.
3. The architecture according to claim 2, characterized in that: The control module is used to control the operation module to determine the first data corresponding to the current second data according to the storage data closest to the current second data in the storage module, including: The control module is used to control the operation module to determine the difference between the storage address in the storage module closest to the index address and the index address; according to the number of iterations determined by the difference, the storage data in the storage address closest to the index address is iteratively operated to obtain the first data corresponding to the index address.
Citation Information
Patent Citations
Nonvolatile writing buffer data retention to be dispatch verified
CN103985411A
Proof-of-work calculating method and device, electronic equipment, program and medium
CN108322304A