WO2020233637A1 - Receipt storage method combining code labelling with user type, and node - Google Patents

Receipt storage method combining code labelling with user type, and node Download PDF

Info

Publication number
WO2020233637A1
WO2020233637A1 PCT/CN2020/091419 CN2020091419W WO2020233637A1 WO 2020233637 A1 WO2020233637 A1 WO 2020233637A1 CN 2020091419 W CN2020091419 W CN 2020091419W WO 2020233637 A1 WO2020233637 A1 WO 2020233637A1
Authority
WO
WIPO (PCT)
Prior art keywords
smart contract
transaction
blockchain node
code
receipt
Prior art date
Application number
PCT/CN2020/091419
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 WO2020233637A1 publication Critical patent/WO2020233637A1/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
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3825Use of electronic signatures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3827Use of message hashing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3829Payment protocols; Details thereof insuring higher security of transaction involving key management
    • 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
    • G06Q30/00Commerce
    • G06Q30/04Billing or invoicing

Definitions

  • One or more embodiments of this specification relate to the field of blockchain technology, and more particularly to a receipt storage method and node that combines code annotation and user type.
  • Blockchain technology is built on a transmission network (such as a peer-to-peer network).
  • the network nodes in the transmission network use chained data structures to verify and store data, and use distributed node consensus algorithms to generate and update data.
  • TEE Trusted Execution Environment
  • TEE can play the role of a black box in the hardware. Neither the code executed in the TEE nor the data operating system layer can be peeped. Only the pre-defined interface in the code can operate on it.
  • plaintext data is calculated in TEE instead of complex cryptographic operations in homomorphic encryption. There is no loss of efficiency in the calculation process. Therefore, the combination with TEE can achieve less performance loss. Under the premise, the security and privacy of the blockchain are greatly improved. At present, the industry is very concerned about TEE solutions.
  • TEE solutions including TPM (Trusted Platform Module) for software and Intel SGX (Software Guard Extensions) for hardware. , Software Protection Extension), ARM Trustzone (trust zone) and AMD PSP (Platform Security Processor, platform security processor).
  • one or more embodiments of this specification provide a receipt storage method and node combining code labeling and user type.
  • a receipt storage method combining code labeling and user type including:
  • the first blockchain node receives an encrypted transaction corresponding to a smart contract, and the code of the smart contract includes an object marked by an exposed identifier;
  • the first blockchain node decrypts the transaction in the trusted execution environment to obtain the code of the smart contract
  • the first blockchain node executes the code of the smart contract in the trusted execution environment to obtain receipt data
  • the first blockchain node stores the receipt data, and when the transaction initiator belongs to a preset user type, the content of the receipt corresponding to the object indicated by the exposure identifier is stored in plain text, and the rest of the receipt content is stored in cipher text.
  • a receipt storage node combining code labeling and user type including:
  • the receiving unit receives an encrypted transaction corresponding to a smart contract, and the code of the smart contract includes an object marked by an exposed identifier;
  • the execution unit executes the code of the smart contract in the trusted execution environment to obtain receipt data
  • the storage unit stores the receipt data.
  • the receipt content corresponding to the object indicated by the exposure identifier is stored in plain text, and the rest of the receipt content is stored in cipher text.
  • an electronic device including:
  • a memory for storing processor executable instructions
  • the processor implements the method according to the first aspect by running the executable instruction.
  • a computer-readable storage medium is provided, and computer instructions are stored thereon, which, when executed by a processor, implement the steps of the method described in the first aspect.
  • Fig. 1 is a schematic diagram of creating a smart contract according to an exemplary embodiment.
  • Fig. 2 is a schematic diagram of invoking a smart contract provided by an exemplary embodiment.
  • Fig. 3 is a flowchart of a receipt storage method combining code labeling and user type according to an exemplary embodiment.
  • Fig. 4 is a schematic diagram of implementing privacy protection on blockchain nodes according to an exemplary embodiment.
  • Fig. 5 is a schematic diagram of the functional logic of implementing a blockchain network through a system contract and a chain code provided by an exemplary embodiment.
  • Fig. 6 is a block diagram of a receipt storage node combining code labeling and user type according to an exemplary embodiment.
  • the steps of the corresponding method may not be executed in the order shown and described in this specification.
  • the method includes more or fewer steps than described in this specification.
  • a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may also be combined into a single step in other embodiments. description.
  • Blockchain is generally divided into three types: Public Blockchain, Private Blockchain and Consortium Blockchain.
  • the most decentralized one is the public chain.
  • the public chain is represented by Bitcoin and Ethereum. Participants who join the public chain can read the data records on the chain, participate in transactions, and compete for the accounting rights of new blocks. Moreover, each participant (ie, node) can freely join and exit the network, and perform related operations.
  • the private chain is the opposite.
  • the write permission of the network is controlled by an organization or institution, and the data read permission is regulated by the organization.
  • the private chain can be a weakly centralized system with strict restrictions and few participating nodes. This type of blockchain is more suitable for internal use by specific institutions.
  • the alliance chain is a block chain between the public chain and the private chain, which can achieve "partial decentralization".
  • Each node in the alliance chain usually has a corresponding entity or organization; participants are authorized to join the network and form a stakeholder alliance to jointly maintain the operation of the blockchain.
  • a smart contract on the blockchain is a contract that can be triggered and executed by a transaction on the blockchain system.
  • Smart contracts can be defined in the form of codes.
  • EVM Ethereum Virtual Machine
  • bytecode virtual machine code
  • the EVM of node 1 can execute the transaction and generate a corresponding contract instance.
  • "0x6f8ae93" in the figure 1 represents the address of this contract, the data field of the transaction can be stored in bytecode, and the to field of the transaction is empty.
  • the contract is successfully created and can be called in the subsequent process.
  • a contract account corresponding to the smart contract appears on the blockchain and has a specific address, and the contract code will be stored in the contract account.
  • the behavior of the smart contract is controlled by the contract code.
  • smart contracts enable virtual accounts containing contract codes and account storage (Storage) to be generated on the blockchain.
  • the EVM of a certain node can execute the transaction and generate a corresponding contract instance.
  • the from field of the transaction in Figure 2 is the address of the account of the transaction initiator (ie Bob), the "0x6f8ae93" in the to field represents the address of the called smart contract, and the value field in Ethereum is the value of Ether ,
  • the method and parameters of calling the smart contract are stored in the data field of the transaction. Smart contracts are executed independently on each node in the blockchain network in a prescribed manner. All execution records and data are stored on the blockchain, so when the transaction is completed, the blockchain will be stored on the blockchain that cannot be tampered with. Lost transaction certificate.
  • the receipt data obtained by a node executing a transaction can include the following:
  • the Result field indicates the execution result of the transaction
  • the Gas used field indicates the gas value consumed by the transaction
  • the Logs field indicates the log generated by the transaction.
  • the log can further include the From field, To field, Topic field, and Log data field, among which the From field indicates the account address of the initiator of the call, and the To field indicates the called object (such as a smart contract)
  • the account address and Topic field indicate the subject of the log, and the Log data field indicates the log data;
  • the Output field indicates the output of the transaction.
  • the receipt data generated after the transaction is executed is stored in plain text, and anyone can see the contents of the above-mentioned receipt fields contained in the receipt data, without privacy protection settings and capabilities.
  • the block chain is a data set stored in a database of a node and organized by a specific logic.
  • the database as described later, may be a storage medium, such as a persistent storage medium, on a physical carrier.
  • only part of the content of the receipt data may be sensitive, while other content is not sensitive. Only sensitive content needs to be protected for privacy, other content can be disclosed, and in some cases it may even be necessary to retrieve some content to drive Implementation of related operations, the implementation of privacy protection for this part of the content will affect the implementation of retrieval operations.
  • the first blockchain node receives an encrypted transaction corresponding to a smart contract, and the code of the smart contract includes an object marked by an exposed identifier.
  • the user when the user writes the code of the smart contract, he can add an exposure identifier to the code to mark one or more objects, so that the receipt content corresponding to this part of the object in the receipt data can be stored in plain text, then The contents of the receipts corresponding to the remaining objects without an exposed identifier need to be stored in cipher text to achieve corresponding privacy protection.
  • the data field can store the bytecode of the smart contract.
  • the bytecode consists of a series of bytes, and each byte can identify an operation. Based on many considerations such as development efficiency and readability, developers can choose a high-level language to write smart contract code instead of directly writing bytecode.
  • the code of a smart contract written in a high-level language is compiled by a compiler to generate bytecode, and then the bytecode can be deployed on the blockchain.
  • Solidity language As an example, the contract written in it is very similar to the class in the object-oriented programming language. A variety of members can be declared in a contract, including state variables, functions, function modifiers, and events. The following is a simple smart contract code example 1 written in Solidity language:
  • one or more objects can be marked by exposing identifiers, so that the receipt content corresponding to this part of the object in the receipt data can be stored in plain text, while the rest of the receipt content is encrypted Document storage.
  • one or more objects can also be marked by exposing identifiers to realize the plaintext storage of the relevant receipt content.
  • the exposure identifier may be a receipt field dedicated to indicating that plain text storage is required.
  • the keyword plain may be used to characterize the exposure identifier. Then, for the receipt content that you want to store in plain text, you can add plain before the corresponding object (or, you can also associate with the corresponding object in other ways).
  • the object marked by the exposure identifier can include receipt fields, such as the Result field, Gas used field, Logs field, Output field, etc., as described above, or the From field, To field, Topic field, and Log data field further contained in the Logs field Wait.
  • receipt fields such as the Result field, Gas used field, Logs field, Output field, etc., as described above, or the From field, To field, Topic field, and Log data field further contained in the Logs field Wait.
  • the code sample 1 above can be adjusted to the following code sample 2:
  • the fields that need to be stored in plaintext can also be specified.
  • the From field is marked by the exposed identifier
  • the code of the smart contract is executed, if the transaction initiator belongs to the preset user type, the content of the receipt corresponding to the From field in the generated receipt data is in plain text.
  • the objects (all fields or From fields) marked by the exposed identifier "plain" are contract-level objects, so that the first blockchain node is storing
  • the contract-level object can be applied to all events in the smart contract. Take the From field as an example: when the transaction initiator belongs to the preset user type, for multiple events The corresponding Logs fields are generated separately, and the From field contained in each Logs field will be stored in plain text, without the need to add an exposure identifier for each event.
  • the exposed identifier can also be used to identify other objects.
  • the object indicated by the exposure identifier may include a state variable, and the state variable may also be a contract-level object. Taking the state variable "price" as an example, the above code example 1 can be adjusted to the following code example 3:
  • each Logs field (such as the Topic field in the Logs field) will store the receipt content related to the state variable "price” in clear text, and the Output field will also be stored in clear text with the state variable "price” "Related receipt content, there is no need to add an exposure identifier for the state variable "price” in each event.
  • a smart contract can include the following code example 4:
  • the objects indicated by the exposure identifier may include: event-level objects corresponding to at least one event defined in the smart contract, so that when the first blockchain node stores receipt data, if the transaction initiator belongs to the pre- Assuming the user type, the receipt content corresponding to the at least one event in the receipt data can be stored in plain text.
  • the above event-level objects can be set for at least some of the events, so that the content of the receipt corresponding to this part of the event is stored in plain text, and the content of the receipt corresponding to the remaining events is stored in cipher text .
  • the character "from” corresponding to the From field is added to the event function "event currentPrice(int price)" corresponding to the event currentPrice, and the exposed identifier used in the character from is different from the aforementioned plain, but modify the character from with quotation marks.
  • the quotation marks in code example 5 are equivalent to the aforementioned exposed identifier.
  • Event-level objects can also include state variables. Taking the state variable "price" as an example, the above code example 1 can be adjusted to the following code example 6:
  • the event-level object may include fields, which is similar to the above-mentioned From field. However, since no specific fields are specified, all fields in the log generated by the event currentPrice can be regarded as the above event-level objects, such as the aforementioned From field, To field, Topic field, Log Data field, etc., so that the transaction is initiated When the party belongs to the preset user type, all the contents of the receipt corresponding to the event currentPrice are stored in plain text.
  • event-level objects can include state variables.
  • the above code example 6 defines the state variable "price”
  • the event currentPrice refers to the state variable "price”, which corresponds to adding the exposure identifier "plain” before the event function "event currentPrice(int price)”
  • the state variable "price” can be used as the above-mentioned event-level object, so that when the transaction initiator belongs to the preset user type, all receipts related to the state variable "price” generated by the event are stored in plain text.
  • the state variable "price” belongs to the event-level object in Code Example 6, when the code of the smart contract also contains another event event1 that references the state variable "price”, if no level of exposure is added to the event event1 Identifier, even if the event event1 references the state variable "price", the content of the receipt generated by the event event1 will still be stored in cipher text, not in plain text.
  • the above event-level object may include all the state variables referenced.
  • the above code sample 4 can be adjusted to the following code sample 7:
  • the event function "event currentPrice(int price, int price1)" corresponding to the event currentPrice refers to the state variables "price” and "price1", and by adding the exposure identifier plain before the event, The quoted state variables "price” and “price1” will both be affected, so when the transaction initiator belongs to the preset user type, all receipts related to the state variables "price” and "price1” generated by the event will be Store in clear text. However, for other events where the exposed identifier plain is not added, the contents of the receipts generated are stored in cipher text.
  • the event-level object When the event-level object includes state variables, it can also specifically indicate one or more state variables referenced by the event. Taking the state variable "price" as an example, the above code example 1 can be adjusted to the following code example 8:
  • the event function "event currentPrice(int price)" corresponding to the event currentPrice refers to the state variable "price", and by adding the exposure identifier plain before the type int of the state variable "price", so that The state variable "price” is configured as an event-level object, and the event-level object is only applicable to the currentPrice event and not applicable to other events included in the smart contract, that is: on the premise that the transaction initiator belongs to the preset user type , Only the receipt content related to the state variable "price” generated by the event currentPrice is stored in plain text. Unless other events also add an exposure identifier for the state variable "price", other events even if the state variable "price” is applied ", the generated receipt content is still stored in cipher text.
  • the event currentPrice references the state variables "price” and “price1" at the same time
  • the state variable "price” can be configured by adding the exposure identifier plain before the type int of the state variable "price” It is an event-level object, and the state variable "price1" without the exposed identifier plain is not an event-level object, so that the event generated by the event is related to the state variable "price” on the premise that the transaction initiator belongs to the preset user type
  • the receipt content of is stored in plain text, and the receipt content related to the state variable "price1" is still stored in cipher text.
  • the smart contract corresponding to the transaction received by the first blockchain node may be a smart contract written in a high-level language, or may be a smart contract in the form of bytecode.
  • the first blockchain node when the smart contract is a smart contract written in a high-level language, the first blockchain node also compiles the smart contract written in the high-level language through a compiler to generate a smart contract in the form of bytecode to be used in a trusted execution environment In execution.
  • the smart contract in bytecode form can be obtained by compiling the smart contract written in high-level language by the client through the compiler , And the smart contract written in this high-level language is written by the user on the client.
  • the smart contract corresponding to the transaction received by the first blockchain node may be a smart contract generated by the user on the first blockchain node.
  • the first blockchain node also uses a compiler to compile the smart contract written in the high-level language into a smart contract in the form of bytecode; or, the user may also be in the first area Smart contracts in bytecode form are directly written on the blockchain nodes.
  • the smart contract corresponding to the transaction received by the first blockchain node may be a smart contract generated by the user on the client.
  • the client submits the transaction to the first blockchain node.
  • the first blockchain node includes a transaction/query interface, which can be connected with the client, so that the client can submit the above-mentioned transaction to the first blockchain node.
  • the user can use a high-level language to write a smart contract on the client, and then the client uses a compiler to compile the smart contract in the high-level language to obtain the corresponding smart contract in bytecode form.
  • the client can directly send a smart contract written in a high-level language to the first blockchain node, so that the first blockchain node is compiled into a bytecode smart contract by a compiler.
  • the smart contract corresponding to the transaction received by the first blockchain node can be the smart contract in the transaction sent by the client through the second blockchain node.
  • the smart contract is usually in the form of bytecode; of course, the smart contract It can also be a smart contract written in a high-level language, and the first blockchain node can be compiled into a bytecode smart contract by a compiler.
  • the smart contract written in a high-level language and the smart contract in the form of bytecode may have the same exposure identifier.
  • the bytecode can use an exposed identifier different from a high-level language.
  • the code of a smart contract written in a high-level language contains the first identifier and the code of the smart contract in the form of bytecode. If the second identifier is included, there is a corresponding relationship between the first identifier and the second identifier to ensure that after being compiled into bytecode by a high-level language, the function of exposing the identifier will not be affected.
  • Step 304 The first blockchain node decrypts the transaction in the trusted execution environment to obtain the code of the smart contract.
  • the foregoing transaction may be encrypted by a symmetric encryption algorithm, or may be encrypted by an asymmetric algorithm.
  • the encryption algorithm used by symmetric encryption such as DES algorithm, 3DES algorithm, TDEA algorithm, Blowfish algorithm, RC5 algorithm, IDEA algorithm, etc.
  • Asymmetric encryption algorithms such as RSA, Elgamal, knapsack algorithm, Rabin, D-H, ECC (elliptic curve encryption algorithm), etc.
  • the foregoing transaction may be encrypted by a combination of a symmetric encryption algorithm and an asymmetric encryption algorithm.
  • the client can use a symmetric encryption algorithm to encrypt the transaction content, that is, use the symmetric encryption algorithm key to encrypt the transaction content, and use an asymmetric encryption algorithm to encrypt the symmetric encryption algorithm
  • the key used for example, the key used in the public key encryption symmetric encryption algorithm using an asymmetric encryption algorithm.
  • the first blockchain node after the first blockchain node receives the encrypted transaction, it can first decrypt it with the private key of the asymmetric encryption algorithm to obtain the key of the symmetric encryption algorithm, and then decrypt it with the key of the symmetric encryption algorithm to obtain the transaction content.
  • the transaction content can include the code of the smart contract that needs to be created; when the transaction is used to call a smart contract, the transaction content can include the account address of the smart contract being called, and the required input Methods and parameters, etc.
  • a transaction When a transaction is used to call a smart contract, it can be a call of multiple nested structures. For example, the transaction directly calls smart contract 1, and the code of smart contract 1 calls smart contract 2, and the code in smart contract 2 points to the contract address of smart contract 3, so that the transaction actually calls the code of smart contract 3 indirectly , And the code in smart contract 3 can include objects marked by exposed identifiers. In this way, it is equivalent to that the smart contract 1 contains the object identified by the exposed identifier.
  • the specific implementation process is similar to the above process, and will not be repeated here.
  • Step 306 The first blockchain node executes the code of the smart contract in the trusted execution environment to obtain receipt data.
  • the transaction received by the first blockchain node may be, for example, a transaction for creating and/or invoking a smart contract.
  • a transaction for creating and/or invoking a smart contract For example, in Ethereum, after the first blockchain node receives the transaction to create and/or call the smart contract from the client, it can check whether the transaction is valid, the format is correct, and the signature of the transaction is legal.
  • the nodes in Ethereum are generally nodes that compete for the right to bookkeeping. Therefore, the first blockchain node as the node that competes for the right to bookkeeping can execute the transaction locally. If one of the nodes competing for the accounting right wins in the current round of the accounting right, it becomes the accounting node. If the first blockchain node wins this round of competition for accounting rights, it becomes the accounting node; of course, if the first blockchain node does not win in this round of competition for accounting rights, it is not Accounting nodes, and other nodes may become accounting nodes.
  • a smart contract is similar to a class in object-oriented programming.
  • the result of execution generates a contract instance corresponding to the smart contract, similar to the object corresponding to the generated class.
  • the process of executing the code used to create a smart contract in a transaction will create a contract account and deploy the contract in the account space.
  • the address of the smart contract account is generated from the sender's address ("0xf5e -- in Figure 1-2) and the transaction nonce (nonce) as input, and is generated by an encryption algorithm, such as in Figure 1-2
  • the contract address "0x6f8ae93" is generated from the sender's address "0xf5e" and the nonce in the transaction through an encryption algorithm.
  • consensus algorithms such as Proof of Work (POW), Proof of Stake (POS), and Delegated Proof of Stake (DPOS) are adopted in blockchain networks that support smart contracts. All nodes competing for the right to account can execute the transaction after receiving the transaction including the creation of a smart contract. One of the nodes competing for the right to bookkeeping may win this round and become the bookkeeping node.
  • the accounting node can package the transaction containing the smart contract with other transactions and generate a new block, and send the generated new block to other nodes for consensus.
  • the nodes with the right to book accounts have been agreed before this round of bookkeeping. Therefore, after the first blockchain node receives the above transaction, if it is not the accounting node of this round, it can send the transaction to the accounting node.
  • accounting nodes which can be the first blockchain node
  • the accounting node packages the transaction (or other transactions together) and generates a new block
  • the generated new block or block header is sent to other nodes for consensus.
  • the accounting nodes in this round can package and package the transaction. Generate a new block, and send the header of the new block to other nodes for consensus. If other nodes receive the block and verify that there is no problem, they can append the new block to the end of the original block chain to complete the accounting process and reach a consensus; if the transaction is used to create a smart contract, then The deployment of the smart contract on the blockchain network is completed. If the transaction is used to call the smart contract, the call and execution of the smart contract are completed. In the process of verifying the new block or block header sent by the accounting node, other nodes may also execute the transaction in the block.
  • the execution process can generally be executed by a virtual machine. Taking Ethereum as an example, it supports users to create and/or call some complex logic in the Ethereum network. This is the biggest challenge that distinguishes Ethereum from Bitcoin blockchain technology.
  • the core of Ethereum as a programmable blockchain is the Ethereum Virtual Machine (EVM), and every Ethereum node can run EVM.
  • EVM is a Turing complete virtual machine, which means that various complex logic can be implemented through it. Users publish and call smart contracts in Ethereum run on the EVM.
  • the first blockchain node can execute the decrypted smart contract code in a Trusted Execution Environment (TEE).
  • TEE Trusted Execution Environment
  • the first blockchain node can be divided into a regular execution environment (on the left in the figure) and TEE, and transactions submitted by the client (as described above, transactions can have other sources; here, the client submits Take the transaction as an example to illustrate)
  • First enter the "transaction/query interface" in the regular execution environment for identification.
  • Transactions that do not require privacy processing can be left in the regular execution environment for processing (here can be based on the user type of the transaction initiator , Transaction type, identifier contained in the exchange, etc.
  • TEE is isolated from the conventional execution environment.
  • the transaction is encrypted before entering the TEE, and it is decrypted into the transaction content in the clear in the trusted execution environment, so that the transaction content in the clear text can be efficiently processed in the TEE and in the TEE under the premise of ensuring data security.
  • the receipt data in plaintext is generated in.
  • TEE is a secure extension based on CPU hardware and a trusted execution environment completely isolated from the outside.
  • TEE was first proposed by Global Platform to solve the security isolation of resources on mobile devices, and parallel to the operating system to provide a trusted and secure execution environment for applications.
  • ARM's Trust Zone technology is the first to realize the real commercial TEE technology.
  • security requirements are getting higher and higher.
  • Not only mobile devices, cloud devices, and data centers have put forward more needs for TEE.
  • the concept of TEE has also been rapidly developed and expanded. Compared with the originally proposed concept, TEE is a broader TEE. For example, server chip manufacturers Intel, AMD, etc. have successively introduced hardware-assisted TEE and enriched the concept and characteristics of TEE, which has been widely recognized in the industry.
  • Intel Software Protection Extensions (SGX) and other TEE technologies isolate code execution, remote attestation, secure configuration, secure storage of data, and trusted paths for code execution.
  • the applications running in the TEE are protected by security and are almost impossible to be accessed by third parties.
  • SGX provides an enclave (also called an enclave), which is an encrypted trusted execution area in the memory, and the CPU protects data from being stolen.
  • enclave also called an enclave
  • the CPU protects data from being stolen.
  • a part of the area EPC Enclave Page Cache, enclave page cache or enclave page cache
  • the encryption engine MEE Memory Encryption Engine
  • SGX users can distrust the operating system, VMM (Virtual Machine Monitor), and even BIOS (Basic Input Output System). They only need to trust the CPU to ensure that private data will not leakage.
  • the private data can be encrypted and transmitted to the circle in cipher text, and the corresponding secret key can also be transmitted to the circle through remote certification. Then, the data is used for calculation under the encryption protection of the CPU, and the result will be returned in ciphertext. In this mode, you can use powerful computing power without worrying about data leakage.
  • the transaction contains the code of the smart contract
  • the first blockchain node can decrypt the transaction in the TEE to obtain the code of the smart contract contained therein, and then Execute this code in TEE.
  • the first blockchain node can execute the code in the TEE (if the called smart contract handles the encryption state, the smart contract needs to be executed in the TEE first. Decrypt to get the corresponding code).
  • the first blockchain node may use the newly added processor instructions in the CPU to allocate a part of the area EPC in the memory, and encrypt the above-mentioned plaintext code and store it in the EPC through the encryption engine MEE in the CPU.
  • the encrypted content in EPC is decrypted into plain text after entering the CPU.
  • the CPU perform operations on the plaintext code to complete the execution process.
  • the plaintext code for executing smart contracts can load the EVM into the enclosure.
  • the key management server can calculate the hash value of the local EVM code and compare it with the hash value of the EVM code loaded in the first blockchain node. The correct comparison result is a necessary condition for passing remote certification. , So as to complete the measurement of the code loaded in the SGX circle of the first blockchain node. After measurement, the correct EVM can execute the above smart contract code in SGX.
  • Step 308 The first blockchain node stores the receipt data.
  • the transaction initiator belongs to the preset user type
  • the content of the receipt corresponding to the object indicated by the exposure identifier is stored in plain text
  • the rest of the receipt content is stored in cipher text. Form storage.
  • the user has a corresponding external account on the blockchain, and initiates transactions or performs other operations based on the external account. Then, the user type to which the transaction initiator belongs, that is, the user type to which the external account belongs. Therefore, the first blockchain node can determine the external account corresponding to the transaction initiator, and query the user type corresponding to the external account recorded on the blockchain as the user type to which the transaction initiator belongs.
  • the external account may include a type field (such as a Type field) recorded on the blockchain, and the value of the type field corresponds to the user type. For example, when the value of the type field is 00, the user type is ordinary user, when the value of the type field is 01, the user type is advanced user, and when the value of the type field is 11, the user type is administrative user, etc. . Therefore, the first blockchain node can determine the corresponding user type based on the value by reading the type field of the external account mentioned above.
  • a type field such as a Type field
  • the user type when creating the above-mentioned external account, can be configured to be associated with the external account, so that the association relationship between the user type and the external account is recorded in the blockchain, such as through the user type and The account address of the external account is used to establish the above-mentioned association relationship, so that the data structure of the external account does not need to be changed, that is, the external account does not need to include the above type field. Therefore, the first blockchain node can determine the above-mentioned preset user type corresponding to the external account by reading the association relationship recorded on the blockchain and based on the external account corresponding to the transaction initiator.
  • the user type of the external account can be modified under certain conditions.
  • the management user may have a modification right item, so that the first blockchain node can change the user type corresponding to the above-mentioned external account according to the change request initiated by the management user.
  • the management user can correspond to the external account preset in the genesis block with management authority, so that the management user can make type changes to other ordinary users, advanced users, etc., such as changing ordinary users to advanced users, and changing advanced users For ordinary users, etc.
  • the first blockchain node can determine the strength of the transaction initiator’s privacy protection needs by identifying the user type to which the transaction initiator belongs: when it belongs to the preset user type, it can be determined that the transaction initiator’s privacy protection needs are relatively weak , Can accept the exposure of receipt data to a certain extent to achieve corresponding function expansion; when it does not belong to the preset user type, it can be determined that the transaction initiator has relatively strong privacy protection requirements and cannot accept the exposure of receipt data. Therefore, based on the identification of the user type to which the transaction initiator belongs, the storage method for the receipt data can meet the actual needs of the transaction initiator, and it can take into account privacy protection and function expansion. For example, ordinary users have relatively lower requirements for privacy protection and higher requirements for function expansion based on receipt data.
  • the first blockchain node can store the content of the receipt corresponding to the object indicated by the exposure identifier in plain text when the transaction initiator belongs to the preset user type, and store the remaining content of the receipt in cipher text
  • Receipt data can be stored in plaintext or ciphertext flexibly, so that the receipt content stored in ciphertext form can meet the privacy needs of users, and the receipt content stored in plaintext form can meet the user's search function expansion needs.
  • the log in the receipt data (such as the entire Logs field; or at least one of the From field, To field, Topic field, and Log data field) is stored in plain text, it can support subsequent retrieval of the log content, thereby For example, it implements event-driven based on log content, such as driving DAPP (Decentralized Application, distributed application) clients to perform related processing operations.
  • DAPP Decentralized Application, distributed application
  • the computing device By running the program code of the blockchain (hereinafter referred to as the chain code) on the computing device (physical machine or virtual machine), the computing device can be configured as a blockchain node in the blockchain network, such as the first Blockchain nodes, etc.
  • the first blockchain node runs the above chain code to realize the corresponding functional logic. Therefore, when the blockchain network is created, the receipt data storage logic related to the exposed identifier and user type can be written into the chain code, so that each blockchain node can implement the receipt data storage logic;
  • the receipt data storage logic related to the exposed identifier and the user type may include: identification logic for the user type, and logic for storing the content of the receipt based on the exposed identifier.
  • the user type identification logic is used to instruct the first blockchain node to identify the user type of the transaction initiator.
  • the system contract can record the association relationship between the predefined external account and the user type, or the system contract can record the correspondence between the value of the user type field and the user type.
  • the relevant description of identifying user types above please refer to the relevant description of identifying user types above, which will not be repeated here.
  • the logic of storing the content of the receipt based on the exposed identifier is used to instruct the first blockchain node: for the objects marked by the exposed identifier and the unmarked objects, how to store the corresponding receipt content respectively.
  • the corresponding receipt content is stored in plain text for objects marked by the exposed identifier
  • the corresponding receipt content is stored in cipher text for objects not marked by the exposed identifier. The contents of the receipt.
  • chain code is used to realize the basic functions of the blockchain network, and the function expansion during operation can be achieved through the system Realized by way of contract.
  • the system contract includes code in the form of bytecode, for example, the first blockchain node can run the system contract code (for example, according to the unique corresponding address "0x53a98" to read the system The code in the contract) to realize the functional supplement of the chain code.
  • the first blockchain node can read the code of the system contract, which defines the receipt data storage logic related to the exposed identifier and user type; then, the first blockchain node can execute the system The code of the contract, based on the receipt data storage logic related to the exposed identifier and user type, in the case that the transaction initiator belongs to the preset user type, the corresponding receipt content in the receipt data of the object marked by the exposed identifier is written in plain text Form storage, the rest of the receipt data is stored in cipher text.
  • the system contract read by the first blockchain node may include a preset system contract configured in the genesis block of the blockchain network; and, the administrator in the blockchain network (ie, the above-mentioned management user) may have The update authority of the system contract, so as to update the preset system contract such as the above, the system contract read by the first blockchain node may also include the corresponding updated system contract.
  • the updated system contract can be obtained by the administrator after one update of the preset system contract; or, the updated system contract can be obtained by the administrator after multiple iterations of the preset system contract, such as the preset system contract Update the system contract 1, update the system contract 1 to obtain the system contract 2, update the system contract 2 to obtain the system contract 3.
  • the system contract 1, the system contract 2, and the system contract 3 can all be regarded as the updated system contract, but the first Blockchain nodes usually follow the latest version of the system contract. For example, the first blockchain node will follow the code in system contract 3 instead of the code in system contract 1 or system contract 2.
  • the administrator can also publish system contracts in subsequent blocks and update the published system contracts.
  • system contracts in subsequent blocks and update the published system contracts.
  • a certain degree of restrictions should be imposed on the issuance and update of system contracts through methods such as authority management to ensure that the functional logic of the blockchain network can operate normally and avoid unnecessary losses to any users.
  • the first blockchain node encrypts at least a part of the receipt content through the key.
  • the encryption may be symmetric encryption or asymmetric encryption. If the first blockchain node uses symmetric encryption, that is, the symmetric key of the symmetric encryption algorithm is used to encrypt the content of the receipt, the client (or other object holding the key) can use the symmetric key pair of the symmetric encryption algorithm The encrypted receipt content is decrypted.
  • the symmetric key may be provided to the first blockchain node in advance by the client. Then, since only the client (actually the user corresponding to the logged-in account on the client) and the first blockchain node have the symmetric key, only the client can decrypt the corresponding encrypted receipt content, avoiding Irrelevant users and even criminals decrypt the encrypted receipt content.
  • the client when the client initiates a transaction to the first blockchain node, the client can use the initial key of the symmetric encryption algorithm to encrypt the transaction content to obtain the transaction; accordingly, the first blockchain node can obtain
  • the initial key is used to directly or indirectly encrypt the content of the receipt.
  • the initial key can be negotiated in advance by the client and the first blockchain node, or sent by the key management server to the client and the first blockchain node, or sent by the client to the first blockchain node.
  • the client can encrypt the initial key with the public key of the asymmetric encryption algorithm, and then send the encrypted initial key to the first block
  • the chain node, and the first blockchain node decrypts the encrypted initial key through the private key of the asymmetric encryption algorithm to obtain the initial key, which is the digital envelope encryption described above, which will not be repeated here.
  • the first blockchain node can use the aforementioned initial key to encrypt the content of the receipt. Different transactions can use the same initial key, so that all transactions submitted by the same user are encrypted with this initial key, or different transactions can use different initial keys. For example, the client can randomly generate an initial key for each transaction. Key to improve security.
  • the first blockchain node can generate a derived key according to the initial key and the impact factor, and encrypt the content of the receipt through the derived key.
  • the derived key can increase the degree of randomness, thereby increasing the difficulty of being compromised and helping to optimize the security protection of data.
  • the impact factor can be related to the transaction; for example, the impact factor can include the specified bits of the transaction hash value.
  • the first blockchain node can associate the initial key with the first 16 bits (or the first 32 bits and the last 16 bits) of the transaction hash value. Bits, last 32 bits, or other bits) are spliced, and the spliced string is hashed to generate a derived key.
  • the first blockchain node can also use an asymmetric encryption method, that is, use the public key of the asymmetric encryption algorithm to encrypt the content of the receipt, and accordingly, the client can use the private key of the asymmetric encryption algorithm to decrypt the encrypted The contents of the receipt.
  • the key of an asymmetric encryption algorithm for example, can be that the client generates a pair of public and private keys, and sends the public key to the first blockchain node in advance, so that the first blockchain node can use the receipt content Public key encryption.
  • the first blockchain node realizes the function by running the code used to realize the function. Therefore, for the functions that need to be implemented in the TEE, the relevant code also needs to be executed. For the code executed in the TEE, it needs to comply with the relevant specifications and requirements of the TEE; accordingly, for the code used to implement a certain function in the related technology, the code needs to be rewritten in combination with the specifications and requirements of the TEE. Large amount of development, and easy to produce loopholes (bugs) in the process of rewriting, affecting the reliability and stability of function implementation.
  • the first blockchain node can execute the storage function code outside the TEE to store the receipt data generated in the TEE (including the receipt content in plain text that needs to be stored in plain text, and the receipt content in cipher text that needs to be stored in cipher text.
  • TEE Is stored in an external storage space outside the TEE, so that the storage function code can be the code used to implement the storage function in the related technology, and does not need to be rewritten in conjunction with the specifications and requirements of the TEE to achieve safe and reliable receipt data
  • the storage of TEE can not only reduce the amount of related code development without affecting security and reliability, but also reduce TCB (Trusted Computing Base) by reducing the related code of TEE, making TEE technology and regional In the process of combining block chain technology, the additional security risks caused are in a controllable range.
  • TCB Trusted Computing Base
  • the first blockchain node may execute the write cache function code in the TEE to store the above-mentioned receipt data in the write cache in the TEE.
  • the write cache may correspond to the one shown in FIG. 2 "Cache".
  • the first blockchain node outputs the data in the write cache from the trusted execution environment to be stored in the external storage space.
  • the write cache function code can be stored in the TEE in plain text, and the cache function code in the plain text can be directly executed in the TEE; or, the write cache function code can be stored outside the TEE in cipher text, such as the above External storage space (such as the "package + storage” shown in Figure 2, where "package” means that the first blockchain node packs the transaction into blocks outside the trusted execution environment), the ciphertext form
  • the write cache function code is read into the TEE, decrypted into the plaintext code in the TEE, and the plaintext code is executed.
  • Write cache refers to a "buffer" mechanism provided to avoid “impact” to the external storage space when data is written to the external storage space.
  • the above-mentioned write cache can be implemented by using buffer; of course, the write cache can also be implemented by using cache, which is not limited in this specification.
  • the write cache mechanism can be used to write the data in the cache to the external storage space in batches, thereby reducing the gap between the TEE and the external storage space. The number of interactions increases the efficiency of data storage.
  • TEE may need to retrieve the generated data.
  • the data to be called happens to be in the write cache, the data can be read directly from the write cache.
  • the interaction between the external storage space eliminates the decryption process of the data read from the external storage space, thereby improving the data processing efficiency in the TEE.
  • the write cache can also be established outside the TEE.
  • the first blockchain node can execute the write cache function code outside the TEE, so as to store the above receipt data in the write cache outside the TEE, and further write The data in the cache is stored in an external storage space.
  • the receiving unit 61 receives an encrypted transaction corresponding to a smart contract, the code of the smart contract includes an object marked by an exposed identifier;
  • the decryption unit 62 decrypts the transaction in a trusted execution environment to obtain the code of the smart contract
  • the execution unit 63 executes the code of the smart contract in the trusted execution environment to obtain receipt data
  • the storage unit 64 stores the receipt data.
  • the receipt content corresponding to the object indicated by the exposure identifier is stored in plain text, and the rest of the receipt content is stored in cipher text.
  • the smart contract corresponding to the transaction received by the receiving unit 61 includes:
  • the node when the smart contract corresponding to the transaction received by the first blockchain node is a smart contract written in a high-level language, the node further includes:
  • the compiling unit 65 compiles the smart contract written in the high-level language through a compiler, and generates the smart contract in the form of bytecode for execution in the trusted execution environment.
  • the smart contract in the form of bytecode is a smart contract written in a high-level language by the client through a compiler It is obtained by compiling, and the smart contract written in the high-level language is written by the user on the client.
  • the smart contract written in the high-level language and the smart contract in bytecode form have the same or corresponding exposure identifier.
  • the smart contract corresponding to the transaction received by the receiving unit 61 includes:
  • the smart contract generated by the user on the first blockchain node or,
  • the smart contract generated by the user on the client or,
  • the objects indicated by the exposure identifier include: receipt fields and/or state variables.
  • the objects indicated by the exposure identifier include: contract-level objects; the storage unit 64 is specifically used for:
  • the objects indicated by the exposure identifier include: event-level objects corresponding to at least one event defined in the smart contract; the storage unit 64 is specifically configured to:
  • the receipt content corresponding to the at least one event in the receipt data is stored in plain text.
  • the first blockchain node determines the user type to which the transaction initiator belongs in the following manner:
  • the external account includes a type field recorded on the blockchain, and the value of the type field corresponds to the user type.
  • the user type is configured to be associated with the external account, so that the association relationship between the user type and the external account is recorded in the blockchain.
  • Optional also includes:
  • the changing unit 66 changes the user type corresponding to the external account according to the change request initiated by the management user.
  • the storage unit 64 is specifically used for:
  • the code of the system contract defines the receipt data storage logic related to the exposed identifier and user type
  • the code of the system contract is executed to store the content of the receipt corresponding to the object indicated by the exposure identifier in plain text when the transaction initiator belongs to the preset user type, and the rest of the receipt content in cipher text , And when the transaction initiator does not belong to the preset user type, the receipt data is stored in cipher text.
  • the system contract includes: a preset system contract recorded in the genesis block, or an updated system contract corresponding to the preset system contract.
  • the storage unit 64 is specifically used for:
  • the storage function code is executed outside the trusted execution environment to store the receipt data in an external storage space outside the trusted execution environment.
  • the transaction is used to create and/or call the smart contract.
  • the key used by the first blockchain node to encrypt the receipt field includes: a key of a symmetric encryption algorithm or a key of an asymmetric encryption algorithm.
  • the key of the symmetric encryption algorithm includes an initial key provided by the client; or, the key of the symmetric encryption algorithm includes a derived key generated by the initial key and an influence factor.
  • the transaction is encrypted by the initial key, and the initial key is encrypted by the public key of an asymmetric encryption algorithm; the decryption unit 62 is specifically configured to:
  • the initial key is generated by the client; or, the initial key is sent to the client by the key management server.
  • the impact factor is related to the transaction.
  • the impact factor includes: a designated bit of the hash value of the transaction.
  • a programmable logic device Programmable Logic Device, PLD
  • FPGA Field Programmable Gate Array
  • HDL Hardware Description Language
  • the controller can be implemented in any suitable manner.
  • the controller can take the form of, for example, a microprocessor or a processor and a computer-readable medium storing computer-readable program codes (such as software or firmware) executable by the (micro)processor. , Logic gates, switches, application specific integrated circuits (ASICs), programmable logic controllers and embedded microcontrollers. Examples of controllers include but are not limited to the following microcontrollers: ARC625D, Atmel AT91SAM, Microchip PIC18F26K20 and Silicon Labs C8051F320, the memory controller can also be implemented as part of the memory control logic.
  • controller in addition to implementing the controller in a purely computer-readable program code manner, it is entirely possible to program the method steps to make the controller use logic gates, switches, application specific integrated circuits, programmable logic controllers and embedded The same function can be realized in the form of a microcontroller, etc. Therefore, such a controller can be regarded as a hardware component, and the devices included in it for implementing various functions can also be regarded as a structure within the hardware component. Or even, the device for realizing various functions can be regarded as both a software module for realizing the method and a structure within a hardware component.
  • a typical implementation device is a computer.
  • the computer may be, for example, a personal computer, a laptop computer, a cell phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or Any combination of these devices.
  • the embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention can be in the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
  • a computer-usable storage media including but not limited to disk storage, CD-ROM, optical storage, etc.
  • program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types.
  • This specification can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network.
  • program modules can be located in local and remote computer storage media including storage devices.
  • These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device.
  • the device implements the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
  • These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment.
  • the instructions provide steps for implementing functions specified in a flow or multiple flows in the flowchart and/or a block or multiple blocks in the block diagram.
  • the computer includes one or more processors (CPU), input/output interfaces, network interfaces, and memory.
  • the memory may include non-permanent memory in computer readable media, random access memory (RAM) and/or non-volatile memory, such as read-only memory (ROM) or flash memory (flash RAM). Memory is an example of computer readable media.
  • RAM random access memory
  • ROM read-only memory
  • flash RAM flash memory
  • Computer-readable media include permanent and non-permanent, removable and non-removable media, and information storage can be realized by any method or technology.
  • the information can be computer-readable instructions, data structures, program modules, or other data.
  • Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, CD-ROM, digital versatile disc (DVD) or other optical storage, Magnetic cassettes, magnetic disk storage, quantum memory, graphene-based storage media or other magnetic storage devices or any other non-transmission media can be used to store information that can be accessed by computing devices. According to the definition in this article, computer-readable media does not include transitory media, such as modulated data signals and carrier waves.
  • first, second, third, etc. may be used in one or more embodiments of this specification to describe various information, the information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other.
  • first information may also be referred to as second information, and similarly, the second information may also be referred to as first information.
  • word “if” as used herein can be interpreted as "when” or “when” or "in response to determination”.

Landscapes

  • Business, Economics & Management (AREA)
  • Accounting & Taxation (AREA)
  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Finance (AREA)
  • Strategic Management (AREA)
  • General Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

A receipt storage method combining code labelling with a user type, and a node, the method comprising: a first blockchain node receives an encrypted transaction corresponding to a smart contract, the code of the smart contract comprising an object identified by an exposed identifier (302); the first blockchain node decrypts the transaction in a trusted execution environment to acquire the code of the smart contract (304); the first blockchain node executes the code of the smart contract in the trusted execution environment to obtain receipt data (306); the first blockchain node stores the receipt data so that, when the transaction initiating party belongs to a preset user type, the receipt content corresponding to the object identified by the exposed identifier is stored in a plain text format, and the remaining receipt content is stored in a ciphertext format (308).

Description

结合代码标注与用户类型的收据存储方法和节点Receipt storage method and node combining code annotation and user type 技术领域Technical field
本说明书一个或多个实施例涉及区块链技术领域,尤其涉及一种结合代码标注与用户类型的收据存储方法和节点。One or more embodiments of this specification relate to the field of blockchain technology, and more particularly to a receipt storage method and node that combines code annotation and user type.
背景技术Background technique
区块链技术构建在传输网络(例如点对点网络)之上。传输网络中的网络节点利用链式数据结构来验证与存储数据,并采用分布式节点共识算法来生成和更新数据。Blockchain technology is built on a transmission network (such as a peer-to-peer network). The network nodes in the transmission network use chained data structures to verify and store data, and use distributed node consensus algorithms to generate and update data.
目前企业级的区块链平台技术上最大的两个挑战就是隐私和性能,往往这两个挑战很难同时解决。大多解决方案都是通过损失性能换取隐私,或者不大考虑隐私去追求性能。常见的解决隐私问题的加密技术,如同态加密(Homomorphic encryption)和零知识证明(Zero-knowledge proof)等复杂度高,通用性差,而且还可能带来严重的性能损失。At present, the two biggest challenges of enterprise-level blockchain platform technology are privacy and performance. It is often difficult to solve these two challenges at the same time. Most of the solutions are to lose performance in exchange for privacy, or do not consider privacy to pursue performance. Common encryption technologies that solve privacy problems, such as Homomorphic encryption and Zero-knowledge proof, are highly complex, poor in versatility, and may also cause serious performance losses.
可信执行环境(Trusted Execution Environment,TEE)是另一种解决隐私问题的方式。TEE可以起到硬件中的黑箱作用,在TEE中执行的代码和数据操作系统层都无法偷窥,只有代码中预先定义的接口才能对其进行操作。在效率方面,由于TEE的黑箱性质,在TEE中进行运算的是明文数据,而不是同态加密中的复杂密码学运算,计算过程效率没有损失,因此与TEE相结合可以在性能损失较小的前提下很大程度上提升区块链的安全性和隐私性。目前工业界十分关注TEE的方案,几乎所有主流的芯片和软件联盟都有自己的TEE解决方案,包括软件方面的TPM(Trusted Platform Module,可信赖平台模块)以及硬件方面的Intel SGX(Software Guard Extensions,软件保护扩展)、ARM Trustzone(信任区)和AMD PSP(Platform Security Processor,平台安全处理器)。Trusted Execution Environment (TEE) is another way to solve privacy issues. TEE can play the role of a black box in the hardware. Neither the code executed in the TEE nor the data operating system layer can be peeped. Only the pre-defined interface in the code can operate on it. In terms of efficiency, due to the black-box nature of TEE, plaintext data is calculated in TEE instead of complex cryptographic operations in homomorphic encryption. There is no loss of efficiency in the calculation process. Therefore, the combination with TEE can achieve less performance loss. Under the premise, the security and privacy of the blockchain are greatly improved. At present, the industry is very concerned about TEE solutions. Almost all mainstream chip and software alliances have their own TEE solutions, including TPM (Trusted Platform Module) for software and Intel SGX (Software Guard Extensions) for hardware. , Software Protection Extension), ARM Trustzone (trust zone) and AMD PSP (Platform Security Processor, platform security processor).
发明内容Summary of the invention
有鉴于此,本说明书一个或多个实施例提供一种结合代码标注与用户类型的收据存储方法和节点。In view of this, one or more embodiments of this specification provide a receipt storage method and node combining code labeling and user type.
为实现上述目的,本说明书一个或多个实施例提供技术方案如下:To achieve the foregoing objectives, one or more embodiments of this specification provide technical solutions as follows:
根据本说明书一个或多个实施例的第一方面,提出了一种结合代码标注与用户类型的收据存储方法,包括:According to the first aspect of one or more embodiments of this specification, a receipt storage method combining code labeling and user type is proposed, including:
第一区块链节点接收经过加密的对应于智能合约的交易,所述智能合约的代码中包括通过暴露标识符标明的对象;The first blockchain node receives an encrypted transaction corresponding to a smart contract, and the code of the smart contract includes an object marked by an exposed identifier;
第一区块链节点在可信执行环境中解密所述交易,以获得所述智能合约的代码;The first blockchain node decrypts the transaction in the trusted execution environment to obtain the code of the smart contract;
第一区块链节点在所述可信执行环境中执行所述智能合约的代码,得到收据数据;The first blockchain node executes the code of the smart contract in the trusted execution environment to obtain receipt data;
第一区块链节点存储所述收据数据,当交易发起方属于预设用户类型时,使所述暴露标识符标明的对象对应的收据内容以明文形式存储、其余收据内容以密文形式存储。The first blockchain node stores the receipt data, and when the transaction initiator belongs to a preset user type, the content of the receipt corresponding to the object indicated by the exposure identifier is stored in plain text, and the rest of the receipt content is stored in cipher text.
根据本说明书一个或多个实施例的第二方面,提出了一种结合代码标注与用户类型的收据存储节点,包括:According to the second aspect of one or more embodiments of this specification, a receipt storage node combining code labeling and user type is proposed, including:
接收单元,接收经过加密的对应于智能合约的交易,所述智能合约的代码中包括通过暴露标识符标明的对象;The receiving unit receives an encrypted transaction corresponding to a smart contract, and the code of the smart contract includes an object marked by an exposed identifier;
解密单元,在可信执行环境中解密所述交易,以获得所述智能合约的代码;A decryption unit to decrypt the transaction in a trusted execution environment to obtain the code of the smart contract;
执行单元,在所述可信执行环境中执行所述智能合约的代码,得到收据数据;The execution unit executes the code of the smart contract in the trusted execution environment to obtain receipt data;
存储单元,存储所述收据数据,当交易发起方属于预设用户类型时,使所述暴露标识符标明的对象对应的收据内容以明文形式存储、其余收据内容以密文形式存储。The storage unit stores the receipt data. When the transaction initiator belongs to the preset user type, the receipt content corresponding to the object indicated by the exposure identifier is stored in plain text, and the rest of the receipt content is stored in cipher text.
根据本说明书一个或多个实施例的第三方面,提出了一种电子设备,包括:According to a third aspect of one or more embodiments of this specification, an electronic device is proposed, including:
处理器;processor;
用于存储处理器可执行指令的存储器;A memory for storing processor executable instructions;
其中,所述处理器通过运行所述可执行指令以实现如第一方面所述的方法。Wherein, the processor implements the method according to the first aspect by running the executable instruction.
根据本说明书一个或多个实施例的第四方面,提出了一种计算机可读存储介质,其上存储有计算机指令,该指令被处理器执行时实现如第一方面所述方法的步骤。According to the fourth aspect of one or more embodiments of the present specification, a computer-readable storage medium is provided, and computer instructions are stored thereon, which, when executed by a processor, implement the steps of the method described in the first aspect.
附图说明Description of the drawings
图1是一示例性实施例提供的一种创建智能合约的示意图。Fig. 1 is a schematic diagram of creating a smart contract according to an exemplary embodiment.
图2是一示例性实施例提供的一种调用智能合约的示意图。Fig. 2 is a schematic diagram of invoking a smart contract provided by an exemplary embodiment.
图3是一示例性实施例提供的一种结合代码标注与用户类型的收据存储方法的流程图。Fig. 3 is a flowchart of a receipt storage method combining code labeling and user type according to an exemplary embodiment.
图4是一示例性实施例提供的一种在区块链节点上实现隐私保护的示意图。Fig. 4 is a schematic diagram of implementing privacy protection on blockchain nodes according to an exemplary embodiment.
图5是一示例性实施例提供的一种通过系统合约和链代码实现区块链网络的功能逻辑的示意图。Fig. 5 is a schematic diagram of the functional logic of implementing a blockchain network through a system contract and a chain code provided by an exemplary embodiment.
图6是一示例性实施例提供的一种结合代码标注与用户类型的收据存储节点的框图。Fig. 6 is a block diagram of a receipt storage node combining code labeling and user type according to an exemplary embodiment.
具体实施方式Detailed ways
这里将详细地对示例性实施例进行说明,其示例表示在附图中。下面的描述涉及附图时,除非另有表示,不同附图中的相同数字表示相同或相似的要素。以下示例性实施例中所描述的实施方式并不代表与本说明书一个或多个实施例相一致的所有实施方式。相反,它们仅是与如所附权利要求书中所详述的、本说明书一个或多个实施例的一些方面相一致的装置和方法的例子。Here, exemplary embodiments will be described in detail, and examples thereof are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings indicate the same or similar elements. The implementation manners described in the following exemplary embodiments do not represent all implementation manners consistent with one or more embodiments of this specification. On the contrary, they are merely examples of devices and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.
需要说明的是:在其他实施例中并不一定按照本说明书示出和描述的顺序来执行相应方法的步骤。在一些其他实施例中,其方法所包括的步骤可以比本说明书所描述的更多或更少。此外,本说明书中所描述的单个步骤,在其他实施例中可能被分解为多个步骤进行描述;而本说明书中所描述的多个步骤,在其他实施例中也可能被合并为单个步骤进行描述。It should be noted that in other embodiments, the steps of the corresponding method may not be executed in the order shown and described in this specification. In some other embodiments, the method includes more or fewer steps than described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may also be combined into a single step in other embodiments. description.
区块链一般被划分为三种类型:公有链(Public Blockchain),私有链(Private Blockchain)和联盟链(Consortium Blockchain)。此外,还有多种类型的结合,比如私有链+联盟链、联盟链+公有链等不同组合形式。其中去中心化程度最高的是公有链。公有链以比特币、以太坊为代表,加入公有链的参与者可以读取链上的数据记录、参与交易以及竞争新区块的记账权等。而且,各参与者(即节点)可自由加入以及退出网络,并进行相关操作。私有链则相反,该网络的写入权限由某个组织或者机构控制,数据读取权限受组织规定。简单来说,私有链可以为一个弱中心化系统,参与节点具有严格限制且少。这种类型的区块链更适合于特定机构内部使用。联盟链则是介于公有链以及私有链之间的区块链,可实现“部分去中心化”。联盟链中各个节点通常有与之相对应的实体机构或者组织;参与者通过授权加入网络并组成利益相关联盟,共同维护区块链运行。Blockchain is generally divided into three types: Public Blockchain, Private Blockchain and Consortium Blockchain. In addition, there are many types of combinations, such as private chain + alliance chain, alliance chain + public chain and other different combinations. The most decentralized one is the public chain. The public chain is represented by Bitcoin and Ethereum. Participants who join the public chain can read the data records on the chain, participate in transactions, and compete for the accounting rights of new blocks. Moreover, each participant (ie, node) can freely join and exit the network, and perform related operations. The private chain is the opposite. The write permission of the network is controlled by an organization or institution, and the data read permission is regulated by the organization. In simple terms, the private chain can be a weakly centralized system with strict restrictions and few participating nodes. This type of blockchain is more suitable for internal use by specific institutions. The alliance chain is a block chain between the public chain and the private chain, which can achieve "partial decentralization". Each node in the alliance chain usually has a corresponding entity or organization; participants are authorized to join the network and form a stakeholder alliance to jointly maintain the operation of the blockchain.
不论是公有链、私有链还是联盟链,都可能提供智能合约的功能。区块链上的智能合约是在区块链系统上可以被交易触发执行的合约。智能合约可以通过代码的形式定义。Whether it is a public chain, a private chain or a consortium chain, it is possible to provide the function of a smart contract. A smart contract on the blockchain is a contract that can be triggered and executed by a transaction on the blockchain system. Smart contracts can be defined in the form of codes.
以以太坊为例,支持用户在以太坊网络中创建并调用一些复杂的逻辑,这是以太坊 区别于比特币区块链技术的最大挑战。以太坊作为一个可编程区块链的核心是以太坊虚拟机(EVM),每个以太坊节点都可以运行EVM。EVM是一个图灵完备的虚拟机,这意味着可以通过它实现各种复杂的逻辑。用户在以太坊中发布和调用智能合约就是在EVM上运行的。实际上,虚拟机直接运行的是虚拟机代码(虚拟机字节码,下简称“字节码”)。部署在区块链上的智能合约可以是字节码的形式。Taking Ethereum as an example, it supports users to create and call some complex logic in the Ethereum network. This is the biggest challenge that distinguishes Ethereum from Bitcoin blockchain technology. The core of Ethereum as a programmable blockchain is the Ethereum Virtual Machine (EVM), and each Ethereum node can run EVM. EVM is a Turing complete virtual machine, which means that various complex logic can be implemented through it. Users publish and call smart contracts in Ethereum run on the EVM. In fact, the virtual machine directly runs virtual machine code (virtual machine bytecode, hereinafter referred to as "bytecode"). The smart contract deployed on the blockchain can be in the form of bytecode.
例如图1所示,Bob将一个包含创建智能合约信息的交易发送到以太坊网络后,节点1的EVM可以执行这个交易并生成对应的合约实例。图中1中的“0x6f8ae93…”代表了这个合约的地址,交易的data字段保存的可以是字节码,交易的to字段为空。节点间通过共识机制达成一致后,这个合约成功创建,并且可以在后续过程中被调用。合约创建后,区块链上出现一个与该智能合约对应的合约账户,并拥有一个特定的地址,合约代码将保存在该合约账户中。智能合约的行为由合约代码控制。换句话说,智能合约使得区块链上产生包含合约代码和账户存储(Storage)的虚拟账户。For example, as shown in Figure 1, after Bob sends a transaction containing the creation of a smart contract to the Ethereum network, the EVM of node 1 can execute the transaction and generate a corresponding contract instance. "0x6f8ae93..." in the figure 1 represents the address of this contract, the data field of the transaction can be stored in bytecode, and the to field of the transaction is empty. After the nodes reach an agreement through the consensus mechanism, the contract is successfully created and can be called in the subsequent process. After the contract is created, a contract account corresponding to the smart contract appears on the blockchain and has a specific address, and the contract code will be stored in the contract account. The behavior of the smart contract is controlled by the contract code. In other words, smart contracts enable virtual accounts containing contract codes and account storage (Storage) to be generated on the blockchain.
如图2所示,仍以以太坊为例,Bob将一个用于调用智能合约的交易发送到以太坊网络后,某一节点的EVM可以执行这个交易并生成对应的合约实例。图中2中交易的from字段是交易发起方(即Bob)的账户的地址,to字段中的“0x6f8ae93…”代表了被调用的智能合约的地址,value字段在以太坊中是以太币的值,交易的data字段保存的调用智能合约的方法和参数。智能合约以规定的方式在区块链网络中每个节点独立的执行,所有执行记录和数据都保存在区块链上,所以当交易完成后,区块链上就保存了无法篡改、不会丢失的交易凭证。As shown in Figure 2, still taking Ethereum as an example, after Bob sends a transaction for invoking a smart contract to the Ethereum network, the EVM of a certain node can execute the transaction and generate a corresponding contract instance. The from field of the transaction in Figure 2 is the address of the account of the transaction initiator (ie Bob), the "0x6f8ae93..." in the to field represents the address of the called smart contract, and the value field in Ethereum is the value of Ether , The method and parameters of calling the smart contract are stored in the data field of the transaction. Smart contracts are executed independently on each node in the blockchain network in a prescribed manner. All execution records and data are stored on the blockchain, so when the transaction is completed, the blockchain will be stored on the blockchain that cannot be tampered with. Lost transaction certificate.
区块链网络中的节点在执行Bob发起的交易后,会生成相应的收据(receipt)数据,以用于记录该交易相关的收据信息。以以太坊为例,节点执行交易所得的收据数据可以包括如下内容:After the nodes in the blockchain network execute the transaction initiated by Bob, they will generate corresponding receipt data to record the receipt information related to the transaction. Taking Ethereum as an example, the receipt data obtained by a node executing a transaction can include the following:
Result字段,表示交易的执行结果;The Result field indicates the execution result of the transaction;
Gas used字段,表示交易消耗的gas值;The Gas used field indicates the gas value consumed by the transaction;
Logs字段,表示交易产生的日志,日志可以进一步包括From字段、To字段、Topic字段和Log data字段等,其中From字段表示调用的发起方的账户地址、To字段表示被调用对象(如智能合约)的账户地址、Topic字段表示日志的主题、Log data字段表示日志数据;The Logs field indicates the log generated by the transaction. The log can further include the From field, To field, Topic field, and Log data field, among which the From field indicates the account address of the initiator of the call, and the To field indicates the called object (such as a smart contract) The account address and Topic field indicate the subject of the log, and the Log data field indicates the log data;
Output字段,表示交易的输出。The Output field indicates the output of the transaction.
一般的,交易执行后生成的收据数据以明文形式进行存储,任何人都可以看到收据数据所含的上述各个收据字段的内容,无隐私保护的设置和能力。而在一些区块链与TEE相结合的解决方案中,为了实现隐私保护,收据数据的全部内容均被当作需要隐私保护的数据存储在区块链上。所述区块链,是存储在节点的数据库中特定逻辑组织而成的数据集合。所述数据库,如后所述,其物理载体可以存储介质,例如持久性存储介质。实际上,收据数据中可能只有部分内容是敏感的,而其它内容并不敏感,只需要针对敏感的内容进行隐私保护、其他内容可以公开,甚至在一些情况下可能需要对部分内容实施检索以驱动相关操作的实施,那么针对这部分内容实施隐私保护将影响检索操作的实施。Generally, the receipt data generated after the transaction is executed is stored in plain text, and anyone can see the contents of the above-mentioned receipt fields contained in the receipt data, without privacy protection settings and capabilities. In some solutions that combine blockchain and TEE, in order to achieve privacy protection, the entire content of the receipt data is stored on the blockchain as data that requires privacy protection. The block chain is a data set stored in a database of a node and organized by a specific logic. The database, as described later, may be a storage medium, such as a persistent storage medium, on a physical carrier. In fact, only part of the content of the receipt data may be sensitive, while other content is not sensitive. Only sensitive content needs to be protected for privacy, other content can be disclosed, and in some cases it may even be necessary to retrieve some content to drive Implementation of related operations, the implementation of privacy protection for this part of the content will affect the implementation of retrieval operations.
以下结合图3所示说明本申请一结合代码标注与用户类型的收据存储方法的实施例的实现过程:The following describes the implementation process of an embodiment of a receipt storage method combining code labeling and user type of the present application with reference to FIG. 3:
步骤302,第一区块链节点接收经过加密的对应于智能合约的交易,所述智能合约的代码中包括通过暴露标识符标明的对象。In step 302, the first blockchain node receives an encrypted transaction corresponding to a smart contract, and the code of the smart contract includes an object marked by an exposed identifier.
在一实施例中,用户在编写智能合约的代码时,可以通过在代码中添加暴露标识符来标明一个或多个对象,使得收据数据中对应于这部分对象的收据内容能够采用明文存储,那么剩余未标注暴露标识符的对象所对应的收据内容需要采用密文存储,以实现相应的隐私保护。In one embodiment, when the user writes the code of the smart contract, he can add an exposure identifier to the code to mark one or more objects, so that the receipt content corresponding to this part of the object in the receipt data can be stored in plain text, then The contents of the receipts corresponding to the remaining objects without an exposed identifier need to be stored in cipher text to achieve corresponding privacy protection.
如上文所述,在用于创建智能合约的交易中,data字段保存的可以是该智能合约的字节码。字节码由一连串的字节组成,每一字节可以标识一个操作。基于开发效率、可读性等多方面考虑,开发者可以不直接书写字节码,而是选择一门高级语言编写智能合约代码。高级语言编写的智能合约的代码,经过编译器编译而生成字节码,进而该字节码可以部署到区块链上。以太坊支持的高级语言很多,如Solidity、Serpent、LLL语言等。As mentioned above, in a transaction used to create a smart contract, the data field can store the bytecode of the smart contract. The bytecode consists of a series of bytes, and each byte can identify an operation. Based on many considerations such as development efficiency and readability, developers can choose a high-level language to write smart contract code instead of directly writing bytecode. The code of a smart contract written in a high-level language is compiled by a compiler to generate bytecode, and then the bytecode can be deployed on the blockchain. There are many high-level languages supported by Ethereum, such as Solidity, Serpent, and LLL languages.
以Solidity语言为例,用其编写的合约与面向对象编程语言中的类(Class)很相似,在一个合约中可以声明多种成员,包括状态变量、函数、函数修改器、事件等。如下是以Solidity语言编写的一个简单的智能合约的代码示例1:Taking the Solidity language as an example, the contract written in it is very similar to the class in the object-oriented programming language. A variety of members can be declared in a contract, including state variables, functions, function modifiers, and events. The following is a simple smart contract code example 1 written in Solidity language:
Figure PCTCN2020091419-appb-000001
Figure PCTCN2020091419-appb-000001
Figure PCTCN2020091419-appb-000002
Figure PCTCN2020091419-appb-000002
在基于Solidity语言编写的智能合约的代码中,可以通过暴露标识符来标明一个或多个对象,使得收据数据中对应于这部分对象的收据内容能够以明文形式存储,而其余的收据内容以密文形式存储。类似地,在基于Serpent、LLL语言等编写的智能合约的代码中,同样可以通过暴露标识符来标明一个或多个对象,以实现相关收据内容的明文存储。In the code of the smart contract written in Solidity language, one or more objects can be marked by exposing identifiers, so that the receipt content corresponding to this part of the object in the receipt data can be stored in plain text, while the rest of the receipt content is encrypted Document storage. Similarly, in the code of a smart contract written based on Serpent, LLL language, etc., one or more objects can also be marked by exposing identifiers to realize the plaintext storage of the relevant receipt content.
暴露标识符可以为专用于表明需要明文存储的收据字段,例如可以采用关键字plain来表征该暴露标识符。那么,对于希望以明文形式存储的收据内容,可以在相应的对象之前添加plain(或者,也可以采用其他方式与相应的对象进行关联)。The exposure identifier may be a receipt field dedicated to indicating that plain text storage is required. For example, the keyword plain may be used to characterize the exposure identifier. Then, for the receipt content that you want to store in plain text, you can add plain before the corresponding object (or, you can also associate with the corresponding object in other ways).
暴露标识符标明的对象可以包括收据字段,比如上文所述的Result字段、Gas used字段、Logs字段、Output字段等,或者Logs字段中进一步包含的From字段、To字段、Topic字段、Log data字段等。例如,可以将上述的代码示例1调整为下述的代码示例2:The object marked by the exposure identifier can include receipt fields, such as the Result field, Gas used field, Logs field, Output field, etc., as described above, or the From field, To field, Topic field, and Log data field further contained in the Logs field Wait. For example, the code sample 1 above can be adjusted to the following code sample 2:
Figure PCTCN2020091419-appb-000003
Figure PCTCN2020091419-appb-000003
在上述的代码示例2中,通过在智能合约的代码最前方添加暴露标识符plain,使得智能合约的代码被执行后,如果交易发起方属于预设用户类型,那么产生的收据数据中的所有字段均以明文形式进行存储。In the above code example 2, by adding the exposed identifier plain at the front of the smart contract code, after the smart contract code is executed, if the transaction initiator belongs to the preset user type, all fields in the generated receipt data All are stored in plain text.
当然,在其他实施例中,也可以具体指明需要明文存储的字段。比如,通过暴露标 识符对From字段进行标注时,可使得智能合约的代码被执行后,如果交易发起方属于预设用户类型,那么产生的收据数据中的From字段对应的收据内容以明文形式进行存储,而后续可以针对该From字段中的收据内容实施检索操作,比如可以统计某一账户所发起的交易量等。Of course, in other embodiments, the fields that need to be stored in plaintext can also be specified. For example, when the From field is marked by the exposed identifier, after the code of the smart contract is executed, if the transaction initiator belongs to the preset user type, the content of the receipt corresponding to the From field in the generated receipt data is in plain text. Store, and subsequently retrieve the content of the receipt in the From field, such as counting the transaction volume initiated by a certain account.
需要指出的是:在上述的代码示例2及其相关实施例中,由暴露标识符“plain”所标明的对象(所有字段或From字段)为合约级对象,使得第一区块链节点在存储收据数据时,将收据数据中对应于该合约级对象的所有收据内容以明文形式存储(前提为交易发起方属于预设用户类型)。尤其是,当智能合约的代码中包含多个事件时,合约级对象可以适用于智能合约中的所有事件,那么以From字段为例:当交易发起方属于预设用户类型时,对于多个事件分别的产生各自对应的Logs字段,每一Logs字段所含的From字段均会采用明文形式进行存储,而无需针对每一事件分别添加暴露标识符。It should be pointed out that in the above code example 2 and related embodiments, the objects (all fields or From fields) marked by the exposed identifier "plain" are contract-level objects, so that the first blockchain node is storing When receiving receipt data, store all receipt contents corresponding to the contract-level object in the receipt data in plain text (provided that the transaction initiator belongs to the preset user type). In particular, when the code of a smart contract contains multiple events, the contract-level object can be applied to all events in the smart contract. Take the From field as an example: when the transaction initiator belongs to the preset user type, for multiple events The corresponding Logs fields are generated separately, and the From field contained in each Logs field will be stored in plain text, without the need to add an exposure identifier for each event.
除了收据字段之外,暴露标识符还可以用于标明其他对象。例如,暴露标识符标明的对象可以包括状态变量,且该状态变量同样可以为合约级对象。以状态变量“price”为例,可以将上述的代码示例1调整为下述的代码示例3:In addition to the receipt field, the exposed identifier can also be used to identify other objects. For example, the object indicated by the exposure identifier may include a state variable, and the state variable may also be a contract-level object. Taking the state variable "price" as an example, the above code example 1 can be adjusted to the following code example 3:
Figure PCTCN2020091419-appb-000004
Figure PCTCN2020091419-appb-000004
在上述的代码示例3中,通过在状态变量“price”的类型int之前添加暴露标识符“plain”(或者,可以将暴露标识符plain置于类型int之后),使得当交易发起方属于预设用户类型时,在智能合约的代码被执行后产生的收据数据的各个字段(通常包括Topic字段、Output字段等)中,与状态变量“price”相关的收据内容均以明文形式进行存储,那么后续可以针对与状态变量“price”相关的收据内容实施检索操作。由于状态变量“price”在代码示例3中属于合约级对象,使得当智能合约的代码中包含多个事件时,合约级对象可以适用于智能合约中的所有事件,那么当多个事件分别产生各自对 应的Logs字段时,每一Logs字段(如Logs字段中的Topic字段)均会采用明文形式存储与状态变量“price”相关的收据内容,Output字段等也会采用明文形式存储与状态变量“price”相关的收据内容,无需在每一事件中分别针对状态变量“price”添加暴露标识符。In the above code example 3, by adding the exposed identifier "plain" before the type int of the state variable "price" (or, the exposed identifier plain can be placed after the type int), so that when the transaction initiator belongs to the default In the case of user type, in each field (usually including Topic field, Output field, etc.) of the receipt data generated after the code of the smart contract is executed, the content of the receipt related to the state variable "price" is stored in plain text, then the subsequent The retrieval operation can be performed on the content of the receipt related to the state variable "price". Since the state variable "price" belongs to the contract-level object in code example 3, when the code of the smart contract contains multiple events, the contract-level object can be applied to all events in the smart contract. Then when multiple events are generated separately For the corresponding Logs field, each Logs field (such as the Topic field in the Logs field) will store the receipt content related to the state variable "price" in clear text, and the Output field will also be stored in clear text with the state variable "price" "Related receipt content, there is no need to add an exposure identifier for the state variable "price" in each event.
当智能合约的代码中定义了多个状态变量时,上述的合约级对象可以包括其中的部分或全部状态变量。例如,智能合约可以包括下述的代码示例4:When multiple state variables are defined in the code of the smart contract, the above-mentioned contract-level object may include some or all of the state variables. For example, a smart contract can include the following code example 4:
Figure PCTCN2020091419-appb-000005
Figure PCTCN2020091419-appb-000005
在上述的代码示例4中,智能合约的代码中定义了“price”、“price1”等多个状态变量,而用户可以仅针对状态变量“price”添加暴露标识符plain,使得该状态变量“price”成为合约级对象,而状态变量“price1”则并未由暴露标识符进行标注。In the above code example 4, multiple state variables such as "price" and "price1" are defined in the code of the smart contract, and the user can only add the exposure identifier plain for the state variable "price", so that the state variable "price" "Becomes a contract-level object, and the state variable "price1" is not marked by an exposed identifier.
除了合约级对象之外,暴露标识符标明的对象可以包括:对应于智能合约中定义的至少一个事件的事件级对象,使得第一区块链节点在存储收据数据时,如果交易发起方属于预设用户类型,就可以将收据数据中对应于该至少一个事件的收据内容以明文形式存储。尤其是,当智能合约中包含多个事件时,可以针对至少一部分事件设定上述的事件级对象,使得这部分事件对应的收据内容以明文形式存储、其余事件对应的收据内容以密文形式存储。以From字段为例,可以将上述的代码示例1调整为下述的代码示例5:In addition to contract-level objects, the objects indicated by the exposure identifier may include: event-level objects corresponding to at least one event defined in the smart contract, so that when the first blockchain node stores receipt data, if the transaction initiator belongs to the pre- Assuming the user type, the receipt content corresponding to the at least one event in the receipt data can be stored in plain text. Especially, when the smart contract contains multiple events, the above event-level objects can be set for at least some of the events, so that the content of the receipt corresponding to this part of the event is stored in plain text, and the content of the receipt corresponding to the remaining events is stored in cipher text . Taking the From field as an example, the above code example 1 can be adjusted to the following code example 5:
Figure PCTCN2020091419-appb-000006
Figure PCTCN2020091419-appb-000006
Figure PCTCN2020091419-appb-000007
Figure PCTCN2020091419-appb-000007
在上述的代码示例5中,通过在事件currentPrice对应的事件函数“event currentPrice(int price)”中添加From字段对应的字符“from”,并且在该字符from所采用的暴露标识符区别于前述的plain,而是通过引号对该字符from进行修饰,则代码示例5中的引号相当于前述的暴露标识符,将From字段配置为事件级对象,使得当交易发起方属于预设用户类型时,在该事件对应产生的Logs字段中,From字段将以明文形式进行存储。除了上述事件currentPrice之外,如果智能合约的代码还包含另一事件,那么上述的字符from不会影响该另一事件、该另一事件对应的收据内容将以密文形式进行存储,除非存在针对该另一事件而添加的“from”。In the above code example 5, the character "from" corresponding to the From field is added to the event function "event currentPrice(int price)" corresponding to the event currentPrice, and the exposed identifier used in the character from is different from the aforementioned plain, but modify the character from with quotation marks. The quotation marks in code example 5 are equivalent to the aforementioned exposed identifier. Configure the From field as an event-level object, so that when the transaction initiator belongs to the preset user type, In the Logs field corresponding to this event, the From field will be stored in plain text. In addition to the above event currentPrice, if the code of the smart contract also contains another event, then the above character from will not affect the other event, and the receipt content corresponding to the other event will be stored in ciphertext unless there is a "From" added for this other event.
事件级对象还可以包括状态变量。以状态变量“price”为例,可以将上述的代码示例1调整为下述的代码示例6:Event-level objects can also include state variables. Taking the state variable "price" as an example, the above code example 1 can be adjusted to the following code example 6:
Figure PCTCN2020091419-appb-000008
Figure PCTCN2020091419-appb-000008
在上述的代码示例6中,通过在事件currentPrice对应的事件函数“event currentPrice(int price)”之前添加关键字“plain”,而区别于代码示例5中添加的“from”,使得此处并未指明事件级对象为From字段,那么:In the above code sample 6, the keyword "plain" is added before the event function "event currentPrice(int price)" corresponding to the event currentPrice, which is different from the "from" added in code sample 5, so that there is no Specify the event-level object as the From field, then:
一种情况下,事件级对象可以包括字段,这与上述的From字段相类似。但是,由于未指明具体的字段,可以将事件currentPrice所产生的日志中的所有字段均作为上述 的事件级对象,譬如前述的From字段、To字段、Topic字段、Log Data字段等,使得在交易发起方属于预设用户类型时,将该事件currentPrice对应的所有收据内容均以明文形式存储。In one case, the event-level object may include fields, which is similar to the above-mentioned From field. However, since no specific fields are specified, all fields in the log generated by the event currentPrice can be regarded as the above event-level objects, such as the aforementioned From field, To field, Topic field, Log Data field, etc., so that the transaction is initiated When the party belongs to the preset user type, all the contents of the receipt corresponding to the event currentPrice are stored in plain text.
另一种情况下,事件级对象可以包括状态变量。例如,上述的代码示例6中定义了状态变量“price”,并且事件currentPrice引用了该状态变量“price”,对应于在事件函数“event currentPrice(int price)”之前添加暴露标识符“plain”,可以将状态变量“price”作为上述的事件级对象,使得在交易发起方属于预设用户类型时,该事件产生的所有与状态变量“price”相关的收据内容均以明文形式进行存储。由于状态变量“price”在代码示例6中属于事件级对象,使得当智能合约的代码中还包含另一引用状态变量“price”的事件event1时,如果并未针对该事件event1添加任何级别的暴露标识符,那么即便该事件event1引用了状态变量“price”,该事件event1所产生的收据内容仍将以密文形式进行存储,而并非以明文形式存储。In another case, event-level objects can include state variables. For example, the above code example 6 defines the state variable "price", and the event currentPrice refers to the state variable "price", which corresponds to adding the exposure identifier "plain" before the event function "event currentPrice(int price)", The state variable "price" can be used as the above-mentioned event-level object, so that when the transaction initiator belongs to the preset user type, all receipts related to the state variable "price" generated by the event are stored in plain text. Since the state variable "price" belongs to the event-level object in Code Example 6, when the code of the smart contract also contains another event event1 that references the state variable "price", if no level of exposure is added to the event event1 Identifier, even if the event event1 references the state variable "price", the content of the receipt generated by the event event1 will still be stored in cipher text, not in plain text.
当同一事件中引用了多个状态变量时,上述的事件级对象可以包括被引用的全部状态变量。例如,可以将上述的代码示例4调整为下述的代码示例7:When multiple state variables are referenced in the same event, the above event-level object may include all the state variables referenced. For example, the above code sample 4 can be adjusted to the following code sample 7:
Figure PCTCN2020091419-appb-000009
Figure PCTCN2020091419-appb-000009
在上述的代码示例7中,事件currentPrice对应的事件函数“event currentPrice(int price,int price1)”引用了状态变量“price”和“price1”,而通过在该事件之前添加暴露标识符plain,使得被引用的状态变量“price”和“price1”均会受到影响,那么当交易发起方属于预设用户类型时,该事件产生的所有与状态变量“price”和“price1”相关的收据内容均以明文形式进行存储。但是,对于其他并未添加暴露标识符plain的事件,产生的收据内容均以密文形式进行存储。In the above code example 7, the event function "event currentPrice(int price, int price1)" corresponding to the event currentPrice refers to the state variables "price" and "price1", and by adding the exposure identifier plain before the event, The quoted state variables "price" and "price1" will both be affected, so when the transaction initiator belongs to the preset user type, all receipts related to the state variables "price" and "price1" generated by the event will be Store in clear text. However, for other events where the exposed identifier plain is not added, the contents of the receipts generated are stored in cipher text.
当事件级对象包括状态变量时,还可以具体指示为事件所引用的一个或多个状态变量。以状态变量“price”为例,可以将上述的代码示例1调整为下述的代码示例8:When the event-level object includes state variables, it can also specifically indicate one or more state variables referenced by the event. Taking the state variable "price" as an example, the above code example 1 can be adjusted to the following code example 8:
Figure PCTCN2020091419-appb-000010
Figure PCTCN2020091419-appb-000010
在上述的代码示例8中,事件currentPrice对应的事件函数“event currentPrice(int price)”引用了状态变量“price”,而通过在该状态变量“price”的类型int之前添加暴露标识符plain,使得该状态变量“price”被配置为事件级对象,并且该事件级对象仅适用于该事件currentPrice、不适用于智能合约包含的其他事件,即:在满足交易发起方属于预设用户类型的前提下,只有事件currentPrice产生的与状态变量“price”相关的收据内容以明文形式进行存储,除非其他事件中也针对状态变量“price”添加了暴露标识符,否则其他事件即便应用了该状态变量“price”,产生的收据内容仍以密文形式进行存储。In the above code example 8, the event function "event currentPrice(int price)" corresponding to the event currentPrice refers to the state variable "price", and by adding the exposure identifier plain before the type int of the state variable "price", so that The state variable "price" is configured as an event-level object, and the event-level object is only applicable to the currentPrice event and not applicable to other events included in the smart contract, that is: on the premise that the transaction initiator belongs to the preset user type , Only the receipt content related to the state variable "price" generated by the event currentPrice is stored in plain text. Unless other events also add an exposure identifier for the state variable "price", other events even if the state variable "price" is applied ", the generated receipt content is still stored in cipher text.
由于代码示例8中的事件currentPrice仅应用了状态变量“price”,使其实际效果与上述的代码示例6中针对该事件添加暴露标识符、将该事件引用的状态变量“price”配置为事件级对象相似。而当事件同时应用多个状态变量时,可以更加清晰地体现出两者的不同,比如可以将上述的代码示例4调整为下述的代码示例9:Since the event currentPrice in code sample 8 only applies the state variable "price", its actual effect is the same as the above code sample 6 for adding an exposure identifier for the event, and configuring the state variable "price" referenced by the event as the event level The objects are similar. When multiple state variables are applied to the event at the same time, the difference between the two can be more clearly reflected. For example, the above code example 4 can be adjusted to the following code example 9:
Figure PCTCN2020091419-appb-000011
Figure PCTCN2020091419-appb-000011
Figure PCTCN2020091419-appb-000012
Figure PCTCN2020091419-appb-000012
在上述的代码示例9中,事件currentPrice同时引用了状态变量“price”和“price1”,而通过在状态变量“price”的类型int之前添加暴露标识符plain,可以将该状态变量“price”配置为事件级对象,而未添加暴露标识符plain的状态变量“price1”则并非事件级对象,使得在满足交易发起方属于预设用户类型的前提下,该事件产生的与状态变量“price”相关的收据内容以明文形式进行存储、与状态变量“price1”相关的收据内容仍以密文形式进行存储。In the code sample 9 above, the event currentPrice references the state variables "price" and "price1" at the same time, and the state variable "price" can be configured by adding the exposure identifier plain before the type int of the state variable "price" It is an event-level object, and the state variable "price1" without the exposed identifier plain is not an event-level object, so that the event generated by the event is related to the state variable "price" on the premise that the transaction initiator belongs to the preset user type The receipt content of is stored in plain text, and the receipt content related to the state variable "price1" is still stored in cipher text.
在一实施例中,第一区块链节点接收的交易对应的智能合约,可以是通过高级语言编写的智能合约,或者可以是字节码形式的智能合约。其中,当智能合约为高级语言编写的智能合约时,第一区块链节点还通过编译器对该高级语言编写的智能合约进行编译,生成字节码形式的智能合约,以在可信执行环境中执行。而当第一区块链节点接收的交易对应的智能合约为字节码形式的智能合约时,该字节码形式的智能合约可由客户端通过编译器对高级语言编写的智能合约进行编译而得到,而该高级语言编写的智能合约由用户在客户端上编写得到。In an embodiment, the smart contract corresponding to the transaction received by the first blockchain node may be a smart contract written in a high-level language, or may be a smart contract in the form of bytecode. Among them, when the smart contract is a smart contract written in a high-level language, the first blockchain node also compiles the smart contract written in the high-level language through a compiler to generate a smart contract in the form of bytecode to be used in a trusted execution environment In execution. When the smart contract corresponding to the transaction received by the first blockchain node is a smart contract in bytecode form, the smart contract in bytecode form can be obtained by compiling the smart contract written in high-level language by the client through the compiler , And the smart contract written in this high-level language is written by the user on the client.
对于第一区块链节点接收的交易对应的智能合约,可以为用户在第一区块链节点上生成的智能合约。当用户采用高级语言编写得到上述的智能合约时,第一区块链节点还通过编译器将该高级语言编写的智能合约编译为字节码形式的智能合约;或者,用户也可能在第一区块链节点上直接编写得到字节码形式的智能合约。The smart contract corresponding to the transaction received by the first blockchain node may be a smart contract generated by the user on the first blockchain node. When the user writes the above-mentioned smart contract in a high-level language, the first blockchain node also uses a compiler to compile the smart contract written in the high-level language into a smart contract in the form of bytecode; or, the user may also be in the first area Smart contracts in bytecode form are directly written on the blockchain nodes.
对于第一区块链节点接收的交易对应的智能合约,可以为用户在客户端上生成的智能合约。例如,用户通过对应的账户在客户端生成该交易后,通过该客户端将交易提交至第一区块链节点。以图4为例,第一区块链节点中包含交易/查询接口,该接口可与客户端对接,使得客户端可以向第一区块链节点提交上述交易。比如上文所述,用户可以采用高级语言在客户端上编写智能合约,然后由客户端通过编译器对该高级语言的智能合约进行编译,得到相应的字节码形式的智能合约。当然,客户端可以直接将高级语言编写的智能合约发送至第一区块链节点,使得第一区块链节点通过编译器编译为字节码形式的智能合约。The smart contract corresponding to the transaction received by the first blockchain node may be a smart contract generated by the user on the client. For example, after the user generates the transaction on the client through the corresponding account, the client submits the transaction to the first blockchain node. Taking FIG. 4 as an example, the first blockchain node includes a transaction/query interface, which can be connected with the client, so that the client can submit the above-mentioned transaction to the first blockchain node. For example, as mentioned above, the user can use a high-level language to write a smart contract on the client, and then the client uses a compiler to compile the smart contract in the high-level language to obtain the corresponding smart contract in bytecode form. Of course, the client can directly send a smart contract written in a high-level language to the first blockchain node, so that the first blockchain node is compiled into a bytecode smart contract by a compiler.
对于第一区块链节点接收的交易对应的智能合约,可以为客户端通过第二区块链节点发来的交易中的智能合约,该智能合约通常为字节码形式;当然,该智能合约也可以 为高级语言编写的智能合约,则第一区块链节点可以通过编译器编译为字节码形式的智能合约。For the smart contract corresponding to the transaction received by the first blockchain node, it can be the smart contract in the transaction sent by the client through the second blockchain node. The smart contract is usually in the form of bytecode; of course, the smart contract It can also be a smart contract written in a high-level language, and the first blockchain node can be compiled into a bytecode smart contract by a compiler.
在一实施例中,当智能合约的代码中包括暴露标识符时,高级语言编写的智能合约与字节码形式的智能合约可以具有相同的暴露标识符。而本领域技术人员应当理解的是:字节码可以采用不同于高级语言的暴露标识符,比如高级语言编写的智能合约的代码中包含第一标识符、字节码形式的智能合约的代码中包含第二标识符,则第一标识符与第二标识符之间存在对应关系,确保由高级语言编译为字节码后,不会影响暴露标识符的功能。In an embodiment, when the code of the smart contract includes an exposure identifier, the smart contract written in a high-level language and the smart contract in the form of bytecode may have the same exposure identifier. Those skilled in the art should understand that the bytecode can use an exposed identifier different from a high-level language. For example, the code of a smart contract written in a high-level language contains the first identifier and the code of the smart contract in the form of bytecode. If the second identifier is included, there is a corresponding relationship between the first identifier and the second identifier to ensure that after being compiled into bytecode by a high-level language, the function of exposing the identifier will not be affected.
步骤304,第一区块链节点在可信执行环境中解密所述交易,以获得所述智能合约的代码。Step 304: The first blockchain node decrypts the transaction in the trusted execution environment to obtain the code of the smart contract.
在一实施例中,上述交易可以通过对称加密算法的方式进行加密,也可以采用非对称算法的方式进行加密。对称加密采用的加密算法,例如是DES算法,3DES算法,TDEA算法,Blowfish算法,RC5算法,IDEA算法等。非对称加密算法,例如是RSA、Elgamal、背包算法、Rabin、D-H、ECC(椭圆曲线加密算法)等。In an embodiment, the foregoing transaction may be encrypted by a symmetric encryption algorithm, or may be encrypted by an asymmetric algorithm. The encryption algorithm used by symmetric encryption, such as DES algorithm, 3DES algorithm, TDEA algorithm, Blowfish algorithm, RC5 algorithm, IDEA algorithm, etc. Asymmetric encryption algorithms, such as RSA, Elgamal, knapsack algorithm, Rabin, D-H, ECC (elliptic curve encryption algorithm), etc.
在一实施例中,上述交易可以通过对称加密算法结合非对称加密算法的方式进行加密。以客户端将上述交易提交至第一区块链节点为例,客户端可以采用对称加密算法加密交易内容,即采用对称加密算法的密钥加密交易内容,并用非对称加密算法加密对称加密算法中采用的密钥,譬如采用非对称加密算法的公钥加密对称加密算法中采用的密钥。这样,第一区块链节点接收到加密的交易后,可以先采用非对称加密算法的私钥进行解密,得到对称加密算法的密钥,进而用对称加密算法的密钥解密得到交易内容。例如,当交易用于创建智能合约时,交易内容可以包括所需创建的智能合约的代码;当交易用于调用智能合约时,交易内容可以包括被调用的智能合约的账户地址、需要传入的方法和参数等。In one embodiment, the foregoing transaction may be encrypted by a combination of a symmetric encryption algorithm and an asymmetric encryption algorithm. Taking the client submitting the above transaction to the first blockchain node as an example, the client can use a symmetric encryption algorithm to encrypt the transaction content, that is, use the symmetric encryption algorithm key to encrypt the transaction content, and use an asymmetric encryption algorithm to encrypt the symmetric encryption algorithm The key used, for example, the key used in the public key encryption symmetric encryption algorithm using an asymmetric encryption algorithm. In this way, after the first blockchain node receives the encrypted transaction, it can first decrypt it with the private key of the asymmetric encryption algorithm to obtain the key of the symmetric encryption algorithm, and then decrypt it with the key of the symmetric encryption algorithm to obtain the transaction content. For example, when a transaction is used to create a smart contract, the transaction content can include the code of the smart contract that needs to be created; when the transaction is used to call a smart contract, the transaction content can include the account address of the smart contract being called, and the required input Methods and parameters, etc.
当交易用于调用智能合约时,可以是多重嵌套结构的调用。例如,交易直接调用智能合约1,而该智能合约1的代码调用了智能合约2,且智能合约2中的代码指向了智能合约3的合约地址,使得交易实际上间接调用了智能合约3的代码,而智能合约3中的代码可以包括通过暴露标识符标明的对象。这样,相当于智能合约1中包含了通过暴露标识符标明的对象。具体实现过程与上述过程类似,在此不再赘述。When a transaction is used to call a smart contract, it can be a call of multiple nested structures. For example, the transaction directly calls smart contract 1, and the code of smart contract 1 calls smart contract 2, and the code in smart contract 2 points to the contract address of smart contract 3, so that the transaction actually calls the code of smart contract 3 indirectly , And the code in smart contract 3 can include objects marked by exposed identifiers. In this way, it is equivalent to that the smart contract 1 contains the object identified by the exposed identifier. The specific implementation process is similar to the above process, and will not be repeated here.
步骤306,第一区块链节点在所述可信执行环境中执行所述智能合约的代码,得到 收据数据。Step 306: The first blockchain node executes the code of the smart contract in the trusted execution environment to obtain receipt data.
如前所述,第一区块链节点接收的交易,例如可以是创建和/或调用智能合约的交易。比如在以太坊中,第一区块链节点接收到客户端发来的创建和/或调用智能合约的交易后,可以检查交易是否有效、格式是否正确,验证交易的签名是否合法等。As mentioned above, the transaction received by the first blockchain node may be, for example, a transaction for creating and/or invoking a smart contract. For example, in Ethereum, after the first blockchain node receives the transaction to create and/or call the smart contract from the client, it can check whether the transaction is valid, the format is correct, and the signature of the transaction is legal.
一般来说,以太坊中的节点一般也是争夺记账权的节点,因此,第一区块链节点作为争夺记账权的节点可以在本地执行所述交易。如果争夺记账权的节点中的一个在本轮争夺记账权的过程中胜出,则成为记账节点。第一区块链节点如果在本轮争夺记账权的过程中胜出,就成为记账节点;当然,如果第一区块链节点如果在本轮争夺记账权的过程中没有胜出,则不是记账节点,而其它节点可能成为记账节点。Generally speaking, the nodes in Ethereum are generally nodes that compete for the right to bookkeeping. Therefore, the first blockchain node as the node that competes for the right to bookkeeping can execute the transaction locally. If one of the nodes competing for the accounting right wins in the current round of the accounting right, it becomes the accounting node. If the first blockchain node wins this round of competition for accounting rights, it becomes the accounting node; of course, if the first blockchain node does not win in this round of competition for accounting rights, it is not Accounting nodes, and other nodes may become accounting nodes.
智能合约类似于面向对象编程中的类,执行的结果生成对应该智能合约的合约实例,类似于生成类对应的对象。执行交易中用于创建智能合约的代码的过程,会创建合约账户,并在账户空间中部署合约。以太坊中,智能合约账户的地址是由发送者的地址(如图1-2中的“0xf5e…”)和交易随机数(nonce)作为输入,通过加密算法生成的,比如图1-2中的合约地址“0x6f8ae93…”即由发送者的地址“0xf5e…”和交易中的nonce经加密算法生成。A smart contract is similar to a class in object-oriented programming. The result of execution generates a contract instance corresponding to the smart contract, similar to the object corresponding to the generated class. The process of executing the code used to create a smart contract in a transaction will create a contract account and deploy the contract in the account space. In Ethereum, the address of the smart contract account is generated from the sender's address ("0xf5e..." in Figure 1-2) and the transaction nonce (nonce) as input, and is generated by an encryption algorithm, such as in Figure 1-2 The contract address "0x6f8ae93..." is generated from the sender's address "0xf5e..." and the nonce in the transaction through an encryption algorithm.
一般的,采用工作量证明(Proof of Work,POW)以及股权证明(Proof of Stake,POS)、委任权益证明(Delegated Proof of Stake,DPOS)等共识算法的支持智能合约的区块链网络中,争夺记账权的节点都可以在接收到包含创建智能合约的交易后执行所述交易。争夺记账权的节点中可能其中一个在本轮争夺记账权的过程中胜出,成为记账节点。记账节点可以将该包含智能合约的交易与其它交易一起打包并生成新的区块,并将生成的新的区块发送至其它节点进行共识。Generally, consensus algorithms such as Proof of Work (POW), Proof of Stake (POS), and Delegated Proof of Stake (DPOS) are adopted in blockchain networks that support smart contracts. All nodes competing for the right to account can execute the transaction after receiving the transaction including the creation of a smart contract. One of the nodes competing for the right to bookkeeping may win this round and become the bookkeeping node. The accounting node can package the transaction containing the smart contract with other transactions and generate a new block, and send the generated new block to other nodes for consensus.
对于采用实用拜占庭容错(Practical Byzantine Fault Tolerance,PBFT)等机制的支持智能合约的区块链网络中,具有记账权的节点在本轮记账前已经商定好。因此,第一区块链节点接收到上述交易后,如果自身不是本轮的记账节点,则可以将该交易发送至记账节点。对于本轮的记账节点(可以是第一区块链节点),在将该交易打包并生成新区块的过程中或者之前,或在将该交易与其它交易一起打包并生成新区块的过程中或者之前,可以执行该交易。所述记账节点将该交易打包(或还包括其它交易一起打包)并生成新的区块后,将生成的新的区块或者区块头发送至其它节点进行共识。For a blockchain network supporting smart contracts that adopts mechanisms such as Practical Byzantine Fault Tolerance (PBFT), the nodes with the right to book accounts have been agreed before this round of bookkeeping. Therefore, after the first blockchain node receives the above transaction, if it is not the accounting node of this round, it can send the transaction to the accounting node. For this round of accounting nodes (which can be the first blockchain node), during or before packaging the transaction and generating a new block, or during the process of packaging the transaction together with other transactions and generating a new block Or before, the transaction can be executed. After the accounting node packages the transaction (or other transactions together) and generates a new block, the generated new block or block header is sent to other nodes for consensus.
如上所述,采用POW机制的支持智能合约的区块链网络中,或者采用POS、DPOS、 PBFT机制的支持智能合约的区块链网络中,本轮的记账节点都可以将该交易打包并生成新的区块,并将生成的新的区块后区块头发送至其它节点进行共识。如果其它节点接收到所述区块后经验证没有问题,可以将该新的区块追加到原有的区块链末尾,从而完成记账过程,达成共识;若交易用于创建智能合约,则完成了智能合约在区块链网络上的部署,若交易用于调用智能合约,则完成了智能合约的调用和执行。其它节点验证记账节点发来的新的区块或区块头的过程中,也可以执行所述区块中的交易。As mentioned above, in the blockchain network that supports smart contracts using the POW mechanism, or in the blockchain network that supports smart contracts using the POS, DPOS, and PBFT mechanisms, the accounting nodes in this round can package and package the transaction. Generate a new block, and send the header of the new block to other nodes for consensus. If other nodes receive the block and verify that there is no problem, they can append the new block to the end of the original block chain to complete the accounting process and reach a consensus; if the transaction is used to create a smart contract, then The deployment of the smart contract on the blockchain network is completed. If the transaction is used to call the smart contract, the call and execution of the smart contract are completed. In the process of verifying the new block or block header sent by the accounting node, other nodes may also execute the transaction in the block.
所述执行过程,一般可以通过虚拟机执行。以以太坊为例,支持用户在以太坊网络中创建和/或调用一些复杂的逻辑,这是以太坊区别于比特币区块链技术的最大挑战。以太坊作为一个可编程区块链的核心是以太坊虚拟机(EVM,Ethereum Virtual Machine),每个以太坊节点都可以运行EVM。EVM是一个图灵完备的虚拟机,这意味着可以通过它实现各种复杂的逻辑。用户在以太坊中发布和调用智能合约就是在EVM上运行的。The execution process can generally be executed by a virtual machine. Taking Ethereum as an example, it supports users to create and/or call some complex logic in the Ethereum network. This is the biggest challenge that distinguishes Ethereum from Bitcoin blockchain technology. The core of Ethereum as a programmable blockchain is the Ethereum Virtual Machine (EVM), and every Ethereum node can run EVM. EVM is a Turing complete virtual machine, which means that various complex logic can be implemented through it. Users publish and call smart contracts in Ethereum run on the EVM.
本实施例中,第一区块链节点可以在可信执行环境(Trusted Execution Environment,TEE)中执行解密的智能合约的代码。例如图4所示,第一区块链节点可以划分为常规执行环境(图中位于左侧)和TEE,客户端提交的交易(如上文所述,交易可以存在其他来源;此处以客户端提交的交易为例进行说明)首先进入常规执行环境中的“交易/查询接口”进行识别,不存在隐私处理需求的交易可以被留在常规执行环境中进行处理(这里可以根据交易发起方的用户类型、交易类型、交易所含的标识符等识别是否存在隐私处理需求),而将存在隐私处理需求的交易传递至TEE中进行处理。TEE与常规执行环境相互隔离。交易在进入TEE之前处于加密状态,在可信执行环境内则被解密为明文的交易内容,从而在确保数据安全的前提下,使得该明文的交易内容能够在TEE中实现高效处理,并在TEE中生成明文的收据数据。In this embodiment, the first blockchain node can execute the decrypted smart contract code in a Trusted Execution Environment (TEE). For example, as shown in Figure 4, the first blockchain node can be divided into a regular execution environment (on the left in the figure) and TEE, and transactions submitted by the client (as described above, transactions can have other sources; here, the client submits Take the transaction as an example to illustrate) First, enter the "transaction/query interface" in the regular execution environment for identification. Transactions that do not require privacy processing can be left in the regular execution environment for processing (here can be based on the user type of the transaction initiator , Transaction type, identifier contained in the exchange, etc. to identify whether there is a privacy processing requirement), and the transaction that has a privacy processing requirement is passed to the TEE for processing. TEE is isolated from the conventional execution environment. The transaction is encrypted before entering the TEE, and it is decrypted into the transaction content in the clear in the trusted execution environment, so that the transaction content in the clear text can be efficiently processed in the TEE and in the TEE under the premise of ensuring data security. The receipt data in plaintext is generated in.
TEE是基于CPU硬件的安全扩展,且与外部完全隔离的可信执行环境。TEE最早是由Global Platform提出的概念,用于解决移动设备上资源的安全隔离,平行于操作系统为应用程序提供可信安全的执行环境。ARM的Trust Zone技术最早实现了真正商用的TEE技术。伴随着互联网的高速发展,安全的需求越来越高,不仅限于移动设备,云端设备,数据中心都对TEE提出了更多的需求。TEE的概念也得到了高速的发展和扩充。现在所说的TEE相比与最初提出的概念已经是更加广义的TEE。例如,服务器芯片厂商Intel,AMD等都先后推出了硬件辅助的TEE并丰富了TEE的概念和特性,在工业界得到了广泛的认可。现在提起的TEE通常更多指这类硬件辅助的TEE技术。不同于移动端,云端访问需要远程访问,终端用户对硬件平台不可见,因此使用TEE 的第一步就是要确认TEE的真实可信。因此现在的TEE技术都引入了远程证明机制,由硬件厂商(主要是CPU厂商)背书并通过数字签名技术确保用户对TEE状态可验证。同时仅仅是安全的资源隔离也无法满足的安全需求,进一步的数据隐私保护也被提出。包括Intel SGX,AMD SEV在内的商用TEE也都提供了内存加密技术,将可信硬件限定在CPU内部,总线和内存的数据均是密文防止恶意用户进行窥探。例如,英特尔的软件保护扩展(SGX)等TEE技术隔离了代码执行、远程证明、安全配置、数据的安全存储以及用于执行代码的可信路径。在TEE中运行的应用程序受到安全保护,几乎不可能被第三方访问。TEE is a secure extension based on CPU hardware and a trusted execution environment completely isolated from the outside. TEE was first proposed by Global Platform to solve the security isolation of resources on mobile devices, and parallel to the operating system to provide a trusted and secure execution environment for applications. ARM's Trust Zone technology is the first to realize the real commercial TEE technology. With the rapid development of the Internet, security requirements are getting higher and higher. Not only mobile devices, cloud devices, and data centers have put forward more needs for TEE. The concept of TEE has also been rapidly developed and expanded. Compared with the originally proposed concept, TEE is a broader TEE. For example, server chip manufacturers Intel, AMD, etc. have successively introduced hardware-assisted TEE and enriched the concept and characteristics of TEE, which has been widely recognized in the industry. The TEE mentioned now usually refers to this kind of hardware-assisted TEE technology. Unlike the mobile terminal, cloud access requires remote access, and the end user is invisible to the hardware platform. Therefore, the first step in using TEE is to confirm the authenticity of TEE. Therefore, the current TEE technology has introduced a remote certification mechanism, which is endorsed by hardware vendors (mainly CPU vendors) and digital signature technology ensures that users can verify the state of the TEE. At the same time, security requirements that cannot be met by only secure resource isolation, further data privacy protection are also proposed. Commercial TEEs, including Intel SGX and AMD SEV, also provide memory encryption technology to limit trusted hardware to the inside of the CPU. The data on the bus and memory are ciphertext to prevent malicious users from snooping. For example, Intel’s Software Protection Extensions (SGX) and other TEE technologies isolate code execution, remote attestation, secure configuration, secure storage of data, and trusted paths for code execution. The applications running in the TEE are protected by security and are almost impossible to be accessed by third parties.
以Intel SGX技术为例,SGX提供了围圈(enclave,也称为飞地),即内存中一个加密的可信执行区域,由CPU保护数据不被窃取。以第一区块链节点采用支持SGX的CPU为例,利用新增的处理器指令,在内存中可以分配一部分区域EPC(Enclave Page Cache,围圈页面缓存或飞地页面缓存),通过CPU内的加密引擎MEE(Memory Encryption Engine)对其中的数据进行加密。EPC中加密的内容只有进入CPU后才会被解密成明文。因此,在SGX中,用户可以不信任操作系统、VMM(Virtual Machine Monitor,虚拟机监控器)、甚至BIOS(Basic Input Output System,基本输入输出系统),只需要信任CPU便能确保隐私数据不会泄漏。实际应用中,可以将隐私数据加密后以密文形式传递至围圈中,并通过远程证明将对应的秘钥也传入围圈。然后,在CPU的加密保护下利用数据进行运算,结果会以密文形式返回。这种模式下,既可以利用强大的计算力,又不用担心数据泄漏。Taking Intel SGX technology as an example, SGX provides an enclave (also called an enclave), which is an encrypted trusted execution area in the memory, and the CPU protects data from being stolen. Taking the first blockchain node using a CPU that supports SGX as an example, using the newly added processor instructions, a part of the area EPC (Enclave Page Cache, enclave page cache or enclave page cache) can be allocated in the memory through the CPU. The encryption engine MEE (Memory Encryption Engine) encrypts the data in it. The encrypted content in EPC will be decrypted into plaintext only after entering the CPU. Therefore, in SGX, users can distrust the operating system, VMM (Virtual Machine Monitor), and even BIOS (Basic Input Output System). They only need to trust the CPU to ensure that private data will not leakage. In practical applications, the private data can be encrypted and transmitted to the circle in cipher text, and the corresponding secret key can also be transmitted to the circle through remote certification. Then, the data is used for calculation under the encryption protection of the CPU, and the result will be returned in ciphertext. In this mode, you can use powerful computing power without worrying about data leakage.
当上述存在隐私处理需求的交易用于创建智能合约时,该交易中包含智能合约的代码,第一区块链节点可以在TEE中对该交易进行解密得到其所含智能合约的代码,并进而在TEE中执行该代码。当上述存在隐私处理需求的交易用于调用智能合约时,第一区块链节点可以在TEE中执行该代码(若被调用的智能合约处理加密状态,则需要先在TEE中对该智能合约进行解密,以得到相应的代码)。具体的,第一区块链节点可以利用CPU中新增的处理器指令,在内存中分配一部分区域EPC,通过CPU内的加密引擎MEE对上述的明文代码进行加密存入所述EPC中。EPC中加密的内容进入CPU后被解密成明文。在CPU中,对明文的代码进行运算,完成执行过程。例如,在SGX技术中,执行智能合约的明文代码,可以将EVM加载进围圈中。在远程证明过程中,密钥管理服务器可以计算本地EVM代码的hash值,并与第一区块链节点中加载的EVM代码的hash值比对,比对结果正确作为通过远程证明的一个必要条件,从而完成对第一区块链节点SGX围圈加载的代码的度量。经过度量,正确的EVM可以在SGX 中执行上述智能合约的代码。When the above transaction with privacy processing requirements is used to create a smart contract, the transaction contains the code of the smart contract, and the first blockchain node can decrypt the transaction in the TEE to obtain the code of the smart contract contained therein, and then Execute this code in TEE. When the above transaction with privacy processing requirements is used to call a smart contract, the first blockchain node can execute the code in the TEE (if the called smart contract handles the encryption state, the smart contract needs to be executed in the TEE first. Decrypt to get the corresponding code). Specifically, the first blockchain node may use the newly added processor instructions in the CPU to allocate a part of the area EPC in the memory, and encrypt the above-mentioned plaintext code and store it in the EPC through the encryption engine MEE in the CPU. The encrypted content in EPC is decrypted into plain text after entering the CPU. In the CPU, perform operations on the plaintext code to complete the execution process. For example, in SGX technology, the plaintext code for executing smart contracts can load the EVM into the enclosure. During the remote certification process, the key management server can calculate the hash value of the local EVM code and compare it with the hash value of the EVM code loaded in the first blockchain node. The correct comparison result is a necessary condition for passing remote certification. , So as to complete the measurement of the code loaded in the SGX circle of the first blockchain node. After measurement, the correct EVM can execute the above smart contract code in SGX.
步骤308,第一区块链节点存储所述收据数据,当交易发起方属于预设用户类型时,使所述暴露标识符标明的对象对应的收据内容以明文形式存储、其余收据内容以密文形式存储。Step 308: The first blockchain node stores the receipt data. When the transaction initiator belongs to the preset user type, the content of the receipt corresponding to the object indicated by the exposure identifier is stored in plain text, and the rest of the receipt content is stored in cipher text. Form storage.
在一实施例中,用户在区块链上存在对应的外部账户,并基于该外部账户发起交易或实施其他操作。那么,交易发起方所属的用户类型,即该外部账户所属的用户类型。因此,第一区块链节点可以确定所述交易发起方对应的外部账户,并通过查询区块链上记录的所述外部账户对应的用户类型,以作为所述交易发起方所属的用户类型。In an embodiment, the user has a corresponding external account on the blockchain, and initiates transactions or performs other operations based on the external account. Then, the user type to which the transaction initiator belongs, that is, the user type to which the external account belongs. Therefore, the first blockchain node can determine the external account corresponding to the transaction initiator, and query the user type corresponding to the external account recorded on the blockchain as the user type to which the transaction initiator belongs.
在一实施例中,外部账户可以包括记录于区块链上的类型字段(如Type字段),该类型字段的取值对应于用户类型。比如,当类型字段的取值为00时,用户类型为普通用户,当类型字段的取值为01时,用户类型为高级用户,当类型字段的取值为11时,用户类型为管理用户等。因此,第一区块链节点可以通过读取上述的外部账户的类型字段,即可基于取值确定相应的用户类型。In an embodiment, the external account may include a type field (such as a Type field) recorded on the blockchain, and the value of the type field corresponds to the user type. For example, when the value of the type field is 00, the user type is ordinary user, when the value of the type field is 01, the user type is advanced user, and when the value of the type field is 11, the user type is administrative user, etc. . Therefore, the first blockchain node can determine the corresponding user type based on the value by reading the type field of the external account mentioned above.
在一实施例中,在创建上述的外部账户时,用户类型可以被配置为关联至该外部账户,使用户类型与外部账户之间的关联关系被记录于区块链中,比如通过用户类型与外部账户的账户地址来建立上述的关联关系,使得外部账户的数据结构并不需要改变,即外部账户无需包含上述的类型字段。因此,第一区块链节点可以通过读取区块链上记录的关联关系,并基于交易发起方对应的外部账户,确定该外部账户对应的上述预设用户类型。In one embodiment, when creating the above-mentioned external account, the user type can be configured to be associated with the external account, so that the association relationship between the user type and the external account is recorded in the blockchain, such as through the user type and The account address of the external account is used to establish the above-mentioned association relationship, so that the data structure of the external account does not need to be changed, that is, the external account does not need to include the above type field. Therefore, the first blockchain node can determine the above-mentioned preset user type corresponding to the external account by reading the association relationship recorded on the blockchain and based on the external account corresponding to the transaction initiator.
在一实施例中,可以在一定条件下对外部账户的用户类型进行修改。例如,管理用户可以具备修改权项,使得第一区块链节点可以根据管理用户发起的更改请求,更改上述外部账户对应的用户类型。管理用户可以对应于创世块中预置的、具有管理权限的外部账户,使得管理用户可以对其他的普通用户、高级用户等进行类型更改,比如将普通用户更改为高级用户、将高级用户更改为普通用户等。In an embodiment, the user type of the external account can be modified under certain conditions. For example, the management user may have a modification right item, so that the first blockchain node can change the user type corresponding to the above-mentioned external account according to the change request initiated by the management user. The management user can correspond to the external account preset in the genesis block with management authority, so that the management user can make type changes to other ordinary users, advanced users, etc., such as changing ordinary users to advanced users, and changing advanced users For ordinary users, etc.
第一区块链节点通过识别交易发起方所属的用户类型,可以确定交易发起方的隐私保护需求的强烈程度:当属于预设用户类型时,可以确定该交易发起方的隐私保护需求相对较弱,能够接受收据数据在一定程度上的暴露,以实现相应的功能扩展;当不属于预设用户类型时,可以确定该交易发起方的隐私保护需求相对较强,无法接受对收据数据的暴露。因而,基于对交易发起方所属的用户类型的识别,可使针对收据数据的存储 方式满足交易发起方的实际需求,能够兼顾隐私保护和功能扩展。例如,普通用户的隐私保护的需求相对更低、对基于收据数据的功能扩展需求相对更高,那么对于普通用户发起的交易所产生的收据数据,可以将相对更多的收据内容采用明文形式存储,以便针对明文存储的收据内容实施功能扩展。再例如,高级用户的隐私保护的需求相对更高、对基于收据数据的功能扩展需求相对更低,那么对于高级用户发起的交易所产生的收据数据,可以将相对更少的收据内容采用明文形式存储、相对更多的收据内容采用密文形式存储,以便在支持部分功能扩展的同时,确保密文形式的收据内容得以安全保存。又例如,管理用户的隐私保护需求极高,那么对于管理用户发起的交易所产生的收据数据,可以将所有收据内容均采用密文形式存储。The first blockchain node can determine the strength of the transaction initiator’s privacy protection needs by identifying the user type to which the transaction initiator belongs: when it belongs to the preset user type, it can be determined that the transaction initiator’s privacy protection needs are relatively weak , Can accept the exposure of receipt data to a certain extent to achieve corresponding function expansion; when it does not belong to the preset user type, it can be determined that the transaction initiator has relatively strong privacy protection requirements and cannot accept the exposure of receipt data. Therefore, based on the identification of the user type to which the transaction initiator belongs, the storage method for the receipt data can meet the actual needs of the transaction initiator, and it can take into account privacy protection and function expansion. For example, ordinary users have relatively lower requirements for privacy protection and higher requirements for function expansion based on receipt data. Then, for the receipt data generated by transactions initiated by ordinary users, relatively more receipt content can be stored in clear text. , In order to implement function extensions for the contents of receipts stored in plaintext. For another example, the privacy protection needs of advanced users are relatively higher, and the need for function expansion based on receipt data is relatively lower. Then for the receipt data generated by transactions initiated by advanced users, relatively less receipt content can be used in plain text. Storage, relatively more receipt content is stored in ciphertext form, so as to support part of the function expansion while ensuring that the receipt content in ciphertext form can be stored safely. For another example, the privacy protection requirements of the management user are extremely high, so for the receipt data generated by the transaction initiated by the management user, all the receipt content can be stored in cipher text.
其中,第一区块链节点可以在交易发起方属于预设用户类型的情况下,将上述暴露标识符标明的对象对应的收据内容以明文形式存储,并将其余收据内容以密文形式存储,可以灵活地针对收据数据进行明文存储或密文存储,使得采用密文形式存储的收据内容能够满足用户的隐私需求,而采用明文形式存储的收据内容能够满足用户的检索等功能扩展需求。例如,当收据数据中的日志(如整个Logs字段;或者,From字段、To字段、Topic字段、Log data字段中的至少一个)采用明文形式存储时,能够支持后续对该日志内容的检索,从而实现譬如基于日志内容的事件驱动,比如驱动DAPP(Decentralized Application,分布式应用)客户端执行相关处理操作等。Among them, the first blockchain node can store the content of the receipt corresponding to the object indicated by the exposure identifier in plain text when the transaction initiator belongs to the preset user type, and store the remaining content of the receipt in cipher text, Receipt data can be stored in plaintext or ciphertext flexibly, so that the receipt content stored in ciphertext form can meet the privacy needs of users, and the receipt content stored in plaintext form can meet the user's search function expansion needs. For example, when the log in the receipt data (such as the entire Logs field; or at least one of the From field, To field, Topic field, and Log data field) is stored in plain text, it can support subsequent retrieval of the log content, thereby For example, it implements event-driven based on log content, such as driving DAPP (Decentralized Application, distributed application) clients to perform related processing operations.
通过在计算设备(物理机或虚拟机)上运行区块链的程序代码(以下简称为链代码),可以将该计算设备配置为区块链网络中的区块链节点,比如上述的第一区块链节点等。换言之,第一区块链节点通过运行上述的链代码,以实现相应的功能逻辑。因此,可以在创建区块链网络时,将与暴露标识符、用户类型相关的收据数据存储逻辑写入链代码中,使得各个区块链节点均可以实现该收据数据存储逻辑;以第一区块链节点为例,该与暴露标识符、用户类型相关的收据数据存储逻辑可以包括:对用户类型的识别逻辑、基于暴露标识符对收据内容进行存储的逻辑。By running the program code of the blockchain (hereinafter referred to as the chain code) on the computing device (physical machine or virtual machine), the computing device can be configured as a blockchain node in the blockchain network, such as the first Blockchain nodes, etc. In other words, the first blockchain node runs the above chain code to realize the corresponding functional logic. Therefore, when the blockchain network is created, the receipt data storage logic related to the exposed identifier and user type can be written into the chain code, so that each blockchain node can implement the receipt data storage logic; Taking the block chain node as an example, the receipt data storage logic related to the exposed identifier and the user type may include: identification logic for the user type, and logic for storing the content of the receipt based on the exposed identifier.
对用户类型的识别逻辑用于指示第一区块链节点:识别交易发起方的用户类型。比如:系统合约中可以记录有预定义的外部账户与用户类型之间的关联关系,或者系统合约中可以记录有用户类型字段的取值与用户类型之间的对应关系。具体可以参考上文中识别用户类型的相关描述,此处不再赘述。The user type identification logic is used to instruct the first blockchain node to identify the user type of the transaction initiator. For example, the system contract can record the association relationship between the predefined external account and the user type, or the system contract can record the correspondence between the value of the user type field and the user type. For details, please refer to the relevant description of identifying user types above, which will not be repeated here.
基于暴露标识符对收据内容进行存储的逻辑用于指示第一区块链节点:针对暴露标识符标明的对象、未标明的对象,分别采用何种方式存储相应的收据内容。比如:在交 易发起方属于预设用户类型的前提下,对暴露标识符标明的对象,采用明文形式存储对应的收据内容,而对未由暴露标识符标明的对象,采用密文形式存储对应的收据内容。The logic of storing the content of the receipt based on the exposed identifier is used to instruct the first blockchain node: for the objects marked by the exposed identifier and the unmarked objects, how to store the corresponding receipt content respectively. For example, on the premise that the transaction initiator belongs to the preset user type, the corresponding receipt content is stored in plain text for objects marked by the exposed identifier, and the corresponding receipt content is stored in cipher text for objects not marked by the exposed identifier. The contents of the receipt.
然而,链代码的升级更新相对较为困难,使得采用链代码实现对收据数据的存储存在灵活性低、可扩展性不足的问题。为了实现对链代码的功能扩展,如图5所示,可以采用链代码与系统合约相结合的方式:链代码用于实现区块链网络的基础功能,而运行过程中的功能扩展可以通过系统合约的方式实现。与上述的智能合约相类似的,系统合约包括譬如字节码形式的代码,第一区块链节点可以通过运行系统合约的代码(比如,根据唯一对应的地址“0x53a98…”来读取该系统合约中的代码),实现对链代码的功能补充。相应地,第一区块链节点可以读取系统合约的代码,该系统合约的代码中定义了与暴露标识符、用户类型相关的收据数据存储逻辑;然后,第一区块链节点可以执行系统合约的代码,从而基于与暴露标识符、用户类型相关的收据数据存储逻辑,在交易发起方属于预设用户类型的情况下,将暴露标识符标明的对象在收据数据中对应的收据内容以明文形式存储、收据数据的其余内容以密文形式存储。However, it is relatively difficult to upgrade the chain code, which makes the storage of receipt data using the chain code have the problems of low flexibility and insufficient scalability. In order to realize the function expansion of the chain code, as shown in Figure 5, a combination of chain code and system contract can be used: chain code is used to realize the basic functions of the blockchain network, and the function expansion during operation can be achieved through the system Realized by way of contract. Similar to the above-mentioned smart contract, the system contract includes code in the form of bytecode, for example, the first blockchain node can run the system contract code (for example, according to the unique corresponding address "0x53a98..." to read the system The code in the contract) to realize the functional supplement of the chain code. Correspondingly, the first blockchain node can read the code of the system contract, which defines the receipt data storage logic related to the exposed identifier and user type; then, the first blockchain node can execute the system The code of the contract, based on the receipt data storage logic related to the exposed identifier and user type, in the case that the transaction initiator belongs to the preset user type, the corresponding receipt content in the receipt data of the object marked by the exposed identifier is written in plain text Form storage, the rest of the receipt data is stored in cipher text.
区别于上述由用户发布至区块链的智能合约,系统合约无法由用户自由发布。第一区块链节点读取的系统合约可以包括配置于区块链网络的创世块中的预置系统合约;以及,区块链网络中的管理员(即上述的管理用户)可以具有针对系统合约的更新权限,从而针对诸如上述的预置系统合约进行更新,则上述第一区块链节点读取的系统合约还可以包括相应的更新后系统合约。当然,更新后系统合约可以由管理员对预置系统合约实施一次更新后得到;或者,更新后系统合约可以由管理员对预置系统合约实施多次迭代更新后得到,比如由预置系统合约更新得到系统合约1、对系统合约1更新得到系统合约2、对系统合约2更新得到系统合约3,该系统合约1、系统合约2、系统合约3均可以视为更新后系统合约,但第一区块链节点通常会以最新版本的系统合约为准,比如第一区块链节点会以系统合约3中的代码为准,而非系统合约1或系统合约2中的代码。Different from the above-mentioned smart contracts issued by users to the blockchain, system contracts cannot be freely issued by users. The system contract read by the first blockchain node may include a preset system contract configured in the genesis block of the blockchain network; and, the administrator in the blockchain network (ie, the above-mentioned management user) may have The update authority of the system contract, so as to update the preset system contract such as the above, the system contract read by the first blockchain node may also include the corresponding updated system contract. Of course, the updated system contract can be obtained by the administrator after one update of the preset system contract; or, the updated system contract can be obtained by the administrator after multiple iterations of the preset system contract, such as the preset system contract Update the system contract 1, update the system contract 1 to obtain the system contract 2, update the system contract 2 to obtain the system contract 3. The system contract 1, the system contract 2, and the system contract 3 can all be regarded as the updated system contract, but the first Blockchain nodes usually follow the latest version of the system contract. For example, the first blockchain node will follow the code in system contract 3 instead of the code in system contract 1 or system contract 2.
除了创世块中包含的预置系统合约之外,管理员还可以在后续区块内发布系统合约,以及针对所发布的系统合约进行更新。总之,应当通过诸如权限管理等方式,对系统合约的发布和更新实施一定程度的限制,以确保区块链网络的功能逻辑能够正常运作,并且避免对任何用户造成不必要的损失。In addition to the preset system contracts included in the genesis block, the administrator can also publish system contracts in subsequent blocks and update the published system contracts. In short, a certain degree of restrictions should be imposed on the issuance and update of system contracts through methods such as authority management to ensure that the functional logic of the blockchain network can operate normally and avoid unnecessary losses to any users.
第一区块链节点通过密钥对至少一部分收据内容进行加密。所述加密,可以采用对称加密,也可以采用非对称加密。如果第一区块链节点用对称加密方式,即用对称 加密算法的对称密钥对收据内容加密,则客户端(或其他持有密钥的对象)可以用该对称加密算法的对称密钥对加密后的收据内容进行解密。The first blockchain node encrypts at least a part of the receipt content through the key. The encryption may be symmetric encryption or asymmetric encryption. If the first blockchain node uses symmetric encryption, that is, the symmetric key of the symmetric encryption algorithm is used to encrypt the content of the receipt, the client (or other object holding the key) can use the symmetric key pair of the symmetric encryption algorithm The encrypted receipt content is decrypted.
第一区块链节点用对称加密算法的对称密钥对收据内容进行加密时,该对称密钥可由客户端预先提供至第一区块链节点。那么,由于只有客户端(实际应当为客户端上的已登录账户对应的用户)和第一区块链节点掌握该对称密钥,使得仅该客户端能够解密相应的加密后的收据内容,避免无关用户甚至不法分子对加密后的收据内容进行解密。When the first blockchain node uses the symmetric key of the symmetric encryption algorithm to encrypt the content of the receipt, the symmetric key may be provided to the first blockchain node in advance by the client. Then, since only the client (actually the user corresponding to the logged-in account on the client) and the first blockchain node have the symmetric key, only the client can decrypt the corresponding encrypted receipt content, avoiding Irrelevant users and even criminals decrypt the encrypted receipt content.
例如,客户端在向第一区块链节点发起交易时,客户端可以用对称加密算法的初始密钥对交易内容进行加密,以得到该交易;相应地,第一区块链节点可以通过获得该初始密钥,以用于直接或间接对收据内容进行加密。譬如,该初始密钥可以由客户端与第一区块链节点预先协商得到,或者由密钥管理服务器发送至客户端和第一区块链节点,或者由客户端发送至第一区块链节点。当初始密钥由客户端发送至第一区块链节点时,客户端可以通过非对称加密算法的公钥对该初始密钥进行加密后,将加密后的初始密钥发送至第一区块链节点,而第一区块链节点通过非对称加密算法的私钥对该加密后的初始密钥进行解密,得到初始密钥,即上文所述的数字信封加密,此处不再赘述。For example, when the client initiates a transaction to the first blockchain node, the client can use the initial key of the symmetric encryption algorithm to encrypt the transaction content to obtain the transaction; accordingly, the first blockchain node can obtain The initial key is used to directly or indirectly encrypt the content of the receipt. For example, the initial key can be negotiated in advance by the client and the first blockchain node, or sent by the key management server to the client and the first blockchain node, or sent by the client to the first blockchain node. When the initial key is sent by the client to the first blockchain node, the client can encrypt the initial key with the public key of the asymmetric encryption algorithm, and then send the encrypted initial key to the first block The chain node, and the first blockchain node decrypts the encrypted initial key through the private key of the asymmetric encryption algorithm to obtain the initial key, which is the digital envelope encryption described above, which will not be repeated here.
第一区块链节点可以采用上述的初始密钥对收据内容进行加密。不同交易采用的初始密钥可以相同,使得同一用户所提交的所有交易均采用该初始密钥进行加密,或者不同交易采用的初始密钥可以不同,比如客户端可以针对每一交易随机生成一初始密钥,以提升安全性。The first blockchain node can use the aforementioned initial key to encrypt the content of the receipt. Different transactions can use the same initial key, so that all transactions submitted by the same user are encrypted with this initial key, or different transactions can use different initial keys. For example, the client can randomly generate an initial key for each transaction. Key to improve security.
第一区块链节点可以根据初始密钥与影响因子生成衍生密钥,并通过该衍生密钥对收据内容进行加密。相比于直接采用初始密钥进行加密,衍生密钥可以增加随机度,从而提升被攻破的难度,有助于优化数据的安全保护。影响因子可以与交易相关;例如,影响因子可以包括交易哈希值的指定位,比如第一区块链节点可以将初始密钥与交易哈希值的前16位(或前32位、后16位、后32位,或者其他位)进行拼接,并对拼接后的字符串进行哈希运算,从而生成衍生密钥。The first blockchain node can generate a derived key according to the initial key and the impact factor, and encrypt the content of the receipt through the derived key. Compared with directly using the initial key for encryption, the derived key can increase the degree of randomness, thereby increasing the difficulty of being compromised and helping to optimize the security protection of data. The impact factor can be related to the transaction; for example, the impact factor can include the specified bits of the transaction hash value. For example, the first blockchain node can associate the initial key with the first 16 bits (or the first 32 bits and the last 16 bits) of the transaction hash value. Bits, last 32 bits, or other bits) are spliced, and the spliced string is hashed to generate a derived key.
第一区块链节点还可以采用非对称加密方式,即用非对称加密算法的公钥对收据内容加密,则相应地,客户端可以用所述非对称加密算法的私钥解密上述加密后的收据内容。非对称加密算法的密钥,例如可以是由客户端生成一对公钥和私钥,并将公钥预先发送至第一区块链节点,从而第一区块链节点可以将收据内容用该公钥加密。The first blockchain node can also use an asymmetric encryption method, that is, use the public key of the asymmetric encryption algorithm to encrypt the content of the receipt, and accordingly, the client can use the private key of the asymmetric encryption algorithm to decrypt the encrypted The contents of the receipt. The key of an asymmetric encryption algorithm, for example, can be that the client generates a pair of public and private keys, and sends the public key to the first blockchain node in advance, so that the first blockchain node can use the receipt content Public key encryption.
第一区块链节点通过运行用于实现某一功能的代码,以实现该功能。因此,对于需要在TEE中实现的功能,同样需要执行相关代码。而对于在TEE中执行的代码,需要符合TEE的相关规范和要求;相应地,对于相关技术中用于实现某一功能的代码,需要结合TEE的规范和要求重新进行代码编写,不仅存在相对更大的开发量,而且容易在重新编写过程中产生漏洞(bug),影响功能实现的可靠性和稳定性。The first blockchain node realizes the function by running the code used to realize the function. Therefore, for the functions that need to be implemented in the TEE, the relevant code also needs to be executed. For the code executed in the TEE, it needs to comply with the relevant specifications and requirements of the TEE; accordingly, for the code used to implement a certain function in the related technology, the code needs to be rewritten in combination with the specifications and requirements of the TEE. Large amount of development, and easy to produce loopholes (bugs) in the process of rewriting, affecting the reliability and stability of function implementation.
因此,第一区块链节点可以通过在TEE之外执行存储功能代码,将TEE中生成的收据数据(包括需要明文存储的明文形式的收据内容,以及需要密文存储的密文形式的收据内容)存储至TEE之外的外部存储空间,使得该存储功能代码可以为相关技术中用于实现存储功能的代码、不需要结合TEE的规范和要求重新进行代码编写,即可针对收据数据实现安全可靠的存储,不仅可以在不影响安全、可靠程度的基础上,减少相关代码的开发量,而且可以通过减少TEE的相关代码而降低TCB(Trusted Computing Base,可信计算基),使得TEE技术与区块链技术进行结合的过程中,额外造成的安全风险处于可控范围。Therefore, the first blockchain node can execute the storage function code outside the TEE to store the receipt data generated in the TEE (including the receipt content in plain text that needs to be stored in plain text, and the receipt content in cipher text that needs to be stored in cipher text. ) Is stored in an external storage space outside the TEE, so that the storage function code can be the code used to implement the storage function in the related technology, and does not need to be rewritten in conjunction with the specifications and requirements of the TEE to achieve safe and reliable receipt data The storage of TEE can not only reduce the amount of related code development without affecting security and reliability, but also reduce TCB (Trusted Computing Base) by reducing the related code of TEE, making TEE technology and regional In the process of combining block chain technology, the additional security risks caused are in a controllable range.
在一实施例中,第一区块链节点可以在TEE内执行写缓存功能代码,以将上述的收据数据存入TEE内的写缓存中,比如该写缓存可以对应于如图2所示的“缓存”。进一步的,第一区块链节点将写缓存中的数据从可信执行环境输出,以存储至外部存储空间。其中,写缓存功能代码可以以明文形式存储于TEE中,可以直接在TEE中执行该明文形式的缓存功能代码;或,写缓存功能代码可以以密文形式存储于TEE之外,比如存储于上述的外部存储空间(比如图2所示的“打包+存储”,其中“打包”表示第一区块链节点在可信执行环境之外对交易进行打包成块),可以将该密文形式的写缓存功能代码读入TEE、在TEE中进行解密为明文代码,并执行该明文代码。In an embodiment, the first blockchain node may execute the write cache function code in the TEE to store the above-mentioned receipt data in the write cache in the TEE. For example, the write cache may correspond to the one shown in FIG. 2 "Cache". Further, the first blockchain node outputs the data in the write cache from the trusted execution environment to be stored in the external storage space. Among them, the write cache function code can be stored in the TEE in plain text, and the cache function code in the plain text can be directly executed in the TEE; or, the write cache function code can be stored outside the TEE in cipher text, such as the above External storage space (such as the "package + storage" shown in Figure 2, where "package" means that the first blockchain node packs the transaction into blocks outside the trusted execution environment), the ciphertext form The write cache function code is read into the TEE, decrypted into the plaintext code in the TEE, and the plaintext code is executed.
写缓存是指在将数据写入外部存储空间时,为了避免造成对外部存储空间的“冲击”而提供的“缓冲”机制。例如,可以采用buffer实现上述的写缓存;当然,写缓存也可以采用cache来实现,本说明书并不对此进行限制。实际上,由于TEE为隔离的安全环境,而外部存储空间位于TEE之外,使得通过采用写缓存机制,可以对缓存内的数据进行批量写入外部存储空间,从而减少TEE与外部存储空间之间的交互次数,提升数据存储效率。同时,TEE在不断执行各条交易的过程中,可能需要调取已生成的数据,如果需调用的数据恰好位于写缓存中,可以直接从写缓存中读取该数据,这样一方面可以减少与外部存储空间之间的交互,另一方面免去了对从外部存储空间所读取数据的解密过程,从而提升在TEE中的数据处理效率。Write cache refers to a "buffer" mechanism provided to avoid "impact" to the external storage space when data is written to the external storage space. For example, the above-mentioned write cache can be implemented by using buffer; of course, the write cache can also be implemented by using cache, which is not limited in this specification. In fact, because the TEE is an isolated security environment and the external storage space is outside the TEE, the write cache mechanism can be used to write the data in the cache to the external storage space in batches, thereby reducing the gap between the TEE and the external storage space. The number of interactions increases the efficiency of data storage. At the same time, in the process of continuously executing each transaction, TEE may need to retrieve the generated data. If the data to be called happens to be in the write cache, the data can be read directly from the write cache. The interaction between the external storage space, on the other hand, eliminates the decryption process of the data read from the external storage space, thereby improving the data processing efficiency in the TEE.
当然,也可以将写缓存建立于TEE之外,比如第一区块链节点可以在TEE之外执行写缓存功能代码,从而将上述的收据数据存入TEE外的写缓存中,并进一步将写缓存中的数据存储至外部存储空间。Of course, the write cache can also be established outside the TEE. For example, the first blockchain node can execute the write cache function code outside the TEE, so as to store the above receipt data in the write cache outside the TEE, and further write The data in the cache is stored in an external storage space.
以下结合图6介绍本说明书一种结合代码标注与用户类型的收据存储节点的实施例,包括:The following describes an embodiment of a receipt storage node combining code labeling and user type in this specification with reference to FIG. 6, including:
接收单元61,接收经过加密的对应于智能合约的交易,所述智能合约的代码中包括通过暴露标识符标明的对象;The receiving unit 61 receives an encrypted transaction corresponding to a smart contract, the code of the smart contract includes an object marked by an exposed identifier;
解密单元62,在可信执行环境中解密所述交易,以获得所述智能合约的代码;The decryption unit 62 decrypts the transaction in a trusted execution environment to obtain the code of the smart contract;
执行单元63,在所述可信执行环境中执行所述智能合约的代码,得到收据数据;The execution unit 63 executes the code of the smart contract in the trusted execution environment to obtain receipt data;
存储单元64,存储所述收据数据,当交易发起方属于预设用户类型时,使所述暴露标识符标明的对象对应的收据内容以明文形式存储、其余收据内容以密文形式存储。The storage unit 64 stores the receipt data. When the transaction initiator belongs to the preset user type, the receipt content corresponding to the object indicated by the exposure identifier is stored in plain text, and the rest of the receipt content is stored in cipher text.
可选的,接收单元61接收的交易对应的智能合约,包括:Optionally, the smart contract corresponding to the transaction received by the receiving unit 61 includes:
高级语言编写的智能合约;或,Smart contracts written in high-level languages; or,
字节码形式的智能合约。Smart contract in bytecode form.
可选的,当第一区块链节点接收的交易对应的智能合约为高级语言编写的智能合约时,所述节点还包括:Optionally, when the smart contract corresponding to the transaction received by the first blockchain node is a smart contract written in a high-level language, the node further includes:
编译单元65,通过编译器对所述高级语言编写的智能合约进行编译,生成字节码形式的智能合约,以在所述可信执行环境中执行。The compiling unit 65 compiles the smart contract written in the high-level language through a compiler, and generates the smart contract in the form of bytecode for execution in the trusted execution environment.
可选的,当第一区块链节点接收的交易对应的智能合约为字节码形式的智能合约时,所述字节码形式的智能合约由客户端通过编译器对高级语言编写的智能合约进行编译而得到,所述高级语言编写的智能合约由用户在所述客户端上编写得到。Optionally, when the smart contract corresponding to the transaction received by the first blockchain node is a smart contract in the form of bytecode, the smart contract in the form of bytecode is a smart contract written in a high-level language by the client through a compiler It is obtained by compiling, and the smart contract written in the high-level language is written by the user on the client.
可选的,所述高级语言编写的智能合约与所述字节码形式的智能合约具有相同或对应的暴露标识符。Optionally, the smart contract written in the high-level language and the smart contract in bytecode form have the same or corresponding exposure identifier.
可选的,接收单元61接收的交易对应的智能合约,包括:Optionally, the smart contract corresponding to the transaction received by the receiving unit 61 includes:
用户在第一区块链节点上生成的智能合约;或,The smart contract generated by the user on the first blockchain node; or,
用户在客户端上生成的智能合约;或,The smart contract generated by the user on the client; or,
所述客户端通过第二区块链节点发来的交易中的智能合约。The smart contract in the transaction sent by the client through the second blockchain node.
可选的,所述暴露标识符标明的对象包括:收据字段和/或状态变量。Optionally, the objects indicated by the exposure identifier include: receipt fields and/or state variables.
可选的,所述暴露标识符标明的对象包括:合约级对象;存储单元64具体用于:Optionally, the objects indicated by the exposure identifier include: contract-level objects; the storage unit 64 is specifically used for:
在存储所述收据数据时,将所述收据数据中对应于所述合约级对象的所有收据内容以明文形式存储。When storing the receipt data, all the receipt contents corresponding to the contract-level object in the receipt data are stored in plain text.
可选的,所述暴露标识符标明的对象包括:对应于所述智能合约中定义的至少一个事件的事件级对象;存储单元64具体用于:Optionally, the objects indicated by the exposure identifier include: event-level objects corresponding to at least one event defined in the smart contract; the storage unit 64 is specifically configured to:
在存储所述收据数据时,将所述收据数据中对应于所述至少一个事件的收据内容以明文形式存储。When storing the receipt data, the receipt content corresponding to the at least one event in the receipt data is stored in plain text.
可选的,第一区块链节点通过下述方式确定所述交易发起方所属的用户类型:Optionally, the first blockchain node determines the user type to which the transaction initiator belongs in the following manner:
确定所述交易发起方对应的外部账户;Determine the external account corresponding to the transaction initiator;
查询区块链上记录的所述外部账户对应的用户类型,以作为所述交易发起方所属的用户类型。Query the user type corresponding to the external account recorded on the blockchain as the user type to which the transaction initiator belongs.
可选的,所述外部账户包括记录于区块链上的类型字段,所述类型字段的取值对应于所述用户类型。Optionally, the external account includes a type field recorded on the blockchain, and the value of the type field corresponds to the user type.
可选的,在创建所述外部账户时,所述用户类型被配置为关联至所述外部账户,使所述用户类型与所述外部账户之间的关联关系被记录于区块链中。Optionally, when the external account is created, the user type is configured to be associated with the external account, so that the association relationship between the user type and the external account is recorded in the blockchain.
可选的,还包括:Optional, also includes:
更改单元66,根据管理用户发起的更改请求,更改所述外部账户对应的用户类型。The changing unit 66 changes the user type corresponding to the external account according to the change request initiated by the management user.
可选的,存储单元64具体用于:Optionally, the storage unit 64 is specifically used for:
读取系统合约的代码,所述系统合约的代码中定义了与暴露标识符、用户类型相关的收据数据存储逻辑;Read the code of the system contract, the code of the system contract defines the receipt data storage logic related to the exposed identifier and user type;
执行所述系统合约的代码,以在所述交易发起方属于所述预设用户类型时,将所述暴露标识符标明的对象对应的收据内容以明文形式存储、其余收据内容以密文形式存储,并在所述交易发起方不属于所述预设用户类型时,将所述收据数据以密文形式存储。The code of the system contract is executed to store the content of the receipt corresponding to the object indicated by the exposure identifier in plain text when the transaction initiator belongs to the preset user type, and the rest of the receipt content in cipher text , And when the transaction initiator does not belong to the preset user type, the receipt data is stored in cipher text.
可选的,所述系统合约包括:记录于创世块中的预置系统合约,或所述预置系 统合约对应的更新后系统合约。Optionally, the system contract includes: a preset system contract recorded in the genesis block, or an updated system contract corresponding to the preset system contract.
可选的,存储单元64具体用于:Optionally, the storage unit 64 is specifically used for:
在所述可信执行环境之外执行存储功能代码,以将所述收据数据存储至所述可信执行环境之外的外部存储空间。The storage function code is executed outside the trusted execution environment to store the receipt data in an external storage space outside the trusted execution environment.
可选的,所述交易用于创建和/或调用所述智能合约。Optionally, the transaction is used to create and/or call the smart contract.
可选的,第一区块链节点对所述收据字段进行加密的密钥包括:对称加密算法的密钥或非对称加密算法的密钥。Optionally, the key used by the first blockchain node to encrypt the receipt field includes: a key of a symmetric encryption algorithm or a key of an asymmetric encryption algorithm.
可选的,所述对称加密算法的密钥包括所述客户端提供的初始密钥;或,所述对称加密算法的密钥包括所述初始密钥与影响因子生成的衍生密钥。Optionally, the key of the symmetric encryption algorithm includes an initial key provided by the client; or, the key of the symmetric encryption algorithm includes a derived key generated by the initial key and an influence factor.
可选的,所述交易由所述初始密钥进行加密,且所述初始密钥被非对称加密算法的公钥进行加密;解密单元62具体用于:Optionally, the transaction is encrypted by the initial key, and the initial key is encrypted by the public key of an asymmetric encryption algorithm; the decryption unit 62 is specifically configured to:
用所述非对称加密算法的私钥解密得到所述初始密钥,并用所述初始密钥对所述交易进行解密得到所述智能合约的代码。Decryption with the private key of the asymmetric encryption algorithm to obtain the initial key, and use the initial key to decrypt the transaction to obtain the code of the smart contract.
可选的,所述初始密钥由客户端生成;或,所述初始密钥由密钥管理服务器发送至所述客户端。Optionally, the initial key is generated by the client; or, the initial key is sent to the client by the key management server.
可选的,所述影响因子与所述交易相关。Optionally, the impact factor is related to the transaction.
可选的,所述影响因子包括:所述交易的哈希值的指定位。Optionally, the impact factor includes: a designated bit of the hash value of the transaction.
在20世纪90年代,对于一个技术的改进可以很明显地区分是硬件上的改进(例如,对二极管、晶体管、开关等电路结构的改进)还是软件上的改进(对于方法流程的改进)。然而,随着技术的发展,当今的很多方法流程的改进已经可以视为硬件电路结构的直接改进。设计人员几乎都通过将改进的方法流程编程到硬件电路中来得到相应的硬件电路结构。因此,不能说一个方法流程的改进就不能用硬件实体模块来实现。例如,可编程逻辑器件(Programmable Logic Device,PLD)(例如现场可编程门阵列(Field Programmable Gate Array,FPGA))就是这样一种集成电路,其逻辑功能由用户对器件编程来确定。由设计人员自行编程来把一个数字系统“集成”在一片PLD上,而不需要请芯片制造厂商来设计和制作专用的集成电路芯片。而且,如今,取代手工地制作集成电路芯片,这种编程也多半改用“逻辑编译器(logic compiler)”软件来实现,它与程序开发撰写时所用的软件编译器相类似,而要编译之前的原始代码也得用特定的编程 语言来撰写,此称之为硬件描述语言(Hardware Description Language,HDL),而HDL也并非仅有一种,而是有许多种,如ABEL(Advanced Boolean Expression Language)、AHDL(Altera Hardware Description Language)、Confluence、CUPL(Cornell University Programming Language)、HDCal、JHDL(Java Hardware Description Language)、Lava、Lola、MyHDL、PALASM、RHDL(Ruby Hardware Description Language)等,目前最普遍使用的是VHDL(Very-High-Speed Integrated Circuit Hardware Description Language)与Verilog。本领域技术人员也应该清楚,只需要将方法流程用上述几种硬件描述语言稍作逻辑编程并编程到集成电路中,就可以很容易得到实现该逻辑方法流程的硬件电路。In the 1990s, the improvement of a technology can be clearly distinguished between hardware improvements (for example, improvements in circuit structures such as diodes, transistors, switches, etc.) or software improvements (improvements in method flow). However, with the development of technology, the improvement of many methods and procedures of today can be regarded as a direct improvement of the hardware circuit structure. Designers almost always get the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that the improvement of a method flow cannot be realized by hardware entity modules. For example, a programmable logic device (Programmable Logic Device, PLD) (such as a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logic function is determined by the user's programming of the device. It is programmed by the designer to "integrate" a digital system on a PLD without requiring the chip manufacturer to design and manufacture a dedicated integrated circuit chip. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly realized by using "logic compiler" software, which is similar to the software compiler used in program development and writing, but before compilation The original code must also be written in a specific programming language, which is called Hardware Description Language (HDL), and there is not only one type of HDL, but many types, such as ABEL (Advanced Boolean Expression Language) , AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description), etc., currently most commonly used The ones are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. It should also be clear to those skilled in the art that only a little logic programming of the method flow in the above hardware description languages and programming into an integrated circuit can easily obtain the hardware circuit that implements the logic method flow.
控制器可以按任何适当的方式实现,例如,控制器可以采取例如微处理器或处理器以及存储可由该(微)处理器执行的计算机可读程序代码(例如软件或固件)的计算机可读介质、逻辑门、开关、专用集成电路(Application Specific Integrated Circuit,ASIC)、可编程逻辑控制器和嵌入微控制器的形式,控制器的例子包括但不限于以下微控制器:ARC 625D、Atmel AT91SAM、Microchip PIC18F26K20以及Silicone Labs C8051F320,存储器控制器还可以被实现为存储器的控制逻辑的一部分。本领域技术人员也知道,除了以纯计算机可读程序代码方式实现控制器以外,完全可以通过将方法步骤进行逻辑编程来使得控制器以逻辑门、开关、专用集成电路、可编程逻辑控制器和嵌入微控制器等的形式来实现相同功能。因此这种控制器可以被认为是一种硬件部件,而对其内包括的用于实现各种功能的装置也可以视为硬件部件内的结构。或者甚至,可以将用于实现各种功能的装置视为既可以是实现方法的软件模块又可以是硬件部件内的结构。The controller can be implemented in any suitable manner. For example, the controller can take the form of, for example, a microprocessor or a processor and a computer-readable medium storing computer-readable program codes (such as software or firmware) executable by the (micro)processor. , Logic gates, switches, application specific integrated circuits (ASICs), programmable logic controllers and embedded microcontrollers. Examples of controllers include but are not limited to the following microcontrollers: ARC625D, Atmel AT91SAM, Microchip PIC18F26K20 and Silicon Labs C8051F320, the memory controller can also be implemented as part of the memory control logic. Those skilled in the art also know that in addition to implementing the controller in a purely computer-readable program code manner, it is entirely possible to program the method steps to make the controller use logic gates, switches, application specific integrated circuits, programmable logic controllers and embedded The same function can be realized in the form of a microcontroller, etc. Therefore, such a controller can be regarded as a hardware component, and the devices included in it for implementing various functions can also be regarded as a structure within the hardware component. Or even, the device for realizing various functions can be regarded as both a software module for realizing the method and a structure within a hardware component.
上述实施例阐明的系统、装置、模块或单元,具体可以由计算机芯片或实体实现,或者由具有某种功能的产品来实现。一种典型的实现设备为计算机。具体的,计算机例如可以为个人计算机、膝上型计算机、蜂窝电话、相机电话、智能电话、个人数字助理、媒体播放器、导航设备、电子邮件设备、游戏控制台、平板计算机、可穿戴设备或者这些设备中的任何设备的组合。The systems, devices, modules, or units illustrated in the above embodiments may be specifically implemented by computer chips or entities, or implemented by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cell phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or Any combination of these devices.
为了描述的方便,描述以上装置时以功能分为各种单元分别描述。当然,在实施本说明书时可以把各单元的功能在同一个或多个软件和/或硬件中实现。For the convenience of description, when describing the above device, the functions are divided into various units and described separately. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and/or hardware.
本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代 码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art should understand that the embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention can be in the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present invention is described with reference to flowcharts and/or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and/or block in the flowchart and/or block diagram, and the combination of processes and/or blocks in the flowchart and/or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing equipment to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing equipment are generated It is a device that realizes the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
本说明书可以在由计算机执行的计算机可执行指令的一般上下文中描述,例如程序模块。一般地,程序模块包括执行特定任务或实现特定抽象数据类型的例程、程序、对象、组件、数据结构等等。也可以在分布式计算环境中实践本说明书,在这些分布式计算环境中,由通过通信网络而被连接的远程处理设备来执行任务。在分布式计算环境中,程序模块可以位于包括存储设备在内的本地和远程计算机存储介质中。This specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. This specification can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device. The device implements the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。在一个典型的配置中,计算机包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment. The instructions provide steps for implementing functions specified in a flow or multiple flows in the flowchart and/or a block or multiple blocks in the block diagram. In a typical configuration, the computer includes one or more processors (CPU), input/output interfaces, network interfaces, and memory.
内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。The memory may include non-permanent memory in computer readable media, random access memory (RAM) and/or non-volatile memory, such as read-only memory (ROM) or flash memory (flash RAM). Memory is an example of computer readable media.
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储 器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带、磁盘存储、量子存储器、基于石墨烯的存储介质或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。Computer-readable media include permanent and non-permanent, removable and non-removable media, and information storage can be realized by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, CD-ROM, digital versatile disc (DVD) or other optical storage, Magnetic cassettes, magnetic disk storage, quantum memory, graphene-based storage media or other magnetic storage devices or any other non-transmission media can be used to store information that can be accessed by computing devices. According to the definition in this article, computer-readable media does not include transitory media, such as modulated data signals and carrier waves.
还需要说明的是,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、商品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、商品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、商品或者设备中还存在另外的相同要素。It should also be noted that the terms "include", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, product or equipment including a series of elements not only includes those elements, but also includes Other elements that are not explicitly listed, or include elements inherent to this process, method, commodity, or equipment. If there are no more restrictions, the element defined by the sentence "including a..." does not exclude the existence of other identical elements in the process, method, commodity, or equipment that includes the element.
上述对本说明书特定实施例进行了描述。其它实施例在所附权利要求书的范围内。在一些情况下,在权利要求书中记载的动作或步骤可以按照不同于实施例中的顺序来执行并且仍然可以实现期望的结果。另外,在附图中描绘的过程不一定要求示出的特定顺序或者连续顺序才能实现期望的结果。在某些实施方式中,多任务处理和并行处理也是可以的或者可能是有利的。The foregoing describes specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps described in the claims may be performed in a different order than in the embodiments and still achieve desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
在本说明书一个或多个实施例使用的术语是仅仅出于描述特定实施例的目的,而非旨在限制本说明书一个或多个实施例。在本说明书一个或多个实施例和所附权利要求书中所使用的单数形式的“一种”、“所述”和“该”也旨在包括多数形式,除非上下文清楚地表示其他含义。还应当理解,本文中使用的术语“和/或”是指并包含一个或多个相关联的列出项目的任何或所有可能组合。The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and/or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
应当理解,尽管在本说明书一个或多个实施例可能采用术语第一、第二、第三等来描述各种信息,但这些信息不应限于这些术语。这些术语仅用来将同一类型的信息彼此区分开。例如,在不脱离本说明书一个或多个实施例范围的情况下,第一信息也可以被称为第二信息,类似地,第二信息也可以被称为第一信息。取决于语境,如在此所使用的词语“如果”可以被解释成为“在……时”或“当……时”或“响应于确定”。It should be understood that, although the terms first, second, third, etc. may be used in one or more embodiments of this specification to describe various information, the information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first information may also be referred to as second information, and similarly, the second information may also be referred to as first information. Depending on the context, the word "if" as used herein can be interpreted as "when" or "when" or "in response to determination".
以上所述仅为本说明书一个或多个实施例的较佳实施例而已,并不用以限制本说明书一个或多个实施例,凡在本说明书一个或多个实施例的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本说明书一个或多个实施例保护的范围之内。The above descriptions are only preferred embodiments of one or more embodiments of this specification, and are not used to limit one or more embodiments of this specification. All within the spirit and principle of one or more embodiments of this specification, Any modification, equivalent replacement, improvement, etc. made should be included in the protection scope of one or more embodiments of this specification.

Claims (26)

  1. 一种结合代码标注与用户类型的收据存储方法,包括:A receipt storage method combining code labeling and user type, including:
    第一区块链节点接收经过加密的对应于智能合约的交易,所述智能合约的代码中包括通过暴露标识符标明的对象;The first blockchain node receives an encrypted transaction corresponding to a smart contract, and the code of the smart contract includes an object marked by an exposed identifier;
    第一区块链节点在可信执行环境中解密所述交易,以获得所述智能合约的代码;The first blockchain node decrypts the transaction in the trusted execution environment to obtain the code of the smart contract;
    第一区块链节点在所述可信执行环境中执行所述智能合约的代码,得到收据数据;The first blockchain node executes the code of the smart contract in the trusted execution environment to obtain receipt data;
    第一区块链节点存储所述收据数据,当交易发起方属于预设用户类型时,使所述暴露标识符标明的对象对应的收据内容以明文形式存储、其余收据内容以密文形式存储。The first blockchain node stores the receipt data, and when the transaction initiator belongs to a preset user type, the content of the receipt corresponding to the object indicated by the exposure identifier is stored in plain text, and the rest of the receipt content is stored in cipher text.
  2. 根据权利要求1所述的方法,第一区块链节点接收的交易对应的智能合约,包括:According to the method of claim 1, the smart contract corresponding to the transaction received by the first blockchain node includes:
    高级语言编写的智能合约;或,Smart contracts written in high-level languages; or,
    字节码形式的智能合约。Smart contract in bytecode form.
  3. 根据权利要求2所述的方法,当第一区块链节点接收的交易对应的智能合约为高级语言编写的智能合约时,所述方法还包括:The method according to claim 2, when the smart contract corresponding to the transaction received by the first blockchain node is a smart contract written in a high-level language, the method further comprises:
    第一区块链节点通过编译器对所述高级语言编写的智能合约进行编译,生成字节码形式的智能合约,以在所述可信执行环境中执行。The first blockchain node compiles the smart contract written in the high-level language through the compiler, and generates the smart contract in the form of bytecode for execution in the trusted execution environment.
  4. 根据权利要求2所述的方法,当第一区块链节点接收的交易对应的智能合约为字节码形式的智能合约时,所述字节码形式的智能合约由客户端通过编译器对高级语言编写的智能合约进行编译而得到,所述高级语言编写的智能合约由用户在所述客户端上编写得到。According to the method of claim 2, when the smart contract corresponding to the transaction received by the first blockchain node is a smart contract in the form of bytecode, the smart contract in the form of bytecode is checked by the client through a compiler. The smart contract written in the language is compiled and obtained, and the smart contract written in the high-level language is written by the user on the client.
  5. 根据权利要求2所述的方法,所述高级语言编写的智能合约与所述字节码形式的智能合约具有相同或对应的暴露标识符。According to the method of claim 2, the smart contract written in the high-level language and the smart contract in the bytecode form have the same or corresponding exposure identifier.
  6. 根据权利要求1所述的方法,第一区块链节点接收的交易对应的智能合约,包括:According to the method of claim 1, the smart contract corresponding to the transaction received by the first blockchain node includes:
    用户在第一区块链节点上生成的智能合约;或,The smart contract generated by the user on the first blockchain node; or,
    用户在客户端上生成的智能合约;或,The smart contract generated by the user on the client; or,
    所述客户端通过第二区块链节点发来的交易中的智能合约。The smart contract in the transaction sent by the client through the second blockchain node.
  7. 根据权利要求1所述的方法,所述暴露标识符标明的对象包括:收据字段和/或状态变量。The method according to claim 1, wherein the objects indicated by the exposure identifier include: receipt fields and/or state variables.
  8. 根据权利要求1所述的方法,所述暴露标识符标明的对象包括:合约级对象;第一区块链节点存储所述收据数据,包括:The method according to claim 1, wherein the objects indicated by the exposure identifier include: contract-level objects; and storing the receipt data by the first blockchain node includes:
    第一区块链节点在交易发起方属于预设用户类型时,将所述收据数据中对应于所述合约级对象的所有收据内容以明文形式存储。When the transaction initiator belongs to the preset user type, the first blockchain node stores all receipt contents corresponding to the contract-level object in the receipt data in plain text.
  9. 根据权利要求1所述的方法,所述暴露标识符标明的对象包括:对应于所述智能合约中定义的至少一个事件的事件级对象;第一区块链节点存储所述收据数据,包括:The method according to claim 1, wherein the object indicated by the exposure identifier includes: an event-level object corresponding to at least one event defined in the smart contract; and the first blockchain node to store the receipt data includes:
    第一区块链节点在交易发起方属于预设用户类型时,确定出所述收据数据中对应于所述至少一个事件的收据内容,并将确定出的收据内容中对应于所述事件级对象的部分以明文形式存储。When the transaction initiator belongs to the preset user type, the first blockchain node determines the receipt content corresponding to the at least one event in the receipt data, and determines the receipt content corresponding to the event-level object The part is stored in clear text.
  10. 根据权利要求1所述的方法,第一区块链节点通过下述方式确定所述交易发起方所属的用户类型:According to the method of claim 1, the first blockchain node determines the user type to which the transaction initiator belongs in the following manner:
    第一区块链节点确定所述交易发起方对应的外部账户;The first blockchain node determines the external account corresponding to the transaction initiator;
    第一区块链节点查询区块链上记录的所述外部账户对应的用户类型,以作为所述交易发起方所属的用户类型。The first blockchain node queries the user type corresponding to the external account recorded on the blockchain as the user type to which the transaction initiator belongs.
  11. 根据权利要求10所述的方法,所述外部账户包括记录于区块链上的类型字段,所述类型字段的取值对应于所述用户类型。The method according to claim 10, wherein the external account includes a type field recorded on the blockchain, and the value of the type field corresponds to the user type.
  12. 根据权利要求10所述的方法,在创建所述外部账户时,所述用户类型被配置为关联至所述外部账户,使所述用户类型与所述外部账户之间的关联关系被记录于区块链中。The method according to claim 10, when the external account is created, the user type is configured to be associated with the external account, so that the association relationship between the user type and the external account is recorded in the area Block chain.
  13. 根据权利要求12所述的方法,还包括:The method according to claim 12, further comprising:
    第一区块链节点根据管理用户发起的更改请求,更改所述外部账户对应的用户类型。The first blockchain node changes the user type corresponding to the external account according to the change request initiated by the management user.
  14. 根据权利要求1所述的方法,第一区块链节点存储所述收据数据,包括:The method according to claim 1, wherein the first blockchain node storing the receipt data includes:
    第一区块链节点读取系统合约的代码,所述系统合约的代码中定义了与暴露标识符、用户类型相关的收据数据存储逻辑;The first blockchain node reads the code of the system contract, and the code of the system contract defines the receipt data storage logic related to the exposed identifier and user type;
    第一区块链节点执行所述系统合约的代码,以在所述交易发起方属于所述预设用户类型时,将所述暴露标识符标明的对象对应的收据内容以明文形式存储、其余收据内容以密文形式存储,并在所述交易发起方不属于所述预设用户类型时,将所述收据数据以密文形式存储。The first blockchain node executes the code of the system contract to store the content of the receipt corresponding to the object marked by the exposure identifier in plain text when the transaction initiator belongs to the preset user type, and the remaining receipts The content is stored in cipher text, and when the transaction initiator does not belong to the preset user type, the receipt data is stored in cipher text.
  15. 根据权利要求14所述的方法,所述系统合约包括:记录于创世块中的预置系统合约,或所述预置系统合约对应的更新后系统合约。The method according to claim 14, wherein the system contract comprises: a preset system contract recorded in the genesis block, or an updated system contract corresponding to the preset system contract.
  16. 根据权利要求1所述的方法,第一区块链节点存储所述收据数据,包括:The method according to claim 1, wherein the first blockchain node storing the receipt data includes:
    第一区块链节点在所述可信执行环境之外执行存储功能代码,以将所述收据数据存储至所述可信执行环境之外的外部存储空间。The first blockchain node executes the storage function code outside the trusted execution environment to store the receipt data in an external storage space outside the trusted execution environment.
  17. 根据权利要求1所述的方法,所述交易用于创建和/或调用所述智能合约。According to the method of claim 1, the transaction is used to create and/or call the smart contract.
  18. 根据权利要求1所述的方法,第一区块链节点对所述收据字段进行加密的密钥包括:对称加密算法的密钥或非对称加密算法的密钥。According to the method of claim 1, the key used by the first blockchain node to encrypt the receipt field includes: a key of a symmetric encryption algorithm or a key of an asymmetric encryption algorithm.
  19. 根据权利要求18所述的方法,所述对称加密算法的密钥包括所述客户端提供的初始密钥;或,所述对称加密算法的密钥包括所述初始密钥与影响因子生成的衍生密钥。The method according to claim 18, wherein the key of the symmetric encryption algorithm comprises an initial key provided by the client; or, the key of the symmetric encryption algorithm comprises a derivative generated by the initial key and an impact factor Key.
  20. 根据权利要求19所述的方法,所述交易由所述初始密钥进行加密,且所述初始密钥被非对称加密算法的公钥进行加密;第一区块链节点在可信执行环境中解密所述交易中的所述智能合约的代码,包括:The method according to claim 19, wherein the transaction is encrypted by the initial key, and the initial key is encrypted by the public key of an asymmetric encryption algorithm; the first blockchain node is in a trusted execution environment The code for decrypting the smart contract in the transaction includes:
    第一区块链节点用所述非对称加密算法的私钥解密得到所述初始密钥,并用所述初始密钥对所述交易进行解密得到所述智能合约的代码。The first blockchain node decrypts the private key of the asymmetric encryption algorithm to obtain the initial key, and uses the initial key to decrypt the transaction to obtain the code of the smart contract.
  21. 根据权利要求19所述的方法,所述初始密钥由客户端生成;或,所述初始密钥由密钥管理服务器发送至所述客户端。According to the method of claim 19, the initial key is generated by a client; or, the initial key is sent to the client by a key management server.
  22. 根据权利要求19所述的方法,所述影响因子与所述交易相关。The method of claim 19, the impact factor is related to the transaction.
  23. 根据权利要求22所述的方法,所述影响因子包括:所述交易的哈希值的指定位。The method according to claim 22, wherein the impact factor comprises: a designated bit of a hash value of the transaction.
  24. 一种结合代码标注与用户类型的收据存储节点,包括:A receipt storage node combining code annotation and user type, including:
    接收单元,接收经过加密的对应于智能合约的交易,所述智能合约的代码中包括通过暴露标识符标明的对象;The receiving unit receives an encrypted transaction corresponding to a smart contract, and the code of the smart contract includes an object marked by an exposed identifier;
    解密单元,在可信执行环境中解密所述交易,以获得所述智能合约的代码;A decryption unit to decrypt the transaction in a trusted execution environment to obtain the code of the smart contract;
    执行单元,在所述可信执行环境中执行所述智能合约的代码,得到收据数据;The execution unit executes the code of the smart contract in the trusted execution environment to obtain receipt data;
    存储单元,存储所述收据数据,当交易发起方属于预设用户类型时,使所述暴露标识符标明的对象对应的收据内容以明文形式存储、其余收据内容以密文形式存储。The storage unit stores the receipt data. When the transaction initiator belongs to the preset user type, the receipt content corresponding to the object indicated by the exposure identifier is stored in plain text, and the rest of the receipt content is stored in cipher text.
  25. 一种电子设备,包括:An electronic device including:
    处理器;processor;
    用于存储处理器可执行指令的存储器;A memory for storing processor executable instructions;
    其中,所述处理器通过运行所述可执行指令以实现如权利要求1-23中任一项所述的方法。Wherein, the processor executes the executable instruction to implement the method according to any one of claims 1-23.
  26. 一种计算机可读存储介质,其上存储有计算机指令,该指令被处理器执行时实现如权利要求1-23中任一项所述方法的步骤。A computer-readable storage medium having computer instructions stored thereon, which, when executed by a processor, implement the steps of the method according to any one of claims 1-23.
PCT/CN2020/091419 2019-05-20 2020-05-20 Receipt storage method combining code labelling with user type, and node WO2020233637A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910419928.6A CN110245945B (en) 2019-05-20 2019-05-20 Receipt storage method and node combining code marking and user type
CN201910419928.6 2019-05-20

Publications (1)

Publication Number Publication Date
WO2020233637A1 true WO2020233637A1 (en) 2020-11-26

Family

ID=67884371

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/091419 WO2020233637A1 (en) 2019-05-20 2020-05-20 Receipt storage method combining code labelling with user type, and node

Country Status (2)

Country Link
CN (1) CN110245945B (en)
WO (1) WO2020233637A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112948499A (en) * 2021-03-31 2021-06-11 北京金山云网络技术有限公司 Information acquisition method and device, electronic equipment and storage medium

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110245945B (en) * 2019-05-20 2021-03-23 创新先进技术有限公司 Receipt storage method and node combining code marking and user type
WO2020233422A1 (en) * 2019-05-20 2020-11-26 创新先进技术有限公司 Receipt storage method and node based on user type
CN110263089B (en) * 2019-05-20 2021-05-04 创新先进技术有限公司 Receipt storage method and node combining conditional restrictions of transaction and event types
CN110263543B (en) * 2019-05-20 2021-06-01 创新先进技术有限公司 Object-level receipt storage method and node based on code labeling
CN110266644B (en) * 2019-05-20 2021-04-06 创新先进技术有限公司 Receipt storage method and node combining code marking and transaction types
WO2020233421A1 (en) * 2019-05-20 2020-11-26 创新先进技术有限公司 Object-level receipt storage method and node based on code marking
CN110245503B (en) * 2019-05-20 2021-04-27 创新先进技术有限公司 Receipt storage method and node combining code marking and judging conditions
CN110580412B (en) * 2019-11-08 2020-03-06 支付宝(杭州)信息技术有限公司 Permission query configuration method and device based on chain codes

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105653973A (en) * 2015-12-16 2016-06-08 金蝶软件(中国)有限公司 Data encryption method and apparatus based on business platform
WO2017090041A1 (en) * 2015-11-24 2017-06-01 Ben-Ari Adi A system and method for blockchain smart contract data privacy
CN107342858A (en) * 2017-07-05 2017-11-10 武汉凤链科技有限公司 A kind of intelligent contract guard method and system based on trusted context
CN108052321A (en) * 2017-12-28 2018-05-18 杭州趣链科技有限公司 A kind of method that block chain intelligence contract is automatically generated based on configuration information
CN109034814A (en) * 2018-09-14 2018-12-18 百度在线网络技术(北京)有限公司 Intelligent contract treating method and apparatus based on ether mill virtual machine
CN109040133A (en) * 2018-09-27 2018-12-18 上海点融信息科技有限责任公司 The method, apparatus and storage medium of intelligent contract are installed in block chain network
CN110245945A (en) * 2019-05-20 2019-09-17 阿里巴巴集团控股有限公司 In conjunction with the receipt storage method and node of code mark and user type
CN110266644A (en) * 2019-05-20 2019-09-20 阿里巴巴集团控股有限公司 In conjunction with the receipt storage method and node of code mark and type of transaction
CN110264196A (en) * 2019-05-20 2019-09-20 阿里巴巴集团控股有限公司 In conjunction with the conditional receipt storage method and node of code mark and user type

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11209815B2 (en) * 2016-04-01 2021-12-28 Intel Corporation Drone control registration
CN106559211B (en) * 2016-11-22 2019-12-13 中国电子科技集团公司第三十研究所 Privacy protection intelligent contract method in block chain
CN107507091A (en) * 2017-09-07 2017-12-22 复旦大学 Enhanced data Right protection method based on block chain and intelligent contract
CN108235772B (en) * 2017-12-29 2021-04-09 达闼机器人有限公司 Data processing method and device based on block chain, storage medium and electronic equipment
CN108922012B (en) * 2018-07-11 2020-05-19 北京大账房网络科技股份有限公司 Invoice checking method without leakage of original information based on block chain technology
CN109033855B (en) * 2018-07-18 2020-02-11 腾讯科技(深圳)有限公司 Data transmission method and device based on block chain and storage medium
CN109214903A (en) * 2018-08-10 2019-01-15 海南高灯科技有限公司 A kind of invoice reimbursement system and method for charging out based on block chain
CN108961030B (en) * 2018-08-15 2023-01-03 深圳市智税链科技有限公司 Data processing method, apparatus, system, medium, and device for electronic ticket
CN109523267A (en) * 2018-10-30 2019-03-26 苏宁易购集团股份有限公司 A kind of verification method, the apparatus and system of the transaction data based on block chain
CN109766722B (en) * 2019-01-22 2020-11-10 苏州同济区块链研究院有限公司 Method for constructing intelligent contract in block chain
CN109756582B (en) * 2019-03-15 2022-08-12 腾讯科技(深圳)有限公司 Information recording method, device, node and storage medium in block chain network

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017090041A1 (en) * 2015-11-24 2017-06-01 Ben-Ari Adi A system and method for blockchain smart contract data privacy
CN105653973A (en) * 2015-12-16 2016-06-08 金蝶软件(中国)有限公司 Data encryption method and apparatus based on business platform
CN107342858A (en) * 2017-07-05 2017-11-10 武汉凤链科技有限公司 A kind of intelligent contract guard method and system based on trusted context
CN108052321A (en) * 2017-12-28 2018-05-18 杭州趣链科技有限公司 A kind of method that block chain intelligence contract is automatically generated based on configuration information
CN109034814A (en) * 2018-09-14 2018-12-18 百度在线网络技术(北京)有限公司 Intelligent contract treating method and apparatus based on ether mill virtual machine
CN109040133A (en) * 2018-09-27 2018-12-18 上海点融信息科技有限责任公司 The method, apparatus and storage medium of intelligent contract are installed in block chain network
CN110245945A (en) * 2019-05-20 2019-09-17 阿里巴巴集团控股有限公司 In conjunction with the receipt storage method and node of code mark and user type
CN110266644A (en) * 2019-05-20 2019-09-20 阿里巴巴集团控股有限公司 In conjunction with the receipt storage method and node of code mark and type of transaction
CN110264196A (en) * 2019-05-20 2019-09-20 阿里巴巴集团控股有限公司 In conjunction with the conditional receipt storage method and node of code mark and user type

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112948499A (en) * 2021-03-31 2021-06-11 北京金山云网络技术有限公司 Information acquisition method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN110245945B (en) 2021-03-23
CN110245945A (en) 2019-09-17

Similar Documents

Publication Publication Date Title
WO2020233616A1 (en) Receipt storage method and node employing code marking in combination with transaction type and user type
WO2020233642A1 (en) Conditional receipt storage method and node which combine code labelling and type dimension
WO2020233637A1 (en) Receipt storage method combining code labelling with user type, and node
WO2020233638A1 (en) Receipt storage method and node based on code labeling and transaction type
WO2020233644A1 (en) Conditional receipt storage method and node combining dimensions of code annotation and type
WO2020233612A1 (en) Receipt storage method and node combining code annotation with transaction and event types
WO2020233643A1 (en) Receipt storage method and node employing multi-dimensional information and having restriction
WO2020233613A1 (en) Conditional receipt storage method and node which combine code marking with transaction type
WO2020233609A1 (en) Conditional receipt storage method and node combining code labeling with user type
WO2020233640A1 (en) Receipt storage method and node based on code labeling and determination condition
WO2020233610A1 (en) Receipt storage method combining code labelling with user and event type, and node
WO2020233623A1 (en) Receipt storage method and node combining transaction type and judgment condition
WO2020233622A1 (en) Receipt storage method and node based on code labeling and multiple types of dimensions
WO2020233630A1 (en) User type-based receipt storing method and node
WO2020233615A1 (en) Receipt storage method combining user type and event function type and node
WO2020233614A1 (en) Conditional receipt storage method and node combining code labeling with event type
WO2020233635A1 (en) Receipt storage method combining conditional restrictions of multiple types of dimensions and node
WO2020233626A1 (en) Receipt storage method and node in combination with conditional limitation of transaction and user types
WO2020233625A1 (en) Receipt storage method combining user type and determination conditions and node
WO2020233639A1 (en) Receipt storage method and node based on code labeling and event function type
WO2020233628A1 (en) Receipt storage method and node based on combination of event function type and judgment condition
WO2020233629A1 (en) Object-level receipt storage method and node based on code labeling
WO2020233624A1 (en) Receipt storage method and node employing transaction type in combination with event function type
WO2020233619A1 (en) Receipt storage method and node in combination with user type and transaction type
WO2020233632A1 (en) Receipt storage method and node based on event function type

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

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

Country of ref document: EP

Kind code of ref document: A1