Scrypt algorithm workload proof method and device

By extracting part of the data as storage data in the Scrypt algorithm and using multi-slot task allocation, the problem of the Scrypt algorithm taking up a large amount of storage space is solved, and the storage space saving and execution efficiency are improved.

CN109815372BActive Publication Date: 2024-11-08CANAAN CREATIVE (SH) CO LTD
View PDF 12 Cites 0 Cited by

Patent Information

Application Number
CN201910068396.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-01-24
Publication Date
2024-11-08
Estimated Expiration
2039-01-24

AI Technical Summary

Technical Problem

The Scrypt algorithm proof of work method occupies a large storage space, resulting in large volume of related devices and the inability to reduce the chip volume.

Method used

In the proof of work method of the Scrypt algorithm, by extracting part of the data as stored data in the first stage, the number of stored data is reduced, and the second data is generated according to the stored data of the target task in the second stage, and multiple time slots are used to perform. Task allocation and execution to improve storage efficiency and execution efficiency.

Benefits of technology

Save storage space, improve multi-task execution efficiency, and reduce the volume of related devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN109815372B_ABST
    Figure CN109815372B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a Scrypt algorithm workload proof method and device, the method includes multiple workload proof tasks, the tasks include a first stage and a second stage, the method includes: in the first stage of each task, extracting part of the data from the first data as storage data for storage, the amount of storage data is less than the amount of first data; in the second stage of each task, each task is respectively corresponded to a different first time slot in the first cycle, in the first time slot corresponding to the target task, the corresponding first data is determined according to the storage data of the target task, and the second data is generated according to the corresponding first data, the target task includes any task, the first cycle includes multiple first time slots, and the number of first time slots is greater than or equal to the number of tasks. The embodiment of the present disclosure can save storage space and improve the execution efficiency of multiple tasks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of blockchain technology, and in particular to a Scrypt algorithm workload proof method and device. 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, occupying a large storage space, making the chip implementing the Scrypt algorithm proof-of-work method larger in size, which is not conducive to reducing the size of related equipment. Summary of the invention

[0003] In view of this, the present disclosure proposes a Scrypt algorithm workload proof method and device to solve the problem that the Scrypt algorithm workload proof method occupies a large storage space and cannot reduce the size of the related chip.

[0004] According to one aspect of the present disclosure, a Scrypt algorithm workload proof method is provided, the method comprising a plurality of workload proof tasks, the tasks comprising a first stage and a second stage, the method comprising:

[0005] In the first stage of each task, part of the data is extracted from the first data and stored as storage data, and the amount of the storage data is less than the amount of the first data;

[0006] In the second stage of each task, each task is respectively corresponded to a different first time slot in the first cycle. In the first time slot corresponding to the target task, the corresponding first data is determined according to the storage data of the target task, and the second data is generated according to the corresponding first data. The target task includes any of the tasks, and the first cycle includes multiple first time slots, and the number of the first time slots is greater than or equal to the number of tasks.

[0007] In a possible implementation, in the first stage of each task, extracting part of the first data as storage data for storage includes:

[0008] In the first phase of each task, each task is mapped to a different second time slot in the second cycle.

[0009] In a second time slot corresponding to the target task, first data is generated, and part of the first data is extracted and written into a memory as storage data, wherein the second cycle includes a plurality of second time slots, and the number of the second time slots is greater than or equal to the number of the tasks.

[0010] In a possible implementation, determining corresponding first data according to the stored data of the target task, and generating second data according to the corresponding first data includes:

[0011] Searching the stored data of the target task for first data corresponding to the current second data;

[0012] When the first data corresponding to the current second data cannot be found in the stored data, determining the first data corresponding to the current second data according to the closest stored data;

[0013] The next second data of the current second data is obtained according to the first data corresponding to the current second data and the current second data.

[0014] In a possible implementation, the first data is an ordered sequence, and extracting part of the first data as storage data for storage includes:

[0015] Determining a storage address of the stored data according to a serial number of the stored data;

[0016] Searching the stored data of the target task for first data corresponding to the current second data includes:

[0017] An index address is generated according to data at a preset digit in the current second data of the target task, 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.

[0018] In a possible implementation, determining, according to the closest stored data, first data corresponding to the current second data includes:

[0019] determining a difference between the closest storage address and the index address;

[0020] 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.

[0021] In a possible implementation, extracting part of the data from the first data as storage data for storage includes any of the following:

