CN116186746A - Parallel hash encryption method, storage medium and electronic device - Google Patents

Parallel hash encryption method, storage medium and electronic device Download PDF

Info

Publication number
CN116186746A
CN116186746A CN202310464782.3A CN202310464782A CN116186746A CN 116186746 A CN116186746 A CN 116186746A CN 202310464782 A CN202310464782 A CN 202310464782A CN 116186746 A CN116186746 A CN 116186746A
Authority
CN
China
Prior art keywords
data
segment
matrix
dimensional
hashed
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202310464782.3A
Other languages
Chinese (zh)
Other versions
CN116186746B (en
Inventor
吴刚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Dark Chain Technology Shenzhen Co ltd
Original Assignee
Dark Chain Technology Shenzhen Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Dark Chain Technology Shenzhen Co ltd filed Critical Dark Chain Technology Shenzhen Co ltd
Priority to CN202310464782.3A priority Critical patent/CN116186746B/en
Publication of CN116186746A publication Critical patent/CN116186746A/en
Application granted granted Critical
Publication of CN116186746B publication Critical patent/CN116186746B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/602Providing cryptographic facilities or services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F17/00Digital computing or data processing equipment or methods, specially adapted for specific functions
    • G06F17/10Complex mathematical operations
    • G06F17/16Matrix or vector computation, e.g. matrix-matrix or matrix-vector multiplication, matrix factorization

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Mathematical Analysis (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • Pure & Applied Mathematics (AREA)
  • Mathematical Optimization (AREA)
  • Computational Mathematics (AREA)
  • General Health & Medical Sciences (AREA)
  • Computing Systems (AREA)
  • Bioethics (AREA)
  • Health & Medical Sciences (AREA)
  • Computer Security & Cryptography (AREA)
  • Algebra (AREA)
  • Computer Hardware Design (AREA)
  • Databases & Information Systems (AREA)
  • Storage Device Security (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention relates to the technical field of data encryption and discloses a parallel hash encryption method, a storage medium and electronic equipment. The parallel hash encryption method comprises the following steps: the method comprises the steps of obtaining source data, dividing the source data into a plurality of equal-length data segments, generating three-dimensional data matrixes corresponding to each data segment in parallel, performing hash operation on each three-dimensional data matrix in parallel to obtain hash segment data corresponding to each data segment, and compressing the hash segment data into hash encryption data with specified bit numbers. The embodiment adopts a parallel encryption architecture, can carry out hash encryption processing on each data segment in a multithreading manner, and is beneficial to improving the encryption calculation efficiency.

Description

Parallel hash encryption method, storage medium and electronic device
Technical Field
The present invention relates to the field of data encryption technologies, and in particular, to a parallel hash encryption method, a storage medium, and an electronic device.
Background
The secure hash algorithm (Secure Hash Algorithm, SHA algorithm) is widely applied to data encryption services such as digital signature, and the SHA algorithm can output a message digest with a fixed length according to source data with different lengths so as to verify the integrity of the source data. The SHA algorithm family comprises MD5, SHA1 algorithm, SHA2 algorithm, SHA3 algorithm and the like, the SHA algorithm is generated in the single-core computer age and is limited by the technical background of the single-core computer age, the encryption architecture of the SHA algorithm adopts a sequential mechanism, a computer carries out hash encryption processing on source data in a sequential mode, the encryption time of the sequential hash encryption method can linearly increase along with the increase of the source data, the encryption efficiency is low, and the method is unfavorable for frequent use of application scenes such as large file tamper-proof verification in the blockchain age and the like.
Disclosure of Invention
An object of an embodiment of the present invention is to provide a parallel hash encryption method, a storage medium, and an electronic device, which aim to solve the technical problems of low encryption efficiency, security, and poor scalability of the existing SHA algorithm.
In a first aspect, an embodiment of the present invention provides a parallel hash encryption method, including:
acquiring source data, and dividing the source data into a plurality of data segments with equal length;
generating three-dimensional data matrixes corresponding to each data segment in parallel;
performing hashing operation on each three-dimensional data matrix in parallel to obtain hashed segment data corresponding to each data segment;
and compressing a plurality of pieces of hashed segment data into hashed encrypted data with specified digits.
In a second aspect, an embodiment of the present invention provides a storage medium storing computer-executable instructions for causing an electronic device to perform the parallel hash encryption method described above.
In a third aspect, an embodiment of the present invention provides an electronic device, including:
at least one processor; the method comprises the steps of,
a memory communicatively coupled to the at least one processor; wherein, the liquid crystal display device comprises a liquid crystal display device,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the parallel hash encryption method described above.
In the parallel hash encryption method provided by the embodiment of the invention, source data is acquired, the source data is divided into a plurality of equal-length data segments, a three-dimensional data matrix corresponding to each data segment is generated in parallel, a hash operation is performed on each three-dimensional data matrix in parallel, hash segment data corresponding to each data segment is obtained, and the hash segment data is compressed into hash encryption data with specified bit numbers. The embodiment adopts a parallel encryption architecture, can carry out parallel hash encryption processing on each data segment in a multithreading manner, and is beneficial to improving encryption calculation efficiency.
Drawings
One or more embodiments are illustrated by way of example and not limitation in the figures of the accompanying drawings, in which like references indicate similar elements, and in which the figures of the drawings are not to be taken in a limiting sense, unless otherwise indicated.
Fig. 1 is a schematic flow chart of a parallel hash encryption method according to an embodiment of the present invention;
fig. 2 is a schematic diagram of a scenario of a parallel hash encryption method according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of segmenting source data according to an embodiment of the present invention;
FIG. 4 is a schematic diagram illustrating a state of performing 24 hashing operations on a three-dimensional data matrix according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of a state of splicing a plurality of hashed segment data into a segment-spliced three-dimensional matrix according to a segment splicing coefficient according to an embodiment of the present invention;
fig. 6 is a schematic circuit diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present invention more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
It should be noted that, if not in conflict, the features of the embodiments of the present invention may be combined with each other, which is within the protection scope of the present invention. In addition, while functional block division is performed in a device diagram and logical order is shown in a flowchart, in some cases, the steps shown or described may be performed in a different order than the block division in the device, or in the flowchart. Furthermore, the words "first," "second," "third," and the like as used herein do not limit the order of data and execution, but merely distinguish between identical or similar items that have substantially the same function and effect.
The embodiment of the invention provides a parallel hash encryption method. Referring to fig. 1, the parallel hash encryption method includes the steps of:
s11: source data is acquired.
In this step, the source data is data for which hash encryption operation needs to be performed. The source data is expressed in a binary form, wherein the number of bits of the source data is not fixed, for example, the number of bits of the source data is 300 bits or 1024 bits or 1555000000 bits, and the specific length is not limited.
S12: the source data is divided into a plurality of equal length data segments.
In this step, the data segment is a data set composed of a plurality of values intercepted from the source data according to a specified number of bits, and the number of bits of any two data segments is equal, where the specified number of bits can be customized by a designer according to the service requirement. In some embodiments, the specified number of bits is 2 to the power N, where N is a positive integer. In some embodiments, N is 8, and thus the number of specified bits is 256 bits.
Referring to fig. 2, source data is divided into data segments
Figure SMS_2
Data segment->
Figure SMS_4
Data segment->
Figure SMS_5
Data segment->
Figure SMS_6
… … data segment
Figure SMS_7
Data section->
Figure SMS_8
Data segment->
Figure SMS_9
Data segment->
Figure SMS_1
Data section->
Figure SMS_3
The number of bits of (2) is 256 bits.
S13: a three-dimensional data matrix corresponding to each data segment is generated in parallel.
In this step, the matrix size of the three-dimensional data matrix can be customized by a designer according to the service requirement, and the matrix size of the three-dimensional data matrix is r×s×t. For example, the matrix size of the three-dimensional data matrix is a matrix of size 8×8×64, where r=s= 8,t =64.
The three-dimensional data matrix is configured with a three-dimensional coordinate system including an origin, an X-axis, a Y-axis, and a Z-axis, wherein the origin may be defined at any position of the three-dimensional data matrix, such as an upper left corner or an upper right corner or a center of the three-dimensional data matrix, and the origin is defined at the upper left corner of the three-dimensional data matrix. The X-axis is referred to as the rows of the three-dimensional data matrix, the Y-axis is referred to as the vertical, and the Z-axis is referred to as the team. The XY plane is the front of the three-dimensional data matrix, the XZ plane is the plane, and the YZ plane is the side.
Each data segment has a three-dimensional data matrix corresponding thereto, e.g. data segments
Figure SMS_11
Corresponding three-dimensional data matrix->
Figure SMS_12
Data section->
Figure SMS_13
Corresponding three-dimensional data matrix->
Figure SMS_14
Data section->
Figure SMS_15
Corresponding three-dimensional data matrix->
Figure SMS_16
Data section->
Figure SMS_17
Corresponding three-dimensional data matrix->
Figure SMS_10
The embodiment can set a plurality of threads to generate the three-dimensional data matrix for each data segment in parallel. Referring to FIG. 2, the present embodiment sets threads
Figure SMS_19
Processing data segment- >
Figure SMS_21
To generate a three-dimensional data matrix->
Figure SMS_22
Similarly, it is available to set thread +.>
Figure SMS_24
Thread and thread
Figure SMS_27
Thread->
Figure SMS_28
Processing data segments separately->
Figure SMS_29
Data segment->
Figure SMS_18
Data section->
Figure SMS_20
To generate a three-dimensional data matrix respectively>
Figure SMS_23
Three-dimensional data matrix->
Figure SMS_25
Three-dimensional data matrix->
Figure SMS_26
S14: and performing hashing operation on each three-dimensional data matrix in parallel to obtain hashed segment data corresponding to each data segment.
In this step, the hashing operation is used to hash the values of the three-dimensional data matrix, where the hashed segment data is a data set obtained by intercepting a specified number of bits from the hashed three-dimensional data matrix, and as described above, the specified number of bits can be customized by a designer according to the service requirement. In some embodiments, the specified number of bits is 256 bits.
Each thread is capable of performing a hashing operation on a corresponding three-dimensional data matrix in parallel, e.g., please refer to FIG. 2 in conjunction with the threads
Figure SMS_31
Three-dimensional data matrix->
Figure SMS_32
Performing a hashing operation to obtain 256 bits of segment 0 hash segment data +.>
Figure SMS_34
. Similarly, thread->
Figure SMS_36
Three-dimensional data matrix->
Figure SMS_39
Performing a hashing operation to obtain 256 bits of 1 st segment hashed segment data +.>
Figure SMS_40
. Thread->
Figure SMS_41
Three-dimensional data matrix->
Figure SMS_30
Performing a hashing operation to obtain 256 bits of 2 nd segment hashed segment data +. >
Figure SMS_33
. Thread->
Figure SMS_35
Three-dimensional data matrix->
Figure SMS_37
Performing a hashing operation to obtain 256 bits of 3 rd segment hashed segment data +.>
Figure SMS_38
S15: the plurality of hashed segment data is compressed into hashed encrypted data of a specified number of bits.
In this step, for example, please refer to fig. 2, the embodiment hashes the segment data at the 0 th segment
Figure SMS_43
Hashing segment data to segment 15 +.>
Figure SMS_44
Spliced three-dimensional matrix spliced into segments>
Figure SMS_46
Hashing segment data of segment 16 +.>
Figure SMS_48
Hashing segment data to segment 31
Figure SMS_50
Spliced three-dimensional matrix spliced into segments>
Figure SMS_52
And so on. Then follow againIn the embodiment, the segments are spliced into a three-dimensional matrix +.>
Figure SMS_54
Segment spliced three-dimensional matrix->
Figure SMS_42
Segment spliced three-dimensional matrix->
Figure SMS_45
… … section spliced three-dimensional matrix->
Figure SMS_47
Splicing the final three-dimensional matrix->
Figure SMS_49
From the final three-dimensional matrix->
Figure SMS_51
Extracting hash encryption data of 256 bits to be output +.>
Figure SMS_53
. The embodiment adopts a parallel encryption architecture, can carry out parallel hash encryption processing on each data segment in a multithreading manner, and is beneficial to improving encryption efficiency.
In some embodiments, dividing the source data into a plurality of equal length data segments includes the steps of:
s121: and sequentially dividing the source data into a plurality of data segments according to the preset length.
S122: and when the length of the last data segment is smaller than or equal to the preset length, performing the filling operation on the last data segment, so that the length of the last data segment after filling is the preset length.
In S121, as described above, the preset length may be customized by the designer according to the service requirement. In some embodiments, the preset length is 2 to the power N, where N is a positive integer. In some embodiments, the preset length is 32×h, where h is a positive integer, and when h is 8, the preset length is 256 bits. In some embodiments, the predetermined length is equal to a total number of values of the three-dimensional data matrix, the total number of values being a total number of values of the three-dimensional data matrix, for example, the three-dimensional data matrix has a matrix size of 8×8×64, and the predetermined length is 4096. For another example the matrix size of the three-dimensional data matrix is 8 x 8, the preset length is 512.
Referring to fig. 3, the present embodiment divides the source data D into data segments according to 256 bits/segment
Figure SMS_56
Data segment->
Figure SMS_58
Data segment
Figure SMS_60
Data segment->
Figure SMS_61
Data section->
Figure SMS_62
Wherein the data section->
Figure SMS_63
Data segment->
Figure SMS_64
Data segment->
Figure SMS_55
Data section->
Figure SMS_57
The number of bits of (a) is 256 bits, data segment +.>
Figure SMS_59
The number of bits of (2) is less than 256 bits.
In S122, the last data segment is an operation of arranging the last data segment among the plurality of data segments, and complement Ji Cao is an operation of supplementing the value after the last data point. Please refer to fig. 3, data segment
Figure SMS_65
For the last data segment, since the data segment +.>
Figure SMS_66
The number of bits of the data is less than 256 bits, and the present embodiment requires +. >
Figure SMS_67
Performing a padding operation such that the padded data segment +.>
Figure SMS_68
Is 256 bits in length.
In some embodiments, performing a padding operation on the last data segment such that the length of the padded last data segment is a preset length includes: and adding a first preset value after the last data segment so that the length of the last data segment after the filling is a preset length.
The first preset value can be defined by a designer according to experience, for example, the first preset value is 0 or 1, and in this embodiment, a plurality of '0's are added after the last data segment, so that the length of the last data segment after the filling is a preset length.
In some embodiments, performing a padding operation on the last data segment such that the length of the padded last data segment is a preset length includes: and adding a filling field after the last data segment so that the length of the last data segment after filling is a preset length.
In some embodiments, adding the padding field after the last data segment includes the steps of:
when the length of the last data segment is smaller than the first length, the supplementary field is composed of a first supplementary value, a plurality of second supplementary values and a third supplementary value in sequence, wherein the difference between the preset length and the first length is larger than the natural number 2.
When the length of the last data segment is the first length, the padding field is sequentially composed of a first padding value and a third padding value, wherein the difference between the preset length and the first length is equal to a natural number 2.
When the length of the last data segment is the second length, the complement field is composed of a first complement value and a first preset data segment in sequence, the first preset data segment is composed of a second complement value and a third complement value of the second length, and the difference between the preset length and the second length is equal to a natural number 1.
When the length of the last data segment is the preset length, the filling field is composed of a second preset data segment, and the second preset data segment is composed of a first filling value, a plurality of second filling values and a third filling value in sequence.
It is understood that the first, second and third filling values may be customized by the designer according to the business requirements. In some embodiments, the first and third fill values are both 1 and the second fill value is 0.
It can also be appreciated that the first length and the second length are smaller than the preset length, and the first length and the second length can be customized by a designer according to service requirements. In some embodiments, the first length is 254, the second length is 255, and the predetermined length is 256.
For example, if the data segment
Figure SMS_69
Length m of (2)<254, in the data section +.>
Figure SMS_70
A first padding value "1" is added at the end of (a) the (254-m) second padding values "0", and a third padding value "1" is added at the 256 th bit.
If the data segment
Figure SMS_71
Length m=254, then the present embodiment is in data section +.>
Figure SMS_72
The end of (1) is added with a first filling value of "1", and then added with 1 third filling value of "1".
If the data segment
Figure SMS_73
The length m=255, the present embodiment is numberedAccording to section->
Figure SMS_74
A first padding value "1" is added to the end of (c), and a first preset data segment is added, wherein the first preset data segment consists of 255 second padding values "0" and a third padding value "1".
If the data segment
Figure SMS_75
Length m=256, then the present embodiment is in data section +.>
Figure SMS_76
A second preset data segment is added at the end of the frame, and the second preset data segment is composed of 1 first complement value '1', 254 second complement values '0', and 1 third complement value '1'.
The method has no requirement on the length of the data segment, is suitable for the original data with any length, and can expand the application range of the method provided by the embodiment. Meanwhile, the embodiment can support extremely long data, specifically, the number of segments can be supported in the segment filling stage to be 2 3840 And total data amount is 2 3848 Bit bytes.
In some embodiments, generating in parallel a three-dimensional data matrix corresponding to each data segment includes: and arranging the original numerical value of each data segment according to a matrix arrangement mode, and adding the filling data in parallel after each data segment according to the matrix arrangement mode, so that the size of the filled data segment is consistent with the matrix size of the three-dimensional data matrix.
The data segment includes a plurality of original values sequentially arranged, and the original values are values constituting source data, for example, binary system of the source data is 0101011110 … … 11, wherein 0, 1, etc. are all original values. The three-dimensional data matrix includes a plurality of numerical values arranged in a matrix arrangement direction, and positional information of each numerical value in the three-dimensional data matrix may be represented by a ternary number.
The numerical expression of each ternary number is
Figure SMS_77
Wherein X, Y and Z are integers and are the coordinates of the X axis, Y axis and Z axis of the three-dimensional data matrix, respectively. k is the segment order of the data segments corresponding to the ternary number, and the segment order is the order of the corresponding data segments in the plurality of data segments. In some embodiments, 0.ltoreq.x<8,0≤y<8,0≤z<64, the total number of values of the three-dimensional data matrix is therefore: / >
Figure SMS_78
That is, a total of 4096 values form a three-dimensional data matrix.
Arranging the original values of each of the data segments according to a matrix arrangement includes: and generating original ternary numbers of each original numerical value in parallel according to a matrix arrangement mode, and arranging each original numerical value of the data segment according to each original ternary number.
The original ternary number is a ternary number corresponding to the original numerical value, wherein one original numerical value corresponds to one original ternary number. Since the length of the data segment is a specified number of bits, the present embodiment generates a plurality of original triples, the number of which is identical to the specified number of bits, from each data segment, for example, the number of bits of the data segment is 256 bits, and thus the present embodiment can generate 256 original triples from each data segment.
The (x, y, z) of the ternary number is position information, and is used for representing the position information of the numerical value in the three-dimensional data matrix. For example, when the ternary number of the values is
Figure SMS_80
The ternary number of the 0 th data segment +.>
Figure SMS_81
At the origin of the three-dimensional data matrix, and the values are mapped on the origin. When the ternary number of the numerical value is +.>
Figure SMS_82
The ternary number of the 0 th data segment +.>
Figure SMS_83
The data matrix is represented in three dimensions x=0, y=0,z=1, and the values are mapped to the positions of the arrays x=0, y=0, z=1. Similarly, when the ternary number of the numerical values is +. >
Figure SMS_84
Or->
Figure SMS_85
The ternary number of the 0 th data segment +.>
Figure SMS_86
At the position of the three-dimensional data matrix x=0, y=1, z=0, or the ternary number of the 0 th data segment +.>
Figure SMS_79
At the positions of the three-dimensional data matrix x=1, y=0, z=0.
In some embodiments, generating the original triples for each original value in parallel according to the matrix arrangement includes: according to the matrix arrangement mode, the original ternary number of each original numerical value in each data segment is sequentially and parallelly generated by taking the origin of the three-dimensional data matrix as a starting point.
The present embodiment uses the upper left corner of the front face of the three-dimensional data matrix as the origin, and as described above, the Z axis is called the team, the X axis is called the row, and the Y axis is called the vertical. The data segment comprises 256 original numerical values which are sequentially arranged, the matrix size of the three-dimensional data matrix is 8 x 64, wherein 64 ternary numbers can be configured in each team, 8 ternary numbers can be configured in each row, and 8 ternary numbers can be configured in each longitudinal direction.
In this embodiment, 64 primitive triples are configured on the 0 th queue according to the queue direction, where the expression of the 64 primitive triples of the 0 th queue is
Figure SMS_87
. Then, 64 original triples are configured on the 1 st team, wherein the expression of the 64 original triples of the 1 st team is +.>
Figure SMS_88
. Then, 64 original triples are configured on the 2 nd team, wherein the expression of the 64 original triples of the 2 nd team is +. >
Figure SMS_89
. Then, 64 original triples are configured on the 3 rd team, wherein the expression of the 64 original triples of the 3 rd team is +.>
Figure SMS_90
. The present embodiment configures the original triples of all original values in each data segment over 4 queues.
Generating in parallel in sequence the original ternary number for each original value in each data segment includes: and generating the original ternary number of each original numerical value in each data segment in parallel in sequence according to the position of each original numerical value in the data segment.
For example, the 0 th data segment
Figure SMS_91
Comprising a plurality of raw values arranged in sequence as follows: 1001 … …. The origin of the three-dimensional data matrix is defined in the upper left corner of the front face of the three-dimensional data matrix. Data segment 0->
Figure SMS_92
The position information of the 0 th original value "1" is (0, 0), wherein the original ternary number of the 0 th original value "1" is +.>
Figure SMS_93
Original ternary +_>
Figure SMS_94
Corresponding to the 0 th original value "1", and so on.
The filling data is data added after the data segments, the size of the data segments after filling is consistent with the matrix size of the three-dimensional data matrix, and the filling numerical value is a numerical value for forming the filling data. For example, the 0 th data segment
Figure SMS_95
Comprising a plurality of raw values arranged in sequence as follows: 1001 … …, the patch data includes a plurality of patch values arranged in order as follows: 00 … … 000, where, at the th 0 data section->
Figure SMS_96
After adding the filling data, the data segment after filling is: "1001 … …" + "00 … … 000", wherein the size of the data segment after the filling is 8×8×64, and the size of the data segment after the filling is consistent with the matrix size of the three-dimensional data matrix.
Adding the filling data in parallel after each data segment according to the matrix arrangement mode comprises the following steps: and generating the filling data corresponding to each data segment according to the segment sequence of each data segment, and adding the filling data in parallel after each data segment according to the matrix arrangement mode. It is understood that the present embodiment can write the upper sequence at any position in the patch data.
According to the embodiment, the filling data are added according to the segment sequence of each data segment, so that the filling data of different data segments are different, the filling data are prevented from being attacked or cracked easily due to the fact that the filling data are identical, and the encryption reliability and the encryption security are improved.
In some embodiments, the supplemental data includes non-segment identification data and segment identification data arranged in sequence, each including a plurality of supplemental values arranged in sequence. The filling ternary number is a ternary number corresponding to a filling value, wherein one filling value corresponds to one filling ternary number. The ternary numbers may be original ternary numbers or supplementary ternary numbers, each ternary number corresponding to a respective original value or a respective supplementary value, e.g., for a ternary number
Figure SMS_98
Wherein x and z satisfy the following condition: />
Figure SMS_99
Ternary number ∈>
Figure SMS_100
As the original ternary number, ternary number +.>
Figure SMS_101
The corresponding value is the original value. Corresponding ternary number->
Figure SMS_102
Wherein x, y and z satisfy the following conditions: />
Figure SMS_103
Ternary number ∈>
Figure SMS_104
To complement the ternary number, the ternary number +.>
Figure SMS_97
The corresponding value is the complement value. />
Generating the corresponding filling data of each data segment according to the segment sequence of each data segment comprises the following steps: generating segment identification data according to the segment sequence of each data segment, acquiring non-segment identification data, and sequentially combining the non-segment identification data and the segment identification data to obtain the complement data.
The segment identification data is used to identify each data segment, and in some embodiments generating the segment identification data from the segment order of each data segment includes: and determining a binary value corresponding to the segment sequence of each data segment, and taking the binary value as segment identification data.
For example, a data segment
Figure SMS_106
The segment sequence of (2) is 0, the binary value corresponding to the segment sequence "0" is 0, the data segment +.>
Figure SMS_107
The segment identification data of (2) is 0. Data section->
Figure SMS_108
The segment sequence of (1), the binary corresponding to the segment sequence "1" is 1, the data segment +.>
Figure SMS_109
The segment identification data of (1). Data section->
Figure SMS_110
The segment order of (2) is 2, and the binary corresponding to the segment order of (2) 10, data segment->
Figure SMS_111
The segment identification data of (2) is 10. Data section->
Figure SMS_112
The segment sequence of (2) is 3, the binary number corresponding to the segment sequence "3" is 11, the data segment +.>
Figure SMS_105
The segment identification data of (2) is 11.
The non-segment identification data is data excluding segment identification data from the patch data. The padding value of the non-segment identification data may be represented by either 0 or 1. The number of bits of the non-segment identification data is a difference between the size of the original ternary number and the size of the segment identification data subtracted from the matrix size of the three-dimensional data matrix in sequence, for example, the matrix size of the three-dimensional data matrix is 8×8×64=4096, and the size of the original ternary number is 256. For data segments
Figure SMS_113
The size of the segment identification data is 1, and thus, the size of the non-segment identification data is 4096-256-1=3839. Similarly available, for data segments +.>
Figure SMS_114
The size of the segment identification data is 2, and thus, the size of the non-segment identification data is 4096-256-2=3838.
The embodiment sequentially combines the non-segment identification data and the segment identification data to obtain the supplementary data, and adds the supplementary data in parallel after each data segment according to the matrix arrangement mode. For example, for a data segment
Figure SMS_115
The data segment after the filling is: "1001 … …" + "00 … … 000".
Adding the filling data in parallel after each data segment according to the matrix arrangement mode comprises the following steps: and generating the filling ternary number of each filling numerical value in parallel according to the matrix arrangement mode, and arranging the filling numerical values after each data segment according to each filling ternary number.
In some embodiments, generating the complement triples for each complement value in parallel according to the matrix arrangement includes: and according to the matrix arrangement mode, sequentially generating the complement ternary numbers of each complement value in parallel by taking the next position of the last original ternary number as a starting point.
In some embodiments, sequentially generating the complement triples for each complement value in parallel includes: and generating the filling ternary number of each filling numerical value in parallel in sequence according to the position of each filling numerical value in the filling data.
According to the three-dimensional data matrix generation method, the three-dimensional data matrix corresponding to each data segment can be generated in parallel according to the original ternary number and the complement ternary number. According to the embodiment, the three-dimensional data matrix is generated, so that the data transformation space is increased, the subsequent hash operation has a larger data transformation space, the difficulty in cracking the data is improved, and the purpose of unidirectional encryption can be achieved. In addition, in the operation of constructing a three-dimensional data matrix requiring addition of patch data, the present embodiment can support
Figure SMS_116
The data is filled, so that the embodiment can be compatible with the filling operation of source data with various lengths, and has wide application range.
The difference from the above embodiments is that in some embodiments, generating in parallel a three-dimensional data matrix corresponding to each data segment comprises the steps of: and arranging the numerical values of each data segment according to a matrix arrangement mode to obtain a three-dimensional data matrix, wherein the preset length is equal to the total numerical value of the three-dimensional data matrix.
For example, the predetermined length is 4096, i.e. each data segment contains 4096 values. The matrix size of the three-dimensional data matrix is 8×8×64, and then, according to the matrix arrangement manner, each value of the data segment can be arranged, so that the three-dimensional data matrix can be obtained. In this embodiment, the source data is sequentially divided into a plurality of data segments according to the preset length, and the preset length is equal to the total number of the three-dimensional data matrix, so that the original number contained in each data segment can fill the three-dimensional data matrix, and the three-dimensional data matrix does not need to be subjected to the filling operation again, so that the efficiency of generating the three-dimensional data matrix can be improved, and the encryption efficiency is further improved.
In some embodiments, performing a hashing operation on each three-dimensional data matrix in parallel to obtain hashed segment data corresponding to each data segment includes the steps of:
s141: and according to the preset cycle times, carrying out hash operation on each three-dimensional data matrix in parallel to obtain a hash three-dimensional matrix corresponding to each data segment.
S142: and extracting the hashed segment data with the specified bit number according to the hashed three-dimensional matrix.
In S141, the preset number of loops may be customized by the designer according to the service requirement, and in some embodiments, the preset number of loops is 24. In this embodiment, the hashing operation is performed on each three-dimensional data matrix in parallel by each thread, wherein, referring to fig. 4, in the 1 st hashing operation, for a data segment
Figure SMS_118
Three-dimensional data matrix>
Figure SMS_119
In this embodiment, three-dimensional data matrix +.>
Figure SMS_122
Performing 1 st hashing operation to obtain a three-dimensional data matrix after 1 st hashing>
Figure SMS_123
. Three-dimensional data matrix after 1 st time of hashing +.>
Figure SMS_124
As an input to the 2 nd hashing operation, in the 2 nd hashing operation, the present embodiment applies to the three-dimensional data matrix +.>
Figure SMS_125
Performing the 2 nd hash operation to obtain the three-dimensional data after the 2 nd hash operationMatrix->
Figure SMS_126
And so on, executing 24 times all the time to obtain a 24 th hashed three-dimensional data matrix +.>
Figure SMS_117
Finally, the 24 th hashed three-dimensional data matrix is->
Figure SMS_120
As a data section +.>
Figure SMS_121
Is used to hash the three-dimensional matrix.
In S142, the hashed segment output data is composed of hashed values of the specified number of bits in the hashed three-dimensional matrix. Referring to fig. 4, the three-dimensional data matrix after 24 th hashing in this embodiment
Figure SMS_127
Figure SMS_127
256 hash values are extracted as hash segment output data.
According to the embodiment, the hashing operation of the preset cycle times is carried out on the three-dimensional data matrix of each data segment, so that the hashing degree of the source data can be improved, and the encryption effect of the data can be improved.
In some embodiments, in each hashing operation, performing the hashing operation on each three-dimensional data matrix in parallel includes: and acquiring global variable information, and updating each three-dimensional data matrix in parallel according to the global variable information to obtain the three-dimensional data matrix after each hash.
The global variable information is information for globally describing source data. In some embodiments, the global variable information includes one or a combination of more than two of data segment number information before the padding, source data length information, data length information after the padding, and data segment number information after the padding. The number of data segments before the non-padding is the number of data segments in which the source data is divided into a plurality of data segments and the padding operation is not performed. The source data length information is the length of the source data. The data length information after the filling is the length of the source data after the filling. The number of data segments after the padding is the number of data segments after the source data is divided into a plurality of data segments and the padding operation is performed.
In some embodiments, updating each three-dimensional data matrix in parallel according to the global variable information, the obtaining the three-dimensional data matrix after each hash includes: generating a global variable matrix according to the global variable information, wherein the matrix size of the global variable matrix is consistent with the matrix size of the three-dimensional data matrix, fusing the three-dimensional data matrix and the global variable matrix to obtain a fused data matrix, and performing hashing operation on the fused data matrix to obtain the three-dimensional data matrix after each hashing.
Fusing the three-dimensional data matrix with the global variable matrix to obtain a fused data matrix, wherein the fusing comprises the following steps: and performing exclusive OR processing on the three-dimensional data matrix and the global variable matrix to obtain a fusion data matrix.
In some embodiments, performing a hashing operation on the fused data matrix to obtain a three-dimensional data matrix after each hashing includes: and performing transformation operation in any one or more directions of an X axis, a Y axis and a Z axis of the three-dimensional coordinate system on the numerical values of the fusion data matrix to obtain the three-dimensional data matrix after each hash. It will be appreciated that the present embodiment may perform a transform operation on the X-axis or Y-axis or Z-axis or XY-axis or XZ-axis or YZ-axis or XYZ-axis for each ternary number of values.
In some embodiments, after the transformation operation in any one or more directions of the X-axis, the Y-axis, and the Z-axis, performing a hashing operation on the fused data matrix to obtain a three-dimensional data matrix after each hashing operation further includes: and determining a target array set in the three-dimensional data matrix after each hash, wherein the target array set comprises a plurality of target values, the target values are on the appointed direction line of the three-dimensional data matrix, the target values of each target ternary number in the target array set are replaced by a preset array set, and the three-dimensional data matrix after hash is obtained again.
The target values are values located on a specified direction line of the transformed three-dimensional data matrix, a plurality of target values form a target array set, and the specified direction line is customized by a designer according to service requirements. The coordinates of each target value on the specified direction line are the same in the first target coordinate axis, the coordinates in the second target coordinate axis are the same, and the coordinates in the third target coordinate axis are different. The first target coordinate axis, the second target coordinate axis and the third target coordinate axis are customized by a designer according to business requirements.
In some embodiments, the first target coordinate axis is the X-axis, the second target coordinate axis is the Y-axis, and the third target coordinate axis is the Z-axis, so that the X-axis coordinates of each target value located on a given directional line are the same, the Y-axis coordinates are the same, but the Z-axis coordinates are different, as previously described, the X-axis is referred to as a row of the three-dimensional data matrix, the Y-axis is referred to as a vertical, and the Z-axis is referred to as a team, so that the plurality of target values are on the same team of the transformed three-dimensional data matrix.
The expression of the ternary number of the target value is
Figure SMS_128
Target array set
Figure SMS_129
That is, the embodiment selects all target values on the last queue in the transformed three-dimensional data matrix to form the target array set.
In some embodiments, the first target coordinate axis is the X-axis, the second target coordinate axis is the Z-axis, and the third target coordinate axis is the Y-axis, so that the X-axis coordinates of the respective target values located on the specified directional line are the same, the Z-axis coordinates are the same, but the Y-axis coordinates are different, so that the plurality of target values are on the same longitudinal axis of the transformed three-dimensional data matrix.
In some embodiments, the first target coordinate axis is the Y-axis, the second target coordinate axis is the Z-axis, and the third target coordinate axis is the X-axis, so that the Y-axis coordinates of the respective target values located on the specified directional line are the same, the Z-axis coordinates are the same, but the X-axis coordinates are different, so that the plurality of target values are on the same row of the transformed three-dimensional data matrix.
The preset number set can be customized by a designer according to business requirements, wherein the preset number value comprises a plurality of preset number values, the number of which is consistent with that of the target number values. For example, the preset number set includes 64 preset values, which are respectively: 01010 … … 00111. In this embodiment, each preset target value in the target array set is replaced by the preset array set, so that topology homozygosity in function transformation can be destroyed, a result is prevented from being pushed reversely, the deepening is irreversible, and the original data is ensured not to be tampered. It can be understood that the designer can also design the preset number set into a password or a verification code, so that the unidirectionality is improved, and the right-confirming function is provided.
In some embodiments, performing a transformation operation of any one or more of the X-axis, Y-axis, and Z-axis of the three-dimensional coordinate system on the values of the fused data matrix includes: and executing Y-axis filling operation on the numerical values of the fusion data matrix according to a preset Y-axis filling function.
In some embodiments, performing the Y-axis priming operation on the values of the fused data matrix according to a preset Y-axis priming function comprises: and selecting one ternary number as a reference ternary number in the fusion data matrix, determining the longitudinal direction of the reference ternary number as a reference longitudinal direction, determining the longitudinal direction of an X-axis coordinate smaller than 1 than that of the reference longitudinal direction as an adjacent longitudinal direction, determining the longitudinal direction of the X-axis coordinate larger than 1 than that of the reference longitudinal direction and the Z-axis coordinate smaller than 1 as an isolation longitudinal direction, continuously performing exclusive-or operation on the numerical values of all ternary numbers in the adjacent longitudinal directions to obtain a first exclusive-or value, continuously performing exclusive-or operation on the numerical values of all ternary numbers in the isolation longitudinal direction to obtain a second exclusive-or value, performing exclusive-or operation on the first exclusive-or value, the second exclusive-or value and the numerical value of the reference ternary number to obtain a final exclusive-or value, and replacing the numerical value of the reference ternary number with the final exclusive-or value.
According to the method, the numerical values of all the ternary numbers in the adjacent vertical directions are continuously subjected to exclusive-or operation to obtain a first exclusive-or value, the numerical values of all the ternary numbers in the isolated vertical directions are continuously subjected to exclusive-or operation to obtain a second exclusive-or value, the first exclusive-or value, the second exclusive-or value and the numerical value of the reference ternary number are subjected to exclusive-or operation to obtain a final exclusive-or value, and the final exclusive-or value is used for replacing the numerical value of the reference ternary number.
In some embodiments, performing a transformation operation of any one or more of the X-axis, Y-axis, and Z-axis of the three-dimensional coordinate system on the values of the fused data matrix includes: and executing Z-axis drifting operation on the numerical values of the fusion data matrix according to a preset Z-axis drifting function.
In some embodiments, performing a transformation operation of any one or more of the X-axis, Y-axis, and Z-axis of the three-dimensional coordinate system on the values of the fused data matrix includes: and executing XY axis torsion operation on the numerical value of the fusion data matrix according to a preset XY axis torsion function.
In some embodiments, performing a transformation operation of any one or more of the X-axis, Y-axis, and Z-axis of the three-dimensional coordinate system on the values of the fused data matrix includes: and performing X-axis blending operation on the numerical values of the fusion data matrix according to a preset X-axis blending function.
In the process of realizing the invention, the inventor finds that: although the SHA3 adopts the cassette mechanism with a sponge structure to avoid the length extension attack, the internal hash scrambling mechanism lacks optimization, the 5x5 design of the SHA3 generates a central bit with insufficient scrambling degree, and an additional fifth step is needed to specially operate on the central bit to supplement the defect of scrambling degree, but the step cannot provide random entropy increment for other bits except the center, so that the step efficiency is consumed, the encryption mechanism structure is not compact enough, and additional learning consumption is formed on an execution level and subsequent extension, and sustainable development is reduced. In the present invention, in each of the above embodiments, the value of the ternary number of the center position is adjusted in performing the Z-axis drifting operation or the XY-axis twisting operation, without having to provide a special step for adjusting the value of the ternary number of the center position. The embodiment can simplify corresponding steps and improve encryption efficiency in rounds on the premise of ensuring the reliability and irreversibility of data transformation. On the other hand, the optimized cassette mechanism used in the present embodiment can provide more excellent security capacity, simplicity, and sustainable expansion capability while preventing length expansion attacks.
In some embodiments, compressing the plurality of hashed segment data into hashed, encrypted data of a specified number of bits includes: the plurality of hashed segment data is compressed in logarithmic mode into hashed encrypted data of a specified number of bits.
As described above, the conventional algorithm of SHA3 performs hash encryption processing on source data in a sequential manner, and the encryption time of the parallel hash encryption method increases linearly with the increase of source data. For example, assuming that there are 32 hashed segment data lengths from the source data, SHA3 and previous SHA algorithms process the segment of source data in a sequential manner, 32 times the 1 hashed segment data length source data time is required for processing. In this embodiment, 32 pieces of hashed segment data can be processed simultaneously in a parallel manner, and then the output of every 16 pieces of hashed segment data is combined into the first three-dimensional matrix, so that the output is reduced in a reciprocating manner, and the effect of logarithmic compression time curve is achieved. The computational complexity of this embodiment is LOG 16 (n) is a logarithmic increase. This is a significant improvement over the O (n) computational complexity of SHA3 and previous SHA algorithms.
In some embodiments, compressing the plurality of hashed segment data in logarithmic mode into hashed, encrypted data of a specified number of bits includes the steps of:
S151: and splicing the plurality of hashed segment data in parallel into a segment spliced three-dimensional matrix with a specified matrix size according to a preset segment splicing coefficient.
S152: and according to the preset cycle times, performing hashing operation on each segment spliced three-dimensional matrix in parallel to obtain a target three-dimensional matrix corresponding to each segment spliced three-dimensional matrix.
S153: and extracting target hash data with specified digits according to the target three-dimensional matrix.
S154: the plurality of target hashed data is compressed into hashed encrypted data of a specified number of bits.
In S151, the segment splicing coefficient is customized by the designer according to the service requirement, for example, the segment splicing coefficient is 16. The three-dimensional segment-spliced matrix is a three-dimensional matrix formed by splicing a plurality of pieces of hashed segment data with a number of segment splicing coefficients, the size of a specified matrix of the three-dimensional segment-spliced matrix is equal to the number of specified bits of the hashed segment data multiplied by the segment splicing coefficients, referring to fig. 5, the segment splicing coefficients are 16, and the number of specified bits is 256, and the embodiment can splice 16 pieces of hashed segment data 51 into a three-dimensional segment-spliced matrix 52 with a specified matrix size of 8×8×64.
In some embodiments, before splicing the plurality of hashed segment data in parallel into the segment-spliced three-dimensional matrix of the specified matrix size, if the number of the plurality of hashed segment data is less than Duan Pinjie coefficients, the plurality of hashed segment data is spliced in sequence, and a second padding field is added after the last hashed segment data, such that the size of the added hashed segment data satisfies the specified matrix size. The value of the second padding field may be customized by the designer according to the service requirement, for example, the values of the second padding field are all 0.
In some embodiments, adding the second pad field after the last hashed segment data includes the steps of: and calculating the number of the segments to be supplemented according to the size of the designated matrix, the number of the plurality of pieces of hashed segment data and the designated bit number of each piece of hashed segment data, and generating a second filling field according to the number of the segments to be supplemented and the designated bit number of each piece of hashed segment data.
For example, the plurality of hashed segment data are hashed segment data, respectively
Figure SMS_131
Hashing segment data->
Figure SMS_132
Hashing segment data->
Figure SMS_133
… … hashed segment data->
Figure SMS_134
The number of the plurality of hashed segment data is 14 segments, the size of the designated matrix is 8 x 64, the number of designated bits is 256, and the matrix of the designated parent segment data is +.>
Figure SMS_135
Thus, the number of segments to be complemented is 2, the bits of the second padding fieldThe number is 2 x 256 = 512, therefore hashed segment data +.>
Figure SMS_136
As the last hashed segment data, the present embodiment is described as +.>
Figure SMS_137
After this 512 values are added, which are defined by +.>
Figure SMS_130
The last 512-bit value of the matrix of (c) is filled.
In S152, as described above, the preset number of loops may be customized by the designer according to the business requirements, and in some embodiments, the preset number of loops is 24. In this embodiment, the hashing operation is performed on each segment of the spliced three-dimensional matrix in parallel by each thread. For example, in the 1 st hashing operation, a three-dimensional matrix is stitched for a segment
Figure SMS_139
In the embodiment, the three-dimensional matrix is spliced by the opposite segments>
Figure SMS_140
Performing 1 st hashing operation to obtain a segment spliced three-dimensional matrix after 1 st hashing>
Figure SMS_141
. Segment spliced three-dimensional matrix after 1 st time hashing>
Figure SMS_142
As an input to the 2 nd hashing operation, in the 2 nd hashing operation, the present embodiment splices the three-dimensional matrix for the segments +.>
Figure SMS_143
Performing the 2 nd hashing operation to obtain a segment spliced three-dimensional matrix after the 2 nd hashing operation>
Figure SMS_144
And so on, the method is always carried out 24 times, and the segment splicing after 24 th hashing is obtainedThree-dimensional matrix->
Figure SMS_145
Finally, the 24 th hashed segments are spliced into a three-dimensional matrix>
Figure SMS_138
As a target three-dimensional matrix.
In S153, the target hashed data is composed of hashed values of a specified number of bits in the target three-dimensional matrix. For example, the embodiment splices the three-dimensional matrix at the 24 th hashed segment
Figure SMS_146
Figure SMS_146
256 hash values are extracted as target hash data.
In S154, the present embodiment can compress the plurality of target hash data into hash encrypted data with a specified bit number, and since the target hash data is encrypted data, the present embodiment can integrate the plurality of target hash data and extract the hash encrypted data with the specified bit number therefrom, thereby achieving the effect of multiple encryption.
In some embodiments, compressing the plurality of target hashed data into hashed, encrypted data of a specified number of bits includes the steps of: and generating a final three-dimensional matrix according to the plurality of target hash data, and extracting hash encryption data with specified digits from the final three-dimensional matrix. According to the embodiment, the plurality of target hash data can be finally integrated into the final three-dimensional matrix, and the hash encryption data with the specified bit number is extracted from the final three-dimensional matrix, so that the mixing complexity can be improved, and the encryption effect can be improved.
In some embodiments, generating the final three-dimensional matrix from the plurality of target hashed data includes: and sequentially selecting a plurality of target hash data with the quantity consistent with the preset segment splicing coefficient to splice the target hash data into a candidate three-dimensional matrix, and generating a final three-dimensional matrix according to at least one candidate three-dimensional matrix.
In some embodiments, sequentially selecting a number of target hashed data stitching to form a candidate three-dimensional matrix that is consistent with the preset segment stitching coefficients includes:
a11: it is determined whether the number of the plurality of target hashed data is equal to the segment splice coefficient.
A12: and if the number is equal to the segment splicing coefficient, splicing the plurality of target hash data into a candidate three-dimensional matrix with the specified matrix size.
A13: if the number is greater than the segment splicing coefficient, a plurality of target hashed data with the number consistent with the segment splicing coefficient are spliced into a candidate three-dimensional matrix, and a first filling field is added to the rest of the target hashed data, so that the size of the hashed segment data after being added is consistent with the size of the appointed matrix of the candidate three-dimensional matrix.
A14: if the number is smaller than Duan Pinjie, adding a first filling field after the last target hashed segment data so that the size of the added hashed segment data is consistent with the specified matrix size of the candidate three-dimensional matrix.
The operation of adding the first padding field after the last target hashed segment data is the same as adding the second padding field after the last hashed segment data, and will not be described here.
In some embodiments, generating the final three-dimensional matrix from the at least one candidate three-dimensional matrix comprises: and performing hashing operation on each candidate three-dimensional matrix in parallel to obtain hashed candidate three-dimensional matrixes, extracting candidate hashed segment data with specified digits from the hashed candidate three-dimensional matrixes, and integrating the plurality of candidate hashed segment data into a final three-dimensional matrix in a logarithmic mode.
In some embodiments, integrating the plurality of candidate hashed segment data in a logarithmic mode into a final three-dimensional matrix includes:
b11: it is determined whether the number of the plurality of candidate hashed data is equal to the segment splice coefficient.
B12: and if the number is equal to the segment splicing coefficient, splicing the plurality of candidate hashed data into a final three-dimensional matrix with the specified matrix size.
B13: if the number is greater than the segment splicing coefficient, a plurality of candidate hashed data with the number consistent with the segment splicing coefficient are spliced into a new candidate three-dimensional matrix, a third filling field is added to the rest candidate hashed data, so that the size of the added candidate hashed segment data is consistent with the size of the appointed matrix of the candidate three-dimensional matrix, and the step of executing the hash operation on each candidate three-dimensional matrix in parallel is returned.
And B14: if the number is smaller than Duan Pinjie coefficient, adding a third filling field after the last candidate hashed segment data so that the size of the added candidate hashed segment data is consistent with the designated matrix size of the final three-dimensional matrix.
For example, the number of the target hashed data is 16, and the embodiment splices the 16 target hashed data into 8×8×64 candidate three-dimensional matrices, and uses the 8×8×64 candidate three-dimensional matrices as the final three-dimensional matrix. Finally, the present embodiment extracts 256-bit hash-encrypted data from the final three-dimensional matrix.
For another example, the number of the plurality of target hashed data is 34, the embodiment splices 1 candidate three-dimensional matrix according to the rule of every 16 target hashed data, so that 2 candidate three-dimensional matrices can be obtained, the remaining 2 target hashed data needs to be added with a first filling field to become 1 candidate three-dimensional matrix, so that 3 candidate three-dimensional matrices can be obtained in total, then the embodiment performs 24 rounds of hash operations on the 3 candidate three-dimensional matrices in parallel, and finally obtains 3 hashed candidate three-dimensional matrices. Next, the present embodiment extracts 256-bit candidate hashed segment data from each hashed candidate three-dimensional matrix, and can extract a total of 3 sets of 256-bit candidate hashed segment data.
Then, since the number of the 3 sets of 256-bit candidate hashed segment data is 3 and is smaller than Duan Pinjie coefficients, the present embodiment increases 13×256= 3,328 values from the 1 st candidate three-dimensional matrix as the third padding field after the last candidate hashed data of the 3 sets of 256-bit candidate hashed segment data, so that the size of the increased candidate hashed segment data coincides with the specified matrix size of the final three-dimensional matrix. Finally, the present embodiment extracts 256-bit hash-encrypted data from the final three-dimensional matrix.
When the length of the source data is large, the embodiment can splice a plurality of pieces of hashed segment data into the segment spliced three-dimensional matrix with the size of the appointed matrix in parallel, and then extract the target hashed data with the appointed bit number from the segment spliced three-dimensional matrix, so that the aim of logarithmic compression can be fulfilled, and the encryption efficiency is improved.
In order to illustrate the benefits of the method provided by the embodiments of the present invention in detail, the following description is aided by SHA3 algorithm as a comparative example, which is specifically shown as follows:
illustrated by SHA 3: for encrypting a source data (1 tb) of total 1,099,511,627,776 bits, we first split it into 256-bit data segments, which total 4,294,967,296 (40 billion) data segments, and then encrypt the data segments.
If SHA3 is used for encryption, SHA3 encrypts the 1 st 256-bit data segment first, then encrypts the output result in the same way as the second data segment, and so on, for a total of 4,294,967,296 rounds, if each round consumes one time unit t, the total encryption time is 4,294,967,296t.
If the encryption is performed by using the method provided by the embodiment of the invention, if there are 32,768 chips providing 65,536 parallel threads, the embodiment needs to spend 65,536t to complete the first round of encryption, then the compression with the splicing coefficient of 16 is performed, the total number of fragments is reduced to 268,435,456 after 4,096t, then the total number of fragments is reduced to 16,777,216 after 256t, then the total number of fragments is reduced to 1,048,576 after 16t, then the total number of fragments is reduced to 65,536 after 1t, then the total number of fragments is reduced to 4,096 after 1t, then the total number of fragments is reduced to 256 after 1t, then the total number of fragments is reduced to 16 after 1t, and then the total number of fragments is reduced to 1 after 1t, thus the final output is obtained. Thus, the total consumption time is 65,536+4,096+256+16+1+1+1+1=69,909t, which is 6 ten thousand times faster than SHA 3.
It should be noted that, in the foregoing embodiments, there is not necessarily a certain sequence between the steps, and those skilled in the art will understand that, according to the description of the embodiments of the present invention, the steps may be performed in different orders in different embodiments, that is, may be performed in parallel, may be performed interchangeably, or the like.
Referring to fig. 6, fig. 6 is a schematic circuit diagram of an electronic device according to an embodiment of the present invention, where the electronic device may be any suitable type of device or electronic product, for example, the electronic device includes a server, a computer, a mobile phone, or other devices or electronic products with logic computing and analyzing functions. As shown in fig. 6, the electronic device 600 includes one or more processors 61 and a memory 62. In fig. 6, a processor 61 is taken as an example.
The processor 61 and the memory 62 may be connected by a bus or otherwise, which is illustrated in fig. 6 as a bus connection.
The memory 62 is used as a non-volatile computer readable storage medium for storing non-volatile software programs, non-volatile computer executable programs, and modules, such as program instructions/modules corresponding to the parallel hash encryption method in the embodiment of the present invention. The processor 61 implements the functions of the parallel hash encryption method provided by the above-described method embodiment by running a nonvolatile software program, instructions, and modules stored in the memory 62.
The memory 62 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, memory 62 may optionally include memory located remotely from processor 61, which may be connected to processor 61 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The program instructions/modules are stored in the memory 62 that, when executed by the one or more processors 61, perform the parallel hash encryption method of any of the method embodiments described above.
Embodiments of the present invention also provide a storage medium storing computer-executable instructions that are executable by one or more processors, such as one of the processors 61 in fig. 6, to cause the one or more processors to perform the parallel hash encryption method of any of the method embodiments described above.
Embodiments of the present invention also provide a computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions which, when executed by an electronic device, cause the electronic device to perform any of the parallel hash encryption methods.
The above-described embodiments of the apparatus or device are merely illustrative, in which the unit modules illustrated as separate components may or may not be physically separate, and the components shown as unit modules may or may not be physical units, may be located in one place, or may be distributed over multiple network module units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
From the above description of embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus a general purpose hardware platform, or may be implemented by hardware. Based on such understanding, the foregoing technical solution may be embodied essentially or in a part contributing to the related art in the form of a software product, which may be stored in a computer readable storage medium, such as ROM/RAM, a magnetic disk, an optical disk, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform the method described in the respective embodiments or some parts of the embodiments.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and are not limiting; the technical features of the above embodiments or in the different embodiments may also be combined within the idea of the invention, the steps may be implemented in any order, and there are many other variations of the different aspects of the invention as described above, which are not provided in detail for the sake of brevity; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the invention.

Claims (11)

1. A parallel hash encryption method, comprising:
acquiring source data, and dividing the source data into a plurality of data segments with equal length;
generating three-dimensional data matrixes corresponding to each data segment in parallel;
performing hashing operation on each three-dimensional data matrix in parallel to obtain hashed segment data corresponding to each data segment;
And compressing a plurality of pieces of hashed segment data into hashed encrypted data with specified digits.
2. The method of claim 1, wherein the dividing the source data into a plurality of equal-length data segments comprises:
sequentially dividing the source data into a plurality of data segments according to a preset length;
and when the length of the last data segment is smaller than or equal to the preset length, adding a first preset value after the last data segment, so that the length of the last data segment after the filling is the preset length.
3. The method of claim 1, wherein the parallel generation of the three-dimensional data matrix corresponding to each of the data segments comprises:
and arranging the numerical values of each data segment according to a matrix arrangement mode to obtain the three-dimensional data matrix, wherein the preset length is equal to the total numerical value of the three-dimensional data matrix.
4. The method of claim 1, wherein said performing a hashing operation on each of said three-dimensional data matrices in parallel to obtain hashed segment data corresponding to each of said data segments comprises:
according to the preset cycle times, carrying out hash operation on each three-dimensional data matrix in parallel to obtain a hash three-dimensional matrix corresponding to each data segment;
And extracting the hash segment data with the specified bit number according to the hash three-dimensional matrix.
5. The method of claim 4, wherein in each hashing operation, the parallel performing a hashing operation on each of the three-dimensional data matrices comprises:
acquiring global variable information;
and updating each three-dimensional data matrix in parallel according to the global variable information to obtain the three-dimensional data matrix after each hash.
6. The method of any of claims 1 to 5, wherein compressing the plurality of hashed segment data into hashed, encrypted data of a specified number of bits comprises: compressing a plurality of the hashed segment data into hashed encrypted data of a specified number of bits in a logarithmic mode.
7. The method of claim 6, wherein compressing the plurality of hashed segment data in a logarithmic mode into hashed, encrypted data of a specified number of bits comprises:
splicing a plurality of pieces of hashed segment data into a segment spliced three-dimensional matrix with a specified matrix size according to a preset segment splicing coefficient;
performing hashing operation on each segment spliced three-dimensional matrix according to preset circulation times to obtain a target three-dimensional matrix corresponding to each segment spliced three-dimensional matrix;
Extracting target hash data with specified digits according to the target three-dimensional matrix;
compressing a plurality of the target hash data into hash encryption data with a specified bit number.
8. The method of claim 7, wherein compressing the plurality of target hashed data into hashed, encrypted data of a specified number of bits comprises:
generating a final three-dimensional matrix according to a plurality of target hash data;
and extracting hash encryption data with specified digits from the final three-dimensional matrix.
9. The method of claim 8, wherein the generating a final three-dimensional matrix from a plurality of the target hashed data comprises:
sequentially selecting a plurality of target hash data with the quantity consistent with the splicing coefficient of the preset section to splice the target hash data into a candidate three-dimensional matrix;
and generating a final three-dimensional matrix according to at least one candidate three-dimensional matrix.
10. A storage medium storing computer executable instructions for causing an electronic device to perform the parallel hash encryption method of any one of claims 1 to 9.
11. An electronic device, comprising:
at least one processor; the method comprises the steps of,
A memory communicatively coupled to the at least one processor; wherein, the liquid crystal display device comprises a liquid crystal display device,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the parallel hash encryption method of any one of claims 1 to 9.
CN202310464782.3A 2023-04-27 2023-04-27 Parallel hash encryption method, storage medium and electronic device Active CN116186746B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310464782.3A CN116186746B (en) 2023-04-27 2023-04-27 Parallel hash encryption method, storage medium and electronic device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310464782.3A CN116186746B (en) 2023-04-27 2023-04-27 Parallel hash encryption method, storage medium and electronic device

Publications (2)

Publication Number Publication Date
CN116186746A true CN116186746A (en) 2023-05-30
CN116186746B CN116186746B (en) 2023-07-14

Family

ID=86440680

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310464782.3A Active CN116186746B (en) 2023-04-27 2023-04-27 Parallel hash encryption method, storage medium and electronic device

Country Status (1)

Country Link
CN (1) CN116186746B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070244850A1 (en) * 2006-04-17 2007-10-18 Microsoft Corporation Perfect multidimensional spatial hashing
CN103559458A (en) * 2013-10-09 2014-02-05 广州华迅网络科技有限公司 Method and system for acquiring data hashes
US20150098563A1 (en) * 2013-10-09 2015-04-09 Sean M. Gulley Generating Multiple Secure Hashes from a Single Data Buffer
US9112525B1 (en) * 2014-03-28 2015-08-18 Comtech Ef Data Corp. System and method for parallel hash-based data compression
CN115664640A (en) * 2022-12-23 2023-01-31 苏州浪潮智能科技有限公司 Hardware implementation method, system, storage medium and equipment of SHA-3 algorithm

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070244850A1 (en) * 2006-04-17 2007-10-18 Microsoft Corporation Perfect multidimensional spatial hashing
CN103559458A (en) * 2013-10-09 2014-02-05 广州华迅网络科技有限公司 Method and system for acquiring data hashes
US20150098563A1 (en) * 2013-10-09 2015-04-09 Sean M. Gulley Generating Multiple Secure Hashes from a Single Data Buffer
US9112525B1 (en) * 2014-03-28 2015-08-18 Comtech Ef Data Corp. System and method for parallel hash-based data compression
CN115664640A (en) * 2022-12-23 2023-01-31 苏州浪潮智能科技有限公司 Hardware implementation method, system, storage medium and equipment of SHA-3 algorithm

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
李建瑞;汪鹏君;张跃军;李刚;: "基于SHA-3算法的图像密钥生成方法", 华东理工大学学报(自然科学版), no. 05, pages 119 - 123 *

Also Published As

Publication number Publication date
CN116186746B (en) 2023-07-14

Similar Documents

Publication Publication Date Title
US11082482B2 (en) Block chain encoding with fair delay for distributed network devices
US20180011996A1 (en) Secret shared random access machine
US11750403B2 (en) Robust state synchronization for stateful hash-based signatures
US10749670B2 (en) Block chain decoding with fair delay for distributed network devices
CN113055431B (en) Block chain-based industrial big data file efficient chaining method and device
US11722313B2 (en) State synchronization for post-quantum signing facilities
CN111611621A (en) Block chain based distributed data encryption storage method and electronic equipment
CN112182109A (en) Distributed data coding storage method based on block chain and electronic equipment
CN116186747A (en) Adaptive hash encryption method, nonvolatile readable storage medium, and electronic device
CN115580390A (en) Multi-scene mode calculation method and system under safe multi-party calculation
KR101428649B1 (en) Encryption system for mass private information based on map reduce and operating method for the same
CN110611568B (en) Dynamic encryption and decryption method, device and equipment based on multiple encryption and decryption algorithms
CN116186746B (en) Parallel hash encryption method, storage medium and electronic device
CN110515591B (en) Random number generation method and device based on block chain
CN109951275B (en) Key generation method and device, computer equipment and storage medium
WO2020233086A1 (en) Block processing method and apparatus, computer device and storage medium
CN111931204A (en) Encryption and de-duplication storage method and terminal equipment for distributed system
CN116318660A (en) Message expansion and compression method and related device
CN115276952A (en) Private data processing method and device
CN112181974B (en) Identification information distribution method, system and storage device
US20200204363A1 (en) Quantum-resistant cryptoprocessing
CN114124469A (en) Data processing method, device and equipment
CN112181308A (en) Block chain based distributed data storage method and electronic equipment
CN111931202A (en) Encrypted storage method, terminal device and storage medium for distributed system
Pu et al. Computing privacy-preserving edit distance and Smith-Waterman problems on the GPU architecture

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant