WO2022205956A1 - Procédé et appareil de communication entre une chaîne de blocs et un dispositif hors chaîne - Google Patents

Procédé et appareil de communication entre une chaîne de blocs et un dispositif hors chaîne Download PDF

Info

Publication number
WO2022205956A1
WO2022205956A1 PCT/CN2021/133008 CN2021133008W WO2022205956A1 WO 2022205956 A1 WO2022205956 A1 WO 2022205956A1 CN 2021133008 W CN2021133008 W CN 2021133008W WO 2022205956 A1 WO2022205956 A1 WO 2022205956A1
Authority
WO
WIPO (PCT)
Prior art keywords
session
transaction
blockchain
chain device
message
Prior art date
Application number
PCT/CN2021/133008
Other languages
English (en)
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 蚂蚁区块链科技(上海)有限公司
Publication of WO2022205956A1 publication Critical patent/WO2022205956A1/fr

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
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/04Payment circuits
    • G06Q20/06Private payment circuits, e.g. involving electronic currency used among participants of a common payment scheme
    • G06Q20/065Private payment circuits, e.g. involving electronic currency used among participants of a common payment scheme using e-cash
    • 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
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management

Definitions

  • the embodiments of this specification relate to the field of blockchain technology, and more particularly, to a method and apparatus for communication between a blockchain and an off-chain device.
  • Blockchain technology also known as distributed ledger technology, is a decentralized distributed database technology characterized by decentralization, openness, transparency, immutability, and trustworthiness. Each transaction of the blockchain will be broadcast to the blockchain nodes of the entire network, and each full node has full and consistent data. Since the blockchain is a closed environment, the blockchain cannot actively initiate network calls, and the smart contracts on the chain can only passively receive data. Therefore, the blockchain cannot actively obtain data or resources outside the chain.
  • off-chain trusted devices can log in to the blockchain client and exchange information between the blockchain smart contracts, thereby providing off-chain data or resources to the blockchain, such as It can provide off-chain information, off-chain data processing capabilities, etc. to the blockchain.
  • off-chain trusted devices can log in to the blockchain client and exchange information between the blockchain smart contracts, thereby providing off-chain data or resources to the blockchain, such as It can provide off-chain information, off-chain data processing capabilities, etc. to the blockchain.
  • only one-way communication is realized in which the blockchain receives information from off-chain devices through contracts
  • the embodiments of this specification aim to provide a more effective communication solution between the blockchain and off-chain devices, so as to solve the deficiencies in the prior art.
  • one aspect of this specification provides a communication method between a blockchain and an off-chain device, the method being executed by a blockchain node, including: executing a first transaction to provide the off-chain device with A pre-opening message for a first session, wherein the first session is a session between the blockchain and the off-chain device; execute a second transaction sent by the off-chain device to send the off-chain device to the off-chain device An opening message of the first session is provided, and confirmation information for the pre-opening message is included in the second transaction.
  • executing the first transaction further includes executing the first transaction to store a pre-opening message of the first session in the blockchain.
  • executing the first transaction further includes executing the first transaction to record the state of the first session as a pre-opened state in the blockchain.
  • the first contract is invoked in the first transaction, wherein recording the state of the first session as a pre-opened state in the blockchain includes, in the account of the first contract In the state, the state of the first session is recorded as a pre-opened state.
  • the first contract is invoked in the second transaction
  • the executing the second transaction sent by the off-chain device includes executing the first contract invoked in the second transaction , so that it is determined whether the second transaction is executed within the first predetermined period, and in the case where it is determined that the second transaction is executed within the first predetermined period, an opening message of the first session is provided to the off-chain device.
  • executing the first contract invoked in the second transaction further results in ending the first session if the second transaction is determined to be executed after a first predetermined period of time.
  • providing the off-chain device with an open message of the first session includes modifying the state of the first session to an open state.
  • providing the off-chain device with the opening message of the first session includes storing the opening message of the first session in the blockchain.
  • the method further includes, after providing the off-chain device with the opening message of the first session, executing a third transaction invoking the first contract, the third transaction including the pending first session A piece of data, so as to determine whether the state of the first session is an open state, and in the case of determining that the state of the first session is an open state, it is stored in the blockchain in association with the first session the first data.
  • the method further includes: executing a fourth transaction sent by the off-chain device, the fourth transaction including pre-closing information, so that it is determined whether the off-chain device has received All messages sent; in a case where it is determined that all messages sent by the off-chain device are received, a close message of the first session is provided to the off-chain device.
  • providing the off-chain device with a close message of the first session includes modifying the state of the first session to a closed state.
  • executing the fourth transaction further causes, in the event that it is determined that the message sent at least in part by the off-chain device has not been received, storing in the blockchain in association with the first session incoming request information, where the request information is used to request the off-chain device to resend the at least part of the message.
  • executing the fourth transaction further results in modifying the state of the first session to a pre-closed state in the event that it is determined that a message sent at least in part by the off-chain device has not been received.
  • Another aspect of this specification provides a method for communication between a blockchain and an off-chain device, the method being performed by the off-chain device, comprising: acquiring a pre-opening message of a first session from the blockchain, the first session A session is a session between the blockchain and the off-chain device; send a second transaction to the blockchain, the second transaction includes confirmation information for the pre-opening message; open the first The data retention period for the session.
  • sending the second transaction to the blockchain includes sending the second transaction to the blockchain within a first predetermined period of time.
  • the method further includes, after the data retention period is opened, determining whether to obtain the open message of the first session from the blockchain within a second predetermined period, when the second predetermined period In the case where the opening message of the first session is not obtained from the blockchain within the period, the data retention period is ended.
  • the method further includes, when a preset condition is met, sending a fourth transaction to the blockchain, where the fourth transaction includes pre-closing information of the first session.
  • the method further includes, after sending the fourth transaction to the blockchain, obtaining a close message for the first session from the blockchain; and ending the data retention period.
  • the method further comprises, after sending the fourth transaction to the blockchain, obtaining a request message from the blockchain for at least a portion of the messages in the first session that have been sent ; sending a fifth transaction to the blockchain, the fifth transaction including the at least part of the message.
  • Another aspect of the present specification provides a communication device between a blockchain and an off-chain device, the device is deployed on a blockchain node, and includes: a first execution unit configured to execute a first transaction to send a transaction to the blockchain.
  • the off-chain device provides a pre-opening message of a first session, where the first session is a session between the blockchain and the off-chain device; the second execution unit is configured to execute a session sent by the off-chain device to provide the off-chain device with an opening message of the first session, and the second transaction includes confirmation information for the pre-opening message.
  • the first execution unit is further configured to execute a first transaction to store a pre-opening message of the first session in the blockchain.
  • the first execution unit is further configured to execute a first transaction to record the state of the first session as a pre-opened state in the blockchain.
  • the first contract is invoked in the first transaction, wherein the first execution unit is further configured to record the state of the first session in the account state of the first contract as pre-opened state.
  • the first contract is invoked in the second transaction
  • the second execution unit is further configured to execute the first contract invoked in the second transaction, so as to determine whether the first contract is invoked in the second transaction.
  • the second transaction is executed within a predetermined period of time, and in the event that the second transaction is determined to be executed within the first predetermined period of time, an opening message of the first session is provided to the off-chain device.
  • the first execution unit is further configured to end the first session if it is determined that the second transaction is executed after a first predetermined period of time.
  • the second execution unit is further configured to modify the state of the first session to an open state.
  • the second execution unit is further configured to store an opening message of the first session in the blockchain.
  • the apparatus further includes a third execution unit configured to, after providing the off-chain device with an opening message of the first session, execute a third transaction that invokes the first contract, the first The first data to be processed is included in the third transaction, so that it is determined whether the state of the first session is an open state, and in the case of determining that the state of the first session is an open state, the blockchain is connected with all and storing the first data in association with the first session.
  • a third execution unit configured to, after providing the off-chain device with an opening message of the first session, execute a third transaction that invokes the first contract, the first The first data to be processed is included in the third transaction, so that it is determined whether the state of the first session is an open state, and in the case of determining that the state of the first session is an open state, the blockchain is connected with all and storing the first data in association with the first session.
  • the apparatus further includes: a fourth execution unit configured to execute a fourth transaction sent by the off-chain device, where the fourth transaction includes pre-closing information, so as to determine whether to All messages sent by the off-chain device are received; in a case where it is determined that all messages sent by the off-chain device are received, a close message of the first session is provided to the off-chain device.
  • a fourth execution unit configured to execute a fourth transaction sent by the off-chain device, where the fourth transaction includes pre-closing information, so as to determine whether to All messages sent by the off-chain device are received; in a case where it is determined that all messages sent by the off-chain device are received, a close message of the first session is provided to the off-chain device.
  • the fourth execution unit is further configured to modify the state of the first session to a closed state.
  • the fourth execution unit is further configured to, in the event of determining that a message sent at least in part by the off-chain device has not been received, in the blockchain associated with the first session storing request information, where the request information is used to request the off-chain device to resend the at least part of the message.
  • the fourth execution unit is further configured to, in a case where it is determined that a message sent at least in part by the off-chain device has not been received, modify the state of the first session to a pre-closed state .
  • Another aspect of this specification provides a communication device between a blockchain and an off-chain device, the device is deployed on the off-chain device, and includes: a first obtaining unit configured to obtain a first session from the blockchain The first session is a session between the blockchain and the off-chain device; the first sending unit is configured to send a second transaction to the blockchain, in which the second transaction Including confirmation information for the pre-opening message; an opening unit, configured to open a data retention period of the first session.
  • the first sending unit is further configured to send a second transaction to the blockchain within a first predetermined period of time.
  • the apparatus further includes a determining unit configured to, after the data retention period is enabled, determine whether to acquire the opening message of the first session from the blockchain within a second predetermined period, A first ending unit, configured to end the data retention period when the opening message of the first session is not obtained from the blockchain within a second predetermined period of time.
  • the apparatus further includes a second sending unit configured to, when a preset condition is met, send a fourth transaction to the blockchain, where the fourth transaction includes the first session pre-close information.
  • the apparatus further includes a second obtaining unit configured to obtain a closing message of the first session from the blockchain after the fourth transaction is sent to the blockchain; A second end unit configured to end the data retention period.
  • the apparatus further includes a third obtaining unit, configured to, after sending the fourth transaction to the blockchain, obtain from the blockchain a request for the first session that has been sent A request message for at least part of the message in the third sending unit, configured to send a fifth transaction to the blockchain, where the fifth transaction includes the at least part of the 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 methods.
  • Another aspect of the present specification provides a computing device, including a memory and a processor, where a computer program is stored in the memory, and the processor implements any one of the above methods when executing the computer program.
  • the session can be opened after both the blockchain and the off-chain device confirm the channel, and the off-chain device guarantees the session during the session opening.
  • the data retention period ensures secure two-way communication between the blockchain and off-chain devices.
  • by using a smart contract in the blockchain to conduct a session with an off-chain device, and recording the session status in the account status of the smart contract it is convenient for each node to query the session status, and Communication with off-chain devices can be done based on session state.
  • FIG. 1 shows a schematic diagram of a blockchain system according to an embodiment of the present specification
  • FIG. 2 shows a flowchart of a communication method between the blockchain 11 and the off-chain device 12 according to an embodiment of the present specification
  • FIG. 3 shows a communication apparatus 300 between a blockchain and an off-chain device according to an embodiment of the present specification
  • FIG. 4 is a communication apparatus 400 used between a blockchain and an off-chain device according to an embodiment of the present specification.
  • FIG. 1 shows a schematic diagram of a blockchain system according to an embodiment of the present specification.
  • the system includes a blockchain 11 and off-chain devices 12 .
  • the contract C1 and the communication contract C2 are deployed in the blockchain 11 .
  • the communication contract C2 is used for two-way communication with the off-chain device, and the contract C1 realizes data interaction with the off-chain device by calling the communication contract C2.
  • the off-chain device 12 is a trusted device, and the trusted device can realize its trustworthiness through hardware, software, etc.
  • the off-chain device 12 can include a trusted execution environment (TEE), and the TEE has its own hardware
  • TEE trusted execution environment
  • the private key and public key, or the off-chain device 12 realizes its credibility through algorithms such as secure multi-party computation and zero-knowledge implementation, or the off-chain device 12 may be a device of a trusted authority, and so on.
  • the communication contract C2 can have a session with at least one off-chain device.
  • the communication contract C2 includes, for example, a request to open a session function, a session open function, a data transmission function, a result return function, and a session close function, and the account database of the blockchain 11 records the communication between the communication contract C2 and each off-chain device.
  • the session state for example, the session state includes: a pre-open state, an open state, a pre-close state, and a closed state.
  • node 1 in blockchain 11 wishes to call contract C1 for data processing. Since contract C1 calls communication contract C2, node 1 can first query the status of communication contract C2 in the account database of the blockchain to determine the status of communication contract C2. Whether the communication contract C2 has established a session with the off-chain device 12. If the session status between the communication contract C2 and the off-chain device 12 is found to be closed, node 1 can send transaction 1, and in transaction 1, call the request open session function in the communication contract C2 to send the pre-open session to the off-chain device 12. information.
  • the "pre-opening message” sent by the communication contract C2 to the off-chain device 12 is stored in the blockchain, and the communication contract C2 and the off-chain device's session 1 are stored in the blockchain.
  • the state is recorded as "pre-open state”.
  • the off-chain device 12 can read the above-mentioned "pre-opening message” by reading the data in the blockchain 11, and send transaction 2 to the blockchain 11, and the transaction 2 calls the session opening function in the communication contract C2.
  • the off-chain device 12 enables the data retention period while sending transaction 2, thereby ensuring the security of the data in the session.
  • the node in the blockchain 11 modifies the state of the session 1 to "open state".
  • node 1 After node 1 determines that the state of session 1 has changed to "open state", it can send transaction 3 that calls contract C1.
  • contract C1 uses data D1 as a parameter to call the data sending function in communication contract C2.
  • the node in the blockchain 11 executes the transaction 3, it executes the communication contract C2 called therein, thereby storing the data D1 in the blockchain for sending to the off-chain device 12.
  • data D1 is sent to off-chain device 12 in blockchain 11 in the form of receipt R1 and Spv proof including data D1.
  • the blockchain 11 can be any blockchain, such as Bitcoin chain, Ethereum chain, Hyperledger Fabric blockchain (hereinafter referred to as Fabric chain) and so on. Different blockchains have different on-chain data proof methods.
  • the Fabric chain uses the endorsement node signature method
  • the Ethereum chain uses the Spv proof method.
  • the blockchain 11 is used as an example to illustrate the Ethereum chain.
  • the off-chain device 12 can then read the receipt R1 and its Spv proof from the blockchain 11 .
  • the off-chain device 12 includes an Spv client. After obtaining the receipt R1 and the Spv certificate, the off-chain device 12 uses the Spv client to verify the receipt R1 through the Spv verification method, and obtains the data from the receipt R1 after the verification. Data D1 sent by contract C2, and data D1 is processed.
  • the off-chain device 12 is, for example, a TEE device, and after processing the data D1, for example, the acquired processing result is the processing result E1.
  • the off-chain device 12 signs the processing result E1 using its hardware private key, and sends a transaction 4 that calls the communication contract C2 to the blockchain, where the call returns the result of calling the communication contract C2 with the processing result E1 and its signature as parameters function to provide the processing result E1 and its signature to the communication contract C2. Therefore, when the transaction 4 is executed in the blockchain, the communication contract C2 uses the preset public key of the off-chain device 12 to verify the signature of the processing result E1, and after the verification is passed, the contract C1 is called back to send the The processing result E1 is provided to the contract C1.
  • the off-chain device 12 When the off-chain device 12 is about to end the session with the communication contract C2, it sends a transaction 5 to the blockchain 11, and in the transaction 5 calls the communication contract C2's request to close the session function. When the node in the blockchain 11 is executing transaction 5, it determines whether the reception of the data from the off-chain device 12 is completed. Change the state of session 1 to closed, thus ending the execution of transaction 5. The off-chain device 12 ends the above data retention period after reading the "session close message" from the blockchain 11, that is, deletes the data in the above session.
  • the blockchain 11 is not limited to calling the communication contract through the contract C1.
  • the communication contract C2 can also be called directly with the data D1 as the incoming parameter in the transaction, so that the data D1 can be processed by the off-chain device 12.
  • the communication process between the above-mentioned blockchain and off-chain devices will be described in detail below.
  • FIG. 2 shows a flowchart of a communication method between the blockchain 11 and the off-chain device 12 according to an embodiment of the present specification.
  • the blockchain 11 and the off-chain device 12 communicate interactively, thereby realizing the session between the blockchain 11 and the off-chain device 12 .
  • the node in the blockchain 11 can send the desired data in the form of provable data (eg transaction receipt, account data, etc.) by sending a transaction Stored in the blockchain so that the off-chain device 12 can receive this data by reading the receipt in the blockchain.
  • the off-chain device 12 may send a transaction to the blockchain through the blockchain client therein, thereby providing data to the blockchain through the transaction.
  • the blockchain 11 can communicate with the off-chain device 12 by executing a transaction that invokes the communication contract C2, which will be described below as an example. It can be understood that the communication method provided by the embodiments of this specification is not limited to executing a transaction that invokes the communication contract C2, but can also be executed by executing a transaction including a data field, as long as a message that can be explicitly sent through the data field of the transaction, and Either the recipient or the sender of the message is sufficient.
  • step S202 the blockchain 11 sends a pre-opening message to the off-chain device 12.
  • the account status of the communication contract C2 records the session status between the communication contract C2 and the off-chain device. For example, initially, the account status of the communication contract C2 records that the status of session 1 with the off-chain device 12 is closed, or the account status of the communication contract C2 does not record any session with the off-chain device 12, that is, The session state between the communication contract C2 and the off-chain device is closed.
  • the node 1 in the blockchain 11 wishes to perform data processing by invoking the communication contract C2, it can first query the account status of the communication contract C2, so as to know that the communication contract C2 has not established a session with the off-chain device 12. Therefore, node 1 may send transaction 1, in which the request to open session function in communication contract C2 is called with the off-chain device 12 identifier as an incoming parameter in transaction 1 to send a pre-open message to off-chain device 12.
  • Each node in the blockchain executes transaction 1 after consensus on transaction 1 to obtain a consistent state.
  • the receipt R1 includes the account of the communication contract C2, the identifier of the off-chain device 12, and the pre-opening message.
  • the pre-opening message is, for example, "OpenSyncMsg".
  • the receipt R1 may further include an identifier of session 1 (eg "session 1").
  • the nodes in the blockchain also record the session status between the communication contract C2 and the off-chain device 12 in the account status of the communication contract C2. For example, session 1 is used as the identifier of the session, and the status of session 1 is recorded as "pre- On state".
  • Table 1 schematically shows a table of session states recorded in the account state of the communication contract C2 in the blockchain node.
  • multiple sessions may be recorded in the account state of the communication contract C2, such as session 1, session 2, and different sessions are sessions with different off-chain devices, and may have different session states .
  • session 1 is a session between communication contract C2 and off-chain device 12, and the state of session 1 is a pre-opened state.
  • the off-chain device 12 can monitor the receipt including the account address of the communication contract C2 and the identification of the off-chain device 12 through its Spv client, or the off-chain device 12 can monitor the receipt including "session 1", whenever the area is determined.
  • the receipt can be read from the blockchain 11, and the Spv certification data of the receipt can be read accordingly.
  • the blockchain 11 can actively push information, and each time it is determined that the blockchain 11 stores the receipt generated by the execution of the communication contract C2 and sent to the off-chain device 12, the receipt and the corresponding Spv proof data are stored in the blockchain 11. Actively push to off-chain device 12. Therefore, after the above-mentioned receipt R1 is stored in the blockchain 11, the off-chain device 12 can read the receipt R1 and its Spv proof from the blockchain 11, that is, receive the pre-opening message of the session 1 in the receipt R1.
  • the embodiment of the present specification is not limited thereto.
  • blockchain 11 may provide a pre-open message to off-chain device 12 through the state of session 1 in the account state of communication contract C2.
  • the off-chain device 12 can obtain the message by reading the state of the session 1 in the blockchain 11 .
  • the node 1 in the blockchain 11 can query whether the transaction sent by the off-chain device 12 for confirming the above-mentioned pre-opening message is included in the predetermined number of blocks after the transaction 1 is formed into a block, if not included, the node 1 can be as follows: As shown by the dotted line in Figure 2, a transaction that calls the session closing function in the communication contract C2 is sent. After the transaction is executed, the information of the session 1 recorded in the account state of the communication contract C2 is deleted, or the state of the session 1 is modified to Disabled. Optionally, after the transaction is executed, a session close message is stored in the blockchain 11 so that the off-chain device 12 can obtain the information.
  • step S204 the off-chain device 12 sends pre-opening confirmation information to the blockchain 11.
  • the off-chain device 12 After reading the receipt R1 and its Spv proof, the off-chain device 12 verifies the receipt R1 by using the Spv proof through the Spv client. After the verification is passed, the "OpenSyncMsg" message can be read from the receipt R1.
  • the off-chain device 12 can send transaction 2 to the blockchain 11 through the client within a predetermined period after the receipt R1 is read. In the transaction 2, for example, the session opening function in the communication contract C2 is called to send the pre-received transaction to the blockchain 11. Turn on the confirmation message.
  • the off-chain device 12 After sending transaction 2, the off-chain device 12 opens a session with the communication contract C2 in the blockchain 11, and accordingly opens a data retention period corresponding to the session, during which the off-chain device 12 has a pair of Any communication data with the communication contract C2 in this period is retained to ensure data security.
  • Table 2 schematically shows a table of data retention periods for individual sessions recorded in the off-chain device 12 .
  • session ID contract address Data retention period session 1 Communication contract C2 address turn on session 2 Contract C3 address closure ...
  • communication device 12 may establish sessions with multiple contracts, such as session 1 and session 2, and so on.
  • the communication data in each session can be associated with "session 1", so that when the data retention period of the session 1 is on according to Table 2, the communication in the session 1 is reserved in the communication device 12 data, when it is determined that the data retention period of session 2 is closed according to Table 2, the communication data in session 2 can be deleted, and the record of session 2 can be deleted in Table 2.
  • step S206 the blockchain 11 sends an opening message to the off-chain device 12.
  • a node in blockchain 11 executes transaction 2 after consensus on transaction 2, it is first determined whether the state of session 1 is a pre-open state. If the state of session 1 is the pre-open state, change the state of session 1 to the open state, and store the receipt R2 corresponding to transaction 2 in the blockchain 11.
  • the receipt R2 includes the account and chain of the communication contract C2.
  • the off-chain device 12 determines whether the above-mentioned opening message sent by the blockchain 11 is read within a predetermined period of time, and if the above-mentioned opening message is read within the predetermined period of time, it can be confirmed that the blockchain 11 has received To the transaction 2 sent by it, then continue to retain the above-mentioned data retention period (as shown in the data retention period T1 in Figure 2), if the above-mentioned opening message is not read within a predetermined period of time, then end the above-mentioned data retention period (as shown in Figure 2). 2 in the data retention period T2).
  • the predetermined period of time may be predetermined based on transaction block times in the blockchain 11 .
  • the off-chain device 12 can determine whether the transaction 2 is read by the blockchain within a predetermined period of time after the transaction 2 is sent. 11 The pending data sent to it, if the pending data sent to it is read within a predetermined period, continue to retain the data retention period, and if the pending data is not read within the predetermined period, end the data retention period.
  • step S208 the blockchain 11 sends the data D1 to be processed to the off-chain device 12.
  • node 1 After node 1 executes transaction 2 so that the state of session 1 becomes the open state, node 1 can start data processing through off-chain device 12 .
  • Node 1 sends transaction 3, in which transaction 3 calls the data sending function in communication contract C2 with data D1 and the identifier of off-chain device 12 as parameters.
  • Nodes in the blockchain execute transaction 3 after consensus on transaction 3, and deposit receipt 3 of transaction 3 after executing transaction 3.
  • the receipt 3 includes the identification of the communication contract C2, the identification of the off-chain device 12 and the data D1. Similar to the above reading receipt R1, the off-chain device 12 can read the receipt 3 and its Spv proof from the blockchain 11 through the client, verify the receipt 3, and obtain the data D1 and the communication contract C2 from the receipt 3. logo.
  • step S210 the off-chain device 12 sends the processing result of the data D1 to the blockchain 11.
  • the off-chain device 12 is, for example, a TEE device, in which a data processing program is preset and has its hardware private key and public key. After obtaining the identifiers of the data D1 and the communication contract C2, the off-chain device 12 uses the preset data processing program to process the data D1, thereby obtaining the processing result (processing result E1) of the data D1, and uses its hardware private key to process the data D1. The result E1 is digitally signed. After that, the off-chain device 12 sends transaction 4 to the blockchain 11, in which the result-returning function in the communication contract C2 is called with the processing result E1 and the TEE signature as incoming parameters. The hardware public key of the off-chain device 12 is preset in the result return function.
  • the node 1 in the blockchain 11 executes the transaction 4, it uses the hardware public key to verify the TEE signature, and the data D1 can be obtained after the verification is passed.
  • the contract C1 is called in the transaction 3 and the communication contract C2 is called in the contract C1 as shown in Fig. 1, the result return function in the communication contract C2 is called in the transaction 4, and the result E1 is processed in the function.
  • nodes such as node 2 in the blockchain 11 want to call the communication contract C2, similar to the node 1, they first query the session status between the communication contract C2 and the off-chain device 12 in the account status of the communication contract C2, When the status of the session 1 between the communication contract C2 and the off-chain device 12 is queried, the node 2 can send data to the off-chain device 12 similar to the node 1 (for example, the data D2 shown in FIG. 2 ). ) and receive the processing result E2 of the data D2.
  • step S212 the off-chain device 12 sends pre-shutdown information to the blockchain 11.
  • the off-chain device 12 sends a pre-close message for session 1 to the blockchain when predetermined conditions are met.
  • the predetermined condition is, for example, any one of the following: the off-chain device 12 has not received the data to be processed for a continuous predetermined length of time, and the blockchain 11 stores the request chain in the blockchain 11 by executing the communication contract C2.
  • the off-chain device 12 sends transaction 5 to the blockchain 11 through the client, and in the transaction 5 calls the close session function of the communication contract C2 to send a pre-close message to the blockchain 11 .
  • step S214 the blockchain 11 sends a shutdown message to the off-chain device 12.
  • the node in the blockchain 11 executes the transaction 5, it determines whether it has received all the messages or data sent by the off-chain device 12;
  • the state of session 1 in the account state in contract C2 is deleted (ie, session 1 is closed), or the state of session 1 is modified to the closed state, the execution of transaction 5 is ended, and receipt 5 is stored in blockchain 11.
  • the receipt 5 includes the account of the communication contract C2, the identification of the off-chain device 12 and the session close message (eg "CloseMsg").
  • the communication contract C2 can number the data sent each time.
  • the sent data are numbered as data D1 and data D2, and the off-chain device 12 also sends back corresponding numbers.
  • the data results of the blockchain are numbered, for example, the processing result of the data D1 is numbered as the processing result E1, and the processing result of the data D2 is numbered as the processing result E2.
  • the blockchain 11 can determine which data the processing result corresponds to based on the number of the received processing result.
  • the off-chain device 12 sends the pre-close message
  • the number of the last processing result (for example, "10") sent by it in transaction 5 can be used as a parameter to call the request to close the session function in the communication contract C2.
  • the transaction 5 When the transaction 5 is executed in 11, it is determined whether the processing result E1-processing result E10 has been received, thereby determining whether all the messages or data sent by the off-chain device 12 have been received.
  • the off-chain device 12 After the off-chain device 12 sends the pre-close message through transaction 5, it is possible that the pending data D11, data D12, etc. have been sent to the off-chain device 12 on the blockchain 11 side, and the transaction is executed At 5:00, these data numbers can also be recorded in the state of session 1 of the communication contract C2 for the user to query, or for processing when the session is opened next time.
  • the communication contract C2 and the off-chain device 12 are pre-configured: the off-chain device 12 closes the session after processing a predetermined number (eg, 20) of data.
  • a predetermined number eg, 20
  • a transaction that invokes contract C1, which invokes communication contract C2, is executed for data processing, for example, in the blockchain.
  • the off-chain device 12 returns the processing of the data by calling back the transaction of the communication contract C2, wherein the communication contract C2 returns the returned processing result to the contract C1 through the callback contract C1, and the contract C1 stores the processing result in the contract C1 after obtaining the processing result in the account status. Therefore, the blockchain node can determine whether to receive all the messages or data sent by the off-chain device 12 by querying the account status of the contract C1.
  • the off-chain device 12 After the off-chain device 12 reads the receipt 5 and its Spv certificate from the blockchain 11, it verifies the receipt 5, and obtains the account and "CloseMsg" of the communication contract C2 from the receipt 5, so as to correspond to the communication contract C2
  • the data retention period T1 is ended, that is, the communication data in the session 1 is deleted, thereby ending the session 1.
  • a receipt 5 is deposited in the blockchain, the receipt 5 including the account of the communication contract C2, the off-chain device 12 and the identifiers of the unreceived partial messages (such as message numbers), and modify the state of session 1 to the pre-closed state.
  • the off-chain device 12 After reading the receipt 5, the off-chain device 12 sends the transaction 6, in which the partial message is used as the incoming parameter to call the close session function of the communication contract C2, and the blockchain 11 receives the transaction 6 and After executing transaction 6, in the case of determining that all messages or data sent by the off-chain device 12 are received, delete the information of session 1 in the account state in the communication contract C2 (ie close session 1), or delete session 1's information.
  • the state is modified to a closed state, and a receipt 6 is deposited in the blockchain 11, which includes the account of the communication contract C2, the identification of the off-chain device 12, and a session close message (eg "CloseMsg").
  • the embodiment of this specification is not limited to this.
  • it can be performed on the blockchain 11 side by sending a transaction including a data field
  • a session identifier such as "session 1”
  • message content such as pre-opening message, pre-opening confirmation message, open message, Pending data, pre-close messages, close messages, etc.
  • the blockchain node can also create a session state database locally to record the state of each session similarly to the contract account state, so as to facilitate the query of the session state.
  • the node of the blockchain 11 needs to determine the session state between the blockchain 11 and the off-chain device 12, it is determined by querying the session state in the account state of the communication contract C2. It can be understood that, The embodiment of the present application is not limited to this, and the nodes in the blockchain 11 can also determine the status of the session 1 by querying the ledger data of the blockchain for the receipts of each transaction related to the session 1. For example, when the receipt of transaction 2 is queried in the ledger data, but the receipt that includes the pre-close message sent by the off-chain device 12 is not queried, it can be determined that the state of session 1 is the open state.
  • other statuses of session 1 may be determined based on the queried other transaction receipts related to session 1 . That is to say, in the solution of the embodiment of the present application, it is not necessary to record the state of the session 1 in the account state of the communication contract C2.
  • FIG. 3 is a communication apparatus 300 between a blockchain and off-chain devices according to an embodiment of the present specification.
  • the apparatus is deployed on a blockchain node and includes: a first execution unit 31 configured to execute a first execution unit 31.
  • the second execution unit 32 is configured to execute the
  • the second transaction sent by the off-chain device is used to provide the off-chain device with an opening message of the first session, and the second transaction includes confirmation information for the pre-opening message.
  • the first execution unit 31 is further configured to execute a first transaction to store the pre-opening message of the first session in the blockchain.
  • the first execution unit 31 is further configured to execute a first transaction, so as to record the state of the first session as a pre-opened state in the blockchain.
  • the first contract is invoked in the first transaction, wherein the first execution unit 31 is further configured to record the state of the first session in the account state of the first contract is pre-opened.
  • the first contract is invoked in the second transaction
  • the second execution unit 32 is further configured to execute the first contract invoked in the second transaction, so as to determine whether to The second transaction is executed within a first predetermined period of time, and in a case where it is determined that the second transaction is executed within the first predetermined period of time, an opening message of the first session is provided to the off-chain device.
  • the first execution unit 31 is further configured to end the first session if it is determined that the second transaction is executed after a first predetermined period of time.
  • the second execution unit 32 is further configured to modify the state of the first session to an open state.
  • the second execution unit 32 is further configured to store the opening message of the first session in the blockchain.
  • the apparatus 300 further includes a third execution unit 33 configured to, after providing the off-chain device with the opening message of the first session, execute a third transaction that invokes the first contract, where the The third transaction includes the pending first data, so that it is determined whether the state of the first session is an open state, and in the case of determining that the state of the first session is an open state, in the blockchain
  • the first data is stored in association with the first session.
  • the apparatus 300 further includes: a fourth execution unit 34 configured to execute a fourth transaction sent by the off-chain device, where the fourth transaction includes pre-closing information, so that: determining whether all messages sent by the off-chain device are received; in the case of determining that all messages sent by the off-chain device are received, providing the off-chain device with a close message of the first session.
  • a fourth execution unit 34 configured to execute a fourth transaction sent by the off-chain device, where the fourth transaction includes pre-closing information, so that: determining whether all messages sent by the off-chain device are received; in the case of determining that all messages sent by the off-chain device are received, providing the off-chain device with a close message of the first session.
  • the fourth execution unit 34 is further configured to modify the state of the first session to a closed state.
  • the fourth execution unit 34 is further configured to associate in the blockchain with the first session in the event that it is determined that a message sent at least in part by the off-chain device has not been received request information for requesting the off-chain device to resend the at least part of the message.
  • the fourth execution unit 34 is further configured to, in a case where it is determined that a message sent at least in part by the off-chain device has not been received, modify the state of the first session to pre-closed state.
  • FIG. 4 shows an apparatus 400 for communication between a blockchain and an off-chain device according to an embodiment of the present specification.
  • the apparatus is deployed in the off-chain device, and includes: a first obtaining unit 401 configured to:
  • the blockchain obtains a pre-opening message of a first session, where the first session is a session between the blockchain and the off-chain device;
  • the first sending unit 402 is configured to send a second transaction to the blockchain , the second transaction includes confirmation information for the pre-opening message;
  • the opening unit 403 is configured to open the data retention period of the first session.
  • the first sending unit 402 is further configured to send the second transaction to the blockchain within a first predetermined period of time.
  • the apparatus 400 further includes a determining unit 404 configured to, after the data retention period is enabled, determine whether to obtain the opening of the first session from the blockchain within a second predetermined period of time message, the first ending unit 405 is configured to end the data retention period in the case that the opening message of the first session is not obtained from the blockchain within a second predetermined period of time.
  • the apparatus 400 further includes a second sending unit 406 configured to, when a preset condition is met, send a fourth transaction to the blockchain, where the fourth transaction includes the first transaction Pre-close information for a session.
  • the apparatus 400 further includes a second obtaining unit 407 configured to, after sending the fourth transaction to the blockchain, obtain the closure of the first session from the blockchain message; and a second ending unit 408, configured to end the data retention period.
  • the apparatus further includes a third obtaining unit 409, configured to, after sending the fourth transaction to the blockchain, obtain from the blockchain a pair of the sent first transaction A request message for at least part of the messages in the session; the third sending unit 410 is configured to send a fifth transaction to the blockchain, where the fifth transaction includes the at least part of the 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 methods.
  • Another aspect of the present specification provides a computing device, including a memory and a processor, where a computer program is stored in the memory, and the processor implements any one of the above methods when executing the computer program.
  • the session can be opened after both the blockchain and the off-chain device confirm the channel, and the off-chain device guarantees the session during the session opening.
  • the data retention period ensures secure two-way communication between the blockchain and off-chain devices.
  • by using a smart contract in the blockchain to conduct a session with an off-chain device, and recording the session status in the account status of the smart contract it is convenient for each node to query the session status, and Communication with off-chain devices can be done based on session state.
  • 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

  • Business, Economics & Management (AREA)
  • Engineering & Computer Science (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • General Business, Economics & Management (AREA)
  • Signal Processing (AREA)
  • Strategic Management (AREA)
  • Physics & Mathematics (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Technology Law (AREA)
  • Computer And Data Communications (AREA)

Abstract

Les modes de réalisation de la présente invention concernent un procédé et un appareil de communication entre une chaîne de blocs et un dispositif hors chaîne. Le procédé est exécuté par un nœud de chaîne de blocs et comprend les étapes suivantes : exécution d'une première transaction de manière à fournir à un dispositif hors chaîne un message de pré-validation d'une première session, la première session étant une session entre une chaîne de blocs et le dispositif hors chaîne ; et exécution d'une seconde transaction envoyée par le dispositif hors chaîne de façon à fournir au dispositif hors chaîne un message de validation de la première session, la seconde transaction comprenant des informations d'accusé de réception pour le message de pré-validation.
PCT/CN2021/133008 2021-03-30 2021-11-25 Procédé et appareil de communication entre une chaîne de blocs et un dispositif hors chaîne WO2022205956A1 (fr)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110340111.7 2021-03-30
CN202110340111.7A CN112738280B (zh) 2021-03-30 2021-03-30 一种用于区块链与链下设备之间的通信方法和装置

Publications (1)

Publication Number Publication Date
WO2022205956A1 true WO2022205956A1 (fr) 2022-10-06

Family

ID=75596143

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/133008 WO2022205956A1 (fr) 2021-03-30 2021-11-25 Procédé et appareil de communication entre une chaîne de blocs et un dispositif hors chaîne

Country Status (2)

Country Link
CN (2) CN113691633A (fr)
WO (1) WO2022205956A1 (fr)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113691633A (zh) * 2021-03-30 2021-11-23 支付宝(杭州)信息技术有限公司 一种用于区块链与链下设备之间的通信方法和装置

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109670335A (zh) * 2018-12-20 2019-04-23 众安信息技术服务有限公司 用于在区块链与链外数据之间进行交互的方法及装置
CN110933125A (zh) * 2018-09-19 2020-03-27 英飞凌科技股份有限公司 区块链实体、链下实体、认证设备及用于执行协作的方法
US20200344042A1 (en) * 2019-04-24 2020-10-29 International Trust Machines Corporation Verification system and method for cooperating with blockchain and off-chain devices
CN112202715A (zh) * 2020-08-31 2021-01-08 北京锐格信安技术有限公司 一种物联网与区块链可信交互的系统、方法及装置
CN112738280A (zh) * 2021-03-30 2021-04-30 支付宝(杭州)信息技术有限公司 一种用于区块链与链下设备之间的通信方法和装置

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110210845B (zh) * 2019-06-11 2021-06-18 网易(杭州)网络有限公司 用于区块链数据迁移的方法、装置、介质和计算设备
CN110378690B (zh) * 2019-06-13 2022-05-27 北京航空航天大学 一种基于匿名安全支付通道的交易方法及装置
CN111047450A (zh) * 2020-03-18 2020-04-21 支付宝(杭州)信息技术有限公司 链上数据的链下隐私计算方法及装置

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110933125A (zh) * 2018-09-19 2020-03-27 英飞凌科技股份有限公司 区块链实体、链下实体、认证设备及用于执行协作的方法
CN109670335A (zh) * 2018-12-20 2019-04-23 众安信息技术服务有限公司 用于在区块链与链外数据之间进行交互的方法及装置
US20200344042A1 (en) * 2019-04-24 2020-10-29 International Trust Machines Corporation Verification system and method for cooperating with blockchain and off-chain devices
CN112202715A (zh) * 2020-08-31 2021-01-08 北京锐格信安技术有限公司 一种物联网与区块链可信交互的系统、方法及装置
CN112738280A (zh) * 2021-03-30 2021-04-30 支付宝(杭州)信息技术有限公司 一种用于区块链与链下设备之间的通信方法和装置

Also Published As

Publication number Publication date
CN112738280B (zh) 2021-07-23
CN113691633A (zh) 2021-11-23
CN112738280A (zh) 2021-04-30

Similar Documents

Publication Publication Date Title
WO2020258846A1 (fr) Procédé et appareil d'envoi de messages certifiables entre chaînes
TWI733328B (zh) 跨鏈發送可認證訊息的方法和裝置
EP3627797B1 (fr) Manicodage pour une vérification d'accès
US10824701B2 (en) System and method for mapping decentralized identifiers to real-world entities
TW202101440A (zh) 跨鏈發送資源的方法和裝置
US11422981B2 (en) Information management and access control in a database
WO2021184970A1 (fr) Procédé et dispositif pour un appel de contrat
US11429967B2 (en) Mechanism for efficient validation of finality proof in lightweight distributed ledger clients
WO2019042101A1 (fr) Procédé et appareil de trading cross-chaînes
US8572710B2 (en) Pluggable token provider model to implement authentication across multiple web services
WO2021203853A1 (fr) Procédé, dispositif, appareil et support de génération de clés
CN110311781A (zh) 提供微服务信息
JP2005312026A (ja) セッション開始プロトコルルーティングヘッダに対して署名および検証を行う方法
CN113114476B (zh) 基于合约的隐私存证方法及装置
CN111640017A (zh) 一种应用于联盟链跨链转账的交易正确性验证方法及装置
WO2021184877A1 (fr) Procédé de gestion de nœuds pour un système de chaîne de blocs, nœuds et dispositif informatique
CN113364735A (zh) 多链场景下数据跨链访问控制方法、系统、设备及终端
WO2022205956A1 (fr) Procédé et appareil de communication entre une chaîne de blocs et un dispositif hors chaîne
WO2022078398A1 (fr) Procédé et système de traitement de transaction de sous-compte à base de chaîne de blocs, dispositif et support
WO2020037927A1 (fr) Procédé de transaction de chaîne de blocs négociable, appareil, dispositif et support d'informations
CN111127206A (zh) 一种基于智能合约的区块链数据访问控制方法及装置
WO2022206438A1 (fr) Procédé et appareil pour fournir un message inter-chaînes
WO2022206439A1 (fr) Procédé et appareil pour fournir un message à chaîne transversale
WO2023124746A1 (fr) Commande d'autorisation d'interaction inter-sous-réseau
CN113923228A (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: 21934592

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

Country of ref document: EP

Kind code of ref document: A1