[0022] Extracting and storing the stored data in the first data according to a preset extraction interval;

[0023] Extracting and storing the stored data in the first data according to a preset sequence number range;

[0024] A preset number of storage data are randomly selected from the first data for storage.

[0025] In a possible implementation, the storage data of each task is stored in different storage spaces of a memory, and the number of the storage spaces is greater than or equal to the number of the tasks.

[0026] In a possible implementation, each of the tasks is executed in an execution cycle consisting of the second cycle in front and the first cycle in the back.

[0027] In a possible implementation manner, the first cycle further includes idle time slots, and the number or duration of the idle time slots is determined according to the delay of the memory.

[0028] In a possible implementation manner, the first cycle and the second cycle are performed in parallel.

[0029] In a possible implementation, the method further includes:

[0030] When at least one of the multiple tasks is completed, a first time slot corresponding to the completed task is allocated to a new task.

[0031] According to another aspect of the present disclosure, a Scrypt algorithm workload proof device is provided, the device is used to perform multiple workload proof tasks, the tasks include a first stage and a second stage, the device includes:

[0032] An extraction module, used for extracting part of the data from the first data as storage data for storage in the first stage of each task, wherein the amount of the storage data is less than the amount of the first data;

[0033] The first cycle execution module is used to correspond each task to a different first time slot in the first cycle in the second stage of each task, determine the corresponding first data according to the storage data of the target task in the first time slot corresponding to the target task, and generate second data according to the corresponding first data. The target task includes any of the tasks, and the first cycle includes multiple first time slots, and the number of the first time slots is greater than or equal to the number of tasks.

[0034] In a possible implementation, the extraction module includes:

[0035] The second cycle execution submodule is used to correspond each task to a different second time slot in the second cycle in the first stage of each task, generate first data in the second time slot corresponding to the target task, and extract part of the first data and write it into the memory as storage data. The second cycle includes multiple second time slots, and the number of the second time slots is greater than or equal to the number of tasks.

[0036] In a possible implementation, the first cycle execution module includes:

[0037] A corresponding data search submodule, used to search the stored data of the target task for first data corresponding to the current second data;

[0038] A corresponding data determination submodule, for determining the first data corresponding to the current second data according to the closest stored data when the first data corresponding to the current second data cannot be found in the stored data;

[0039] The second data acquisition submodule is used to obtain the next second data of the current second data according to the first data corresponding to the current second data and the current second data.

[0040] In a possible implementation, the first data is an ordered sequence, and the extraction module includes:

[0041] A storage address submodule, used to determine the storage address of the storage data according to the serial number of the storage data;

[0042] The corresponding data search submodule is used to:

[0043] An index address is generated according to data at a preset digit in the current second data of the target task, 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.

[0044] In a possible implementation, the corresponding data determination submodule is used to:

[0045] determining a difference between the closest storage address and the index address;

[0046] 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.

[0047] In a possible implementation, extracting part of the data from the first data as storage data for storage includes any of the following:

[0048] Extracting and storing the stored data in the first data according to a preset extraction interval;

[0049] Extracting and storing the stored data in the first data according to a preset sequence number range;

[0050] A preset number of storage data are randomly selected from the first data for storage.

[0051] In a possible implementation, the storage data of each task is stored in different storage spaces of a memory, and the number of the storage spaces is greater than or equal to the number of the tasks.

[0052] In a possible implementation, each of the tasks is executed in an execution cycle consisting of the second cycle in front and the first cycle in the back.

[0053] In a possible implementation manner, the first cycle further includes idle time slots, and the number or duration of the idle time slots is determined according to the delay of the memory.

[0054] In a possible implementation manner, the first cycle and the second cycle are performed in parallel.

[0055] In the disclosed embodiment, in the first stage of the Scrypt algorithm workload proof, part of the data is extracted from the first data and stored as storage data, which can save storage space. Multiple tasks are respectively mapped to different first time slots in the first cycle, and second data is generated in the first time slot corresponding to each task, which can improve the execution efficiency of multiple tasks.

[0056] 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

[0057] 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.

[0058] Figure 1 A flowchart showing a Scrypt algorithm workload proof method according to an embodiment of the present disclosure is shown;

[0059] Figure 2 A flowchart showing a Scrypt algorithm workload proof method according to an embodiment of the present disclosure is shown;

