WO2021068290A1 - 基于区块链的密钥生成方法、相关装置及计算机存储介质 - Google Patents

基于区块链的密钥生成方法、相关装置及计算机存储介质 Download PDF

Info

Publication number
WO2021068290A1
WO2021068290A1 PCT/CN2019/112860 CN2019112860W WO2021068290A1 WO 2021068290 A1 WO2021068290 A1 WO 2021068290A1 CN 2019112860 W CN2019112860 W CN 2019112860W WO 2021068290 A1 WO2021068290 A1 WO 2021068290A1
Authority
WO
WIPO (PCT)
Prior art keywords
key
public key
sender
blockchain
private key
Prior art date
Application number
PCT/CN2019/112860
Other languages
English (en)
French (fr)
Inventor
蒋炜
于卓
谢可
董爱强
赵建保
张春光
郭少勇
郝艳亚
Original Assignee
北京中电普华信息技术有限公司
国网信息通信产业集团有限公司
国家电网有限公司
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 北京中电普华信息技术有限公司, 国网信息通信产业集团有限公司, 国家电网有限公司 filed Critical 北京中电普华信息技术有限公司
Publication of WO2021068290A1 publication Critical patent/WO2021068290A1/zh

Links

Images

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/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0816Key establishment, i.e. cryptographic processes or cryptographic protocols whereby a shared secret becomes available to two or more parties, for subsequent use
    • H04L9/0838Key agreement, i.e. key establishment technique in which a shared key is derived by parties as a function of information contributed by, or associated with, each of these
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/04Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks
    • H04L63/0428Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks wherein the data content is protected, e.g. by encrypting or encapsulating the payload
    • 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/3006Public key, i.e. encryption algorithm being computationally infeasible to invert or user's encryption keys not requiring secrecy underlying computational problems or public-key parameters
    • H04L9/3033Public key, i.e. encryption algorithm being computationally infeasible to invert or user's encryption keys not requiring secrecy underlying computational problems or public-key parameters details relating to pseudo-prime or prime number generation, e.g. primality test

