WO2019127265A1 - Blockchain smart contract-based data writing method, device and storage medium - Google Patents

Blockchain smart contract-based data writing method, device and storage medium Download PDF

Info

Publication number
WO2019127265A1
WO2019127265A1 PCT/CN2017/119559 CN2017119559W WO2019127265A1 WO 2019127265 A1 WO2019127265 A1 WO 2019127265A1 CN 2017119559 W CN2017119559 W CN 2017119559W WO 2019127265 A1 WO2019127265 A1 WO 2019127265A1
Authority
WO
WIPO (PCT)
Prior art keywords
blockchain account
blockchain
information
ciphertext
account
Prior art date
Application number
PCT/CN2017/119559
Other languages
French (fr)
Chinese (zh)
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 深圳前海达闼云端智能科技有限公司
Priority to PCT/CN2017/119559 priority Critical patent/WO2019127265A1/en
Priority to CN201780002394.6A priority patent/CN110100422B/en
Publication of WO2019127265A1 publication Critical patent/WO2019127265A1/en

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/40Network security protocols

Definitions

  • the present disclosure relates to the field of blockchain technology, and in particular, to a data writing method, device, and storage medium based on a blockchain smart contract.
  • Blockchain technology is a distributed, decentralized, trusted network data consensus storage technology based on a unique block generation mechanism and P2P (Point To Point (point-to-point) network communication mechanism realizes the synchronization problem of distributed computing.
  • P2P Point To Point (point-to-point) network communication mechanism
  • transaction information of any blockchain account is public, and any blockchain account can view the transaction information of other blockchain accounts.
  • transaction information for blockchain accounts may include private information (eg, user identity information), and traditional public blockchains do not adequately protect private information.
  • the main purpose of the present disclosure is to provide a data writing method, device and storage medium based on a blockchain smart contract for protecting private information of a blockchain account.
  • a first aspect of the present disclosure provides a data writing method based on a blockchain smart contract, including:
  • the information ciphertext of the first blockchain account and the secret key ciphertext of the first blockchain account are written into the blockchain of the first blockchain account through the smart contract.
  • a second aspect of the present disclosure provides a data writing apparatus based on a blockchain smart contract, including:
  • a first encryption module configured to encrypt information to be encrypted of the first blockchain account according to a symmetric key obtained in advance, to obtain an information ciphertext of the first blockchain account
  • a second encryption module configured to encrypt the symmetric key according to the public key of the first blockchain account, to obtain a secret key ciphertext of the first blockchain account
  • a writing module configured to write the information ciphertext of the first blockchain account and the secret key ciphertext of the first blockchain account into the block where the first blockchain account is located by using a smart contract In the chain.
  • a third aspect of the present disclosure provides a data writing apparatus based on a blockchain smart contract, including:
  • At least one processor unit a communication interface, a memory, and a communication bus; the at least one processor unit, the communication interface, and the memory complete communication with each other through the communication bus;
  • the memory is configured to store program code
  • the at least one processor unit is configured to execute the program code to implement the method of the first aspect.
  • a fourth aspect of the present disclosure provides a computer readable storage medium for storing a computer program, the computer program comprising instructions for performing the method of the first aspect.
  • the information ciphertext of the first blockchain account and the secret ciphertext of the first blockchain account are stored in the blockchain through the smart contract, and the first blockchain account can be decrypted only by the private key.
  • the secret key ciphertext, and then decrypt the information ciphertext of the first blockchain account, to obtain the information to be encrypted of the first blockchain account, and the private key of the first blockchain account is only known to the blockchain
  • the other blockchain accounts on the block are unknown, so other blockchain accounts on the blockchain cannot decrypt the secret ciphertext of the first blockchain account, and cannot further decrypt the information ciphertext of the first blockchain account. Unable to get the information to be encrypted of the first blockchain account. Therefore, the protection of the information to be encrypted of the first blockchain account is implemented by the above method.
  • FIG. 1 is a schematic flowchart diagram of a data writing method based on a blockchain smart contract according to an embodiment of the present disclosure.
  • FIG. 2 is a schematic flowchart of encryption in a data writing method based on a blockchain smart contract according to an embodiment of the present disclosure.
  • FIG. 3 is a schematic flowchart of decryption in a data writing method based on a blockchain smart contract according to an embodiment of the present disclosure.
  • FIG. 4 is another schematic flowchart of a data writing method based on a blockchain smart contract according to an embodiment of the present disclosure.
  • FIG. 5 is another schematic flowchart of a data writing method based on a blockchain smart contract according to an embodiment of the present disclosure.
  • FIG. 6 is a schematic structural diagram of a data writing apparatus based on a blockchain smart contract according to an embodiment of the present disclosure.
  • FIG. 7 is a schematic structural diagram of another data writing apparatus based on a blockchain smart contract according to an embodiment of the present disclosure.
  • FIG. 1 is a schematic flowchart of a data writing method based on a blockchain smart contract according to an embodiment of the present disclosure, as shown in FIG. The method includes the following steps:
  • Step S101 Encrypt the information to be encrypted of the first blockchain account according to the symmetric key obtained in advance, to obtain the information ciphertext of the first blockchain account;
  • Step S102 Encrypt the symmetric key according to the public key of the first blockchain account to obtain a secret key ciphertext of the first blockchain account;
  • Step S103 Write the information ciphertext of the first blockchain account and the secret key ciphertext of the first blockchain account into the blockchain of the first blockchain account through the smart contract.
  • the first blockchain account may be any blockchain account in the blockchain in which it is located.
  • the information to be encrypted of the first blockchain account includes, but is not limited to, private information of the first blockchain account itself (eg, user identity information) or public information of the first blockchain account itself.
  • the first blockchain account performs the data writing method based on the blockchain smart contract provided by the embodiment of the present disclosure, and the private information of the first blockchain account itself or the public information of the first blockchain account itself Protect.
  • the first blockchain account directly writes it into the blockchain where the first blockchain account is located, so as to speed up data processing. Speed, improve data processing efficiency.
  • the method further includes:
  • the received information to be encrypted is determined as the information to be encrypted of the first blockchain account.
  • the information to be encrypted of the first blockchain account may be provided by any terminal, device or system outside the blockchain.
  • the information to be encrypted is information that needs to be encrypted sent from a terminal device outside the blockchain where the first blockchain account is located.
  • the information that needs to be encrypted is sent to the first blockchain account, and the region based on the embodiment of the present disclosure is executed by the first blockchain account.
  • the data writing method of the blockchain smart contract is to protect the information that the terminal device needs to encrypt.
  • the obtaining manner of the symmetric key obtained in advance in step S101 includes but is not limited to the following two implementation manners:
  • the first implementation manner before each encrypting the information to be encrypted of the first blockchain account, randomly generating the symmetric key, and acquiring the randomly generated symmetric key.
  • the second implementation manner before encrypting the information to be encrypted of the first blockchain account for the first time, randomly generating the symmetric key, and acquiring the first randomly generated symmetric key.
  • the first blockchain account randomly generates a symmetric key before encrypting the encrypted information, and performs the steps S101-S102 by using the randomly generated symmetric key. Since the rules for generating the symmetric key each time are randomly generated, the symmetric key generated by the first blockchain account is different each time, and thus the first blockchain account performs the symmetry used in steps S101-S102 each time.
  • the secret key is different.
  • the first blockchain account randomly generates a symmetric key, and the first randomly generated symmetric key is used to perform steps S101-S102. After the first symmetric generation of the symmetric key, the first blockchain account uses the first randomly generated symmetric key each time steps S101-S102 are performed.
  • the first blockchain account randomly generates a symmetric key before encrypting the encrypted information for the first time, it is not necessary to randomly generate a symmetric key again, and the first randomly generated symmetric key is fixed as the first
  • a blockchain account performs the symmetric key used in steps S101-S102, and thus, the first blockchain account is identical in that the symmetric key used in steps S101-S102 is executed each time.
  • FIG. 2 is a schematic flowchart of encryption in a data writing method based on a blockchain smart contract according to an embodiment of the present disclosure.
  • the first blockchain account encrypts the information to be encrypted of the first blockchain account according to the symmetric key obtained in advance, and obtains the information ciphertext of the first blockchain account;
  • the first blockchain account encrypts the pre-acquired symmetric key according to the public key of the first blockchain account, and obtains the secret key ciphertext of the first blockchain account.
  • the information ciphertext of the first blockchain account and the key ciphertext of the first blockchain account constitute a "digital envelope", and thus, the first blockchain account completes the information to be encrypted in the form of a "digital envelope” And encryption of pre-acquired symmetric keys.
  • step S103 is executed, the information ciphertext of the first blockchain account obtained in step S101 is executed, and the first blockchain account obtained in step S102 is executed.
  • the secret key ciphertext is written into the blockchain where the first blockchain account is located through the smart contract.
  • the information in the blockchain is the ciphertext of the first blockchain account and the secret ciphertext of the first blockchain account
  • only the secret key of the first blockchain account can be decrypted by the private key, and then Decrypting the information ciphertext of the first blockchain account to obtain the information to be encrypted of the first blockchain account
  • the private key of the first blockchain account is only known to itself and to other blockchain accounts on the blockchain It is unknowable, so other blockchain accounts on the blockchain cannot decrypt the secret ciphertext of the first blockchain account, and cannot further decrypt the information ciphertext of the first blockchain account, and cannot obtain the first blockchain.
  • the information to be encrypted of the account Therefore, the protection of the information to be encrypted of the first blockchain account is implemented by the above method.
  • the method further includes:
  • the information to be encrypted is included in the information ciphertext of the first blockchain account, and is stored in the blockchain where the first blockchain account is located. If the information to be encrypted needs to be obtained, firstly, the information ciphertext of the first blockchain account and the secret ciphertext of the first blockchain account are read from the blockchain where the first blockchain account is located. Examples of reading include, but are not limited to, the following embodiments:
  • step S103 After performing step S103, first establishing a mapping relationship between the blockchain account of the first blockchain account and the secret ciphertext of the first blockchain account and the secret ciphertext of the first blockchain account ( That is, the first mapping relationship), so as to query the information of the first blockchain account from the blockchain where the first blockchain account is located through the first mapping relationship and the blockchain account of the first blockchain account.
  • the secret key of the ciphertext and the first blockchain account is ciphered and read.
  • FIG. 3 is a schematic flowchart of decryption in a data writing method based on a blockchain smart contract according to an embodiment of the present disclosure.
  • the above embodiment is applicable to the case where the information to be encrypted is only disclosed to the first blockchain account, and the other blockchain accounts except the first blockchain account are kept secret.
  • the information to be encrypted is disclosed to the first blockchain account and the second blockchain account, and other areas than the first blockchain account and the second blockchain account are The blockchain account is confidential, wherein the number of second blockchain accounts is one or more.
  • the information to be encrypted of the first blockchain account is public information of the second blockchain account, and the first blockchain account and the second blockchain account belong to the same blockchain;
  • FIG. 4 is another schematic flowchart of a data writing method based on a blockchain smart contract according to an embodiment of the present disclosure. As shown in FIG. 4, the method further includes: steps S101-S103 including:
  • Step S104 Encrypt the symmetric key according to the public key of the second blockchain account to obtain a secret key ciphertext of the second blockchain account;
  • Step S105 Write the information ciphertext of the first blockchain account and the secret key ciphertext of the second blockchain account into the blockchain through a smart contract.
  • step S105 the method further includes:
  • steps S104-S105 are similar to steps S102-S103.
  • steps S101-S102 and step S104 are performed.
  • the first blockchain account encrypts the information to be encrypted of the first blockchain account according to the pre-acquired symmetric key to obtain the information ciphertext of the first blockchain account; on the other hand, the first block
  • the chain account encrypts the pre-acquired symmetric key according to the public key of the first blockchain account to obtain the secret key ciphertext of the first blockchain account, and the first blockchain account is based on the second blockchain account.
  • the public key encrypts the pre-acquired symmetric key to obtain the secret key ciphertext of the second blockchain account.
  • the information ciphertext of the first blockchain account and the key ciphertext of the first blockchain account constitute a "digital envelope", the information ciphertext of the first blockchain account and the key of the second blockchain account The ciphertext constitutes another "digital envelope", and thus, the first blockchain account completes the encryption of the encrypted information and the pre-acquired symmetric key in the form of two "digital envelopes".
  • step S103 and step S105 are performed.
  • the process of performing the step S105 in the first blockchain account is: performing the information ciphertext of the first blockchain account obtained in step S101, and executing the secret key of the second blockchain account obtained in step S104.
  • the texts are all written into the blockchain where the first blockchain account and the second blockchain account are co-located through the smart contract. Since the block ciphertext is stored in the blockchain and the secret ciphertext of the second blockchain account is stored, the second blockchain account can only be decrypted by the private key of the second blockchain account.
  • the secret key ciphertext, or the secret key of the first blockchain account can be decrypted by the private key of the first blockchain account, thereby decrypting the information ciphertext of the first blockchain account, and obtaining the first block
  • the information to be encrypted of the chain account, and the private key of the first blockchain account and the private key of the second blockchain account are only known to oneself and are unknown to other blockchain accounts on the blockchain, so the block
  • the other blockchain accounts on the chain cannot decrypt the secret key ciphertext of the first blockchain account and the secret key ciphertext of the second blockchain account, and cannot further decrypt the information ciphertext of the first blockchain account, and cannot
  • the information to be encrypted of the first blockchain account is obtained. Therefore, only the protection of the information to be encrypted is realized by the above method.
  • steps S101-S102 are performed.
  • the first blockchain account encrypts the information to be encrypted of the first blockchain account according to the symmetric key obtained in advance, and obtains the information ciphertext of the first blockchain account;
  • the first blockchain account encrypts the pre-acquired symmetric key according to the public key of the first blockchain account, and obtains the secret key ciphertext of the first blockchain account.
  • the information ciphertext and the key ciphertext actually constitute a "digital envelope", and thus, the first blockchain account completes the encryption of the encrypted information and the pre-acquired symmetric key in the form of "digital envelope".
  • step S103 is executed, the information ciphertext of the first blockchain account obtained in step S101 is executed, and the first blockchain account obtained in step S102 is executed.
  • the secret key ciphertext is written into the blockchain where the first blockchain account is located through the smart contract. Since the block cipher and the secret ciphertext are stored in the blockchain, only the private key of the first blockchain account can decrypt the secret ciphertext, thereby decrypting the ciphertext and obtaining the information to be encrypted, and the first zone
  • the private key of the blockchain account is only known to itself and is unknown to other blockchain accounts on the blockchain.
  • FIG. 5 is another schematic flowchart of a data writing method based on a blockchain smart contract according to an embodiment of the present disclosure. The following is a description of the data writing method based on the blockchain smart contract provided by the embodiment of the present disclosure.
  • the personnel commissioner When the personnel commissioner enters the employee information of an employee, the personal information of the employee's name, ID card, email address, salary, etc., is only allowed to be viewed by the personnel commissioner and the employee himself, and the other personnel are kept confidential; Public information such as travel reimbursement, allowing all employees to view. Therefore, when entering the above private information, the computer used by the personnel commissioner (as the first blockchain account) randomly generates a symmetric key, encrypts the aforementioned private information to form a message ciphertext; and then uses the first blockchain account. The public key and the public key of the computer used by the employee (as the second blockchain account) encrypt the aforementioned symmetric key to form two key ciphertexts.
  • the information ciphertext and the two key ciphertexts are then written into the blockchain in which the first blockchain account and the second blockchain account are co-located through the smart contract.
  • the blockchain For the aforementioned public information, it is directly written into the blockchain.
  • 5 shows an example of a secret key ciphertext, which forms a digital envelope, and the digital envelope is stored in the blockchain through a smart contract.
  • the employee's private information is only passed through the employee's private key (ie, the private key of the second blockchain account) or the personnel commissioner's private key (ie, the private key of the first blockchain account).
  • the employee's private key ie, the private key of the second blockchain account
  • the personnel commissioner's private key ie, the private key of the first blockchain account.
  • FIG. 6 is a schematic structural diagram of a data writing apparatus based on a blockchain smart contract according to an embodiment of the present disclosure.
  • the block chain smart contract based data writing device 600 includes:
  • the first encryption module 601 is configured to encrypt information to be encrypted of the first blockchain account according to a symmetric key obtained in advance, to obtain an information ciphertext of the first blockchain account;
  • the second encryption module 602 is configured to encrypt the symmetric key according to the public key of the first blockchain account to obtain a secret key ciphertext of the first blockchain account;
  • a first writing module 603 configured to write the information ciphertext of the first blockchain account and the secret key ciphertext of the first blockchain account into the first blockchain account by using a smart contract In the blockchain.
  • the device further includes:
  • a first establishing module configured to establish, by the blockchain account of the first blockchain account, an information ciphertext of the first blockchain account and a secret ciphertext of the first blockchain account First mapping relationship between;
  • a first reading module configured to read, according to the first mapping relationship, the information of the first blockchain account from the blockchain according to the blockchain account of the first blockchain account Ciphertext and secret key ciphertext of the first blockchain account;
  • a first decryption module configured to decrypt a secret key ciphertext of the first blockchain account according to a private key of the first blockchain account, to obtain the symmetric key
  • a second decrypting module configured to decrypt the information ciphertext of the first blockchain account according to the symmetric key to obtain information to be encrypted of the first blockchain account.
  • the information to be encrypted of the first blockchain account is public information of a second blockchain account, and the first blockchain account and the second blockchain account belong to the same blockchain.
  • the device also includes:
  • a third encryption module configured to encrypt the symmetric key according to the public key of the second blockchain account, to obtain a secret key ciphertext of the second blockchain account;
  • a second writing module configured to write the information ciphertext of the first blockchain account and the secret key ciphertext of the second blockchain account into the blockchain through a smart contract.
  • the device further includes:
  • a second establishing module configured to establish, by the blockchain account of the second blockchain account, an information ciphertext of the first blockchain account and a secret ciphertext of the second blockchain account a second mapping relationship between;
  • a second reading module configured to read, according to the block mapping account of the second blockchain account, the first blockchain account from the blockchain in the location based on the second mapping relationship Information ciphertext and secret key ciphertext of the second blockchain account;
  • a third decryption module configured to decrypt the secret key ciphertext of the second blockchain account according to the private key of the second blockchain account, to obtain the symmetric key
  • a fourth decryption module configured to decrypt the information ciphertext of the first blockchain account according to the symmetric key to obtain information to be encrypted of the first blockchain account.
  • the device further includes:
  • a first acquiring module configured to randomly generate the symmetric key before acquiring the information to be encrypted of the first blockchain account, and obtain the symmetric key generated by the randomization;
  • a second acquiring module configured to randomly generate the symmetric key before encrypting the information to be encrypted of the first blockchain account for the first time, and obtain a symmetric key generated randomly for the first time.
  • the device further includes:
  • a receiving module configured to receive information to be encrypted sent by the terminal device outside the blockchain
  • a determining module configured to determine the received information to be encrypted as the information to be encrypted of the first blockchain account.
  • the division performed by the block generating device component module is only one logical function division, and may be further divided when actually implemented.
  • the physical implementation of each module may also be in various manners, which is not limited in this disclosure.
  • FIG. 7 is a structure of another data writing device based on a blockchain smart contract according to an embodiment of the present disclosure.
  • At least one processor unit (such as processor unit 111 shown in FIG. 7), communication interface 112, memory 113, and communication bus 114; said at least one processor unit, said communication interface 112, and said memory 113 Communication bus 114 completes communication with each other;
  • the memory 113 is configured to store program code, and the at least one processor unit is configured to execute the program code to implement a blockchain smart contract based data writing method provided by an embodiment of the present disclosure, with specific reference to the above method. Description of the embodiments.
  • the embodiment of the present disclosure further provides a non-transitory computer readable storage medium including instructions, such as the above-described memory 113, which may be executed by a processor of the device 110 to complete the blockchain smart contract based on the embodiments of the present disclosure.
  • Data writing method can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device.

Abstract

A blockchain smart contract-based data writing method, a device and a storage medium, which are used to protect private information of a blockchain account. The method comprises: encrypting information to be encrypted of a first blockchain account according to a pre-acquired symmetric key to obtain an information ciphertext of the first blockchain account; encrypting the symmetric key according to a public key of the first blockchain account to obtain a secret key ciphertext of the first blockchain account; by means of a smart contract, writing the information ciphertext of the first blockchain account and the secret key ciphertext of the first blockchain account into a blockchain in which the first block chain account is located.

Description

基于区块链智能合约的数据写入方法、装置及存储介质Data writing method, device and storage medium based on blockchain intelligent contract 技术领域Technical field
本公开涉及区块链技术领域,尤其涉及一种基于区块链智能合约的数据写入方法、装置及存储介质。The present disclosure relates to the field of blockchain technology, and in particular, to a data writing method, device, and storage medium based on a blockchain smart contract.
背景技术Background technique
区块链技术是一种分布式、去中心、去信任的网络数据共识存储技术,其基于独特的区块(Block)生成机制和P2P(Point to Point,点对点)网络通信机制实现了分布式计算的同步性问题。Blockchain technology is a distributed, decentralized, trusted network data consensus storage technology based on a unique block generation mechanism and P2P (Point To Point (point-to-point) network communication mechanism realizes the synchronization problem of distributed computing.
对传统的公有区块链而言,任一区块链账户的交易信息都是公开的,且任一区块链账户都可以查看其他区块链账户的交易信息。然而,区块链账户的交易信息可能包括隐私信息(例如:用户身份信息),传统的公有区块链无法较好地保护隐私信息。For the traditional public blockchain, the transaction information of any blockchain account is public, and any blockchain account can view the transaction information of other blockchain accounts. However, transaction information for blockchain accounts may include private information (eg, user identity information), and traditional public blockchains do not adequately protect private information.
发明内容Summary of the invention
本公开的主要目的是提供一种基于区块链智能合约的数据写入方法、装置及存储介质,用以保护区块链账户的隐私信息。The main purpose of the present disclosure is to provide a data writing method, device and storage medium based on a blockchain smart contract for protecting private information of a blockchain account.
为了实现上述目的,本公开第一方面提供一种基于区块链智能合约的数据写入方法,包括:In order to achieve the above object, a first aspect of the present disclosure provides a data writing method based on a blockchain smart contract, including:
根据预先获取的对称秘钥对所述第一区块链账户的待加密信息进行加密,得到所述第一区块链账户的信息密文;Encrypting information to be encrypted of the first blockchain account according to a symmetric key obtained in advance, to obtain an information ciphertext of the first blockchain account;
根据所述第一区块链账户的公钥对所述对称秘钥进行加密,得到所述第一区块链账户的秘钥密文;Encrypting the symmetric key according to the public key of the first blockchain account to obtain a secret key ciphertext of the first blockchain account;
将所述第一区块链账户的信息密文和所述第一区块链账户的秘钥密文通过智能合约写入所述第一区块链账户所在的区块链中。The information ciphertext of the first blockchain account and the secret key ciphertext of the first blockchain account are written into the blockchain of the first blockchain account through the smart contract.
本公开第二方面提供一种基于区块链智能合约的数据写入装置,包括:A second aspect of the present disclosure provides a data writing apparatus based on a blockchain smart contract, including:
第一加密模块,用于根据预先获取的对称秘钥对所述第一区块链账户的待加密信息进行加密,得到所述第一区块链账户的信息密文;a first encryption module, configured to encrypt information to be encrypted of the first blockchain account according to a symmetric key obtained in advance, to obtain an information ciphertext of the first blockchain account;
第二加密模块,用于根据所述第一区块链账户的公钥对所述对称秘钥进行加密,得到所述第一区块链账户的秘钥密文;a second encryption module, configured to encrypt the symmetric key according to the public key of the first blockchain account, to obtain a secret key ciphertext of the first blockchain account;
写入模块,用于将所述第一区块链账户的信息密文和所述第一区块链账户的秘钥密文通过智能合约写入所述第一区块链账户所在的区块链中。a writing module, configured to write the information ciphertext of the first blockchain account and the secret key ciphertext of the first blockchain account into the block where the first blockchain account is located by using a smart contract In the chain.
本公开第三方面提供一种基于区块链智能合约的数据写入装置,包括:A third aspect of the present disclosure provides a data writing apparatus based on a blockchain smart contract, including:
至少一个处理器单元、通信接口、存储器和通信总线;所述至少一个处理器单元、所述通信接口和所述存储器通过所述通信总线完成相互间的通信;At least one processor unit, a communication interface, a memory, and a communication bus; the at least one processor unit, the communication interface, and the memory complete communication with each other through the communication bus;
所述存储器被配置为存储程序代码;The memory is configured to store program code;
所述至少一个处理器单元被配置为运行所述程序代码以实现第一方面所述的方法。The at least one processor unit is configured to execute the program code to implement the method of the first aspect.
本公开第四方面提供一种计算机可读存储介质,所述计算机可读存储介质用于存储计算机程序,所述计算机程序包括用于执行第一方面所述的方法的指令。A fourth aspect of the present disclosure provides a computer readable storage medium for storing a computer program, the computer program comprising instructions for performing the method of the first aspect.
采用上述技术方案,将第一区块链账户的信息密文和第一区块链账户的秘钥密文通过智能合约存入区块链中,只有通过私钥才能解密第一区块链账户的秘钥密文,进而解密第一区块链账户的信息密文,得到第一区块链账户的待加密信息,而第一区块链账户的私钥仅对自己可知而对区块链上的其他区块链账户不可知,所以区块链上的其他区块链账户无法解密第一区块链账户的秘钥密文,也无法进一步解密第一区块链账户的信息密文,无法得到第一区块链账户的待加密信息。因而,采用上述方法实现了对第一区块链账户的待加密信息的保护。Using the above technical solution, the information ciphertext of the first blockchain account and the secret ciphertext of the first blockchain account are stored in the blockchain through the smart contract, and the first blockchain account can be decrypted only by the private key. The secret key ciphertext, and then decrypt the information ciphertext of the first blockchain account, to obtain the information to be encrypted of the first blockchain account, and the private key of the first blockchain account is only known to the blockchain The other blockchain accounts on the block are unknown, so other blockchain accounts on the blockchain cannot decrypt the secret ciphertext of the first blockchain account, and cannot further decrypt the information ciphertext of the first blockchain account. Unable to get the information to be encrypted of the first blockchain account. Therefore, the protection of the information to be encrypted of the first blockchain account is implemented by the above method.
附图说明DRAWINGS
为了更清楚地说明本公开实施例或现有技术中的技术方案,下面将对实施例描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本公开的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the drawings used in the description of the embodiments will be briefly described below. It is obvious that the drawings in the following description are the disclosure of the present disclosure. For some embodiments, other drawings may be obtained from those of ordinary skill in the art without departing from the drawings.
图1为本公开实施例提供的一种基于区块链智能合约的数据写入方法的流程示意图。FIG. 1 is a schematic flowchart diagram of a data writing method based on a blockchain smart contract according to an embodiment of the present disclosure.
图2为本公开实施例提供的一种基于区块链智能合约的数据写入方法中加密的流程示意图。FIG. 2 is a schematic flowchart of encryption in a data writing method based on a blockchain smart contract according to an embodiment of the present disclosure.
图3为本公开实施例提供的一种基于区块链智能合约的数据写入方法中解密的流程示意图。FIG. 3 is a schematic flowchart of decryption in a data writing method based on a blockchain smart contract according to an embodiment of the present disclosure.
图4为本公开实施例提供的一种基于区块链智能合约的数据写入方法的另一流程示意图。FIG. 4 is another schematic flowchart of a data writing method based on a blockchain smart contract according to an embodiment of the present disclosure.
图5为本公开实施例提供的一种基于区块链智能合约的数据写入方法的另一流程示意图。FIG. 5 is another schematic flowchart of a data writing method based on a blockchain smart contract according to an embodiment of the present disclosure.
图6为本公开实施例提供的一种基于区块链智能合约的数据写入装置的结构示意图。FIG. 6 is a schematic structural diagram of a data writing apparatus based on a blockchain smart contract according to an embodiment of the present disclosure.
图7为本公开实施例提供的另一种基于区块链智能合约的数据写入装置的结构示意图。FIG. 7 is a schematic structural diagram of another data writing apparatus based on a blockchain smart contract according to an embodiment of the present disclosure.
具体实施方式Detailed ways
为使本公开实施例的目的、技术方案和优点更加清楚,下面将结合本公开实施例中的附图,对本公开实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本公开一部分实施例,而不是全部的实施例。基于本公开中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本公开保护的范围。The technical solutions in the embodiments of the present disclosure will be clearly and completely described in conjunction with the drawings in the embodiments of the present disclosure. It is a partial embodiment of the present disclosure, and not all of the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present disclosure without departing from the inventive scope are the scope of the disclosure.
本公开实施例提供一种基于区块链智能合约的数据写入方法,图1为本公开实施例提供的一种基于区块链智能合约的数据写入方法的流程示意图,如图1所示,该方法包括以下步骤:The embodiment of the present disclosure provides a data writing method based on a blockchain smart contract. FIG. 1 is a schematic flowchart of a data writing method based on a blockchain smart contract according to an embodiment of the present disclosure, as shown in FIG. The method includes the following steps:
步骤S101:根据预先获取的对称秘钥对所述第一区块链账户的待加密信息进行加密,得到所述第一区块链账户的信息密文;Step S101: Encrypt the information to be encrypted of the first blockchain account according to the symmetric key obtained in advance, to obtain the information ciphertext of the first blockchain account;
步骤S102:根据所述第一区块链账户的公钥对所述对称秘钥进行加密,得到所述第一区块链账户的秘钥密文;Step S102: Encrypt the symmetric key according to the public key of the first blockchain account to obtain a secret key ciphertext of the first blockchain account;
步骤S103:将所述第一区块链账户的信息密文和所述第一区块链账户的秘钥密文通过智能合约写入所述第一区块链账户所在的区块链中。Step S103: Write the information ciphertext of the first blockchain account and the secret key ciphertext of the first blockchain account into the blockchain of the first blockchain account through the smart contract.
其中,第一区块链账户可以是其所在的区块链中的任一区块链账户。第一区块链账户的待加密信息包括但不限于:第一区块链账户本身的隐私信息(例如:用户身份信息)或第一区块链账户本身的公开信息。相应地,第一区块链账户执行本公开实施例提供的基于区块链智能合约的数据写入方法,对第一区块链账户本身的隐私信息或第一区块链账户本身的公开信息进行保护。可选地,针对第一区块链账户本身的公开信息,由于是公开信息,所以第一区块链账户直接将其写入第一区块链账户所在的区块链中,以加快数据处理速度,提高数据处理效率。The first blockchain account may be any blockchain account in the blockchain in which it is located. The information to be encrypted of the first blockchain account includes, but is not limited to, private information of the first blockchain account itself (eg, user identity information) or public information of the first blockchain account itself. Correspondingly, the first blockchain account performs the data writing method based on the blockchain smart contract provided by the embodiment of the present disclosure, and the private information of the first blockchain account itself or the public information of the first blockchain account itself Protect. Optionally, for the public information of the first blockchain account itself, since it is public information, the first blockchain account directly writes it into the blockchain where the first blockchain account is located, so as to speed up data processing. Speed, improve data processing efficiency.
可选地,在步骤S101之前,所述方法还包括:Optionally, before the step S101, the method further includes:
接收所述区块链外的终端设备发送的待加密信息;Receiving information to be encrypted sent by the terminal device outside the blockchain;
将所接收到的待加密信息确定为所述第一区块链账户的待加密信息。The received information to be encrypted is determined as the information to be encrypted of the first blockchain account.
第一区块链账户的待加密信息可以是区块链外任意终端、设备或系统等提供的。示例地,待加密信息是来自于第一区块链账户所在的区块链外的终端设备发送的需要加密的信息。对于第一区块链账户所在的区块链外的终端设备而言,将其需要加密的信息发送给第一区块链账户,由第一区块链账户执行本公开实施例提供的基于区块链智能合约的数据写入方法,以保护该终端设备需要加密的信息。The information to be encrypted of the first blockchain account may be provided by any terminal, device or system outside the blockchain. For example, the information to be encrypted is information that needs to be encrypted sent from a terminal device outside the blockchain where the first blockchain account is located. For the terminal device outside the blockchain where the first blockchain account is located, the information that needs to be encrypted is sent to the first blockchain account, and the region based on the embodiment of the present disclosure is executed by the first blockchain account. The data writing method of the blockchain smart contract is to protect the information that the terminal device needs to encrypt.
其中,步骤S101中预先获取的对称秘钥的获取方式包括但不限于以下两种实施方式:The obtaining manner of the symmetric key obtained in advance in step S101 includes but is not limited to the following two implementation manners:
第一种实施方式:在每次对所述第一区块链账户的待加密信息进行加密之前,随机生成所述对称秘钥,并获取本次随机生成的对称秘钥。The first implementation manner: before each encrypting the information to be encrypted of the first blockchain account, randomly generating the symmetric key, and acquiring the randomly generated symmetric key.
第二种实施方式:在第一次对所述第一区块链账户的待加密信息进行加密之前,随机生成所述对称秘钥,并获取第一次随机生成的对称秘钥。The second implementation manner: before encrypting the information to be encrypted of the first blockchain account for the first time, randomly generating the symmetric key, and acquiring the first randomly generated symmetric key.
采用第一种实施方式,在每次对待加密信息进行加密之前,第一区块链账户随机生成对称秘钥,并利用本次随机生成的对称秘钥,执行步骤S101- S102。由于每次生成对称秘钥的规则都是随机生成,所以第一区块链账户每次随机生成的对称秘钥不同,因而,第一区块链账户每次执行步骤S101-S102所使用的对称秘钥不同。In the first implementation manner, the first blockchain account randomly generates a symmetric key before encrypting the encrypted information, and performs the steps S101-S102 by using the randomly generated symmetric key. Since the rules for generating the symmetric key each time are randomly generated, the symmetric key generated by the first blockchain account is different each time, and thus the first blockchain account performs the symmetry used in steps S101-S102 each time. The secret key is different.
采用第二种实施方式,在第一次对待加密信息进行加密之前,第一区块链账户随机生成对称秘钥,并利用第一次随机生成的对称秘钥,执行步骤S101- S102。在第一次随机生成对称秘钥之后,第一区块链账户以后每次执行步骤S101-S102都使用第一次随机生成的对称秘钥。也就是说,只要第一区块链账户在第一次对待加密信息进行加密之前随机生成对称秘钥,此后都无需再次随机生成对称秘钥,该第一次随机生成的对称秘钥固定为第一区块链账户执行步骤S101-S102所使用的对称秘钥,因而,第一区块链账户每次执行步骤S101-S102所使用的对称秘钥相同。In the second implementation manner, before the encryption of the encrypted information is performed for the first time, the first blockchain account randomly generates a symmetric key, and the first randomly generated symmetric key is used to perform steps S101-S102. After the first symmetric generation of the symmetric key, the first blockchain account uses the first randomly generated symmetric key each time steps S101-S102 are performed. That is to say, as long as the first blockchain account randomly generates a symmetric key before encrypting the encrypted information for the first time, it is not necessary to randomly generate a symmetric key again, and the first randomly generated symmetric key is fixed as the first A blockchain account performs the symmetric key used in steps S101-S102, and thus, the first blockchain account is identical in that the symmetric key used in steps S101-S102 is executed each time.
在第一区块链账户预先获取对称秘钥之后,执行步骤S101-S102。图2为本公开实施例提供的一种基于区块链智能合约的数据写入方法中加密的流程示意图。如图2所示,一方面,第一区块链账户根据预先获取的对称秘钥对第一区块链账户的待加密信息进行加密,得到第一区块链账户的信息密文;另一方面,第一区块链账户根据第一区块链账户的公钥对预先获取的对称秘钥进行加密,得到第一区块链账户的秘钥密文。第一区块链账户的信息密文和第一区块链账户的密钥密文组成了“数字信封”,因而,第一区块链账户以一个“数字信封”的形式完成了对待加密信息和预先获取的对称密钥的加密。After the first blockchain account acquires the symmetric key in advance, steps S101-S102 are performed. FIG. 2 is a schematic flowchart of encryption in a data writing method based on a blockchain smart contract according to an embodiment of the present disclosure. As shown in FIG. 2, on the one hand, the first blockchain account encrypts the information to be encrypted of the first blockchain account according to the symmetric key obtained in advance, and obtains the information ciphertext of the first blockchain account; In the aspect, the first blockchain account encrypts the pre-acquired symmetric key according to the public key of the first blockchain account, and obtains the secret key ciphertext of the first blockchain account. The information ciphertext of the first blockchain account and the key ciphertext of the first blockchain account constitute a "digital envelope", and thus, the first blockchain account completes the information to be encrypted in the form of a "digital envelope" And encryption of pre-acquired symmetric keys.
在第一区块链账户执行完步骤S101-S102之后,执行步骤S103,将执行步骤S101所得到的第一区块链账户的信息密文,以及执行步骤S102所得到的第一区块链账户的秘钥密文,均通过智能合约写入第一区块链账户所在的区块链中。由于区块链中存储的是第一区块链账户的信息密文和第一区块链账户的秘钥密文,只有通过私钥才能解密第一区块链账户的秘钥密文,进而解密第一区块链账户的信息密文,得到第一区块链账户的待加密信息,而第一区块链账户的私钥仅对自己可知而对区块链上的其他区块链账户不可知,所以区块链上的其他区块链账户无法解密第一区块链账户的秘钥密文,也无法进一步解密第一区块链账户的信息密文,无法得到第一区块链账户的待加密信息。因而,采用上述方法实现了对第一区块链账户的待加密信息的保护。After the step S101-S102 is performed in the first blockchain account, step S103 is executed, the information ciphertext of the first blockchain account obtained in step S101 is executed, and the first blockchain account obtained in step S102 is executed. The secret key ciphertext is written into the blockchain where the first blockchain account is located through the smart contract. Since the information in the blockchain is the ciphertext of the first blockchain account and the secret ciphertext of the first blockchain account, only the secret key of the first blockchain account can be decrypted by the private key, and then Decrypting the information ciphertext of the first blockchain account to obtain the information to be encrypted of the first blockchain account, and the private key of the first blockchain account is only known to itself and to other blockchain accounts on the blockchain It is unknowable, so other blockchain accounts on the blockchain cannot decrypt the secret ciphertext of the first blockchain account, and cannot further decrypt the information ciphertext of the first blockchain account, and cannot obtain the first blockchain. The information to be encrypted of the account. Therefore, the protection of the information to be encrypted of the first blockchain account is implemented by the above method.
可选地,在步骤S103之后,所述方法还包括:Optionally, after step S103, the method further includes:
建立所述第一区块链账户的区块链账户分别与所述第一区块链账户的信息密文和所述第一区块链账户的秘钥密文之间的第一映射关系;Establishing a first mapping relationship between the blockchain account of the first blockchain account and the secret ciphertext of the first blockchain account and the secret key ciphertext of the first blockchain account;
根据所述第一区块链账户的区块链账户,基于所述第一映射关系,从所述区块链中读取所述第一区块链账户的信息密文和所述第一区块链账户的秘钥密文;Reading, according to the blockchain account of the first blockchain account, the information ciphertext of the first blockchain account and the first zone from the blockchain based on the first mapping relationship The secret key ciphertext of the blockchain account;
根据所述第一区块链账户的私钥对所述第一区块链账户的秘钥密文进行解密,得到所述对称秘钥;Decrypting the secret key ciphertext of the first blockchain account according to the private key of the first blockchain account to obtain the symmetric key;
根据所述对称秘钥对所述第一区块链账户的信息密文进行解密,得到所述第一区块链账户的待加密信息。Decrypting the information ciphertext of the first blockchain account according to the symmetric key to obtain information to be encrypted of the first blockchain account.
在第一区块链账户执行完步骤S103之后,待加密信息被包含在第一区块链账户的信息密文中,且被存储在第一区块链账户所在的区块链上。如果需要获得待加密信息,首先需要从第一区块链账户所在的区块链上读取第一区块链账户的信息密文和第一区块链账户的秘钥密文。读取的实施方式包括但不限于以下实施方式:After the step S103 is performed in the first blockchain account, the information to be encrypted is included in the information ciphertext of the first blockchain account, and is stored in the blockchain where the first blockchain account is located. If the information to be encrypted needs to be obtained, firstly, the information ciphertext of the first blockchain account and the secret ciphertext of the first blockchain account are read from the blockchain where the first blockchain account is located. Examples of reading include, but are not limited to, the following embodiments:
在执行完步骤S103之后,首先建立第一区块链账户的区块链账户分别与第一区块链账户的信息密文和第一区块链账户的秘钥密文之间的映射关系(即第一映射关系),以便于通过第一映射关系以及第一区块链账户的区块链账户,从第一区块链账户所在的区块链上查询到第一区块链账户的信息密文和第一区块链账户的秘钥密文,并读取出来。After performing step S103, first establishing a mapping relationship between the blockchain account of the first blockchain account and the secret ciphertext of the first blockchain account and the secret ciphertext of the first blockchain account ( That is, the first mapping relationship), so as to query the information of the first blockchain account from the blockchain where the first blockchain account is located through the first mapping relationship and the blockchain account of the first blockchain account. The secret key of the ciphertext and the first blockchain account is ciphered and read.
图3为本公开实施例提供的一种基于区块链智能合约的数据写入方法中解密的流程示意图。在读取出第一区块链账户的信息密文和第一区块链账户的秘钥密文之后,如图3所示,首先第一区块链账户利用自己的私钥对读取出的密钥密文进行解密,取得对称密钥,然后利用该对称密钥对读取出的信息密文进行解密,进而获得待加密信息。FIG. 3 is a schematic flowchart of decryption in a data writing method based on a blockchain smart contract according to an embodiment of the present disclosure. After reading the information ciphertext of the first blockchain account and the secret key ciphertext of the first blockchain account, as shown in FIG. 3, first, the first blockchain account is read out by using its own private key pair. The key ciphertext is decrypted to obtain a symmetric key, and then the read ciphertext is decrypted by using the symmetric key, thereby obtaining information to be encrypted.
以上实施例适用于待加密信息仅对第一区块链账户公开,对除第一区块链账户之外的其他区块链账户保密的情况。The above embodiment is applicable to the case where the information to be encrypted is only disclosed to the first blockchain account, and the other blockchain accounts except the first blockchain account are kept secret.
可选地,在另一实施例中,待加密信息对第一区块链账户和第二区块链账户公开,对除第一区块链账户和第二区块链账户之外的其他区块链账户保密,其中,第二区块链账户的数量为一个或多个。相应地,所述第一区块链账户的待加密信息是第二区块链账户的公开信息,所述第一区块链账户和所述第二区块链账户属于同一个区块链;图4为本公开实施例提供的一种基于区块链智能合约的数据写入方法的另一流程示意图。如图4所示,所述方法除包括步骤S101-S103还包括:Optionally, in another embodiment, the information to be encrypted is disclosed to the first blockchain account and the second blockchain account, and other areas than the first blockchain account and the second blockchain account are The blockchain account is confidential, wherein the number of second blockchain accounts is one or more. Correspondingly, the information to be encrypted of the first blockchain account is public information of the second blockchain account, and the first blockchain account and the second blockchain account belong to the same blockchain; FIG. 4 is another schematic flowchart of a data writing method based on a blockchain smart contract according to an embodiment of the present disclosure. As shown in FIG. 4, the method further includes: steps S101-S103 including:
步骤S104:根据所述第二区块链账户的公钥对所述对称秘钥进行加密,得到所述第二区块链账户的秘钥密文;Step S104: Encrypt the symmetric key according to the public key of the second blockchain account to obtain a secret key ciphertext of the second blockchain account;
步骤S105:将所述第一区块链账户的信息密文和所述第二区块链账户的秘钥密文通过智能合约写入所述区块链中。Step S105: Write the information ciphertext of the first blockchain account and the secret key ciphertext of the second blockchain account into the blockchain through a smart contract.
可选地,在步骤S105之后,所述方法还包括:Optionally, after step S105, the method further includes:
建立所述第二区块链账户的区块链账户分别与所述第一区块链账户的信息密文和所述第二区块链账户的秘钥密文之间的第二映射关系;Establishing a second mapping relationship between the blockchain account of the second blockchain account and the secret ciphertext of the first blockchain account and the secret ciphertext of the second blockchain account;
根据所述第二区块链账户的区块链账户,基于所述第二映射关系,从所述所在的区块链中读取所述第一区块链账户的信息密文和所述第二区块链账户的秘钥密文;And reading, according to the block mapping account of the second blockchain account, the information ciphertext of the first blockchain account and the first block from the blockchain in the location according to the second mapping relationship The secret key ciphertext of the second blockchain account;
根据所述第二区块链账户的私钥对所述第二区块链账户的秘钥密文进行解密,得到所述对称秘钥;Decrypting the secret key ciphertext of the second blockchain account according to the private key of the second blockchain account to obtain the symmetric key;
根据所述对称秘钥对所述第一区块链账户的信息密文进行解密,得到所述第一区块链账户的待加密信息。Decrypting the information ciphertext of the first blockchain account according to the symmetric key to obtain information to be encrypted of the first blockchain account.
其中,步骤S104-S105与步骤S102-S103类似。在第一区块链账户预先获取对称秘钥之后,执行步骤S101-S102以及步骤S104。一方面,第一区块链账户根据预先获取的对称秘钥对第一区块链账户的待加密信息进行加密,得到第一区块链账户的信息密文;另一方面,第一区块链账户根据第一区块链账户的公钥对预先获取的对称秘钥进行加密,得到第一区块链账户的秘钥密文,并且,第一区块链账户根据第二区块链账户的公钥对预先获取的对称秘钥进行加密,得到第二区块链账户的秘钥密文。第一区块链账户的信息密文和第一区块链账户的密钥密文组成了一个“数字信封”,第一区块链账户的信息密文和第二区块链账户的密钥密文组成了另一个“数字信封”,因而,第一区块链账户以两个“数字信封”的形式完成了对待加密信息和预先获取的对称密钥的加密。Among them, steps S104-S105 are similar to steps S102-S103. After the first blockchain account acquires the symmetric key in advance, steps S101-S102 and step S104 are performed. On one hand, the first blockchain account encrypts the information to be encrypted of the first blockchain account according to the pre-acquired symmetric key to obtain the information ciphertext of the first blockchain account; on the other hand, the first block The chain account encrypts the pre-acquired symmetric key according to the public key of the first blockchain account to obtain the secret key ciphertext of the first blockchain account, and the first blockchain account is based on the second blockchain account. The public key encrypts the pre-acquired symmetric key to obtain the secret key ciphertext of the second blockchain account. The information ciphertext of the first blockchain account and the key ciphertext of the first blockchain account constitute a "digital envelope", the information ciphertext of the first blockchain account and the key of the second blockchain account The ciphertext constitutes another "digital envelope", and thus, the first blockchain account completes the encryption of the encrypted information and the pre-acquired symmetric key in the form of two "digital envelopes".
在第一区块链账户执行完步骤S101-S102以及步骤S104之后,执行步骤S103以及步骤S105。其中,第一区块链账户执行步骤S105的过程是:将执行步骤S101所得到的第一区块链账户的信息密文,以及执行步骤S104所得到的第二区块链账户的秘钥密文,均通过智能合约写入第一区块链账户和第二区块链账户共同所在的区块链中。由于区块链中存储的是第一区块链账户的信息密文和第二区块链账户的秘钥密文,只有通过第二区块链账户的私钥才能解密第二区块链账户的秘钥密文,或者,通过第一区块链账户的私钥才能解密第一区块链账户的秘钥密文,进而解密第一区块链账户的信息密文,得到第一区块链账户的待加密信息,而第一区块链账户的私钥以及第二区块链账户的私钥分别仅对自己可知而对区块链上的其他区块链账户不可知,所以区块链上的其他区块链账户无法解密第一区块链账户的秘钥密文以及第二区块链账户的秘钥密文,也无法进一步解密第一区块链账户的信息密文,无法得到第一区块链账户的待加密信息。因而,采用上述方法仅有实现了对待加密信息的保护。After the steps S101-S102 and step S104 are performed in the first blockchain account, step S103 and step S105 are performed. The process of performing the step S105 in the first blockchain account is: performing the information ciphertext of the first blockchain account obtained in step S101, and executing the secret key of the second blockchain account obtained in step S104. The texts are all written into the blockchain where the first blockchain account and the second blockchain account are co-located through the smart contract. Since the block ciphertext is stored in the blockchain and the secret ciphertext of the second blockchain account is stored, the second blockchain account can only be decrypted by the private key of the second blockchain account. The secret key ciphertext, or the secret key of the first blockchain account can be decrypted by the private key of the first blockchain account, thereby decrypting the information ciphertext of the first blockchain account, and obtaining the first block The information to be encrypted of the chain account, and the private key of the first blockchain account and the private key of the second blockchain account are only known to oneself and are unknown to other blockchain accounts on the blockchain, so the block The other blockchain accounts on the chain cannot decrypt the secret key ciphertext of the first blockchain account and the secret key ciphertext of the second blockchain account, and cannot further decrypt the information ciphertext of the first blockchain account, and cannot The information to be encrypted of the first blockchain account is obtained. Therefore, only the protection of the information to be encrypted is realized by the above method.
在第一区块链账户预先获取对称秘钥之后,执行步骤S101-S102。如图2所示,一方面,第一区块链账户根据预先获取的对称秘钥对第一区块链账户的待加密信息进行加密,得到第一区块链账户的信息密文;另一方面,第一区块链账户根据第一区块链账户的公钥对预先获取的对称秘钥进行加密,得到第一区块链账户的秘钥密文。信息密文和密钥密文实际上组成了“数字信封”,因而,第一区块链账户以“数字信封”的形式完成了对待加密信息和预先获取的对称密钥的加密。After the first blockchain account acquires the symmetric key in advance, steps S101-S102 are performed. As shown in FIG. 2, on the one hand, the first blockchain account encrypts the information to be encrypted of the first blockchain account according to the symmetric key obtained in advance, and obtains the information ciphertext of the first blockchain account; In the aspect, the first blockchain account encrypts the pre-acquired symmetric key according to the public key of the first blockchain account, and obtains the secret key ciphertext of the first blockchain account. The information ciphertext and the key ciphertext actually constitute a "digital envelope", and thus, the first blockchain account completes the encryption of the encrypted information and the pre-acquired symmetric key in the form of "digital envelope".
在第一区块链账户执行完步骤S101-S102之后,执行步骤S103,将执行步骤S101所得到的第一区块链账户的信息密文,以及执行步骤S102所得到的第一区块链账户的秘钥密文,均通过智能合约写入第一区块链账户所在的区块链中。由于区块链中存储的是信息密文和秘钥密文,只有通过第一区块链账户的私钥才能解密秘钥密文,进而解密信息密文,得到待加密信息,而第一区块链账户的私钥仅对自己可知而对区块链上的其他区块链账户不可知,所以区块链上的其他区块链账户无法解密秘钥密文,也无法进一步解密信息密文,无法得到待加密信息。因而,采用上述方法实现了待加密信息仅对针对第一区块链账户和第二区块链账户公开。After the step S101-S102 is performed in the first blockchain account, step S103 is executed, the information ciphertext of the first blockchain account obtained in step S101 is executed, and the first blockchain account obtained in step S102 is executed. The secret key ciphertext is written into the blockchain where the first blockchain account is located through the smart contract. Since the block cipher and the secret ciphertext are stored in the blockchain, only the private key of the first blockchain account can decrypt the secret ciphertext, thereby decrypting the ciphertext and obtaining the information to be encrypted, and the first zone The private key of the blockchain account is only known to itself and is unknown to other blockchain accounts on the blockchain. Therefore, other blockchain accounts on the blockchain cannot decrypt the secret key ciphertext, and cannot further decrypt the information ciphertext. , can not get the information to be encrypted. Thus, the above method is implemented to realize that the information to be encrypted is only disclosed for the first blockchain account and the second blockchain account.
图5为本公开实施例提供的一种基于区块链智能合约的数据写入方法的另一流程示意图。下面以公司人事专员管理员工信息为例,结合图5,说明本公开实施例提供的基于区块链智能合约的数据写入方法。FIG. 5 is another schematic flowchart of a data writing method based on a blockchain smart contract according to an embodiment of the present disclosure. The following is a description of the data writing method based on the blockchain smart contract provided by the embodiment of the present disclosure.
在人事专员录入某一员工的员工信息时,对于员工的姓名、身份证、邮箱、工资等隐私信息,只允许人事专员和该员工自己查看,对其他人员保密;而对于员工的评奖评优、出差报销等公开信息,允许所有员工查看。因此在录入上述隐私信息时,人事专员使用的电脑(作为第一区块链账户)随机产生一个对称密钥,将前述隐私信息加密形成信息密文;然后,使用该第一区块链账户的公钥和该员工使用的电脑(作为第二区块链账户)的公钥,分别对前述对称密钥加密,形成两个密钥密文。然后通过智能合约将信息密文和两个密钥密文写入第一区块链账户和第二区块链账户共同所在的区块链中。而对于前述公开信息,直接写入该区块链中。其中,图5以示出一个秘钥密文为例,该秘钥密文和信息密文组成了数字信封,将数字信封通过智能合约存入该区块链中。When the personnel commissioner enters the employee information of an employee, the personal information of the employee's name, ID card, email address, salary, etc., is only allowed to be viewed by the personnel commissioner and the employee himself, and the other personnel are kept confidential; Public information such as travel reimbursement, allowing all employees to view. Therefore, when entering the above private information, the computer used by the personnel commissioner (as the first blockchain account) randomly generates a symmetric key, encrypts the aforementioned private information to form a message ciphertext; and then uses the first blockchain account. The public key and the public key of the computer used by the employee (as the second blockchain account) encrypt the aforementioned symmetric key to form two key ciphertexts. The information ciphertext and the two key ciphertexts are then written into the blockchain in which the first blockchain account and the second blockchain account are co-located through the smart contract. For the aforementioned public information, it is directly written into the blockchain. 5 shows an example of a secret key ciphertext, which forms a digital envelope, and the digital envelope is stored in the blockchain through a smart contract.
按照上述方式完成信息录入之后,该员工的隐私信息,只有通过该员工的私钥(即第二区块链账户的私钥)或人事专员的私钥(即第一区块链账户的私钥)才能解密相应的秘钥密文,进而解密信息密文,查看该员工的隐私信息,其他员工由于不知道该员工的私钥或人事专员的私钥,所以无法查看该员工的隐私信息。After the information is entered in the above manner, the employee's private information is only passed through the employee's private key (ie, the private key of the second blockchain account) or the personnel commissioner's private key (ie, the private key of the first blockchain account). In order to decrypt the corresponding secret key ciphertext, and then decrypt the information ciphertext, to view the employee's private information, other employees cannot view the employee's private information because they do not know the employee's private key or the personnel commissioner's private key.
基于同一发明构思,本公开实施例还提供一种基于区块链智能合约的数据写入装置,用于执行本公开实施例提供的上述基于区块链智能合约的数据写入方法。图6为本公开实施例提供的一种基于区块链智能合约的数据写入装置的结构示意图。如图6所示,该基于区块链智能合约的数据写入装置600包括:Based on the same inventive concept, the embodiment of the present disclosure further provides a data writing device based on a blockchain smart contract, which is used to execute the above-described block chain smart contract-based data writing method provided by the embodiment of the present disclosure. FIG. 6 is a schematic structural diagram of a data writing apparatus based on a blockchain smart contract according to an embodiment of the present disclosure. As shown in FIG. 6, the block chain smart contract based data writing device 600 includes:
第一加密模块601,用于根据预先获取的对称秘钥对所述第一区块链账户的待加密信息进行加密,得到所述第一区块链账户的信息密文;The first encryption module 601 is configured to encrypt information to be encrypted of the first blockchain account according to a symmetric key obtained in advance, to obtain an information ciphertext of the first blockchain account;
第二加密模块602,用于根据所述第一区块链账户的公钥对所述对称秘钥进行加密,得到所述第一区块链账户的秘钥密文;The second encryption module 602 is configured to encrypt the symmetric key according to the public key of the first blockchain account to obtain a secret key ciphertext of the first blockchain account;
第一写入模块603,用于将所述第一区块链账户的信息密文和所述第一区块链账户的秘钥密文通过智能合约写入所述第一区块链账户所在的区块链中。a first writing module 603, configured to write the information ciphertext of the first blockchain account and the secret key ciphertext of the first blockchain account into the first blockchain account by using a smart contract In the blockchain.
可选地,所述装置还包括:Optionally, the device further includes:
第一建立模块,用于建立所述第一区块链账户的区块链账户分别与所述第一区块链账户的信息密文和所述第一区块链账户的秘钥密文之间的第一映射关系;a first establishing module, configured to establish, by the blockchain account of the first blockchain account, an information ciphertext of the first blockchain account and a secret ciphertext of the first blockchain account First mapping relationship between;
第一读取模块,用于根据所述第一区块链账户的区块链账户,基于所述第一映射关系,从所述区块链中读取所述第一区块链账户的信息密文和所述第一区块链账户的秘钥密文;a first reading module, configured to read, according to the first mapping relationship, the information of the first blockchain account from the blockchain according to the blockchain account of the first blockchain account Ciphertext and secret key ciphertext of the first blockchain account;
第一解密模块,用于根据所述第一区块链账户的私钥对所述第一区块链账户的秘钥密文进行解密,得到所述对称秘钥;a first decryption module, configured to decrypt a secret key ciphertext of the first blockchain account according to a private key of the first blockchain account, to obtain the symmetric key;
第二解密模块,用于根据所述对称秘钥对所述第一区块链账户的信息密文进行解密,得到所述第一区块链账户的待加密信息。And a second decrypting module, configured to decrypt the information ciphertext of the first blockchain account according to the symmetric key to obtain information to be encrypted of the first blockchain account.
可选地,所述第一区块链账户的待加密信息是第二区块链账户的公开信息,所述第一区块链账户和所述第二区块链账户属于同一个区块链;所述装置还包括:Optionally, the information to be encrypted of the first blockchain account is public information of a second blockchain account, and the first blockchain account and the second blockchain account belong to the same blockchain. The device also includes:
第三加密模块,用于根据所述第二区块链账户的公钥对所述对称秘钥进行加密,得到所述第二区块链账户的秘钥密文;a third encryption module, configured to encrypt the symmetric key according to the public key of the second blockchain account, to obtain a secret key ciphertext of the second blockchain account;
第二写入模块,用于将所述第一区块链账户的信息密文和所述第二区块链账户的秘钥密文通过智能合约写入所述区块链中。And a second writing module, configured to write the information ciphertext of the first blockchain account and the secret key ciphertext of the second blockchain account into the blockchain through a smart contract.
可选地,所述装置还包括:Optionally, the device further includes:
第二建立模块,用于建立所述第二区块链账户的区块链账户分别与所述第一区块链账户的信息密文和所述第二区块链账户的秘钥密文之间的第二映射关系;a second establishing module, configured to establish, by the blockchain account of the second blockchain account, an information ciphertext of the first blockchain account and a secret ciphertext of the second blockchain account a second mapping relationship between;
第二读取模块,用于根据所述第二区块链账户的区块链账户,基于所述第二映射关系,从所述所在的区块链中读取所述第一区块链账户的信息密文和所述第二区块链账户的秘钥密文;a second reading module, configured to read, according to the block mapping account of the second blockchain account, the first blockchain account from the blockchain in the location based on the second mapping relationship Information ciphertext and secret key ciphertext of the second blockchain account;
第三解密模块,用于根据所述第二区块链账户的私钥对所述第二区块链账户的秘钥密文进行解密,得到所述对称秘钥;a third decryption module, configured to decrypt the secret key ciphertext of the second blockchain account according to the private key of the second blockchain account, to obtain the symmetric key;
第四解密模块,用于根据所述对称秘钥对所述第一区块链账户的信息密文进行解密,得到所述第一区块链账户的待加密信息。And a fourth decryption module, configured to decrypt the information ciphertext of the first blockchain account according to the symmetric key to obtain information to be encrypted of the first blockchain account.
可选地,所述装置还包括:Optionally, the device further includes:
第一获取模块,用于在每次对所述第一区块链账户的待加密信息进行加密之前,随机生成所述对称秘钥,并获取本次随机生成的对称秘钥;或a first acquiring module, configured to randomly generate the symmetric key before acquiring the information to be encrypted of the first blockchain account, and obtain the symmetric key generated by the randomization; or
第二获取模块,用于在第一次对所述第一区块链账户的待加密信息进行加密之前,随机生成所述对称秘钥,并获取第一次随机生成的对称秘钥。And a second acquiring module, configured to randomly generate the symmetric key before encrypting the information to be encrypted of the first blockchain account for the first time, and obtain a symmetric key generated randomly for the first time.
可选地,所述装置还包括:Optionally, the device further includes:
接收模块,用于接收所述区块链外的终端设备发送的待加密信息;a receiving module, configured to receive information to be encrypted sent by the terminal device outside the blockchain;
确定模块,用于将所接收到的待加密信息确定为所述第一区块链账户的待加密信息。And a determining module, configured to determine the received information to be encrypted as the information to be encrypted of the first blockchain account.
所属本领域的技术人员应该清楚地了解到,为描述的方便和简洁,上述描述的区块生成装置的各模块的具体工作过程,可以参考前述方法实施例中对应的过程,此处不再赘述。It should be clearly understood by those skilled in the art that, for the convenience and brevity of the description, the specific working process of each module of the above-mentioned block generating device may refer to the corresponding process in the foregoing method embodiment, and details are not described herein again. .
另外,上述对区块生成装置组成模块进行的划分,仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。并且,各个模块的物理实现也可以有多种方式,本公开对此不做限定。In addition, the division performed by the block generating device component module is only one logical function division, and may be further divided when actually implemented. Moreover, the physical implementation of each module may also be in various manners, which is not limited in this disclosure.
基于同一发明构思,本公开实施例还提供一种基于区块链智能合约的数据写入装置,图7为本公开实施例提供的另一种基于区块链智能合约的数据写入装置的结构示意图。如图7所示,该基于区块链智能合约的数据写入装置110包括:Based on the same inventive concept, the embodiment of the present disclosure further provides a data writing device based on a blockchain smart contract, and FIG. 7 is a structure of another data writing device based on a blockchain smart contract according to an embodiment of the present disclosure. schematic diagram. As shown in FIG. 7, the block chain smart contract based data writing device 110 includes:
至少一个处理器单元(如图7示出的处理器单元111)、通信接口112、存储器113和通信总线114;所述至少一个处理器单元、所述通信接口112和所述存储器113通过所述通信总线114完成相互间的通信;At least one processor unit (such as processor unit 111 shown in FIG. 7), communication interface 112, memory 113, and communication bus 114; said at least one processor unit, said communication interface 112, and said memory 113 Communication bus 114 completes communication with each other;
所述存储器113被配置为存储程序代码,所述至少一个处理器单元被配置为运行所述程序代码以实现本公开实施例提供的基于区块链智能合约的数据写入方法,具体参照上述方法实施例的描述。The memory 113 is configured to store program code, and the at least one processor unit is configured to execute the program code to implement a blockchain smart contract based data writing method provided by an embodiment of the present disclosure, with specific reference to the above method. Description of the embodiments.
本公开实施例还提供了一种包括指令的非临时性计算机可读存储介质,例如上述存储器113,上述指令可由装置110的处理器执行以完成本公开实施例提供的基于区块链智能合约的数据写入方法。例如,非临时性计算机可读存储介质可以是ROM、随机存取存储器(RAM)、CD-ROM、磁带、软盘和光数据存储设备等。The embodiment of the present disclosure further provides a non-transitory computer readable storage medium including instructions, such as the above-described memory 113, which may be executed by a processor of the device 110 to complete the blockchain smart contract based on the embodiments of the present disclosure. Data writing method. For example, the non-transitory computer readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device.
以上结合附图详细描述了本公开的优选实施方式,但是,本公开并不限于上述实施方式中的具体细节,在本公开的技术构思范围内,可以对本公开的技术方案进行多种简单变型,这些简单变型均属于本公开的保护范围。The preferred embodiments of the present disclosure have been described in detail above with reference to the accompanying drawings. However, the present disclosure is not limited to the specific details of the above embodiments, and various simple modifications can be made to the technical solutions of the present disclosure within the scope of the technical idea of the present disclosure. These simple variations are all within the scope of the disclosure.
另外需要说明的是,在上述具体实施方式中所描述的各个具体技术特征,在不矛盾的情况下,可以通过任何合适的方式进行组合。为了避免不必要的重复,本公开对各种可能的组合方式不再另行说明。It should be further noted that the specific technical features described in the above specific embodiments may be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present disclosure will not be further described in various possible combinations.
此外,本公开的各种不同的实施方式之间也可以进行任意组合,只要其不违背本公开的思想,其同样应当视为本公开所公开的内容。In addition, any combination of various embodiments of the present disclosure may be made as long as it does not deviate from the idea of the present disclosure, and should also be regarded as the disclosure of the present disclosure.

Claims (14)

  1. 一种基于区块链智能合约的数据写入方法,其特征在于,包括:A data writing method based on a blockchain smart contract, characterized in that it comprises:
    根据预先获取的对称秘钥对所述第一区块链账户的待加密信息进行加密,得到所述第一区块链账户的信息密文;Encrypting information to be encrypted of the first blockchain account according to a symmetric key obtained in advance, to obtain an information ciphertext of the first blockchain account;
    根据所述第一区块链账户的公钥对所述对称秘钥进行加密,得到所述第一区块链账户的秘钥密文;Encrypting the symmetric key according to the public key of the first blockchain account to obtain a secret key ciphertext of the first blockchain account;
    将所述第一区块链账户的信息密文和所述第一区块链账户的秘钥密文通过智能合约写入所述第一区块链账户所在的区块链中。The information ciphertext of the first blockchain account and the secret key ciphertext of the first blockchain account are written into the blockchain of the first blockchain account through the smart contract.
  2. 根据权利要求1所述的方法,其特征在于,在将所述第一区块链账户的信息密文和所述第一区块链账户的秘钥密文通过智能合约写入所述第一区块链账户所在的区块链中之后,所述方法还包括:The method according to claim 1, wherein the information ciphertext of the first blockchain account and the secret key ciphertext of the first blockchain account are written into the first by a smart contract After the blockchain account is in the blockchain, the method further includes:
    建立所述第一区块链账户的区块链账户分别与所述第一区块链账户的信息密文和所述第一区块链账户的秘钥密文之间的第一映射关系;Establishing a first mapping relationship between the blockchain account of the first blockchain account and the secret ciphertext of the first blockchain account and the secret key ciphertext of the first blockchain account;
    根据所述第一区块链账户的区块链账户,基于所述第一映射关系,从所述区块链中读取所述第一区块链账户的信息密文和所述第一区块链账户的秘钥密文;Reading, according to the blockchain account of the first blockchain account, the information ciphertext of the first blockchain account and the first zone from the blockchain based on the first mapping relationship The secret key ciphertext of the blockchain account;
    根据所述第一区块链账户的私钥对所述第一区块链账户的秘钥密文进行解密,得到所述对称秘钥;Decrypting the secret key ciphertext of the first blockchain account according to the private key of the first blockchain account to obtain the symmetric key;
    根据所述对称秘钥对所述第一区块链账户的信息密文进行解密,得到所述第一区块链账户的待加密信息。Decrypting the information ciphertext of the first blockchain account according to the symmetric key to obtain information to be encrypted of the first blockchain account.
  3. 根据权利要求1所述的方法,其特征在于,所述第一区块链账户的待加密信息是第二区块链账户的公开信息,所述第一区块链账户和所述第二区块链账户属于同一个区块链;所述方法还包括:The method according to claim 1, wherein the information to be encrypted of the first blockchain account is public information of a second blockchain account, the first blockchain account and the second zone Blockchain accounts belong to the same blockchain; the method also includes:
    根据所述第二区块链账户的公钥对所述对称秘钥进行加密,得到所述第二区块链账户的秘钥密文;Encrypting the symmetric key according to the public key of the second blockchain account to obtain a secret key ciphertext of the second blockchain account;
    将所述第一区块链账户的信息密文和所述第二区块链账户的秘钥密文通过智能合约写入所述区块链中。The information ciphertext of the first blockchain account and the secret key ciphertext of the second blockchain account are written into the blockchain through a smart contract.
  4. 根据权利要求3所述的方法,其特征在于,在将所述第一区块链账户的信息密文和所述第二区块链账户的秘钥密文通过智能合约写入所述区块链中之后,所述方法还包括:The method according to claim 3, wherein the information ciphertext of the first blockchain account and the secret key ciphertext of the second blockchain account are written into the block by smart contract After the chain, the method further includes:
    建立所述第二区块链账户的区块链账户分别与所述第一区块链账户的信息密文和所述第二区块链账户的秘钥密文之间的第二映射关系;Establishing a second mapping relationship between the blockchain account of the second blockchain account and the secret ciphertext of the first blockchain account and the secret ciphertext of the second blockchain account;
    根据所述第二区块链账户的区块链账户,基于所述第二映射关系,从所述所在的区块链中读取所述第一区块链账户的信息密文和所述第二区块链账户的秘钥密文;And reading, according to the block mapping account of the second blockchain account, the information ciphertext of the first blockchain account and the first block from the blockchain in the location according to the second mapping relationship The secret key ciphertext of the second blockchain account;
    根据所述第二区块链账户的私钥对所述第二区块链账户的秘钥密文进行解密,得到所述对称秘钥;Decrypting the secret key ciphertext of the second blockchain account according to the private key of the second blockchain account to obtain the symmetric key;
    根据所述对称秘钥对所述第一区块链账户的信息密文进行解密,得到所述第一区块链账户的待加密信息。Decrypting the information ciphertext of the first blockchain account according to the symmetric key to obtain information to be encrypted of the first blockchain account.
  5. 根据权利要求1所述的方法,其特征在于,在根据预先获取的对称秘钥对所述第一区块链账户的待加密信息进行加密之前,所述方法还包括:The method according to claim 1, wherein before the encrypting the information to be encrypted of the first blockchain account according to the pre-acquired symmetric key, the method further comprises:
    在每次对所述第一区块链账户的待加密信息进行加密之前,随机生成所述对称秘钥,并获取本次随机生成的对称秘钥;或Before the information to be encrypted of the first blockchain account is encrypted, the symmetric key is randomly generated, and the symmetric key generated randomly is acquired; or
    在第一次对所述第一区块链账户的待加密信息进行加密之前,随机生成所述对称秘钥,并获取第一次随机生成的对称秘钥。Before encrypting the information to be encrypted of the first blockchain account for the first time, the symmetric key is randomly generated, and the first randomly generated symmetric key is obtained.
  6. 根据权利要求1所述的方法,其特征在于,在根据预先获取的对称秘钥对所述第一区块链账户的待加密信息进行加密之前,所述方法还包括:The method according to claim 1, wherein before the encrypting the information to be encrypted of the first blockchain account according to the pre-acquired symmetric key, the method further comprises:
    接收所述区块链外的终端设备发送的待加密信息;Receiving information to be encrypted sent by the terminal device outside the blockchain;
    将所接收到的待加密信息确定为所述第一区块链账户的待加密信息。The received information to be encrypted is determined as the information to be encrypted of the first blockchain account.
  7. 一种基于区块链智能合约的数据写入装置,其特征在于,包括:A data writing device based on a blockchain smart contract, comprising:
    第一加密模块,用于根据预先获取的对称秘钥对所述第一区块链账户的待加密信息进行加密,得到所述第一区块链账户的信息密文;a first encryption module, configured to encrypt information to be encrypted of the first blockchain account according to a symmetric key obtained in advance, to obtain an information ciphertext of the first blockchain account;
    第二加密模块,用于根据所述第一区块链账户的公钥对所述对称秘钥进行加密,得到所述第一区块链账户的秘钥密文;a second encryption module, configured to encrypt the symmetric key according to the public key of the first blockchain account, to obtain a secret key ciphertext of the first blockchain account;
    第一写入模块,用于将所述第一区块链账户的信息密文和所述第一区块链账户的秘钥密文通过智能合约写入所述第一区块链账户所在的区块链中。a first writing module, configured to write the information ciphertext of the first blockchain account and the secret key ciphertext of the first blockchain account into the first blockchain account by using a smart contract In the blockchain.
  8. 根据权利要求7所述的装置,其特征在于,所述装置还包括:The device according to claim 7, wherein the device further comprises:
    第一建立模块,用于建立所述第一区块链账户的区块链账户分别与所述第一区块链账户的信息密文和所述第一区块链账户的秘钥密文之间的第一映射关系;a first establishing module, configured to establish, by the blockchain account of the first blockchain account, an information ciphertext of the first blockchain account and a secret ciphertext of the first blockchain account First mapping relationship between;
    第一读取模块,用于根据所述第一区块链账户的区块链账户,基于所述第一映射关系,从所述区块链中读取所述第一区块链账户的信息密文和所述第一区块链账户的秘钥密文;a first reading module, configured to read, according to the first mapping relationship, the information of the first blockchain account from the blockchain according to the blockchain account of the first blockchain account Ciphertext and secret key ciphertext of the first blockchain account;
    第一解密模块,用于根据所述第一区块链账户的私钥对所述第一区块链账户的秘钥密文进行解密,得到所述对称秘钥;a first decryption module, configured to decrypt a secret key ciphertext of the first blockchain account according to a private key of the first blockchain account, to obtain the symmetric key;
    第二解密模块,用于根据所述对称秘钥对所述第一区块链账户的信息密文进行解密,得到所述第一区块链账户的待加密信息。And a second decrypting module, configured to decrypt the information ciphertext of the first blockchain account according to the symmetric key to obtain information to be encrypted of the first blockchain account.
  9. 根据权利要求7所述的装置,其特征在于,所述第一区块链账户的待加密信息是第二区块链账户的公开信息,所述第一区块链账户和所述第二区块链账户属于同一个区块链;所述装置还包括:The apparatus according to claim 7, wherein the information to be encrypted of the first blockchain account is public information of a second blockchain account, the first blockchain account and the second zone Blockchain accounts belong to the same blockchain; the device also includes:
    第三加密模块,用于根据所述第二区块链账户的公钥对所述对称秘钥进行加密,得到所述第二区块链账户的秘钥密文;a third encryption module, configured to encrypt the symmetric key according to the public key of the second blockchain account, to obtain a secret key ciphertext of the second blockchain account;
    第二写入模块,用于将所述第一区块链账户的信息密文和所述第二区块链账户的秘钥密文通过智能合约写入所述区块链中。And a second writing module, configured to write the information ciphertext of the first blockchain account and the secret key ciphertext of the second blockchain account into the blockchain through a smart contract.
  10. 根据权利要求9所述的装置,其特征在于,所述装置还包括:The device according to claim 9, wherein the device further comprises:
    第二建立模块,用于建立所述第二区块链账户的区块链账户分别与所述第一区块链账户的信息密文和所述第二区块链账户的秘钥密文之间的第二映射关系;a second establishing module, configured to establish, by the blockchain account of the second blockchain account, an information ciphertext of the first blockchain account and a secret ciphertext of the second blockchain account a second mapping relationship between;
    第二读取模块,用于根据所述第二区块链账户的区块链账户,基于所述第二映射关系,从所述所在的区块链中读取所述第一区块链账户的信息密文和所述第二区块链账户的秘钥密文;a second reading module, configured to read, according to the block mapping account of the second blockchain account, the first blockchain account from the blockchain in the location based on the second mapping relationship Information ciphertext and secret key ciphertext of the second blockchain account;
    第三解密模块,用于根据所述第二区块链账户的私钥对所述第二区块链账户的秘钥密文进行解密,得到所述对称秘钥;a third decryption module, configured to decrypt the secret key ciphertext of the second blockchain account according to the private key of the second blockchain account, to obtain the symmetric key;
    第四解密模块,用于根据所述对称秘钥对所述第一区块链账户的信息密文进行解密,得到所述第一区块链账户的待加密信息。And a fourth decryption module, configured to decrypt the information ciphertext of the first blockchain account according to the symmetric key to obtain information to be encrypted of the first blockchain account.
  11. 根据权利要求7所述的装置,其特征在于,所述装置还包括:The device according to claim 7, wherein the device further comprises:
    第一获取模块,用于在每次对所述第一区块链账户的待加密信息进行加密之前,随机生成所述对称秘钥,并获取本次随机生成的对称秘钥;或a first acquiring module, configured to randomly generate the symmetric key before acquiring the information to be encrypted of the first blockchain account, and obtain the symmetric key generated by the randomization; or
    第二获取模块,用于在第一次对所述第一区块链账户的待加密信息进行加密之前,随机生成所述对称秘钥,并获取第一次随机生成的对称秘钥。And a second acquiring module, configured to randomly generate the symmetric key before encrypting the information to be encrypted of the first blockchain account for the first time, and obtain a symmetric key generated randomly for the first time.
  12. 根据权利要求7所述的装置,其特征在于,所述装置还包括:The device according to claim 7, wherein the device further comprises:
    接收模块,用于接收所述区块链外的终端设备发送的待加密信息;a receiving module, configured to receive information to be encrypted sent by the terminal device outside the blockchain;
    确定模块,用于将所接收到的待加密信息确定为所述第一区块链账户的待加密信息。And a determining module, configured to determine the received information to be encrypted as the information to be encrypted of the first blockchain account.
  13. 一种基于区块链智能合约的数据写入装置,其特征在于,包括:A data writing device based on a blockchain smart contract, comprising:
    至少一个处理器单元、通信接口、存储器和通信总线;所述至少一个处理器单元、所述通信接口和所述存储器通过所述通信总线完成相互间的通信;At least one processor unit, a communication interface, a memory, and a communication bus; the at least one processor unit, the communication interface, and the memory complete communication with each other through the communication bus;
    所述存储器被配置为存储程序代码;The memory is configured to store program code;
    所述至少一个处理器单元被配置为运行所述程序代码以实现权利要求1-6任一所述的方法。The at least one processor unit is configured to execute the program code to implement the method of any of claims 1-6.
  14. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质用于存储计算机程序,所述计算机程序包括用于执行权利要求1-6任一所述的方法的指令。A computer readable storage medium, characterized in that the computer readable storage medium is for storing a computer program, the computer program comprising instructions for performing the method of any of claims 1-6.
PCT/CN2017/119559 2017-12-28 2017-12-28 Blockchain smart contract-based data writing method, device and storage medium WO2019127265A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2017/119559 WO2019127265A1 (en) 2017-12-28 2017-12-28 Blockchain smart contract-based data writing method, device and storage medium
CN201780002394.6A CN110100422B (en) 2017-12-28 2017-12-28 Data writing method and device based on block chain intelligent contract and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2017/119559 WO2019127265A1 (en) 2017-12-28 2017-12-28 Blockchain smart contract-based data writing method, device and storage medium

Publications (1)

Publication Number Publication Date
WO2019127265A1 true WO2019127265A1 (en) 2019-07-04

Family

ID=67062944

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/119559 WO2019127265A1 (en) 2017-12-28 2017-12-28 Blockchain smart contract-based data writing method, device and storage medium

Country Status (2)

Country Link
CN (1) CN110100422B (en)
WO (1) WO2019127265A1 (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110335151A (en) * 2019-07-09 2019-10-15 郭小川 Cooperate centralization prophesy machine, information output method and the system of intelligent contract application
CN112019348A (en) * 2020-08-26 2020-12-01 合肥工业大学 Smart phone cloud positioning method based on block chain privacy protection
CN112261015A (en) * 2020-10-12 2021-01-22 北京沃东天骏信息技术有限公司 Block chain based information sharing method, platform, system and electronic equipment
CN112787976A (en) * 2019-11-06 2021-05-11 阿里巴巴集团控股有限公司 Data encryption, decryption and sharing method, device, system and storage medium
CN114726560A (en) * 2020-12-22 2022-07-08 富泰华工业(深圳)有限公司 Data protection method, computer device and readable storage medium
CN114760081A (en) * 2020-12-28 2022-07-15 富泰华工业(深圳)有限公司 File encryption and decryption method and device and electronic equipment
CN115023920A (en) * 2021-11-05 2022-09-06 富途网络科技(深圳)有限公司 Method and device for data processing in stock right incentive system

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111369236B (en) * 2020-02-19 2023-07-07 建信金融科技有限责任公司 Data management method and device applied to blockchain
CN111736783A (en) * 2020-06-23 2020-10-02 湖南天河国云科技有限公司 Self-service printing method based on block chain

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106330452A (en) * 2016-08-13 2017-01-11 深圳市樊溪电子有限公司 Security network attachment device and method for block chain
CN106534097A (en) * 2016-10-27 2017-03-22 上海亿账通区块链科技有限公司 Block chain trading based authority control method and system
CN107294709A (en) * 2017-06-27 2017-10-24 阿里巴巴集团控股有限公司 A kind of block chain data processing method, apparatus and system

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10013573B2 (en) * 2015-12-16 2018-07-03 International Business Machines Corporation Personal ledger blockchain

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106330452A (en) * 2016-08-13 2017-01-11 深圳市樊溪电子有限公司 Security network attachment device and method for block chain
CN106534097A (en) * 2016-10-27 2017-03-22 上海亿账通区块链科技有限公司 Block chain trading based authority control method and system
CN107294709A (en) * 2017-06-27 2017-10-24 阿里巴巴集团控股有限公司 A kind of block chain data processing method, apparatus and system

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110335151A (en) * 2019-07-09 2019-10-15 郭小川 Cooperate centralization prophesy machine, information output method and the system of intelligent contract application
CN110335151B (en) * 2019-07-09 2022-12-20 郭小川 Centralized language prediction machine matched with intelligent contract application, information output method and system
CN112787976A (en) * 2019-11-06 2021-05-11 阿里巴巴集团控股有限公司 Data encryption, decryption and sharing method, device, system and storage medium
CN112019348A (en) * 2020-08-26 2020-12-01 合肥工业大学 Smart phone cloud positioning method based on block chain privacy protection
CN112019348B (en) * 2020-08-26 2022-02-11 合肥工业大学 Smart phone cloud positioning method based on block chain privacy protection
CN112261015A (en) * 2020-10-12 2021-01-22 北京沃东天骏信息技术有限公司 Block chain based information sharing method, platform, system and electronic equipment
CN112261015B (en) * 2020-10-12 2023-05-12 北京沃东天骏信息技术有限公司 Information sharing method, platform, system and electronic equipment based on block chain
CN114726560A (en) * 2020-12-22 2022-07-08 富泰华工业(深圳)有限公司 Data protection method, computer device and readable storage medium
CN114760081A (en) * 2020-12-28 2022-07-15 富泰华工业(深圳)有限公司 File encryption and decryption method and device and electronic equipment
CN115023920A (en) * 2021-11-05 2022-09-06 富途网络科技(深圳)有限公司 Method and device for data processing in stock right incentive system
CN115023920B (en) * 2021-11-05 2024-01-19 富途网络科技(深圳)有限公司 Method and device for data processing in a equity incentive system

Also Published As

Publication number Publication date
CN110100422B (en) 2021-11-05
CN110100422A (en) 2019-08-06

Similar Documents

Publication Publication Date Title
WO2019127265A1 (en) Blockchain smart contract-based data writing method, device and storage medium
US11038853B2 (en) Secure multi-party protocol
US20190318356A1 (en) Offline storage system and method of use
US11880831B2 (en) Encryption system, encryption key wallet and method
US9485096B2 (en) Encryption / decryption of data with non-persistent, non-shared passkey
KR101389100B1 (en) A method and apparatus to provide authentication and privacy with low complexity devices
CN109729041B (en) Method and device for issuing and acquiring encrypted content
US11210658B2 (en) Constructing a distributed ledger transaction on a cold hardware wallet
CN106209352B (en) Efficient key derivation with forward security
CN104270242B (en) A kind of ciphering and deciphering device for network data encryption transmission
WO2016086788A1 (en) Method and apparatus for encrypting/decrypting data on mobile terminal
CN108282329A (en) A kind of Bidirectional identity authentication method and device
CN101720071A (en) Short message two-stage encryption transmission and secure storage method based on safety SIM card
US10263785B1 (en) Cryptography method and system for securing data via electronic transmission
WO2019214069A1 (en) Method and apparatus for encrypted user communication on blockchain, and terminal device and storage medium
US20180063105A1 (en) Management of enciphered data sharing
JP2014175970A (en) Information distribution system, information processing device, and program
WO2022217714A1 (en) Data collision method, apparatus and device, and computer-readable storage medium
CN110716724B (en) Method and device for realizing privacy block chain based on FPGA
US11386429B2 (en) Cryptocurrency securing method and device thereof
US10699021B2 (en) Method and a device for secure storage of at least one element of digital information, and system comprising such device
CN103458101A (en) Hardware encryption storage method and system of mobile phone private contacts
JP2014527786A (en) Communication system for authentication by fingerprint information and use thereof
TWI611316B (en) Text processing method for safe input method, text processing device and text processing system
CN108881300A (en) A kind of file encryption that supporting mobile phone terminal security cooperation and sharing method and system

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: 17936039

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 12.11.2020)

122 Ep: pct application non-entry in european phase

Ref document number: 17936039

Country of ref document: EP

Kind code of ref document: A1