[0060] Figure 3 A flowchart showing a Scrypt algorithm workload proof method according to an embodiment of the present disclosure is shown;

[0061] Figure 4 A block diagram of a Scrypt algorithm workload proof device according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0062] 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.

[0063] 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.

[0064] 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 main purpose of the present disclosure.

[0065] Figure 1 A flowchart of a Scrypt algorithm workload proof method according to an embodiment of the present disclosure is shown as follows: Figure 1 As shown, the method includes:

[0066] Step S10, the first stage of each task, extracts part of the data from the first data as storage data for storage, and the amount of the storage data is less than the amount of the first data.

[0067] 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 random number can be operated using a HASH function to obtain multiple first data. There is a cascade relationship between the first data, and a sequence can be formed. For example, in the first stage, the first first data can be obtained by operating the random number 1 using a HASH function. The first first data can be operated using a HASH function to obtain the second first data. A preset number of first data can be obtained after multiple operations using the HASH function. Each first data can be stored. In order to save storage space, this embodiment can extract part of the data from the first data as storage data for storage, which can save storage space.

[0068] 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 for calculating the second data is not stored, it needs to be calculated based on the stored data, thereby consuming certain computing resources and reducing computing efficiency. The amount of stored data can be determined based on the two requirements of saving storage space and ensuring computing efficiency.

[0069] In a possible implementation, extracting part of the data from the first data as storage data for storage includes any of the following:

[0070] Extracting and storing the stored data in the first data according to a preset extraction interval;

[0071] Extracting and storing the stored data in the first data according to a preset sequence number range;

[0072] A preset number of storage data are randomly selected from the first data for storage.

[0073] In a possible implementation, an extraction interval may be preset. For example, the preset extraction interval may be three first data. Then the first first data, the fourth first data, the eighth first data, and so on may be extracted, until the last stored data is extracted for storage. In the calculation process of the second data, the first data will be used randomly, and the storage columns 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.

[0074] In a possible implementation, there is a cascade relationship between each first data, and each first data can form a sequence. The sequence number between each first data can be determined according to the generation order of the first data. The storage data can be extracted from the first data according to a preset sequence number range. For example, there are 1024 first data in total, and the first data with sequence number ranges of 1-50, 100-150, 200-250... can be extracted as storage data. The storage data can be extracted according to multiple sequence number ranges, or it can be extracted 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.

[0075] In a possible implementation, a preset number of storage data may be randomly selected from the first data for storage. For example, 256 storage data may be randomly selected from a total of 1024 first data, and the first, fifth, fifteenth first data, etc. may be randomly selected as storage data.

[0076] Step S20, in the second stage of each task, each task is respectively corresponded to a different first time slot in the first cycle, in the first time slot corresponding to the target task, the corresponding first data is determined according to the storage data of the target task, and the second data is generated according to the corresponding first data, the target task includes any task, the first cycle includes multiple first time slots, and the number of first time slots is greater than or equal to the number of tasks.

[0077] In a possible implementation, in the second stage, the second data can be obtained by using a HASH function to calculate based on the first data and the random number. For example, in the second stage, the first second data can be obtained by using a HASH function to calculate based on the last first data or based on the random number 2. The first second data can be calculated using a HASH function to obtain the calculation result of the first second data, the first data corresponding to the first second data can be determined, and the first data corresponding to the first second data and the calculation result of the first second data can be XORed to obtain the second second data. The second data can be calculated using a HASH function to obtain the calculation result of the second second data, a first data corresponding to the second second data can be determined, and the first data corresponding to the second second data and the calculation result of the second second data can be XORed to obtain the third second data. And so on, until a preset number of second data is obtained.

[0078] In a possible implementation, the first data corresponding to the current second data can be obtained according to the data on the set digits in the current second data and the preset data conversion rule. 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 first data corresponding to any second data can be obtained by calculation according to any first data. The first data corresponding to each second data can be obtained according to the stored data.

[0079] 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.

[0080] In one possible implementation, in the second stage of each task, in the process of determining the first data corresponding to the current second data, there is a situation where the corresponding first data is not the stored data, and it is necessary to obtain the first data corresponding to the current second data after calculation based on the stored data, and then obtain the next second data based on the first data corresponding to the current second data obtained by calculation. In each task, the hit rate of the first data corresponding to the current second data in the stored data is different, the number of iterations of obtaining the corresponding first data based on the stored data calculation is different, and the calculation time is also different, resulting in different durations required for the second stage of each task. In the traditional proof-of-work method, when multiple proof-of-work tasks are executed simultaneously, it is necessary to wait for the current second data of all tasks to be generated before the next second data generation process can be carried out, and the execution efficiency of each task is low.