Definitions

  • This application belongs to the field of key generation technology, and in particular relates to a blockchain-based key generation method, related devices, and computer storage media.
  • the key is usually generated and stored in advance, and when the service data is transmitted, the pre-generated and stored key is used to encrypt the service data.
  • the embodiment of the application is to provide a method for generating a key based on a blockchain, a related device, and a computer storage medium, which are used to at least solve the problems of high risk of cracking the pre-generated key and low data security in the prior art. .
  • the embodiment of the present application provides a method for generating a key based on a blockchain, including:
  • the sender Before the sender sends service data to the receiver, the sender generates a first private key, and generates a first public key based on the first private key;
  • the sender sends the first public key as the amount in the blockchain transaction to the receiver;
  • the receiver generates a second private key, and generates a second public key based on the second private key;
  • the receiver sends the second public key as the amount in the blockchain transaction to the sender;
  • the sender calculates a first shared key based on the first private key and the second public key; the receiver calculates a second shared key based on the second private key and the first public key Shared key.
  • the sender generating the first private key and generating the first public key based on the first private key includes:
  • the sender randomly selects prime numbers
  • the blockchain-based sender sending the first public key as the amount in the blockchain transaction data to the receiver includes:
  • the sender performs zero-padded operations on the prime number, the generator, and the first public key, respectively, to obtain a prime number with a length of 8 bits after zero-padded, the generator, and the first public key;
  • the sender publicly broadcasts the ledger, selects a transaction that the sender has not spent from the ledger to output UTXO, and pays from the UTXO to the receiver the values are 8-bit prime numbers, 8-bit generators, and 8-bit lengths.
  • the unit of the first public key is the amount of satoshi.
  • the payment value from the UTXO to the recipient is an 8-bit prime number, an 8-bit length generator, and an 8-bit first public key, and the unit is the amount of satoshi.
  • the sender broadcasts the transaction paid to the receiver to the blockchain distributed system, so that after the transaction confirmation is completed, the transaction is written into the block and added to the blockchain through the block.
  • the receiver generating the second private key and generating the second public key based on the second private key includes: after the receiver obtains the ledger, within an interval greater than 1 and less than the prime number , Randomly select data as the second private key;
  • the sender calculating the first shared key based on the first private key and the second public key includes:
  • K1 is the first shared key
  • B is the second public key
  • a is the first private key
  • p is a prime number
  • the receiver calculating the second shared key based on the second private key and the first public key includes:
  • K2 is the second shared key
  • A is the first public key
  • b is the second private key
  • p is a prime number.
  • the sender encrypts the service data by using the first shared key.
  • the embodiment of the present application also provides a block chain-based key generation device, including:
  • the first generating unit is configured to, before the sender sends service data to the receiver, the sender generates a first private key, and generates a first public key based on the first private key;
  • the first sending unit is configured to be based on the blockchain, and the sender sends the first public key as the amount in the blockchain transaction to the receiver;
  • a second generating unit configured to generate a second private key by the receiver, and generate a second public key based on the second private key
  • the second sending unit is configured to be based on the blockchain, and the receiver sends the second public key as the amount in the blockchain transaction to the sender;
  • the calculation unit is configured to: the sender calculates a first shared key based on the first private key and the second public key; the receiver calculates the first shared key based on the second private key and the first public key , Calculate the second shared key.
  • the first generating unit includes:
  • the selection subunit is configured to randomly select a prime number by the sender, and randomly select data as the first private key in an interval greater than 1 and less than the prime number;
  • an encryption unit configured to encrypt the service data by using the first shared key or the second shared key obtained by calculation.
  • the embodiment of the present application also provides a blockchain-based key generation method, which is applied to the sender, and the method includes:
  • the sender Before sending the service data to the receiver, the sender generates a first private key, and generates a first public key based on the first private key;
  • a first shared key is calculated.
  • the embodiment of the present application also provides a method for generating a key based on a blockchain, which is applied to a receiver, and the method includes:
  • the receiver generates a second private key, and generates a second public key based on the second private key;
  • the receiver sends the second public key as the amount in the blockchain transaction
  • the receiver calculates a second shared key based on the second private key and the received first public key.
  • the embodiment of the present application also provides a block chain-based key generation device, which is applied to the sender, and the device includes:
  • a generating unit configured to generate a first private key before sending the service data, and generate a first public key based on the first private key
  • a sending unit configured to send the first public key as an amount in a blockchain transaction based on the blockchain
  • the calculation unit is configured to calculate the first shared key based on the first private key and the second public key obtained for the sent first public key.
  • the embodiment of the present application also provides a block chain-based key generation device, which is applied to the receiver, and includes:
  • a generating unit configured to generate a second private key, and generate a second public key based on the second private key
  • a sending unit configured to send the second public key as an amount in a blockchain transaction based on the blockchain
  • the calculation unit is configured to calculate a second shared key based on the second private key and the received first public key.
  • the embodiment of the present application also provides a block chain-based key generation device, including a memory, a processor, and the steps of the aforementioned block chain-based key generation method stored on the memory and capable of running on the processor.
  • the sender before the sender sends service data to the receiver, the sender generates the first private key, and generates the first public key based on the first private key; based on the block Chain, the sender sends the first public key as the amount in the blockchain transaction data to the receiver; the receiver generates a second private key, and generates a second public key based on the second private key Based on the blockchain, the receiver sends the second public key as the amount in the blockchain transaction data to the sender; the sender calculates based on the first private key and the second public key A first shared key; the receiver calculates a second shared key based on the second private key and the first public key.
  • the first shared key or the second shared key can be used to encrypt the service data, and because the service data only needs to be transmitted between the sender and the receiver,
  • the generation of the first shared key and the second shared key reduces the storage time of the key compared with the scheme of pre-generating the key in the related technology, thereby reducing the risk of the key being cracked and improving the use of the key
  • the security of encrypted data is a code that is used to encrypt the service data.
  • Fig. 1 is a first flowchart of a blockchain-based key generation method provided by an embodiment of the present application
  • Fig. 2 is a second flowchart of a method for generating a key based on a blockchain provided by an embodiment of the present application;
  • FIG. 3 is a schematic diagram of generating a key for encrypting service data transmitted between a sender and a receiver according to an embodiment of the present application
  • FIG. 4 is a schematic diagram of the structure of a blockchain-based key generation device provided by an embodiment of the present application.
  • FIG. 5 is a schematic structural diagram of a block chain-based key generation device applied to a sender according to an embodiment of the present application
  • FIG. 6 is a schematic structural diagram of a block chain-based key generation device applied to a receiver according to an embodiment of the present application
  • FIG. 7 is a schematic diagram of the hardware structure of the blockchain-based key generation device provided by an embodiment of the present application.
  • the embodiment of the present application provides a method for generating a key based on a blockchain. As shown in FIG. 1, the method may include the following steps:
  • the sender Before the sender sends service data to the receiver, the sender generates a first private key, and generates a first public key based on the first private key.
  • business data is different.
  • the excess electricity can be used for subsidies and nearby transactions.
  • user A has surplus power
  • he can conduct a nearby transaction of surplus power with nearby user B.
  • the transaction data includes sales price and sales volume.
  • the sales price and sales volume are business data, and user A needs to send the business data to user B.
  • the sender When it is necessary to use a key to encrypt business data, the sender generates a first private key, and generates a first public key based on the first private key.
  • the sender Based on the blockchain, the sender sends the first public key as the amount in the blockchain transaction to the receiver.
  • Blockchain refers to a chained data structure that combines blocks in a sequential manner in chronological order, and is a distributed ledger that cannot be tampered with and is guaranteed by cryptography.
  • the transaction process based on the block chain includes the steps of payment transaction, transaction broadcast, transaction writing into the block, and block joining the block chain.
  • the transaction object can be Bitcoin.
  • the sender and the receiver are respectively regarded as two sub-nodes in the blockchain distributed system, and the process of negotiating the key between the sender and the receiver is used as the process of the transaction between the sender and the receiver.
  • the sender acts as the payer, and pays the first public key as the transaction amount to the receiver.
  • the receiver generates a second private key, and generates a second public key based on the second private key.
  • the receiver After the sender successfully pays to the receiver, the receiver generates a second private key, and generates a second public key based on the second private key.
  • the receiver Based on the blockchain, the receiver sends the second public key as the amount in the blockchain transaction to the sender.
  • Step S102 is a transaction in which the sender makes a payment to the receiver
  • step S104 is a transaction in which the receiver makes a payment to the sender.
  • the receiver serves as the payer
  • the second public key is used as the transaction amount to pay to the sender.
  • the sender calculates a first shared key based on the first private key and the second public key; the receiver calculates based on the second private key and the first public key The second shared key.
  • the first shared key or the second shared key can be used to encrypt the service data transmitted between the sender and the receiver.
  • S101 and S102 are processing steps of the sender
  • S103 and S104 are processing steps of the receiver. There is no strict sequence of these two major steps, and they can also be carried out at the same time.
  • the sender before the sender sends service data to the receiver, the sender generates the first private key, and generates the first public key based on the first private key; based on the blockchain, The sender sends the first public key as the amount in the blockchain transaction data to the recipient; the recipient generates a second private key, and generates a second public key based on the second private key; based on In the blockchain, the receiver sends the second public key as the amount in the blockchain transaction data to the sender; the sender calculates the first private key and the second public key based on the first private key and the second public key. A shared key; the receiver calculates a second shared key based on the second private key and the first public key.
  • the first shared key or the second shared key can be used to encrypt the service data, and since the service data needs to be transmitted between the sender and the receiver, only when the service data needs to be transmitted between the sender and the receiver, the first shared key or the second shared key can be used to encrypt the service data.
  • the generation of the first shared key and the second shared key reduces the storage time of the key compared with the scheme of pre-generating the key in the related technology, thereby reducing the risk of the key being cracked and improving the use of the key The security of encrypted data. Moreover, the storage space will not be occupied for a long time, the utilization rate of storage resources is improved, and the storage cost is reduced.
  • This embodiment also provides another embodiment of a blockchain-based key generation method. As shown in FIG. 2, the method may include the following steps:
  • the key is generated when the key is needed to encrypt the business data.
  • the process of generating the key involves the sender randomly selecting a prime number p.
  • S202 Randomly select data as the first private key in an interval greater than 1 and less than the prime number.
  • the sender randomly selects data between [1, p] as the first private key a, that is, 1 ⁇ a ⁇ p.
  • the sender performs zero-padded operations on the prime number, the generator, and the first public key, respectively, to obtain a prime number with a length of 8 bits after zero-padded, the generator, and the first public key.
  • the sender publicly broadcasts the ledger, selects a transaction output UTXO that the sender has not spent from the ledger, and pays from the UTXO to the receiver the value of which is an 8-digit prime number, an 8-digit generator, and 8.
  • the first public key of bit length, the unit is the amount of satoshi.
  • Bitcoin transactions are composed of transaction input and transaction output. Each transaction costs an input to produce an output, and the remaining output is UTXO (Unspent Transaction Output).
  • UTXO Unspent Transaction Output
  • Blockchain is a distributed ledger, a way to collectively maintain a reliable database through decentralization and trustlessness, and blockchain is a distributed database that is almost impossible to change.
  • Distributed here is not only embodied in the distributed storage of data, but also embodied in the distributed record of data, that is, it is jointly maintained by each child node in the blockchain distributed system.
  • the sender as a child node in the blockchain distributed system, publicly broadcasts the ledger, selects from the ledger other child nodes in the blockchain distributed system to pay to the sender’s UTXO, and receives from the selected UTXO
  • the party pays 0.000...0A satoshis, 0.0...0000g satoshis, and 0.0...0000p satoshis.
  • 1BTC (Bitcoin) 10 ⁇ 8 Satoshi.
  • the sender broadcasts the transaction paid to the receiver to the blockchain distributed system, so that after the transaction confirmation is completed, the transaction is written into the block and added to the blockchain through the block.
  • the transaction paid by the sender to the receiver needs to be broadcast to the blockchain distributed system, so that each child node in the blockchain distributed system can receive it This transaction confirms whether the transaction is successful.
  • Each child node uses the received transaction as the input of the block in the block chain, that is, writes the transaction into the block, and adds the block written into the transaction to the block chain.
  • the timestamp server adds timestamps to the transactions stored in the form of blocks, so that each transaction actually generated can be stored correctly.
  • the ledger will be updated.
  • the receiver randomly selects data in the interval [1, p] as the second private key b, that is, l ⁇ b ⁇ p.
  • the receiver sends the second public key as the amount in the blockchain transaction to the sender.
  • the receiver After the receiver gets B, it performs zero padding on B. Specifically, 0 is filled on the left side of the data, so that the total length of the data after 0 is filled is 8 bits, resulting in 0.000...0B.
  • the recipient as a child node in the blockchain distributed system, publicly broadcasts the ledger, selects from the ledger other child nodes in the blockchain distributed system to pay the recipient's UTXO, and sends it from the selected UTXO
  • the party pays 0.000...0B Satoshi.
  • K2 is the second shared key
  • A is the first public key
  • b is the second private key
  • p is a prime number.
  • an encryption algorithm needs to be used to encrypt and decrypt the service data transmitted between the sender and the receiver based on the shared key.
  • the distributed ledger based on the blockchain in this embodiment generates the key between the sender and the receiver, the ciphertext after the sender uses the key to encrypt the business data can only be decrypted by the receiver, thereby reducing the encryption.
  • the probability of text being deciphered improves the security of business data.
  • FIG. 3 is a schematic diagram of generating a key for encrypting the service data transmitted between the sender and the receiver in this embodiment.
  • Alice is the sender and Bob is the receiver.
  • An embodiment of the present application also provides a blockchain-based key generation method applied to a sender, and the method includes:
  • the sender Before sending the service data to the receiver, the sender generates a first private key and generates a first public key based on the first private key; based on the blockchain, the first public key is used as a block The amount in the chain transaction is sent; based on the first private key and the second public key obtained for the sent first public key, the first shared key is calculated.
  • An embodiment of the present application also provides a blockchain-based key generation method applied to a receiver, the method including:
  • an embodiment of the present application provides a blockchain-based key generation device. As shown in FIG. 4, the device includes:
  • the first generating unit 401 is configured to before the sender sends service data to the receiver, the sender generates a first private key, and generates a first public key based on the first private key.
  • the first generating unit 401 includes:
  • the selection subunit is configured to randomly select a prime number by the sender, and randomly select data as the first private key in an interval greater than 1 and less than the prime number;
  • the first sending unit 402 is configured to be based on the blockchain, and the sender sends the first public key as the amount in the blockchain transaction to the receiver;
  • the second generating unit 403 is configured to generate a second private key by the receiver, and generate a second public key based on the second private key;
  • the second sending unit 404 is configured to be based on the blockchain, and the receiver sends the second public key as the amount in the blockchain transaction to the sender;
  • the calculation unit 405 is configured to: the sender calculates a first shared key based on the first private key and the second public key; the receiver calculates the first shared key based on the second private key and the first public key Key to calculate the second shared key.
  • the device may further include:
  • the encryption unit is configured to encrypt the service data by using the first shared key or the second shared key obtained by calculation.
  • the device may further include:
  • the decryption unit is configured to decrypt the encrypted service data by using the calculated first shared key or the second shared key.
  • first generating unit 401, the first sending unit 402, the second generating unit 403, the second sending unit 404, and the calculating unit 405 in the device can all be operated by the central processing unit (CPU, Central Processing Unit, Digital Signal Processor (DSP, Digital Signal Processor), Microcontroller Unit (MCU) or Programmable Gate Array (FPGA, Field-Programmable Gate Array) are implemented.
  • CPU Central Processing Unit
  • DSP Digital Signal Processor
  • MCU Microcontroller Unit
  • FPGA Field-Programmable Gate Array
  • the embodiment of the present application provides a block chain-based key generation device, which is applied to the sender.
  • the device includes: a generating unit 501, a sending unit 502, and a calculating unit 503; among them,
  • the generating unit 501 is configured to generate a first private key before the sender sends service data, and generate a first public key based on the first private key;
  • the sending unit 502 is configured to send the first public key as the amount in the blockchain transaction based on the blockchain;
  • the calculation unit 503 is configured to calculate a first shared key based on the first private key and a second public key obtained for the sent first public key.
  • the device may further include:
  • the encryption unit is configured to encrypt the service data by using the first shared key or the second shared key obtained by calculation.
  • the device may further include:
  • the decryption unit is configured to decrypt the encrypted service data by using the calculated first shared key or the second shared key.
  • the embodiment of the present application provides a block chain-based key generation device, which is applied to a receiver.
  • the device includes: a generating unit 601, a sending unit 602, and a calculating unit 603; among them,
  • the generating unit 601 is configured to generate a second private key, and generate a second public key based on the second private key;
  • the sending unit 602 is configured to send the second public key as the amount in the blockchain transaction based on the blockchain;
  • the calculation unit 603 is configured to calculate a second shared key based on the second private key and the received first public key.
  • the device may further include:
  • the encryption unit is configured to encrypt the service data by using the first shared key or the second shared key obtained by calculation.
  • the device may further include:
  • the decryption unit is configured to decrypt the encrypted service data by using the calculated first shared key or the second shared key.
  • the generating unit 501, sending unit 502, and calculating unit 503 applied to the sender and the generating unit 601, sending unit 602, and calculating unit 603 applied to the receiver in the device can all be controlled by the device in practical applications CPU, DSP, MCU or FPGA implementation.
  • the key generation device based on the blockchain in the embodiment of the present application, because the key generation device solves the problem in principle similar to the aforementioned blockchain-based key generation method, therefore, the key generation device
  • the key generation device For the implementation process and implementation principle of, please refer to the implementation process and implementation principle description of the aforementioned blockchain-based key generation method, and the repetition will not be repeated.
  • the sender before the sender sends service data to the receiver, the sender generates the first private key, and generates the first public key based on the first private key; based on the blockchain, The sender sends the first public key as the amount in the blockchain transaction data to the recipient; the recipient generates a second private key, and generates a second public key based on the second private key; based on In the blockchain, the receiver sends the second public key as the amount in the blockchain transaction data to the sender; the sender calculates the first private key and the second public key based on the first private key and the second public key. A shared key; the receiver calculates a second shared key based on the second private key and the first public key.
  • the first shared key or the second shared key can be used to encrypt the service data, and because the service data only needs to be transmitted between the sender and the receiver, Generating the first shared key and the second shared key shortens the storage time of the key, thereby reducing the risk of the key being cracked, and improving the security of using the key to encrypt data. Moreover, the storage space will not be occupied for a long time, the utilization rate of storage resources is improved, and the storage cost is reduced.
  • An embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored, where the program is at least used to execute any of the blockchain-based keys shown in FIGS. 1 to 3 when the program is executed by the processor. Steps to generate method.
  • the computer-readable storage medium may specifically be a memory.
  • the memory may be the memory 702 as shown in FIG. 7.
  • FIG. 7 is a schematic diagram of the hardware structure of a key generation device based on a blockchain according to an embodiment of the present invention.
  • the device includes: a communication component 703 for data transmission, at least one processor 701, and a memory 702 for storing a computer program that can run on the processor 701.
  • the various components in the terminal are coupled together through the bus system 704.
  • the bus system 704 is used to implement connection and communication between these components.
  • the bus system 704 also includes a power bus, a control bus, and a status signal bus.
  • various buses are marked as the bus system 704 in FIG. 7.
  • the processor 701 executes at least the steps of any one of the methods shown in FIG. 1 to FIG. 3 when executing the computer program.
  • the memory 702 may be a volatile memory or a non-volatile memory, and may also include both volatile and non-volatile memory.
  • the non-volatile memory can be a read-only memory (ROM, Read Only Memory), a programmable read-only memory (PROM, Programmable Read-Only Memory), an erasable programmable read-only memory (EPROM, Erasable Programmable Read- Only Memory, Electrically Erasable Programmable Read-Only Memory (EEPROM), Ferromagnetic Random Access Memory (FRAM), Flash Memory, Magnetic Surface Memory , CD-ROM, or CD-ROM (Compact Disc Read-Only Memory); magnetic surface memory can be magnetic disk storage or tape storage.
  • the volatile memory may be a random access memory (RAM, Random Access Memory), which is used as an external cache.
  • RAM random access memory
  • SRAM static random access memory
  • SSRAM synchronous static random access memory
  • Synchronous Static Random Access Memory Synchronous Static Random Access Memory
  • DRAM Dynamic Random Access Memory
  • SDRAM Synchronous Dynamic Random Access Memory
  • DDRSDRAM Double Data Rate Synchronous Dynamic Random Access Memory
  • ESDRAM Enhanced Synchronous Dynamic Random Access Memory
  • SLDRAM synchronous connection dynamic random access memory
  • DRRAM Direct Rambus Random Access Memory
  • the memory 702 described in the embodiment of the present invention is intended to include, but is not limited to, these and any other suitable types of memory.
  • the method disclosed in the foregoing embodiment of the present invention may be applied to the processor 701 or implemented by the processor 701.
  • the processor 701 may be an integrated circuit chip with signal processing capability. In the implementation process, the steps of the foregoing method can be completed by an integrated logic circuit of hardware in the processor 701 or instructions in the form of software.
  • the aforementioned processor 701 may be a general-purpose processor, a DSP, or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, and the like.
  • the processor 701 may implement or execute various methods, steps, and logical block diagrams disclosed in the embodiments of the present invention.
  • the general-purpose processor may be a microprocessor or any conventional processor or the like.
  • the steps of the method disclosed in the embodiments of the present invention may be directly embodied as being executed and completed by a hardware decoding processor, or executed and completed by a combination of hardware and software modules in the decoding processor.
  • the software module may be located in a storage medium, and the storage medium is located in the memory 702.
  • the processor 701 reads the information in the memory 702 and completes the steps of the foregoing method in combination with its hardware.
  • the blockchain-based key generation device can be implemented by one or more application specific integrated circuits (ASIC, Application Specific Integrated Circuit), DSP, programmable logic device (PLD, Programmable Logic Device), complex Programmable logic device (CPLD, Complex Programmable Logic Device), FPGA, general-purpose processor, controller, MCU, microprocessor (Microprocessor), or other electronic components to implement the aforementioned blockchain-based key generation method.
  • ASIC Application Specific Integrated Circuit
  • DSP programmable logic device
  • PLD Programmable Logic Device
  • CPLD Complex Programmable logic device
  • FPGA general-purpose processor
  • controller MCU
  • microprocessor Microprocessor
  • this application can be provided as methods, systems, or computer program products. Therefore, this application may adopt the form of hardware embodiment, software embodiment, or a combination of software and hardware embodiments. Moreover, this application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, optical storage, etc.) containing computer-usable program codes.
  • These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device.
  • the device implements the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
  • These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment.
  • the instructions provide steps for implementing the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
  • the sender generates the first public key based on the generated first private key; the receiver generates the second public key based on the generated second private key; based on the blockchain, the sender, The receiver sends their public key as the amount in the blockchain transaction data to the other party; the sender and receiver calculate their respective shared keys based on the first private key and the second public key they received.
  • the first shared key, the second shared key so that when the sender and the receiver transmit service data, the first shared key or the second shared key can be used to encrypt the service data.
  • the key is shortened compared with the scheme of pre-generating the key in the related technology.
  • the storage time of the key is reduced, and the risk of the key being cracked is reduced, and the security of using the key to encrypt data is improved. Moreover, the storage space will not be occupied for a long time, the utilization rate of storage resources is improved, and the storage cost is reduced.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computing Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Business, Economics & Management (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • Economics (AREA)
  • Development Economics (AREA)
  • Marketing (AREA)
  • Strategic Management (AREA)
  • Technology Law (AREA)
  • Physics & Mathematics (AREA)
  • General Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • General Engineering & Computer Science (AREA)
  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)

Abstract

一种基于区块链的密钥生成方法、装置及计算机存储介质。方法包括:在发送方向接收方发送业务数据前,发送方生成第一私有密钥,并基于第一私有密钥生成第一公开密钥(S101);基于区块链,发送方将所述第一公开密钥作为区块链交易中的金额发送给接收方(S102);接收方生成第二私有密钥,并基于第二私有密钥生成第二公开密钥(S103);基于区块链,接收方将所述第二公开密钥作为区块链交易中的金额发送给发送方(S104);发送方基于第一私有密钥和第二公开密钥,计算出第一共享密钥;接收方基于第二私有密钥和第一公开密钥,计算出第二共享密钥(S105)。

Description

基于区块链的密钥生成方法、相关装置及计算机存储介质
相关申请的交叉引用
本申请基于申请号为201910949286.0、申请日为2019年10月08日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的内容在此以引入方式并入本申请。
技术领域
本申请属于密钥生成技术领域,尤其涉及一种基于区块链的密钥生成方法、相关装置及计算机存储介质。
背景技术
在发送方和接收方之间传输业务数据时,为了保证数据的安全性,需要利用密钥对传输的业务数据进行加密。
现有技术中,通常预先生成密钥并存储密钥,并在进行业务数据传输时,再利用预先生成并存储的密钥对业务数据进行加密。
但是,由于预先生成并存储私钥和公钥,导致为破解密钥预留了一定的时间,提高了密钥被破解的风险,从而使得数据安全性不足。
发明内容
本申请实施例在于提供一种基于区块链的密钥生成方法、相关装置及计算机存储介质,至少用于解决现有技术中预先生成的密钥被破解的风险高、数据安全性低的问题。
本申请实施例采用的技术方案如下所述:
本申请实施例提供一种基于区块链的密钥生成方法,包括:
在发送方向接收方发送业务数据前,发送方生成第一私有密钥,并基 于所述第一私有密钥生成第一公开密钥;
基于区块链,发送方将所述第一公开密钥作为区块链交易中的金额发送给接收方;
接收方生成第二私有密钥,并基于所述第二私有密钥生成第二公开密钥;
基于区块链,接收方将所述第二公开密钥作为区块链交易中的金额发送给发送方;
发送方基于所述第一私有密钥和所述第二公开密钥,计算出第一共享密钥;接收方基于所述第二私有密钥和所述第一公开密钥,计算出第二共享密钥。
上述方案中,所述发送方生成第一私有密钥,并基于所述第一私有密钥生成第一公开密钥,包括:
发送方随机选取素数;
在大于1且小于所述素数的区间内,随机选取数据作为第一私有密钥;
基于公式A=g^a mod p计算得到第一公开密钥;其中,A为第一公开密钥;a为第一私有密钥;p为素数;g为生成元、是所述素数的原根。
上述方案中,所述基于区块链发送方将所述第一公开密钥作为区块链交易数据中的金额发送给接收方,包括:
发送方对所述素数、所述生成元和所述第一公开密钥分别进行补零操作,得到补零后长度为8位的素数、生成元和第一公开密钥;
发送方公开广播账本,从账本中选择一个该发送方未花费的交易输出UTXO,并从所述UTXO中向接收方支付数值分别为8位长度的素数、8位长度的生成元和8位长度的第一公开密钥,单位均为聪的金额。
上述方案中,所述从所述UTXO中向接收方支付数值分别为8位长度的素数、8位长度的生成元和8位长度的第一公开密钥,单位均为聪的金额 之后,还包括:
发送方将向接收方支付的交易广播到区块链分布式系统中,使得完成交易确认后将该交易写入区块并通过区块加入到区块链中。
上述方案中,所述接收方生成第二私有密钥,并基于所述第二私有密钥生成第二公开密钥包括:接收方获取到账本后,在大于1且小于所述素数的区间内,随机选取数据作为第二私有密钥;
基于公式B=g^b mod p计算得到第二公开密钥;其中,B为第二公开密钥;b为第二私有密钥;p为素数;g为生成元、是所述素数的原根。
上述方案中,所述发送方基于所述第一私有密钥和所述第二公开密钥,计算出第一共享密钥包括:
基于公式K1=B^a mod p计算第一共享密钥;其中,K1为第一共享密钥,B为第二公开密钥;a为第一私有密钥;p为素数;
所述接收方基于所述第二私有密钥和所述第一公开密钥,计算出第二共享密钥包括:
基于公式K2=A^b mod p计算第二共享密钥;其中,K2为第二共享密钥,A为第一公开密钥;b为第二私有密钥;p为素数。
上述方案中,还包括:发送方利用所述第一共享密钥对所述业务数据进行加密。
本申请实施例还提供了一种基于区块链的密钥生成装置,包括:
第一生成单元,配置为在发送方向接收方发送业务数据前,发送方生成第一私有密钥,并基于所述第一私有密钥生成第一公开密钥;
第一发送单元,配置为基于区块链,发送方将所述第一公开密钥作为区块链交易中的金额发送给接收方;
第二生成单元,配置为接收方生成第二私有密钥,并基于所述第二私有密钥生成第二公开密钥;
第二发送单元,配置为基于区块链,接收方将所述第二公开密钥作为区块链交易中的金额发送给发送方;
计算单元,配置为发送方基于所述第一私有密钥和所述第二公开密钥,计算出第一共享密钥;接收方基于所述第二私有密钥和所述第一公开密钥,计算出第二共享密钥。
上述方案中,所述第一生成单元包括:
选取子单元,配置为发送方随机选取素数,并在大于1且小于所述素数的区间内,随机选取数据作为第一私有密钥;
计算子单元,配置为基于公式A=g^a mod p计算得到第一公开密钥;其中,A为第一公开密钥;a为第一私有密钥;p为素数;g为生成元,所述生成元是所述素数的原根。
上述方案中,还包括:加密单元,配置为利用计算得到第一共享密钥或第二共享密钥对业务数据进行加密。
本申请实施例还提供一种基于区块链的密钥生成方法,应用于发送方,所述方法包括:
在向接收方发送业务数据前,发送方生成第一私有密钥,并基于所述第一私有密钥生成第一公开密钥;
基于区块链,将所述第一公开密钥作为区块链交易中的金额发送;
基于所述第一私有密钥和针对发送的第一公开密钥而得到的第二公开密钥,计算出第一共享密钥。
本申请实施例还提供一种基于区块链的密钥生成方法,应用于接收方,所述包括:
接收方生成第二私有密钥,并基于所述第二私有密钥生成第二公开密钥;
基于区块链,接收方将所述第二公开密钥作为区块链交易中的金额发 送;
接收方基于所述第二私有密钥和接收到的第一公开密钥,计算出第二共享密钥。
本申请实施例还提供一种基于区块链的密钥生成装置,应用于发送方,该装置包括:
生成单元,配置为在发送业务数据前,生成第一私有密钥,并基于所述第一私有密钥生成第一公开密钥;
发送单元,配置为基于区块链将所述第一公开密钥作为区块链交易中的金额发送;
计算单元,配置为基于所述第一私有密钥和针对发送的第一公开密钥而得到的第二公开密钥,计算出第一共享密钥。
本申请实施例还提供一种基于区块链的密钥生成装置,应用于接收方,包括:
生成单元,配置为生成第二私有密钥,并基于所述第二私有密钥生成第二公开密钥;
发送单元,配置为基于区块链将所述第二公开密钥作为区块链交易中的金额发送;
计算单元,配置为基于所述第二私有密钥和接收到的第一公开密钥,计算出第二共享密钥。
本申请实施例还提供一种基于区块链的密钥生成装置,包括存储器、处理器及存储在存储器上并可在处理器上运行前述的基于区块链的密钥生成方法的步骤。
与现有技术相比,本申请实施例提供的上述技术方案具有如下优点:
从上述技术方案可知,本申请实施例中,在发送方向接收方发送业务数据前,发送方生成第一私有密钥,并基于所述第一私有密钥生成第一公 开密钥;基于区块链,发送方将所述第一公开密钥作为区块链交易数据中的金额发送给接收方;接收方生成第二私有密钥,并基于所述第二私有密钥生成第二公开密钥;基于区块链,接收方将所述第二公开密钥作为区块链交易数据中的金额发送给发送方;发送方基于所述第一私有密钥和所述第二公开密钥,计算出第一共享密钥;接收方基于所述第二私有密钥和所述第一公开密钥,计算出第二共享密钥。使得发送方与接收方之间传输业务数据时,可以利用第一共享密钥或第二共享密钥对业务数据加密,且由于仅在需要在发送方和接收方之间传输业务数据时,才生成第一共享密钥和第二共享密钥,与相关技术中的预先生成密钥的方案相比,缩短了密钥的存储时间,进而降低了密钥被破解的风险,提高了利用密钥加密数据的安全性。
附图说明
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据提供的附图获得其他的附图。
图1是本申请实施例提供的基于区块链的密钥生成方法的流程图一;
图2是本申请实施例提供的基于区块链的密钥生成方法的流程图二;
图3是本申请实施例提供的生成对发送方与接收方之间传输的业务数据进行加密的密钥的示意图;
图4是本申请实施例提供的基于区块链的密钥生成装置的结构示意图;
图5是本申请实施例提供的应用于发送方的基于区块链的密钥生成装置的结构示意图;
图6是本申请实施例提供的应用于接收方的基于区块链的密钥生成装置的结构示意图;
图7是本申请实施例提供的基于区块链的密钥生成装置的硬件结构示意图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
本申请实施例提供了一种基于区块链的密钥生成方法,参见图1所示,该方法可以包括以下步骤:
S101、在发送方向接收方发送业务数据前,发送方生成第一私有密钥,并基于所述第一私有密钥生成第一公开密钥。
在不同的业务场景中,业务数据是不同的。以电力这一业务场景为例,针对新兴的分布式光伏发电模式,除去自用电量部分外,多余电力可以用于申领补贴和就近交易。例如,用户A有多余电力可以与附近的用户B进行多余电力的就近交易,交易数据包括销售价格和销售量,则销售价格和销售量为业务数据,用户A需要将业务数据发送至用户B。
为了保证电力的销售价格和销售量的可信度,需要使用密钥对销售价格和销售量进行加密。
当需要使用密钥对业务数据进行加密的情况下,发送方生成第一私有密钥,并基于第一私有密钥生成第一公开密钥。
S102、基于区块链,发送方将所述第一公开密钥作为区块链交易中的金额发送给接收方。
区块链指的是按照时间顺序将区块以顺序相连的方式组合成的一种链式数据结构,并以密码学方式保证的不可篡改和不可伪造的分布式账本。
基于区块链实现的交易过程包括支付交易、交易广播、交易写入区块、以及区块加入区块链这几个步骤。其中,交易对象可以为比特币。
本实施例中将发送方和接收方分别作为区块链分布式系统中的两个子节点,将发送方和接收方之间协商密钥的过程作为发送方和接收方之间进行交易的过程,发送方作为支付方,将第一公开密钥作为交易金额支付给接收方。
S103、接收方生成第二私有密钥,并基于所述第二私有密钥生成第二公开密钥。
发送方向接收方支付成功后,接收方生成第二私有密钥,并基于第二私有密钥生成第二公开密钥。
S104、基于区块链,接收方将所述第二公开密钥作为区块链交易中的金额发送给发送方。
步骤S102为发送方向接收方进行支付的交易,而步骤S104为接收方向发送方进行支付的交易。
本步骤中接收方作为支付方,将第二公开密钥作为交易金额支付给发送方。
S105、发送方基于所述第一私有密钥和所述第二公开密钥,计算出第一共享密钥;接收方基于所述第二私有密钥和所述第一公开密钥,计算出第二共享密钥。
在计算出第一共享密钥和第二共享密钥后,可以利用第一共享密钥或第二共享密钥对发送方和接收方之间传输的业务数据进行加密。
可以理解,S101和S102为发送方的处理步骤,S103和S104为接收方的处理步骤。这两大步骤无严格的先后顺序,还可以同时进行。
通过上述技术方案,本实施例中,在发送方向接收方发送业务数据前,发送方生成第一私有密钥,并基于所述第一私有密钥生成第一公开密钥; 基于区块链,发送方将所述第一公开密钥作为区块链交易数据中的金额发送给接收方;接收方生成第二私有密钥,并基于所述第二私有密钥生成第二公开密钥;基于区块链,接收方将所述第二公开密钥作为区块链交易数据中的金额发送给发送方;发送方基于所述第一私有密钥和所述第二公开密钥,计算出第一共享密钥;接收方基于所述第二私有密钥和所述第一公开密钥,计算出第二共享密钥。使得发送方与接收方之间传输业务数据时,可以利用第一共享密钥或第二共享密钥对业务数据加密,且由于仅在需要在发送方和接收方之间传输业务数据时,才生成第一共享密钥和第二共享密钥,与相关技术中的预先生成密钥的方案相比,缩短了密钥的存储时间,进而降低了密钥被破解的风险,提高了利用密钥加密数据的安全性。且,不会长时间的占用存储空间,提升了存储资源利用率,降低了存储成本。
本实施例还提供了基于区块链的密钥生成方法的另一种实施例,参见图2所示,该方法可以包括以下步骤:
S201、在发送方向接收方发送业务数据前,发送方随机选取素数。
需要利用密钥对业务数据进行加密时生成密钥。生成密钥的过程包括发送方随机选取素数p。
S202、在大于1且小于所述素数的区间内,随机选取数据作为第一私有密钥。
发送方在[1,p]之间随机选取数据作为第一私有密钥a,即1<a<p。
S203、基于公式A=g^a mod p计算得到第一公开密钥;其中,A为第一公开密钥;a为第一私有密钥;p为素数;g为生成元,所述生成元是所述素数的原根也即生成元g是素数p的原根;mod为求模操作;^为求幂操作。
得到素数p的原根的过程为:假设g是p的原根,那么i值不同g^i mod p的结果两两不同,其中,1<g<p,0<i<p。即g^(p-1)=1(mod p)当且仅当 指数为p-1时成立。
可见,g^i mod p≠g^j mod p,其中i≠j且i,j均介于1至(p-1)之间,则g为p的原根。
p、a、g均确定后,基于公式A=g^a mod p可以计算得到第一公开密钥A。
S204、发送方对所述素数、所述生成元和所述第一公开密钥分别进行补零操作,得到补零后长度为8位的素数、生成元和第一公开密钥。
p、g、A均确定后,对这三个数据分别执行补零操作。具体为在数据左边填充0,使得填充0后的数据总长度为8位,得到0.000…0A,0.0…0000g,0.0…0000p。
S205、发送方公开广播账本,从账本中选择一个该发送方未花费的交易输出UTXO,并从所述UTXO中向接收方支付数值分别为8位长度的素数、8位长度的生成元和8位长度的第一公开密钥,单位均为聪的金额。
比特币的交易由交易输入和交易输出组成,每一笔交易都要花费一笔输入而产生一笔输出,而所剩余的输出就是UTXO(Unspent Transaction Output,未花费的交易输出)。
区块链是一个分布式账本,一种通过去中心化、去信任的方式集体维护一个可靠数据库,区块链是一种几乎不可能被更改的分布式数据库。此处分布式不仅体现为数据的分布式存储,也体现为数据的分布式记录,即由区块链分布式系统中的各个子节点共同维护。
发送方作为区块链分布式系统中的一个子节点,公开广播账本,从账本中选择一个区块链分布式系统中其他的子节点支付给该发送方的UTXO,从选择的UTXO中向接收方支付0.000…0A聪,0.0…0000g聪,0.0…0000p聪。其中,1BTC(比特币)=10^8聪。
S206、发送方将向接收方支付的交易广播到区块链分布式系统中,使 得完成交易确认后将该交易写入区块并通过区块加入到区块链中。
发送方向接收方支付特定数量的聪后,还需要将发送方向接收方支付的此次交易广播到区块链分布式系统中,使得通过区块链分布式系统中的各个子节点都可以接收到此次交易,进而确认此次交易是否成功。各个子节点将接收到的交易作为区块链中区块的输入,即将该交易写入区块中,并将写入交易的该区块加入到区块链中。
其中,时间戳服务器对以区块形式存储的交易加上时间戳,使得每条实际产生的交易都能正确的被存储。
由于交易都被存储在区块链的分布式账本中,因此可以为后续生成的密钥的准确性和真实性提供追溯依据。
S207、区块链记录交易后的账本后,接收方在大于1且小于所述素数的区间内,随机选取数据作为第二私有密钥。
随着区块链分布式系统中各个子节点之间进行交易,账本会进行更新。区块链记录发送方向接收方支付的交易后,接收方在[1,p]这一区间内随机选取数据作为第二私有密钥b,即l<b<p。
S208、基于公式B=g^b mod p计算得到第二公开密钥;其中,B为第二公开密钥;b为第二私有密钥;p为素数;g为生成元,所述生成元是所述素数的原根。
p、b、g均确定后,基于公式B=g^b mod p可以计算得到第二公开密钥B。
S209、基于区块链,接收方将所述第二公开密钥作为区块链交易中的金额发送给发送方。
接收方得到B后,对B执行补零操作。具体为在数据左边填充0,使得填充0后的数据总长度为8位,得到0.000…0B。
接收方作为区块链分布式系统中的一个子节点,公开广播账本,从账 本中选择一个区块链分布式系统中其他的子节点支付给该接收方的UTXO,从选择的UTXO中向发送方支付0.000…0B聪。
S210、基于公式K1=B^a mod p计算第一共享密钥;其中,K1为第一共享密钥,B为第二公开密钥;a为第一私有密钥;p为素数。
并基于公式K2=A^b mod p计算第二共享密钥;其中,K2为第二共享密钥,A为第一公开密钥;b为第二私有密钥;p为素数。
计算得到的第一共享密钥和第二共享密钥后,需要使用加密算法基于共享密钥对发送方和接收方之间传输的业务数据进行加密、解密。
由于本实施例中基于区块链的分布式账本生成发送方和接收方之间的密钥,使得发送方利用密钥对业务数据加密后的密文只能由接收方解密,从而降低了密文被破译的几率,提高了业务数据的安全性。
参见图3所示,为本实施例中生成对发送方与接收方之间传输的业务数据进行加密的密钥的示意图。其中,Alice为发送方,Bob为接收方。
本申请实施例还提供的一种应用于发送方的基于区块链的密钥生成方法,所述方法包括:
在向接收方发送业务数据前,发送方生成第一私有密钥,并基于所述第一私有密钥生成第一公开密钥;基于区块链,将所述第一公开密钥作为区块链交易中的金额发送;基于所述第一私有密钥和针对发送的第一公开密钥而得到的第二公开密钥,计算出第一共享密钥。
本申请实施例还提供的一种应用于接收方的基于区块链的密钥生成方法,所述方法包括:
生成第二私有密钥,并基于所述第二私有密钥生成第二公开密钥;基于区块链将所述第二公开密钥作为区块链交易中的金额发送;基于所述第二私有密钥和接收到的第一公开密钥,计算出第二共享密钥。
需要说明的是,应用于发送方、接收方的基于区块链的密钥生成方法 的具体实现请参见前述的发送方和接收方之间交互的密钥生成方法的具体实现过程,重复之处不再赘述。
对应上述实施例提供的基于区块链的密钥生成方法,本申请实施例提供了一种基于区块链的密钥生成装置,参见图4所示,该装置包括:
第一生成单元401、第一发送单元402、第二生成单元403、第二发送单元404和计算单元405。
第一生成单元401,配置为在发送方向接收方发送业务数据前,发送方生成第一私有密钥,并基于所述第一私有密钥生成第一公开密钥。
作为一种可实现方式,第一生成单元401包括:
选取子单元和计算子单元。
所述选取子单元,配置为发送方随机选取素数,并在大于1且小于所述素数的区间内,随机选取数据作为第一私有密钥;
所述计算子单元,配置为基于公式A=g^a mod p计算得到第一公开密钥;其中,A为第一公开密钥;a为第一私有密钥;p为素数;g为生成元,所述生成元是所述素数的原根。
第一发送单元402,配置为基于区块链,发送方将所述第一公开密钥作为区块链交易中的金额发送给接收方;
第二生成单元403,配置为接收方生成第二私有密钥,并基于所述第二私有密钥生成第二公开密钥;
第二发送单元404,配置为基于区块链,接收方将所述第二公开密钥作为区块链交易中的金额发送给发送方;
计算单元405,配置为发送方基于所述第一私有密钥和所述第二公开密钥,计算出第一共享密钥;接收方基于所述第二私有密钥和所述第一公开密钥,计算出第二共享密钥。
在可选实施例中,所述装置还可以包括:
加密单元,配置为利用计算得到第一共享密钥或第二共享密钥对业务数据进行加密。
在可选实施例中,所述装置还可以包括:
解密单元,配置为利用计算得到的第一共享密钥或第二共享密钥对加密后的业务数据进行解密。
可以理解,所述装置中的第一生成单元401、第一发送单元402、第二生成单元403、第二发送单元404和计算单元405在实际应用中均可由该装置的中央处理器(CPU,Central Processing Unit)、数字信号处理器(DSP,Digital Signal Processor)、微控制单元(MCU,Microcontroller Unit)或可编程门阵列(FPGA,Field-Programmable Gate Array)实现。
本申请实施例提供了一种基于区块链的密钥生成装置,该装置应用于发送方。参见图5所示,该装置包括:生成单元501、发送单元502、计算单元503;其中,
生成单元501,配置为在发送方发送业务数据前,生成第一私有密钥,并基于所述第一私有密钥生成第一公开密钥;
发送单元502,配置为基于区块链,将所述第一公开密钥作为区块链交易中的金额发送;
计算单元503,配置为基于所述第一私有密钥和针对发送的第一公开密钥而得到的第二公开密钥,计算出第一共享密钥。
在可选实施例中,所述装置还可以包括:
加密单元,配置为利用计算得到第一共享密钥或第二共享密钥对业务数据进行加密。
在可选实施例中,所述装置还可以包括:
解密单元,配置为利用计算得到的第一共享密钥或第二共享密钥对加密后的业务数据进行解密。
本申请实施例提供了一种基于区块链的密钥生成装置,该装置应用于接收方。参见图6所示,该装置包括:生成单元601、发送单元602、计算单元603;其中,
生成单元601,配置为生成第二私有密钥,并基于所述第二私有密钥生成第二公开密钥;
发送单元602,配置为基于区块链,将所述第二公开密钥作为区块链交易中的金额发送;
计算单元603,配置为基于所述第二私有密钥和接收到的第一公开密钥,计算出第二共享密钥。
在可选实施例中,所述装置还可以包括:
加密单元,配置为利用计算得到第一共享密钥或第二共享密钥对业务数据进行加密。
在可选实施例中,所述装置还可以包括:
解密单元,配置为利用计算得到的第一共享密钥或第二共享密钥对加密后的业务数据进行解密。
可以理解,所述装置中的应用于发送方的生成单元501、发送单元502、计算单元503以及应用于接收方的生成单元601、发送单元602、计算单元603在实际应用中均可由该装置的CPU、DSP、MCU或FPGA实现。
需要说明的是,本申请实施例的基于区块链的密钥生成装置,由于该密钥生成装置解决问题的原理与前述的基于区块链的密钥生成方法相似,因此,密钥生成装置的实施过程及实施原理均可以参见前述基于区块链的密钥生成方法的实施过程及实施原理描述,重复之处不再赘述。
通过上述技术方案,本实施例中,在发送方向接收方发送业务数据前,发送方生成第一私有密钥,并基于所述第一私有密钥生成第一公开密钥;基于区块链,发送方将所述第一公开密钥作为区块链交易数据中的金额发 送给接收方;接收方生成第二私有密钥,并基于所述第二私有密钥生成第二公开密钥;基于区块链,接收方将所述第二公开密钥作为区块链交易数据中的金额发送给发送方;发送方基于所述第一私有密钥和所述第二公开密钥,计算出第一共享密钥;接收方基于所述第二私有密钥和所述第一公开密钥,计算出第二共享密钥。使得发送方与接收方之间传输业务数据时,可以利用第一共享密钥或第二共享密钥对业务数据加密,且由于仅在需要在发送方和接收方之间传输业务数据时,才生成第一共享密钥和第二共享密钥,缩短了密钥的存储时间,进而降低了密钥被破解的风险,提高了利用密钥加密数据的安全性。且,不会长时间的占用存储空间,提升了存储资源利用率,降低了存储成本。
本申请实施例还提供一种计算机可读存储介质,其上存储有计算机程序,其中,该程序被处理器执行时至少用于执行图1至图3任一所示基于区块链的密钥生成方法的步骤。所述计算机可读存储介质具体可以为存储器。所述存储器可以为如图7所示的存储器702。
本发明实施例还提供了一种基于区块链的密钥生成装置。图7为本发明实施例的基于区块链的密钥生成装置的硬件结构示意图。如图7所示,该装置包括:用于进行数据传输的通信组件703、至少一个处理器701和用于存储能够在处理器701上运行的计算机程序的存储器702。终端中的各个组件通过总线系统704耦合在一起。可理解,总线系统704用于实现这些组件之间的连接通信。总线系统704除包括数据总线之外,还包括电源总线、控制总线和状态信号总线。但是为了清楚说明起见,在图7中将各种总线都标为总线系统704。
其中,所述处理器701执行所述计算机程序时至少执行图1至图3任一所示方法的步骤。
可以理解,存储器702可以是易失性存储器或非易失性存储器,也可 包括易失性和非易失性存储器两者。其中,非易失性存储器可以是只读存储器(ROM,Read Only Memory)、可编程只读存储器(PROM,Programmable Read-Only Memory)、可擦除可编程只读存储器(EPROM,Erasable Programmable Read-Only Memory)、电可擦除可编程只读存储器(EEPROM,Electrically Erasable Programmable Read-Only Memory)、磁性随机存取存储器(FRAM,ferromagnetic random access memory)、快闪存储器(Flash Memory)、磁表面存储器、光盘、或只读光盘(CD-ROM,Compact Disc Read-Only Memory);磁表面存储器可以是磁盘存储器或磁带存储器。易失性存储器可以是随机存取存储器(RAM,Random Access Memory),其用作外部高速缓存。通过示例性但不是限制性说明,许多形式的RAM可用,例如静态随机存取存储器(SRAM,Static Random Access Memory)、同步静态随机存取存储器(SSRAM,Synchronous Static Random Access Memory)、动态随机存取存储器(DRAM,Dynamic Random Access Memory)、同步动态随机存取存储器(SDRAM,Synchronous Dynamic Random Access Memory)、双倍数据速率同步动态随机存取存储器(DDRSDRAM,Double Data Rate Synchronous Dynamic Random Access Memory)、增强型同步动态随机存取存储器(ESDRAM,Enhanced Synchronous Dynamic Random Access Memory)、同步连接动态随机存取存储器(SLDRAM,SyncLink Dynamic Random Access Memory)、直接内存总线随机存取存储器(DRRAM,Direct Rambus Random Access Memory)。本发明实施例描述的存储器702旨在包括但不限于这些和任意其它适合类型的存储器。
上述本发明实施例揭示的方法可以应用于处理器701中,或者由处理器701实现。处理器701可能是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法的各步骤可以通过处理器701中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器701可以是通用处理器、 DSP,或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。处理器701可以实现或者执行本发明实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者任何常规的处理器等。结合本发明实施例所公开的方法的步骤,可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于存储介质中,该存储介质位于存储器702,处理器701读取存储器702中的信息,结合其硬件完成前述方法的步骤。
在示例性实施例中,基于区块链的密钥生成装置可以被一个或多个应用专用集成电路(ASIC,Application Specific Integrated Circuit)、DSP、可编程逻辑器件(PLD,Programmable Logic Device)、复杂可编程逻辑器件(CPLD,Complex Programmable Logic Device)、FPGA、通用处理器、控制器、MCU、微处理器(Microprocessor)、或其他电子元件实现,用于执行前述的基于区块链的密钥生成方法。
对于前述的各方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本申请并不受所描述的动作顺序的限制,因为依据本申请,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作和模块并不一定是本申请所必须的。
需要说明的是,本说明书中的各个实施例均采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似的部分互相参见即可。对于装置类实施例而言,由于其与方法实施例基本相似,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。
最后,还需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定 要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。
对所公开的实施例的上述说明,使本领域技术人员能够实现或使用本申请。对这些实施例的多种修改对本领域技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本申请的精神或范围的情况下,在其它实施例中实现。因此,本申请将不会被限制于本文所示的这些实施例,而是要符合与本文所公开的原理和新颖特点相一致的最宽的范围。
以上所述仅是本申请的优选实施方式,应当指出,对于本技术领域的普通技术人员来说,在不脱离本申请原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也应视为本申请的保护范围。
本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用硬件实施例、软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器和光学存储器等)上实施的计算机程序产品的形式。
本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得 通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
以上所述,仅为本申请的较佳实施例而已,并非用于限定本发明申请的保护范围。
工业实用性
本申请实施例中,发送方基于生成的第一私有密钥而生成第一公开密钥;接收方基于生成的第二私有密钥而生成第二公开密钥;基于区块链,发送方、接收方将各自的公开密钥作为区块链交易数据中的金额发送给对方;发送方、接收方基于各自接收到的第一私有密钥和第二公开密钥,计算出各自的共享密钥(第一共享密钥、第二共享密钥),使得发送方与接收方之间传输业务数据时,可以利用第一共享密钥或第二共享密钥对业务数据加密。且由于仅在需要在发送方和接收方之间传输业务数据时,才生成第一共享密钥和第二共享密钥,与相关技术中的预先生成密钥的方案相比,缩短了密钥的存储时间,进而降低了密钥被破解的风险,提高了利用密钥 加密数据的安全性。且,不会长时间的占用存储空间,提升了存储资源利用率,降低了存储成本。

