CN114091117A - Data storage method, server, medium, and apparatus - Google Patents

Data storage method, server, medium, and apparatus Download PDF

Info

Publication number
CN114091117A
CN114091117A CN202111404029.2A CN202111404029A CN114091117A CN 114091117 A CN114091117 A CN 114091117A CN 202111404029 A CN202111404029 A CN 202111404029A CN 114091117 A CN114091117 A CN 114091117A
Authority
CN
China
Prior art keywords
value
module
data blocks
bit
string
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.)
Pending
Application number
CN202111404029.2A
Other languages
Chinese (zh)
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.)
Bank of China Ltd
Original Assignee
Bank of China 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 Bank of China Ltd filed Critical Bank of China Ltd
Priority to CN202111404029.2A priority Critical patent/CN114091117A/en
Publication of CN114091117A publication Critical patent/CN114091117A/en
Pending legal-status Critical Current

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
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • 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/62Protecting access to data via a platform, e.g. using keys or access control rules
    • G06F21/6218Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database
    • 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/64Protecting data integrity, e.g. using checksums, certificates or signatures

Landscapes

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

Abstract

The application discloses a data storage method, a server, a medium and a device, which can be applied to the field of block chains or the field of finance. After the preset 80 constants are obtained, the 80 constants are reassigned to obtain the 80 reassigned constants. In this application, if the input information is divided into a plurality of data blocks, in the process of calculating the next data block, the identifier H of the buffer corresponding to the next data block0Initial value of (1), H1Initial value of (1), H2Initial value of (1), H3Initial value of (1), H4Is the initial value of H obtained for the last data block0Final value of (1), H1Final value of (1), H2Final value of (1), H3Is the most important ofFinal value, H4The final value of (c), i.e., the specific content of the ciphertext, is not only related to the number of data blocks into which the input information is divided, but also related to the 80 re-assigned constants. If the input information is violently cracked, the number of the divided data blocks and the 80 constants after re-assignment of the input information need to be cracked, so that the violent cracking is more difficult, and the safety of the ciphertext is improved.

Description

