CN114900284A - Method for generating SM2 key based on mnemonic words - Google Patents

Method for generating SM2 key based on mnemonic words Download PDF

Info

Publication number
CN114900284A
CN114900284A CN202210316524.6A CN202210316524A CN114900284A CN 114900284 A CN114900284 A CN 114900284A CN 202210316524 A CN202210316524 A CN 202210316524A CN 114900284 A CN114900284 A CN 114900284A
Authority
CN
China
Prior art keywords
intermediate value
key
random number
values
bits
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
CN202210316524.6A
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.)
Beijing Rongyi Technology Co ltd
Original Assignee
Beijing Rongyi Technology 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 Beijing Rongyi Technology Co ltd filed Critical Beijing Rongyi Technology Co ltd
Publication of CN114900284A publication Critical patent/CN114900284A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/06Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols the encryption apparatus using shift registers or memories for block-wise or stream coding, e.g. DES systems or RC4; Hash functions; Pseudorandom sequence generators
    • H04L9/0643Hash functions, e.g. MD5, SHA, HMAC or f9 MAC
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0861Generation of secret information including derivation or calculation of cryptographic keys or passwords
    • H04L9/0869Generation of secret information including derivation or calculation of cryptographic keys or passwords involving random numbers or seeds
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0894Escrow, recovery or storing of secret information, e.g. secret key escrow or cryptographic key storage
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/30Public key, i.e. encryption algorithm being computationally infeasible to invert or user's encryption keys not requiring secrecy
    • H04L9/3066Public key, i.e. encryption algorithm being computationally infeasible to invert or user's encryption keys not requiring secrecy involving algebraic varieties, e.g. elliptic or hyper-elliptic curves
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3236Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions
    • H04L9/3239Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions involving non-keyed hash functions, e.g. modification detection codes [MDCs], MD5, SHA or RIPEMD

Abstract

The present disclosure discloses a method for generating an SM2 key and its derivative sub-key pair based on mnemonics, which mainly comprises the following steps: obtaining an intermediate value of 128 bits in length in binary form based on the first random number; obtaining another intermediate value based on the first random number; taking a certain 4 digits of another intermediate value and a 128-bit intermediate value to obtain a 132-bit new intermediate value, and dividing the intermediate value into 12 segments of values according to a certain algorithm, wherein each segment of values has 11 bits; obtaining 12 decimal values according to the 12 segments of values; finding out 12 corresponding words according to the 12 decimal numerical values and the word list; using the 12 words and all intermediate values, the SM2 key and its derivative sub-key pairs are finally generated through other functional relationships. In this manner, the present disclosure is able to recover or reconstruct a key in the event of a loss of a private key, and may also re-derive other sub-key pairs in the event that the sub-key pair is no longer secure.

Description