Claims (15)

  1. 一种基于区块链的密钥生成方法,包括:
    在发送方向接收方发送业务数据前,发送方生成第一私有密钥,并基于所述第一私有密钥生成第一公开密钥;
    基于区块链,发送方将所述第一公开密钥作为区块链交易中的金额发送给接收方;
    接收方生成第二私有密钥,并基于所述第二私有密钥生成第二公开密钥;
    基于区块链,接收方将所述第二公开密钥作为区块链交易中的金额发送给发送方;
    发送方基于所述第一私有密钥和所述第二公开密钥,计算出第一共享密钥;接收方基于所述第二私有密钥和所述第一公开密钥,计算出第二共享密钥。
  2. 根据权利要求1所述的方法,其中,所述发送方生成第一私有密钥,并基于所述第一私有密钥生成第一公开密钥,包括:
    发送方随机选取素数;
    在大于1且小于所述素数的区间内,随机选取数据作为第一私有密钥;
    基于公式A=g^a mod p计算得到第一公开密钥;其中,A为第一公开密钥;a为第一私有密钥;p为素数;g为生成元、是所述素数的原根;mod为求模操作;^为求幂操作。
  3. 根据权利要求2所述的方法,其中,所述基于区块链发送方将所述第一公开密钥作为区块链交易数据中的金额发送给接收方,包括:
    发送方对所述素数、所述生成元和所述第一公开密钥分别进行补零操作,得到补零后长度为8位的素数、生成元和第一公开密钥;
    发送方公开广播账本,从账本中选择一个该发送方未花费的交易输出 UTXO,并从所述UTXO中向接收方支付数值分别为8位长度的素数、8位长度的生成元和8位长度的第一公开密钥,单位均为聪的金额。
  4. 根据权利要求3所述的方法,其中,所述从所述UTXO中向接收方支付数值分别为8位长度的素数、8位长度的生成元和8位长度的第一公开密钥,单位均为聪的金额之后,所述方法还包括:
    发送方将向接收方支付的交易广播到区块链分布式系统中,使得完成交易确认后将该交易写入区块并通过区块加入到区块链中。
  5. 根据权利要求4所述的方法,其中,所述接收方生成第二私有密钥,并基于所述第二私有密钥生成第二公开密钥,包括:
    接收方获取到账本后,在大于1且小于所述素数的区间内,随机选取数据作为第二私有密钥;
    基于公式B=g^b mod p计算得到第二公开密钥;其中,B为第二公开密钥;b为第二私有密钥;p为素数;g为生成元、生成元是所述素数的原根。
  6. 根据权利要求5所述的方法,其中,所述发送方基于所述第一私有密钥和所述第二公开密钥,计算出第一共享密钥,包括:
    基于公式K1=B^a mod p计算第一共享密钥;其中,K1为第一共享密钥,B为第二公开密钥;a为第一私有密钥;p为素数;
    所述接收方基于所述第二私有密钥和所述第一公开密钥,计算出第二共享密钥包括:
    基于公式K2=A^b mod p计算第二共享密钥;其中,K2为第二共享密钥,A为第一公开密钥;b为第二私有密钥;p为素数。
  7. 根据权利要求1-6任一项所述的方法,其中,还包括:发送方利用所述第一共享密钥对所述业务数据进行加密。
  8. 一种基于区块链的密钥生成装置,包括:
    第一生成单元,配置为在发送方向接收方发送业务数据前,发送方生 成第一私有密钥,并基于所述第一私有密钥生成第一公开密钥;
    第一发送单元,配置为基于区块链,发送方将所述第一公开密钥作为区块链交易中的金额发送给接收方;
    第二生成单元,配置为接收方生成第二私有密钥,并基于所述第二私有密钥生成第二公开密钥;
    第二发送单元,配置为基于区块链,接收方将所述第二公开密钥作为区块链交易中的金额发送给发送方;
    计算单元,配置为发送方基于所述第一私有密钥和所述第二公开密钥,计算出第一共享密钥;接收方基于所述第二私有密钥和所述第一公开密钥,计算出第二共享密钥。
  9. 根据权利要求8所述的装置,其中,所述第一生成单元包括:
    选取子单元,配置为发送方随机选取素数,并在大于1且小于所述素数的区间内,随机选取数据作为第一私有密钥;
    计算子单元,配置为基于公式A=g^a mod p计算得到第一公开密钥;其中,A为第一公开密钥;a为第一私有密钥;p为素数;g为生成元、是所述素数的原根;mod为求模操作;^为求幂操作。
  10. 根据权利要求8或9任一项所述的装置,其中,所述装置还包括:加密单元,配置为利用计算得到第一共享密钥或第二共享密钥对业务数据进行加密。
  11. 一种基于区块链的密钥生成方法,应用于发送方,所述方法包括:
    在向接收方发送业务数据前,发送方生成第一私有密钥,并基于所述第一私有密钥生成第一公开密钥;
    基于区块链,将所述第一公开密钥作为区块链交易中的金额发送;
    基于所述第一私有密钥和针对发送的第一公开密钥而得到的第二公开密钥,计算出第一共享密钥。
  12. 一种基于区块链的密钥生成方法,应用于接收方,所述包括:
    接收方生成第二私有密钥,并基于所述第二私有密钥生成第二公开密钥;
    基于区块链,接收方将所述第二公开密钥作为区块链交易中的金额发送;
    接收方基于所述第二私有密钥和接收到的第一公开密钥,计算出第二共享密钥。
  13. 一种基于区块链的密钥生成装置,应用于发送方,该装置包括:
    生成单元,配置为在发送业务数据前,生成第一私有密钥,并基于所述第一私有密钥生成第一公开密钥;
    发送单元,配置为基于区块链将所述第一公开密钥作为区块链交易中的金额发送;
    计算单元,配置为基于所述第一私有密钥和针对发送的第一公开密钥而得到的第二公开密钥,计算出第一共享密钥。
  14. 一种基于区块链的密钥生成装置,应用于接收方,包括:
    生成单元,配置为生成第二私有密钥,并基于所述第二私有密钥生成第二公开密钥;
    发送单元,配置为基于区块链将所述第二公开密钥作为区块链交易中的金额发送;
    计算单元,配置为基于所述第二私有密钥和接收到的第一公开密钥,计算出第二共享密钥。
  15. 一种基于区块链的密钥生成装置,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述程序时实现权利要求1至7任一所述方法、权利要求11和/或权利要求12所述方法的步骤。
