The present invention relates to the technical field of MPC algorithms, and in particular to a method for generating keys and signatures based on multi-party calculation.
A sub-field of secure multi-party calculation type cryptography aims to create a method for all parties to collaboratively calculate functions on inputs and retain these inputs, where MPC allows multiple parties to collaboratively generate keys and signatures without trusting each other. In the blockchain field, traditional wallets require owners to save private keys, where public keys can be analyzed to others, so that wallets can be verified.
In actual use, ordinary users need to keep keys to prevent disclosure of personal trouble information. However, if the keys are lost, it will lead to the disclosure of personal sensitive information, and may affect assets in the wallets.
For the defects in the prior art, the present invention provides a method for generating keys and signatures based on multi-party calculation, which solves the problem that if the keys are lost, it will lead to disclosure of personal sensitive information, and may affect the assets in the wallets.
To achieve the above objective, the present invention is implemented by the following technical solution: a method for generating keys and signatures based on multi-party calculation includes the following steps:
Further, in the first step, the S2 of calculating the public keys includes:
Further, in S21, Hash processing includes:
Further, in the fifth step, the step of updating the content of the register specially includes:
Further, the link variables include A-H8 variables, and the conversion variables include a-h8 variables.
Further, the calculation formula of S21 is as follows:
sk(x∥prefix);
public key=hash(Aapk0,A1)*A0+hash(A1,A0)*A1.
Further, in the second step, the S2 of calculating the signatures includes:
Further, in S21, calculating the signatures specially includes the following steps:
R
i=(ri mod q)B, where B is the generator of the group;
Further, after commitment check fails, signing is discontinued; and
after the signature check fails, output is continued and marked as invalid.
Further, communication in the first step and the second step adopt https communication.
The present invention has the following beneficial effects:
according to the method for generating the keys and the signatures based on multi-party calculation, by the multi-party calculation method, a wallet owner can sign by the keys, and whether a message is signed by the wallet owner through the public keys of a wallet can be verified. In the process, it is unnecessary to share sensitive information with other parties, and the problem that the keys are easy to lose is solved, thereby preventing properties in the wallet from being lost, and helping more non-technical users to use a blockchain wallet.
Certainly, it is unnecessary to achieve all the advantages described above at the same time to implement any product of the present invention.
The technical solutions in the embodiments of the present invention are described below clearly with reference to the accompanying drawings in the embodiments of the present invention. Apparently, the described embodiments are a part, but not all the embodiments of the present invention. All other embodiments obtained by a person of ordinary skilled in the art based on the embodiments of the present invention without inventive efforts fall within the scope of protection of the present invention.
In the description of the present invention, it should be understood that orientation or position relationships indicated by terms such as “opening”, “upper”, “lower”, “thickness”, “top”, “middle”, “length”, “in” and “around” are just used to facilitate description of the present invention and simplify the description, but not to indicate or imply that the mentioned components or elements must have a specific orientation and must be established and operated in a specific orientation, and thus, these terms cannot be understood as a limitation to the present invention.
Please refer to
In the first step, the S2 of calculating the public keys includes:
Specially, in S21, Hash processing includes:
In the fifth step, the step of updating the content of the register specially includes:
The link variables include A-H8 variables, and the conversion variables include a-h8 variables.
In the embodiments, the client sends a request for “generating public keys” to the background of Party 0 through the https request, and then Party 0 and Party 1 communicate through https and perform collaborative calculation to obtain the public keys. The specific calculation step includes: each party selects a random key from a field, uses SHA512 to perform Hash processing to obtain an extended private key, and aggregates the generated keys to obtain aggregated public keys.
Hash processing specially includes: padding bits are added in an initial message to enable a length of the initial message to be equal to a value, where the value is 128 bits less than any multiple of 1024. The length of the message except the padding bits is calculated, and the message as a 128-bit block is added to the padding bits, so that the length of the message is exactly a multiple of 128. Then, input information is divided into a plurality of blocks, where the length of each block is 215 bits, and the blocks are inputs of message abstract processing logic.
The 8 link variables A-H are initialized, where in order to generate a 512-bit message abstract in SHA512, 8 link variables are needed, each link variable contains 64 bits, and then the blocks are processed. Firstly, the link variables A-H are copied into variables a-h, where variables a-h are regarded as a single register to store temporary intermediate results and final results. Then, the current 1024-bit block is divided into 16 sub-blocks, the current 1024-bit block, the register and constants are regarded as inputs, and the content of the register is updated through the SHA512 algorithm step, with a total of 80 rounds.
Specially, the calculation formula of the step S21 is as follows:
sk(x∥prefix);
The calculation formula of the step S22 is as follows:
public key=hash(Aapk0,A1)*A0+hash(A1,A0)*A1.
In the embodiments, the public keys can be calculated by the above formula. In the process, the owner does not need to share sensitive information and does not need to keep the keys.
Specially, in the second step, the S2 of calculating signatures includes:
The S21 of calculating signatures specially includes the following steps:
R
i=(ri mod q)B, wherein B is the generator of the group;
After commitment check fails, signing is discontinued; and
after the signature check fails, output is continued and marked as invalid.
In the embodiment, based on the steps, the signatures can be obtained by calculation, and the signatures and the public keys are verified so as to verify whether the message is signed by the wallet owner through the public keys of the wallet.
Specially, communication in the first step and the second step adopt https communication.
In the embodiment, HTTPS is an HTTP channel aiming at security. Based on HTTP, the security of a transmission process is guaranteed through transmission encryption and identity authentication.
Multi-party calculation, that is MPC, allows multiple parties to collaboratively generate keys and signatures without trusting each other. In the blockchain field, each wallet has keys and public keys, wherein the public keys can be shared with others, but the keys need to be kept by the owner. The wallet owner can use the keys to sign. Others can verify whether the message is signed by the wallet owner through the public keys of the wallet. However, in order to prevent the wallet from losing the keys, the MPC the algorithm step can be used to collaboratively generate the keys and signatures through multi-party collaboration and
the client sends a request for “generating public keys” to the background of Party 0 through the https request, and then Party 0 and Party 1 communicate through https and perform collaborative calculation to obtain the public keys. The specific calculation step includes: each party selects a random key from a field, uses SHA512 to perform Hash processing to obtain an extended private key, and aggregates the generated keys to obtain aggregated public keys.
Hash processing specially includes: padding bits are added in an initial message to enable the length of the initial message to be equal to a value, where the value is 128 bits less than any multiple of 1024; the length of the message except the padding bits is calculated, and the message as a 128-bit block is added to the padding bits, so that the length of the message is exactly a multiple of 128; then, input information is divided into a plurality of blocks, where the length of each block is 215 bits, and the blocks are inputs to message abstract processing logic; and
the 8 link variables A-H are initialized, where in order to generate a 512-bit message abstract in SHA512, 8 link variables are needed, each link variable contains 64 bits, and then the blocks are processed. Firstly, the link variables A-H are copied into variables a-h, where variables a-h are regarded as a single register to store temporary intermediate results and final results; then, the current 1024-bit block is divided into 16 sub-blocks, the current 1024-bit block, and the register and constants are regarded as inputs, the content of the register is updated through the SHA512 algorithm step, with a total of 80 rounds.
Specially, the calculation formula is as follows:
sk(x∥prefix);
Then, the public keys are aggregated through public key=hash (Aapk0, A1)*A0+hash (A1, A0)*A1 to obtain the public keys, and the generated public keys are returned to the client through https communication.
After the public keys are generated, the signature link is entered, and the generated signatures and the public keys are verified:
a
i=hash(Ai,A1-i);
R=R
0
+R
1 and=hash(R,apk,M)k;
s
i
=r
i
+k*x
i
*a
i mod q;
In the process, after commitment check fails, signing is discontinued, so that the signatures cannot be generated. After the signature check fails, output is continued, but the output results are marked as invalid.
Based on the steps, the public keys and the signatures can be generated, and verification is performed, so that users do not need to keep the keys, and the public keys and the signatures are generated by multi-party calculation; and each party does not need to share sensitive information, so as to prevent the user from writing the private keys and causing disclosure of assets, and also help more non-technical users to use the blockchain wallet.
It should be noted that in this specification, relational terms such as first and second are only used to differentiate one entity or operation from another entity or operation, and do not necessarily require or imply that any actual relation or sequence exists between these entities or operations. Besides, the terms “comprise”, “include” or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.
The preferred embodiments of the present invention disclosed above are only used to help explain the present invention. Not all details are described in detail in the preferable embodiments, and the present invention is not limited to specific implementations. Obviously,
many modifications and changes may be made based on content of this specification. The embodiments are selected and specifically described in the specification to better explain the principle and practical application of the present invention, so that those skilled in the art can better understand and use the present invention. The present invention is limited only by the claims and full scope and equivalents thereof.