Method for generating SM2 key based on mnemonic words
Technical Field
The disclosure belongs to the field of information security, and particularly relates to a method for generating an SM2 key based on mnemonics.
Background
Taking blockchain technology as an example, ownership of digital assets in blockchain is established by a key, an address, and a digital signature, where:
1) and (3) secret key: i.e., asymmetric key pairs, that enable many interesting features of digital assets, including decentralized trust and control, ownership authentication, and cryptographic proof-based security models;
2) address: deriving from the public key according to a specific hash algorithm;
3) digital signature: the generated ciphertext data is encrypted with the key for the specific data.
The above-mentioned key, which is not actually stored in the network but generated and stored by the user himself, is used by the user to sign the uplink data, and its role is crucial. According to the mechanism of the blockchain, each operation needs a valid digital signature to be stored in the blockchain. Only a valid digital key can produce a valid digital signature. It can be understood that which party has possession of the key has possession of control. The secret keys are presented in pairs, one public key and one private key, the public key can be disclosed to the outside, the private key is mastered by the user and can not be replaced, and once replaced, the rights and the behaviors of the user cannot be proved.
In addition to the blockchain domain, other information security domains also require public and private keys. In particular, in the field related to the national cryptographic standard, a key complying with the national cryptographic standard is required.
However, as mentioned before, the private key is of crucial importance, but the private key itself is a string of poorly readable numbers that may be inadvertently lost.
How to generate a key in a new way by using mnemonics is always a problem to be solved urgently.
Disclosure of Invention
In view of this, the present disclosure discloses a method for generating an SM2 key based on a mnemonic, comprising the steps of:
s10, obtaining a first intermediate value with the length of 128 bits in a binary form based on the first random number;
s20, calculating the first random number through an SHA-3 algorithm, and generating at least a 32-byte second intermediate value;
s30, based on the second intermediate value, at least obtaining a third intermediate value with the length of 256 bits in binary form;
s40, taking a certain 4 digits of the third intermediate value, and splicing the digits at the tail of the 128-bit first intermediate value to obtain a new first intermediate value with the length of 132 bits;
s50, dividing the 132-bit new first intermediate value into 12 segments of numerical values according to a certain algorithm, wherein each segment of numerical values has 11 bits;
s60, for the 12 segments of numerical values, converting the 12 segments of numerical values from binary system to decimal system to obtain 12 decimal system numerical values;
s70, for the 12 decimal values, comparing with a preset word list, and finding out words corresponding to the 12 decimal values so as to obtain 12 words;
s80, sequentially splicing the obtained numerical values corresponding to the 12 words into a string of numbers to obtain a fourth intermediate value;
s90, calculating a fifth intermediate value by using a fixed value and an optional value;
s100, at least 2048 times of SM3-512 calculation is carried out on the fourth intermediate value and the fifth intermediate value, and a sixth intermediate value with the length of 512 bits is obtained;
s110, taking 256 bits from the left of the sixth intermediate value to obtain a seventh intermediate value, and taking the seventh intermediate value as a private key;
s120, taking 256 bits from the right of the sixth intermediate value to obtain an eighth intermediate value;
and S130, deducing the seventh intermediate value according to an elliptic curve algorithm to obtain a ninth intermediate value, and taking the ninth intermediate value as a corresponding public key.
Preferably, the first and second liquid crystal materials are,
in step S10, the first random number is generated using a random number generator or a library of calling algorithms.
In a preferred embodiment of the method of the invention,
in step S10, the first random number is at least a 16-byte random number.
Preferably, the first and second liquid crystal materials are,
in step S20, the SHA-3 algorithm includes: SHA-3256 algorithm, SHA-3384 algorithm and SHA-512 algorithm, wherein the output of the SHA-3256 algorithm is 32 bytes, the output of the SHA-3384 algorithm is 48 bytes and the output of the SHA-3512 algorithm is 64 bytes.
Preferably, the first and second liquid crystal materials are,
in step S40, continuous 4-digit numbers such as the first 4 digits and the last 4 digits of the third intermediate value are taken, or numbers at 4-digit intervals are randomly taken.
Through the technical scheme, the method for generating the SM2 key pair based on the mnemonic words is realized, and the method is favorable for recovering the keys through the related mnemonic words again and accessing digital files and the like which can be normally accessed only by the keys under the condition of losing the keys.
Detailed Description
In order to make those skilled in the art understand the technical solutions disclosed in the present disclosure, the technical solutions of the respective embodiments will be described below with reference to the embodiments, which are a part of the embodiments of the present disclosure, but not all of the embodiments. The terms "first," "second," and the like as used in this disclosure are used for distinguishing between different objects and not for describing a particular order. Furthermore, "include" and "have," as well as any variations thereof, are intended to cover and not to exclude inclusions. For example, a process, method, system, or article or apparatus that comprises a list of steps or elements is not limited to only those steps or elements but may alternatively include other steps or elements not expressly listed or inherent to such process, method, system, article, or apparatus.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the disclosure. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It will be appreciated by those skilled in the art that the embodiments described herein may be combined with other embodiments.
In one embodiment, the present disclosure discloses a method for generating an SM2 key based on a mnemonic comprising the steps of:
s10, obtaining a first intermediate value with the length of 128 bits in a binary form based on the first random number;
s20, calculating the first random number through an SHA-3 algorithm, and generating at least a 32-byte second intermediate value;
s30, based on the second intermediate value, at least obtaining a third intermediate value with the length of 256 bits in binary form;
s40, taking a certain 4 digits of the third intermediate value, and splicing the digits at the tail of the 128-bit first intermediate value to obtain a new first intermediate value with the length of 132 bits;
s50, dividing the 132-bit new first intermediate value into 12 segments of numerical values according to a certain algorithm, wherein each segment of numerical values has 11 bits;
s60, for the 12 segments of numerical values, converting the 12 segments of numerical values from binary system to decimal system to obtain 12 decimal system numerical values;
s70, for the 12 decimal values, comparing with a preset word table, finding out words corresponding to the 12 decimal values, thereby obtaining 12 words, wherein the 12 words are readable private key variant forms;
it can be understood that 11-bit binary digits, converted to a decimal maximum of 2047; this means that the present disclosure prioritizes 2000 common words; further, to be generalized, the 2000 common words may be english words, or words of other languages, which of course depends on the construction of the word list. It can be appreciated that English words are preferred.
S80, sequentially splicing the obtained numbers corresponding to the 12 words into a string of numbers to obtain a fourth intermediate value;
s90, calculating a fifth intermediate value by using a fixed value and an optional value;
s100, at least 2048 times of SM3-512 calculation is carried out on the fourth intermediate value and the fifth intermediate value, and a sixth intermediate value with the length of 512 bits is obtained;
s110, taking 256 bits from the left of the sixth intermediate value to obtain a seventh intermediate value, and taking the seventh intermediate value as a private key;
s120, taking 256 bits from the right of the sixth intermediate value to obtain an eighth intermediate value;
and S130, deducing the seventh intermediate value according to an elliptic curve algorithm to obtain a ninth intermediate value, and taking the ninth intermediate value as a corresponding public key.
It can be appreciated that the above embodiments implement a mnemonic-based generation of SM2 keys: the scheme of the private key and the public key is beneficial to recovering or reconstructing the secret key by using the mnemonic words.
In one embodiment of the present invention,
in step S10, the first random number is generated using a random number generator or a library of calling algorithms.
In another embodiment of the present invention, the substrate is,
in step S10, the first random number is at least a 16-byte random number.
It will be appreciated that if more than 16 bytes are used, then a random number of 16 bytes could be generated therefrom according to alternative algorithms.
In another embodiment of the present invention, the substrate is,
in step S20, the SHA-3 algorithm includes: SHA-3256 algorithm, SHA-3384 algorithm and SHA-512 algorithm, wherein the output of the SHA-3256 algorithm is 32 bytes, the output of the SHA-3384 algorithm is 48 bytes and the output of the SHA-3512 algorithm is 64 bytes.
In another embodiment of the present invention, the substrate is,
in step S40, continuous 4-digit numbers such as the first 4 digits and the last 4 digits of the third intermediate value are taken, or numbers at 4-digit intervals are randomly taken.
It will be appreciated that, further, the present disclosure may also utilize the public key of the key pair described above as the parent public key, thereby deriving the child public key according to prior art techniques. Similarly, the child private key can be further derived by using the private key in the key pair as the parent private key. In many scenarios, security can be enhanced by replacing the private key with a child private key. When the derived sub-key is no longer secure, it is possible to fully re-derive the new sub-key.
Those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts, modules and units described are not necessarily required to practice the invention.
In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the several embodiments provided in the present disclosure, it should be understood that the disclosed technical solutions can be implemented as corresponding functional units, processors or even systems, wherein each part of the system can be located in one place or distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment. In addition, each functional unit may be integrated into one processing unit, or each unit may exist alone, or two or more units may be integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit. The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present disclosure may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a smartphone, a personal digital assistant, a wearable device, a laptop, a tablet computer) to perform all or part of the steps of the method according to the embodiments of the present disclosure. The storage medium includes various media capable of storing program codes, such as a USB disk, a Read-only Memory (R0M), a Random Access Memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk, and is not limited to different interfaces or transmission methods, such as USB, bluetooth, or audio.
As described above, the above embodiments are only used to illustrate the technical solutions of the present disclosure, and not to limit the same; although the present disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art will appreciate that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present disclosure.