Data storage method, server, medium, and apparatus
Technical Field
The present application relates to the field of blockchain technologies, and in particular, to a data storage method, a server, a medium, and an apparatus.
Background
SHA-1(Secure Hash Algorithm 1) is a function for generating 160-bit ciphertext and is widely applied in the prior art, but with the continuous development of computer computing capacity, security personnel have successfully broken the SHA-1 Algorithm.
Therefore, how to strengthen the existing SHA-1 is a necessary requirement for the technical development.
Disclosure of Invention
In view of the above, the present application provides a data storage method, a server, a medium, and an apparatus.
In order to achieve the above purpose, the present application provides the following technical solutions:
according to a first aspect of the embodiments of the present disclosure, there is provided a data storage method, including:
acquiring input information to be stored to a block chain;
expanding the length complementary bits of the input information into 512 bits x Q to obtain a first message, wherein Q is any integer greater than or equal to 1;
dividing the first message into Q data blocks, wherein the number of bits of the data blocks is 512 bits;
setting the initial value of G to be 1;
the following operations are performed for the G-th data block:
dividing the data block into 16 target sub data blocks, wherein the number of bits of the target sub data blocks is 32;
performing operation on the 16 target sub data blocks to obtain 64 operation sub data blocks to obtain 80 sub data blocks, wherein the bit number of the operation sub data blocks is 32 bits, and the 80 sub data blocks comprise the 16 target sub data blocks and the 64 operation sub data blocks;
obtaining preset 80 constants, wherein the values of the 80 constants are as follows:
Ktfirst predetermined value (0)<=t<=19)
KtSecond predetermined value (20)<=t<=39)
KtThird preset value (40)<=t<=59)
KtFourth preset value (60)<=t<=79);
Setting the initial value of i to be 1;
for an ith preset numerical value, converting the ith preset numerical value into a decimal number to obtain a first character string consisting of the decimal number;
using formulas
Figure BDA0003371661370000021
Obtaining a second character string; wherein, bmIs the m-th character in the second string, b1Is the character located at bit 1 of the second string, and b1=a1
Figure BDA0003371661370000022
avIs the v-th character in the first string, P (a)v) Means avProbability of occurrence in said first string, n being the total number of characters contained in the first string, avA number means avA number of occurrences in the first string;
using formulas
Figure BDA0003371661370000023
To obtain a third string, wherein cm+1Is the m +1 th character in the third string;
converting the obtained third character string into a 16-system to obtain an ith candidate value;
setting the i-th preset numerical value as the i-th candidate numerical value mod0 xFFFFFFFF;
setting i to i +1, returning to the step, converting the ith preset numerical value into a decimal number for the ith preset numerical value to obtain a first character string consisting of the decimal number until i is equal to 5;
obtaining an identity of a buffer H0Initial value of (1), H1Initial value of (1), H2Initial value of (1), H3Initial value of (1), H4An initial value of (1);
h is to be0Of (d), H1Of (d), H2Of (d), H3Of (d), H4Said initiation ofValues are respectively assigned to the first parameter, the second parameter, the third parameter, the fourth parameter and the fifth parameter;
setting the initial value of P to be 0;
for t ═ P, the following calculation is performed:
TEMP=S5(H0)+ft(H1,H2,H3)+H4+Wt+Kt;H4=H3;H3=H2;H2=S30(H1);H1=H0;H0TEMP; wherein, WtFor the t +1 th sub-data block of the 80 sub-data blocks, ft(H1,H2,H3) Is a preset function; s5(H0) Means that H is0Left shift by 5; s30(H1) Means that H is1Left shift by 30;
setting P +1, returning to the step for t P, the following calculation is performed until P equals 80 to obtain the identification H of the buffer area0Value of (A), H1Value of (A), H2Value of (A), H3Value of (A), H4A value of (d);
let H0Final value of ═ H0Value of + first parameter, H1Final value of ═ H1Value of + second parameter, H2Final value of ═ H2Value of + third parameter, H3Final value of ═ H3Value of + fourth parameter, H4Final value of (H)4The value of + the fifth parameter;
subjecting said H to0Final value of (1), H1Final value of (a), H2Final value of (1), H3Final value of (1), H4Respectively as the mark H of the buffer corresponding to the G +1 th data block0Initial value of (1), H1Initial value of (1), H2Initial value of (1), H3Initial value of (1), H4An initial value of (1);
setting G to G +1, and returning to the step to execute the following operations on the G-th data block until G is larger than Q;
according to H0、H1、H2、H3、H4In the order of (A) and (B), is0Final value of (1), H1Final value of (1), H2Final value of (1), H3Final value of (1), H4160 bit hash value;
obtaining a ciphertext based on the 160-bit hash value;
and storing the ciphertext to a block chain.
According to a second aspect of embodiments of the present disclosure, there is provided a data storage device including:
the first acquisition module is used for acquiring input information to be stored to the block chain;
a bit-complementing expansion module, configured to expand the length bit-complementing of the input information to 512 bits × Q to obtain a first packet, where Q is any integer greater than or equal to 1;
the first dividing module is used for dividing the first message into Q data blocks, and the bit number of each data block is 512 bits;
the first setting module is used for setting the initial value of G to be 1;
the following operations are performed for the G-th data block:
the second dividing module is used for dividing the data block into 16 target sub data blocks, and the number of bits of each target sub data block is 32;
the operation module is used for performing operation on the 16 target sub data blocks to obtain 64 operation sub data blocks so as to obtain 80 sub data blocks, the bit number of each operation sub data block is 32 bits, and the 80 sub data blocks comprise 16 target sub data blocks and 64 operation sub data blocks;
the second obtaining module is configured to obtain preset 80 constants, where values of the 80 constants are as follows:
Ktfirst preset value (0)<=t<=19)
KtSecond predetermined value (20)<=t<=39)
KtThird preset value (40)<=t<=59)
KtFourth preset value (60)<=t<=79);
The first setting module is used for setting the initial value of i to be 1;
the first conversion module is used for converting the ith preset numerical value into a decimal number for the ith preset numerical value so as to obtain a first character string consisting of the decimal numbers;
a third obtaining module for utilizing the formula
Figure BDA0003371661370000041
Obtaining a second character string; wherein, bmIs the m-th character in the second string, b1Is the character located at bit 1 of the second string, and b1=a1
Figure BDA0003371661370000042
avIs the v-th character in the first string, P (a)v) Means avProbability of occurrence in said first string, n being the total number of characters contained in the first string, avA number means avA number of occurrences in the first string;
a fourth obtaining module for utilizing the formula
Figure BDA0003371661370000043
To obtain a third string, wherein cm+1Is the m +1 th character in the third string;
the second conversion module is used for converting the obtained third character string into a 16-system so as to obtain an ith candidate value;
a second setting module, configured to make an ith preset value equal to the ith candidate value mod0 xfffffffff;
the first trigger module is used for setting i to i +1 and returning to the first conversion module until i is equal to 5;
a fifth obtaining module, configured to obtain an identifier H of the buffer0Initial value of (1), H1Initial value of (1), H2Initial value of (1), H3Initial value of (1), H4An initial value of (1);
second oneAn assignment module for assigning H0Of (d), H1Of (d), H2Of (d), H3Of (d), H4Respectively assigning the initial values to a first parameter, a second parameter, a third parameter, a fourth parameter and a fifth parameter;
the third assignment module is used for setting the initial value of P to be 0;
a calculation module for performing the following calculation for t ═ P:
TEMP=S5(H0)+ft(H1,H2,H3)+H4+Wt+Kt;H4=H3;H3=H2;H2=S30(H1);H1=H0;H0TEMP; wherein, WtFor the t +1 th sub-data block of the 80 sub-data blocks, ft(H1,H2,H3) Is a preset function; s5(H0) Means that H is0Left shift by 5; s30(H1) Means that H is1Left shift by 30;
a second trigger module, configured to set P +1, and return to the calculation module until P equals 80, so as to obtain an identifier H of the buffer area0Value of (A), H1Value of (A), H2Value of (A), H3Value of (H)4A value of (d);
a fourth assignment module for ordering H0Final value of ═ H0Value of + first parameter, H1Final value of ═ H1Value of + second parameter, H2Final value of (H)2Value of + third parameter, H3Final value of ═ H3Value of + fourth parameter, H4Final value of ═ H4The value of + the fifth parameter;
a fifth valuation module to assign H to0Final value of (1), H1Final value of (1), H2Final value of (1), H3Final value of (1), H4Respectively as the mark H of the buffer corresponding to the G +1 th data block0Initial value of (1), H1Initial value of (1), H2Initial value of (1), H3Initial value of (1), H4An initial value of (1);
the third triggering module is used for setting G +1 and returning to the second dividing module until G is larger than Q;
a sixth obtaining module for obtaining according to H0、H1、H2、H3、H4In the order of (A) and (B), is0Final value of (a), H1Final value of (1), H2Final value of (1), H3Final value of (a), H4The 160-bit abstract composed of the final values of the two-bit abstract is determined as a ciphertext;
and the storage module is used for storing the ciphertext to the block chain.
According to a third aspect of the embodiments of the present disclosure, there is provided a server, including:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement the data storage method of the first aspect.
According to a fourth aspect of embodiments of the present disclosure, there is provided a computer-readable storage medium, wherein instructions, when executed by a processor of a server, enable the server to perform the data storage method of the first aspect.
According to a fifth aspect of the embodiments of the present disclosure, there is provided a computer program product directly loadable into an internal memory of a computer, wherein the memory is included in the server shown in the third aspect and contains software codes, and the computer program can realize the data storage method according to the first aspect after being loaded into and executed by the computer.
According to the technical scheme, after 80 preset constants are obtained, the data storage method provided by the application performs the following processing on each constant: converting the constant from 16 to a decimal number to obtain a first character string consisting of the decimal number; using formulas
Figure BDA0003371661370000061
Obtaining a second character string; wherein, bmIs the m-th character in the second string, b1Is the 1 st bit character in the second string, and b1=a1
Figure BDA0003371661370000062
avIs the v-th character in the first string, P (a)v) Means avProbability of occurrence in said first string, n being the total number of characters contained in the first string, avA number means avA number of occurrences in the first string; using a formula
Figure BDA0003371661370000063
To obtain a third string, wherein cm+1Is the m +1 th character in the third string; converting the obtained third character string into a 16-system to obtain a candidate value; the constant is reassigned by assigning the constant value mod0xFFFFFFFF to obtain the 80 reassigned constant. H derived based on 80 reassigned constants0Value of (A), H1Value of (A), H2Value of (A), H3Value of (A), H4And H obtained based on 80 constants set in advance0Value of (A), H1Value of (A), H2Value of (A), H3Value of (A), H4If the input information is divided into a plurality of data blocks, the identifier H of the buffer area corresponding to the next data block is calculated in the next data block0Initial value of (1), H1Initial value of (1), H2Initial value of (1), H3Initial value of (1), H4Initial value of (2), H obtained for the last data block0Final value of (1), H1Final value of (1), H2Final value of (a), H3Final value of (1), H4The final value of (a), i.e., the specific content of the resulting ciphertext, is related not only to the number of data blocks into which the input information is divided, but also to the 80 re-assigned constants. If necessary, brute force crackingAnd then, the number of the divided data blocks of the input information needs to be cracked, and 80 re-assigned constants need to be cracked, so that compared with the prior art, brute force cracking is more difficult, and the safety of the ciphertext is improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, it is obvious that the drawings in the following description are only embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
Fig. 1 is a block chain apparatus according to an embodiment of the present disclosure;
fig. 2 is a block chain structure diagram provided in an embodiment of the present application;
FIG. 3 is a flowchart of a data storage method according to an embodiment of the present application;
fig. 4a to 4c are schematic diagrams illustrating the input information bit complement expansion provided in the embodiment of the present application;
FIG. 5 is a schematic diagram of the data block being divided into 16 target sub data blocks;
fig. 6 is a block diagram of a data storage device according to an embodiment of the present application;
FIG. 7 is a block diagram illustrating an apparatus for a server in accordance with an example embodiment.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The embodiment of the application provides a data storage method, a data storage device, a server, a medium and a product, and before introducing the technical scheme provided by the embodiment of the application, an application environment related to the embodiment of the application is explained.
Fig. 1 is a block chain apparatus according to an embodiment of the present disclosure.
The blockchain apparatus comprises a plurality of nodes 11, which may be electronic devices or servers.
For example, the electronic device may be any electronic product that can interact with a user through one or more ways such as a keyboard, a touch PAD, a touch screen, a remote controller, a voice interaction device, or a handwriting device, for example, a mobile phone, a notebook computer, a tablet computer, a palm computer, a personal computer, a wearable device, a smart television, a PAD, and the like.
The server may be, for example, one server, a server cluster composed of a plurality of servers, or a cloud computing server center. The server may include a processor, memory, and a network interface, among others.
The plurality of nodes included in the block chain device respectively store one same block chain.
For any node in the plurality of nodes, the node stores the node identifiers of other nodes in the blockchain device, so that the generated block is broadcasted to other nodes in the blockchain device according to the other node identifiers.
In order to make the embodiments of the present application more understandable to those skilled in the art, the structure of the block chain is described in detail below.
As shown in fig. 2, the block chain is composed of a plurality of blocks. The starting block comprises a block head and a block main body, wherein the block head stores an input information characteristic value, a version number, a timestamp and a difficulty value, and the block main body stores input information; the next block of the starting block takes the starting block as a parent block, the next block also comprises a block head and a block main body, the block head stores the input information characteristic value of the current block, the block head characteristic value of the parent block, the version number, the timestamp and the difficulty value, and the like, so that the block data stored in each block in the block chain is associated with the block data stored in the parent block, and the safety of the input information in the block is ensured.
When each block in the block chain is generated, when the node where the block chain is located receives input information, the SHA-1 algorithm needs to be carried out on the input information for calculation, and the obtained 160-bit ciphertext is used as a characteristic value of the input information and is stored to the head of the block. And after the block main body and the block head are obtained, the current block is obtained, then, the node where the block chain is located sends the newly generated blocks to other nodes respectively according to the node identifications of the other nodes, the newly generated blocks are verified by the other nodes, and the newly generated blocks are added to the block chain stored in the newly generated blocks after the verification is completed.
With the continuous development of computer computing power and the continuous accumulation of collision password libraries in the application process of the SHA-1 algorithm, the ciphertext generated by the SHA-1 algorithm has the possibility of being cracked violently. If the SHA-1 algorithm is replaced by other algorithms, for example, the SHA-2 algorithm, to prevent the ciphertext generated by the SHA-1 algorithm from being violently cracked, but the SHA-2 algorithm generates 256-bit ciphertext, that is, the length of the ciphertext is different from the length of 160-bit ciphertext generated by the SHA-1 algorithm, the improvement will affect the interface and the message format, improve the transformation cost, and have high difficulty.
The embodiment of the application provides an improved method for SHA-1, so that the length of a ciphertext obtained by an improved SHA-1 algorithm is still 160 bits, an interface and a message format do not need to be improved, and the reconstruction cost is reduced.
The data storage method provided by the embodiment of the application can be applied to any application scene using SHA-1, for example, a calculation scene of the characteristic value of transaction data of a bank. The input information is different in different application scenes, such as in a calculation scene of a characteristic value of transaction data of a bank, and the input information is the transaction data.
The following describes a data storage method provided in an embodiment of the present application.
As shown in fig. 3, a flowchart of a data storage method provided in an embodiment of the present application includes the following steps S301 to S326.
Step S301: input information to be stored to a blockchain is obtained.
For example, the input information may be transaction data. Such as transfer transaction data.
Step S302: and expanding the length complementary bits of the input information into 512 bits x Q to obtain a first message, wherein Q is any integer greater than or equal to 1.
The bit-filling expansion method provided by the embodiment of the present application has various types, but the embodiment of the present application provides, but is not limited to, the following three types.
The first implementation of step S302 includes steps a11 through a 14.
Step A11: and complementing one 1 at the tail of the input information.
Illustratively, the input information is binary data.
For example, if the length of the input information is an integer multiple of 512, the complementary bit extension operation may not be required, and if the length of the input information is not an integer multiple of 512, the complementary bit extension operation may be required.
Step A12: and supplementing 0 after 1 of the input information padding bit until the length of the second message after padding bit is 448 after modulo 512.
For example, if the remainder of the input information modulo 512 is 448, the steps a11 to a12 may not be performed. If the remainder of the length of the input information modulo 512 is not 448, steps a11 through a12 may be performed.
Step A13: and one 1 is added at the tail of the second message.
Step A14: and supplementing 63 0 s after 1 of the complementary bit of the second message to obtain the first message.
In order to make the implementation of the first step S302 more understood by those skilled in the art, the following description is made.
Fig. 4a is a schematic diagram illustrating an expansion of input information padding according to an embodiment of the present application.
Assuming that the length of the input message is 600 bits, the remainder of the input message modulo 512 is 88, and a second message is obtained after the input message is supplemented with a1 and 359 0. After the second message is supplemented with one 1 and 63 0's, the first message is obtained.
The second implementation of step S302 includes steps a21 through a 23.
Step A21: and one 1 is added at the tail of the input information.
Illustratively, the input information is binary data.
For example, if the length of the input information is an integer multiple of 512, the complementary bit extension operation may not be required, and if the length of the input information is not an integer multiple of 512, the complementary bit extension operation may be required.
Step A22: and supplementing 0 after 1 of the input information padding bit until the length of the second message after padding bit is 448 after modulo 512.
For example, if the remainder of the input information modulo 512 is 448, the steps a21 to a22 may not be performed. If the remainder of the length of the input information modulo 512 is not 448, steps a21 through a22 may be performed.
Step A23: and padding 64 bits of 1 at the tail of the second message to obtain the first message.
In order to make the implementation of the second step S302 more understood by those skilled in the art, the following description is made.
Fig. 4b is a schematic diagram illustrating the input information padding expansion according to the embodiment of the present application.
Assuming that the length of the input message is 600 bits, the remainder of the input message modulo 512 is 88, and after adding one 1 and 359 0 after the input message, the second message is obtained. And supplementing 64 pieces of 1 after the second message to obtain the first message.
The third implementation of step S302 includes steps a31 through a 32.
Step A31: and complementing one 1 at the tail of the input information.
Illustratively, the input information is binary data.
For example, if the length of the input information is an integer multiple of 512, the complementary bit extension operation may not be required, and if the length of the input information is not an integer multiple of 512, the complementary bit extension operation may be required.
Step A32: and supplementing 0 after 1 of the input information padding bit until the remainder is 0 after the length of the first message after padding bit is modulo 512, so as to obtain the first message.
In order to make the implementation of the third step S302 more understood by those skilled in the art, the following description is made.
Fig. 4c is a schematic diagram illustrating the input information padding expansion according to the embodiment of the present application.
Assuming that the length of the input message is 600 bits, the remainder of the input message modulo 512 is 88, 1 is added after the input message, and 423 0 s are added to obtain the first message.
Step S303: and dividing the first message into Q data blocks, wherein the bit number of the data blocks is 512 bits.
Taking fig. 4a to 4c as an example, Q is 2.
For example, in this embodiment of the present application, the first packet is divided into Q data blocks, and one data block is obtained every time 512 bits of data are obtained from the head of the first packet.
Step S304: the initial value of G is set to 1.
Step S305: the following operations are performed for the G-th data block:
step S306: and dividing the data block into 16 target sub data blocks, wherein the bit number of the target sub data blocks is 32 bits.
Step S307: and performing operation on the 16 target sub data blocks to obtain 64 operation sub data blocks to obtain 80 sub data blocks, wherein the bit number of the operation sub data blocks is 32 bits, and the 80 sub data blocks comprise the 16 target sub data blocks and the 64 operation sub data blocks.
Step S308: obtaining preset 80 constants, wherein the values of the 80 constants are as follows:
Ktfirst preset value (0)<=t<=19)
KtSecond predetermined value (20)<=t<=39)
KtThird preset value (40)<=t<=59)
KtFourth preset value (60)<=t<=79)。
In an optional implementation manner, the 80 constants corresponding to different data blocks may be different, for example, the corresponding relationship between the 16 target sub data blocks obtained in step S306 and the 80 constants may be preset. I.e., 80 constants, vary from data block to data block.
In an alternative implementation, the 80 constants corresponding to different input information may be different, for example, the correspondence between the input information and the 80 constants may be preset. I.e., 80 constants that vary with the input information.
In an alternative implementation, the 80 constants corresponding to different data blocks may be the same.
In an alternative implementation, the first preset value is 0x5a827999, the second preset value is 0x6ED9EBA1, the third preset value is 0x8F1BBCDC, and the fourth preset value is 0xCA62C1D 6.
For example, 80 sub-data blocks sequentially include: 16 target sub-data blocks and 64 operation sub-data blocks.
Wherein, the sequence of the 16 target sub-data blocks is as follows: and sequencing according to the sequence of dividing the data block to obtain the target sub data block.
FIG. 5 is a schematic diagram showing the data block being divided into 16 target sub data blocks.
From the head of the data block, each time a target sub-data block is obtained by extracting 32 bits of data, a target sub-data block 1, a target sub-data block 2, a target sub-data block 3, a target sub-data block 4, …, and a target sub-data block 16 can be obtained in sequence. The sequence of the 16 target sub-data blocks is as follows: target sub data block 1, target sub data block 2, target sub data block 3, target sub data block 4, …, target sub data block 16.
In an alternative implementation manner, there are various implementation manners of step S307, and the embodiment of the present application provides, but is not limited to, the following implementation manner, and the method includes step B11 to step B14.
Step B11: the initial value of R is set to 0.
Step B12: let t be R, perform the following operations:
step B13: wt=Mt(t is more than or equal to 0 and less than 16), wherein MtThe target subdata block is the t +1 th subdata block; wt=S1(Wt-3XOR Wt-14 XOR Wt-16) (16 is less than or equal to t is less than or equal to 79); wherein, S1 indicates a shift of 1 bit to the left.
Step B14: let R ═ R +1, return to step B12 until R equals 80.
Wherein, the 80 sub-data blocks are sequentially: w0、W1、W2、W3,…,W79
In an alternative implementation, at least one of the 16 target sub-data blocks may be logically operated to obtain 64 operation sub-data blocks. The exclusive or operation XOR described above is not limited.
Step S309: the initial value of i is set to 1.
And step S310, for the ith preset numerical value, converting the ith preset numerical value into a decimal number to obtain a first character string consisting of the decimal number.
It is understood that since the first character string is a 10-ary number, the first character string contains characters from 0 to 9.
Step S311 of utilizing the formula
Figure BDA0003371661370000121
Obtaining a second character string; wherein, bmIs the m-th character in the second string, b1Is the 1 st bit character in the second string, and b1=a1
Figure BDA0003371661370000122
avIs the v-th character in the first string, P (a)v) Means avProbability of occurrence in said first string, n being the total number of characters contained in the first string, avA number means avNumber of occurrences in the first string。
In the embodiment of the application, the specific value of the character m +1 in the second character string is set to be related to the character m, so that the set second character has strong randomness and disturbance, the strength and the complexity of the algorithm are increased, and the reinforcement optimization of the SHA-1 calculation is realized.
If the input information is different, the first character string is different, and if the characters in the first character string are changed by one or more than one digit, the method for obtaining the second character string provided by the application can enable at least 1/2 characters in the obtained second character string to be changed remarkably, namely the avalanche effect of the algorithm, so that the complexity of the password is enhanced remarkably, the brute-force cracking can be hardly realized under the existing computing capability, and the cost of the brute-force cracking is increased dramatically.
The process of obtaining the second character string is described below by way of example.
For example, if the first string includes 10 characters, the following are: a is1,a2,a3,a4,a5,a6,a7,a8,a9,a10
Suppose a1=1,a2=2,a3=3,a4=4,a5=5,a6=6,a7=7,a8=8,a9=9,a10When equal to 0, then P (a)1)=P(a2)=P(a3)=P(a4)=P(a5)=P(a6)=P(a7)=P(a8)=P(a9)=P(a10)=0.1。
b1=a1=1;
Figure BDA0003371661370000131
Figure BDA0003371661370000132
Figure BDA0003371661370000133
Figure BDA0003371661370000134
Figure BDA0003371661370000135
Figure BDA0003371661370000136
Figure BDA0003371661370000137
Figure BDA0003371661370000138
Figure BDA0003371661370000139
The second character string is {1,0.1,0.01,0.001,0.0001,0.00001,0.000001,0.0000001,0.00000001,0.000000001}
Step S312, using the formula:
Figure BDA0003371661370000141
to obtain a third string, wherein cm+1Is the character located at the m +1 th bit in the third string.
Mod is a remainder function.
Still take the above as an example, then
Figure BDA0003371661370000142
Then each in the obtained third stringThe characters are respectively:
c1=(1000000000*b1)mod 10=1;
c2=(1000000001*b2)mod 10=0;
c3=(1000000002*b2)mod 10=0;
c4=(1000000003*b2)mod 10=0;
c5=(1000000004*b2)mod 10=0;
c6=(1000000005*b2)mod 10=0;
c7=(1000000006*b2)mod 10=0;
c8=(1000000007*b2)mod 10=0;
c9=(1000000008*b2)mod 10=0;
c10=(1000000009*b2)mod 10=0;
the obtained third character string is {1000000000 }.
It is understood that step S312 is to make the characters in the obtained third character string be the characters in 0 to 9.
And step 313, converting the obtained third character string into a 16-system number to obtain an ith candidate value.
Taking the third string as {1000000000} as an example, the third string is converted into 16-ary, and 5f5e100 is obtained.
In step S314, the ith preset value is made equal to the ith candidate value mod0 xFFFFFFFF.
In step S315, i is set to i +1, and the process returns to step S310 until i is equal to 5.
It is understood that the steps S309 to S315 are processes for re-assigning the first preset value, the second preset value, the third preset value and the fourth preset value.
In an optional implementation manner, for different input information, the values of the 80 constants obtained in step S308 are different, that is, the initial values of the first preset value to the fourth preset value corresponding to different input information are different, so that in the present application, under the condition of different plaintext inputs, the first preset value to the fourth preset value after re-assignment are different. Thereby increasing randomness and the brute force cracking resistance of the algorithm.
In an optional implementation manner, for different data blocks, the values of the 80 constants obtained in step S308 are different, that is, the initial values of the first preset value to the fourth preset value corresponding to the different data blocks are different, so that in the present application, under the condition of different data blocks, the first preset value to the fourth preset value after re-assignment are different. Thereby increasing randomness and the brute force cracking resistance of the algorithm.
Step S316: obtaining an identity of a buffer H0Initial value of (1), H1Initial value of (1), H2Initial value of (1), H3Initial value of (1), H4Is started.
In an alternative implementation, for the first data block, that is, when step S316 is performed for the first time, the preset identifier H of 16 sub data blocks and buffers may be used0Initial value of (1), H1Initial value of (1), H2Initial value of (1), H3Initial value of (1), H4In the corresponding relation of the initial values, the identifier H of the buffer area corresponding to the 16 target sub data blocks is searched0Initial value of (1), H1Initial value of (1), H2Initial value of (1), H3Initial value of (1), H4Is started.
I.e. H corresponding to different target sub-data blocksiThe initial values of the target sub data blocks are different, because the target sub data blocks are related to the input information, the randomness and the brute force cracking resistance of the algorithm are increased, the performance consumption of the algorithm is low, and the algorithm can be transplanted and realized on different platforms and hardware equipment so as to meet the requirements of various use scenes of a block chain in a financial business system.
In an alternative implementation, the buffer { Hi } is initialized to the following values:
H0=0x67452301
H1=0xEFCDAB89
H2=0x98BADCFE
H3=0x10325476
H4=0xC3D2E1F0
step S317: will H0Of the initial value of (1), H1Of (d), H2Of (d), H3Of (d), H4Respectively assigning the initial values to a first parameter, a second parameter, a third parameter, a fourth parameter and a fifth parameter.
Step S318: the initial value of P is set to 0.
Step S319: for t ═ P, the following calculation is performed:
TEMP=S5(H0)+ft(H1,H2,H3)+H4+Wt+Kt;H4=H3;H3=H2;H2=S30(H1);H1=H0;H0TEMP; wherein, WtFor the t +1 th sub-data block of the 80 sub-data blocks, ft(H1,H2,H3) Is a preset function; s5(H0) Means that H is0Left shift by 5; s. the30(H1) Means that H is1Shifted 30 to the left.
Exemplary, ft(H1,H2,H3) Is preset with H1,H2,H3As a function of the argument, e.g. a preset function ft(H1,H2,H3) The following were used:
ft(H1,H2,H3)=(H1 AND H2)or((NOT H1)AND H3)(0<=t<=19)
ft(H1,H2,H3)=H1 XOR H2 XOR H3(20<=t<=39)
ft(H1,H2,H3)=(H1 AND H2)or(H1 AND H3)or(H2 AND H3)(40<=t<=59)
ft(H1,H2,H3)=H1 XOR H2 XOR H3(60<=t<=79)。
in an alternative implementation, ft(H1,H2,H3) It may or may not be a piecewise function, and the above is only an example and is not for ft(H1,H2,H3) Resulting in a definition.
Step S320: setting P +1, returning to step S319 until P equals 80 to obtain the identifier H of the buffer area0Value of (A), H1Value of (A), H2Value of (A), H3Value of (A), H4The value of (c).
Step S321: let H0Final value of (H)0Value of + first parameter, H1Final value of ═ H1Value of + second parameter, H2Final value of ═ H2Value of + third parameter, H3Final value of ═ H3Value of + fourth parameter, H4Final value of ═ H4+ the fifth parameter.
Step S322: subjecting said H to0Final value of (1), H1Final value of (1), H2Final value of (1), H3Final value of (1), H4Respectively as the mark H of the buffer corresponding to the G +1 th data block0Initial value of (1), H1Initial value of (1), H2Initial value of (1), H3Initial value of (1), H4Is started.
I.e. the obtained identification H of the buffer area when step S316 is performed for the second timeiIs the initial value of (a) obtained when step S321 is first executed, HiThe final value of (c).
In the third execution of step S316, the obtained identifier H of the buffer areaiIs the initial value of (a), H obtained when step S321 is executed for the second timeiThe final value of (c). And so on, will not be described again.
If the first message is divided into a plurality of data blocks, thenMultiple iterations may be required, resulting in H for the previous block0Final value of (1), H1Final value of (1), H2Final value of (1), H3Final value of (1), H4Is the final value of H for the next data block0Initial value of (1), H1Initial value of (1), H2Initial value of (1), H3Initial value of (1), H4The initial value of (2) so that the finally obtained ciphertext is related to the number of iterations, and the ciphertext is more difficult to crack.
Step S323: set G +1 and return to step S305 until G is greater than Q.
Step S324: according to H0、H1、H2、H3、H4In the order of (A) and (B), is0Final value of (1), H1Final value of (1), H2Final value of (1), H3Final value of (1), H4Constitutes a 160-bit hash value.
It is understood that HiThe values of (a) are all 32 bits in length, so 5HiConstituting a 160-bit hash value.
Step S325: and obtaining a ciphertext based on the 160-bit hash value.
In an alternative implementation, a 160-bit hash value is determined as the ciphertext.
In an optional implementation manner, a third character string corresponding to a first preset value, a third character string corresponding to a second preset value, a third character string corresponding to a third preset value, and a third character string corresponding to a fourth preset value are obtained; obtaining a fourth character string, wherein the fourth character string consists of a third character string corresponding to a first preset numerical value, a third character string corresponding to a second preset numerical value, a third character string corresponding to a third preset numerical value and a third character string corresponding to a fourth preset numerical value; and determining the ciphertext as a logical operation result of the 160-bit hash value and the fourth character string.
For example, the ciphertext XOR fourth string may be a 160-bit hash value.
Step S326: and storing the ciphertext to a block chain.
For example, the ciphertext may be stored as a feature value of the input information to a corresponding block in the blockchain.
According to the data storage method provided by the application, after 80 preset constants are obtained, the following processing is carried out on each constant: converting the constant from 16 to a decimal number to obtain a first character string consisting of the decimal number; using formulas
Figure BDA0003371661370000171
Obtaining a second character string; wherein, bmIs the m-th character in the second string, b1Is the character located at bit 1 of the second string, and b1=a1
Figure BDA0003371661370000172
avIs the v-th character in the first string, P (a)v) Means avProbability of occurrence in said first string, n being the total number of characters contained in the first string, avA number means avA number of occurrences in the first string; using formulas
Figure BDA0003371661370000173
To obtain a third string, wherein cm+1Is the m +1 th character in the third string; converting the obtained third character string into a 16-system to obtain a candidate value; the constant is reassigned by assigning the constant value mod0xFFFFFFFF to obtain the 80 reassigned constant. H derived based on 80 reassigned constants0Value of (A), H1Value of (A), H2Value of (A), H3Value of (H)4And H obtained based on 80 constants set in advance0Value of (A), H1Value of (A), H2Value of (A), H3Value of (A), H4If the input information is divided into a plurality of data blocks, the identifier H of the buffer area corresponding to the next data block is calculated in the next data block0Initial value of (1), H1Initial value of (1), H2Initial value of (1), H3Initial value of (1), H4Is the initial value of H obtained for the last data block0Final value of (1), H1Final value of (1), H2Final value of (1), H3Final value of (1), H4The final value of (a), i.e., the specific content of the resulting ciphertext, is related not only to the number of data blocks into which the input information is divided, but also to the 80 re-assigned constants. If brute force cracking is needed, the number of the divided data blocks of the input information needs to be cracked, and 80 constants after re-assignment need to be cracked.
By adopting the data storage method provided by the embodiment of the application, the safety of the characteristic value of the input information of the block chain is improved, an attacker cannot use the conventional SHA-1 dictionary base to reversely decrypt the characteristic value, and the possibility of brute force cracking is avoided.
The method is described in detail in the embodiments disclosed in the present application, and the method of the present application can be implemented by various types of apparatuses, so that an apparatus is also disclosed in the present application, and the following detailed description is given of specific embodiments.
As shown in fig. 6, a block diagram of a data storage device provided in an embodiment of the present application includes: a first obtaining module 601, a complementary bit expanding module 602, a first dividing module 603, a first setting module 604, a second dividing module 605, an operation module 606, a second obtaining module 607, a first setting module 608, a first converting module 609, a third obtaining module 610, a fourth obtaining module 611, a second converting module 612, a second setting module 613, a first triggering module 614, a fifth obtaining module 615, a second assignment module 616, a third assignment module 617, a calculating module 618, a second triggering module 619, a fourth assignment module 620, a fifth assignment module 621, a third triggering module 622, a sixth obtaining module 623, a seventh obtaining module 624, and a storage module 625, wherein:
a first obtaining module 601, configured to obtain input information to be stored in a block chain;
a bit-complementing expansion module 602, configured to expand the length-complementing bits of the input information to 512 bits × Q to obtain a first packet, where Q is any integer greater than or equal to 1;
a first dividing module 603, configured to divide the first packet into Q data blocks, where the number of bits of each data block is 512 bits;
a first setting module 604, configured to set an initial value of G to 1;
the following operations are performed for the G-th data block:
a second dividing module 605, configured to divide the data block into 16 target sub data blocks, where the number of bits of the target sub data blocks is 32 bits;
an operation module 606, configured to perform an operation on the 16 target sub data blocks to obtain 64 operation sub data blocks, so as to obtain 80 sub data blocks, where the bit number of the operation sub data block is 32 bits, and the 80 sub data blocks include 16 target sub data blocks and 64 operation sub data blocks;
a second obtaining module 607, configured to obtain preset 80 constants, where values of the 80 constants are as follows:
Ktfirst preset value (0)<=t<=19)
KtSecond predetermined value (20)<=t<=39)
KtThird preset value (40)<=t<=59)
KtFourth preset value (60)<=t<=79);
A first setting module 608, configured to set an initial value of i to 1;
a first conversion module 609, configured to, for an ith preset numerical value, convert the ith preset numerical value into a decimal number to obtain a first character string composed of the decimal numbers;
a third obtaining module 610 for utilizing the formula
Figure BDA0003371661370000191
Obtaining a second character string; wherein, bmIs the m-th character in the second string, b1Is the character located at bit 1 of the second string, and b1=a1
Figure BDA0003371661370000192
avIs the v-th character in the first string, P (a)v) Means avProbability of occurrence in said first string, n being the total number of characters contained in the first string, avA _ number means avA number of occurrences in the first string;
a fourth obtaining module 611 for utilizing the formula
Figure BDA0003371661370000193
To obtain a third string, wherein cm+1Is the m +1 th character in the third string;
a second conversion module 612, configured to convert the obtained third string into a 16-ary system to obtain an ith candidate value;
a second setting module 613, configured to make the ith preset value equal to the ith candidate value mod0 xfffffffff;
a first triggering module 614, configured to set i to i +1, and return to the first conversion module until i is equal to 5;
a fifth obtaining module 615, configured to obtain an identifier H of the buffer0Initial value of (1), H1Initial value of (1), H2Initial value of (1), H3Initial value of (1), H4An initial value of (1);
a second valuation module 616 for assigning H0Of (d), H1Of (d), H2Of (d), H3Of (d), H4Respectively assigning the initial values to a first parameter, a second parameter, a third parameter, a fourth parameter and a fifth parameter;
a third assigning module 617, configured to set an initial value of P to 0;
a calculating module 618, configured to perform the following calculation for t ═ P:
TEMP=S5(H0)+ft(H1,H2,H3)+H4+Wt+Kt;H4=H3;H3=H2;H2=S30(H1);H1=H0;H0TEMP; wherein, WtFor the t +1 th sub-data block of the 80 sub-data blocks, ft(H1,H2,H3) Is a preset function; s5(H0) Means that H is0Left shift by 5; s30(H1) Means that H is1Left shift by 30;
a second triggering module 619, configured to set P +1 to P, and return to the calculating module until P equals 80, so as to obtain the identifier H of the buffer area0Value of (A), H1Value of (A), H2Value of (A), H3Value of (A), H4A value of (d);
a fourth assignment module 620 for ordering H0Final value of ═ H0Value of + first parameter, H1Final value of ═ H1Value of + second parameter, H2Final value of ═ H2Value of + third parameter, H3Final value of ═ H3Value of + fourth parameter, H4Final value of (H)4The value of + the fifth parameter;
a fifth assigning module 621 configured to assign the H to the data0Final value of (1), H1Final value of (1), H2Final value of (1), H3Final value of (1), H4Respectively as the mark H of the buffer corresponding to the G +1 th data block0Initial value of (1), H1Initial value of (1), H2Initial value of (1), H3Initial value of (1), H4An initial value of (1);
a third triggering module 622, configured to set G +1, and return to the second dividing module until G is greater than Q;
a sixth obtaining module 623 for obtaining H0、H1、H2、H3、H4In the order of (A) and (B), is0Final value of (1), H1Final value of (1), H2Final value of (1), H3Final value of (1), H4160 bit hash value;
a seventh obtaining module 624, configured to obtain a ciphertext based on the 160-bit hash value;
a storage module 625, configured to store the ciphertext to a block chain.
In an optional implementation manner, the bit complement expansion module includes:
a first padding unit for padding one 1 at the end of the input information;
a second bit complement unit, configured to complement 0 after 1 of the input information bit complement until a remainder of a length of the second packet after the bit complement modulo 512 is 448;
a third bit complementing unit, configured to complement a bit 1 at the end of the second packet;
a fourth bit complement unit, configured to complement 63 0 s after 1 of the bit complement of the second packet, so as to obtain the first packet.
In an alternative implementation, the first preset value is 0x5a827999, the second preset value is 0x6ED9EBA1, the third preset value is 0x8F1BBCDC, and the fourth preset value is 0xCA62C1D 6.
In an alternative implementation, the preset function ft(H1,H2,H3) The following were used:
ft(H1,H2,H3)=(H1 AND H2)or((NOT H1)AND H3)(0<=t<=19)
ft(H1,H2,H3)=H1 XOR H2 XOR H3(20<=t<=39)
ft(H1,H2,H3)=(H1 AND H2)or(H1 AND H3)or(H2 AND H3)(40<=t<=59)
ft(H1,H2,H3)=H1 XOR H2 XOR H3(60<=t<=79)。
with regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
FIG. 7 is a block diagram illustrating an apparatus for a server in accordance with an example embodiment.
Servers include, but are not limited to: a processor 71, a memory 72, a network interface 73, an I/O controller 74, and a communication bus 75.
It should be noted that the structure of the server shown in fig. 7 does not constitute a limitation of the server, and the server may include more or less components than those shown in fig. 7, or combine some components, or arrange different components, as will be understood by those skilled in the art.
The following describes each component of the server in detail with reference to fig. 7:
the processor 71 is a control center of the server, connects various parts of the entire server using various interfaces and lines, and performs various functions of the server and processes data by running or executing software programs and/or modules stored in the memory 72 and calling data stored in the memory 72, thereby performing overall monitoring of the server. Processor 71 may include one or more processing units; illustratively, the processor 71 may integrate an application processor, which primarily handles operating systems, user interfaces, applications, etc., and a modem processor, which primarily handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 71.
Processor 71 may be a Central Processing Unit (CPU), or an Application Specific Integrated Circuit (ASIC), or one or more Integrated circuits configured to implement embodiments of the present invention, or the like;
the Memory 72 may include Memory, such as a Random-Access Memory (RAM) 721 and a Read-Only Memory (ROM) 722, and may also include a mass storage device 723, such as at least 1 disk storage. Of course, the server may also include hardware needed for other services.
The memory 72 is used for storing the executable instructions of the processor 71. The processor 71 described above has a function of a data storage method.
A wired or wireless network interface 73 is configured to connect the server to a network.
The processor 71, the memory 72, the network interface 73, and the I/O controller 74 may be connected to each other by a communication bus 75, which may be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, an EISA (Extended Industry Standard Architecture) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc.
In an exemplary embodiment, the server may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the above-described data storage methods.
In an exemplary embodiment, the disclosed embodiments provide a storage medium comprising instructions, such as a memory 72 comprising instructions, executable by a processor 71 of a server to perform the above-described method. Alternatively, the storage medium may be a non-transitory computer readable storage medium, which may be, for example, a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
In an exemplary embodiment, a computer readable storage medium is also provided, which can be directly loaded into the internal memory of a computer, such as the memory 72, and contains software codes, and the computer program can implement the steps shown in any embodiment of the data storage method after being loaded and executed by the computer.
In an exemplary embodiment, a computer program product is also provided, which is directly loadable into an internal memory of a computer, such as a memory included in the server, and contains software codes, and which, when loaded and executed by the computer, is able to carry out the steps shown in any of the embodiments of the data storage method described above.
It should be noted that the data storage method, the server, the medium and the apparatus provided by the present invention can be used in the field of block chain or in the field of finance. The foregoing is merely an example and does not limit the application fields of the data storage method, the server, the medium, and the apparatus provided by the present invention.
Note that the features described in the embodiments in the present specification may be replaced with or combined with each other. For the device or system type embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
It is further noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A method of storing data, comprising:
acquiring input information to be stored to a block chain;
expanding the length complementary bits of the input information into 512 bits x Q to obtain a first message, wherein Q is any integer greater than or equal to 1;
dividing the first message into Q data blocks, wherein the number of bits of the data blocks is 512 bits;
setting the initial value of G to be 1;
the following operations are performed for the G-th data block:
dividing the data block into 16 target sub data blocks, wherein the number of bits of the target sub data blocks is 32;
performing operation on the 16 target sub data blocks to obtain 64 operation sub data blocks so as to obtain 80 sub data blocks, wherein the bit number of the operation sub data blocks is 32 bits, and the 80 sub data blocks comprise the 16 target sub data blocks and the 64 operation sub data blocks;
obtaining preset 80 constants, wherein the values of the 80 constants are as follows:
Ktfirst preset value (0)<=t<=19)
KtSecond predetermined value (20)<=t<=39)
KtThird preset value (40)<=t<=59)
KtFourth predetermined value (60)<=t<=79);
Setting the initial value of i to be 1;
for an ith preset numerical value, converting the ith preset numerical value into a decimal number to obtain a first character string consisting of the decimal number;
using a formula
Figure FDA0003371661360000011
Obtaining a second character string; wherein, bmIs the m-th character in the second string, b1Is the character located at bit 1 of the second string, and b1=a1
Figure FDA0003371661360000012
avIs the v-th character in the first string, P (a)v) Means avProbability of occurrence in said first string, n being the total number of characters contained in the first string, avA number means avA number of occurrences in the first string;
using formulas
Figure FDA0003371661360000013
To obtain a third string, wherein cm+1Is the m +1 th character in the third string;
converting the obtained third character string into a 16-system to obtain an ith candidate value;
setting the i-th preset numerical value as the i-th candidate numerical value mod0 xFFFFFFFF;
setting i to i +1, returning to the step, converting the ith preset numerical value into a decimal number for the ith preset numerical value to obtain a first character string consisting of the decimal number until i is equal to 5;
obtaining an identity of a buffer H0Initial value of (1), H1Initial value of (1), H2Initial value of (1), H3Initial value of (1), H4An initial value of (1);
h is to be0Of (d), H1Of (d), H2Of (d), H3Of (d), H4Respectively assigned to the firstA parameter, a second parameter, a third parameter, a fourth parameter, and a fifth parameter;
setting the initial value of P to be 0;
for t ═ P, the following calculation is performed:
TEMP=S5(H0)+ft(H1,H2,H3)+H4+Wt+Kt;H4=H3;H3=H2;H2=S30(H1);H1=H0;H0TEMP; wherein, WtFor the t +1 th sub-data block of the 80 sub-data blocks, ft(H1,H2,H3) Is a preset function; s5(H0) Means that H is0Left shift by 5; s30(H1) Means that H is1Left shift by 30;
setting P +1, returning to the step for t P, the following calculation is performed until P equals 80 to obtain the identification H of the buffer area0Value of (A), H1Value of (A), H2Value of (A), H3Value of (A), H4A value of (d);
let H0Final value of ═ H0Value of + first parameter, H1Final value of ═ H1Value of + second parameter, H2Final value of ═ H2Value of + third parameter, H3Final value of ═ H3Value of + fourth parameter, H4Final value of ═ H4The value of + the fifth parameter;
subjecting said H to0Final value of (1), H1Final value of (a), H2Final value of (a), H3Final value of (1), H4Respectively as the mark H of the buffer corresponding to the G +1 th data block0Initial value of (1), H1Initial value of (1), H2Initial value of (1), H3Initial value of (1), H4An initial value of (1);
setting G to G +1, and returning to the step to execute the following operations on the G-th data block until G is larger than Q;
according to H0、H1、H2、H3、H4In the order ofObtaining H0Final value of (1), H1Final value of (1), H2Final value of (1), H3Final value of (1), H4A 160-bit hash value;
obtaining a ciphertext based on the 160-bit hash value;
and storing the ciphertext to a block chain.
2. The data storage method of claim 1, wherein the step of expanding the complementary bits of the input information to 512 bits x Q to obtain the first message comprises:
padding one 1 at the tail of the input information;
supplementing 0 after 1 of the input information bit-complementing position until the remainder is 448 after the length of the second message after the bit-complementing position is modulo 512;
padding one 1 at the tail of the second message;
and supplementing 63 0 s after 1 of the complementary bit of the second message to obtain the first message.
3. The data storage method as claimed in claim 1 or 2, wherein the step of performing the operation on the 16 target sub-data blocks to obtain 64 operation sub-data blocks comprises:
setting the initial value of R to be 0;
let t be R, perform the following operations:
Wt=Mt(t is more than or equal to 0 and less than 16), wherein MtThe target subdata block is the t +1 th subdata block;
Wt=S1(Wt-3 XOR Wt-14 XOR Wt-16) (t is more than or equal to 16 and less than or equal to 79); wherein, S1 indicates a shift of 1 bit to the left;
let R ═ R +1, return to step let t ═ R, perform the following operations until R equals 80.
4. The data storage method as claimed in claim 1, wherein the first preset value is 0x5a827999, the second preset value is 0x6ED9EBA1, the third preset value is 0x8F1BBCDC, and the fourth preset value is 0xCA62C1D 6.
5. The data storage method of claim 1, wherein the preset function ft(H1,H2,H3) The following were used:
ft(H1,H2,H3)=(H1 AND H2)or((NOT H1)AND H3)(0<=t<=19)
ft(H1,H2,H3)=H1 XOR H2 XOR H3(20<=t<=39)
ft(H1,H2,H3)=(H1 AND H2)or(H1 AND H3)or(H2 AND H3)(40<=t<=59)
ft(H1,H2,H3)=H1 XOR H2 XOR H3(60<=t<=79)。
6. a data storage device, comprising:
the first acquisition module is used for acquiring input information to be stored to the block chain;
a bit-complementing expansion module, configured to expand the length bit-complementing of the input information to 512 bits × Q to obtain a first packet, where Q is any integer greater than or equal to 1;
a first dividing module, configured to divide the first packet into Q data blocks, where the number of bits of each data block is 512 bits;
the first setting module is used for setting the initial value of G to be 1;
the following operations are performed for the G-th data block:
the second dividing module is used for dividing the data block into 16 target sub data blocks, and the number of bits of each target sub data block is 32;
the operation module is used for performing operation on the 16 target sub data blocks to obtain 64 operation sub data blocks so as to obtain 80 sub data blocks, the bit number of each operation sub data block is 32 bits, and the 80 sub data blocks comprise 16 target sub data blocks and 64 operation sub data blocks;
the second obtaining module is configured to obtain preset 80 constants, where values of the 80 constants are as follows:
Ktfirst preset value (0)<=t<=19)
KtSecond predetermined value (20)<=t<=39)
KtThird preset value (40)<=t<=59)
KtFourth preset value (60)<=t<=79);
The first setting module is used for setting the initial value of i to be 1;
the first conversion module is used for converting the ith preset numerical value into a decimal number for the ith preset numerical value so as to obtain a first character string consisting of the decimal numbers;
a third obtaining module for utilizing the formula
Figure FDA0003371661360000041
Obtaining a second character string; wherein, bmIs the m-th character in the second string, b1Is the character located at bit 1 of the second string, and b1=a1
Figure FDA0003371661360000042
avIs the v-th character in the first string, P (a)v) Means avProbability of occurrence in said first string, n being the total number of characters contained in the first string, avA number means avA number of occurrences in the first string;
a fourth obtaining module for utilizing the formula
Figure FDA0003371661360000043
To obtain a third string, wherein cm+1Is located in the third wordThe (m + 1) th bit of the string;
the second conversion module is used for converting the obtained third character string into a 16-system number so as to obtain an ith candidate value;
a second setting module, configured to set an ith preset value to the ith candidate value mod0 xFFFFFFFF;
the first triggering module is used for setting i to i +1 and returning to the first conversion module until i is equal to 5;
a fifth obtaining module, configured to obtain an identifier H of the buffer0Initial value of (1), H1Initial value of (1), H2Initial value of (1), H3Initial value of (1), H4An initial value of (1);
a second assignment module for assigning H0Of (d), H1Of (d), H2Of (d), H3Of (d), H4Respectively assigning the initial values to a first parameter, a second parameter, a third parameter, a fourth parameter and a fifth parameter;
the third assignment module is used for setting the initial value of P to be 0;
a calculation module for performing the following calculation for t ═ P:
TEMP=S5(H0)+ft(H1,H2,H3)+H4+Wt+Kt;H4=H3;H3=H2;H2=S30(H1);H1=H0;H0TEMP; wherein, WtFor the t +1 th sub-data block of the 80 sub-data blocks, ft(H1,H2,H3) Is a preset function; s5(H0) Means that H is0Left shift by 5; s30(H1) Means that H is1Left shift by 30;
a second trigger module, configured to set P +1, and return to the calculation module until P equals 80, so as to obtain an identifier H of the buffer area0Value of (H)1Value of (A), H2Value of (A), H3Value of (A), H4A value of (d);
a fourth assignment module for ordering H0Final value of ═ H0Value of + first parameter, H1Final value of ═ H1Value of + second parameter, H2Final value of ═ H2Value of + third parameter, H3Final value of ═ H3Value of + fourth parameter, H4Final value of ═ H4The value of + the fifth parameter;
a fifth assignment module for assigning the H0Final value of (a), H1Final value of (1), H2Final value of (1), H3Final value of (1), H4Respectively as the mark H of the buffer corresponding to the G +1 th data block0Initial value of (1), H1Initial value of (1), H2Initial value of (1), H3Initial value of (1), H4An initial value of (1);
the third triggering module is used for setting G +1 and returning to the second dividing module until G is larger than Q;
a sixth obtaining module for obtaining according to H0、H1、H2、H3、H4In the order of (1) to obtain H0Final value of (1), H1Final value of (1), H2Final value of (1), H3Final value of (1), H4160 bit hash value;
a seventh obtaining module, configured to obtain a ciphertext based on the 160-bit hash value;
and the storage module is used for storing the ciphertext to the block chain.
7. The data storage device of claim 6, wherein the bit complement expansion module comprises:
a first padding unit for padding one 1 at the end of the input information;
a second bit complement unit, configured to complement 0 after 1 of the input information bit complement until a remainder of a length of the second packet after the bit complement modulo 512 is 448;
a third bit complementing unit, configured to complement a bit 1 at the end of the second packet;
a fourth bit complement unit, configured to complement 63 0 s after 1 of the bit complement of the second packet, so as to obtain the first packet.
8. A server, comprising:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement the data storage method of any of claims 1 to 5.
9. A computer readable storage medium, instructions in which, when executed by a processor of a server, enable the server to perform a data storage method as claimed in any one of claims 1 to 5.
10. A computer program product directly loadable into the internal memory of a computer, said memory being the memory comprised by the server according to claim 8 and containing software code, said computer program being loadable and executable by the computer to perform the data storage method according to any of claims 1 to 5.
CN202111404029.2A 2021-11-24 2021-11-24 Data storage method, server, medium, and apparatus Pending CN114091117A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111404029.2A CN114091117A (en) 2021-11-24 2021-11-24 Data storage method, server, medium, and apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111404029.2A CN114091117A (en) 2021-11-24 2021-11-24 Data storage method, server, medium, and apparatus