[0081] In a possible implementation, in the second phase of each task, each task can be respectively corresponded to a different first time slot in the first cycle, and the first cycle includes multiple first time slots, and the number of first time slots is greater than or equal to the number of tasks. For example, the first cycle is T1, and T1 includes 10 first time slots, which can correspond to 10 different tasks respectively, the first first time slot corresponds to task 1, the second first time slot corresponds to task 2, the third first time slot corresponds to task 3... Within the duration corresponding to the first first time slot, the second phase of task 1 is executed, and within the duration corresponding to the second first time slot, the second phase of task 2 is executed, and so on, until the first cycle is completed and the next first cycle is executed.

[0082] In a possible implementation, when at least one of the multiple tasks is completed, the first time slot corresponding to the completed task can be allocated to a new task. For example, among 10 tasks, task 3 is completed. The third first time slot corresponding to task 3 can be allocated to a new task 11, thereby improving the efficiency of multi-task execution.

[0083] In this embodiment, in the first stage of the Scrypt algorithm workload proof, part of the data is extracted from the first data and stored as storage data, which can save storage space. Multiple tasks are respectively mapped to different first time slots in the first cycle, and second data is generated in the first time slot corresponding to each task, which can improve the execution efficiency of multiple tasks.

[0084] Figure 2 A flowchart of a Scrypt algorithm workload proof method according to an embodiment of the present disclosure is shown as follows: Figure 2 As shown, the method includes: step S11, step S20, wherein step S20 can refer to the above Figure 1 As described in the related description, step S11 includes:

[0085] Step S11, in the first stage of each task, each task is respectively corresponded to a different second time slot in the second cycle, and in the second time slot corresponding to the target task, the first data is generated, and part of the data is extracted from the first data and written into the memory as storage data. The second cycle includes multiple second time slots, and the number of second time slots is greater than or equal to the number of tasks.

[0086] In a possible implementation, each task can be respectively mapped to a different second time slot in the second cycle, and in the second time slot corresponding to the target task, the first stage of the target task is executed to generate first data, and part of the data in the first data is extracted and written into the memory as storage data. Since the execution time of the second stage of each task is different, after each task is respectively mapped to the first cycle, when one of the tasks is completed, the first time slot corresponding to it can be released, and the released first time slot can be used for a new task. Accordingly, the second time slot corresponding to the second cycle corresponding to the completed task can also be released, and the released second time slot can also be allocated to the new task to improve the execution efficiency of multiple tasks.

[0087] In a possible implementation, the sequence number of the first time slot corresponding to each task in the first cycle may be the same as or different from the sequence number of the second time slot corresponding to each task in the second cycle.

[0088] In this embodiment, in the first stage of each task, each task is respectively mapped to a different second time slot in the second cycle, and in the second time slot corresponding to the target task, first data is generated, and part of the first data is extracted and written into the memory as storage data. The first stage of each task is also completed in the corresponding first time slot, which can further improve the execution efficiency of multiple tasks.

[0089] Figure 3 A flowchart of a Scrypt algorithm workload proof method according to an embodiment of the present disclosure is shown as follows: Figure 3 As shown, the method includes: step S10, step S21, step S22, step S23, wherein step S10 can refer to the above Figure 1 As described in the related description, step S21, step S22 and step S23 include:

[0090] Step S21, searching the storage data of the target task for the first data corresponding to the current second data.

[0091] 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 extracted from the stored data and used for calculating the current second data.

[0092] Step S22: when the first data corresponding to the current second data cannot be found in the stored data, the first data corresponding to the current second data is determined according to the closest stored data.

[0093] In a possible implementation, when the first data corresponding to the current second data cannot be found in the stored data, the first data corresponding to the current second data can be determined after calculation using the HASH function based on the closest stored 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. The first data corresponding to the current second data with a sequence number of 14 can be obtained by performing a cascade calculation using the HASH function based on the 16th first data closest to the sequence number 14.

[0094] In a possible implementation, the closest stored data with a sequence number smaller than the sequence number of the first data corresponding to the current second data may be determined as the closest stored data. For example, among the sequence numbers smaller than 14, the first data with the closest sequence number of 11 may be cascaded using a HASH function to obtain the first data with a sequence number of 14 corresponding to the current second data.