PCT/CN2019/112860 2019-10-08 2019-10-23 基于区块链的密钥生成方法、相关装置及计算机存储介质 WO2021068290A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910949286.0A CN110677246A (zh) 2019-10-08 2019-10-08 一种基于区块链的密钥生成方法及装置
CN201910949286.0 2019-10-08

Publications (1)

Publication Number Publication Date
WO2021068290A1 true WO2021068290A1 (zh) 2021-04-15

Family

ID=69080640

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/112860 WO2021068290A1 (zh) 2019-10-08 2019-10-23 基于区块链的密钥生成方法、相关装置及计算机存储介质

Country Status (2)

Country Link
CN (1) CN110677246A (zh)
WO (1) WO2021068290A1 (zh)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113114627B (zh) * 2021-03-19 2023-01-31 京东科技信息技术有限公司 一种基于密钥交换的安全数据交互方法以及交互系统
CN117254909B (zh) * 2023-11-13 2024-02-23 泉州信息工程学院 一种快速生成高概率原根的计算方法、系统及存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101272240A (zh) * 2007-03-21 2008-09-24 华为技术有限公司 一种会话密钥的生成方法、系统和通信设备
US20170324711A1 (en) * 2016-05-03 2017-11-09 The Real Mccoy, Llc Inc. Method for establishing, securing and transferring computer readable information using peer-to-peer public and private key cryptography
CN109102294A (zh) * 2018-08-24 2018-12-28 北京京东尚科信息技术有限公司 信息传输方法和装置
CN109691013A (zh) * 2018-08-16 2019-04-26 区链通网络有限公司 区块链节点间通信方法、装置及存储介质、区块链系统

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108491980A (zh) * 2018-04-04 2018-09-04 湘潭大学 基于云区块链服务平台的微电网智能节点交易决策方法
CN109087099A (zh) * 2018-07-31 2018-12-25 杭州复杂美科技有限公司 一种隐私交易方法及系统、设备和存储介质
CN109495249B (zh) * 2018-11-23 2021-09-14 全链通有限公司 一种区块链系统的数据存储方法、节点和区块链系统

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101272240A (zh) * 2007-03-21 2008-09-24 华为技术有限公司 一种会话密钥的生成方法、系统和通信设备
US20170324711A1 (en) * 2016-05-03 2017-11-09 The Real Mccoy, Llc Inc. Method for establishing, securing and transferring computer readable information using peer-to-peer public and private key cryptography
CN109691013A (zh) * 2018-08-16 2019-04-26 区链通网络有限公司 区块链节点间通信方法、装置及存储介质、区块链系统
CN109102294A (zh) * 2018-08-24 2018-12-28 北京京东尚科信息技术有限公司 信息传输方法和装置