Claims (3)

1. A method of generating an SM2 key based on a mnemonic comprising the steps of:
obtaining an intermediate value of 128 bits in length in binary form based on the first random number;
obtaining another intermediate value based on the first random number;
taking a certain 4 digits of another intermediate value and a 128-bit intermediate value to obtain a 132-bit new intermediate value, and dividing the intermediate value into 12 segments of numerical values according to a certain algorithm, wherein each segment of numerical value has 11 bits;
obtaining 12 decimal values according to the 12 segments of values;
finding out 12 corresponding words according to the 12 decimal numerical values and the word list;
using the 12 words and all intermediate values, the SM2 key and its derivative sub-key pairs are finally generated through other functional relationships.
2. The method of claim 1, wherein, preferably,
the first random number is generated using a random number generator or a library of calling algorithms.
3. The method of claim 1, wherein,
the first random number is at least a 16 byte random number.
CN202210316524.6A 2021-03-29 2022-03-28 Method for generating SM2 key based on mnemonic words Pending CN114900284A (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN2021103371874 2021-03-29
CN202110337187 2021-03-29

Publications (1)

Publication Number Publication Date
CN114900284A true CN114900284A (en) 2022-08-12

Family

ID=82715545

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210316524.6A Pending CN114900284A (en) 2021-03-29 2022-03-28 Method for generating SM2 key based on mnemonic words

Country Status (1)

Country Link
CN (1) CN114900284A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116011431A (en) * 2023-03-22 2023-04-25 暗链科技(深圳)有限公司 Method for generating mnemonic words and electronic equipment

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116011431A (en) * 2023-03-22 2023-04-25 暗链科技(深圳)有限公司 Method for generating mnemonic words and electronic equipment

Similar Documents

Publication Publication Date Title
US10284372B2 (en) Method and system for secure management of computer applications
US7694147B2 (en) Hashing method and system
TW202101432A (en) Data homomorphic encryption and decryption method and apparatus for implementing privacy protection
CN110110548B (en) Method for storing files in trusted execution environment in encrypted manner based on encryption chip
CN109658078B (en) Block chain private key generation method, device and medium based on biological characteristics
US8369523B2 (en) Surrogate key generation using cryptographic hashing
TWI724579B (en) Block chain data processing method, device, system, processing equipment and storage medium
US9602280B2 (en) System and method for content encryption in a key/value store
JP6533291B2 (en) Method and apparatus for encrypting / decrypting data on a mobile terminal
JP2003249927A (en) Super secure migratable key in tcpa
CN112184444B (en) Method, device, equipment and medium for processing information based on characteristics of information
CN115269938B (en) Homomorphic encryption-based keyword track hiding query method, system and related device
WO2020140626A1 (en) Salt-based data possession verification method and terminal device
WO2022068360A1 (en) Shared root key-based information processing method and apparatus, and device and medium
CN108574567A (en) Private file protection and cryptographic-key management system and method, the information processing terminal
CN115147111A (en) Key generation method and device, electronic device and storage medium
CN114900284A (en) Method for generating SM2 key based on mnemonic words
CN112202555B (en) Information processing method, device and equipment for generating random number based on information attribute
KR20200089877A (en) A privatekey management method
US11876888B2 (en) Encryption device, decryption device, encryption method, decryption method, and computer readable medium
CN116361849A (en) Backup data encryption and decryption method and device for encrypted database
JP2019015918A (en) Encryption data generating device, decryption data generating device, authentication cryptosystem with additional data, and method and program therefor
CN112306582A (en) Configuration variable encryption and decryption method and device, computer equipment and readable storage medium
US10630470B2 (en) Zone based key version encoding
CN113342802A (en) Method and device for storing block chain data

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