WO2022206453A1 - 提供跨链隐私数据的方法和装置 - Google Patents

提供跨链隐私数据的方法和装置 Download PDF

Info

Publication number
WO2022206453A1
WO2022206453A1 PCT/CN2022/082010 CN2022082010W WO2022206453A1 WO 2022206453 A1 WO2022206453 A1 WO 2022206453A1 CN 2022082010 W CN2022082010 W CN 2022082010W WO 2022206453 A1 WO2022206453 A1 WO 2022206453A1
Authority
WO
WIPO (PCT)
Prior art keywords
transaction
message
chain
cross
data
Prior art date
Application number
PCT/CN2022/082010
Other languages
English (en)
French (fr)
Inventor
余逸荣
Original Assignee
支付宝(杭州)信息技术有限公司
蚂蚁区块链科技(上海)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 支付宝(杭州)信息技术有限公司, 蚂蚁区块链科技(上海)有限公司 filed Critical 支付宝(杭州)信息技术有限公司
Publication of WO2022206453A1 publication Critical patent/WO2022206453A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/04Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks
    • H04L63/0428Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks wherein the data content is protected, e.g. by encrypting or encapsulating the payload
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]
    • 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/50Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using hash chains, e.g. blockchains or hash trees

Definitions

  • the embodiments of this specification relate to the field of blockchain technology, and more particularly, to a method and apparatus for providing cross-chain privacy data, and a method and apparatus for obtaining cross-chain privacy data.
  • Blockchain technology also known as distributed ledger technology, is a decentralized distributed database technology characterized by decentralization, openness, transparency, immutability, and trustworthiness. Each data of the blockchain will be broadcast to the blockchain nodes of the entire network, and each full node has a full amount of consistent data.
  • many different types of chains have emerged, which are applied in the fields of finance, health care, supply chain, asset management and traceability. At present, how to make different types of chains cooperate and realize the circulation of value is an important exploration direction.
  • the cross-chain messages sent by the accounts in the blockchain to the outside of the chain are usually obtained by reading the blockchain ledger.
  • encrypted ledger data is usually stored, and even if the off-chain device reads the ledger data from the blockchain, the actual content of the ledger data cannot be obtained.
  • the embodiments of this specification aim to provide a more effective solution for transmitting cross-chain privacy data, so as to solve the deficiencies in the prior art.
  • one aspect of this specification provides a method for providing cross-chain messages, the method being executed by a node device of a blockchain, including: acquiring a first transaction, in which the first contract is invoked , and provide the first cross-chain message to the first contract; execute the first transaction to store the first cross-chain message in the message queue in the account status of the first contract; obtain the second transaction, the The query function in the first contract is called in the second transaction; the second transaction is executed to read the first cross-chain message from the message queue; the first data corresponding to the second transaction is generated, The first data includes the first cross-chain message; the first data is encrypted with a first predetermined key to obtain the second data, and the first predetermined key is used by the second transaction Provided by the initiator; storing the second data in the blockchain.
  • the first predetermined key is a public key of a sending account of the second transaction.
  • executing the second transaction further includes, after reading the first cross-chain message from the message queue, deleting the first cross-chain message from the message queue.
  • executing the second transaction further includes verifying whether the sending account of the second transaction is a predetermined account, and in the case that the sending account of the second transaction is a predetermined account, extracting from the message queue Read the first cross-chain message.
  • the first data is a receipt for the second transaction.
  • the blockchain is a Fabric chain
  • the first data is a read-write set of the second transaction.
  • Another aspect of this specification provides a method for obtaining a cross-chain message, the method is executed by an off-chain device, and includes: sending a second transaction to the blockchain, in which the query function in the first contract is invoked in the second transaction,
  • the account state of the first contract includes a message queue of cross-chain messages, the cross-chain messages are private data, and the query function is used to read the cross-chain messages in the message queue; obtain the second data corresponding to the second transaction in chain message.
  • the second predetermined key is a private key of a sending account of the second transaction.
  • the query function in the first contract is called with a query parameter as an incoming parameter in the second transaction, and the query parameter is used to indicate the first cross-chain message.
  • Another aspect of this specification provides an apparatus for providing cross-chain messages, the apparatus is deployed on a node device of a blockchain, and includes: a first obtaining unit configured to obtain a first transaction, in which the first transaction calls the the first contract and provide the first cross-chain message to the first contract; the first execution unit is configured to execute the first transaction to store the first transaction in the message queue in the account state of the first contract a cross-chain message; a second acquisition unit, configured to acquire a second transaction, in which the query function in the first contract is invoked; and a second execution unit, configured to execute the second transaction to execute the transaction from reading the first cross-chain message in the message queue; a generating unit configured to generate first data corresponding to the second transaction, where the first data includes the first cross-chain message; encrypting a unit configured to encrypt the first data using a first predetermined key to obtain the second data, the first predetermined key is provided by the initiator of the second transaction; the storage unit is configured to: The second data is stored in the blockchain.
  • the second execution unit is further configured to delete the first cross-chain message from the message queue after reading the first cross-chain message from the message queue.
  • the second execution unit is further configured to verify whether the sending account of the second transaction is a predetermined account, and in the case that the sending account of the second transaction is a predetermined account, from the The first cross-chain message is read from the message queue.
  • the first data is a receipt for the second transaction.
  • the blockchain is a Fabric chain
  • the first data is a read-write set of the second transaction.
  • an apparatus for obtaining cross-chain messages the apparatus is deployed on off-chain devices, and includes: a sending unit configured to send a second transaction to the blockchain, in which the second transaction calls the first transaction a query function in the contract, the account state of the first contract includes a message queue of cross-chain messages, the cross-chain messages are private data, and the query function is used to read the cross-chain messages in the message queue; an obtaining unit, configured to obtain second data corresponding to the second transaction from the blockchain; a decryption unit, configured to decrypt the second data using a second predetermined key to obtain the first data, where the first data includes the first cross-chain message in the message queue.
  • the second predetermined key is a private key of a sending account of the second transaction.
  • the query function in the first contract is called with a query parameter as an incoming parameter in the second transaction, and the query parameter is used to indicate the first cross-chain message.
  • Another aspect of the present specification provides a computer-readable storage medium on which a computer program is stored, when the computer program is executed in a computer, the computer is made to execute any one of the above-mentioned methods executed by a blockchain node device.
  • Another aspect of this specification provides a computing device, including a memory and a processor, where a computer program is stored in the memory, and when the processor executes the computer program, the processor implements any one of the above-mentioned execution by the blockchain node device. a method.
  • Another aspect of the present specification provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed in a computer, causes the computer to execute any one of the above-mentioned methods executed by an off-chain device.
  • the solution for providing cross-chain messages according to the embodiments of this specification is especially suitable for privacy protection scenarios.
  • the privacy protection scenario users cannot obtain clear-text ledger data by directly reading the blockchain ledger.
  • the cross-chain message is saved in the account state of the message sending contract, and the queryer sends the transaction to call the query function of the message sending contract to query the cross-chain message in the account state.
  • the key provided by the queryer encrypts the receipt of the transaction and stores it in the blockchain, so that the queryer can decrypt the receipt with a predetermined decryption key to obtain the plaintext of the receipt and obtain the cross-chain message from it;
  • By setting a verification program in the query function it can also verify whether the query account is an allowed preset account, thereby improving security.
  • FIG. 1 shows a schematic diagram of a cross-chain system according to an embodiment of the present specification
  • FIG. 2 shows a flowchart of a method for providing a cross-chain message according to an embodiment of the present specification
  • Figure 3 shows a schematic diagram of transaction m
  • Figure 4 shows a schematic diagram of a log included in receipt m
  • FIG. 5 shows an apparatus 500 for providing a cross-chain message according to an embodiment of the present specification
  • FIG. 6 shows an apparatus 600 for acquiring a cross-chain message according to an embodiment of the present specification.
  • FIG. 1 shows a schematic diagram of a cross-chain system according to an embodiment of the present specification.
  • the cross-chain system includes a blockchain 11 and an off-chain device 12 .
  • a business contract and a message sending contract are deployed in the blockchain 11.
  • the business contract is, for example, a cross-chain transfer contract, and the business contract includes a call of a message sending contract, and the message sending contract is used to send cross-chain messages.
  • a user in the blockchain 11 wishes to perform a cross-chain transfer, he can send transaction 1 to the blockchain 11 through his device.
  • the transaction 1 calls the business contract, and transfers the parameters related to the transfer to the business contract.
  • the ledger data in the blockchain is stored in the form of cipher text, so that the users off the chain are stored.
  • the ledger in the blockchain cannot be read arbitrarily. For example, when the above-mentioned device sends transaction 1 to the blockchain 11, an encrypted transaction 1 is sent, and the encrypted key is provided to the blockchain by the above-mentioned device in advance or simultaneously with the sending of transaction 1.
  • each node in the blockchain 11 decrypts the transaction 1 using the corresponding decryption key, and executes the transaction 1.
  • the account balance of the transaction 1 is reduced by the transfer amount, and a cross-chain message to be sent (message 1 in Figure 1) is generated.
  • the message 1 includes the sending block chain of the message 1. Identification, receiving blockchain identification, sending account, receiving account, receiving contract account and adding the amount to the balance of the receiving account, etc., then execute the message sending contract, and provide message 1 to the message sending contract.
  • the message 1 is recorded in the message queue in the account status of the message sending contract, that is, the message 1 is recorded in the ledger of the blockchain 11.
  • the messages 1- Message 5 schematically shows the message queue in the account state of the message sending contract.
  • the message 1-message 5 here may also be the message 1-message 5 encrypted using a key determined internally by the node.
  • the off-chain device 12 is used to pass messages between the blockchain 11 and other blockchains.
  • the off-chain device 12 can obtain cross-chain messages by sending a transaction (eg, transaction m in FIG. 1 , where m is a transaction number) to the blockchain 11 .
  • off-chain device 12 may send encrypted transaction m to blockchain 11 for privacy protection.
  • the query function of the message sending contract is called in transaction m to query the above message queue. Assuming that the blockchain 11 is the Ethereum chain, when the node device in the blockchain 11 executes the transaction m, it reads the message 1 from the message queue and deletes the message 1 in the message queue (as shown in the dotted box in Figure 1). shown).
  • the node device After the node device completes the transaction m, it generates a receipt m corresponding to the transaction m.
  • the receipt m includes the message 1 obtained by querying the message queue, and encrypts the receipt m using, for example, the account public key of the off-chain device. Store encrypted receipt m in .
  • the off-chain device 12 can read the encrypted receipt m from the blockchain 11, so that it can decrypt the encrypted receipt m with its own private key to obtain the receipt m, and obtain the message 1 from the receipt m.
  • the off-chain device 12 After acquiring the message 1, the off-chain device 12 can provide the message 1 to the receiving account and the receiving contract in the receiving blockchain in the message 1, so that the receiving blockchain can complete the transfer process based on the message 1.
  • the blockchain 11 is not limited to being an Ethereum chain, therefore, when executing a transaction m, it is not limited to depositing an encrypted receipt m in the blockchain 11 for depositing a message 1, but can be based on the specific area
  • the block chain type stores the message 1 in other forms. The method for providing messages across chains according to embodiments of the present specification will be described in detail below.
  • FIG. 2 shows a flowchart of a method for providing a cross-chain message according to an embodiment of the present specification.
  • the blockchain 11 includes, for example, node 1 and node 2.
  • the ledger data of the blockchain 11 is stored in the node devices of node 1 and node 2 of the blockchain, which are described in FIG. 2 and below.
  • node 1 represents the node device of node 1
  • node 2 represents the node device of node 2
  • the corresponding steps are performed by the corresponding node device.
  • the method can be executed jointly by node 1, node 2 and off-chain device 12 of the blockchain 11.
  • step S201 node 1 sends transaction 1 to node 2.
  • user A corresponding to node 1 in blockchain 11 wishes to perform a cross-chain transfer business. Therefore, user A can send transaction 1 to any node in blockchain 11 (for example, node 2 here) through node 1 , to broadcast transaction 1 into blockchain 11.
  • the transaction 1 includes a call to the business contract in FIG. 1 for cross-chain transfer business.
  • the business contract calls the sending function included in the message sending contract with message 1 as the incoming parameter, so as to send message 1 to the outside of the chain as a cross-chain message. It can be understood that, here, it is not limited to send transaction 1 from node 1 to node 2.
  • the user of blockchain 11 can also send transaction 1 to node 2 through their user equipment.
  • user A can use a predetermined key to encrypt transaction 1, and send the encrypted transaction 1 to the blockchain 11.
  • user A can encrypt transaction 1 using the public key in a predetermined asymmetric key, and provide the private key in the asymmetric key to a node in blockchain 11 .
  • User A may encrypt transaction 1 using a predetermined symmetric key and provide the predetermined symmetric key to nodes in blockchain 11 .
  • step S202 node 2 executes transaction 1 and stores message 1 in blockchain 11.
  • each node of blockchain 11 After node 1 sends transaction 1 to blockchain 11, each node of blockchain 11 will obtain transaction 1 and execute transaction 1 to store the data related to transaction 1 in the ledger of blockchain 11 .
  • the message queue may be a first-in, first-out message queue.
  • message 1 is a cross-chain message corresponding to transaction 1
  • message 2 is a cross-chain message corresponding to transaction 2
  • transaction 2 is executing The transaction is executed after transaction 1. Therefore, message 2 enters the message queue after message 1.
  • the off-chain device 12 reads the message queue, message 1 can be read first, and then message 2 can be read.
  • each node can encrypt the message 1 with a key (such as a symmetric key) determined by the node itself, and record the encrypted message 1 into the message in the queue.
  • a key such as a symmetric key
  • step S203 the off-chain device 12 sends the transaction m to the node 2.
  • the off-chain device 12 may be the device of the user of the blockchain 11, the node device of other blockchains, or the relay device used to transfer messages between multiple blockchains, etc., which is not limited here. , the ledger data of the blockchain 11 is not stored in the off-chain device 12 .
  • the off-chain device 12 obtains cross-chain messages from the blockchain 11 by sending a specific transaction to the blockchain 11 . Specifically, for example, as shown in FIG. 1 , the off-chain device 12 can send a transaction m to any node of the blockchain 11 (eg, node 2 ), and the transaction m calls the query function included in the message sending contract.
  • Figure 3 shows a schematic diagram of transaction m.
  • off-chain device 12 may encrypt transaction m with a secret key before sending the transaction m.
  • off-chain device 12 may encrypt transaction m using a public key in a predetermined asymmetric key and provide the private key in this asymmetric key to a node in blockchain 11, eg, through a key management authority.
  • the off-chain device 12 may encrypt the transaction m using a predetermined symmetric key, encrypt the symmetric key using the public key in the predetermined asymmetric key, and send the encrypted transaction m together with the encrypted symmetric key to The node of the blockchain 11, and the private key in the asymmetric key is provided to the node in the blockchain 11 through the key management organization.
  • the off-chain device 12 may encrypt the transaction m using a predetermined symmetric key and provide the symmetric key to the nodes in the blockchain 11 through a key management authority.
  • step S204 node 2 executes transaction m and reads message 1.
  • the node broadcasts the transaction m to the blockchain 11, and the The accounting node of 1 executes transaction m, updates the world state and incorporates the block, after which the accounting node sends the block including transaction m to blockchain 11, so that each node in blockchain 11 executes transaction m , update the world state and update the block, so that finally the ledger data of each node in the blockchain 11 is consistent. That is, this step performed by the node 2 of the blockchain 11 shown in FIG. 2 is performed in each node in the blockchain 11 .
  • node 2 of blockchain 11 when node 2 of blockchain 11 is about to execute transaction m, if transaction m is an encrypted transaction using a symmetric key, and the information sent with transaction m includes the encrypted symmetric key, then node 2 uses The private key in the corresponding pre-acquired asymmetric key decrypts the encrypted symmetric key to obtain the symmetric key, and uses the symmetric key to decrypt the encrypted transaction m, thereby obtaining the plaintext content of the transaction m.
  • node 2 After acquiring the plaintext content of transaction m, node 2 executes the query function in the message sending contract in transaction m, and the query function can be preset to allow the query account to verify whether the sending account of transaction m is an allowed query account. Therefore, when the query function is executed, the sending account of transaction m is first verified. If the verification fails, the query failure is returned. If the verification succeeds, the cross-chain message is read from the message queue in the account status of the message sending contract. It can be understood that in the case where the query account does not need to be verified, when the query function is executed, the cross-chain message can be directly read from the message queue in the account state of the message sending contract.
  • the query function includes, for example, the GetProposer interface.
  • the certificate of the proposer is first obtained by calling GetProposer. It includes the proposer's account, public key and other information, so that it can be verified whether the proposer is allowed to query based on the account or public key preset in the query function.
  • the query function includes, for example, the GetCreator interface. When the query function is executed, the proposer's account is first obtained by calling GetCreator, and then whether the proposer's account is verified based on the allowable account preset in the query function for allowed accounts.
  • the reading method of cross-chain messages in the query function can be set according to requirements. For example, it can be preset that each time the query function is executed, the oldest message is read from the message queue. Referring to Figure 1, assuming the current message 1 is the earliest recorded message, and message 2-message 5 are all messages recorded after message 1. Therefore, when the query function is executed this time, message 1 in the message queue is read.
  • the query function is not limited to reading the oldest message, but can be preset to read the oldest predetermined number (for example, 5, etc.) messages in the message queue, or can be preset to read The latest predetermined number of messages in the message queue, or it can be preset to read the message with the specified sequence number, and the specified sequence number can be passed to the query function as an incoming parameter when calling the query function, or it can be preset to read the specified sequence number.
  • the content of the message, the specified content is the content included in the message, such as accepting the contract account number, receiving the blockchain identifier, etc.
  • the specified content can also be passed to the query function as an incoming parameter when calling the query function. .
  • the query function can also be preset to modify the state of the message sending contract (that is, modify the world state) after reading the cross-chain message. Specifically, in one embodiment, after reading the message 1 in the message queue, for example, the message 1 (or encrypted message 1) may be deleted in the message queue, so that the next time the query function is executed, the reading will not be repeated Take message 1. In one embodiment, after reading message 1, message 1 may be marked to indicate that off-chain device 12 has read message 1, and in this embodiment, off-chain device 12 may read message 1 repeatedly, Alternatively, in the case where more than one off-chain device reads the cross-chain message from the blockchain 11, after the off-chain device 12 reads the message 1, other off-chain devices can also read the message 1.
  • step S205 node 2 generates receipt m.
  • node 2 After executing the above query function, node 2 uses the read cross-chain message (for example, message 1) as the return data for executing the query function, so that node 2 generates a receipt m for transaction m after executing transaction m.
  • the receipt m Include the return data (ie message 1) of executing the query function.
  • step S206 the node 2 encrypts the receipt m and stores the encrypted receipt m.
  • Message 1 in receipt m may involve personal privacy, such as transfer account, transfer amount, etc. Therefore, in order to protect privacy, node 2 needs to encrypt receipt m before depositing receipt m into blockchain 11.
  • the node 2 encrypts the receipt m using the public key of the sending account of the transaction m, and stores the encrypted receipt m in the blockchain 11 .
  • the node 2 may encrypt the receipt m using a predetermined symmetric key or a predetermined asymmetric key and store it in the blockchain 11 .
  • the blockchain 11 is described as an example of the Ethereum chain, the blockchain 11 is not limited to the Ethereum chain, but can be any other type of blockchain.
  • the blockchain 11 can also be a Hyperledger Fabric blockchain.
  • the node device of the endorsing node in the blockchain 11 pre-executes the transaction m, after reading the message 1, it writes the message 1 into In the read-write set corresponding to the transaction m, the submitting node in the blockchain 11 encrypts the read-write set after verifying the read-write set of the transaction m, and stores the encrypted read-write set in the blockchain 11 .
  • step S207 the off-chain device 12 obtains the encrypted receipt m from the node 2.
  • the off-chain device 12 can connect to any node in the blockchain 11 (eg, node 2) and remotely read the encrypted receipt m from that node. In one embodiment, after reading the encrypted receipt m, the off-chain device 12 can also read the Spv proof of the receipt m from the node of the blockchain 11 .
  • any node in the blockchain 11 can actively push the encrypted receipt m to the off-chain device 12 after depositing the encrypted receipt m.
  • step S208 the off-chain device 12 decrypts the encrypted receipt m to obtain the receipt m.
  • the off-chain device 12 when the off-chain device 12 is a relay device, the off-chain device 12 first decrypts the encrypted receipt m after acquiring the encrypted receipt m and its Spv certificate. In the case where the encrypted receipt m is encrypted using the account public key of the off-chain device 12, the off-chain device 12 decrypts the encrypted receipt m using its own account private key, thereby obtaining the plaintext receipt m. In the case where the encrypted receipt m is encrypted using a predetermined key, the off-chain device 12 uses the decryption key (either a symmetric key or a decryption key in an asymmetric key) corresponding to the predetermined key for the encrypted receipt m Decrypt to obtain receipt m in plaintext. In the latter case, the off-chain device 12 can also provide the decryption key for the encrypted receipt m to other devices, so that the other devices can obtain the encrypted receipt m from the nodes of the blockchain 11 and decrypt it.
  • the decryption key either a symmetric key or a de
  • the off-chain device 12 can obtain the message 1 by parsing the receipt m.
  • Message 1 is recorded in receipt m, for example, in the form of a log (Log).
  • the log is a log recorded after executing the message sending contract, and is used to record the return data when the function of the message sending contract is executed, that is, message 1.
  • Figure 4 shows a schematic diagram of the log included in receipt m. As shown in Fig. 4, the log has, for example, a preset specific identifier (as shown in "Message” in Fig. 4), and the "From" field in the log records the contract that calls the message sending contract (such as the transfer contract Transfer) The account of the message sending contract is recorded in the "To" field. Therefore, in receipt m, the log for recording message 1 can be determined based on the specific identifier "Message” or the account of the message sending contract, and the content of the "Data” field of the log can be obtained, which is message 1 .
  • the off-chain device 12 can determine the receiving chain identification from message 1, so that the receipt m and its Spv proof can be provided to the corresponding receiving chain.
  • the off-chain device 12 in the case where the off-chain device 12 is a trusted relay device, after obtaining the receipt m and its Spv certificate, the off-chain device 12 can first use the Spv certificate to verify the receipt m, and after the verification passes In the case of , by parsing the receipt m, the message 1 can be obtained, the receiving chain identifier can be determined from the message 1, and the message 1 can be directly provided to the corresponding receiving chain.
  • receipt m or message 1 in receipt m may be provided to the corresponding receiving chain.
  • FIG. 5 shows an apparatus 500 for providing a cross-chain message according to an embodiment of the present specification.
  • the apparatus 500 is deployed on a node device of a blockchain, and includes: a first obtaining unit 51 configured to obtain a first transaction, where the In the first transaction, the first contract is invoked, and the first cross-chain message is provided to the first contract; the first execution unit 52 is configured to execute the first transaction to the account status of the first contract.
  • the first cross-chain message is stored in the message queue; the second obtaining unit 53 is configured to obtain a second transaction, and the query function in the first contract is called in the second transaction; and the second execution unit 54, is configured to execute a second transaction to read the first cross-chain message from the message queue; the generating unit 55 is configured to generate first data corresponding to the second transaction, the first data including the first cross-chain message; the encryption unit 56 is configured to encrypt the first data using a first predetermined key to obtain second data, the first predetermined key is used by the second Provided by the initiator of the transaction; the storage unit 57 is configured to store the second data in the blockchain.
  • the first predetermined key is a public key of a sending account of the second transaction.
  • the second execution unit 54 is further configured to delete the first cross-chain message from the message queue after reading the first cross-chain message from the message queue .
  • the second execution unit 54 is further configured to verify whether the sending account of the second transaction is a predetermined account, and in the case that the sending account of the second transaction is a predetermined account, from the Read the first cross-chain message from the message queue.
  • the first data is a receipt for the second transaction.
  • the blockchain is a Fabric chain
  • the first data is a read-write set of the second transaction.
  • FIG. 6 shows an apparatus 600 for obtaining a cross-chain message according to an embodiment of the present specification.
  • the apparatus 600 is deployed on an off-chain device, and includes a sending unit 61 configured to send a second transaction to the blockchain, the In the second transaction, the query function in the first contract is called, and the account status of the first contract includes a message queue of cross-chain messages, and the cross-chain messages are private data, and the query function is used to read the message the cross-chain message in the queue;
  • the obtaining unit 62 is configured to obtain the second data corresponding to the second transaction from the blockchain;
  • the decrypting unit 63 is configured to use the second predetermined key to The second data is decrypted to obtain first data, where the first data includes the first cross-chain message in the message queue.
  • the second predetermined key is a private key of a sending account of the second transaction.
  • the query function in the first contract is called with a query parameter as an incoming parameter in the second transaction, and the query parameter is used to indicate the first cross-chain message.
  • Another aspect of the present specification provides a computer-readable storage medium on which a computer program is stored, when the computer program is executed in a computer, the computer is made to execute any one of the above-mentioned methods executed by a blockchain node device.
  • Another aspect of this specification provides a computing device, including a memory and a processor, where a computer program is stored in the memory, and when the processor executes the computer program, the processor implements any one of the above-mentioned execution by the blockchain node device. a method.
  • Another aspect of the present specification provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed in a computer, causes the computer to execute any one of the above-mentioned methods executed by an off-chain device.
  • the solution for providing cross-chain messages according to the embodiments of this specification is especially suitable for privacy protection scenarios.
  • the privacy protection scenario users cannot obtain clear-text ledger data by directly reading the blockchain ledger.
  • the cross-chain message is saved in the account state of the message sending contract, and the queryer sends the transaction to call the query function of the message sending contract to query the cross-chain message in the account state.
  • the key provided by the queryer encrypts the receipt of the transaction and stores it in the blockchain, so that the queryer can decrypt the receipt with a predetermined decryption key to obtain the plaintext of the receipt and obtain the cross-chain message from it;
  • By setting a verification program in the query function it can also verify whether the query account is an allowed preset account, thereby improving security.
  • the software module can be placed in random access memory (RAM), internal memory, read only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disks, removable disks, CD-ROMs, or technical fields in any other form of storage medium known in the art.
  • RAM random access memory
  • ROM read only memory
  • electrically programmable ROM electrically erasable programmable ROM
  • registers hard disks, removable disks, CD-ROMs, or technical fields in any other form of storage medium known in the art.

Landscapes

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

Abstract

本说明书实施例提供了一种提供跨链隐私数据的方法和装置,所述方法由区块链的节点设备执行,包括:获取第一交易,所述第一交易中调用所述第一合约、并向所述第一合约提供第一跨链消息;执行第一交易,以在第一合约的账户状态中的消息队列中存入所述第一跨链消息;获取第二交易,所述第二交易中调用所述第一合约中的查询函数;执行第二交易,以从所述消息队列中读取所述第一跨链消息;生成与所述第二交易对应的第一数据,所述第一数据中包括所述第一跨链消息;使用第一预定密钥对所述第一数据进行加密,以获取第二数据,所述第一预定密钥由所述第二交易的发起方提供;将所述第二数据存储到所述区块链中。

Description

提供跨链隐私数据的方法和装置 技术领域
本说明书实施例涉及区块链技术领域,更具体地,涉及一种提供跨链隐私数据的方法和装置、以及获取跨链隐私数据的方法和装置。
背景技术
区块链技术也被称之为分布式账本技术,是一种去中心化的分布式数据库技术,其特点是去中心化、公开透明、不可篡改、可信任。区块链的每笔数据,都会广播到全网的区块链节点,每个全节点都有全量的、一致的数据。随着区块链技术的火热,出现了许多不同类型的链,应用在金融、健康医疗、供应链、资产管理和溯源等领域。当前,如何能让不同类型的链协同合作实现价值的流通是一个重要的探索方向。在已有的跨链技术中,通常通过读取区块链账本而获取由该区块链中的账户向链外发送的跨链消息。然而,在保护隐私的区块链中,通常存储经加密的账本数据,链外设备即使从区块链中读取了账本数据也无法获取该账本数据的实际内容。
因此,需要一种更有效的跨链传递隐私数据的方案。
发明内容
本说明书实施例旨在提供一种更有效的传递跨链隐私数据的方案,以解决现有技术中的不足。
为实现上述目的,本说明书一个方面提供一种提供跨链消息的方法,所述方法由区块链的节点设备执行,包括:获取第一交易,所述第一交易中调用所述第一合约、并向所述第一合约提供第一跨链消息;执行第一交易,以在第一合约的账户状态中的消息队列中存入所述第一跨链消息;获取第二交易,所述第二交易中调用所述第一合约中的查询函数;执行第二交易,以从所述消息队列中读取所述第一跨链消息;生成与所述第二交易对应的第一数据,所述第一数据中包括所述第一跨链消息;使用第一预定密钥对所述第一数据进行加密,以获取第二数据,所述第一预定密钥由所述第二交易的发起方提供;将所述第二数据存储到所述区块链中。
在一种实施方式中,所述第一预定密钥为所述第二交易的发送账户的公钥。
在一种实施方式中,执行第二交易还包括,在从所述消息队列中读取所述第一跨链消息之后,在所述消息队列中删除所述第一跨链消息。
在一种实施方式中,执行第二交易还包括,验证所述第二交易的发送账户是否为预定账户,在所述第二交易的发送账户为预定账户的情况中,从所述消息队列中读取所述第一跨链消息。
在一种实施方式中,所述第一数据为所述第二交易的收据。
在一种实施方式中,所述区块链为Fabric链,所述第一数据为所述第二交易的读写集。
本说明书另一方面提供一种获取跨链消息的方法,所述方法由链下设备执行,包括:向区块链发送第二交易,所述第二交易中调用第一合约中的查询函数,所述第一合约的账户状态中包括跨链消息的消息队列,所述跨链消息为隐私数据,所述查询函数用于读取所述消息队列中的跨链消息;从所述区块链中获取与所述第二交易对应的第二数据;使用第二预定密钥对所述第二数据解密,以获取第一数据,所述第一数据中包括所述消息队列中的第一跨链消息。
在一种实施方式中,所述第二预定密钥为所述第二交易的发送账户的私钥。
在一种实施方式中,所述第二交易中以查询参数为传入参数调用第一合约中的查询函数,所述查询参数用于指示所述第一跨链消息。
本说明书另一方面提供一种提供跨链消息的装置,所述装置部署于区块链的节点设备,包括:第一获取单元,配置为,获取第一交易,所述第一交易中调用所述第一合约、并向所述第一合约提供第一跨链消息;第一执行单元,配置为,执行第一交易,以在第一合约的账户状态中的消息队列中存入所述第一跨链消息;第二获取单元,配置为,获取第二交易,所述第二交易中调用所述第一合约中的查询函数;第二执行单元,配置为,执行第二交易,以从所述消息队列中读取所述第一跨链消息;生成单元,配置为,生成与所述第二交易对应的第一数据,所述第一数据中包括所述第一跨链消息;加密单元,配置为,使用第一预定密钥对所述第一数据进行加密,以获取第二数据,所述第一预定密钥由所述第二交易的发起方提供;存储单元,配置为,将所述第二数据存储到所述区块链中。
在一种实施方式中,所述第一预定密钥为所述第二交易的发送账户的公钥。
在一种实施方式中,所述第二执行单元还配置为,在从所述消息队列中读取所述第 一跨链消息之后,在所述消息队列中删除所述第一跨链消息。
在一种实施方式中,所述第二执行单元还配置为,验证所述第二交易的发送账户是否为预定账户,在所述第二交易的发送账户为预定账户的情况中,从所述消息队列中读取所述第一跨链消息。
在一种实施方式中,所述第一数据为所述第二交易的收据。
在一种实施方式中,所述区块链为Fabric链,所述第一数据为所述第二交易的读写集。
本说明书另一方面提供一种获取跨链消息的装置,所述装置部署于链下设备,包括:发送单元,配置为,向区块链发送第二交易,所述第二交易中调用第一合约中的查询函数,所述第一合约的账户状态中包括跨链消息的消息队列,所述跨链消息为隐私数据,所述查询函数用于读取所述消息队列中的跨链消息;获取单元,配置为,从所述区块链中获取与所述第二交易对应的第二数据;解密单元,配置为,使用第二预定密钥对所述第二数据解密,以获取第一数据,所述第一数据中包括所述消息队列中的第一跨链消息。
在一种实施方式中,所述第二预定密钥为所述第二交易的发送账户的私钥。
在一种实施方式中,所述第二交易中以查询参数为传入参数调用第一合约中的查询函数,所述查询参数用于指示所述第一跨链消息。
本说明书另一方面提供一种计算机可读存储介质,其上存储有计算机程序,当所述计算机程序在计算机中执行时,令计算机执行上述由区块链节点设备执行的任一种方法。
本说明书另一方面提供一种计算设备,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器在执行所述计算机程序时,实现上述由区块链节点设备执行的任一种方法。
本说明书另一方面提供一种计算机可读存储介质,其上存储有计算机程序,当所述计算机程序在计算机中执行时,令计算机执行上述由链下设备执行的任一种方法。
本说明书另一方面提供一种计算设备,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器在执行所述计算机程序时,实现上述由链下设备执行的任一种方法。
根据本说明书实施例的提供跨链消息的方案尤其适用于隐私保护场景,在隐私保护的场景中,用户通过直接读取区块链账本并不能获取明文的账本数据,在本说明书实施 例提供的方案中,在消息发送合约的账户状态中保存跨链消息,并由查询者发送交易调用消息发送合约的查询函数来查询账户状态中的跨链消息,通过该方式,在区块链中以由查询者提供的密钥对该交易的收据进行加密并存入区块链中,从而查询者可使用预定解密密钥对该收据解密从而获取收据明文并从中获取跨链消息;通过该方法,还可以通过在查询函数设置验证程序,还可以验证查询账户是否为允许的预设账户,从而提高了安全性。
附图说明
通过结合附图描述本说明书实施例,可以使得本说明书实施例更加清楚:
图1示出根据本说明书实施例的跨链系统的示意图;
图2示出根据本说明书实施例的提供跨链消息的方法流程图;
图3示出交易m的示意图;
图4示出收据m中包括的日志示意图;
图5示出根据本说明书实施例的一种提供跨链消息的装置500;
图6示出根据本说明书实施例的一种获取跨链消息的装置600。
具体实施方式
下面将结合附图描述本说明书实施例。
图1示出根据本说明书实施例的跨链系统的示意图。如图1所示,所述跨链系统中包括区块链11和链下设备12。区块链11中部署有业务合约和消息发送合约,所述业务合约例如为跨链转账合约,并且所述业务合约中包括消息发送合约的调用,所述消息发送合约用于发送跨链消息。当区块链11中的用户希望进行跨链转账时,可通过其设备向区块链11中发送交易1,所述交易1中调用业务合约,并向业务合约传入与转账相关的参数,如接收转账的区块链标识、接收转账的账户、转账金额、接收合约账户等等。
假设区块链11为用于进行隐私保护的区块链,在区块链11中,与一般的区块链不同,区块链中的账本数据以密文的形式存储,从而使得链下用户不能随意读取区块链中的账本。例如,当上述设备向区块链11发送交易1时发送经加密的交易1,所述加密的密钥由上述设备预先或与发送交易1同时地提供给区块链。
区块链11中的各个节点在获取交易1之后,使用相应的解密密钥对交易1解密,并执行交易1。各个节点在执行交易时,将发起交易1的账户余额减少所述转账金额,并生成待发送的跨链消息(图1中的消息1),消息1中例如包括该消息1的发送区块链标识、接收区块链标识、发送账户、接收账户、接收合约账户及对接收账户的余额增加金额等内容,然后执行消息发送合约,并将消息1提供给消息发送合约。通过执行交易1中的消息发送合约,将消息1记录到消息发送合约的账户状态中的消息队列中,即将消息1记录到区块链11的账本中,图1中以顺序排列的消息1-消息5示意示出消息发送合约的账户状态中的消息队列。这里的消息1-消息5也可以是使用节点内部确定的密钥加密的消息1-消息5。
链下设备12用于在区块链11与其它区块链之间传递消息。链下设备12可通过向区块链11发送交易(例如图1中的交易m,其中m为交易编号)以获取跨链消息。同样地,链下设备12可向区块链11发送经加密的交易m,以用于进行隐私保护。交易m中调用消息发送合约的查询函数,以进行对上述消息队列的查询。假设区块链11为以太坊链,当区块链11中的节点设备执行交易m时,从消息队列中读取消息1,并将消息队列中的消息1删除(如图1中的虚线框所示)。节点设备在执行完成交易m之后,生成与交易m对应的收据m,收据m中包括通过查询消息队列获取的消息1,使用例如链下设备的账户公钥对收据m加密,在区块链11中存入加密的收据m。之后,链下设备12可从区块链11中读取加密的收据m,从而可通过自身的私钥对加密的收据m解密获取收据m,并从收据m中获取其中的消息1。链下设备12在获取消息1之后,可以将消息1提供给该消息1中的接收区块链中的接收账户和接收合约,从而使得接收区块链可基于该消息1完成转账过程。
可以理解,上述参考图1的描述只是示意性的,而不是用于限制本说明书实施例。例如,区块链11不限于为以太坊链,因此,当执行交易m时,不限于在区块链11中存入加密的收据m,以用于存入消息1,而可以根据具体的区块链类型通过其它形式进行对消息1的存储。下文将详细描述根据本说明书实施例的跨链提供消息的方法。
图2示出根据本说明书实施例的提供跨链消息的方法流程图。如图2所示,区块链11中例如包括节点1和节点2,区块链的节点1和节点2的节点设备中都存储有区块链11的账本数据,在图2及下文的描述中,为了简化描述,以节点1表示节点1的节点设备,以节点2表示节点2的节点设备,相应的步骤由相应的节点设备执行。该方法可由区块链11的节点1、节点2以及链下设备12共同执行。
首先,在步骤S201,节点1向节点2发送交易1。
例如,区块链11中的节点1对应的用户A希望进行跨链转账业务,因此,该用户A可通过节点1向区块链11中的任一节点(这里例如为节点2)发送交易1,以将交易1广播到区块链11中。该交易1中包括对图1中的业务合约的调用,以用于进行跨链转账业务。该业务合约以消息1为传入参数调用消息发送合约中包括的发送函数,以用于将消息1作为跨链消息发送到链外。可以理解,这里,不限于由节点1向节点2发送交易1,例如也可以由区块链11的用户通过其用户设备向节点2发送交易1。
为了保护隐私,用户A在发送交易1之前,可使用预定密钥对交易1进行加密,并将加密之后的交易1发送到区块链11中。例如,用户A可使用预定的非对称密钥中的公钥对交易1进行加密,并将该非对称密钥中的私钥提供给区块链11中的节点。或者用户A可使用预定对称密钥对交易1加密,并将该预定对称密钥提供给区块链11中的节点。
在步骤S202,节点2执行交易1,在区块链11中存入消息1。
在节点1向区块链11中发送交易1之后,区块链11的每个节点都将获取到交易1,执行交易1,以将与交易1相关的数据存入区块链11的账本中。
具体是,区块链11中的各个节点的节点设备在执行交易1中的消息发送合约时,从传入参数获取消息1,将消息1记录到消息发送合约的账户状态中的消息队列中,如图1中所示。该消息队列可以为先进先出的消息队列,例如,如图1中所示,消息1为与交易1对应的跨链消息,消息2为与交易2对应的跨链消息,交易2为在执行交易1之后执行的交易,因此,消息2在消息1之后进入消息队列,当链外设备12对该消息队列进行读取时,可先读取消息1,之后再读取消息2。
为了保护隐私,各个节点中在通过执行交易1获取消息1之后,可使用由该节点自身确定的密钥(例如对称密钥)对该消息1进行加密,并将加密后的消息1记录到消息队列中。
在步骤S203,链下设备12向节点2发送交易m。
所述链下设备12可以为区块链11的使用用户的设备,其它区块链的节点设备、或者用于在多个区块链之间中转消息的中继设备等等,在此不作限定,所述链下设备12中未存储有区块链11的账本数据。链下设备12通过向区块链11发送特定交易来从区块链11获取跨链消息。具体是,例如,如图1所示,链下设备12可向区块链11的任 一节点(例如节点2)发送交易m,该交易m中调用消息发送合约中包括的查询函数。图3示出交易m的示意图。如图3所示,在交易m中,“From”字段中的“0x215e...”为链下设备12用于向区块链11发送交易m的账户,表示该交易m由链下设备12发出,“To”字段中的“SendMessage(0x29a0…)”为消息发送合约的合约名称,“0x29a0…”为消息发送合约的合约账户,表示该交易m调用消息发送合约,“Data”字段中的“Qurery()”为消息发送合约中的查询函数,表示交易m调用消息发送合约中的查询函数。这里对于Qurery()未传入任何参数,如下文中所述,在对Qurery()函数不同的设定下,也可以对Qurery()函数传入用于进行查询的参数。
同样地,为了保护隐私,链下设备12在发送交易m之前,可使用密钥对该交易m进行加密。例如,链下设备12可使用预定非对称密钥中的公钥对交易m进行加密,并例如通过密钥管理机构将该非对称密钥中的私钥提供给区块链11中的节点。或者链下设备12可使用预定对称密钥对交易m进行加密,并使用预定非对称密钥中的公钥对该对称密钥进行加密,将加密的交易m、加密的对称密钥一起发送给区块链11的节点,并通过密钥管理机构将该非对称密钥中的私钥提供给区块链11中的节点。或者链下设备12可使用预定对称密钥对交易m进行加密,并通过密钥管理机构将该对称密钥提供给区块链11中的节点。
在步骤S204,节点2执行交易m,读取消息1。
假设区块链11为以太坊链,在链下设备12向区块链11中的任一节点发送交易m之后,该节点将交易m广播到区块链11中,并由区块链11中的记账节点执行交易m、更新世界状态并入块,之后,记账节点将该包括交易m的区块发送到区块链11中,以使得区块链11中的每个节点执行交易m、更新世界状态并更新区块,从而最终区块链11中的每个节点的账本数据都是一致的。也就是说,图2中示出的区块链11的节点2执行的该步骤在区块链11中的每个节点中执行。
具体是,当区块链11的节点2即将执行交易m时,如果交易m为使用对称密钥经加密的交易,并且随交易m一起发送的信息中包括加密的对称密钥,则节点2使用预先获取的对应的非对称密钥中的私钥对加密的对称密钥解密,以获取对称密钥,并使用对称密钥对加密的交易m解密,从而获取交易m的明文内容。
在获取交易m的明文内容之后,节点2执行交易m中的消息发送合约中的查询函数,该查询函数中可预设允许查询账户,以验证交易m的发送账户是否为允许的查询账户。因此,在执行查询函数时,首先对交易m的发送账户进行验证,如果验证失败,则 返回查询失败,如果验证成功,则从消息发送合约的账户状态中的消息队列中读取跨链消息。可以理解,在不需要对查询账户进行验证的情况中,在执行查询函数时,可直接从消息发送合约的账户状态中的消息队列中读取跨链消息。
在区块链11为Hyperledger Fabric区块链的情况中,在一种实施方式中,所述查询函数中例如包括GetProposer接口,在执行查询函数时,首先通过调用GetProposer获取提案者的证书,该证书中包括提案者的账户、公钥等信息,从而可基于查询函数中预设的账户或公钥验证该提案者是否被允许进行查询。在一种实施方式中,所述查询函数中例如包括GetCreator接口,在执行查询函数时,首先通过调用GetCreator获取提案者的账户,然后基于查询函数中预设的允许账户验证该提案者的账户是否为允许账户。
所述查询函数中对跨链消息的读取方式可根据需求进行设置,例如,可预设,在每次执行查询函数时,从消息队列中读取最早的消息,参考图1,假设当前消息1为最早记录的消息,消息2-消息5都是在消息1之后记录的消息。因此,在该次执行查询函数时,读取消息队列中的消息1。可以理解,所述查询函数不限于读取最老的1个消息,而可以预设为读取消息队列中最老的预定数目(例如5个等等)个消息,或者可以预设为读取消息队列中最新的预定数目个消息,或者可以预设为读取指定序号的消息,所述指定序号可在调用查询函数时作为传入参数传入给查询函数,或者可以预设为读取指定内容的消息,所述指定内容为所述消息中包括的内容,如接受合约账号、接收区块链标识等等,所述指定内容也可以在调用查询函数时作为传入参数传入给查询函数。
查询函数中还可以预设在进行对跨链消息的读取之后修改消息发送合约的状态(即修改世界状态)。具体是,在一种实施方式中,在例如读取消息队列中的消息1之后,可在消息队列中删除消息1(或加密的消息1),从而使得在下一次执行查询函数时不会重复读取消息1。在一种实施方式中,在读取消息1之后,可对消息1进行标记,以指示链下设备12已读取消息1,在该实施方式中,链下设备12可重复读取消息1,或者,在不止一个链下设备从区块链11读取跨链消息的情况中,在链下设备12读取消息1之后,其它链下设备还可以读取消息1。
在步骤S205,节点2生成收据m。
节点2在执行完成上述查询函数之后,以读取到的跨链消息(例如消息1)作为执行查询函数的返回数据,从而节点2在执行交易m之后,生成交易m的收据m,该收据m中包括执行查询函数的返回数据(即消息1)。
在步骤S206,节点2对收据m加密,并存入加密收据m。
收据m中的消息1可能涉及到个人隐私,如转账账户、转账金额等内容,因此,为了保护隐私,节点2在向区块链11中存入收据m之前需要对收据m进行加密。在一种实施方式中,节点2使用交易m的发送账户的公钥对收据m进行加密,并将加密收据m存入区块链11中。在一种实施方式中,节点2可使用预定对称密钥或预定非对称密钥对收据m进行加密并存入区块链11中。
可以理解,上文虽然以区块链11为以太坊链为例进行了描述,区块链11不限于为以太坊链,而可以为其它任意类型的区块链。例如,区块链11也可以为Hyperledger Fabric区块链,在该情况中,区块链11中的背书节点的节点设备在预执行交易m时,在读取消息1之后,将消息1写入与交易m对应的读写集中,区块链11中的提交节点在验证交易m的读写集之后,对该读写集进行加密,将该加密的读写集存入区块链11中。
在步骤S207,链下设备12从节点2获取加密收据m。
在一种实施方式中,链下设备12可连接区块链11中的任一节点(例如节点2),并从该节点远程读取加密收据m。在一种实施方式中,链下设备12在读取加密收据m之后,还可以从区块链11的节点中读取收据m的Spv证明。
在一种实施方式中,区块链11中的任一节点可在存入加密收据m之后主动向链下设备12推送所述加密收据m。
在步骤S208,链下设备12对加密收据m解密,以获取收据m。
在一种实施方式中,在链下设备12为中继设备的情况中,链下设备12在获取加密收据m及其Spv证明之后,首先对加密收据m解密。在加密收据m使用链下设备12的账户公钥进行加密的情况中,链下设备12使用自身账户私钥对该加密收据m解密,从而获取明文的收据m。在加密收据m使用预定密钥进行加密的情况中,链下设备12使用与所述预定密钥对应的解密密钥(对称密钥或者非对称密钥中的解密密钥)对该加密收据m解密,从而获取明文的收据m。在后一种情况中,链下设备12还可以将对加密收据m的解密密钥提供给其它设备,从而使得其它设备可从区块链11的节点中获取加密收据m并对其进行解密。
链下设备12在获取明文的收据m之后,可通过解析收据m获取其中的消息1。在收据m中例如以日志(Log)的形式记录消息1。该日志为在执行消息发送合约之后记录的日志,以用于记录执行消息发送合约的函数时的返回数据,即消息1。图4示出收 据m中包括的日志示意图。如图4所示,该日志例如具有预设的特定标识(如图4中的“Message”所示),并且该日志中的“From”字段记录调用消息发送合约的合约(例如转账合约Transfer)的账户,“To”字段中记录消息发送合约的账户。因此,在收据m中,可基于所述特定标识“Message”或者消息发送合约的账户来确定用于记录消息1的日志,并获取该日志的“Data”字段的内容,该内容即为消息1。
在获取消息1之后,链下设备12可从消息1中确定接收链标识,从而可将该收据m及其Spv证明提供给相应的接收链。
在一种实施方式中,在链下设备12为可信中继设备的情况中,链下设备12在获取收据m及其Spv证明之后,首先可使用Spv证明对收据m进行验证,在验证通过的情况中,通过解析收据m,可获取消息1,从消息1中确定接收链标识,从而将消息1直接提供给相应的接收链。
在一种实施方式中,在链下设备12仅获取收据m的情况中,可将收据m或收据m中的消息1提供给对应的接收链。
图5示出根据本说明书实施例的一种提供跨链消息的装置500,所述装置500部署于区块链的节点设备,包括:第一获取单元51,配置为,获取第一交易,所述第一交易中调用所述第一合约、并向所述第一合约提供第一跨链消息;第一执行单元52,配置为,执行第一交易,以在第一合约的账户状态中的消息队列中存入所述第一跨链消息;第二获取单元53,配置为,获取第二交易,所述第二交易中调用所述第一合约中的查询函数;第二执行单元54,配置为,执行第二交易,以从所述消息队列中读取所述第一跨链消息;生成单元55,配置为,生成与所述第二交易对应的第一数据,所述第一数据中包括所述第一跨链消息;加密单元56,配置为,使用第一预定密钥对所述第一数据进行加密,以获取第二数据,所述第一预定密钥由所述第二交易的发起方提供;存储单元57,配置为,将所述第二数据存储到所述区块链中。
在一种实施方式中,所述第一预定密钥为所述第二交易的发送账户的公钥。
在一种实施方式中,所述第二执行单元54还配置为,在从所述消息队列中读取所述第一跨链消息之后,在所述消息队列中删除所述第一跨链消息。
在一种实施方式中,所述第二执行单元54还配置为,验证所述第二交易的发送账户是否为预定账户,在所述第二交易的发送账户为预定账户的情况中,从所述消息队列中读取所述第一跨链消息。
在一种实施方式中,所述第一数据为所述第二交易的收据。
在一种实施方式中,所述区块链为Fabric链,所述第一数据为所述第二交易的读写集。
图6示出根据本说明书实施例的一种获取跨链消息的装置600,所述装置600部署于链下设备,包括:发送单元61,配置为,向区块链发送第二交易,所述第二交易中调用第一合约中的查询函数,所述第一合约的账户状态中包括跨链消息的消息队列,所述跨链消息为隐私数据,所述查询函数用于读取所述消息队列中的跨链消息;获取单元62,配置为,从所述区块链中获取与所述第二交易对应的第二数据;解密单元63,配置为,使用第二预定密钥对所述第二数据解密,以获取第一数据,所述第一数据中包括所述消息队列中的第一跨链消息。
在一种实施方式中,所述第二预定密钥为所述第二交易的发送账户的私钥。
在一种实施方式中,所述第二交易中以查询参数为传入参数调用第一合约中的查询函数,所述查询参数用于指示所述第一跨链消息。
本说明书另一方面提供一种计算机可读存储介质,其上存储有计算机程序,当所述计算机程序在计算机中执行时,令计算机执行上述由区块链节点设备执行的任一种方法。
本说明书另一方面提供一种计算设备,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器在执行所述计算机程序时,实现上述由区块链节点设备执行的任一种方法。
本说明书另一方面提供一种计算机可读存储介质,其上存储有计算机程序,当所述计算机程序在计算机中执行时,令计算机执行上述由链下设备执行的任一种方法。
本说明书另一方面提供一种计算设备,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器在执行所述计算机程序时,实现上述由链下设备执行的任一种方法。
根据本说明书实施例的提供跨链消息的方案尤其适用于隐私保护场景,在隐私保护的场景中,用户通过直接读取区块链账本并不能获取明文的账本数据,在本说明书实施例提供的方案中,在消息发送合约的账户状态中保存跨链消息,并由查询者发送交易调用消息发送合约的查询函数来查询账户状态中的跨链消息,通过该方式,在区块链中以由查询者提供的密钥对该交易的收据进行加密并存入区块链中,从而查询者可使用预定解密密钥对该收据解密从而获取收据明文并从中获取跨链消息;通过该方法,还可以通 过在查询函数设置验证程序,还可以验证查询账户是否为允许的预设账户,从而提高了安全性。
本说明书另一方面提供一种计算设备,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器在执行所述计算机程序时,实现上述由链下设备执行的任一种方法。
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于系统实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。
上述对本说明书特定实施例进行了描述。其它实施例在所附权利要求书的范围内。在一些情况下,在权利要求书中记载的动作或步骤可以按照不同于实施例中的顺序来执行并且仍然可以实现期望的结果。另外,在附图中描绘的过程不一定要求示出的特定顺序或者连续顺序才能实现期望的结果。在某些实施方式中,多任务处理和并行处理也是可以的或者可能是有利的。
本领域普通技术人员应该还可以进一步意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。本领域普通技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。其中,软件模块可以置于随机存储器(RAM)、内存、只读存储器(ROM)、电可编程ROM、电可擦除可编程ROM、寄存器、硬盘、可移动磁盘、CD-ROM、或技术领域内所公知的任意其它形式的存储介质中。
以上所述的具体实施方式,对本说明书实施例的目的、技术方案和有益效果进行了进一步详细说明,所应理解的是,以上所述仅为本说明书实施例的具体实施方式而已,并不用于限定本说明书实施例的保护范围,凡在本说明书实施例的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本说明书实施例的保护范围之内。

Claims (22)

  1. 一种提供跨链隐私数据的方法,所述方法由区块链的节点设备执行,包括:
    获取第一交易,所述第一交易中调用第一合约、并向所述第一合约提供第一跨链消息,所述第一跨链消息为隐私数据;
    执行第一交易,以在第一合约的账户状态中的消息队列中存入所述第一跨链消息;
    获取第二交易,所述第二交易中调用所述第一合约中的查询函数;
    执行第二交易,以从所述消息队列中读取所述第一跨链消息;
    生成与所述第二交易对应的第一数据,所述第一数据中包括所述第一跨链消息;
    使用第一预定密钥对所述第一数据进行加密,以获取第二数据,所述第一预定密钥由所述第二交易的发起方提供;
    将所述第二数据存储到所述区块链中。
  2. 根据权利要求1所述的方法,其中,所述第一预定密钥为所述第二交易的发送账户的公钥。
  3. 根据权利要求1所述的方法,执行第二交易还包括,在从所述消息队列中读取所述第一跨链消息之后,在所述消息队列中删除所述第一跨链消息。
  4. 根据权利要求1所述的方法,其中,执行第二交易还包括,验证所述第二交易的发送账户是否为预定账户,在所述第二交易的发送账户为预定账户的情况中,从所述消息队列中读取所述第一跨链消息。
  5. 根据权利要求1至4中任一项所述的方法,其中,所述第一数据为所述第二交易的收据。
  6. 根据权利要求1至4中任一项所述的方法,其中,所述区块链为Fabric链,所述第一数据为所述第二交易的读写集。
  7. 一种获取跨链隐私数据的方法,所述方法由链下设备执行,包括:
    向区块链发送第二交易,所述第二交易中调用第一合约中的查询函数,所述第一合约的账户状态中包括跨链消息的消息队列,所述跨链消息为隐私数据,所述查询函数用于读取所述消息队列中的跨链消息;
    从所述区块链中获取与所述第二交易对应的第二数据;
    使用第二预定密钥对所述第二数据解密,以获取第一数据,所述第一数据中包括所述消息队列中的第一跨链消息。
  8. 根据权利要求7所述的方法,其中,所述第二预定密钥为所述第二交易的发送账户的私钥。
  9. 根据权利要求7所述的方法,其中,所述第二交易中以查询参数为传入参数调用第一合约中的查询函数,所述查询参数用于指示所述第一跨链消息。
  10. 一种提供跨链隐私数据的装置,所述装置部署于区块链的节点设备,包括:
    第一获取单元,配置为,获取第一交易,所述第一交易中调用所述第一合约、并向所述第一合约提供第一跨链消息,所述第一跨链消息为隐私数据;
    第一执行单元,配置为,执行第一交易,以在第一合约的账户状态中的消息队列中存入所述第一跨链消息;
    第二获取单元,配置为,获取第二交易,所述第二交易中调用所述第一合约中的查询函数;
    第二执行单元,配置为,执行第二交易,以从所述消息队列中读取所述第一跨链消息;
    生成单元,配置为,生成与所述第二交易对应的第一数据,所述第一数据中包括所述第一跨链消息;
    加密单元,配置为,使用第一预定密钥对所述第一数据进行加密,以获取第二数据,所述第一预定密钥由所述第二交易的发起方提供;
    存储单元,配置为,将所述第二数据存储到所述区块链中。
  11. 根据权利要求10所述的装置,其中,所述第一预定密钥为所述第二交易的发送账户的公钥。
  12. 根据权利要求10所述的装置,所述第二执行单元还配置为,在从所述消息队列中读取所述第一跨链消息之后,在所述消息队列中删除所述第一跨链消息。
  13. 根据权利要求10所述的装置,其中,所述第二执行单元还配置为,验证所述第二交易的发送账户是否为预定账户,在所述第二交易的发送账户为预定账户的情况中,从所述消息队列中读取所述第一跨链消息。
  14. 根据权利要求10至13中任一项所述的装置,其中,所述第一数据为所述第二交易的收据。
  15. 根据权利要求10至13中任一项所述的装置,其中,所述区块链为Fabric链,所述第一数据为所述第二交易的读写集。
  16. 一种获取跨链隐私数据的装置,所述装置部署于链下设备,包括:
    发送单元,配置为,向区块链发送第二交易,所述第二交易中调用第一合约中的查询函数,所述第一合约的账户状态中包括跨链消息的消息队列,所述跨链消息为隐私数据,所述查询函数用于读取所述消息队列中的跨链消息;
    获取单元,配置为,从所述区块链中获取与所述第二交易对应的第二数据;
    解密单元,配置为,使用第二预定密钥对所述第二数据解密,以获取第一数据,所述第一数据中包括所述消息队列中的第一跨链消息。
  17. 根据权利要求16所述的装置,其中,所述第二预定密钥为所述第二交易的发送账户的私钥。
  18. 根据权利要求16所述的装置,其中,所述第二交易中以查询参数为传入参数调用第一合约中的查询函数,所述查询参数用于指示所述第一跨链消息。
  19. 一种计算机可读存储介质,其上存储有计算机程序或指令,当所述计算机程序或指令在计算机中执行时,令计算机执行权利要求1至6中任一项的所述的方法。
  20. 一种计算设备,包括存储器和处理器,所述存储器中存储有计算机程序或指令,所述处理器在执行所述计算机程序或指令时,实现权利要求1至6中任一项所述的方法。
  21. 一种计算机可读存储介质,其上存储有计算机程序或指令,当所述计算机程序或指令在计算机中执行时,令计算机执行权利要求7至9中任一项的所述的方法。
  22. 一种计算设备,包括存储器和处理器,所述存储器中存储有计算机程序或指令,所述处理器在执行所述计算机程序或指令时,实现权利要求7至9中任一项所述的方法。
PCT/CN2022/082010 2021-03-30 2022-03-21 提供跨链隐私数据的方法和装置 WO2022206453A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110340166.8 2021-03-30
CN202110340166.8A CN112804360B (zh) 2021-03-30 2021-03-30 提供跨链隐私数据的方法和装置

Publications (1)

Publication Number Publication Date
WO2022206453A1 true WO2022206453A1 (zh) 2022-10-06

Family

ID=75815989

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/082010 WO2022206453A1 (zh) 2021-03-30 2022-03-21 提供跨链隐私数据的方法和装置

Country Status (2)

Country Link
CN (1) CN112804360B (zh)
WO (1) WO2022206453A1 (zh)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112804360B (zh) * 2021-03-30 2021-07-06 支付宝(杭州)信息技术有限公司 提供跨链隐私数据的方法和装置
CN113923228A (zh) * 2021-06-02 2022-01-11 支付宝(杭州)信息技术有限公司 跨链交互方法及装置
CN117294540B (zh) * 2023-11-27 2024-01-23 人民法院信息技术服务中心 基于角色授权的隐私数据跨链获取方法、装置及系统

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108881187A (zh) * 2018-05-31 2018-11-23 杭州秘猿科技有限公司 一种适用于许可链场景的跨链数据传递方法及设备
CN110210861A (zh) * 2019-06-11 2019-09-06 北京艾摩瑞策科技有限公司 区块链上的数据交易方法及其设备
US20200119910A1 (en) * 2018-10-16 2020-04-16 International Business Machines Corporation Selective exchange of transaction data
CN111191286A (zh) * 2019-12-28 2020-05-22 南京理工大学 Hyperledger Fabric区块链隐私数据存储与访问系统及其方法
CN112804360A (zh) * 2021-03-30 2021-05-14 支付宝(杭州)信息技术有限公司 提供跨链隐私数据的方法和装置

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190303942A1 (en) * 2018-04-02 2019-10-03 American Express Travel Related Services Company, Inc. Fraud management using a distributed database
CN110033244B (zh) * 2019-03-15 2021-10-22 创新先进技术有限公司 基于区块链的智能合约执行方法及装置和电子设备
CN110580413B (zh) * 2019-11-08 2020-03-24 支付宝(杭州)信息技术有限公司 基于链下授权的隐私数据查询方法及装置
CN111581251B (zh) * 2020-04-23 2023-07-28 傲林科技有限公司 一种跨链交易的数字资产查询方法、装置及存储介质
CN111859443A (zh) * 2020-06-11 2020-10-30 上海简苏网络科技有限公司 账户级区块链隐私数据访问权限管控方法及系统
CN112837160B (zh) * 2020-12-04 2022-09-27 腾讯科技(深圳)有限公司 基于区块链的跨链交易方法、装置和计算机可读存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108881187A (zh) * 2018-05-31 2018-11-23 杭州秘猿科技有限公司 一种适用于许可链场景的跨链数据传递方法及设备
US20200119910A1 (en) * 2018-10-16 2020-04-16 International Business Machines Corporation Selective exchange of transaction data
CN110210861A (zh) * 2019-06-11 2019-09-06 北京艾摩瑞策科技有限公司 区块链上的数据交易方法及其设备
CN111191286A (zh) * 2019-12-28 2020-05-22 南京理工大学 Hyperledger Fabric区块链隐私数据存储与访问系统及其方法
CN112804360A (zh) * 2021-03-30 2021-05-14 支付宝(杭州)信息技术有限公司 提供跨链隐私数据的方法和装置

Also Published As

Publication number Publication date
CN112804360B (zh) 2021-07-06
CN112804360A (zh) 2021-05-14

Similar Documents

Publication Publication Date Title
WO2020238255A1 (zh) 基于区块链的智能合约管理方法及装置、电子设备
CN110580413B (zh) 基于链下授权的隐私数据查询方法及装置
CN110580418B (zh) 基于区块链账户的隐私数据查询方法及装置
CN110580414B (zh) 基于区块链账户的隐私数据查询方法及装置
CN110992027B (zh) 在区块链中实现隐私保护的高效交易方法及装置
CN110535833B (zh) 一种基于区块链的数据共享控制方法
CN110580412B (zh) 基于链代码的权限查询配置方法及装置
WO2022206453A1 (zh) 提供跨链隐私数据的方法和装置
US8447983B1 (en) Token exchange
CN110580245B (zh) 隐私数据的共享方法及装置
US20160294794A1 (en) Security System For Data Communications Including Key Management And Privacy
CN110264192B (zh) 基于交易类型的收据存储方法和节点
CN110580417B (zh) 基于智能合约的隐私数据查询方法及装置
CN107025409A (zh) 一种数据安全存储平台
CN110580411B (zh) 基于智能合约的权限查询配置方法及装置
CN112669147B (zh) 基于区块链的服务请求方法及装置
CN110489996A (zh) 一种数据库数据安全管理方法及系统
CN107864157A (zh) 基于权属的数据加密保护和权属授权解密应用方法及系统
CN112149077B (zh) 基于区块链技术的供应链票据方法、系统和计算机设备
WO2022206439A1 (zh) 提供跨链消息的方法和装置
JP4657706B2 (ja) 権限管理システム、認証サーバ、権限管理方法および権限管理プログラム
TWI430643B (zh) Secure key recovery system and method
CN115048672A (zh) 基于区块链的数据审计方法和装置、处理器及电子设备
Chase et al. Acsesor: A new framework for auditable custodial secret storage and recovery
TW202101267A (zh) 帳戶資料處理方法及帳戶資料處理系統

Legal Events

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

Ref document number: 22778636

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 22778636

Country of ref document: EP

Kind code of ref document: A1