Also Published As

Publication number Publication date
CN110677246A (zh) 2020-01-10

Similar Documents

Publication Publication Date Title
WO2020253234A1 (zh) 实现隐私保护的数据同态加解密方法及装置
TWI706275B (zh) 用於資訊保護的系統和方法
JP6908700B2 (ja) 情報保護のためのシステム及び方法
JP6714156B2 (ja) 情報保護のためのシステム及び方法
WO2021121090A1 (en) Property right confirmation and transfer methods and systems, electronic device, and storage medium
CN108418783B (zh) 一种保护区块链智能合约隐私的方法、介质
US10892888B2 (en) System and method for information protection
US10938549B2 (en) System and method for information protection
US10951394B2 (en) System and method for publication of private data using a blockchain network
WO2019209168A2 (zh) 数据处理方法、相关装置及区块链系统
CN109450640B (zh) 基于sm2的两方签名方法及系统
US20180034630A1 (en) Public-key encryption system
CN115580396B (zh) 匿踪查询系统及匿踪查询方法
CN113411345A (zh) 一种安全会话的方法和装置
CN115114658B (zh) 基于区块链的可验证数据交易方法、装置、设备及介质
US20140237252A1 (en) Techniques for validating data exchange
CN109272316A (zh) 一种基于区块链网络下的区块实现方法及系统
WO2021068290A1 (zh) 基于区块链的密钥生成方法、相关装置及计算机存储介质
CN111080296A (zh) 一种基于区块链系统的验证方法及装置
JP2956709B2 (ja) 公開鍵生成方法及び装置
JP2024534237A (ja) 共有暗号キーを生成すること
RU2417410C2 (ru) Способ хранения и использования криптографического ключа
CN117795901A (zh) 生成数字签名份额
CN112348674A (zh) 一种区块链的交易数据存储与获取方法及装置
CN111510299B (zh) 联合数字签名生成方法、电子设备和计算机可读介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19948773

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19948773

Country of ref document: EP

Kind code of ref document: A1