WO2022206430A1 - Method and apparatus for processing bill data by using off-chain trusted device - Google Patents

Method and apparatus for processing bill data by using off-chain trusted device Download PDF

Info

Publication number
WO2022206430A1
WO2022206430A1 PCT/CN2022/081699 CN2022081699W WO2022206430A1 WO 2022206430 A1 WO2022206430 A1 WO 2022206430A1 CN 2022081699 W CN2022081699 W CN 2022081699W WO 2022206430 A1 WO2022206430 A1 WO 2022206430A1
Authority
WO
WIPO (PCT)
Prior art keywords
ticket
transaction
chain
contract
identifier
Prior art date
Application number
PCT/CN2022/081699
Other languages
French (fr)
Chinese (zh)
Inventor
邱鸿霖
闫莺
张辉
Original Assignee
支付宝(杭州)信息技术有限公司
蚂蚁区块链科技(上海)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 支付宝(杭州)信息技术有限公司, 蚂蚁区块链科技(上海)有限公司 filed Critical 支付宝(杭州)信息技术有限公司
Publication of WO2022206430A1 publication Critical patent/WO2022206430A1/en

Links

Images

Classifications

    • 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/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network

Definitions

  • the embodiments of this specification relate to the technical field of blockchain, and more particularly, to a method and apparatus for processing bill data using an off-chain trusted 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. Due to the above-mentioned characteristics of the blockchain, the blockchain can be developed into an invoice chain, for example, for the invoicing and circulation business of invoices.
  • invoice chain architecture all invoicing operations are carried out through smart contracts deployed in the blockchain, which is limited by the performance of blockchain smart contract execution, resulting in limited invoicing throughput of the invoice business, which is difficult to expand. Business demands may not be met during peak business hours (eg, Double Eleven). Therefore, there is a need for a more efficient ticket processing scheme.
  • the embodiments of this specification aim to provide a more effective solution for using off-chain trusted devices to process bill data, so as to solve the deficiencies in the prior art.
  • one aspect of this specification provides a method for processing bill data using an off-chain trusted device, the method being executed by a blockchain node, including: executing a first transaction, where the first transaction includes at least A ticket identifier for assigning the at least one ticket identifier to the first off-chain trusted device; executing a second transaction sent by the first off-chain trusted device, the second transaction including The at least one bill identifies the corresponding at least one bill, so as to obtain the at least one bill.
  • executing the first transaction includes executing the first transaction such that at least one ticket identification associated with the first off-chain trusted device is deposited in the blockchain.
  • the first contract is invoked in the first transaction, and bill information corresponding to each bill identifier is recorded in the account status of the first contract, wherein executing the first transaction includes executing the first contract. contract such that the assignment of the at least one ticket identification is recorded in the account state of the first contract.
  • executing the first transaction further includes executing the first contract, so that the at least one ticket identifier is allocated to the first off-chain trusted device among the plurality of off-chain trusted devices.
  • allocating the at least one ticket identifier to a first off-chain trusted device among the multiple off-chain trusted devices includes, based on a value range corresponding to the at least one ticket identifier, assigning the at least one off-chain trusted device.
  • a ticket identifier is allocated to the first off-chain trusted device among the multiple off-chain trusted devices.
  • allocating the at least one ticket identifier to the first off-chain trusted device among the multiple off-chain trusted devices includes, based on the identifier of the invoicing subject corresponding to the at least one ticket identifier, assigning all the off-chain trusted devices.
  • the at least one ticket identifier is allocated to a first off-chain trusted device among the multiple off-chain trusted devices.
  • invoking the first contract in the second transaction, and executing the second transaction sent by the trusted device off the first chain further includes executing the first contract, so that when obtaining After the at least one bill, the at least one bill is stored in the bill information of the corresponding bill identifier in the account state of the first contract.
  • the method further includes, after executing the second transaction, executing a third transaction, in which the first contract is called in the third transaction, so that the waiting period is determined based on the ticket information identified by each ticket.
  • the allocation information is deleted from the ticket information of the first ticket identifier.
  • a second contract is invoked in the second transaction, and the first contract is invoked in the second contract, wherein executing the second transaction sent by the trusted device off the first chain also further Including, executing the second contract such that the at least one ticket is verified, and the verified at least one ticket is provided to the first contract.
  • the first off-chain trusted device is a TEE device
  • the second transaction further includes a signature of the TEE device on the at least one ticket, wherein the at least one ticket is signed
  • the verification includes using the preset public key of the TEE device to verify the signature.
  • Another aspect of this specification provides a method for processing bill data using an off-chain trusted device, the method being performed by a first off-chain trusted device, including: obtaining from a blockchain and assigning it to the first off-chain trusted device obtain at least one bill information corresponding to the at least one bill identification; generate at least one bill corresponding to the at least one bill identification based on the at least one bill information; send to the blockchain A second transaction is sent, the second transaction including the at least one ticket.
  • the first off-chain trusted device is a TEE device
  • the second transaction further includes a signature of the TEE device on the at least one ticket.
  • Another aspect of this specification provides an apparatus for processing bill data using an off-chain trusted device, the apparatus is deployed on a blockchain node, and includes: a first execution unit configured to execute a first transaction, the first The transaction includes at least one ticket identifier for assigning the at least one ticket identifier to the first off-chain trusted device; the second execution unit is configured to execute the first off-chain trusted device sent by the first off-chain trusted device. Second transaction, the second transaction includes at least one bill corresponding to the at least one bill identifier, so as to obtain the at least one bill.
  • the first execution unit is further configured to execute the first transaction so that at least one ticket identifier associated with the trusted device under the first chain is stored in the blockchain.
  • a first contract is invoked in the first transaction, and bill information corresponding to each bill identifier is recorded in the account status of the first contract, wherein the first execution unit is further configured to execute the first contract such that the assignment of the at least one ticket identifier is recorded in the account state of the first contract.
  • the first execution unit is further configured to execute the first contract, so that the at least one ticket identifier is allocated to the first off-chain trusted device among the multiple off-chain trusted devices equipment.
  • the first execution unit is further configured to, based on the value range corresponding to the at least one ticket identifier, assign the at least one ticket identifier to the first chain among the multiple off-chain trusted devices under Trusted Devices.
  • the first execution unit is further configured to, based on the identifier of the invoicing subject corresponding to the at least one ticket identifier, assign the at least one ticket identifier to the first one of the multiple off-chain trusted devices An off-chain trusted device.
  • the first contract is invoked in the second transaction, and the second execution unit is further configured to execute the first contract, so that after acquiring the at least one ticket, all The at least one bill is stored in the bill information of the corresponding bill identifier in the account state of the first contract.
  • the apparatus further includes a third execution unit configured to, after executing the second transaction, execute a third transaction, in which the first contract is invoked, so that based on each The ticket information of the ticket identifier is determined, the first ticket identifier waiting to be processed by the trusted device under the first chain is determined, and the allocation information is deleted from the ticket information of the first ticket identifier.
  • a third execution unit configured to, after executing the second transaction, execute a third transaction, in which the first contract is invoked, so that based on each The ticket information of the ticket identifier is determined, the first ticket identifier waiting to be processed by the trusted device under the first chain is determined, and the allocation information is deleted from the ticket information of the first ticket identifier.
  • the second contract is invoked in the second transaction, and the first contract is invoked in the second contract, wherein the second execution unit is further configured to execute the second contract,
  • the verified at least one ticket is provided to the first contract so that the at least one ticket is verified.
  • the first off-chain trusted device is a TEE device
  • the second transaction further includes a signature of the TEE device on the at least one ticket
  • the second execution unit further It is configured to use the preset public key of the TEE device to verify the signature.
  • Another aspect of this specification provides a device for processing bill data using an off-chain trusted device, the device is deployed on a first off-chain trusted device, and includes: a first obtaining unit configured to obtain distribution from the blockchain at least one ticket identifier for the trusted device under the first chain; a second acquiring unit, configured to acquire at least one ticket information corresponding to the at least one ticket identifier; a generating unit, configured to, based on the at least one ticket The information generates at least one ticket corresponding to the at least one ticket identifier; the sending unit is configured to send a second transaction to the blockchain, where the second transaction includes the at least one ticket.
  • the first off-chain trusted device is a TEE device
  • the second transaction further includes a signature of the TEE device on the at least one ticket.
  • 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 main chain can be dynamically expanded through the devices under the chain, so as to meet the business needs during peak business hours; Record the bill information in the account status of the contract, so that the user, the main invoice chain and the off-chain device can coordinate the bill processing based on the bill information; Writing multiple tickets to the main invoice chain at one time before disconnection can greatly reduce the number of transactions on the main invoice chain, thereby improving the overall business throughput.
  • FIG. 1 shows a schematic diagram of an invoicing system according to an embodiment of the present specification
  • FIG. 2 shows a flowchart of a method for invoicing through an off-chain device according to an embodiment of the present specification
  • FIG. 3 shows a schematic diagram of transaction 1 (Tx1) according to an embodiment of the present specification
  • Figure 4 shows a table of invoice information including respective invoice numbers recorded in the account status of the main contract C1;
  • FIG. 5 shows a schematic diagram of transaction 2 (Tx2) according to an embodiment of the present specification
  • FIG. 6 shows a schematic diagram of transaction 3 (Tx3) according to an embodiment of the present specification
  • FIG. 7 shows an apparatus 700 for using off-chain trusted devices to process ticket data according to an embodiment of the present specification
  • Fig. 8 shows an apparatus 800 for processing ticket data using an off-chain trusted device according to an embodiment of the present specification.
  • FIG. 1 shows a schematic diagram of an invoicing system according to an embodiment of the present specification.
  • the invoicing system includes an invoice chain 11 , an off-chain device cluster 12 , and a user terminal 13 .
  • the invoice chain 11 is, for example, a consortium chain, in which the main contract C1 (the contract name is "Main", for example) and the communication contract C2 (the contract name is "Layer2", for example) are deployed.
  • the main contract C1 is a contract for invoicing, which includes, for example, a ticket number function (Num()), a ticket distribution function (Assign()), an invoicing function (Invoice()), and a receiving function (Receipt()) and a check function (Check()).
  • the communication contract C2 is used to send the pending invoice number segment to the off-chain device cluster 12, which includes, for example, a data sending function (Data()), a result returning function (Result()), and a disconnecting function (Close() . )).
  • the main contract C1 can use the off-chain device for billing by calling the communication contract C2.
  • the off-chain device cluster 12 includes a plurality of off-chain trusted devices for invoicing.
  • the off-chain trusted devices include, for example, a Trusted Execution Environment (TEE) and the client of the invoice chain is set in the trusted off-chain device.
  • TEE Trusted Execution Environment
  • device D1 can read the ledger data (such as transactions, receipts, account status, etc.) and its proof data (such as Spv proof) in the invoice chain from any node of the invoice chain through its client, and verify the ledger data, thereby Ensure the credibility of the ledger data.
  • ledger data such as transactions, receipts, account status, etc.
  • proof data such as Spv proof
  • the device D1 After acquiring the invoice number segment assigned to it based on the acquired ledger data, the device D1 can receive a plurality of invoice information corresponding to the invoice number segment from the user terminal 13, and generate a plurality of invoice information corresponding to the number segment based on the plurality of invoice information. , digitally sign the issued multiple invoices using its hardware private key, and provide the multiple invoices and digital signatures to the invoice chain 11 by sending a transaction to the invoice chain 11 . After obtaining the multiple invoices and digital signatures issued from the device D1, the invoice chain 11 can verify the above digital signatures through the pre-stored hardware public key of the device D1, so as to ensure the credibility of the invoice, and obtain the invoice and store it in the invoice. chain 11.
  • the user terminal 13 is, for example, a terminal device of the merchant 1, in which the client terminal of the invoice chain is set.
  • merchant 1 applies for the invoice number segment (for example, invoice number 1-500) in the invoice chain by sending a transaction to the invoice chain node (for example, node P1) in advance.
  • the invoice chain node for example, node P1
  • the transaction for example, calling The Num() function in the main contract C1, thereby causing the transaction to send the invoice number segment 1-500 to Merchant 1 when the transaction is executed.
  • the merchant corresponding to each ticket number can be recorded in the account status of the main contract C1, as shown in FIG. 4 which will be described below.
  • Nodes in the invoice chain 11 can set the invoice number segment to be processed by the off-chain device by sending a transaction, for example, by calling the Assign() function in the main contract C1 in the transaction, and assigning the predetermined invoice number segment (eg, invoice number 1- 1000) is allocated to the off-chain device for processing, and the information is recorded in the account status of the main contract C1.
  • the predetermined invoice number segment eg, invoice number 1- 1000
  • the merchant 1 When the merchant 1 wishes to issue an invoice for a certain invoice number through the invoice chain 11, it queries the account status of the main contract C1 to determine whether the invoice number is issued by the invoice chain 11 or the off-chain device. If it is determined based on the account status of the main contract C1 that the invoice chain 11 issues the invoice, the invoice chain 11 can issue the invoice by sending a transaction calling the Invoice() function of the main contract C1. If it is determined that the device D1 is issued based on the account status of the main contract C1, the device D1 can be connected through the interface of the device D1 provided by the invoice chain 11 to issue the invoice through the device D1.
  • the device D1 After the device D1 issues an invoice, it can send a transaction to the invoice chain 11 through its client, wherein in the transaction, the communication contract C2 is called with at least one invoice as an incoming parameter, and the main contract C1 is called in the communication contract C2, so that the At least one invoice is provided to the main contract C1 in the invoice chain 11 .
  • the main contract C1 After acquiring the at least one invoice, the main contract C1 can deposit the at least one invoice into its account status for use in the subsequent invoice business.
  • FIG. 2 shows a flowchart of a method for invoicing through an off-chain device according to an embodiment of the present specification.
  • the method is executed jointly by the node P2 in the invoice chain 11 and the off-chain device D1, for example.
  • the main contract C1 in the invoice chain 11 can issue invoices by itself, and can also issue invoices through off-chain devices by invoking the communication contract C2.
  • the invoice chain 11 can use the off-chain device for billing processing by opening the connection with the off-chain device (for example, the connection with the off-chain device D1) during peak business hours, so that a faster bill processing speed can be achieved.
  • the transaction volume drops, and the invoice chain 11 itself can execute each transaction and complete the invoicing in a timely manner, that is, the off-chain equipment is no longer required, and thus the use of the off-chain equipment can be terminated.
  • the individual steps in the method will be described in detail below.
  • step S202 node P2 locks the invoice number segment (eg, 1-1000) by executing transaction 1.
  • Invoice Chain 11 can set the use of off-chain device clusters based on business peak hours. For example, for the Double Eleven period, it can be set to open the connection with each device in the off-chain device cluster before 0:00 on November 11, and on November 11. The said connection is disconnected at 24:00 on May 11 to end the use of the off-chain device.
  • FIG. 3 shows a schematic diagram of transaction 1 (Tx1) according to an embodiment of the present specification.
  • the transaction 1 is sent by the node P1, which calls the dispatch function (Assign(a, b)) in the main contract C1 (Main), where a is the starting number parameter of the invoice number segment, and b is the invoice
  • the last number parameter of the number segment is called with "1,1000" as the incoming parameter when calling the ticket dispatch function, which means that 1 is assigned to a and 1000 is assigned to b.
  • the node P2 When executing the Assign function in the main contract C1 in the transaction 1, the node P2 first allocates the invoice number 1-1000 to multiple off-chain devices according to a predetermined allocation rule.
  • the predetermined allocation rule is to allocate based on the range of the invoice number segment of the invoice, for example, assign the ticket with the value after the invoice number modulo 100 less than 20 to the device D1, and assign the value after the invoice number modulo 100 to the device D1. Between 20-40 tickets are allocated to device D2 and so on.
  • the predetermined allocation rule is based on the merchant name of the invoice (that is, the invoicing unit). The invoice number corresponding to the invoicing unit of the flow is assigned to device D2, and so on. It can be understood that the allocation rules are not limited to the above two allocation rules, and can also be allocated based on the invoice number based on other algorithms, or can also be allocated based on other fields in the invoice (such as commodity names, etc.), which are not limited here.
  • FIG. 4 shows a table of invoice information including respective invoice numbers recorded in the account status of the main contract C1.
  • the invoice chain 11 may record in the table shown in FIG. 4 : the merchant with the invoice number 1-500 is the merchant 1 (User1 ), it is also recorded in FIG. 4 that the merchant corresponding to the invoice number 501-1000 is merchant 2 (User2).
  • the Assign function of the main contract C1 it is set that the corresponding merchant based on the invoice number will be allocated to the off-chain device.
  • the invoice number of 2 is assigned to device D2.
  • the merchants corresponding to the invoice numbers 1-1000 are first determined based on the table shown in FIG. After 1000 corresponds to Merchant 2, assign invoice numbers 1-500 to Device D1 (Device1), assign invoice numbers 501-1000 to Device D2 (Device2), and check each item in the invoice status in the table shown in Figure 4.
  • the invoice number is recorded with the corresponding device identifier to indicate that the invoice number is waiting for the corresponding off-chain device to issue, that is, these invoice numbers are locked so that the invoice chain 11 will not issue the invoices corresponding to these invoice numbers. .
  • the invoice status corresponding to the invoice number 1001 is the invoice with the invoice number 1001 that has been issued, which means that the invoice has been issued by the invoice chain 11 or the off-chain device, and the invoice status corresponding to the invoice number 1002 is empty. Indicates that the invoice corresponding to the invoice number will be issued by the invoice chain 11 itself.
  • step S204 the node P2 sends the dispatch information for the invoice number segment (eg 1-500) to the device D1 when the transaction 1 is executed.
  • the invoice number segment eg 1-500
  • the data sending function (Data()) in the communication contract C2 is called in the main contract C1 in the transaction 1 with, for example, the device D1 identification and the invoice number segment 1-500 as incoming parameters.
  • node P2 executes transaction 1, after modifying the account status of the main contract C1 as described above, it executes the communication contract C2, thereby storing the data in the blockchain 11 (that is, the ledger data of the blockchain 11 local to the node P2).
  • Receipt 1 of transaction 1, in which receipt 1 may include the account address of communication contract C2, the identification of device D1 and the invoice number field 1-500.
  • the device D1 can monitor the receipt in the invoice chain 11 including the account address of the communication contract C2 and the identification of the device D1, so that the information sent to it can be read from the invoice chain 11. For example, after reading receipt 1 and its proof data (eg Spv proof) from the invoice chain 11, the device D1 verifies the receipt 1 through the proof data, and then can read the invoice number segment 1-500 from the receipt 1, thereby It can be determined that the invoice chain 11 has assigned the invoice number segment 1-500 to the device D1.
  • proof data eg Spv proof
  • the device D1 obtains the invoice number segment assigned to it by reading the receipt 1
  • the embodiment of the present specification is not limited thereto.
  • the device D1 can query the invoice number segment assigned to it from the table shown in FIG. 4 by reading the account status of the main contract C1.
  • the information is sent to the device D1 by invoking the communication contract C2
  • this specification is not limited to this, and the information can be sent to the device D1 by any known means of sending information outside the chain, for example, it can be By executing a transaction that does not invoke the communication contract C2, a receipt including the identification of the device D1 and the assigned invoice number segment is deposited in the invoice chain 11 to send information to the device D1.
  • step S206 the device D1 generates an invoice 1-400.
  • the merchant 1 after the merchant 1 receives the invoice number segment from the invoice chain 11, when it needs to issue an invoice for, for example, the invoice number 1, the merchant 1 first queries the invoice number 1 in the blockchain 11 through its user terminal 13.
  • the invoice status of that is, the account status of the main contract C1 is queried in the table shown in Figure 4, for example.
  • the user terminal 13 After determining that the invoice status of the invoice number 1 is "Device1", the user terminal 13 connects to the connection interface provided by the invoice chain 11 to the device D1, thereby connecting with the device D1.
  • the user terminal 13 After establishing the connection with the device D1, the user terminal 13 sends the invoice information of the invoice number 1 to the device D1, which includes, for example, the invoice number, customer name, commodity name, and merchant name and other information.
  • the device D1 After receiving the invoice information with the invoice number "1", the device D1 determines that the invoice number 1 is allocated to it by the invoice chain 11 for issuing, and then issues an invoice with the invoice number 1 based on the invoice information received from the user terminal 13. By the same process, device D1 issues, for example, invoice 1-400 before disconnecting from invoice chain 11 .
  • step S208 device D1 sends transaction 2 to send invoice 1 - invoice 400 to invoice chain 11 .
  • the device D1 After generating each of the invoices 1-400, the device D1 does not send each invoice back to the invoice chain 11 separately by sending a plurality of transactions, but can pass a transaction before the connection with the invoice chain 11 is disconnected.
  • 400 invoices are provided to the invoice chain 11 at once through only 1 transaction, compared to sending 400 transactions back to the invoice chain 11 separately, which greatly reduces the number of invoices
  • the number of transactions executed on the chain greatly improves the overall processing speed in the invoice chain.
  • each off-chain device determines before 24:00 on November 11 to stop invoicing after invoicing 400, and sends transaction 2 to invoice chain 11 (eg, node P2) to send invoices 1-400 processed by it to invoice chain 11 .
  • invoice chain 11 eg, node P2
  • FIG. 5 shows a schematic diagram of transaction 2 (Tx2) according to an embodiment of the present specification.
  • transaction 2 is sent by device D1 (Device1), which calls the result return function (Result()) in communication contract C2 (Layer2), and the return parameter to Result() is the invoice issued by device D1 1-400.
  • Device D1 Device1
  • Result() result return function
  • Communication contract C2 Layer2
  • node P2 executes transaction 2 to locally deposit invoice 1-400.
  • the node P2 in the invoice chain 11 executes the result return function in the communication contract C2 when executing the above transaction 2 sent by the device D1.
  • the result returning function includes a call to the receiving function (Receipt()) in the main contract C1, so that when Result() is executed, the Receipt() function in the main contract C1 is executed with the invoice 1-400 as the incoming parameter.
  • the Receipt() function is executed, in the table shown in Figure 4 in the account status in the main contract C1, the corresponding invoice is stored in the invoice status of the corresponding invoice number, for example, the invoice 1 is stored in the invoice number 1 in the invoice status.
  • step S212 the device D1 sends transaction 3 to send connection pre-close information.
  • the device D1 may send the connection pre-close message by sending transaction 3.
  • FIG. 6 shows a schematic diagram of transaction 3 (Tx3) according to an embodiment of the present specification.
  • transaction 3 is sent by device D1, and the disconnection function (Close()) in communication contract C2 (Layer2) is called.
  • the disconnection function includes parameters c and d, where parameter c is device D1
  • the starting number of the number segment of the invoice issued the parameter d is the end number of the number segment of the invoice issued by the device D1
  • the parameter "1" passed in to this function means assigning 1 to c
  • the parameter "400” means assigning value to d 400.
  • step S214 node P2 executes transaction 3 to determine whether all invoices sent by device D1 are received.
  • the communication contract C2 (Layer2) includes a call to the Check() function in the main contract C1 with the parameters c and d as the incoming parameters. Therefore, when the transaction 3 is executed, the main contract C1 is executed with 1 and 400 as the incoming parameters.
  • Check() function in .
  • the Check() function query the table shown in Figure 4 in the account status of the main contract C1, and determine whether the invoice status of each invoice number 1-400 has been stored in the issued invoice, if so, then It is determined that all the invoices sent by the device D1 have been received, and if the invoice status of at least one invoice number in the invoice numbers 1-400 is still "Device1", it is determined that all the invoices sent by the device D1 have not been received.
  • node P2 may re-receive said unreceived invoices from device D1 by sending a transaction to device D1 as described above by sending the invoice number of the unreceived invoice to device D1 bill.
  • step S216 when the node P2 executes the transaction 3, it also unlocks the invoice status of the uninvoiced invoice number.
  • the node P2 executes the Check function in the above-mentioned main contract C1
  • it can also determine that the invoice numbers 401-500 are the invoice numbers assigned to the device D1 but have not been processed based on the parameters 1 and 400 and the table shown in FIG. 4, so that the main The "Device1" in the invoice status of the invoice numbers 401-500 in the table shown in Figure 4 in the account status of the contract C1 is deleted, that is, the lock on the invoice numbers 401-500 is released, so that the invoice chain 11 can itself
  • the issuance of invoices 401-500 is carried out.
  • the node P2 can send the closing information to the device D1 by sending a transaction, so that the connection between the device D1 and the invoice chain 11 is disconnected, that is, the invoice chain 11 ends the use of the device D1.
  • the invoice chain 11 can dispatch and receive invoices from the devices D2 and D3 shown in Figure 1 in the same way.
  • FIG. 7 shows an apparatus 700 for using off-chain trusted devices to process ticket data according to an embodiment of the present specification.
  • the apparatus is deployed on a blockchain node, including:
  • the first execution unit 71 is configured to execute a first transaction, where the first transaction includes at least one ticket identifier, so as to assign the at least one ticket identifier to the first off-chain trusted device;
  • the second execution unit 72 is configured to execute a second transaction sent by the first off-chain trusted device, where the second transaction includes at least one ticket corresponding to the at least one ticket identifier, so as to obtain the at least one ticket.
  • the first execution unit 71 is further configured to execute the first transaction so that at least one ticket identifier associated with the trusted device under the first chain is stored in the blockchain.
  • the first contract is invoked in the first transaction, and bill information corresponding to each bill identifier is recorded in the account status of the first contract, wherein the first execution unit 71 is further configured to: The first contract is executed such that the assignment of the at least one ticket identification is recorded in the account state of the first contract.
  • the first execution unit 71 is further configured to execute the first contract, so that the at least one ticket identifier is allocated to the first off-chain executable among the multiple off-chain trusted devices letter equipment.
  • the first execution unit 71 is further configured to, based on the value range corresponding to the at least one ticket identifier, assign the at least one ticket identifier to the first one of the multiple off-chain trusted devices Off-chain trusted devices.
  • the first execution unit 71 is further configured to, based on the identifier of the invoicing subject corresponding to the at least one ticket identifier, assign the at least one ticket identifier to a plurality of off-chain trusted devices Trusted devices off the first chain.
  • the first contract is invoked in the second transaction
  • the second execution unit 72 is further configured to execute the first contract, so that after acquiring the at least one ticket, execute the The at least one bill is stored in the bill information of the corresponding bill identifier in the account state of the first contract.
  • the apparatus 700 further includes a third execution unit 73 configured to, after executing the second transaction, execute a third transaction, where the first contract is invoked in the third transaction, so that the Based on the ticket information of each ticket identifier, a first ticket identifier waiting to be processed by the first off-chain trusted device is determined, and allocation information is deleted from the ticket information of the first ticket identifier.
  • a third execution unit 73 configured to, after executing the second transaction, execute a third transaction, where the first contract is invoked in the third transaction, so that the Based on the ticket information of each ticket identifier, a first ticket identifier waiting to be processed by the first off-chain trusted device is determined, and allocation information is deleted from the ticket information of the first ticket identifier.
  • the second contract is invoked in the second transaction, and the first contract is invoked in the second contract, wherein the second execution unit 72 is further configured to execute the second contract , so that the at least one ticket is verified, and the verified at least one ticket is provided to the first contract.
  • the first off-chain trusted device is a TEE device
  • the second transaction further includes a signature of the TEE device on the at least one ticket, wherein the second execution unit 72 It is also configured to use the preset public key of the TEE device to verify the signature.
  • FIG. 8 shows an apparatus 800 for processing ticket data using an off-chain trusted device according to an embodiment of the present specification.
  • the apparatus is deployed in a first off-chain trusted device, and includes: a first obtaining unit 81 configured to: Acquire at least one ticket identifier assigned to the trusted device under the first chain from the blockchain; the second acquiring unit 82 is configured to acquire at least one ticket information corresponding to the at least one ticket identifier respectively; the generating unit 83 is configured to to generate at least one ticket corresponding to the at least one ticket identifier based on the at least one ticket information; the sending unit 84 is configured to send a second transaction to the blockchain, where the second transaction includes all at least one ticket.
  • the first off-chain trusted device is a TEE device
  • the second transaction further includes a signature of the TEE device on the at least one ticket.
  • 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 comprising a memory and a processor, wherein a computer program is stored in the memory, and the processor implements any one of the above methods when executing the computer program.
  • the main chain can be dynamically expanded through the devices under the chain, so as to meet the business needs during peak business hours; Record the bill information in the account status of the contract, so that the user, the main invoice chain and the off-chain device can coordinate the bill processing based on the bill information; Writing multiple tickets to the main invoice chain at one time before disconnection can greatly reduce the number of transactions on the main invoice chain, thereby improving the overall business throughput.
  • 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)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • Marketing (AREA)
  • Signal Processing (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Computer Networks & Wireless Communication (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

The embodiments of the present specification provide a method and apparatus for processing bill data by using an off-chain trusted device. The method is executed by a blockchain node and comprises: executing a first transaction, the first transaction comprising at least one bill identifier, so as to allocate the at least one bill identifier to a first off-chain trusted device; and executing a second transaction sent by the first off-chain trusted device, the second transaction comprising at least one bill respectively corresponding to the at least one bill identifier, so as to acquire the at least one bill.

Description

使用链下可信设备进行票据数据处理的方法和装置Method and device for bill data processing using off-chain trusted equipment 技术领域technical field
本说明书实施例涉及区块链技术领域,更具体地,涉及一种使用链下可信设备进行票据数据处理的方法和装置。The embodiments of this specification relate to the technical field of blockchain, and more particularly, to a method and apparatus for processing bill data using an off-chain trusted device.
背景技术Background technique
区块链技术也被称之为分布式账本技术,是一种去中心化的分布式数据库技术,其特点是去中心化、公开透明、不可篡改、可信任。区块链的每笔交易,都会广播到全网的区块链节点,每个全节点都有全量的、一致的数据。由于区块链的上述特点,可将区块链例如开发为发票链,以用于发票的开票、流转业务。然而,在现有的发票链架构中,通过区块链中部署的智能合约进行全部发票操作,受限于区块链智能合约执行的性能,导致发票业务的开票吞吐量受限,难以扩展,在业务峰值时段(例如双十一时段)中可能无法满足业务需求。因此,需要一种更有效的票据处理方案。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. Due to the above-mentioned characteristics of the blockchain, the blockchain can be developed into an invoice chain, for example, for the invoicing and circulation business of invoices. However, in the existing invoice chain architecture, all invoicing operations are carried out through smart contracts deployed in the blockchain, which is limited by the performance of blockchain smart contract execution, resulting in limited invoicing throughput of the invoice business, which is difficult to expand. Business demands may not be met during peak business hours (eg, Double Eleven). Therefore, there is a need for a more efficient ticket processing scheme.
发明内容SUMMARY OF THE INVENTION
本说明书实施例旨在提供一种更有效的使用链下可信设备进行票据数据处理的方案,以解决现有技术中的不足。The embodiments of this specification aim to provide a more effective solution for using off-chain trusted devices to process bill data, so as to solve the deficiencies in the prior art.
为实现上述目的,本说明书一个方面提供一种使用链下可信设备进行票据数据处理的方法,所述方法由区块链节点执行,包括:执行第一交易,所述第一交易中包括至少一个票据标识,以用于将所述至少一个票据标识分配给第一链下可信设备;执行由所述第一链下可信设备发送的第二交易,所述第二交易中包括与所述至少一个票据标识分别对应的至少一个票据,以获取所述至少一个票据。In order to achieve the above object, one aspect of this specification provides a method for processing bill data using an off-chain trusted device, the method being executed by a blockchain node, including: executing a first transaction, where the first transaction includes at least A ticket identifier for assigning the at least one ticket identifier to the first off-chain trusted device; executing a second transaction sent by the first off-chain trusted device, the second transaction including The at least one bill identifies the corresponding at least one bill, so as to obtain the at least one bill.
在一种实施方式中,执行第一交易包括,执行第一交易以使得在区块链中存入与第一链下可信设备关联的至少一个票据标识。In one embodiment, executing the first transaction includes executing the first transaction such that at least one ticket identification associated with the first off-chain trusted device is deposited in the blockchain.
在一种实施方式中,所述第一交易中调用第一合约,所述第一合约的账户状态中记录有各个票据标识对应的票据信息,其中,执行第一交易包括,执行所述第一合约,以使得在所述第一合约的账户状态中记录对所述至少一个票据标识的分配。In one embodiment, the first contract is invoked in the first transaction, and bill information corresponding to each bill identifier is recorded in the account status of the first contract, wherein executing the first transaction includes executing the first contract. contract such that the assignment of the at least one ticket identification is recorded in the account state of the first contract.
在一种实施方式中,执行第一交易还包括,执行所述第一合约,以使得将所述至少一个票据标识分配给多个链下可信设备中的第一链下可信设备。In one embodiment, executing the first transaction further includes executing the first contract, so that the at least one ticket identifier is allocated to the first off-chain trusted device among the plurality of off-chain trusted devices.
在一种实施方式中,将所述至少一个票据标识分配给多个链下可信设备中的第一链下可信设备包括,基于所述至少一个票据标识对应的数值范围,将所述至少一个票据标识分配给多个链下可信设备中的第一链下可信设备。In one embodiment, allocating the at least one ticket identifier to a first off-chain trusted device among the multiple off-chain trusted devices includes, based on a value range corresponding to the at least one ticket identifier, assigning the at least one off-chain trusted device. A ticket identifier is allocated to the first off-chain trusted device among the multiple off-chain trusted devices.
在一种实施方式中,将所述至少一个票据标识分配给多个链下可信设备中的第一链下可信设备包括,基于所述至少一个票据标识对应的开票主体的标识,将所述至少一个票据标识分配给多个链下可信设备中的第一链下可信设备。In one embodiment, allocating the at least one ticket identifier to the first off-chain trusted device among the multiple off-chain trusted devices includes, based on the identifier of the invoicing subject corresponding to the at least one ticket identifier, assigning all the off-chain trusted devices. The at least one ticket identifier is allocated to a first off-chain trusted device among the multiple off-chain trusted devices.
在一种实施方式中,所述第二交易中调用所述第一合约,执行由所述第一链下可信设备发送的第二交易还包括,执行所述第一合约,以使得在获取所述至少一个票据之后,将所述至少一个票据存入所述第一合约的账户状态中相应票据标识的票据信息中。In one embodiment, invoking the first contract in the second transaction, and executing the second transaction sent by the trusted device off the first chain further includes executing the first contract, so that when obtaining After the at least one bill, the at least one bill is stored in the bill information of the corresponding bill identifier in the account state of the first contract.
在一种实施方式中,所述方法还包括,在执行第二交易之后,执行第三交易,所述第三交易中调用所述第一合约,以使得基于各个票据标识的票据信息,确定等待所述第一链下可信设备处理的第一票据标识,在所述第一票据标识的票据信息中删除分配信息。In one embodiment, the method further includes, after executing the second transaction, executing a third transaction, in which the first contract is called in the third transaction, so that the waiting period is determined based on the ticket information identified by each ticket. For the first ticket identifier processed by the trusted device under the first chain, the allocation information is deleted from the ticket information of the first ticket identifier.
在一种实施方式中,所述第二交易中调用第二合约,所述第二合约中调用所述第一合约,其中,执行由所述第一链下可信设备发送的第二交易还包括,执行所述第二合约,以使得对所述至少一个票据进行验证,将经验证的至少一个票据提供给所述第一合约。In one embodiment, a second contract is invoked in the second transaction, and the first contract is invoked in the second contract, wherein executing the second transaction sent by the trusted device off the first chain also further Including, executing the second contract such that the at least one ticket is verified, and the verified at least one ticket is provided to the first contract.
在一种实施方式中,所述第一链下可信设备为TEE设备,所述第二交易中还包括所述TEE设备对所述至少一个票据的签名,其中,对所述至少一个票据进行验证包括,使用预设的所述TEE设备的公钥对所述签名进行验证。In an embodiment, the first off-chain trusted device is a TEE device, and the second transaction further includes a signature of the TEE device on the at least one ticket, wherein the at least one ticket is signed The verification includes using the preset public key of the TEE device to verify the signature.
本说明书另一方面提供一种使用链下可信设备进行票据数据处理的方法,所述方法由第一链下可信设备执行,包括:从区块链获取分配给第一链下可信设备的至少一个票据标识;获取与所述至少一个票据标识分别对应的至少一个票据信息;基于所述至少一个票据信息生成与所述至少一个票据标识分别对应的至少一个票据;向所述区块链发送第二交易,所述第二交易中包括所述至少一个票据。Another aspect of this specification provides a method for processing bill data using an off-chain trusted device, the method being performed by a first off-chain trusted device, including: obtaining from a blockchain and assigning it to the first off-chain trusted device obtain at least one bill information corresponding to the at least one bill identification; generate at least one bill corresponding to the at least one bill identification based on the at least one bill information; send to the blockchain A second transaction is sent, the second transaction including the at least one ticket.
在一种实施方式中,所述第一链下可信设备为TEE设备,所述第二交易中还包括所述TEE设备对所述至少一个票据的签名。In an embodiment, the first off-chain trusted device is a TEE device, and the second transaction further includes a signature of the TEE device on the at least one ticket.
本说明书另一方面提供一种使用链下可信设备进行票据数据处理的装置,所述装置部署于区块链节点,包括:第一执行单元,配置为,执行第一交易,所述第一交易中包括至少一个票据标识,以用于将所述至少一个票据标识分配给第一链下可信设备;第二执行单元,配置为,执行由所述第一链下可信设备发送的第二交易,所述第二交易中包 括与所述至少一个票据标识分别对应的至少一个票据,以获取所述至少一个票据。Another aspect of this specification provides an apparatus for processing bill data using an off-chain trusted device, the apparatus is deployed on a blockchain node, and includes: a first execution unit configured to execute a first transaction, the first The transaction includes at least one ticket identifier for assigning the at least one ticket identifier to the first off-chain trusted device; the second execution unit is configured to execute the first off-chain trusted device sent by the first off-chain trusted device. Second transaction, the second transaction includes at least one bill corresponding to the at least one bill identifier, so as to obtain the at least one bill.
在一种实施方式中,所述第一执行单元还配置为,执行第一交易以使得在区块链中存入与第一链下可信设备关联的至少一个票据标识。In one embodiment, the first execution unit is further configured to execute the first transaction so that at least one ticket identifier associated with the trusted device under the first chain is stored in the blockchain.
在一种实施方式中,所述第一交易中调用第一合约,所述第一合约的账户状态中记录有各个票据标识对应的票据信息,其中,所述第一执行单元还配置为,执行所述第一合约,以使得在所述第一合约的账户状态中记录对所述至少一个票据标识的分配。In one embodiment, a first contract is invoked in the first transaction, and bill information corresponding to each bill identifier is recorded in the account status of the first contract, wherein the first execution unit is further configured to execute the first contract such that the assignment of the at least one ticket identifier is recorded in the account state of the first contract.
在一种实施方式中,所述第一执行单元还配置为,执行所述第一合约,以使得将所述至少一个票据标识分配给多个链下可信设备中的第一链下可信设备。In an embodiment, the first execution unit is further configured to execute the first contract, so that the at least one ticket identifier is allocated to the first off-chain trusted device among the multiple off-chain trusted devices equipment.
在一种实施方式中,所述第一执行单元还配置为,基于所述至少一个票据标识对应的数值范围,将所述至少一个票据标识分配给多个链下可信设备中的第一链下可信设备。In an embodiment, the first execution unit is further configured to, based on the value range corresponding to the at least one ticket identifier, assign the at least one ticket identifier to the first chain among the multiple off-chain trusted devices under Trusted Devices.
在一种实施方式中,所述第一执行单元还配置为,基于所述至少一个票据标识对应的开票主体的标识,将所述至少一个票据标识分配给多个链下可信设备中的第一链下可信设备。In an embodiment, the first execution unit is further configured to, based on the identifier of the invoicing subject corresponding to the at least one ticket identifier, assign the at least one ticket identifier to the first one of the multiple off-chain trusted devices An off-chain trusted device.
在一种实施方式中,所述第二交易中调用所述第一合约,所述第二执行单元还配置为,执行所述第一合约,以使得在获取所述至少一个票据之后,将所述至少一个票据存入所述第一合约的账户状态中相应票据标识的票据信息中。In one embodiment, the first contract is invoked in the second transaction, and the second execution unit is further configured to execute the first contract, so that after acquiring the at least one ticket, all The at least one bill is stored in the bill information of the corresponding bill identifier in the account state of the first contract.
在一种实施方式中,所述装置还包括,第三执行单元,配置为,在执行第二交易之后,执行第三交易,所述第三交易中调用所述第一合约,以使得基于各个票据标识的票据信息,确定等待所述第一链下可信设备处理的第一票据标识,在所述第一票据标识的票据信息中删除分配信息。In one embodiment, the apparatus further includes a third execution unit configured to, after executing the second transaction, execute a third transaction, in which the first contract is invoked, so that based on each The ticket information of the ticket identifier is determined, the first ticket identifier waiting to be processed by the trusted device under the first chain is determined, and the allocation information is deleted from the ticket information of the first ticket identifier.
在一种实施方式中,所述第二交易中调用第二合约,所述第二合约中调用所述第一合约,其中,所述第二执行单元还配置为,执行所述第二合约,以使得对所述至少一个票据进行验证,将经验证的至少一个票据提供给所述第一合约。In an implementation manner, the second contract is invoked in the second transaction, and the first contract is invoked in the second contract, wherein the second execution unit is further configured to execute the second contract, The verified at least one ticket is provided to the first contract so that the at least one ticket is verified.
在一种实施方式中,所述第一链下可信设备为TEE设备,所述第二交易中还包括所述TEE设备对所述至少一个票据的签名,其中,所述第二执行单元还配置为,使用预设的所述TEE设备的公钥对所述签名进行验证。In an embodiment, the first off-chain trusted device is a TEE device, the second transaction further includes a signature of the TEE device on the at least one ticket, wherein the second execution unit further It is configured to use the preset public key of the TEE device to verify the signature.
本说明书另一方面提供一种使用链下可信设备进行票据数据处理的装置,所述装置部署于第一链下可信设备,包括:第一获取单元,配置为,从区块链获取分配给第一链 下可信设备的至少一个票据标识;第二获取单元,配置为,获取与所述至少一个票据标识分别对应的至少一个票据信息;生成单元,配置为,基于所述至少一个票据信息生成与所述至少一个票据标识分别对应的至少一个票据;发送单元,配置为,向所述区块链发送第二交易,所述第二交易中包括所述至少一个票据。Another aspect of this specification provides a device for processing bill data using an off-chain trusted device, the device is deployed on a first off-chain trusted device, and includes: a first obtaining unit configured to obtain distribution from the blockchain at least one ticket identifier for the trusted device under the first chain; a second acquiring unit, configured to acquire at least one ticket information corresponding to the at least one ticket identifier; a generating unit, configured to, based on the at least one ticket The information generates at least one ticket corresponding to the at least one ticket identifier; the sending unit is configured to send a second transaction to the blockchain, where the second transaction includes the at least one ticket.
在一种实施方式中,所述第一链下可信设备为TEE设备,所述第二交易中还包括所述TEE设备对所述至少一个票据的签名。In an embodiment, the first off-chain trusted device is a TEE device, and the second transaction further includes a signature of the TEE device on the at least one ticket.
本说明书另一方面提供一种计算机可读存储介质,其上存储有计算机程序,当所述计算机程序在计算机中执行时,令计算机执行上述任一项方法。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.
通过根据本说明书实施例的主发票链加链下可信设备的两层区块链架构,可通过链下设备对主链动态扩容,从而满足业务峰值时段的业务需求;在主发票链中通过在合约的账户状态中记录票据信息,使得用户、主发票链和链下设备可基于该票据信息协调进行票据处理;另外,当通过链下设备进行票据处理时,通过在与链下设备的连接断开之前一次性将多个票据写入主发票链,可大大减少主发票链上的交易数,从而提升了总体的业务吞吐量。Through the two-layer blockchain architecture of the main invoice chain plus trusted devices under the chain according to the embodiment of this specification, the main chain can be dynamically expanded through the devices under the chain, so as to meet the business needs during peak business hours; Record the bill information in the account status of the contract, so that the user, the main invoice chain and the off-chain device can coordinate the bill processing based on the bill information; Writing multiple tickets to the main invoice chain at one time before disconnection can greatly reduce the number of transactions on the main invoice chain, thereby improving the overall business throughput.
附图说明Description of drawings
通过结合附图描述本说明书实施例,可以使得本说明书实施例更加清楚:By describing the embodiments of the present specification in conjunction with the accompanying drawings, the embodiments of the present specification can be made clearer:
图1示出根据本说明书实施例的开票系统示意图;FIG. 1 shows a schematic diagram of an invoicing system according to an embodiment of the present specification;
图2示出根据本说明书实施例的通过链下设备开具发票的方法流程图;FIG. 2 shows a flowchart of a method for invoicing through an off-chain device according to an embodiment of the present specification;
图3示出根据本说明书实施例的交易1(Tx1)的示意图;FIG. 3 shows a schematic diagram of transaction 1 (Tx1) according to an embodiment of the present specification;
图4示出了在主合约C1的账户状态中记录的包括各个发票号的发票信息的表格;Figure 4 shows a table of invoice information including respective invoice numbers recorded in the account status of the main contract C1;
图5示出根据本说明书实施例的交易2(Tx2)的示意图;FIG. 5 shows a schematic diagram of transaction 2 (Tx2) according to an embodiment of the present specification;
图6示出根据本说明书实施例的交易3(Tx3)的示意图;FIG. 6 shows a schematic diagram of transaction 3 (Tx3) according to an embodiment of the present specification;
图7示出根据本说明书实施例的一种使用链下可信设备进行票据数据处理的装置700;FIG. 7 shows an apparatus 700 for using off-chain trusted devices to process ticket data according to an embodiment of the present specification;
图8示出根据本说明书实施例的一种使用链下可信设备进行票据数据处理的装置 800。Fig. 8 shows an apparatus 800 for processing ticket data using an off-chain trusted device according to an embodiment of the present specification.
具体实施方式Detailed ways
下面将结合附图描述本说明书实施例。The embodiments of the present specification will be described below with reference to the accompanying drawings.
图1示出根据本说明书实施例的开票系统示意图。如图1中所示,所述开票系统中包括发票链11、链下设备集群12、用户终端13。发票链11例如为联盟链,其中部署有主合约C1(合约名称例如为“Main”)和通信合约C2(合约名称例如为“Layer2”)。所述主合约C1为用于进行开票的合约,其中例如包括取票号函数(Num())、派票函数(Assign())、开票函数(Invoice())、接收函数(Receipt())和核查函数(Check())。所述通信合约C2用于向链下设备集群12发送待处理的发票号段,其中例如包括数据发送函数(Data())、结果返回函数(Result())、和连接断开函数(Close())。主合约C1通过调用通信合约C2可通过使用链下设备进行开票。FIG. 1 shows a schematic diagram of an invoicing system according to an embodiment of the present specification. As shown in FIG. 1 , the invoicing system includes an invoice chain 11 , an off-chain device cluster 12 , and a user terminal 13 . The invoice chain 11 is, for example, a consortium chain, in which the main contract C1 (the contract name is "Main", for example) and the communication contract C2 (the contract name is "Layer2", for example) are deployed. The main contract C1 is a contract for invoicing, which includes, for example, a ticket number function (Num()), a ticket distribution function (Assign()), an invoicing function (Invoice()), and a receiving function (Receipt()) and a check function (Check()). The communication contract C2 is used to send the pending invoice number segment to the off-chain device cluster 12, which includes, for example, a data sending function (Data()), a result returning function (Result()), and a disconnecting function (Close() . )). The main contract C1 can use the off-chain device for billing by calling the communication contract C2.
链下设备集群12包括多个用于进行开票的链下可信设备,图中示意示出设备D1、设备D2和设备D3,所述链下可信设备例如为包括可信执行环境(TEE)的设备,并且所述链下可信设备中设置有所述发票链的客户端。例如设备D1可通过其客户端从发票链任一节点读取发票链中的账本数据(如交易、收据、账户状态等)及其证明数据(例如Spv证明),并对账本数据进行验证,从而确保所述账本数据的可信性。设备D1在基于获取的账本数据从而获取分配给其的发票号段之后,可从用户终端13接收与所述发票号段对应的多个发票信息,基于多个发票信息生成与所述号段对应的多个发票,使用其硬件私钥对开具的多个发票进行数字签名,并将该多个发票和数字签名通过向发票链11发送交易而提供给发票链11。发票链11在从设备D1获取该开具的多个发票和数字签名之后,可通过预存的设备D1的硬件公钥验证上述数字签名,从而确保所述发票的可信性,并获取发票存入发票链11中。The off-chain device cluster 12 includes a plurality of off-chain trusted devices for invoicing. The figure schematically shows device D1, device D2 and device D3. The off-chain trusted devices include, for example, a Trusted Execution Environment (TEE) and the client of the invoice chain is set in the trusted off-chain device. For example, device D1 can read the ledger data (such as transactions, receipts, account status, etc.) and its proof data (such as Spv proof) in the invoice chain from any node of the invoice chain through its client, and verify the ledger data, thereby Ensure the credibility of the ledger data. After acquiring the invoice number segment assigned to it based on the acquired ledger data, the device D1 can receive a plurality of invoice information corresponding to the invoice number segment from the user terminal 13, and generate a plurality of invoice information corresponding to the number segment based on the plurality of invoice information. , digitally sign the issued multiple invoices using its hardware private key, and provide the multiple invoices and digital signatures to the invoice chain 11 by sending a transaction to the invoice chain 11 . After obtaining the multiple invoices and digital signatures issued from the device D1, the invoice chain 11 can verify the above digital signatures through the pre-stored hardware public key of the device D1, so as to ensure the credibility of the invoice, and obtain the invoice and store it in the invoice. chain 11.
用户终端13例如为商户1的终端设备,其中设置有所述发票链的客户端。当商户1希望通过发票链进行开票业务时,商户1预先通过向发票链节点(例如节点P1)发送交易而在发票链中申请发票号段(例如发票号1-500),该交易中例如调用主合约C1中的Num()函数,从而使得该交易在被执行时将发票号段1-500发给商户1。在执行该交易之后,可在主合约C1的账户状态中记录各个票号对应的商户,如将在下文描述的图4所示。The user terminal 13 is, for example, a terminal device of the merchant 1, in which the client terminal of the invoice chain is set. When merchant 1 wishes to conduct invoicing business through the invoice chain, merchant 1 applies for the invoice number segment (for example, invoice number 1-500) in the invoice chain by sending a transaction to the invoice chain node (for example, node P1) in advance. In the transaction, for example, calling The Num() function in the main contract C1, thereby causing the transaction to send the invoice number segment 1-500 to Merchant 1 when the transaction is executed. After the transaction is executed, the merchant corresponding to each ticket number can be recorded in the account status of the main contract C1, as shown in FIG. 4 which will be described below.
发票链11中的节点可通过发送交易设定由链下设备处理的发票号段,例如通过在该 交易中调用主合约C1中的Assign()函数,将预定发票号段(例如发票号1-1000)分配给链下设备进行处理,并在主合约C1的账户状态中记录该信息。Nodes in the invoice chain 11 can set the invoice number segment to be processed by the off-chain device by sending a transaction, for example, by calling the Assign() function in the main contract C1 in the transaction, and assigning the predetermined invoice number segment (eg, invoice number 1- 1000) is allocated to the off-chain device for processing, and the information is recorded in the account status of the main contract C1.
商户1在希望通过发票链11对某个发票号进行开票时,查询主合约C1的账户状态,确定该发票号是由发票链11开具、还是由链下设备进行开具。如果基于主合约C1的账户状态确定由发票链11进行开具,则可通过发送调用主合约C1的Invoice()函数的交易,使得由发票链11进行对该发票的开具。如果基于主合约C1的账户状态确定由设备D1开具,则可通过由发票链11提供的设备D1的接口连接设备D1,以通过设备D1进行对该发票的开具。When the merchant 1 wishes to issue an invoice for a certain invoice number through the invoice chain 11, it queries the account status of the main contract C1 to determine whether the invoice number is issued by the invoice chain 11 or the off-chain device. If it is determined based on the account status of the main contract C1 that the invoice chain 11 issues the invoice, the invoice chain 11 can issue the invoice by sending a transaction calling the Invoice() function of the main contract C1. If it is determined that the device D1 is issued based on the account status of the main contract C1, the device D1 can be connected through the interface of the device D1 provided by the invoice chain 11 to issue the invoice through the device D1.
设备D1在开具发票之后,可通过其客户端向发票链11发送交易,其中,在该交易中以至少一个发票为传入参数调用通信合约C2,在通信合约C2中调用主合约C1,从而将至少一个发票提供给发票链11中的主合约C1。主合约C1在获取至少一个发票之后,可将至少一个发票存入其账户状态中,以供后续的发票业务使用。After the device D1 issues an invoice, it can send a transaction to the invoice chain 11 through its client, wherein in the transaction, the communication contract C2 is called with at least one invoice as an incoming parameter, and the main contract C1 is called in the communication contract C2, so that the At least one invoice is provided to the main contract C1 in the invoice chain 11 . After acquiring the at least one invoice, the main contract C1 can deposit the at least one invoice into its account status for use in the subsequent invoice business.
下文将详细描述上述票据处理过程。The above-mentioned ticket processing process will be described in detail below.
图2示出根据本说明书实施例的通过链下设备开具发票的方法流程图。FIG. 2 shows a flowchart of a method for invoicing through an off-chain device according to an embodiment of the present specification.
如图2所示,该方法例如通过发票链11中的节点P2与链下设备D1共同执行。如上文所述,发票链11中的主合约C1自身可进行对发票的开具,也可通过调用通信合约C2以通过链下设备进行对发票的开具。发票链11可在业务高峰时段通过开启与链下设备的连接(例如与链下设备D1的连接),使用链下设备进行开票处理,从而可以实现更快的票据处理速度。在业务高峰时段之后,交易量下降,发票链11自身可及时地执行各个交易并完成开票,即不再需要链下设备,从而,可结束对链下设备的使用。下面将详细描述该方法中的各个步骤。As shown in FIG. 2 , the method is executed jointly by the node P2 in the invoice chain 11 and the off-chain device D1, for example. As mentioned above, the main contract C1 in the invoice chain 11 can issue invoices by itself, and can also issue invoices through off-chain devices by invoking the communication contract C2. The invoice chain 11 can use the off-chain device for billing processing by opening the connection with the off-chain device (for example, the connection with the off-chain device D1) during peak business hours, so that a faster bill processing speed can be achieved. After the business peak period, the transaction volume drops, and the invoice chain 11 itself can execute each transaction and complete the invoicing in a timely manner, that is, the off-chain equipment is no longer required, and thus the use of the off-chain equipment can be terminated. The individual steps in the method will be described in detail below.
首先,在步骤S202,节点P2通过执行交易1锁定发票号段(例如1-1000)。First, in step S202, node P2 locks the invoice number segment (eg, 1-1000) by executing transaction 1.
发票链11可基于业务高峰时段设定对链下设备集群的使用,例如针对双十一时段,可设定在11月11日零点之前开启与链下设备集群中各个设备的连接,并在11月11日24:00断开所述连接,以结束对链下设备的使用。Invoice Chain 11 can set the use of off-chain device clusters based on business peak hours. For example, for the Double Eleven period, it can be set to open the connection with each device in the off-chain device cluster before 0:00 on November 11, and on November 11. The said connection is disconnected at 24:00 on May 11 to end the use of the off-chain device.
在发票链11与链下设备建立连接之后,发票链11中的节点可向发票链11中发送交易1,以对链下设备分配发票号段。该交易1中以发票号段(例如1-1000)为传入参数调用主合约C1中的派票函数(Assign()),以使得将发票号为1-1000的发票分配给链下设备集群12进行处理。图3示出根据本说明书实施例的交易1(Tx1)的示意图。 如图3所示,该交易1由节点P1发送,调用主合约C1(Main)中的派票函数(Assign(a,b)),其中a为发票号段的起始号参数,b为发票号段的末尾号参数,在调用派票函数时,以“1,1000”为传入参数进行调用,表示对a赋值1,对b赋值1000。After the invoice chain 11 establishes the connection with the off-chain device, the nodes in the invoice chain 11 can send transaction 1 to the invoice chain 11 to assign the invoice number segment to the off-chain device. In this transaction 1, the invoice number segment (for example, 1-1000) is used as the incoming parameter to call the dispatch function (Assign()) in the main contract C1, so that the invoice with the invoice number of 1-1000 is allocated to the off-chain device cluster 12 is processed. FIG. 3 shows a schematic diagram of transaction 1 (Tx1) according to an embodiment of the present specification. As shown in Figure 3, the transaction 1 is sent by the node P1, which calls the dispatch function (Assign(a, b)) in the main contract C1 (Main), where a is the starting number parameter of the invoice number segment, and b is the invoice The last number parameter of the number segment is called with "1,1000" as the incoming parameter when calling the ticket dispatch function, which means that 1 is assigned to a and 1000 is assigned to b.
节点P2中在执行交易1中的主合约C1中的Assign函数时,首先根据预定分配规则将发票号1-1000分配给多个链下设备。在一种实施方式中,所述预定分配规则为基于发票的发票号段范围进行分配,例如,将发票号模100之后的值小于20的票分配给设备D1,将发票号模100之后的值在20-40之间的票分配给设备D2等等。在一种实施方式中,所述预定分配规则为基于发票的商户名称(即开票单位)进行分配,例如,将与流量大的热点开票单位对应的发票号分配给设备D1、将与多个小流量的开票单位对应的发票号分配给设备D2,等等。可以理解,所述分配规则不限于上述两种分配规则,还可以基于其它算法基于发票号进行分配,或者还可以基于发票中的其它字段(如商品名称等)进行分配,在此不作限定。When executing the Assign function in the main contract C1 in the transaction 1, the node P2 first allocates the invoice number 1-1000 to multiple off-chain devices according to a predetermined allocation rule. In one embodiment, the predetermined allocation rule is to allocate based on the range of the invoice number segment of the invoice, for example, assign the ticket with the value after the invoice number modulo 100 less than 20 to the device D1, and assign the value after the invoice number modulo 100 to the device D1. Between 20-40 tickets are allocated to device D2 and so on. In one embodiment, the predetermined allocation rule is based on the merchant name of the invoice (that is, the invoicing unit). The invoice number corresponding to the invoicing unit of the flow is assigned to device D2, and so on. It can be understood that the allocation rules are not limited to the above two allocation rules, and can also be allocated based on the invoice number based on other algorithms, or can also be allocated based on other fields in the invoice (such as commodity names, etc.), which are not limited here.
图4示出了在主合约C1的账户状态中记录的包括各个发票号的发票信息的表格。如图4中所示,发票链11在如上文所述向商户1分发发票号段1-500之后,可在图4所示的表格中记录:发票号1-500的商户为商户1(User1),图4中还记录了,发票号501-1000对应的商户为商户2(User2)。例如,在主合约C1的Assign函数中设定了中基于发票号对应的商户将其分配给链下设备,例如将分给商户1的发票号分配给图1中的设备D1,将分给商户2的发票号分配给设备D2。从而,当执行交易1中的主合约C1的Assign函数时,首先基于图4所示表格确定发票号1-1000各自对应的商户,当确定发票号1-500对应于商户1,发票号501-1000对应于商户2之后,将发票号1-500分配给设备D1(Device1),将发票号501-1000分配给设备D2(Device2),并在图4所示的表格中的发票状态中对各个发票号分别记录对应的设备标识,以指示该发票号在等待相应的链下设备进行开具,也即,对这些发票号进行了锁定,使得发票链11不会对这些发票号对应的发票进行开具。另外,如图4所示,发票号1001对应的发票状态为已开具的发票号为1001的发票,表示该发票已由发票链11或链下设备开具,发票号1002对应的发票状态为空,表示该发票号对应的发票将由发票链11自身开具。FIG. 4 shows a table of invoice information including respective invoice numbers recorded in the account status of the main contract C1. As shown in FIG. 4 , after distributing the invoice number segment 1-500 to the merchant 1 as described above, the invoice chain 11 may record in the table shown in FIG. 4 : the merchant with the invoice number 1-500 is the merchant 1 (User1 ), it is also recorded in FIG. 4 that the merchant corresponding to the invoice number 501-1000 is merchant 2 (User2). For example, in the Assign function of the main contract C1, it is set that the corresponding merchant based on the invoice number will be allocated to the off-chain device. The invoice number of 2 is assigned to device D2. Therefore, when executing the Assign function of the main contract C1 in the transaction 1, the merchants corresponding to the invoice numbers 1-1000 are first determined based on the table shown in FIG. After 1000 corresponds to Merchant 2, assign invoice numbers 1-500 to Device D1 (Device1), assign invoice numbers 501-1000 to Device D2 (Device2), and check each item in the invoice status in the table shown in Figure 4. The invoice number is recorded with the corresponding device identifier to indicate that the invoice number is waiting for the corresponding off-chain device to issue, that is, these invoice numbers are locked so that the invoice chain 11 will not issue the invoices corresponding to these invoice numbers. . In addition, as shown in Figure 4, the invoice status corresponding to the invoice number 1001 is the invoice with the invoice number 1001 that has been issued, which means that the invoice has been issued by the invoice chain 11 or the off-chain device, and the invoice status corresponding to the invoice number 1002 is empty. Indicates that the invoice corresponding to the invoice number will be issued by the invoice chain 11 itself.
在步骤S204,节点P2在执行交易1时向设备D1发送对发票号段(例如1-500)的派票信息。In step S204, the node P2 sends the dispatch information for the invoice number segment (eg 1-500) to the device D1 when the transaction 1 is executed.
如上文参考图1所述,在交易1中的主合约C1中例如以设备D1标识和发票号段1-500为传入参数调用通信合约C2中的数据发送函数(Data())。节点P2在执行交 易1时,在如上文所述修改主合约C1的账户状态之后,执行通信合约C2,从而在区块链11(即节点P2本地的区块链11的账本数据)中存入交易1的收据1,在该收据1中可包括通信合约C2的账户地址、设备D1的标识和发票号段1-500。As described above with reference to FIG. 1 , the data sending function (Data()) in the communication contract C2 is called in the main contract C1 in the transaction 1 with, for example, the device D1 identification and the invoice number segment 1-500 as incoming parameters. When node P2 executes transaction 1, after modifying the account status of the main contract C1 as described above, it executes the communication contract C2, thereby storing the data in the blockchain 11 (that is, the ledger data of the blockchain 11 local to the node P2). Receipt 1 of transaction 1, in which receipt 1 may include the account address of communication contract C2, the identification of device D1 and the invoice number field 1-500.
设备D1可对发票链11中的包括通信合约C2的账户地址和设备D1的标识的收据进行监听,从而可从发票链11读取到发送给其的信息。例如,设备D1在从发票链11读取到收据1及其证明数据(例如Spv证明)之后,通过证明数据对收据1进行验证,然后可从收据1中读取发票号段1-500,从而可确定发票链11已经将发票号段1-500分配给设备D1。The device D1 can monitor the receipt in the invoice chain 11 including the account address of the communication contract C2 and the identification of the device D1, so that the information sent to it can be read from the invoice chain 11. For example, after reading receipt 1 and its proof data (eg Spv proof) from the invoice chain 11, the device D1 verifies the receipt 1 through the proof data, and then can read the invoice number segment 1-500 from the receipt 1, thereby It can be determined that the invoice chain 11 has assigned the invoice number segment 1-500 to the device D1.
可以理解,虽然在该步骤中描述了,设备D1通过读取收据1获取分配给其的发票号段,本说明书实施例不限于此。例如,设备D1可通过读取主合约C1的账户状态从而从图4所示的表格中查询分配给其的发票号段。另外,虽然在该步骤中描述了通过调用通信合约C2向设备D1发送信息,本说明书不限于此,而是可以通过任何已知的向链外发送信息的方式向设备D1发送信息,例如,可通过执行未调用通信合约C2的交易,使得在发票链11中存入包括设备D1标识和分配发票号段的收据,以向设备D1发送信息。It can be understood that although it is described in this step that the device D1 obtains the invoice number segment assigned to it by reading the receipt 1, the embodiment of the present specification is not limited thereto. For example, the device D1 can query the invoice number segment assigned to it from the table shown in FIG. 4 by reading the account status of the main contract C1. In addition, although it is described in this step that the information is sent to the device D1 by invoking the communication contract C2, this specification is not limited to this, and the information can be sent to the device D1 by any known means of sending information outside the chain, for example, it can be By executing a transaction that does not invoke the communication contract C2, a receipt including the identification of the device D1 and the assigned invoice number segment is deposited in the invoice chain 11 to send information to the device D1.
在步骤S206,设备D1生成发票1-400。In step S206, the device D1 generates an invoice 1-400.
再参考图1,商户1在从发票链11领到发票号段之后,在需要对其中的例如发票号1开具发票时,商户1首先通过其用户终端13在区块链11中查询发票号1的发票状态,即在主合约C1的账户状态中例如如图4所示的表格中进行查询。当确定发票号1的发票状态为“Device1”之后,用户终端13连接由发票链11提供的对设备D1的连接接口,从而与设备D1连接。Referring to FIG. 1 again, after the merchant 1 receives the invoice number segment from the invoice chain 11, when it needs to issue an invoice for, for example, the invoice number 1, the merchant 1 first queries the invoice number 1 in the blockchain 11 through its user terminal 13. The invoice status of , that is, the account status of the main contract C1 is queried in the table shown in Figure 4, for example. After determining that the invoice status of the invoice number 1 is "Device1", the user terminal 13 connects to the connection interface provided by the invoice chain 11 to the device D1, thereby connecting with the device D1.
用户终端13在与设备D1建立连接之后,将发票号1的发票信息发送给设备D1,其中例如包括发票号、客户名称、商品名称、以及商户名称等信息。After establishing the connection with the device D1, the user terminal 13 sends the invoice information of the invoice number 1 to the device D1, which includes, for example, the invoice number, customer name, commodity name, and merchant name and other information.
设备D1在接收到发票号为“1”的发票信息之后,确定发票号1为由发票链11分配给其进行开具,然后基于从用户终端13接收的发票信息开具发票号为1的发票。通过同样的过程,设备D1在断开与发票链11的连接之前例如开具了发票1-400。After receiving the invoice information with the invoice number "1", the device D1 determines that the invoice number 1 is allocated to it by the invoice chain 11 for issuing, and then issues an invoice with the invoice number 1 based on the invoice information received from the user terminal 13. By the same process, device D1 issues, for example, invoice 1-400 before disconnecting from invoice chain 11 .
在步骤S208,设备D1发送交易2,以向发票链11发送发票1-发票400。In step S208, device D1 sends transaction 2 to send invoice 1 - invoice 400 to invoice chain 11 .
设备D1在生成发票1-400中的每个发票之后,并不通过分别发送多个交易而分别将各个发票发回给发票链11,而可以在与发票链11的连接断开之前通过一个交易一次 性发回给发票链11。通过这样,对于例如400个发票,相比于通过发送400个交易将400个发票分别发回给发票链11,仅通过1个交易将400个发票一次性提供给发票链11,大大减少了发票链上执行的交易数,大大提升了发票链中的总体处理速度。After generating each of the invoices 1-400, the device D1 does not send each invoice back to the invoice chain 11 separately by sending a plurality of transactions, but can pass a transaction before the connection with the invoice chain 11 is disconnected. One-time send back to Invoice Chain 11. By doing this, for example, for 400 invoices, 400 invoices are provided to the invoice chain 11 at once through only 1 transaction, compared to sending 400 transactions back to the invoice chain 11 separately, which greatly reduces the number of invoices The number of transactions executed on the chain greatly improves the overall processing speed in the invoice chain.
例如,如上文所述,在双十一时段,可设定在11月11日24:00结束对各个链下设备的使用。从而,设备D1在11月11日24:00之前确定在开具发票400之后停止开票,并向发票链11(例如节点P2)发送交易2,以将其处理的发票1-400发送给发票链11。For example, as mentioned above, during the Double Eleven period, it can be set to end the use of each off-chain device at 24:00 on November 11. Thus, device D1 determines before 24:00 on November 11 to stop invoicing after invoicing 400, and sends transaction 2 to invoice chain 11 (eg, node P2) to send invoices 1-400 processed by it to invoice chain 11 .
图5示出根据本说明书实施例的交易2(Tx2)的示意图。如图5所示,交易2由设备D1(Device1)发出,其中调用通信合约C2(Layer2)中的结果返回函数(Result()),并且对Result()的返回参数为由设备D1开具的发票1-400。FIG. 5 shows a schematic diagram of transaction 2 (Tx2) according to an embodiment of the present specification. As shown in Figure 5, transaction 2 is sent by device D1 (Device1), which calls the result return function (Result()) in communication contract C2 (Layer2), and the return parameter to Result() is the invoice issued by device D1 1-400.
在步骤S210,节点P2执行交易2,以在本地存入发票1-400。At step S210, node P2 executes transaction 2 to locally deposit invoice 1-400.
发票链11中的例如节点P2在执行上述由设备D1发送的交易2时,执行通信合约C2中的结果返回函数。所述结果返回函数包括对主合约C1中的接收函数(Receipt())的调用,从而在执行Result()时,以发票1-400为传入参数执行主合约C1中的Receipt()函数。在执行Receipt()函数时,在主合约C1中的账户状态中的如图4所示的表格中,将相应的发票存入相应的发票号的发票状态中,例如将发票1存入发票号1的发票状态中。For example, the node P2 in the invoice chain 11 executes the result return function in the communication contract C2 when executing the above transaction 2 sent by the device D1. The result returning function includes a call to the receiving function (Receipt()) in the main contract C1, so that when Result() is executed, the Receipt() function in the main contract C1 is executed with the invoice 1-400 as the incoming parameter. When the Receipt() function is executed, in the table shown in Figure 4 in the account status in the main contract C1, the corresponding invoice is stored in the invoice status of the corresponding invoice number, for example, the invoice 1 is stored in the invoice number 1 in the invoice status.
在步骤S212,设备D1发送交易3,以发送连接预关闭信息。In step S212, the device D1 sends transaction 3 to send connection pre-close information.
设备D1在如上文所述确定即将断开与发票链11的连接、并向发票链11发送其开具的发票1-400之后,可通过发送交易3以发送连接预关闭信息。After the device D1 determines that it is about to disconnect from the invoice chain 11 as described above, and sends the invoice 1-400 it issued to the invoice chain 11, the device D1 may send the connection pre-close message by sending transaction 3.
图6示出根据本说明书实施例的交易3(Tx3)的示意图。如图6所示,交易3由设备D1发出,其中调用通信合约C2(Layer2)中的连接断开函数(Close()),该连接断开函数包括参数c和d,其中参数c为设备D1开具的发票的号段的起始号,参数d为设备D1开具的发票的号段的末尾号,对该函数传入的参数“1”表示对c赋值1,参数“400”表示对d赋值400。FIG. 6 shows a schematic diagram of transaction 3 (Tx3) according to an embodiment of the present specification. As shown in Figure 6, transaction 3 is sent by device D1, and the disconnection function (Close()) in communication contract C2 (Layer2) is called. The disconnection function includes parameters c and d, where parameter c is device D1 The starting number of the number segment of the invoice issued, the parameter d is the end number of the number segment of the invoice issued by the device D1, the parameter "1" passed in to this function means assigning 1 to c, and the parameter "400" means assigning value to d 400.
在步骤S214,节点P2执行交易3,以确定是否接收到设备D1发送的全部发票。In step S214, node P2 executes transaction 3 to determine whether all invoices sent by device D1 are received.
通信合约C2(Layer2)中包括以参数c和d为传入参数对主合约C1中的Check()函数的调用,从而,在执行交易3时,以1和400为传入参数执行主合约C1中的Check()函数。在执行Check()函数时,查询主合约C1的账户状态中的如图4所示的表格,确定其中的发票号1-400各自的发票状态中是否已存入开具的发票,如果是,则确定已接收 到设备D1发送的全部发票,如果发票号1-400中的至少一个发票号的发票状态仍为“Device1”,则确定未接收到设备D1发送的全部发票。在确定未接收到设备D1发送的全部发票的情况中,节点P2可如上文所述通过发送交易而向设备D1发送未接收到发票的发票号,以重新从设备D1接收所述未接收到的发票。The communication contract C2 (Layer2) includes a call to the Check() function in the main contract C1 with the parameters c and d as the incoming parameters. Therefore, when the transaction 3 is executed, the main contract C1 is executed with 1 and 400 as the incoming parameters. Check() function in . When executing the Check() function, query the table shown in Figure 4 in the account status of the main contract C1, and determine whether the invoice status of each invoice number 1-400 has been stored in the issued invoice, if so, then It is determined that all the invoices sent by the device D1 have been received, and if the invoice status of at least one invoice number in the invoice numbers 1-400 is still "Device1", it is determined that all the invoices sent by the device D1 have not been received. In the event that it is determined that all invoices sent by device D1 have not been received, node P2 may re-receive said unreceived invoices from device D1 by sending a transaction to device D1 as described above by sending the invoice number of the unreceived invoice to device D1 bill.
在步骤S216,节点P2在执行交易3时,还解锁未开票的发票号的发票状态。In step S216, when the node P2 executes the transaction 3, it also unlocks the invoice status of the uninvoiced invoice number.
节点P2在执行上述主合约C1中的Check函数时,还可以基于参数1和400以及图4所示的表格确定发票号401-500为分配给设备D1但尚未处理的发票号,从而可将主合约C1的账户状态中的如图4所示的表格中的发票号401-500的发票状态中的“Device1”删除,即,解除对发票号401-500的锁定,从而使得发票链11可自身进行对发票401-500的开具。When the node P2 executes the Check function in the above-mentioned main contract C1, it can also determine that the invoice numbers 401-500 are the invoice numbers assigned to the device D1 but have not been processed based on the parameters 1 and 400 and the table shown in FIG. 4, so that the main The "Device1" in the invoice status of the invoice numbers 401-500 in the table shown in Figure 4 in the account status of the contract C1 is deleted, that is, the lock on the invoice numbers 401-500 is released, so that the invoice chain 11 can itself The issuance of invoices 401-500 is carried out.
在进行上述过程之后,节点P2可通过发送交易而向设备D1发送关闭信息,从而设备D1与发票链11的连接断开,即,发票链11结束对设备D1的使用。对于图1中示出的设备D2和设备D3,发票链11可通过同样的方式对其派票,并从其接收发票。After the above process, the node P2 can send the closing information to the device D1 by sending a transaction, so that the connection between the device D1 and the invoice chain 11 is disconnected, that is, the invoice chain 11 ends the use of the device D1. The invoice chain 11 can dispatch and receive invoices from the devices D2 and D3 shown in Figure 1 in the same way.
图7示出根据本说明书实施例的一种使用链下可信设备进行票据数据处理的装置700,所述装置部署于区块链节点,包括:FIG. 7 shows an apparatus 700 for using off-chain trusted devices to process ticket data according to an embodiment of the present specification. The apparatus is deployed on a blockchain node, including:
第一执行单元71,配置为,执行第一交易,所述第一交易中包括至少一个票据标识,以用于将所述至少一个票据标识分配给第一链下可信设备;The first execution unit 71 is configured to execute a first transaction, where the first transaction includes at least one ticket identifier, so as to assign the at least one ticket identifier to the first off-chain trusted device;
第二执行单元72,配置为,执行由所述第一链下可信设备发送的第二交易,所述第二交易中包括与所述至少一个票据标识分别对应的至少一个票据,以获取所述至少一个票据。The second execution unit 72 is configured to execute a second transaction sent by the first off-chain trusted device, where the second transaction includes at least one ticket corresponding to the at least one ticket identifier, so as to obtain the at least one ticket.
在一种实施方式中,所述第一执行单元71还配置为,执行第一交易以使得在区块链中存入与第一链下可信设备关联的至少一个票据标识。In one embodiment, the first execution unit 71 is further configured to execute the first transaction so that at least one ticket identifier associated with the trusted device under the first chain is stored in the blockchain.
在一种实施方式中,所述第一交易中调用第一合约,所述第一合约的账户状态中记录有各个票据标识对应的票据信息,其中,所述第一执行单元71还配置为,执行所述第一合约,以使得在所述第一合约的账户状态中记录对所述至少一个票据标识的分配。In one embodiment, the first contract is invoked in the first transaction, and bill information corresponding to each bill identifier is recorded in the account status of the first contract, wherein the first execution unit 71 is further configured to: The first contract is executed such that the assignment of the at least one ticket identification is recorded in the account state of the first contract.
在一种实施方式中,所述第一执行单元71还配置为,执行所述第一合约,以使得将所述至少一个票据标识分配给多个链下可信设备中的第一链下可信设备。In one embodiment, the first execution unit 71 is further configured to execute the first contract, so that the at least one ticket identifier is allocated to the first off-chain executable among the multiple off-chain trusted devices letter equipment.
在一种实施方式中,所述第一执行单元71还配置为,基于所述至少一个票据标识对 应的数值范围,将所述至少一个票据标识分配给多个链下可信设备中的第一链下可信设备。In an embodiment, the first execution unit 71 is further configured to, based on the value range corresponding to the at least one ticket identifier, assign the at least one ticket identifier to the first one of the multiple off-chain trusted devices Off-chain trusted devices.
在一种实施方式中,所述第一执行单元71还配置为,基于所述至少一个票据标识对应的开票主体的标识,将所述至少一个票据标识分配给多个链下可信设备中的第一链下可信设备。In one embodiment, the first execution unit 71 is further configured to, based on the identifier of the invoicing subject corresponding to the at least one ticket identifier, assign the at least one ticket identifier to a plurality of off-chain trusted devices Trusted devices off the first chain.
在一种实施方式中,所述第二交易中调用所述第一合约,所述第二执行单元72还配置为,执行所述第一合约,以使得在获取所述至少一个票据之后,将所述至少一个票据存入所述第一合约的账户状态中相应票据标识的票据信息中。In one embodiment, the first contract is invoked in the second transaction, and the second execution unit 72 is further configured to execute the first contract, so that after acquiring the at least one ticket, execute the The at least one bill is stored in the bill information of the corresponding bill identifier in the account state of the first contract.
在一种实施方式中,所述装置700还包括,第三执行单元73,配置为,在执行第二交易之后,执行第三交易,所述第三交易中调用所述第一合约,以使得基于各个票据标识的票据信息,确定等待所述第一链下可信设备处理的第一票据标识,在所述第一票据标识的票据信息中删除分配信息。In one embodiment, the apparatus 700 further includes a third execution unit 73 configured to, after executing the second transaction, execute a third transaction, where the first contract is invoked in the third transaction, so that the Based on the ticket information of each ticket identifier, a first ticket identifier waiting to be processed by the first off-chain trusted device is determined, and allocation information is deleted from the ticket information of the first ticket identifier.
在一种实施方式中,所述第二交易中调用第二合约,所述第二合约中调用所述第一合约,其中,所述第二执行单元72还配置为,执行所述第二合约,以使得对所述至少一个票据进行验证,将经验证的至少一个票据提供给所述第一合约。In an implementation manner, the second contract is invoked in the second transaction, and the first contract is invoked in the second contract, wherein the second execution unit 72 is further configured to execute the second contract , so that the at least one ticket is verified, and the verified at least one ticket is provided to the first contract.
在一种实施方式中,所述第一链下可信设备为TEE设备,所述第二交易中还包括所述TEE设备对所述至少一个票据的签名,其中,所述第二执行单元72还配置为,使用预设的所述TEE设备的公钥对所述签名进行验证。In an embodiment, the first off-chain trusted device is a TEE device, and the second transaction further includes a signature of the TEE device on the at least one ticket, wherein the second execution unit 72 It is also configured to use the preset public key of the TEE device to verify the signature.
图8示出根据本说明书实施例的一种使用链下可信设备进行票据数据处理的装置800,所述装置部署于第一链下可信设备,包括:第一获取单元81,配置为,从区块链获取分配给第一链下可信设备的至少一个票据标识;第二获取单元82,配置为,获取与所述至少一个票据标识分别对应的至少一个票据信息;生成单元83,配置为,基于所述至少一个票据信息生成与所述至少一个票据标识分别对应的至少一个票据;发送单元84,配置为,向所述区块链发送第二交易,所述第二交易中包括所述至少一个票据。FIG. 8 shows an apparatus 800 for processing ticket data using an off-chain trusted device according to an embodiment of the present specification. The apparatus is deployed in a first off-chain trusted device, and includes: a first obtaining unit 81 configured to: Acquire at least one ticket identifier assigned to the trusted device under the first chain from the blockchain; the second acquiring unit 82 is configured to acquire at least one ticket information corresponding to the at least one ticket identifier respectively; the generating unit 83 is configured to to generate at least one ticket corresponding to the at least one ticket identifier based on the at least one ticket information; the sending unit 84 is configured to send a second transaction to the blockchain, where the second transaction includes all at least one ticket.
在一种实施方式中,所述第一链下可信设备为TEE设备,所述第二交易中还包括所述TEE设备对所述至少一个票据的签名。In an embodiment, the first off-chain trusted device is a TEE device, and the second transaction further includes a signature of the TEE device on the at least one ticket.
本说明书另一方面提供一种计算机可读存储介质,其上存储有计算机程序,当所述计算机程序在计算机中执行时,令计算机执行上述任一项方法。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 comprising a memory and a processor, wherein a computer program is stored in the memory, and the processor implements any one of the above methods when executing the computer program.
通过根据本说明书实施例的主发票链加链下可信设备的两层区块链架构,可通过链下设备对主链动态扩容,从而满足业务峰值时段的业务需求;在主发票链中通过在合约的账户状态中记录票据信息,使得用户、主发票链和链下设备可基于该票据信息协调进行票据处理;另外,当通过链下设备进行票据处理时,通过在与链下设备的连接断开之前一次性将多个票据写入主发票链,可大大减少主发票链上的交易数,从而提升了总体的业务吞吐量。Through the two-layer blockchain architecture of the main invoice chain plus trusted devices under the chain according to the embodiment of this specification, the main chain can be dynamically expanded through the devices under the chain, so as to meet the business needs during peak business hours; Record the bill information in the account status of the contract, so that the user, the main invoice chain and the off-chain device can coordinate the bill processing based on the bill information; Writing multiple tickets to the main invoice chain at one time before disconnection can greatly reduce the number of transactions on the main invoice chain, thereby improving the overall business throughput.
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于系统实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。Each embodiment in this specification is described in a progressive manner, and the same and similar parts between the various embodiments may be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, as for the system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and for related parts, please refer to the partial descriptions of the method embodiments.
上述对本说明书特定实施例进行了描述。其它实施例在所附权利要求书的范围内。在一些情况下,在权利要求书中记载的动作或步骤可以按照不同于实施例中的顺序来执行并且仍然可以实现期望的结果。另外,在附图中描绘的过程不一定要求示出的特定顺序或者连续顺序才能实现期望的结果。在某些实施方式中,多任务处理和并行处理也是可以的或者可能是有利的。The foregoing describes specific embodiments of the present specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that in the embodiments and still achieve desirable results. Additionally, the processes depicted in the figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
本领域普通技术人员应该还可以进一步意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。本领域普通技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。其中,软件模块可以置于随机存储器(RAM)、内存、只读存储器(ROM)、电可编程ROM、电可擦除可编程ROM、寄存器、硬盘、可移动磁盘、CD-ROM、或技术领域内所公知的任意其它形式的存储介质中。Those of ordinary skill in the art should further realize that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, computer software or a combination of the two, in order to clearly illustrate the hardware and software interchangeability, the components and steps of each example have been generally described in terms of functions in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Persons of ordinary skill in the art may use different methods of implementing the described functionality for each particular application, but such implementations should not be considered beyond the scope of this application. Wherein, 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.
以上所述的具体实施方式,对本发明的目的、技术方案和有益效果进行了进一步详细说明,所应理解的是,以上所述仅为本发明的具体实施方式而已,并不用于限定本发明的保护范围,凡在本发明的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。The specific embodiments described above further describe the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above descriptions are only specific embodiments of the present invention, and are not intended to limit the scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.

Claims (26)

  1. 一种使用链下可信设备进行票据数据处理的方法,所述方法由区块链节点执行,包括:A method for bill data processing using off-chain trusted devices, the method being executed by a blockchain node, comprising:
    执行第一交易,所述第一交易中包括至少一个票据标识,以用于将所述至少一个票据标识分配给第一链下可信设备;executing a first transaction, where the first transaction includes at least one ticket identifier, so as to assign the at least one ticket identifier to the first off-chain trusted device;
    执行由所述第一链下可信设备发送的第二交易,所述第二交易中包括与所述至少一个票据标识分别对应的至少一个票据,以获取所述至少一个票据。Execute a second transaction sent by the first off-chain trusted device, where the second transaction includes at least one ticket corresponding to the at least one ticket identifier, to obtain the at least one ticket.
  2. 根据权利要求1所述的方法,其中,执行第一交易包括,执行第一交易以使得在区块链中存入与第一链下可信设备关联的至少一个票据标识。The method of claim 1, wherein performing the first transaction comprises performing the first transaction such that at least one ticket identification associated with the first off-chain trusted device is deposited in the blockchain.
  3. 根据权利要求1或2所述的方法,其中,所述第一交易中调用第一合约,所述第一合约的账户状态中记录有各个票据标识对应的票据信息,其中,执行第一交易包括,执行所述第一合约,以使得在所述第一合约的账户状态中记录对所述至少一个票据标识的分配。The method according to claim 1 or 2, wherein a first contract is invoked in the first transaction, and bill information corresponding to each bill identifier is recorded in the account status of the first contract, wherein executing the first transaction includes: , executing the first contract such that the assignment of the at least one ticket identifier is recorded in the account state of the first contract.
  4. 根据权利要求3所述的方法,其中,执行第一交易还包括,执行所述第一合约,以使得将所述至少一个票据标识分配给多个链下可信设备中的第一链下可信设备。4. The method of claim 3, wherein executing the first transaction further comprises executing the first contract such that the at least one ticket identifier is assigned to the first off-chain accessible one of the plurality of off-chain trusted devices letter equipment.
  5. 根据权利要求4所述的方法,其中,将所述至少一个票据标识分配给多个链下可信设备中的第一链下可信设备包括,基于所述至少一个票据标识对应的数值范围,将所述至少一个票据标识分配给多个链下可信设备中的第一链下可信设备。The method according to claim 4, wherein allocating the at least one ticket identifier to the first off-chain trusted device among the plurality of off-chain trusted devices comprises, based on the value range corresponding to the at least one ticket identifier, The at least one ticket identifier is allocated to a first off-chain trusted device among the plurality of off-chain trusted devices.
  6. 根据权利要求4所述的方法,其中,将所述至少一个票据标识分配给多个链下可信设备中的第一链下可信设备包括,基于所述至少一个票据标识对应的开票主体的标识,将所述至少一个票据标识分配给多个链下可信设备中的第一链下可信设备。The method according to claim 4, wherein allocating the at least one ticket identifier to the first off-chain trusted device among the plurality of off-chain trusted devices comprises: based on the at least one ticket identifier corresponding to the billing subject's identifier, and assign the at least one ticket identifier to the first off-chain trusted device among the multiple off-chain trusted devices.
  7. 根据权利要求3所述的方法,其中,所述第二交易中调用所述第一合约,执行由所述第一链下可信设备发送的第二交易还包括,执行所述第一合约,以使得在获取所述至少一个票据之后,将所述至少一个票据存入所述第一合约的账户状态中相应票据标识的票据信息中。The method according to claim 3, wherein invoking the first contract in the second transaction, and executing the second transaction sent by the trusted device off the first chain further comprises executing the first contract, So that after the at least one bill is acquired, the at least one bill is stored in the bill information identified by the corresponding bill in the account state of the first contract.
  8. 根据权利要求7所述的方法,还包括,在执行第二交易之后,执行第三交易,所述第三交易中调用所述第一合约,以使得基于各个票据标识的票据信息,确定等待所述第一链下可信设备处理的第一票据标识,在所述第一票据标识的票据信息中删除分配信息。The method according to claim 7, further comprising, after executing the second transaction, executing a third transaction, in which the first contract is called in the third transaction, so that the waiting list is determined based on the ticket information identified by each ticket. The first ticket identifier processed by the trusted device under the first chain is deleted, and the allocation information is deleted from the ticket information of the first ticket identifier.
  9. 根据权利要求3所述的方法,其中,所述第二交易中调用第二合约,所述第二合约中调用所述第一合约,其中,执行由所述第一链下可信设备发送的第二交易还包括, 执行所述第二合约,以使得对所述至少一个票据进行验证,将经验证的至少一个票据提供给所述第一合约。The method of claim 3, wherein a second contract is invoked in the second transaction, and the first contract is invoked in the second contract, and wherein the execution of the transaction sent by the trusted device off the first chain is performed. The second transaction also includes executing the second contract such that the at least one ticket is verified, providing the verified at least one ticket to the first contract.
  10. 根据权利要求9所述的方法,其中,所述第一链下可信设备为TEE设备,所述第二交易中还包括所述TEE设备对所述至少一个票据的签名,其中,对所述至少一个票据进行验证包括,使用预设的所述TEE设备的公钥对所述签名进行验证。The method according to claim 9, wherein the first off-chain trusted device is a TEE device, and the second transaction further includes a signature of the TEE device on the at least one ticket, wherein the Verifying at least one ticket includes verifying the signature by using the preset public key of the TEE device.
  11. 一种使用链下可信设备进行票据数据处理的方法,所述方法由第一链下可信设备执行,包括:A method for using off-chain trusted devices to process bill data, the method being performed by a first off-chain trusted device, comprising:
    从区块链获取分配给第一链下可信设备的至少一个票据标识;Obtain at least one ticket identifier assigned to the trusted device under the first chain from the blockchain;
    获取与所述至少一个票据标识分别对应的至少一个票据信息;acquiring at least one ticket information corresponding to the at least one ticket identifier;
    基于所述至少一个票据信息生成与所述至少一个票据标识分别对应的至少一个票据;generating at least one ticket corresponding to the at least one ticket identifier based on the at least one ticket information;
    向所述区块链发送第二交易,所述第二交易中包括所述至少一个票据。Sending a second transaction to the blockchain, the second transaction including the at least one ticket.
  12. 根据权利要求11所述的方法,所述第一链下可信设备为TEE设备,所述第二交易中还包括所述TEE设备对所述至少一个票据的签名。The method according to claim 11, wherein the first off-chain trusted device is a TEE device, and the second transaction further includes a signature of the TEE device on the at least one ticket.
  13. 一种使用链下可信设备进行票据数据处理的装置,所述装置部署于区块链节点,包括:A device for bill data processing using off-chain trusted equipment, the device is deployed on a blockchain node, including:
    第一执行单元,配置为,执行第一交易,所述第一交易中包括至少一个票据标识,以用于将所述至少一个票据标识分配给第一链下可信设备;a first execution unit, configured to execute a first transaction, where the first transaction includes at least one ticket identifier, so as to assign the at least one ticket identifier to the first off-chain trusted device;
    第二执行单元,配置为,执行由所述第一链下可信设备发送的第二交易,所述第二交易中包括与所述至少一个票据标识分别对应的至少一个票据,以获取所述至少一个票据。a second execution unit configured to execute a second transaction sent by the first off-chain trusted device, where the second transaction includes at least one ticket corresponding to the at least one ticket identifier, so as to obtain the at least one ticket.
  14. 根据权利要求13所述的装置,其中,所述第一执行单元还配置为,执行第一交易以使得在区块链中存入与第一链下可信设备关联的至少一个票据标识。The apparatus of claim 13, wherein the first execution unit is further configured to execute the first transaction such that at least one ticket identification associated with the first off-chain trusted device is deposited in the blockchain.
  15. 根据权利要求13或14所述的装置,其中,所述第一交易中调用第一合约,所述第一合约的账户状态中记录有各个票据标识对应的票据信息,其中,所述第一执行单元还配置为,执行所述第一合约,以使得在所述第一合约的账户状态中记录对所述至少一个票据标识的分配。The device according to claim 13 or 14, wherein a first contract is invoked in the first transaction, and bill information corresponding to each bill identifier is recorded in the account status of the first contract, wherein the first execution The unit is further configured to execute the first contract such that the assignment of the at least one ticket identification is recorded in the account status of the first contract.
  16. 根据权利要求15所述的装置,其中,所述第一执行单元还配置为,执行所述第一合约,以使得将所述至少一个票据标识分配给多个链下可信设备中的第一链下可信设备。The apparatus of claim 15, wherein the first execution unit is further configured to execute the first contract such that the at least one ticket identifier is assigned to the first one of the plurality of off-chain trusted devices Off-chain trusted devices.
  17. 根据权利要求16所述的装置,其中,所述第一执行单元还配置为,基于所述至 少一个票据标识对应的数值范围,将所述至少一个票据标识分配给多个链下可信设备中的第一链下可信设备。The apparatus according to claim 16, wherein the first execution unit is further configured to, based on the value range corresponding to the at least one ticket identifier, assign the at least one ticket identifier to a plurality of off-chain trusted devices The first off-chain trusted device.
  18. 根据权利要求16所述的装置,其中,所述第一执行单元还配置为,基于所述至少一个票据标识对应的开票主体的标识,将所述至少一个票据标识分配给多个链下可信设备中的第一链下可信设备。The apparatus according to claim 16, wherein the first execution unit is further configured to, based on the identification of the invoicing subject corresponding to the at least one ticket identification, assign the at least one ticket identification to a plurality of off-chain trusted The first off-chain trusted device in the device.
  19. 根据权利要求15所述的装置,其中,所述第二交易中调用所述第一合约,所述第二执行单元还配置为,执行所述第一合约,以使得在获取所述至少一个票据之后,将所述至少一个票据存入所述第一合约的账户状态中相应票据标识的票据信息中。The apparatus of claim 15, wherein the first contract is invoked in the second transaction, and the second execution unit is further configured to execute the first contract, so that the at least one ticket is acquired Afterwards, the at least one bill is stored in the bill information of the corresponding bill identifier in the account state of the first contract.
  20. 根据权利要求19所述的装置,还包括,第三执行单元,配置为,在执行第二交易之后,执行第三交易,所述第三交易中调用所述第一合约,以使得基于各个票据标识的票据信息,确定等待所述第一链下可信设备处理的第一票据标识,在所述第一票据标识的票据信息中删除分配信息。The apparatus according to claim 19, further comprising a third execution unit configured to, after executing the second transaction, execute a third transaction in which the first contract is invoked, so that the first contract is called based on the respective bills The identified ticket information, determine the first ticket identifier waiting to be processed by the first off-chain trusted device, and delete the allocation information from the ticket information of the first ticket identifier.
  21. 根据权利要求15所述的装置,其中,所述第二交易中调用第二合约,所述第二合约中调用所述第一合约,其中,所述第二执行单元还配置为,执行所述第二合约,以使得对所述至少一个票据进行验证,将经验证的至少一个票据提供给所述第一合约。The apparatus of claim 15, wherein a second contract is called in the second transaction, and the first contract is called in the second contract, wherein the second execution unit is further configured to execute the A second contract, such that the at least one ticket is verified, provides the verified at least one ticket to the first contract.
  22. 根据权利要求21所述的装置,其中,所述第一链下可信设备为TEE设备,所述第二交易中还包括所述TEE设备对所述至少一个票据的签名,其中,所述第二执行单元还配置为,使用预设的所述TEE设备的公钥对所述签名进行验证。The apparatus according to claim 21, wherein the first off-chain trusted device is a TEE device, and the second transaction further includes a signature of the TEE device on the at least one ticket, wherein the first The second execution unit is further configured to use the preset public key of the TEE device to verify the signature.
  23. 一种使用链下可信设备进行票据数据处理的装置,所述装置部署于第一链下可信设备,包括:A device for processing bill data using off-chain trusted devices, the device is deployed on a first off-chain trusted device, including:
    第一获取单元,配置为,从区块链获取分配给第一链下可信设备的至少一个票据标识;a first obtaining unit, configured to obtain at least one ticket identifier assigned to the trusted device under the first chain from the blockchain;
    第二获取单元,配置为,获取与所述至少一个票据标识分别对应的至少一个票据信息;a second obtaining unit, configured to obtain at least one piece of bill information corresponding to the at least one bill identifier;
    生成单元,配置为,基于所述至少一个票据信息生成与所述至少一个票据标识分别对应的至少一个票据;a generating unit, configured to generate at least one ticket corresponding to the at least one ticket identifier based on the at least one ticket information;
    发送单元,配置为,向所述区块链发送第二交易,所述第二交易中包括所述至少一个票据。A sending unit, configured to send a second transaction to the blockchain, where the second transaction includes the at least one ticket.
  24. 根据权利要求23所述的装置,所述第一链下可信设备为TEE设备,所述第二交易中还包括所述TEE设备对所述至少一个票据的签名。The apparatus according to claim 23, wherein the first off-chain trusted device is a TEE device, and the second transaction further includes a signature of the TEE device on the at least one ticket.
  25. 一种计算机可读存储介质,其上存储有计算机程序或指令,当所述计算机程序 或指令在计算机中执行时,令计算机执行权利要求1至12中任一项的所述的方法。A computer-readable storage medium on which computer programs or instructions are stored, which, when executed in a computer, cause the computer to perform the method of any one of claims 1 to 12.
  26. 一种计算设备,包括存储器和处理器,所述存储器中存储有计算机程序或指令,所述处理器在执行所述计算机程序或指令时,实现权利要求1至12中任一项所述的方法。A computing device, comprising a memory and a processor, wherein a computer program or instruction is stored in the memory, and the processor implements the method according to any one of claims 1 to 12 when executing the computer program or instruction .
PCT/CN2022/081699 2021-03-30 2022-03-18 Method and apparatus for processing bill data by using off-chain trusted device WO2022206430A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110339765.8 2021-03-30
CN202110339765.8A CN112801797A (en) 2021-03-30 2021-03-30 Method and apparatus for processing ticket data using a down-link trusted device

Publications (1)

Publication Number Publication Date
WO2022206430A1 true WO2022206430A1 (en) 2022-10-06

Family

ID=75815981

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/081699 WO2022206430A1 (en) 2021-03-30 2022-03-18 Method and apparatus for processing bill data by using off-chain trusted device

Country Status (2)

Country Link
CN (1) CN112801797A (en)
WO (1) WO2022206430A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112801797A (en) * 2021-03-30 2021-05-14 支付宝(杭州)信息技术有限公司 Method and apparatus for processing ticket data using a down-link trusted device
US20230082301A1 (en) * 2021-09-13 2023-03-16 Guavus, Inc. MEASURING QoE SATISFACTION IN 5G NETWORKS OR HYBRID 5G NETWORKS

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109034924A (en) * 2018-08-16 2018-12-18 腾讯科技(深圳)有限公司 Electronic bill generation method, device, storage medium and computer equipment
US20190340266A1 (en) * 2018-05-01 2019-11-07 International Business Machines Corporation Blockchain implementing cross-chain transactions
CN110458631A (en) * 2019-07-31 2019-11-15 阿里巴巴集团控股有限公司 Note number distribution method, device and electronic equipment based on block chain
CN110659906A (en) * 2019-09-20 2020-01-07 腾讯科技(深圳)有限公司 Bill information processing method, related device and medium
CN111585994A (en) * 2020-04-27 2020-08-25 中国银行股份有限公司 Data processing method and system
CN112801797A (en) * 2021-03-30 2021-05-14 支付宝(杭州)信息技术有限公司 Method and apparatus for processing ticket data using a down-link trusted device

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108694669A (en) * 2018-07-18 2018-10-23 矩阵元技术(深圳)有限公司 A kind of block chain intelligence contract implementation method and device
CN110098938B (en) * 2019-04-17 2022-05-20 上海寅坤科技发展有限公司 Trusted committee under-chain acceleration solution method and system
CN112235383B (en) * 2020-10-09 2024-03-22 腾讯科技(深圳)有限公司 Container service cluster node scheduling method and device, server and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190340266A1 (en) * 2018-05-01 2019-11-07 International Business Machines Corporation Blockchain implementing cross-chain transactions
CN109034924A (en) * 2018-08-16 2018-12-18 腾讯科技(深圳)有限公司 Electronic bill generation method, device, storage medium and computer equipment
CN110458631A (en) * 2019-07-31 2019-11-15 阿里巴巴集团控股有限公司 Note number distribution method, device and electronic equipment based on block chain
CN110659906A (en) * 2019-09-20 2020-01-07 腾讯科技(深圳)有限公司 Bill information processing method, related device and medium
CN111585994A (en) * 2020-04-27 2020-08-25 中国银行股份有限公司 Data processing method and system
CN112801797A (en) * 2021-03-30 2021-05-14 支付宝(杭州)信息技术有限公司 Method and apparatus for processing ticket data using a down-link trusted device

Also Published As

Publication number Publication date
CN112801797A (en) 2021-05-14

Similar Documents

Publication Publication Date Title
WO2022206430A1 (en) Method and apparatus for processing bill data by using off-chain trusted device
TWI706278B (en) Block chain-based transaction processing method and device, and electronic equipment
TWI737977B (en) Block chain-based transaction processing method and device, and electronic equipment
US20190347657A1 (en) Resource transfer method and apparatus, storage medium, and computer device
TW202025045A (en) Invoice reimbursement method and device based on block chain and electronic device
CN104272258B (en) For supporting the system and method for implicit version control in transaction middleware machine environment
TW202016817A (en) Block chain based transaction processing method and device and electronic equipment
CN110008665B (en) Authority control method and device for blockchain
CN112764887A (en) Construction method, processing method, device, equipment and storage medium of transaction request
WO2022206438A1 (en) Method and apparatus for providing cross-chain message
WO2022206439A1 (en) Method and apparatus for providing cross-chain message
CN111901321A (en) Authentication method, device, electronic equipment and readable storage medium
US10326833B1 (en) Systems and method for processing request for network resources
CN112529709A (en) Ether house intelligent contract implementation method based on multi-sign technology
CN110662210B (en) Secondary or repeated mobile phone number identification method, system and equipment based on block chain
CN109063037A (en) A kind of querying method, service equipment, terminal device and computer readable storage medium
CN110851813B (en) Identity verification method, node device of block chain system and block chain system
CN112001796A (en) Method and device for processing service in block chain system
US10846156B2 (en) Methods, devices and computer program products for managing software function
KR20200014121A (en) Method and system for providing block chain service
CN108989418A (en) A kind of resource amount method of mixed cloud object storage common authentication
CN112017052B (en) Method and apparatus for deploying and invoking contracts in blockchain
CN114372280A (en) Block chain service execution method and device based on multi-sign intelligent contract
CN112001800A (en) Method and device for processing service in block chain system
CN108270865B (en) Job scheduling method of high-performance cloud computing platform

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

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

Country of ref document: EP

Kind code of ref document: A1