Publications (1)

Publication Number Publication Date
CN114091117A true CN114091117A (en) 2022-02-25

Family

ID=80303909

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111404029.2A Pending CN114091117A (en) 2021-11-24 2021-11-24 Data storage method, server, medium, and apparatus

Country Status (1)

Country Link
CN (1) CN114091117A (en)

Similar Documents

Publication Publication Date Title
US10015163B2 (en) Apparatus and method for cryptographic operations using enhanced knowledge factor credentials
KR102182894B1 (en) USER DEVICE PERFORMING PASSWROD BASED AUTHENTICATION AND PASSWORD Registration AND AUTHENTICATION METHOD THEREOF
WO2019114122A1 (en) Encryption method for login information, device, electronic device, and medium
CN115080615A (en) Data query method and device based on multi-party security calculation
CN115051798A (en) Random number generation method and device, electronic equipment and storage medium
CN113746620A (en) Homomorphic encryption method, apparatus, medium, and computer program product
Akhavan et al. Hash function based on piecewise nonlinear chaotic map
CN112235104B (en) Data encryption transmission method, system, terminal and storage medium
Akhshani et al. Hash function based on hierarchy of 2D piecewise nonlinear chaotic maps
CN114091117A (en) Data storage method, server, medium, and apparatus
CN110234082B (en) Addressing method and device of mobile terminal, storage medium and server
CN114124357B (en) Ciphertext generation method, server, medium and device based on Fourier series
CN114124356B (en) Ciphertext generation method, server, medium and device applied to blockchain
CN114374505A (en) Ciphertext generating method, device, server, medium and product
CN114221753B (en) Key data processing method and electronic equipment
CN107947944B (en) Incremental signature method based on lattice
CN114091070A (en) Hilbert transform-based ciphertext generation method, server, medium, and apparatus
Huang et al. Security analysis of image encryption based on twodimensional chaotic maps and improved algorithm
CN114124358B (en) Ciphertext generating method, ciphertext generating device, server and medium
WO2021052033A1 (en) Data calling method and apparatus, and device and computer readable storage medium
EP3238367B1 (en) Technique for generating a password
CN113901437A (en) Password generation method and device, computer equipment and storage medium
CN114499465A (en) Hash algorithm, circuit and electronic equipment
Pamuła et al. Securing video stream captured in real time
CN112073174B (en) Communication account decryption method, device, equipment, storage medium and information interaction system

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