[0095] Step S23, obtaining the next second data of the current second data according to the first data corresponding to the current second data and the current second data.

[0096] In a possible implementation, the current second data may be operated using a HASH function to obtain an operation result, and the first data corresponding to the current second data and the operation result may be XORed to obtain the next second data of the current second data.

[0097] In this embodiment, when the first data corresponding to the current second data cannot be found in each stored data, the first data corresponding to the current second data is determined based on the closest stored data, and the next second data of the current second data is obtained based on the first data corresponding to the current second data and the current second data. The second data can be calculated based on the stored data, reducing the storage space required for the first data.

[0098] In a possible implementation, the first data is an ordered sequence, and step S10 in the method includes:

[0099] The storage address of the stored data is determined according to the serial number of the stored data.

[0100] In a possible implementation, the sequence number of the stored data can be determined 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 can 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.

[0101] Step S21 includes: generating an index address according to data at a preset digit in the current second data of the target task, searching for the index address in the storage address, and determining the first data corresponding to the current second data according to the search result.

[0102] 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.

[0103] In one possible implementation, the index address may be searched in the 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.

[0104] 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.

[0105] In a possible implementation, determining first data corresponding to current second data according to the closest stored data includes:

[0106] The difference between the closest storage address and the index address is determined.

[0107] 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.

[0108] 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.

[0109] 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.

[0110] In this implementation, the difference between the closest storage address and the index address can be determined; 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.

[0111] In a possible implementation, the method further includes:

[0112] The storage data of each task is stored in different storage spaces of the memory, and the number of storage spaces is greater than or equal to the number of tasks.

[0113] In a possible implementation, the memory may be divided into different storage spaces. The number of storage spaces may be determined according to the number of tasks. For example, corresponding to 10 tasks, the memory may be divided into 10 storage spaces, each storage space corresponding to one task. Each task may store storage data in a corresponding storage space, and extract the storage data in the corresponding storage space to calculate and obtain the second data.

[0114] In this embodiment, by dividing the memory into different storage spaces, each task reads and writes data in the corresponding storage space, which can improve the data reading and writing efficiency and improve the execution efficiency of multiple tasks.

[0115] In a possible implementation, each task is executed in an execution cycle consisting of a first cycle in front and a second cycle in the back.

[0116] In a possible implementation, a chip for executing the Scrypt algorithm workload proof method of the embodiment of the present disclosure may be read-only or write-only at the same time. When the method of the embodiment of the present disclosure is applied to a chip that is read-only or write-only at the same time, each task may be executed in an execution cycle consisting of the second cycle in front and the first cycle in the back.

[0117] For example, the second cycle duration is T2, the first cycle duration is T1, and T3=T1+T2 is the duration of the execution cycle. In the execution cycle, the second cycle T2 is executed first and then the first cycle T1 is executed. Each task is executed in sequence in the execution cycle T3. During the duration T2 in T3, the first stage of each task is executed. During the duration T1 in T3, the second stage of each task is executed.

[0118] In this embodiment, each task is executed in an execution cycle consisting of the second cycle in front and the first cycle in the back, which can meet the use environment of the chip that is only read or only write at the same time, and improve the applicability of the embodiment of the present disclosure.

[0119] In a possible implementation, the first cycle further includes idle time slots, and the number or duration of the idle time slots is determined according to a delay of the memory.

[0120] In a possible implementation, since the second phase of each task takes longer than the first phase, the first cycle may further include an idle time slot. The duration of the first cycle including the idle time slot may be longer than the duration of the second cycle. The number or duration of the idle time slot may be determined according to the delay characteristics of the memory. The idle time slot may be used to correspond to the duration required for the computational overhead of each task, so that the first time slot in the first cycle can be aligned with each task.

[0121] In this embodiment, the first cycle may further include idle time slots. The idle time slots are used to correspond to the duration required for the computational overhead of each task, and each first time slot in the first cycle is aligned with each task to improve the execution efficiency of each task.

[0122] In a possible implementation, the first cycle and the second cycle are performed in parallel.

[0123] In a possible implementation, a chip for executing the Scrypt algorithm workload proof method of the embodiment of the present disclosure can read and write at the same time. When the method in the embodiment of the present disclosure is applied to a chip that can read and write at the same time, the first cycle can be parallel to the second cycle.

[0124] In this embodiment, the first cycle and the second cycle are carried out in parallel to meet the use environment of the chip that can read and write at the same time, thereby improving the applicability of the embodiment of the present disclosure.

[0125] Figure 4A block diagram of a Scrypt algorithm workload proof device according to an embodiment of the present disclosure is shown as follows: Figure 4 As shown, the device is used to perform multiple proof-of-work tasks, the tasks include a first stage and a second stage, and the device includes:

[0126] An extraction module 10 is used to extract part of the data from the first data and store it as storage data in the first stage of each task, and the amount of the storage data is less than the amount of the first data;

[0127] The first cycle execution module 20 is used to correspond each task to a different first time slot in the first cycle in the second stage of each task, determine the corresponding first data according to the storage data of the target task in the first time slot corresponding to the target task, and generate second data according to the corresponding first data. The target task includes any task, and the first cycle includes multiple first time slots, and the number of first time slots is greater than or equal to the number of tasks.

[0128] In a possible implementation, the extraction module 10 includes:

[0129] The second cycle execution submodule is used to correspond each task to a different second time slot in the second cycle in the first stage of each task, generate first data in the second time slot corresponding to the target task, and extract part of the first data and write it into the memory as storage data. The second cycle includes multiple second time slots, and the number of second time slots is greater than or equal to the number of tasks.

[0130] In a possible implementation, the first cycle execution module 20 includes:

[0131] A corresponding data search submodule, used to search the stored data of the target task for the first data corresponding to the current second data;

[0132] A corresponding data determination submodule, for determining the first data corresponding to the current second data according to the closest stored data when the first data corresponding to the current second data cannot be found in the stored data;

[0133] The second data acquisition submodule is used to obtain the next second data of the current second data according to the first data corresponding to the current second data and the current second data.

[0134] In a possible implementation, the first data is an ordered sequence, and the extraction module 10 includes:

[0135] A storage address submodule, used to determine the storage address of the stored data according to the serial number of the stored data;

[0136] The corresponding data search submodule is used for:

[0137] An index address is generated according to data at a preset digit in the current second data of the target task, 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.

[0138] In a possible implementation, the corresponding data determination submodule is used to:

[0139] determining the difference between the closest storage address and the index address;

[0140] 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.

[0141] In a possible implementation, extracting part of the data from the first data as storage data for storage includes any of the following:

[0142] Extracting and storing the stored data in the first data according to a preset extraction interval;

[0143] Extracting and storing the stored data in the first data according to a preset sequence number range;

[0144] A preset number of storage data are randomly selected from the first data for storage.

[0145] In a possible implementation, the storage data of each task is stored in different storage spaces of the memory, and the number of the storage spaces is greater than or equal to the number of tasks.

[0146] In a possible implementation, each task is executed in an execution cycle consisting of a second cycle in front and a first cycle in the back.

[0147] In a possible implementation, the first cycle further includes idle time slots, and the number or duration of the idle time slots is determined according to a delay of the memory.

[0148] In a possible implementation, the first cycle and the second cycle are performed in parallel.

[0149] In a possible implementation, the device further includes: an allocation module, configured to allocate a first time slot corresponding to the completed task to a new task when at least one of the multiple tasks is completed.

[0150] The embodiments of the present disclosure have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements to the technology in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.

Claims

1. A Scrypt algorithm workload proof method, It is characterized in that The method includes multiple proof-of-work tasks, the tasks include a first stage and a second stage, and the method includes: In the first stage of each task, some data are randomly selected from the first data and stored as storage data, and the storage address of the storage data is determined according to the sequence number of the first data in the ordered sequence, and the amount of the storage data is less than the amount of the first data; in the first stage of each task, each task is respectively corresponded to a different second time slot in the second cycle; In the second stage of each task, each task is respectively corresponded to a different first time slot in the first cycle; in the first time slot corresponding to the target task, an index address is generated according to the data on the preset digit in the current second data of the target task, 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; when the first data corresponding to the current second data cannot be found in the storage data, the first data corresponding to the current second data is determined by cascading calculation using a HASH function according to the closest storage data whose serial number is less than the serial number of the first data corresponding to the current second data; the next second data of the current second data is obtained according to the first data corresponding to the current second data and the current second data; the target task includes any of the tasks, the first cycle includes multiple first time slots, the number of the first time slots is greater than or equal to the number of the tasks, and the first cycle and the second cycle are parallel.

2. The method according to claim 1, It is characterized in that In the first stage of each task, part of the data is extracted from the first data and stored as storage data, including: In a second time slot corresponding to the target task, first data is generated, and part of the first data is extracted and written into a memory as storage data, wherein the second cycle includes a plurality of second time slots, and the number of the second time slots is greater than or equal to the number of the tasks.

3. The method according to claim 1, It is characterized in that Determining, according to the closest stored data, first data corresponding to the current second data, comprising: determining a 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.

4. The method according to claim 1, It is characterized in that Extracting part of the data from the first data as storage data for storage includes any of the following: Extracting and storing the stored data in the first data according to a preset extraction interval; Extracting and storing the stored data in the first data according to a preset sequence number range; A preset number of storage data are randomly selected from the first data for storage.

5. The method according to claim 2, It is characterized in that The storage data of each task is stored in different storage spaces of the memory, and the number of the storage spaces is greater than or equal to the number of the tasks.

6. The method according to claim 2, It is characterized in that Each of the tasks is executed in an execution cycle consisting of the second cycle in front and the first cycle in the back.

7. The method according to claim 1, It is characterized in that The first cycle also includes idle time slots, and the number or duration of the idle time slots is determined according to the delay of the memory.

8. The method according to claim 1, It is characterized in that The method further comprises: When at least one of the multiple tasks is completed, a first time slot corresponding to the completed task is allocated to a new task.

9. A Scrypt algorithm workload proof device, It is characterized in that The device is used to perform multiple proof-of-work tasks, the tasks including a first stage and a second stage, and the device includes: an extraction module, configured to randomly extract part of the first data as storage data for storage in the first stage of each task, and determine the storage address of the storage data according to the sequence number of the first data in the ordered sequence, wherein the amount of the storage data is less than the amount of the first data; A first cycle execution module is used to correspond each task to a different first time slot in the first cycle in the second stage of each task, generate an index address in the first time slot corresponding to the target task according to the data on the preset digit in the current second data of the target task, search the index address in the storage address, and determine the first data corresponding to the current second data according to the search result; when the first data corresponding to the current second data cannot be found in the storage data, perform cascade calculation using a HASH function according to the closest storage data whose sequence number is less than the sequence number of the first data corresponding to the current second data, and determine the first data corresponding to the current second data; obtain the next second data of the current second data according to the first data corresponding to the current second data and the current second data; the target task includes any of the tasks, and the first cycle includes a plurality of first time slots, and the number of the first time slots is greater than or equal to the number of the tasks; The second cycle execution submodule is used to correspond each task to a different second time slot in a second cycle in the first stage of each task, and the first cycle and the second cycle are parallel.

10. The device according to claim 9, It is characterized in that The extraction module comprises: The second cycle execution submodule is used to generate first data in a second time slot corresponding to the target task, and extract part of the first data as storage data and write it into the memory, the second cycle includes multiple second time slots, and the number of the second time slots is greater than or equal to the number of tasks.

11. The device according to claim 9, It is characterized in that The corresponding data determination submodule is used to: determining a 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.

12. The device according to claim 9, It is characterized in that Extracting part of the data from the first data as storage data for storage includes any of the following: Extracting and storing the stored data in the first data according to a preset extraction interval; Extracting and storing the stored data in the first data according to a preset sequence number range; A preset number of storage data are randomly selected from the first data for storage.

13. The device according to claim 10, It is characterized in that The storage data of each task is stored in different storage spaces of the memory, and the number of the storage spaces is greater than or equal to the number of the tasks.

14. The device according to claim 10, It is characterized in that Each of the tasks is executed in an execution cycle consisting of the second cycle in front and the first cycle in the back.

15. The device according to claim 9, It is characterized in that The first cycle also includes idle time slots, and the number or duration of the idle time slots is determined according to the delay of the memory.

16. The device according to claim 9, It is characterized in that The device also includes: The allocation module is used to allocate the first time slot corresponding to the completed task to a new task when at least one of the multiple tasks is completed.

Citation Information

Patent Citations

  • Pattern inspecting and measuring device and program

    CN104718428A

  • Hardware logical resource reuse module and method for realizing reuse

    CN105515565A

  • Graph data processing method and apparatus

    CN106919628A

  • LoRa star network time slot allocation method, device and system

    CN107396447A

  • Online scene characteristic data storing method and system and data extraction system

    CN107451292A