+

WO2020233423A1 - Receipt storage method and node based on transaction type - Google Patents

Receipt storage method and node based on transaction type Download PDF

Info

Publication number
WO2020233423A1
WO2020233423A1 PCT/CN2020/089384 CN2020089384W WO2020233423A1 WO 2020233423 A1 WO2020233423 A1 WO 2020233423A1 CN 2020089384 W CN2020089384 W CN 2020089384W WO 2020233423 A1 WO2020233423 A1 WO 2020233423A1
Authority
WO
WIPO (PCT)
Prior art keywords
transaction
receipt
event
field
fields
Prior art date
Legal status (The legal status 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 status listed.)
Ceased
Application number
PCT/CN2020/089384
Other languages
French (fr)
Chinese (zh)
Inventor
刘琦
闫莺
魏长征
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Advanced New Technologies Co Ltd
Original Assignee
Advanced New Technologies Co Ltd
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
Priority claimed from CN201910420668.4A external-priority patent/CN110264198B/en
Priority claimed from CN201910419897.4A external-priority patent/CN110278193B/en
Priority claimed from CN201910420663.1A external-priority patent/CN110245946B/en
Priority claimed from CN201910419943.0A external-priority patent/CN110245504B/en
Priority claimed from CN201910419140.5A external-priority patent/CN110264192B/en
Priority claimed from CN201910420679.2A external-priority patent/CN110266644B/en
Priority claimed from CN201910419908.9A external-priority patent/CN110223172B/en
Priority claimed from CN201910420689.6A external-priority patent/CN110276684B/en
Priority claimed from CN201910419925.2A external-priority patent/CN110263089B/en
Priority claimed from CN201910420680.5A external-priority patent/CN110245947B/en
Priority claimed from CN201910419728.0A external-priority patent/CN110264193B/en
Priority claimed from CN201910419887.0A external-priority patent/CN110264195B/en
Priority claimed from CN201910419900.2A external-priority patent/CN110245490B/en
Priority claimed from CN201910420675.4A external-priority patent/CN110263544B/en
Priority claimed from CN201910419898.9A external-priority patent/CN110263087B/en
Priority claimed from CN201910419930.3A external-priority patent/CN110263090B/en
Application filed by Advanced New Technologies Co Ltd filed Critical Advanced New Technologies Co Ltd
Publication of WO2020233423A1 publication Critical patent/WO2020233423A1/en
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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

Definitions

  • One or more embodiments of this specification relate to the field of blockchain technology, and in particular to a method and node for storing receipts based on transaction types.
  • 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 based on transaction type.
  • a method for storing receipts based on transaction types including:
  • the first blockchain node receives the encrypted transaction
  • the first blockchain node decrypts the transaction in the trusted execution environment and executes the obtained transaction content to obtain receipt data
  • the first blockchain node determines the exposed field in the receipt data according to the transaction type of the transaction
  • the first blockchain node stores the receipt data so that at least part of the receipt content corresponding to the exposed field is stored in plain text, and the rest of the receipt content is stored in cipher text.
  • a receipt storage node based on transaction type including:
  • the receiving unit receives encrypted transactions
  • the decryption unit decrypts the transaction in a trusted execution environment to obtain transaction content
  • the execution unit executes the transaction content in the trusted execution environment to obtain receipt data
  • the determining unit determines the exposed fields in the receipt data according to the transaction type of the transaction
  • the storage unit stores the receipt data so that at least part of the receipt content corresponding to the exposed field 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 implementing privacy protection on blockchain nodes according to an exemplary embodiment.
  • Fig. 2 is a flowchart of a method for storing receipts based on transaction types according to an exemplary embodiment.
  • Fig. 3 is a schematic diagram of creating a smart contract according to an exemplary embodiment.
  • Fig. 4 is a schematic diagram of invoking a smart contract provided by 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 device based on transaction 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.
  • 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 forms a receipt tree.
  • the receipt tree is generated through organization, so that when querying or verifying receipt data, the corresponding query or verification efficiency can be greatly improved.
  • the MPT Merkle Patricia Tree
  • the leaf of the receipt tree is the hash value of the receipt data corresponding to each transaction contained in the block, and the receiptRoot is Root hashes generated sequentially upwards according to the hash value of the receipt data at the leaf.
  • other types of tree structures can also be used in other blockchain networks.
  • 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 receipt data needs to be stored in cipher text.
  • the first blockchain node includes the conventional environment on the left (on the left in the figure) and TEE.
  • the transaction submitted by the client (or other sources) first enters the "transaction/query interface" in the conventional environment , And then pass the transaction to the TEE for processing.
  • TEE is isolated from the normal environment. For example, when a transaction is encrypted, the transaction needs to be transferred to the TEE for decryption as the transaction content in clear text, 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 block chain is a data set stored in a database of a node and organized by a specific logic.
  • the database may be a storage medium, such as a persistent storage medium, on a physical carrier.
  • the privacy protection requirements for receipt data are not the same. For example, deposit certificate transactions focus on the privacy protection of the identity of the transaction initiator, transfer transactions focus on the privacy protection of the identities of both parties to the transfer, and transactions related to smart contracts focus on the privacy protection of the identity of the transaction initiator.
  • step 202 the first blockchain node receives the encrypted transaction.
  • the user can directly generate a transaction on the first blockchain node; or, the user can generate a transaction on the client, and send the transaction to the first blockchain node through the client; or, the client
  • the terminal can send the above transaction to the second blockchain node, and the second blockchain node sends the transaction to the first blockchain node.
  • the transactions in this manual can be used to implement relatively simple processing logic, such as similar to the deposit logic and transfer logic in related technologies, that is, the relevant transactions are deposit transactions, transfer transactions, etc. At this time, the above transaction may not be related to the 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 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 3 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 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 that is called, and the required input Methods and parameters, etc.
  • Step 204 The first blockchain node decrypts the transaction in the trusted execution environment and executes the obtained transaction content to obtain receipt data.
  • the encrypted transaction can be kept in a state of privacy protection, and the transaction content can be prevented from being exposed.
  • the transaction content may contain information such as the account address of the transaction initiator and the account address of the transaction target. Encryption processing can ensure that these transaction contents cannot be directly read.
  • 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.
  • 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 .
  • the specific implementation process is similar to the above process, and will not be repeated here.
  • 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 3-4) and the transaction nonce (nonce) as input, and is generated by an encryption algorithm, such as in Figure 3-4
  • 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 generated 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 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 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 206 The first blockchain node determines the exposed field in the receipt data according to the transaction type of the transaction.
  • the transaction may include a transaction type field (such as a TransType field), and the value of the transaction type field is used to indicate the corresponding transaction type. Therefore, by reading the value of the transaction type field in the exchange, the transaction type can be determined, such as the type of deposit certificate, the type of asset transfer (such as transfer), the type of contract creation, and the type of contract invocation. This manual does not limit this .
  • different types of transactions may respectively have corresponding exposed fields.
  • the exposed field is one or more fields specified in the receipt data.
  • the content of the receipt corresponding to the exposed field is allowed to be stored in plain text for subsequent receipts stored in plain text.
  • the mapping relationship between each transaction type and the exposed field may be predefined, so that the first blockchain node can obtain the predefined mapping relationship, and further based on the transaction type of the transaction and the mapping relationship, Identify the exposed fields in the receipt data.
  • the exposed field corresponding to the attestation type may include all fields except the above-mentioned From field
  • the exposed field corresponding to the asset transfer type may include the above-mentioned To field
  • the exposed field corresponding to the contract creation type and contract invocation type may include the above-mentioned From field. All the fields except for the other transaction types will not be repeated here.
  • mapping relationship may be recorded in the system contract. If there is no upgrade requirement for the above mapping relationship, the mapping relationship can also be recorded in the chain code of the blockchain network.
  • Step 208 The first blockchain node stores the receipt data so that at least part of the receipt content corresponding to the exposed field is stored in plain text, and the rest of the receipt content is stored in cipher text.
  • the first blockchain node reads the code of the system contract.
  • the code of the system contract defines the receipt data storage logic related to the transaction type, that is, the exposed field corresponding to each transaction type (similar to The above-mentioned mapping relationship), the logic of implementing plaintext storage for exposed fields, the logic of implementing ciphertext storage for non-exposed fields, etc.; accordingly, the first blockchain node can execute the code of the system contract to correspond to the exposed fields At least part of the receipt content is stored in plain text, and the rest of the receipt content is stored in cipher text.
  • 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 transaction type described above can be written into the chain code, so that each blockchain node can implement the receipt data storage logic; Take the blockchain node as an example.
  • the receipt data storage logic is as described above: the receipt data storage logic can specifically define the exposed fields corresponding to each transaction type, so that the first blockchain node can determine according to the transaction type Which receipt content in the receipt data generated by the transaction needs to be stored in plain text, and which receipt content needs to be stored in cipher text.
  • 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 address "0x53a98" to read the system The code in the contract) to realize the functional supplement of the chain code.
  • 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 can read the code of the system contract, and the code of the system contract defines the receipt data storage logic related to the preset transaction type; then, the first blockchain node can execute the system contract Code to determine the corresponding exposed field according to the transaction type, and store the corresponding receipt content in the receipt data in plain text, and store the remaining receipt content in cipher text.
  • the first blockchain node encrypts the content of the receipt (the content of the receipt corresponding to the non-exposed field, and may also include part of the content of the receipt corresponding to the exposed field) using a 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 may 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.
  • the client can randomly generate an initial key for each transaction. Key to improve security.
  • the first blockchain node may 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 may 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 may use the private key of the asymmetric encryption algorithm.
  • the key decrypts the encrypted receipt content.
  • 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. 1 "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 1, where "package” means that the first blockchain node packages the transaction into blocks outside of the trusted execution environment), the cipher text 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.
  • this specification can further identify the exposed identifier contained in the code of the smart contract corresponding to the transaction, so as to determine the receipt according to the exposed field corresponding to the transaction type and the field marked by the exposed identifier. How the data is stored. Therefore, the above step 208 can be improved as: the first blockchain node stores the receipt data so that the exposed fields in the receipt data indicated by the exposure identifier are stored in plain text, and the remaining receipt fields are stored in cipher text. storage.
  • the user can add an exposed identifier to the code to indicate one or more fields, so as to express the following meaning in the code dimension of the smart contract: For the fields marked by the exposed identifier, they hope that the receipt The corresponding receipt content in the data is stored in plain text, and the receipt content corresponding to the remaining fields is stored in cipher text. Of course, whether to store the fields indicated by the exposed identifiers in plain text in the end also needs to be combined with the relevant information of the transaction types described below, which is not repeated here.
  • 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 fields can be marked by exposing identifiers.
  • the meaning of the expression is: I hope to store the contents of the receipt corresponding to this part of the field in the receipt data in plain text, and Store the rest of the receipt content in cipher text.
  • one or more fields can also be marked by exposing identifiers to indicate similar meanings.
  • the exposure identifier can be dedicated to indicating receipt fields that need to be stored in plain text.
  • the keyword plain can be used to characterize the exposure identifier. Then, for the fields that you want to store in plain text, you can add plain before the corresponding field (or, you can also associate with the corresponding field in other ways), such as the Result field, Gas used field, and Logs field described above. , Output field, etc., or the From field, To field, Topic field, Log data field, etc. further included in the Logs field.
  • 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.
  • only the From field can be judged: if the From field is the exposed field corresponding to the transaction type of the transaction to which the smart contract belongs, then after the code of the smart contract is executed, it will be generated
  • the receipt content corresponding to the From field in the receipt data is stored in plain text, and subsequent retrieval operations can be performed on the receipt content in the From field, such as counting the transaction volume initiated by an account, etc.; and before the From field All other fields are stored in cipher text.
  • the fields (all fields or From fields) marked by the exposed identifier "plain" are contract-level fields, so that the first blockchain node is storing
  • the contract-level field is an exposed field
  • the first blockchain node will store all receipt contents corresponding to the contract-level field in the receipt data in plain text.
  • the contract-level field can be applied to all events in the smart contract.
  • From field Take the From field as an example: when the From field is a contract-level field and the exposed field corresponding to the transaction type , For multiple events to generate their corresponding Logs fields, 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 fields indicated by the exposure identifier may include: event-level fields corresponding to at least one event defined in the smart contract, so that when the first blockchain node stores the receipt data, if the event-level field belongs to the transaction
  • the exposed field corresponding to the type can determine the receipt content corresponding to the at least one event in the receipt data, and store the determined portion of the receipt content corresponding to the event-level field in plain text.
  • the above event-level fields can be set for at least some of the events, so that the part of the receipt content corresponding to these events that corresponds to the event-level field is stored in plain text, and this part The remaining part of the receipt content corresponding to the event and the receipt content corresponding to the remaining events are stored in cipher text.
  • the above code example 1 can be adjusted to the following code example 3:
  • 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.
  • this specification can further identify the user type of the transaction initiator, so as to determine the storage method of the receipt data according to the exposed fields corresponding to the transaction type and the user type of the transaction initiator at the same time. Therefore, the above step 208 can be improved to: the first blockchain node stores the receipt data, and when the transaction initiator belongs to the preset user type, the exposed field is stored in plain text, and the remaining receipt fields are stored in cipher text. When the transaction initiator does not belong to the preset user type, the receipt data is stored in cipher text.
  • different users can implement differentiated storage operations for the exposed fields in the generated receipt data according to the differentiated needs of different users for the degree of privacy protection, which has high flexibility Sex.
  • ordinary users have relatively lower requirements for privacy protection and higher requirements for triggering operations based on receipt data.
  • receipt data generated by transactions initiated by ordinary users the contents of the receipt corresponding to the exposed fields can be stored in plain text.
  • the privacy protection requirements of advanced users are relatively higher, and the requirements for triggering operations based on receipt data are relatively lower.
  • the content of the receipt corresponding to the exposed field can be ciphered Form storage to ensure that the receipt content in ciphertext form can be stored safely while supporting some types of associated operations.
  • the exposed fields contained in the data can achieve differentiated storage operations. Compared with all receipt data stored in ciphertext form, it has relatively higher flexibility, and the content of the receipt stored in plaintext can directly implement subsequent retrieval and other operations. So as to meet more abundant application scenarios.
  • the user has a corresponding external account on the blockchain, and initiates transactions or performs other operations based on the external account. Then, the preset user type to which the transaction initiator belongs, that is, the preset 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 user type field (such as a UserType field) recorded on the blockchain, and the value of the user type field corresponds to the user type.
  • a user type field such as a UserType field
  • the first blockchain node can determine the corresponding user type based on the value by reading the user type field of the external account mentioned above.
  • 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-mentioned user 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.
  • this specification can further identify the event functions contained in the smart contract, so as to determine the storage method of the receipt data according to the exposed fields corresponding to the transaction type and the special event functions contained in the smart contract at the same time . Therefore, the above step 208 can be improved as: the first blockchain node stores the receipt data, so that the exposed fields in the log corresponding to the special event function are stored in plain text, and the rest of the receipt data is stored in encrypted form. Document storage.
  • the exposed fields that can be stored in plaintext can be determined according to the differentiated needs of different types of transactions for privacy protection, and further based on the events contained in the smart contract called by the transaction Function, which reflects the differentiated requirements of different types of event functions for privacy protection in the storage process, and has high flexibility.
  • the exposed fields involved in the special event function are stored in plain text, while the non-exposed fields involved in the special event function and all receipt fields involved in the normal event function are stored in cipher text.
  • the smart contract may include one or more events, and each event is used to implement predefined related processing logic. After each event contained in the smart contract is called and executed, the corresponding Logs field will be generated. For example, when the smart contract contains event 1 and event 2, event 1 can generate the corresponding Logs field, and event 2 can generate the corresponding Logs field. , So that the receipt data corresponding to the smart contract contains multiple Logs fields at the same time.
  • the events contained in the smart contract can be divided into special event functions and ordinary event functions.
  • the logs generated by the ordinary event functions are stored in cipher text to achieve privacy protection; the special event functions generated Logs need to store at least part of the log fields (such as the exposed fields described above) in plain text on the premise of meeting the privacy protection requirements, so that the content of this part of the log fields can be retrieved to drive related operations.
  • the special event function may be a predefined global event function in the blockchain network.
  • the event function belonging to the "special event function” can be recorded, for example, it can be recorded in the special event function list; accordingly, by combining the event function contained in the smart contract with By comparing the above special event function list, it can be determined whether the event function included in the smart contract is the above special event function.
  • the special event function can be any function defined in the smart contract, and by adding a type identifier for the event function in the smart contract, the event function can be marked as a special event function.
  • the code example of the event function included in the smart contract is as follows:
  • Event buy_candy1 expose(who,candy_num);
  • the smart contract defines 2 events: event buy_candy1 and event buy_candy2.
  • event buy_candy1 By adding the type identifier "expose" to the event buy_candy1, the event buy_candy1 can be marked as the above special event function; correspondingly, since the event buy_candy2 does not contain the type identifier "expose", the event buy_candy2 is a normal event function Instead of the special event function mentioned above.
  • High-level languages supported by Ethereum such as Solidity, Serpent, and LLL languages
  • a smart contract written in a high-level language can be compiled into a corresponding bytecode through a compiler, and the first blockchain node will finally execute the smart contract in the form of bytecode in the EVM virtual machine.
  • the above-mentioned type identifier can be the same in high-level language and bytecode smart contract code, or the first type identifier in high-level language smart contract code, and the second type in bytecode smart contract code Type identifier, the first type identifier and the second type identifier can correspond to each other.
  • this specification can further identify the receipt content in the receipt data that meets the preset conditions, so as to determine the receipt according to the user type of the transaction initiator and the satisfaction of the receipt content to the preset conditions. How the data is stored. Therefore, the above step 208 can be improved as follows: the first blockchain node stores the receipt data, so that the exposed fields in the receipt data that meet the preset conditions are stored in plain text, and the remaining receipt fields are stored in cipher text.
  • the exposed fields that meet the preset conditions can be stored in plain text, while the exposed fields or other receipt fields that do not meet the preset conditions must be stored in cipher text.
  • the content of the preset condition may include at least one of the following: the corresponding receipt field contains the preset content, the value of the corresponding receipt field belongs to a preset numerical interval, and so on.
  • the preset content may include: one or more specified keywords.
  • the keywords may include predefined state variables, predefined event functions, information used to indicate the result of transaction execution, etc., so that when an exposed field contains When the state variable, event function, or transaction execution result is used as a keyword, it can be determined that the exposed field meets the preset conditions.
  • the transaction execution result can include: "success” means the transaction is successful, "fail” means the transaction failed; when the keyword is "success”, the exposed fields containing "success” will be stored in plain text, and Exposed fields containing "fail” and other types of receipt fields are not allowed to be stored in plain text, ensuring that successful transactions will be viewed and subsequent operations will be triggered.
  • the preset content may include: preset values.
  • the preset value can be a numeric value, which can be compared with the value of a state variable, etc., to determine whether the value of the state variable meets expectations; for another example, the preset value can be composed of numeric values, letters, special symbols, etc. String, which can be compared with the account address of the transaction initiator, the account address of the transaction target, the content of the event function, etc. to identify the specific transaction initiator, specific transaction target or specific event function, etc. .
  • the user can use the To field when the user initiates a transaction for a specific transaction target and the exposed field corresponding to the transaction type includes the To field. It is stored in plain text, and when a transaction is initiated for other transaction targets, the To field is not allowed to be stored in plain text to avoid privacy leakage.
  • the preset value range can indicate the privacy protection requirements of the relevant receipt fields.
  • the preset value range can be a value range with a smaller value and a lower privacy protection requirement, so that even if the relevant receipt field is disclosed, it will not cause Serious user privacy leakage, but it can be used to automatically trigger related operations such as DAPP client, so as to achieve a certain balance between privacy protection and convenience. Therefore, when the value of the exposed field is within the preset numerical range, the exposed field can be stored in plain text.
  • the preset condition may include a general condition corresponding to all receipt fields in the receipt data, that is, when any receipt field in the receipt data is identified as an exposed field, it is used for comparison with the preset condition.
  • the preset condition is "Contains preset keywords”
  • all the exposed fields in the receipt data can be compared with the keywords contained in the preset conditions to determine the exposed fields containing the keywords, as The exposed fields that meet the above preset conditions.
  • the preset condition may include a dedicated condition corresponding to each receipt field in the receipt data, that is, each receipt field in the receipt data has a corresponding preset condition, so that each determined exposed field is Used to compare with the corresponding preset conditions.
  • the preset conditions corresponding to different receipt fields are independent of each other, but may be the same or different.
  • the preset condition corresponding to the From field and the To field may be "whether the preset content is included", and the preset content may be a preset account address, indicating a transaction initiated by or directed to the account address. It is allowed to store the From field or To field in plain text (it can be stored in plain text when the From field or To field is an exposed field).
  • the preset condition corresponding to the Topic field can be "whether it belongs to the preset value range", and the value of the state variable referenced by the related event can be recorded in the Topic field.
  • it can include a value representing "transfer amount” State variable, indicating that the transfer amount is in the preset value range (usually the small value range corresponding to the smaller amount), the transfer amount is allowed to be stored in clear text (it can be stored in clear text when the Topic field is an exposed field) ).
  • the preset conditions may be located in the transaction, so that the preset conditions adopted by different exchanges may be different to meet the differences in demand faced by different exchanges; of course, different transactions may also use the same preset conditions.
  • the difference in the preset conditions can be expressed as: differences in at least one dimension in the content of the preset conditions, the receipt fields to which the preset conditions apply, and the processing logic for determining whether the exposed fields meet the preset conditions.
  • the preset condition may be located in the smart contract called by the transaction, or the preset condition may be located in another smart contract called by the smart contract called by the transaction, so that the transaction can be selected by selecting the called smart contract to Determine whether to use the corresponding preset conditions.
  • the smart contract can be pre-created by the transaction initiator or any other user; of course, if the smart contract has a corresponding calling condition, then the above-mentioned transaction can call the smart contract only when the calling condition is met.
  • the calling condition may include : The transaction initiator belongs to the preset whitelist, the transaction initiator does not belong to the preset blacklist or other conditions.
  • the preset condition may be located in the system contract or chain code, so that the preset condition is a global condition applicable to all transactions on the blockchain, and is different from the foregoing transaction or the preset contained in the smart contract.
  • Set conditions so that even if the smart contract invoked by the transaction or transaction does not contain preset conditions, the storage of the receipt field can be determined based on the preset conditions defined in the system contract or chain code and combined with the user type of the transaction initiator the way.
  • the two can contain preset conditions of different dimensions, such as preset conditions.
  • the applicable receipt fields are different; or, when there is a conflict between the preset conditions contained in the two, the preset conditions contained in the transaction or smart contract may be used by default, or the preset conditions contained in the chain code or system contract may be preferred.
  • Set conditions which depend on the predefined selection logic.
  • this specification can further identify the exposed identifier contained in the smart contract code and the user type of the transaction initiator, thereby simultaneously according to the exposed fields corresponding to the transaction type and the fields indicated by the exposed identifier And the user type of the transaction initiator determines the storage method of the receipt data. Therefore, the above step 208 can be improved to: the first blockchain node stores the receipt data, and when the transaction initiator belongs to the preset user type, the exposed field in the receipt data marked by the exposure identifier is changed to Stored in plain text, and the rest of the receipt fields are stored in cipher text.
  • the foregoing code example can be improved based on the user type of the transaction initiator.
  • the code example 2 above by adding the exposed identifier "plain" to the front of the smart contract code, all fields in the receipt data are allowed to be stored in plain text. Therefore, if the transaction initiator belongs to the preset user type, Then for the exposed fields corresponding to the transaction type of the transaction to which the smart contract belongs, after the code of the smart contract is executed, the corresponding receipt content in the generated receipt data will be stored in plain text, and subsequent retrieval operations can be performed on the receipt content ; For example, when the From field belongs to the above-mentioned exposed field, the From field can be used to count the transaction volume initiated by a certain account after being stored in plain text.
  • the above-mentioned exposure identifier plain corresponds to all the fields in the receipt data; in other embodiments, the fields that need to be stored in plain text can also be specified. For example, when annotating the From field with an exposed identifier, only the From field needs to be judged: when the From field is the above-mentioned exposed field, when the transaction initiator belongs to the preset user type, for the smart contract
  • the receipt data generated after the code is executed can store the contents of the receipt corresponding to the From field in plain text, and the contents of other receipts are stored in cipher text.
  • the fields (all fields or From fields) marked by the exposed identifier "plain" are contract-level fields, so that the first blockchain node is storing
  • the first blockchain node When receiving the receipt data, if the transaction initiator belongs to the preset user type and the From field is an exposed field, the first blockchain node will store all the receipt contents corresponding to the contract-level field in the receipt data in plain text.
  • the contract-level field can be applied to all events in the smart contract.
  • From field Take the From field as an example: when the transaction initiator belongs to the preset user type and the From field is the transaction type
  • 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 fields indicated by the exposure identifier may include: event-level fields corresponding to at least one event defined in the smart contract, so that when the first blockchain node stores the receipt data, if the transaction initiator belongs to the pre- Assuming that the user type and the event-level field belong to the exposed field corresponding to the transaction type, the receipt content corresponding to the at least one event in the receipt data can be determined, and the part of the determined receipt content corresponding to the above-mentioned event-level field can be in plaintext form storage.
  • the above event-level fields can be set for at least some of the events, so that the part of the receipt content corresponding to these events that corresponds to the event-level field is stored in plain text, and this part The remaining part of the receipt content corresponding to the event and the receipt content corresponding to the remaining events are stored in cipher text.
  • From field Take the From field as an example.
  • 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 by the character from is different
  • the character from is modified by quotation marks.
  • the quotation marks in code example 3 are equivalent to the aforementioned exposed identifier, so that the From field is marked as an event-level field. Therefore, when the transaction initiator belongs to the default user When the type and the From field belongs to the exposed field corresponding to the transaction type, the From field will be stored in plain text in the Logs field corresponding to the event. In addition to the aforementioned event currentPrice, if the code of the smart contract also contains another event, the aforementioned event-level field will not affect the other event, and the content of the receipt corresponding to the other event will be stored in ciphertext.
  • the event-level fields include all the fields in the log Logs corresponding to the event currentPrice For example, the aforementioned From field, To field, Topic field, Log Data field, etc., when the transaction initiator belongs to the preset user type, the exposed fields in these fields can be determined according to the transaction type, and the determined exposed fields are Stored in clear text.
  • the exposed identifier is a global identifier defined in the programming language of the smart contract, it is difficult to modify the fields marked by the exposed identifier as long as the exposed identifier is written in the smart contract. Therefore, by combining the consideration of user type and transaction type, it is possible to more accurately select the fields stored in plain text based on the user type of the transaction initiator and the exposed fields corresponding to the transaction type, rather than just based on the exposed identifier. Determined, so that when different users call the same smart contract or call the same smart contract through different types of transactions, the fields stored in plaintext are matched to the user type and transaction type, so that the storage method of receipt data can meet the actual needs in different situations , Can take into account privacy protection and function expansion.
  • this specification can further identify the exposure identifier contained in the code of the smart contract and the event function contained in the smart contract, so that at the same time, according to the exposed field corresponding to the transaction type, the exposure identifier marked Fields and special event functions included in the smart contract determine how to store receipt data. Therefore, the above step 208 can be improved as: the first blockchain node stores the receipt data, so that at least part of the receipt content in the log corresponding to the special event function is stored in plaintext, and the rest of the receipt data It is stored in a ciphertext form, and the at least a part of the receipt content includes an exposed field indicated by the exposure identifier.
  • the exposed identifier is a global identifier defined in the programming language of the smart contract and is applicable to all smart contracts written in this programming language. Therefore, by defining the exposure identifier in a programming language, so that the code of any smart contract uses the exposure identifier, the storage control of the receipt data can be realized. For example, when a user writes the code of a smart contract, he can add an exposed identifier to the code to indicate one or more fields to indicate that the user wants the receipt content corresponding to this part of the field in the receipt data to be stored in plain text, and the remaining The content of the receipt corresponding to the field marked with the exposed identifier is not allowed to be stored in plain text, but must be stored in cipher text to achieve corresponding privacy protection.
  • the corresponding receipt content is allowed to be stored in plain text; however, this manual can further consider the transaction type and the event function contained in the smart contract, and Comprehensive consideration is achieved from the dimensions of programming language, transaction type, and event function to determine whether to store the content of the receipt corresponding to the field indicated by the exposure identifier in plain text.
  • the aforementioned code example can be improved based on the event function contained in the smart contract.
  • the exposed identifier plain is added to the front of the code of the smart contract. From the perspective of the programming language, the exposed identifier plain indicates: the receipt data generated after the code of the smart contract is executed All fields in are allowed to be stored in plain text, so subsequent retrieval operations can be performed on the receipt content in these fields. For example, the From field can be used to count the transaction volume initiated by an account. By further combining dimensions such as transaction types and event functions, there may be differences in storage solutions for receipt data.
  • the exposed identifier can indicate one or more fields, and these fields have corresponding receipt content in the receipt data. Different types of transactions often have different privacy protection requirements, and the corresponding exposed fields can be allowed to be stored in plain text.
  • the receipt data contains a log corresponding to the special event function, which is actually part of the receipt content in the receipt data.
  • the cross content of the above three parts of receipt content can be filtered out, and the cross content can be stored in plain text.
  • the rest of the receipt data is in cipher text. storage.
  • the exposed identifier is a global identifier defined in the programming language of the smart contract, it is difficult to modify the fields marked by the exposed identifier as long as the exposed identifier is written in the smart contract.
  • the transaction type has nothing to do with the programming language and can be selected by the user according to the actual needs.
  • the definition of the special event function is not necessarily based on the programming language. For example, when recording the special event function based on the special event function list, even in the smart contract A certain event function included is originally a special event function.
  • a smart contract can include the following code example 5:
  • the exposed identifier "plain” is located at the forefront of the code of the smart contract, so that all fields in the receipt data are marked as contract-level fields; at the same time, in the smart contract Contains events currentPrice1 and event currentPrice2: Assuming that the From field is the exposed field corresponding to the transaction type, and the event currentPrice1 corresponds to the special event function defined in the special event function list, and the event currentPrice2 corresponds to the normal event function, then in the event currentPrice1 and event currentPrice2 In the generated logs Log1 and Log2, the From field contained in log Log1 is stored in plain text, and the From field contained in log Log2 is stored in cipher text; similarly, other fields in log Log1 that are exposed fields are also stored in plain text.
  • Non-exposed fields are stored in cipher text, and all fields of log Log2 are stored in cipher text. Moreover, if the event currentPrice2 is updated to correspond to the special event function by updating the list of special event functions, all the fields that belong to the exposed fields contained in the log Log2 will be stored in plain text, without the need to do anything to the smart contract code change.
  • the aforementioned type identifier can be used to indicate whether the event function included in the smart contract is a special event function.
  • the above code sample 5 can be adjusted to the following code sample 6:
  • the contract-level fields include all fields in the receipt data; at the same time, the smart contract contains the event currentPrice1 and the event currentPrice2: because the event currentPrice1 contains the above mentioned
  • the type identifier expose causes the event currentPrice1 to be marked as corresponding to the special event function, while the event currentPrice2 does not contain the type identifier expose, so that the event currentPrice2 is marked as corresponding to the normal event function, then the event currentPrice1 and event currentPrice2 are generated respectively In the logs Log1 and Log2, all the exposed fields corresponding to the transaction type in the log Log1 are stored in plain text, and all the fields contained in the log Log2 are stored in cipher text.
  • the type identifier and the exposed identifier are similar, they are both global identifiers defined in the programming language of the smart contract, but the exposed identifier acts on the contract-level fields and the type identifier acts on the event function, so that by In conjunction with the type identifier, you only need to add a single exposure identifier to set the contract-level fields mentioned above, and then you can flexibly mark the event functions that you want to store the contract-level fields in plaintext, especially when smart contracts When there are a large number of event functions included in the event function and the number of fields involved in the event function is large, you only need to add a "plain" similar to the above. There is no need to implement settings for each event function separately, which can simplify the code logic , Prevent mislabeling or missing labels.
  • the fields marked by the exposure identifier may include: event-level fields corresponding to at least one event defined in the smart contract, so that the first blockchain node can determine the at least one event when storing the receipt data.
  • a log generated by a special event function corresponding to an event, and the determined exposed fields belonging to the event-level field in the log are stored in plain text.
  • the above event-level fields can be set for at least some of the events, so that the exposed fields belonging to the event-level fields in the logs corresponding to these events are stored in plain text, and this part of the events Other fields in the corresponding log and the contents of receipts corresponding to other events are stored in cipher text.
  • the event currentPrice1 does not add the exposed identifier "plain", it contains the content "from".
  • the content "from” corresponds to the From field and is used to indicate the From field in the log generated by the event currentPrice1 It needs to be stored in plain text, so the content "from” not only belongs to the above exposed identifier, but also indicates the From field that needs to be stored in plain text.
  • the From field is an event-level field, so that when the From field is an exposed field corresponding to the transaction type and the event currentPrice1 corresponds to a special event function, the log generated in the event currentPrice1 corresponds to In Logs, the From field will be stored in plain text, and other fields will be stored in cipher text.
  • the other event currentPrice2 contained in code example 7 since no exposure identifier is added for the event currentPrice2, regardless of whether the event currentPrice2 corresponds to a special event function or a normal event function, the generated log Logs are in ciphertext form storage.
  • From indicates that the From field is set as an event-level field; however, in other embodiments, the specific field may not be specified.
  • code example 6 can be adjusted to the following code example 8:
  • all the fields in the log generated by the event currentPrice1 can be used as the aforementioned event-level fields, such as the aforementioned From field and To field. , Topic field, Log Data field, etc.
  • the event currentPrice1 corresponds to a special event function
  • the log field that belongs to both the above event-level field and the exposed field corresponding to the transaction type can be determined from the log generated by the event currentPrice1, and stored in plain text; If the above-mentioned From field, To field, Topic field, Log Data field, etc. are all exposed fields, it is equivalent to storing all receipt content (such as the generated log) corresponding to the event currentPrice1 in plain text.
  • whether the event function contained in the smart contract is a special event function can be identified by means of a special event function list or type identifier. Do not repeat them one by one.
  • this specification can further identify the exposure identifier contained in the smart contract code and the receipt content in the receipt data that meets the preset conditions, thereby simultaneously according to the exposure field and exposure identifier corresponding to the transaction type
  • the fields marked by the symbol and the content of the receipt meet the preset conditions and determine the storage method of the receipt data. Therefore, the above step 208 can be improved to: the first blockchain node stores the receipt data, so that the exposed fields in the receipt data that are marked by the exposure identifier and meet the preset conditions are stored in plain text, and the remaining receipts The fields are stored in cipher text.
  • the foregoing code example can be improved based on the receipt content that meets the preset conditions in the receipt data.
  • the above code example 2 by adding the exposing identifier plain to the front of the smart contract code, after the smart contract code is executed, for the exposed fields corresponding to the transaction type of the smart contract to which the transaction belongs, the generated receipt data The contents of the receipt corresponding to the above exposed fields and meeting the preset conditions are all stored in plain text.
  • the fields that need to be stored in plaintext can also be specified.
  • the From field when annotating the From field with an exposed identifier, only the From field can be judged: if the From field is the exposed field corresponding to the transaction type of the transaction to which the smart contract belongs, then after the code of the smart contract is executed, it will be generated
  • the content of the receipt corresponding to the From field that meets the preset conditions in the receipt data is stored in plain text, and subsequent retrieval operations can be performed on the content of the receipt in the From field stored in plain text, for example, the transaction volume initiated by a certain account can be counted And so on; except for the other fields before the From field, they are all stored in cipher text.
  • the fields (all fields or From fields) marked by the exposed identifier "plain" are contract-level fields, so that the first blockchain node is storing
  • the contract-level field is an exposed field
  • the first blockchain node will store all the receipt contents in the receipt data that correspond to the contract-level field and meet the preset conditions in plain text.
  • the contract-level field can be applied to all events in the smart contract.
  • From field Take the From field as an example: when the From field is a contract-level field and the exposed field corresponding to the transaction type For multiple events to generate their corresponding Logs fields, the From field contained in each Logs field can be compared with preset conditions, so that the From field that meets the preset conditions is stored in plain text without Add an exposure identifier for each event.
  • the fields indicated by the exposure identifier may include: event-level fields corresponding to at least one event defined in the smart contract, so that when the first blockchain node stores the receipt data, if the event-level field belongs to the transaction
  • the exposed field corresponding to the type can determine the receipt content corresponding to the at least one event in the receipt data, and store the determined part of the receipt content corresponding to the event-level field and meeting preset conditions in plain text.
  • the above event-level fields can be set for at least some of the events, so that the part of the receipt content corresponding to these events that corresponds to the event-level field and meets the preset conditions is in plain text Store, and the remaining part of the receipt content corresponding to this part of the event and the receipt content corresponding to the remaining events are stored in cipher text.
  • the From field Take the From field as an example.
  • 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 by the character from is different
  • the character from is modified by quotation marks.
  • the quotation marks in code example 3 are equivalent to the aforementioned exposure identifier, and the From field is configured as an event-level field, so that when the From field belongs to the exposure corresponding to the transaction type In the Logs field corresponding to the event, the From field can be stored in plain text when the preset conditions are met, otherwise the From field will still be stored in cipher text.
  • the code of the smart contract also contains another event, then the above “from” will not affect the other event, and the receipt content corresponding to the other event will be stored in ciphertext unless it exists "From" added for this other event.
  • the exposure identifier "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 example 3, so that It is not specified that the event-level field is the From field, so all fields in the log generated by the event currentPrice can be used as the above-mentioned event-level fields, such as the aforementioned From field, To field, Topic field, Log Data field, etc.
  • this specification can further identify the user type of the transaction initiator and the event function contained in the smart contract, thereby simultaneously according to the exposed fields corresponding to the transaction type, the user type of the transaction initiator, and the smart contract
  • the special event function included determines the storage method of the receipt data. Therefore, the above step 208 can be improved as: the first blockchain node stores the receipt data, and when the transaction initiator belongs to the preset user type, the exposed field in the log corresponding to the special event function is made in plain text The remaining content of the receipt data is stored in cipher text.
  • the exposed fields that allow plaintext storage can be determined according to the differentiated needs of different types of transactions for privacy protection; further, the needs of different types of users for privacy protection It is not the same.
  • the transaction initiator belongs to the preset user type, it is allowed to trigger the DAPP client to implement related follow-up operations by exposing part of the receipt content to improve convenience, while other types of users may not be allowed to expose private information;
  • there are still differentiated privacy protection requirements in different scenarios which can be reflected in the storage process according to the type of event function contained in the smart contract called by the transaction
  • Different types of event functions have differentiated requirements for privacy protection.
  • the exposed fields involved in special event functions are stored in plain text, while the non-exposed fields involved in special event functions and all receipt fields involved in common event functions are all stored in Stored in ciphertext form, with high flexibility.
  • this specification can further identify the user type of the transaction initiator and the receipt content in the receipt data that meets the preset conditions, thereby simultaneously according to the exposed fields corresponding to the transaction type and the user type of the transaction initiator And the content of the receipt to meet the preset conditions, determine the storage method of the receipt data. Therefore, the above step 208 can be improved as follows: the first blockchain node stores the receipt data, and when the transaction initiator belongs to the preset user type, the exposed fields in the receipt data that meet the preset conditions are stored in plain text, The remaining receipt fields are stored in cipher text.
  • the exposed fields that allow plaintext storage can be determined according to the differentiated needs of different types of transactions for privacy protection; further, the needs of different types of users for privacy protection It is not the same.
  • the transaction initiator belongs to the preset user type
  • it is allowed to trigger the DAPP client to implement related follow-up operations by exposing part of the receipt content to improve convenience, while other types of users may not be allowed to expose private information;
  • the privacy protection requirements can be reflected in the storage process according to the satisfaction of the preset conditions by the exposed fields.
  • Differentiated requirements and processing for protection for example: By comparing the exposed fields in the receipt data with preset conditions, the exposed fields that meet the preset conditions can be stored in plain text, and the exposed fields that do not meet the preset conditions or other The receipt field must be stored in ciphertext.
  • this specification can further identify the event function contained in the smart contract and the receipt content in the receipt data that meets the preset conditions, so as to at the same time according to the exposed fields corresponding to the transaction type and the content contained in the smart contract.
  • the special event function and the content of the receipt satisfy the preset conditions and determine the storage method of the receipt data. Therefore, the above step 208 can be improved as: the first blockchain node stores the receipt data, so that the exposed fields in the log corresponding to the special event function that meet the preset conditions are stored in plaintext, and the receipt data The rest of the content is stored in cipher text.
  • the exposed fields allowed to be stored in plaintext can be determined according to the differentiated requirements of different types of transactions for privacy protection; further, because different event functions often involve different information , So that different event functions correspond to different privacy protection requirements.
  • the privacy protection requirements of event functions related to the transfer amount are relatively high, and the privacy protection requirements of event functions related to evidence are relatively low (here only for example ;
  • the privacy protection requirement of the related event function may also be relatively low, and when the deposit content is more important, the privacy protection requirement of the related event function may also be relatively high
  • the event function with relatively low privacy protection requirements can be configured as the above special event function, and when the above exposed field is included in the log generated by the special event function, the receipt content corresponding to the exposed field is allowed to be exposed; furthermore, even For the exposed fields in the logs generated by the special event function, there are still differentiated privacy protection requirements in different scenarios.
  • the difference in privacy protection can be reflected in the storage process according to the satisfaction of the preset conditions by the exposed fields Modification requirements and processing:
  • the exposed fields that meet the preset conditions can be stored in plaintext, while the exposed fields or other receipt fields that do not meet the preset conditions are inevitable Stored in cipher text.
  • a special event function involves a deposit operation
  • the exposed field can be Store in plain text, otherwise store in cipher text.
  • this specification can further identify the user type of the transaction initiator, the event function contained in the smart contract, and the receipt content that meets the preset conditions in the receipt data, thereby simultaneously revealing the corresponding exposure according to the transaction type Fields, the user type of the transaction initiator, the special event functions contained in the smart contract, and the satisfaction of the receipt content to the preset conditions determine the storage method of the receipt data. Therefore, the above step 208 can be improved to: the first blockchain node stores the receipt data, and when the transaction initiator belongs to the preset user type, the log corresponding to the special event function is exposed to the preset condition.
  • the fields are stored in plain text, and the rest of the receipt data is stored in cipher text.
  • the exposed fields allowed to be stored in plaintext can be determined according to the differentiated requirements of different types of transactions for privacy protection; further, because different event functions often involve different information , So that different event functions correspond to different privacy protection requirements.
  • the privacy protection requirements of event functions related to the transfer amount are relatively high, and the privacy protection requirements of event functions related to evidence are relatively low (here only for example ;
  • the privacy protection requirement of the related event function may also be relatively low, and when the deposit content is more important, the privacy protection requirement of the related event function may also be relatively high
  • the event function with relatively low privacy protection requirements can be configured as the above special event function, and when the above exposed field is included in the log generated by the special event function, the receipt content corresponding to the exposed field is allowed to be exposed; furthermore, even For the exposed fields in the logs generated by the special event function, there are still differentiated privacy protection requirements in different scenarios.
  • the difference in privacy protection can be reflected in the storage process according to the satisfaction of the preset conditions by the exposed fields Modification requirements and processing:
  • the exposed fields that meet the preset conditions can be stored in plaintext, while the exposed fields or other receipt fields that do not meet the preset conditions are inevitable Stored in cipher text.
  • a special event function involves a deposit operation
  • the exposed field can be Store in plain text, otherwise store in cipher text.
  • this specification can further identify the exposure identifier contained in the code of the smart contract, the user type of the transaction initiator, and the event function contained in the smart contract, thereby simultaneously corresponding exposure according to the transaction type
  • the fields, the fields indicated by the exposed identifier, the user type of the transaction initiator, and the special event function contained in the smart contract determine the storage method of the receipt data.
  • the above step 208 can be improved to: the first blockchain node stores the receipt data so that when the transaction initiator belongs to the preset user type, at least part of the receipt content in the log corresponding to the special event function It is stored in plain text, and the rest of the receipt data is stored in cipher text, and the at least a part of the receipt content matches the exposed field indicated by the exposure identifier.
  • This manual exposes the content of the receipt to a certain extent to realize the driver of the DAPP client or other function extensions.
  • this manual comprehensively considers the user type of the transaction initiator, the exposed field corresponding to the transaction type, the field indicated by the exposure identifier, and the log generated by the special event function, and can accurately select the receipt content for plaintext storage, that is, simultaneously satisfy Receipt content of "transaction initiator belongs to the preset user type", “belongs to the exposed field corresponding to the transaction type”, “matches the field indicated by the exposure identifier” and “belongs to the log generated by the special event function", thus satisfying the above functions While expanding the demand, ensure that the privacy of most users can be protected.
  • the first blockchain node when it recognizes the special event function based on the information recorded on the blockchain network (such as the list of special event functions), it can perform the "special event function" after the smart contract has been created.
  • Update to adjust the storage method of receipt data such as changing the original receipt content stored in plain text to cipher text storage, or changing the original receipt content stored in cipher text to plain text storage.
  • the foregoing code example can be improved based on the user type of the transaction initiator and the event function contained in the smart contract.
  • the exposed identifier plain is added to the front of the smart contract code, so that after the smart contract code is executed, when the transaction initiator belongs to the preset user type, the receipt data is generated by the special event function
  • the log of the smart contract allows the contents of the receipt corresponding to the exposed field corresponding to the transaction type of the transaction to which the smart contract belongs to be stored in clear text.
  • the From field in the log is an exposed field and the To field is not an exposed field
  • the receipt data can be stored
  • the From field of all logs in the log is stored in plain text, and the To field is stored in cipher text. Then, subsequent retrieval operations can be performed on the receipt content in the From field, for example, the transaction volume initiated by an account can be counted.
  • the exposed identifier is a global identifier defined in the programming language of the smart contract, it is difficult to modify the fields marked by the exposed identifier as long as the exposed identifier is written in the smart contract.
  • the user type depends on the transaction initiator and has nothing to do with the programming language, so that even when different transaction initiators call the same smart contract, the storage method (ciphertext or plaintext) of the receipt data may be different.
  • the transaction type can also be selected by the transaction initiator according to demand to indicate the actual needs of the transaction initiator.
  • the definition of special event functions is not necessarily based on programming languages.
  • the From field When the From field is further an exposed field corresponding to the transaction type, it can be preset at the transaction initiator In the case of the user type, when the first blockchain node stores the receipt data, all the receipt contents corresponding to the From field in the receipt data are allowed to be stored in plain text.
  • a smart contract can include the following code example 9:
  • the exposed identifier "plain" is located at the forefront of the smart contract code, so that all fields in the receipt data are marked as contract-level fields; at the same time, in the smart contract Contains the event currentPrice1 and the event currentPrice2: assuming that the event currentPrice1 corresponds to the special event function defined in the special event function list, and the event currentPrice2 corresponds to the normal event function, then the transaction initiator belongs to the preset user type and the From field is an exposed field.
  • the From field contained in the log Log1 is stored in plain text
  • the From field contained in the log Log2 is stored in cipher text; similarly, the log Log1 belongs to the exposed field.
  • Other fields are also stored in plain text, non-exposed fields are stored in cipher text, and all fields of log Log2 are stored in cipher text.
  • the event currentPrice2 is updated to correspond to the special event function by updating the list of special event functions, all the fields that belong to the exposed fields contained in the log Log2 will be stored in plain text, without the need to do anything to the smart contract code change.
  • the aforementioned type identifier can be used to indicate whether the event function included in the smart contract is a special event function.
  • the above code sample 9 can be adjusted to the following code sample 10:
  • the contract-level fields include all the fields in the receipt data; at the same time, the smart contract contains the event currentPrice1 and the event currentPrice2: because the event currentPrice1 contains the aforementioned The type identifier expose, so that the event currentPrice1 is marked as corresponding to the special event function, and the event currentPrice2 does not contain the type identifier expose, so that the event currentPrice2 is marked as corresponding to the normal event function, then the transaction initiator belongs to the default user In the case of type, in the logs Log1 and Log2 respectively generated by the event currentPrice1 and the event currentPrice2, all the exposed fields corresponding to the transaction type in the log Log1 are stored in plain text, and all the fields contained in the log Log2 are stored in cipher text.
  • the fields indicated by the exposure identifier may include: event-level fields corresponding to at least one event defined in the smart contract, so that the transaction initiator belongs to the preset user type and the event-level field belongs to the exposed field
  • the first blockchain node stores the part of the receipt content generated by the special event function that corresponds to the event-level field in plain text.
  • the above event-level fields can be set for at least some of the events, so that the contents of the receipts corresponding to the above-mentioned event-level fields in the logs generated by these events are stored in plain text, and this The content of the remaining receipts in the log generated by some events and the content of the receipts corresponding to the remaining events are stored in ciphertext.
  • the above code sample 10 can be adjusted to the following code sample 11:
  • the event currentPrice1 does not add the exposed identifier "plain", it contains the content "from".
  • the content "from” corresponds to the From field and is used to indicate the From field in the log generated by the event currentPrice1 It needs to be stored in plain text, so the content "from” not only belongs to the above exposed identifier, but also indicates the From field that needs to be stored in plain text.
  • the From field is an event-level field, so that when the transaction initiator belongs to the preset user type and the From field is an exposed field, when the event currentPrice1 corresponds to a special event function
  • the From field will be stored in plain text, and other fields will be stored in cipher text.
  • the other event currentPrice2 contained in code example 11 since no exposure identifier is added for the event currentPrice2, regardless of whether the event currentPrice2 corresponds to a special event function or a normal event function, the generated log Logs are in ciphertext form storage. In the embodiment corresponding to this code example 11, that is, for event-level fields, it is possible to identify whether the event functions contained in the smart contract are special event functions by means of a special event function list or type identifier. Repeat.
  • this specification can further identify the exposure identifier contained in the smart contract code, the user type of the transaction initiator, and the receipt content that meets the preset conditions in the receipt data, thereby simultaneously according to the transaction type
  • the corresponding exposure field, the field indicated by the exposure identifier, the user type of the transaction initiator, and the content of the receipt meet the preset conditions, and the storage method of the receipt data is determined. Therefore, the above step 208 can be improved to: the first blockchain node stores the receipt data, and when the transaction initiator belongs to the preset user type, the receipt data is marked by the exposure identifier and meets the preset requirements.
  • the exposed fields of the conditions are stored in plain text, and the remaining receipt fields are stored in cipher text.
  • the exposed identifier is a global identifier defined in the programming language of the smart contract, it is difficult to modify the fields marked by the exposed identifier as long as the exposed identifier is written in the smart contract. Therefore, by combining the consideration of user types, transaction types, and preset conditions, it is possible to more accurately select and use plain text based on the user type of the transaction initiator, the exposure field corresponding to the transaction type, and the satisfaction of the preset conditions by the content of the receipt.
  • the fields stored in the form are not only determined based on the exposed identifier, so that when different users call the same smart contract, or call the same smart contract through different types of transactions, or use differentiated preset conditions, the plaintext stored
  • the fields are matched with user types, transaction types and preset conditions, so that the storage method of receipt data can meet the actual needs in different situations, and can take into account privacy protection and function expansion. It can be seen that by exposing the content of the receipt to a certain extent, this manual can be used to drive the DAPP client or expand other functions. In addition, this manual can accurately select the fields for plaintext storage by comprehensively considering the fields indicated by the exposure identifier, the exposed fields corresponding to the transaction type, the user type of the transaction initiator and the content of the receipt to meet the preset conditions. At the same time, it satisfies the fields of "indicated by the exposed identifier", "matched to the transaction type” and "satisfy the preset conditions", so as to meet the above functional expansion requirements while ensuring that most user privacy can
  • the foregoing code example can be improved based on the user type of the transaction initiator and the receipt content that meets the preset conditions in the receipt data.
  • the above code example 2 by adding the exposed identifier plain to the front of the smart contract code, after the smart contract code is executed, when the transaction initiator belongs to the preset user type, the transaction to which the smart contract belongs.
  • the exposed fields corresponding to the transaction types of the generated receipt data corresponding to the above exposed fields and meeting the preset conditions are stored in plain text.
  • the fields that need to be stored in plaintext can also be specified.
  • the fields (all fields or From fields) marked by the exposed identifier "plain" are contract-level fields, so that the first blockchain node is storing
  • the first blockchain node will use all the receipt contents in the receipt data that correspond to the contract-level field and meet the preset conditions with Stored in clear text.
  • the contract-level field can be applied to all events in the smart contract.
  • From field Take the From field as an example: when the transaction initiator belongs to the preset user type, the From field is at the contract level When the fields and the exposed fields corresponding to the transaction type are generated, the Logs fields corresponding to multiple events are generated separately, and the From field contained in each Logs field will be stored in plain text, without the need to add exposure identifiers for each event. symbol.
  • the fields indicated by the exposure identifier may include: event-level fields corresponding to at least one event defined in the smart contract, so that when the first blockchain node stores the receipt data, if the transaction initiator belongs to the pre- Assuming that the user type and the event-level field belong to the exposed field corresponding to the transaction type, the log corresponding to the at least one event in the receipt data can be determined, and the content of the receipt corresponding to the event-level field in the determined log and the preset conditions The comparison is performed so that the content of the receipt meeting the preset condition is stored in plain text.
  • the above event-level fields can be set for at least some of the events, so that the part of the receipt content corresponding to these events that corresponds to the event-level field and meets the preset conditions is in plain text Store, and the remaining part of the receipt content corresponding to this part of the event and the receipt content corresponding to the remaining events are stored in cipher text.
  • the From field Take the From field as an example.
  • 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 by the character from is different
  • the character from is modified by quotation marks.
  • the quotation marks in Code Example 3 are equivalent to the aforementioned exposed identifier.
  • the From field is configured as an event-level field, so that the From field is marked as an event-level field. Therefore, when the transaction initiator belongs to the preset user type and the From field belongs to the exposed field corresponding to the transaction type, in the Logs field corresponding to the event, the From field will be stored in plain text when the preset conditions are met.
  • the aforementioned event currentPrice if the code of the smart contract also contains another event, the aforementioned "from" will not affect the other event, and the content of the receipt corresponding to the other event will be stored in ciphertext.
  • the event-level fields include all the fields in the log Logs corresponding to the event currentPrice.
  • the aforementioned From field, To field, Topic field, Log Data field, etc. when the transaction initiator belongs to the preset user type, the exposed fields in these fields can be determined according to the transaction type, and the determined exposed fields are compared with the preset user types. Set conditions for comparison, so that the exposed fields that meet the preset conditions are stored in plain text. Therefore, if the aforementioned From field, To field, Topic field, Log Data field, etc. all meet the preset conditions, it is equivalent to storing all the contents of the receipt generated by the event currentPrice in plain text.
  • this specification can further identify the exposure identifier contained in the code of the smart contract, the event function contained in the smart contract, and the content of the receipt meeting preset conditions in the receipt data, so as to be based on the transaction at the same time.
  • the exposure field corresponding to the type, the field indicated by the exposure identifier, the special event function contained in the smart contract, and the satisfaction of the preset conditions by the receipt content determine the storage method of the receipt data.
  • the above step 208 can be improved as: the first blockchain node stores the receipt data, so that at least part of the receipt content in the log corresponding to the special event function is stored in plaintext, and the rest of the receipt data It is stored in a ciphertext form, and the at least a part of the receipt content includes exposed fields that are marked by the exposure identifier and meet a preset condition.
  • the foregoing code example can be improved based on the event function contained in the smart contract and the receipt content that meets the preset conditions in the receipt data.
  • the exposed identifier plain is added to the front of the code of the smart contract. From the perspective of the programming language, the exposed identifier plain indicates that after the code of the smart contract is executed, the generated receipt data All fields of are allowed to be stored in plain text, so subsequent retrieval operations can be performed on the receipt content in these fields. For example, for the From field, it can be used to count the transaction volume initiated by an account. By further combining dimensions such as transaction type, event function, and preset conditions, the storage scheme for receipt data may be different.
  • the From field in the receipt data may not all be stored in plain text, but the event currentPrice
  • the From field in the log generated by the event currentPrice is stored in plain text, otherwise it is stored in cipher text.
  • the exposed fields in the log corresponding to the event currentPrice can be stored in plain text without the need to adjust the code example 2; for example, when the From field and the To field To expose fields, the From field and To field in the log generated by the event currentPrice will be stored in plain text, while the remaining fields will be stored in cipher text.
  • the fields marked by the exposed identifier "plain” are all fields in the receipt data, and these fields are contract-level fields . So that when the first blockchain node stores the receipt data, all the receipt contents corresponding to the contract-level field in the receipt data are allowed to be stored in plain text.
  • the From field is marked with the exposed identifier in Code Example 2, then the From field is the contract-level field mentioned above.
  • the From field is further an exposed field corresponding to the transaction type, the first blockchain node can be used When storing receipt data, all the receipt contents corresponding to the From field and meeting preset conditions in the receipt data are allowed to be stored in plain text.
  • the code of a smart contract contains multiple event functions
  • the exposed identifier "plain" is located at the forefront of the smart contract code, so that all fields in the receipt data are marked as contract-level fields; at the same time, smart The contract contains the event currentPrice1 and event currentPrice2: Assume that the From field is the exposed field corresponding to the transaction type, and the event currentPrice1 corresponds to the special event function defined in the special event function list, and the event currentPrice2 corresponds to the normal event function.
  • the From field contained in log Log1 is stored in plain text when the preset conditions are met, and the From field contained in log Log2 is stored in cipher text; similarly, the exposed fields in log Log1 Other fields are also stored in plain text, non-exposed fields are stored in cipher text, and all fields of log Log2 are stored in cipher text.
  • the event currentPrice2 is updated to correspond to the special event function after the special event function list is updated, then all the fields contained in the log Log2 that belong to the exposed fields and meet the preset conditions will be stored in plain text, without the need for smart Make any changes to the contract code.
  • the aforementioned type identifier can be used to indicate whether the event function included in the smart contract is a special event function.
  • the contract-level fields include all fields in the receipt data; at the same time, the smart contract contains the event currentPrice1 and the event currentPrice2: because the event currentPrice1 contains the same as before
  • the type identifier expose mentioned above makes the event currentPrice1 be marked as corresponding to the special event function, while the event currentPrice2 does not contain the type identifier expose, so that the event currentPrice2 is marked as corresponding to the normal event function, then the event currentPrice1 and event currentPrice2 In the generated logs Log1 and Log2, all the exposed fields corresponding to the transaction type in the log Log1 are stored in plain text when the preset conditions are met, and all the fields contained in the log Log2 must be stored in cipher text.
  • the fields marked by the exposure identifier may include: event-level fields corresponding to at least one event defined in the smart contract, so that the first blockchain node can determine the at least one event when storing the receipt data.
  • a log generated by a special event function corresponding to an event, and the determined exposed fields belonging to event-level fields and meeting preset conditions in the determined log are stored in plain text.
  • the above event-level fields can be set for at least some of the events, so that the exposed fields that belong to the event-level fields and meet the preset conditions in the logs corresponding to this part of the events are stored in plain text , And other fields in the log corresponding to this part of the event, and the content of the receipt corresponding to the remaining events are stored in cipher text.
  • the From field Take the From field as an example.
  • the event currentPrice1 does not add the exposed identifier "plain", it contains the content "from”.
  • the content "from” corresponds to the From field and is used to indicate the event currentPrice1.
  • the From field in the generated log needs to be stored in plain text, so the content "from” not only belongs to the above exposed identifier, but also indicates the From field that needs to be stored in plain text. Moreover, since the content "from" is in the event currentPrice1, the From field is an event-level field, so that when the From field is an exposed field corresponding to the transaction type and the event currentPrice1 corresponds to a special event function, the log generated in the event currentPrice1 corresponds to In Logs, the From field will be stored in plain text when the preset conditions are met, and in cipher text when the preset conditions are not met, and other fields must be stored in cipher text.
  • the above keyword "from” indicates that the From field is set as an event-level field; however, in other embodiments, the specific field may not be specified.
  • the above code example 8 by adding the exposure identifier "plain" before the event currentPrice1, all the fields in the log generated by the event currentPrice1 can be used as the aforementioned event-level fields, such as the aforementioned From field, To field, Topic field, Log Data field, etc.
  • the event currentPrice1 corresponds to a special event function
  • the fields meet the preset conditions, they are stored in plain text; if the above-mentioned From field, To field, Topic field, Log Data field, etc. are all exposed fields and meet the preset conditions, then it is equivalent to the content of all receipts corresponding to the event currentPrice1 ( For example, the generated logs are stored in plain text.
  • this specification can further identify the exposure identifier contained in the code of the smart contract, the user type of the transaction initiator, the event function contained in the smart contract, and the receipt data that meet the preset conditions. Receipt content, so as to determine the receipt data at the same time according to the exposed fields corresponding to the transaction type, the fields indicated by the exposed identifier, the user type of the transaction initiator, the special event function included in the smart contract, and the satisfaction of the receipt content to the preset conditions Storage method.
  • the above step 208 can be improved to: the first blockchain node stores the receipt data so that when the transaction initiator belongs to the preset user type, at least part of the receipt content in the log corresponding to the special event function Stored in plain text, and the remaining content of the receipt data is stored in cipher text, and the at least part of the receipt content matches the exposure field indicated by the exposure identifier and meets a preset condition.
  • This manual exposes the content of the receipt to a certain extent to realize the driver of the DAPP client or other function extensions.
  • this manual considers the user type of the transaction initiator, the exposed field corresponding to the transaction type, the field indicated by the exposure identifier, the log generated by the special event function, and the content of the receipt to meet the preset conditions, and can accurately select the application.
  • the content of the receipt stored in plaintext meets the requirements of "transaction initiator belongs to the preset user type", “belongs to the exposed field corresponding to the transaction type”, “matches the field indicated by the exposure identifier”, and “belongs to the log generated by the special event function” "” and “meeting the preset conditions”, so as to meet the above-mentioned function expansion requirements, while ensuring that most of the user privacy can be protected.
  • the first blockchain node when it recognizes the special event function based on the information recorded on the blockchain network (such as the list of special event functions), it can perform the "special event function" after the smart contract has been created.
  • Update to adjust the storage method of receipt data such as changing the original receipt content stored in plain text to cipher text storage, or changing the original receipt content stored in cipher text to plain text storage.
  • the foregoing code example can be improved based on the user type of the transaction initiator, the event function contained in the smart contract, and the receipt content that meets the preset conditions in the receipt data.
  • the exposed identifier plain is added to the front of the smart contract code, so that after the smart contract code is executed, when the transaction initiator belongs to the preset user type, the receipt data is generated by the special event function
  • the log allows the exposed field corresponding to the transaction type of the transaction to which the smart contract belongs and the content of the receipt meeting preset conditions is stored in clear text.
  • the From field of all logs in the receipt data can be stored in plain text when the preset conditions are met, and the To field is stored in cipher text. Then, subsequent retrieval operations can be performed on the receipt content in the From field, for example, a certain account can be counted The volume of transactions initiated, etc.
  • the exposed identifier is a global identifier defined in the programming language of the smart contract, it is difficult to modify the fields marked by the exposed identifier as long as the exposed identifier is written in the smart contract.
  • the user type depends on the transaction initiator and has nothing to do with the programming language, so that even when different transaction initiators call the same smart contract, the storage method (ciphertext or plaintext) of the receipt data may be different.
  • the transaction type can also be selected by the transaction initiator according to demand to indicate the actual needs of the transaction initiator.
  • the preset conditions can be selected by the transaction initiator according to actual needs, regardless of the programming language. At the same time, the definition of special event functions is not necessarily based on programming languages.
  • the From field When the From field is further an exposed field corresponding to the transaction type, it can be preset at the transaction initiator In the case of the user type, when the first blockchain node stores receipt data, all receipt content in the receipt data that corresponds to the From field and meets the preset conditions is allowed to be stored in plain text.
  • the code of the smart contract contains multiple event functions
  • the respective Logs fields generated by the multiple event functions there may be the receipt content corresponding to the contract-level field;
  • the transaction can be identified by The user type to which the initiator belongs, the exposed fields corresponding to the transaction type of the transaction, the type of each event function is ordinary event function or special event function, and the content of the receipt meets the preset conditions, so that the transaction initiator belongs to the preset user type
  • the contract-level field is an exposed field, the contents of the receipt corresponding to the contract-level field and satisfying the preset conditions in the logs generated by all special event functions are stored in plain text.
  • the exposed identifier "plain" is located at the forefront of the smart contract code, so that all fields in the receipt data are marked as contract-level fields; at the same time, smart The contract contains the event currentPrice1 and the event currentPrice2: assuming that the event currentPrice1 corresponds to the special event function defined in the special event function list, and the event currentPrice2 corresponds to the normal event function, then the transaction initiator belongs to the preset user type and the From field is an exposed field
  • the From field contained in the log Log1 is stored in plain text when the preset conditions are met, and in cipher text when the preset conditions are not met
  • the From field contained in log Log2 must be stored in cipher text; similarly, other fields in log Log1 that are exposed fields are also stored in plain text when the preset conditions are met, and non-exposed fields are stored in cipher text.
  • All the fields of the log Log2 are stored in cipher text. Moreover, if the event currentPrice2 is updated to correspond to the special event function after updating the list of special event functions, all the fields belonging to the exposed fields contained in the log Log2 can be stored in plain text under the condition that the preset conditions are met. If the preset conditions are not met, it is stored in ciphertext form, without any changes to the code of the smart contract.
  • the aforementioned type identifier can be used to indicate whether the event function included in the smart contract is a special event function.
  • the contract-level fields include all fields in the receipt data; at the same time, the smart contract contains the event currentPrice1 and the event currentPrice2: because the event currentPrice1 contains the same as before
  • the type identifier expose mentioned above makes the event currentPrice1 be marked as corresponding to the special event function, and the event currentPrice2 does not contain the type identifier expose, so that the event currentPrice2 is marked as corresponding to the normal event function, then the event currentPrice2 is marked as corresponding to the normal event function.
  • the fields indicated by the exposure identifier may include: event-level fields corresponding to at least one event defined in the smart contract, so that the transaction initiator belongs to the preset user type and the event-level field belongs to the exposed field
  • the first blockchain node stores the part of the receipt content generated by the special event function that corresponds to the event-level field and meets the preset condition in plain text.
  • the above event-level fields can be set for at least some of the events, so that the contents of the receipts that correspond to the above-mentioned event-level fields and meet the preset conditions in the logs generated by this part of the events are in plain text
  • the content of the remaining receipts in the log generated by this part of the event and the content of the receipt corresponding to the remaining events are stored in the form of ciphertext. Take the From field as an example.
  • the event currentPrice1 does not add the exposed identifier "plain", it contains the content "from”.
  • the content "from” corresponds to the From field and is used to indicate the event currentPrice1.
  • the From field in the generated log needs to be stored in plain text, so the content "from” not only belongs to the above exposed identifier, but also indicates the From field that needs to be stored in plain text. Moreover, since the content "from" is in the event currentPrice1, the From field is an event-level field, so that when the transaction initiator belongs to the preset user type and the From field is an exposed field, when the event currentPrice1 corresponds to a special event function In the log Logs corresponding to the event currentPrice1, the From field is stored in plain text when the preset conditions are met, and stored in cipher text when the preset conditions are not met, and other fields must be stored in cipher text Form storage.
  • the generated log Logs are in ciphertext form storage.
  • the above-expanded embodiments can also implement corresponding logic functions through chain codes, or adopt a combination of chain codes and system contracts.
  • the embodiment shown in FIG. 2 adopts the receipt data storage logic related to the transaction type, and the expanded embodiment described above further considers at least one of the following factors: exposing the object indicated by the identifier, The user type of the transaction initiator, the content of the receipt meeting preset conditions in the receipt data, and the event function contained in the smart contract.
  • One or more of the above factors can be combined with the user type to obtain the corresponding receipt data storage logic.
  • the receipt data storage logic When the receipt data storage logic is related to the object indicated by the exposure identifier, the receipt data storage logic includes logic for storing the content of the receipt based on the exposure identifier, and the logic is used to instruct the first blockchain node: to indicate the exposure identifier The corresponding receipt content should be stored in the fields of, and fields not marked by the exposed identifier.
  • the receipt data storage logic When the receipt data storage logic is related to the user type of the transaction initiator, the receipt data storage logic includes: identification logic for the user type.
  • 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. For details, please refer to the relevant description of identifying user types above, which will not be repeated here.
  • the receipt data storage logic When the receipt data storage logic is related to the event function contained in the smart contract, the receipt data storage logic includes: identification logic for the event function.
  • the identification logic of the event function is used to instruct the first blockchain node to identify the type of event function contained in the smart contract corresponding to the transaction. For example: according to the type identifier contained in the event function, or according to the list of special event functions recorded in the blockchain network. For details, please refer to the relevant description of identifying special event functions above, which will not be repeated here.
  • the receipt data storage logic When the receipt data storage logic is related to the receipt content that meets the preset condition in the receipt data, the receipt data storage logic includes: logic for determining the preset condition.
  • the determination logic of the preset condition is used to instruct the first blockchain node to obtain the preset condition applicable to the content of the receipt corresponding to the object indicated by the exposure identifier. For example, obtain general conditions applicable to all receipt fields, or obtain special conditions applicable to the field of the receipt content corresponding to the object indicated by the exposure identifier. For details, please refer to the relevant description of the preset conditions above, which will not be repeated here.
  • the receiving unit 61 receives the encrypted transaction
  • the decryption unit 62 decrypts the transaction in a trusted execution environment to obtain transaction content
  • the execution unit 63 executes the transaction content in the trusted execution environment to obtain receipt data
  • the determining unit 64 determines the exposed fields in the receipt data according to the transaction type of the transaction;
  • the storage unit 65 stores the receipt data so that at least part of the receipt content corresponding to the exposed field is stored in plain text, and the rest of the receipt content is stored in cipher text.
  • the transaction includes a transaction type field, and the value of the transaction type field is used to indicate the corresponding transaction type.
  • the determining unit 64 is specifically configured to:
  • mapping relationship is recorded in a system contract.
  • the storage unit 65 is specifically configured to:
  • the code of the system contract is executed to store the exposed fields in plaintext and the remaining receipt fields in ciphertext.
  • 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 transaction type of the transaction includes: deposit certificate type, asset transfer type, contract creation type, contract call type.
  • the storage unit 65 is specifically configured to:
  • the receipt data is stored so that the transaction initiator belongs to a preset user type
  • at least a part of the receipt content corresponding to the exposed field is stored in plain text
  • the rest of the receipt content is stored in cipher text.
  • the storage unit 65 determines the user type to which the transaction initiator belongs in the following manner:
  • the external account includes a user type field recorded on the blockchain, and the value of the user 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 at least part of the receipt content stored in plaintext meets at least one of the following rules:
  • the at least part of the receipt content is generated by a special event function included in the smart contract corresponding to the transaction;
  • the information contained in the at least part of the receipt content meets a preset condition
  • the at least a part of the receipt content corresponds to the object indicated by the exposure identifier contained in the code of the smart contract.
  • the event function in the smart contract includes a type identifier, and the type identifier is used to mark the event function as a special event function.
  • the event function included in the smart contract is in the special function list recorded on the blockchain, the event function included in the smart contract is determined to be a special event function.
  • the preset condition includes at least one of the following: the corresponding receipt content includes the preset content, and the value of the corresponding receipt content belongs to the preset numerical interval.
  • the preset conditions include general conditions corresponding to all receipt fields in the receipt data; or,
  • the preset condition includes a dedicated condition corresponding to each receipt field in the receipt data.
  • the preset condition is in the transaction; or,
  • the preset condition is located in the smart contract corresponding to the transaction, or in another smart contract called by the smart contract corresponding to the transaction; or,
  • the preset conditions are located in the system contract or chain code.
  • the smart contract corresponding to the transaction received by the receiving unit 61 includes:
  • the smart contract written in the high-level language and the smart contract in bytecode form have the same or corresponding exposure identifier.
  • the objects indicated by the exposure identifier include: receipt fields and/or state variables.
  • the object indicated by the exposure identifier includes at least one of the following: a contract-level object applicable to all events defined in the smart contract, and an event-level object corresponding to at least one event defined in the smart contract Object.
  • the storage unit 65 is specifically configured to:
  • 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 key used by the first blockchain node to encrypt the receipt data 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 a 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.
  • 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)
  • Finance (AREA)
  • Strategic Management (AREA)
  • Physics & Mathematics (AREA)
  • General Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)

Abstract

Provided are a receipt storage method and node based on a transaction type. The method may comprise: a first blockchain node receiving an encrypted transaction; the first blockchain node decrypting the transaction in a trusted execution environment, and executing the obtained transaction content to obtain receipt data; the first blockchain node determining, according to the transaction type of the transaction, an exposed field in the receipt data; and the first blockchain node storing the receipt data, wherein at least some of the receipt content corresponding to the exposed field is stored in the form of plaintext, and the remaining receipt content is stored in the form of ciphertext.

Description

基于交易类型的收据存储方法和节点Receipt storage method and node based on transaction type 技术领域Technical field

本说明书一个或多个实施例涉及区块链技术领域,尤其涉及一种基于交易类型的收据存储方法和节点。One or more embodiments of this specification relate to the field of blockchain technology, and in particular to a method and node for storing receipts based on transaction types.

背景技术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 based on transaction 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 method for storing receipts based on transaction types is proposed, including:

第一区块链节点接收经过加密的交易;The first blockchain node receives the encrypted transaction;

第一区块链节点在可信执行环境中解密所述交易并执行获得的交易内容,得到收据数据;The first blockchain node decrypts the transaction in the trusted execution environment and executes the obtained transaction content to obtain receipt data;

第一区块链节点根据所述交易的交易类型,确定所述收据数据中的暴露字段;The first blockchain node determines the exposed field in the receipt data according to the transaction type of the transaction;

第一区块链节点存储所述收据数据,使所述暴露字段对应的至少一部分收据内容以明文形式存储、其余收据内容以密文形式存储。The first blockchain node stores the receipt data so that at least part of the receipt content corresponding to the exposed field 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 based on transaction type is proposed, including:

接收单元,接收经过加密的交易;The receiving unit receives encrypted transactions;

解密单元,在可信执行环境中解密所述交易,获得交易内容;The decryption unit decrypts the transaction in a trusted execution environment to obtain transaction content;

执行单元,在所述可信执行环境中执行所述交易内容,得到收据数据;The execution unit executes the transaction content in the trusted execution environment to obtain receipt data;

确定单元,根据所述交易的交易类型,确定所述收据数据中的暴露字段;The determining unit determines the exposed fields in the receipt data according to the transaction type of the transaction;

存储单元,存储所述收据数据,使所述暴露字段对应的至少一部分收据内容以明文形式存储、其余收据内容以密文形式存储。The storage unit stores the receipt data so that at least part of the receipt content corresponding to the exposed field 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 implementing privacy protection on blockchain nodes according to an exemplary embodiment.

图2是一示例性实施例提供的一种基于交易类型的收据存储方法的流程图。Fig. 2 is a flowchart of a method for storing receipts based on transaction types according to an exemplary embodiment.

图3是一示例性实施例提供的一种创建智能合约的示意图。Fig. 3 is a schematic diagram of creating a smart contract according to an exemplary embodiment.

图4是一示例性实施例提供的一种调用智能合约的示意图。Fig. 4 is a schematic diagram of invoking a smart contract provided by 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 device based on transaction 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.

不论是公有链、私有链还是联盟链,区块链网络中的节点在执行收到的交易后,会生成相应的收据(receipt)数据,以用于记录该交易相关的收据信息。以以太坊为例,节点执行交易所得的收据数据可以包括如下内容:Regardless of whether it is a public chain, a private chain, or a consortium chain, after the nodes in the blockchain network execute the received transaction, 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.

节点在执行某一区块所含的各个交易时,每一交易被执行后都会生成相应的收据数据,而节点可以按照预定义的树状结构和处理逻辑,组织该区块所含各个交易对应的收据数据,形成一颗收据树。通过组织生成收据树,使得在针对收据数据进行查询或验证时,能够极大地提升相应的查询或验证效率。例如,以太坊中采用MPT(Merkle Patricia Tree)结构组织生成上述的收据树,该收据树的叶子为该区块所含各个交易对应的收据数据的哈希值,而收据树根(receiptRoot)为根据叶子处的收据数据的哈希值依次向上生成的根哈希。当然,在其他区块链网络还可以采用其他类型的树状结构。When a node executes each transaction contained in a block, the corresponding receipt data will be generated after each transaction is executed, and the node can organize the corresponding transactions contained in the block according to a predefined tree structure and processing logic The receipt data forms a receipt tree. The receipt tree is generated through organization, so that when querying or verifying receipt data, the corresponding query or verification efficiency can be greatly improved. For example, in Ethereum, the MPT (Merkle Patricia Tree) structure is used to organize the above-mentioned receipt tree. The leaf of the receipt tree is the hash value of the receipt data corresponding to each transaction contained in the block, and the receiptRoot is Root hashes generated sequentially upwards according to the hash value of the receipt data at the leaf. Of course, other types of tree structures can also be used in other blockchain networks.

一般的,交易执行后生成的收据数据以明文形式进行存储,任何人都可以看到收据数据所含的上述各个收据字段的内容,无隐私保护的设置和能力。而在一些区块链与TEE(Trusted Execution Environment,可信执行环境)相结合的解决方案中,出于隐私保护的目的,需要将收据数据以密文形式存储。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 (Trusted Execution Environment), for the purpose of privacy protection, the receipt data needs to be stored in cipher text.

例如图1所示,第一区块链节点包括左侧的常规环境(图中位于左侧)和TEE,客户端(或其他来源)提交的交易首先进入常规环境中的“交易/查询接口”,然后将交易传递至TEE中进行处理。TEE与常规环境相互隔离。例如,当交易被加密时,该交易需要被传递至TEE内进行解密为明文的交易内容,从而在确保数据安全的前提下,使得该明文的交易内容能够在TEE中实现高效处理,并在TEE中生成明文的收据数据。For example, as shown in Figure 1, the first blockchain node includes the conventional environment on the left (on the left in the figure) and TEE. The transaction submitted by the client (or other sources) first enters the "transaction/query interface" in the conventional environment , And then pass the transaction to the TEE for processing. TEE is isolated from the normal environment. For example, when a transaction is encrypted, the transaction needs to be transferred to the TEE for decryption as the transaction content in clear text, 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内生成的收据数据的全部内容均被当作需要隐私保护的数据存储在区块链上。所述区块链,是存储在节点的数据库中特定逻辑组织而成的数据集合。所述数据库,如后所述,其物理载体可以存储介质,例如持久性存储介质。实际上,对于不同类型的交易而言,对于收据数据的隐私保护需求并不相同。比如,存证交易关注于对交易发起方的身份进行隐私保护,转账交易关注于对转账双方的身份进行隐私保 护,与智能合约相关的交易关注于对交易发起方的身份进行隐私保护等。In related technologies, all the contents of the receipt data generated in the TEE are treated as data requiring privacy protection and stored on the blockchain. 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, for different types of transactions, the privacy protection requirements for receipt data are not the same. For example, deposit certificate transactions focus on the privacy protection of the identity of the transaction initiator, transfer transactions focus on the privacy protection of the identities of both parties to the transfer, and transactions related to smart contracts focus on the privacy protection of the identity of the transaction initiator.

以下结合图2所示说明本申请一基于交易类型的收据存储方法的实施例的实现过程:The following describes the implementation process of an embodiment of a method for storing receipts based on transaction types in this application with reference to FIG. 2:

步骤202,第一区块链节点接收经过加密的交易。In step 202, the first blockchain node receives the encrypted transaction.

在一实施例中,用户可以直接在第一区块链节点上生成交易;或者,用户可以在客户端上生成交易,并通过客户端将该交易发送至第一区块链节点;或者,客户端可以将上述交易发送至第二区块链节点,并由第二区块链节点将该交易发送至第一区块链节点。In an embodiment, the user can directly generate a transaction on the first blockchain node; or, the user can generate a transaction on the client, and send the transaction to the first blockchain node through the client; or, the client The terminal can send the above transaction to the second blockchain node, and the second blockchain node sends the transaction to the first blockchain node.

本说明书中的交易可以用于实现相对简单的处理逻辑,比如类似于相关技术中的存证逻辑、转账逻辑等,即相关交易为存证交易、转账交易等。此时,上述交易可与智能合约无关。The transactions in this manual can be used to implement relatively simple processing logic, such as similar to the deposit logic and transfer logic in related technologies, that is, the relevant transactions are deposit transactions, transfer transactions, etc. At this time, the above transaction may not be related to the smart contract.

本说明书中的交易还可以用于实现相对复杂的处理逻辑,这里可以借助于上述的智能合约来实现。区块链上的智能合约是在区块链系统上可以被交易触发执行的合约。智能合约可以通过代码的形式定义。The transactions in this specification can also be used to implement relatively complex processing logic, which can be implemented here with the help of the above-mentioned 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.

例如图3所示,Bob将一个包含创建智能合约信息的交易发送到以太坊网络后,节点1的EVM可以执行这个交易并生成对应的合约实例。图中3中的“0x6f8ae93…”代表了这个合约的地址,交易的data字段保存的可以是字节码,交易的to字段为空。节点间通过共识机制达成一致后,这个合约成功创建,并且可以在后续过程中被调用。合约创建后,区块链上出现一个与该智能合约对应的合约账户,并拥有一个特定的地址,合约代码将保存在该合约账户中。智能合约的行为由合约代码控制。换句话说,智能合约使得区块链上产生包含合约代码和账户存储(Storage)的虚拟账户。For example, as shown in Figure 3, 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 3 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.

如图4所示,仍以以太坊为例,Bob将一个用于调用智能合约的交易发送到以太坊网络后,某一节点的EVM可以执行这个交易并生成对应的合约实例。图中2中交易的 from字段是交易发起方(即Bob)的账户的地址,to字段中的“0x6f8ae93…”代表了被调用的智能合约的地址,value字段在以太坊中是以太币的值,交易的data字段保存的调用智能合约的方法和参数。智能合约以规定的方式在区块链网络中每个节点独立的执行,所有执行记录和数据都保存在区块链上,所以当交易完成后,区块链上就保存了无法篡改、不会丢失的交易凭证。As shown in Figure 4, 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.

可见,当交易用于创建智能合约时,交易内容可以包括所需创建的智能合约的代码;当交易用于调用智能合约时,交易内容可以包括被调用的智能合约的账户地址、需要传入的方法和参数等。It can be seen that 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 that is called, and the required input Methods and parameters, etc.

步骤204,第一区块链节点在可信执行环境中解密所述交易并执行获得的交易内容,得到收据数据。Step 204: The first blockchain node decrypts the transaction in the trusted execution environment and executes the obtained transaction content to obtain receipt data.

在一实施例中,通过对交易内容进行加密,可使上述经过加密的交易处于隐私保护的状态,避免交易内容发生暴露。譬如,交易内容中可能包含交易发起方的账户地址、交易目标的账户地址等信息,通过加密处理可以确保这些交易内容均无法被直接读取。In one embodiment, by encrypting the transaction content, the encrypted transaction can be kept in a state of privacy protection, and the transaction content can be prevented from being exposed. For example, the transaction content may contain information such as the account address of the transaction initiator and the account address of the transaction target. Encryption processing can ensure that these transaction contents cannot be directly read.

在一实施例中,上述交易可以通过对称加密算法的方式进行加密,也可以采用非对称算法的方式进行加密。对称加密采用的加密算法,例如是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.

当交易用于调用智能合约时,可以是多重嵌套结构的调用。例如,交易直接调用智能合约1,而该智能合约1的代码调用了智能合约2,且智能合约2中的代码指向了智能合约3的合约地址,使得交易实际上间接调用了智能合约3的代码。具体实现过程与上述过程类似,在此不再赘述。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 . The specific implementation process is similar to the above process, and will not be repeated here.

如前所述,第一区块链节点接收的交易,例如可以是创建和/或调用智能合约的交易。比如在以太坊中,第一区块链节点接收到客户端发来的创建和/或调用智能合约的交易 后,可以检查交易是否有效、格式是否正确,验证交易的签名是否合法等。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.

智能合约类似于面向对象编程中的类,执行的结果生成对应该智能合约的合约实例,类似于生成类对应的对象。执行交易中用于创建智能合约的代码的过程,会创建合约账户,并在账户空间中部署合约。以太坊中,智能合约账户的地址是由发送者的地址(如图3-4中的“0xf5e…”)和交易随机数(nonce)作为输入,通过加密算法生成的,比如图3-4中的合约地址“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 3-4) and the transaction nonce (nonce) as input, and is generated by an encryption algorithm, such as in Figure 3-4 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 generated 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.

如上文所述,通过在TEE中执行解密后的交易内容,可以确保执行过程在可信环境内完成,以确保隐私信息不会发生泄漏。当上述存在隐私处理需求的交易用于创建智能合约时,该交易中包含智能合约的代码,第一区块链节点可以在TEE中对该交易进行解密得到其所含智能合约的代码,并进而在TEE中执行该代码。当上述存在隐私处理需求的交易用于调用智能合约时,第一区块链节点可以在TEE中执行该代码(若被调用的智能合约处理加密状态,则需要先在TEE中对该智能合约进行解密,以得到相应的代码)。具体的,第一区块链节点可以利用CPU中新增的处理器指令,在内存中分配一部分区域EPC,通过CPU内的加密引擎MEE对上述的明文代码进行加密存入所述EPC中。EPC中加密的内容进入CPU后被解密成明文。在CPU中,对明文的代码进行运算,完成执行过程。例如,在SGX技术中,执行智能合约的明文代码,可以将EVM加载进围圈中。在远程证明过程中,密钥管理服务器可以计算本地EVM代码的hash值,并与第一区块链节点中加载的EVM代码的hash值比对,比对结果正确作为通过远程证明的一个必要条件,从而完成对第一区块链节点SGX围圈加载的代码的度量。经过度量,正确的EVM可以在SGX中执行上述智能合约的代码。As mentioned above, by executing the decrypted transaction content in the TEE, it can be ensured that the execution process is completed in a trusted environment to ensure that private information will not be leaked. 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.

步骤206,第一区块链节点根据所述交易的交易类型,确定所述收据数据中的暴露字段。Step 206: The first blockchain node determines the exposed field in the receipt data according to the transaction type of the transaction.

在一实施例中,交易可以包括交易类型字段(如TransType字段),该交易类型字段的取值用于标明相应的交易类型。因此,通过读取交易所含交易类型字段的取值,可以确定出交易类型,比如存证类型、资产转移(如转账)类型、合约创建类型、合约调用类型等,本说明书并不对此进行限制。In an embodiment, the transaction may include a transaction type field (such as a TransType field), and the value of the transaction type field is used to indicate the corresponding transaction type. Therefore, by reading the value of the transaction type field in the exchange, the transaction type can be determined, such as the type of deposit certificate, the type of asset transfer (such as transfer), the type of contract creation, and the type of contract invocation. This manual does not limit this .

在一实施例中,不同类型的交易可以分别存在对应的暴露字段。暴露字段为收据数据中指定的一个或多个字段,在收据数据需要密文存储以保护隐私的前提下,允许暴露字段对应的收据内容以明文形式进行存储,以便后续针对该明文形式存储的收据内容实施检索等操作。In an embodiment, different types of transactions may respectively have corresponding exposed fields. The exposed field is one or more fields specified in the receipt data. Under the premise that the receipt data needs to be stored in cipher text to protect privacy, the content of the receipt corresponding to the exposed field is allowed to be stored in plain text for subsequent receipts stored in plain text. Content implementation search and other operations.

在一实施例中,可以预先定义每一交易类型与暴露字段之间的映射关系,使得第一区块链节点可以获取该预定义的映射关系,并进一步根据交易的交易类型和该映射关系,确定收据数据中的暴露字段。例如,存证类型对应的暴露字段可以包括上述From字段之外的所有字段,资产转移类型对应的暴露字段可以包括上述的To字段,合约创 建类型和合约调用类型对应的暴露字段可以包括上述From字段之外的所有字段,而对于其他交易类型的情况,此处不再一一赘述。In an embodiment, the mapping relationship between each transaction type and the exposed field may be predefined, so that the first blockchain node can obtain the predefined mapping relationship, and further based on the transaction type of the transaction and the mapping relationship, Identify the exposed fields in the receipt data. For example, the exposed field corresponding to the attestation type may include all fields except the above-mentioned From field, the exposed field corresponding to the asset transfer type may include the above-mentioned To field, and the exposed field corresponding to the contract creation type and contract invocation type may include the above-mentioned From field. All the fields except for the other transaction types will not be repeated here.

可见,在保护用户隐私的前提下,通过对交易类型予以识别,可以根据不同交易类型对于隐私保护程度的差异化需求,使得收据数据所含的收据字段能够实现差异化的存储操作,相比于所有收据数据完全以密文形式存储,具有相对更高的灵活性,并且明文存储的收据内容能够直接实现后续的检索等操作,从而满足更加丰富的应用场景,比如驱动诸如DAPP(Decentralized Application,分布式应用)客户端执行相关处理操作等。It can be seen that under the premise of protecting user privacy, by identifying transaction types, different transaction types can have differentiated requirements for privacy protection, so that the receipt fields contained in receipt data can achieve differentiated storage operations, compared to All receipt data is completely stored in cipher text, which has relatively higher flexibility, and the receipt content stored in plain text can directly implement subsequent retrieval and other operations, thereby satisfying more abundant application scenarios, such as driving such as DAPP (Decentralized Application, distribution) Application) The client performs related processing operations and so on.

在一实施例中,上述的映射关系可以记录于系统合约中。如果上述映射关系不存在升级需求,还可以将该映射关系记录于区块链网络的链代码中。In an embodiment, the above-mentioned mapping relationship may be recorded in the system contract. If there is no upgrade requirement for the above mapping relationship, the mapping relationship can also be recorded in the chain code of the blockchain network.

步骤208,第一区块链节点存储所述收据数据,使所述暴露字段对应的至少一部分收据内容以明文形式存储、其余收据内容以密文形式存储。Step 208: The first blockchain node stores the receipt data so that at least part of the receipt content corresponding to the exposed field is stored in plain text, and the rest of the receipt content is stored in cipher text.

在一实施例中,第一区块链节点读取系统合约的代码,所述系统合约的代码中定义了与交易类型相关的收据数据存储逻辑,即每一交易类型对应的暴露字段(类似于上述的映射关系)、针对暴露字段实施明文存储的逻辑、针对非暴露字段实施密文存储的逻辑等;相应地,第一区块链节点通过执行所述系统合约的代码,可以将暴露字段对应的至少一部分收据内容以明文形式存储、其余收据内容以密文形式存储。In one embodiment, the first blockchain node reads the code of the system contract. The code of the system contract defines the receipt data storage logic related to the transaction type, that is, the exposed field corresponding to each transaction type (similar to The above-mentioned mapping relationship), the logic of implementing plaintext storage for exposed fields, the logic of implementing ciphertext storage for non-exposed fields, etc.; accordingly, the first blockchain node can execute the code of the system contract to correspond to the exposed fields At least part of the receipt content is stored in plain text, and the rest of the receipt content is stored in cipher text.

通过在计算设备(物理机或虚拟机)上运行区块链的程序代码(以下简称为链代码),可以将该计算设备配置为区块链网络中的区块链节点,比如上述的第一区块链节点等。换言之,第一区块链节点通过运行上述的链代码,以实现相应的功能逻辑。因此,可以在创建区块链网络时,将上文所述的与交易类型相关的收据数据存储逻辑写入链代码中,使得各个区块链节点均可以实现该收据数据存储逻辑;以第一区块链节点为例,该收据数据存储逻辑即上文所述的:收据数据存储逻辑中可以具体定义了每一交易类型对应的暴露字段,使得第一区块链节点可以根据交易类型,确定交易产生的收据数据中哪些收据内容需要明文存储、哪些收据内容需要密文存储。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 transaction type described above can be written into the chain code, so that each blockchain node can implement the receipt data storage logic; Take the blockchain node as an example. The receipt data storage logic is as described above: the receipt data storage logic can specifically define the exposed fields corresponding to each transaction type, so that the first blockchain node can determine according to the transaction type Which receipt content in the receipt data generated by the transaction needs to be stored in plain text, and which receipt content needs to be stored in cipher text.

然而,链代码的升级更新相对较为困难,使得采用链代码实现对收据数据的存储存在灵活性低、可扩展性不足的问题。为了实现对链代码的功能扩展,如图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 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 address "0x53a98..." to read the system The code in the contract) to realize the functional supplement of the chain code.

区别于上述由用户发布至区块链的智能合约,系统合约无法由用户自由发布。第一区块链节点读取的系统合约可以包括配置于区块链网络的创世块中的预置系统合约;以及,区块链网络中的管理员(即上述的管理用户)可以具有针对系统合约的更新权限,从而针对诸如上述的预置系统合约进行更新,则上述第一区块链节点读取的系统合约还可以包括相应的更新后系统合约。当然,更新后系统合约可以由管理员对预置系统合约实施一次更新后得到;或者,更新后系统合约可以由管理员对预置系统合约实施多次迭代更新后得到,比如由预置系统合约更新得到系统合约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.

因此,第一区块链节点可以读取系统合约的代码,该系统合约的代码中定义了与预设交易类型相关的收据数据存储逻辑;然后,第一区块链节点可以执行该系统合约的代码,以根据交易类型确定相应的暴露字段,并将收据数据中相应的收据内容以明文形式存储、其余收据内容以密文形式存储。Therefore, the first blockchain node can read the code of the system contract, and the code of the system contract defines the receipt data storage logic related to the preset transaction type; then, the first blockchain node can execute the system contract Code to determine the corresponding exposed field according to the transaction type, and store the corresponding receipt content in the receipt data in plain text, and store the remaining receipt content in cipher text.

在一实施例中,第一区块链节点通过密钥对收据内容(非暴露字段对应的收据内容,还可能包括暴露字段对应的部分收据内容)进行加密。所述加密,可以采用对称加密,也可以采用非对称加密。如果第一区块链节点用对称加密方式,即用对称加密算法的对称密钥对收据内容加密,则客户端(或其他持有密钥的对象)可以用该对称加密算法的对称密钥对加密后的收据内容进行解密。In an embodiment, the first blockchain node encrypts the content of the receipt (the content of the receipt corresponding to the non-exposed field, and may also include part of the content of the receipt corresponding to the exposed field) using a 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.

在一实施例中,第一区块链节点用对称加密算法的对称密钥对收据内容进行加密时,该对称密钥可由客户端预先提供至第一区块链节点。那么,由于只有客户端(实际应当为客户端上的已登录账户对应的用户)和第一区块链节点掌握该对称密钥,使得仅该客户端能够解密相应的加密后的收据内容,避免无关用户甚至不法分子对加密后的收据内容进行解密。In an embodiment, when the first blockchain node encrypts the receipt content with a symmetric key of a symmetric encryption algorithm, 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.

在一实施例中,第一区块链节点可以采用上述的初始密钥对收据内容进行加密。不同交易采用的初始密钥可以相同,使得同一用户所提交的所有交易均采用该初始密钥进行加密,或者不同交易采用的初始密钥可以不同,比如客户端可以针对每一交易随机生成一初始密钥,以提升安全性。In an embodiment, the first blockchain node may 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位,或者其他位)进行拼接,并对拼接后的字符串进行哈希运算,从而生成衍生密钥。In an embodiment, the first blockchain node may 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.

在一实施例中,第一区块链节点还可以采用非对称加密方式,即用非对称加密算法的公钥对收据内容加密,则相应地,客户端可以用所述非对称加密算法的私钥解密上述加密后的收据内容。非对称加密算法的密钥,例如可以是由客户端生成一对公钥和私钥,并将公钥预先发送至第一区块链节点,从而第一区块链节点可以将收据内容用该公钥加密。In an embodiment, the first blockchain node may 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 may use the private key of the asymmetric encryption algorithm. The key decrypts the encrypted receipt content. 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内的写缓存中,比如该写缓存可以对应于如图1所示的“缓存”。进一步的,第一区块链节点将写缓存中的数据从可信执行环境输出,以存储至外部存储空间。其中,写缓存功能代码可以以明文形式存储于TEE中,可以直接在TEE中执行该明文形式的缓存功能代码;或,写缓存功能代码可以以密文形式存储于TEE之外,比如存储于上述的外部存储空间(比如图1所示的“打包+存储”,其中“打包”表示第一区块链节点在可信执行环境之外对交易进行打包成块),可以将该密文形式的写缓存功能代码读入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. 1 "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 1, where "package" means that the first blockchain node packages the transaction into blocks outside of the trusted execution environment), the cipher text 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.

在图2所示实施例的基础上,本说明书可以进一步识别交易对应的智能合约的代码所含的暴露标识符,从而同时根据交易类型对应的暴露字段和暴露标识符标明的字段,确定对收据数据的存储方式。因此,上述的步骤208可以改进为:第一区块链节点存储所述收据数据,使所述收据数据中由所述暴露标识符标明的暴露字段以明文形式存储、 其余收据字段以密文形式存储。On the basis of the embodiment shown in Figure 2, this specification can further identify the exposed identifier contained in the code of the smart contract corresponding to the transaction, so as to determine the receipt according to the exposed field corresponding to the transaction type and the field marked by the exposed identifier. How the data is stored. Therefore, the above step 208 can be improved as: the first blockchain node stores the receipt data so that the exposed fields in the receipt data indicated by the exposure identifier are stored in plain text, and the remaining receipt fields are stored in cipher text. storage.

用户在编写智能合约的代码时,可以在代码中添加暴露标识符来标明一个或多个字段,从而在该智能合约的代码维度上表达下述含义:对于暴露标识符标明的字段,希望将收据数据中相应的收据内容采用明文形式存储,而剩余字段所对应的收据内容则采用密文形式存储。当然,最终是否将暴露标识符标明的字段采用明文形式存储,还需要结合下文所述的交易类型的相关信息,此处暂不赘述。When writing the code of the smart contract, the user can add an exposed identifier to the code to indicate one or more fields, so as to express the following meaning in the code dimension of the smart contract: For the fields marked by the exposed identifier, they hope that the receipt The corresponding receipt content in the data is stored in plain text, and the receipt content corresponding to the remaining fields is stored in cipher text. Of course, whether to store the fields indicated by the exposed identifiers in plain text in the end also needs to be combined with the relevant information of the transaction types described below, which is not repeated here.

如上文所述,在用于创建智能合约的交易中,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 PCTCN2020089384-appb-000001
Figure PCTCN2020089384-appb-000001

在基于Solidity语言编写的智能合约的代码中,可以通过暴露标识符来标明一个或多个字段,其表达的含义为:希望将收据数据中对应于这部分字段的收据内容以明文形式存储,而将其余的收据内容以密文形式存储。类似地,在基于Serpent、LLL语言等编写的智能合约的代码中,同样可以通过暴露标识符来标明一个或多个字段,以表明类似含义。In the code of the smart contract written in Solidity language, one or more fields can be marked by exposing identifiers. The meaning of the expression is: I hope to store the contents of the receipt corresponding to this part of the field in the receipt data in plain text, and Store the rest of the receipt content in cipher text. Similarly, in the code of a smart contract written based on Serpent, LLL languages, etc., one or more fields can also be marked by exposing identifiers to indicate similar meanings.

暴露标识符可以专用于标明需要明文存储的收据字段,例如可以采用关键字 plain来表征该暴露标识符。那么,对于希望以明文形式存储的字段,可以在相应的字段之前添加plain(或者,也可以采用其他方式与相应的字段进行关联),比如上文所述的Result字段、Gas used字段、Logs字段、Output字段等,或者Logs字段中进一步包含的From字段、To字段、Topic字段、Log data字段等。例如,可以将上述的代码示例1调整为下述的代码示例2:The exposure identifier can be dedicated to indicating receipt fields that need to be stored in plain text. For example, the keyword plain can be used to characterize the exposure identifier. Then, for the fields that you want to store in plain text, you can add plain before the corresponding field (or, you can also associate with the corresponding field in other ways), such as the Result field, Gas used field, and Logs field described above. , Output field, etc., or the From field, To field, Topic field, Log data field, etc. further included in the Logs field. For example, the code sample 1 above can be adjusted to the following code sample 2:

Figure PCTCN2020089384-appb-000002
Figure PCTCN2020089384-appb-000002

在上述的代码示例2中,通过在智能合约的代码最前方添加暴露标识符plain,使得智能合约的代码被执行后,对于该智能合约所属交易的交易类型对应的暴露字段,产生的收据数据中对应于上述暴露字段的收据内容均以明文形式进行存储。In the above code example 2, by adding the exposing identifier plain to the front of the smart contract code, after the smart contract code is executed, for the exposed fields corresponding to the transaction type of the smart contract to which the transaction belongs, the generated receipt data The contents of the receipt corresponding to the above exposed fields are all stored in plain text.

当然,在其他实施例中,也可以具体指明需要明文存储的字段。比如,通过暴露标识符对From字段进行标注时,可以仅对该From字段进行判断:如果From字段为该智能合约所属交易的交易类型对应的暴露字段,那么在智能合约的代码被执行后,产生的收据数据中的From字段对应的收据内容以明文形式进行存储,而后续可以针对上述From字段中的收据内容实施检索操作,比如可以统计某一账户所发起的交易量等;而除了From字段之前的其他字段,则均以密文形式存储。Of course, in other embodiments, the fields that need to be stored in plaintext can also be specified. For example, when annotating the From field with an exposed identifier, only the From field can be judged: if the From field is the exposed field corresponding to the transaction type of the transaction to which the smart contract belongs, then after the code of the smart contract is executed, it will be generated The receipt content corresponding to the From field in the receipt data is stored in plain text, and subsequent retrieval operations can be performed on the receipt content in the From field, such as counting the transaction volume initiated by an account, etc.; and before the From field All other fields are stored in cipher text.

需要指出的是:在上述的代码示例2及其相关实施例中,由暴露标识符“plain”所标明的字段(所有字段或From字段)为合约级字段,使得第一区块链节点在存储收据数据时,如果该合约级字段为暴露字段,那么第一区块链节点会将收据数据中对应于该合约级字段的所有收据内容以明文形式存储。尤其是,当智能合约的代码中包含多个事件时,合约级字段可以适用于智能合约中的所有事件,那么以From字段为例:当From字段为合约级字段以及交易类型对应的暴露字段时,对于多个事件分别的产生各自对应的Logs字段,每一Logs字段所含的From字段均会采用明文形式进行存储,而无需针 对每一事件分别添加暴露标识符。It should be pointed out that in the above code example 2 and related embodiments, the fields (all fields or From fields) marked by the exposed identifier "plain" are contract-level fields, so that the first blockchain node is storing When receiving the receipt data, if the contract-level field is an exposed field, the first blockchain node will store all receipt contents corresponding to the contract-level field in the receipt data in plain text. In particular, when the code of a smart contract contains multiple events, the contract-level field can be applied to all events in the smart contract. Take the From field as an example: when the From field is a contract-level field and the exposed field corresponding to the transaction type , For multiple events to generate their corresponding Logs fields, 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.

除了合约级字段之外,暴露标识符标明的字段可以包括:对应于智能合约中定义的至少一个事件的事件级字段,使得第一区块链节点在存储收据数据时,如果事件级字段属于交易类型对应的暴露字段,可以确定出收据数据中对应于该至少一个事件的收据内容,并将确定出的收据内容中对应于上述事件级字段的部分以明文形式存储。尤其是,当智能合约中包含多个事件时,可以针对至少一部分事件设定上述的事件级字段,使得这部分事件对应的收据内容中对应于事件级字段的部分以明文形式存储,而这部分事件对应的收据内容中的剩余部分、其余事件对应的收据内容等均以密文形式存储。以From字段为例,可以将上述的代码示例1调整为下述的代码示例3:In addition to the contract-level fields, the fields indicated by the exposure identifier may include: event-level fields corresponding to at least one event defined in the smart contract, so that when the first blockchain node stores the receipt data, if the event-level field belongs to the transaction The exposed field corresponding to the type can determine the receipt content corresponding to the at least one event in the receipt data, and store the determined portion of the receipt content corresponding to the event-level field in plain text. In particular, when the smart contract contains multiple events, the above event-level fields can be set for at least some of the events, so that the part of the receipt content corresponding to these events that corresponds to the event-level field is stored in plain text, and this part The remaining part of the receipt content corresponding to the event and the receipt content corresponding to the remaining events are stored in cipher text. Taking the From field as an example, the above code example 1 can be adjusted to the following code example 3:

Figure PCTCN2020089384-appb-000003
Figure PCTCN2020089384-appb-000003

在上述的代码示例3中,通过在事件currentPrice对应的事件函数“event currentPrice(int price)”中添加From字段对应的字符from,并且该字符from所采用的暴露标识符区别于前述的plain,而是通过引号对该字符from进行修饰,则代码示例3中的引号相当于前述的暴露标识符,将From字段配置为事件级字段,使得当From字段属于交易类型对应的暴露字段时,在该事件对应产生的Logs字段中,From字段将以明文形式进行存储。除了上述事件currentPrice之外,如果智能合约的代码还包含另一事件,那么上述的字符from不会影响该另一事件、该另一事件对应的收据内容将以密文形式进行存储,除非存在针对该另一事件而添加的“from”。In the above code example 3, by adding the character from corresponding to the From field in the event function "event currentPrice(int price)" corresponding to the event currentPrice, and the exposure identifier used by the character from is different from the aforementioned plain, and The character from is modified by quotation marks. The quotation marks in code example 3 are equivalent to the aforementioned exposure identifier, and the From field is configured as an event-level field, so that when the From field belongs to the exposed field corresponding to the transaction type, in the event Corresponding to the generated Logs field, 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.

或者,可以将上述的代码示例1调整为下述的代码示例4:Or, you can adjust the above code example 1 to the following code example 4:

Figure PCTCN2020089384-appb-000004
Figure PCTCN2020089384-appb-000004

Figure PCTCN2020089384-appb-000005
Figure PCTCN2020089384-appb-000005

在上述的代码示例4中,通过在事件currentPrice对应的事件函数“event currentPrice(int price)”之前添加暴露标识符“plain”,而区别于代码示例3中添加的“from”,使得此处并未指明事件级字段为From字段,那么可以将事件currentPrice所产生的日志中的所有字段均作为上述的事件级字段,譬如前述的From字段、To字段、Topic字段、Log Data字段等,相当于将该事件currentPrice对应的所有收据内容均以明文形式存储。In the above code example 4, by adding the exposure identifier "plain" before the event function "event currentPrice(int price)" corresponding to the event currentPrice, it is different from the "from" added in code example 3, so that If the event-level field is not specified as the From field, then all the fields in the log generated by the event currentPrice can be used as the above-mentioned event-level fields, such as the aforementioned From field, To field, Topic field, Log Data field, etc., which is equivalent to changing The contents of all receipts corresponding to the event currentPrice are stored in plain 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.

在图2所示实施例的基础上,本说明书可以进一步识别交易发起方的用户类型,从而同时根据交易类型对应的暴露字段和交易发起方的用户类型,确定对收据数据的存储方式。因此,上述的步骤208可以改进为:第一区块链节点存储所述收据数据,当交易发起方属于预设用户类型时,所述暴露字段以明文形式存储、其余收据字段以密文形式存储,当交易发起方不属于所述预设用户类型时,所述收据数据以密文形式存储。在保护用户隐私的前提下,通过对用户类型予以识别,可以根据不同用户对于隐私保护程度的差异化需求,针对所产生的收据数据中的暴露字段实施差异化的存储操作,具有较高的灵活性。例如,普通用户的隐私保护的需求相对更低、对基于收据数据的触发操作需求相对更高,那么对于普通用户发起的交易所产生的收据数据,可以将暴露字段对应的收据内容采用明文形式存储,以便针对明文存储的收据内容实施检索并触发相对更多类型的关联操作。再例如,高级用户的隐私保护的需求相对更高、对基于收据数据的触发操作需求相对更低,那么对于高级用户发起的交易所产生的收据数据,可以将暴露字段对应的收据内容采用密文形式存储,以便在支持部分类型的关联操作的同时,确保密文形式的收据内容得以安全保存。综上所述,在保护用户隐私的前提下,通过对交易类型和用户类型分别予以识别,使得即便针对相同类型的交易,也能够根据不同类型的用户对于隐私保护程度的差异化需求,使得收据数据所含的暴露字段能够实现差异化的存储操作,相比于所有收据数据完全以密文形式存储,具有相对更高的灵活性,并且明文存储的收据内容能够直接实现后续的检索等操作,从而满足更加丰富的应用场景。Based on the embodiment shown in FIG. 2, this specification can further identify the user type of the transaction initiator, so as to determine the storage method of the receipt data according to the exposed fields corresponding to the transaction type and the user type of the transaction initiator at the same time. Therefore, the above step 208 can be improved to: the first blockchain node stores the receipt data, and when the transaction initiator belongs to the preset user type, the exposed field is stored in plain text, and the remaining receipt fields are stored in cipher text. When the transaction initiator does not belong to the preset user type, the receipt data is stored in cipher text. Under the premise of protecting user privacy, by identifying user types, different users can implement differentiated storage operations for the exposed fields in the generated receipt data according to the differentiated needs of different users for the degree of privacy protection, which has high flexibility Sex. For example, ordinary users have relatively lower requirements for privacy protection and higher requirements for triggering operations based on receipt data. For receipt data generated by transactions initiated by ordinary users, the contents of the receipt corresponding to the exposed fields can be stored in plain text. , In order to retrieve the contents of the receipt stored in plaintext and trigger relatively more types of associated operations. For another example, the privacy protection requirements of advanced users are relatively higher, and the requirements for triggering operations based on receipt data are relatively lower. For the receipt data generated by transactions initiated by advanced users, the content of the receipt corresponding to the exposed field can be ciphered Form storage to ensure that the receipt content in ciphertext form can be stored safely while supporting some types of associated operations. In summary, under the premise of protecting user privacy, by separately identifying transaction type and user type, even for the same type of transaction, it is possible to make receipts based on the differentiated needs of different types of users for privacy protection. The exposed fields contained in the data can achieve differentiated storage operations. Compared with all receipt data stored in ciphertext form, it has relatively higher flexibility, and the content of the receipt stored in plaintext can directly implement subsequent retrieval and other operations. So as to meet more abundant application scenarios.

在一实施例中,用户在区块链上存在对应的外部账户,并基于该外部账户发起交易或实施其他操作。那么,交易发起方所属的预设用户类型,即该外部账户所属的预 设用户类型。因此,第一区块链节点可以确定所述交易发起方对应的外部账户,并通过查询区块链上记录的所述外部账户对应的用户类型,以作为所述交易发起方所属的用户类型。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 preset user type to which the transaction initiator belongs, that is, the preset 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.

在一实施例中,外部账户可以包括记录于区块链上的用户类型字段(如UserType字段),该用户类型字段的取值对应于用户类型。比如,当用户类型字段的取值为00时,用户类型为普通用户,当用户类型字段的取值为01时,用户类型为高级用户,当用户类型字段的取值为11时,用户类型为管理用户等。因此,第一区块链节点可以通过读取上述的外部账户的用户类型字段,即可基于取值确定相应的用户类型。In an embodiment, the external account may include a user type field (such as a UserType field) recorded on the blockchain, and the value of the user type field corresponds to the user type. For example, when the value of the user type field is 00, the user type is ordinary user, when the value of the user type field is 01, the user type is advanced user, and when the value of the user type field is 11, the user type is Manage users, etc. Therefore, the first blockchain node can determine the corresponding user type based on the value by reading the user 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-mentioned user 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.

在图2所示实施例的基础上,本说明书可以进一步识别智能合约所含的事件函数,从而同时根据交易类型对应的暴露字段和智能合约所含的特殊事件函数,确定对收据数据的存储方式。因此,上述的步骤208可以改进为:第一区块链节点存储所述收据数据,使对应于所述特殊事件函数的日志中的暴露字段以明文形式存储、所述收据数据的其余内容以密文形式存储。在保护用户隐私的前提下,通过对交易类型予以识别,可以根据不同类型的交易对于隐私保护的差异化需求,确定出可以明文存储的暴露字段,并进一步根据交易调用的智能合约所含的事件函数,在存储过程中体现出不同类型的事件函数对于隐私保护的差异化需求,具有较高的灵活性。例如,特殊事件函数涉及的暴露字段以明文形式存储,而特殊事件函数涉及的非暴露字段、普通事件函数所涉及的所有收据字段等,均以密文形式存储。On the basis of the embodiment shown in Figure 2, this specification can further identify the event functions contained in the smart contract, so as to determine the storage method of the receipt data according to the exposed fields corresponding to the transaction type and the special event functions contained in the smart contract at the same time . Therefore, the above step 208 can be improved as: the first blockchain node stores the receipt data, so that the exposed fields in the log corresponding to the special event function are stored in plain text, and the rest of the receipt data is stored in encrypted form. Document storage. Under the premise of protecting user privacy, by identifying transaction types, the exposed fields that can be stored in plaintext can be determined according to the differentiated needs of different types of transactions for privacy protection, and further based on the events contained in the smart contract called by the transaction Function, which reflects the differentiated requirements of different types of event functions for privacy protection in the storage process, and has high flexibility. For example, the exposed fields involved in the special event function are stored in plain text, while the non-exposed fields involved in the special event function and all receipt fields involved in the normal event function are stored in cipher text.

在一实施例中,智能合约可以包含一个或多个事件,每一事件用于实现预定义 的相关处理逻辑。智能合约所含的每一事件被调用执行后,均会生成对应的Logs字段,比如当智能合约包含事件1和事件2时,事件1可以生成对应的Logs字段、事件2可以生成对应的Logs字段,使得该智能合约对应的收据数据同时包含多个Logs字段。In an embodiment, the smart contract may include one or more events, and each event is used to implement predefined related processing logic. After each event contained in the smart contract is called and executed, the corresponding Logs field will be generated. For example, when the smart contract contains event 1 and event 2, event 1 can generate the corresponding Logs field, and event 2 can generate the corresponding Logs field. , So that the receipt data corresponding to the smart contract contains multiple Logs fields at the same time.

在一实施例中,智能合约所含的事件可以分为特殊事件函数和普通事件函数,其中:普通事件函数所产生的日志采用密文形式进行存储,以实现隐私保护;特殊事件函数所产生的日志则需要在满足隐私保护需求的前提下,将至少一部分日志字段(例如上文所述的暴露字段)以明文形式进行存储,从而可以针对该部分日志字段的内容实施检索,以驱动相关操作的实施。In one embodiment, the events contained in the smart contract can be divided into special event functions and ordinary event functions. The logs generated by the ordinary event functions are stored in cipher text to achieve privacy protection; the special event functions generated Logs need to store at least part of the log fields (such as the exposed fields described above) in plain text on the premise of meeting the privacy protection requirements, so that the content of this part of the log fields can be retrieved to drive related operations. Implement.

在一实施例中,特殊事件函数可以为区块链网络中预定义的全局事件函数。比如在区块链网络的链代码或系统合约中,可以记录属于“特殊事件函数”的的事件函数,譬如可以记录在特殊事件函数列表中;相应地,通过将智能合约中包含的事件函数与上述的特殊事件函数列表进行对比,可以确定智能合约包含的事件函数是否为上述的特殊事件函数。In an embodiment, the special event function may be a predefined global event function in the blockchain network. For example, in the chain code or system contract of the blockchain network, the event function belonging to the "special event function" can be recorded, for example, it can be recorded in the special event function list; accordingly, by combining the event function contained in the smart contract with By comparing the above special event function list, it can be determined whether the event function included in the smart contract is the above special event function.

在一实施例中,特殊事件函数可以为智能合约中自定义的任意函数,并通过在智能合约中添加针对事件函数的类型标识符,可以将该事件函数标记为特殊事件函数。以Solidity语言为例,智能合约包含的事件函数的代码示例如下:In an embodiment, the special event function can be any function defined in the smart contract, and by adding a type identifier for the event function in the smart contract, the event function can be marked as a special event function. Taking Solidity language as an example, the code example of the event function included in the smart contract is as follows:

Event buy_candy1 expose(who,candy_num);Event buy_candy1 expose(who,candy_num);

Event buy_candy2(who,candy_num);Event buy_candy2(who,candy_num);

在上述代码示例中,智能合约定义了2个事件:事件buy_candy1和事件buy_candy2。通过在事件buy_candy1中添加类型标识符“expose”,可以将该事件buy_candy1标记为上述的特殊事件函数;相应的,由于事件buy_candy2中并未包含类型标识符“expose”,因而事件buy_candy2为普通事件函数、而非上述的特殊事件函数。In the above code example, the smart contract defines 2 events: event buy_candy1 and event buy_candy2. By adding the type identifier "expose" to the event buy_candy1, the event buy_candy1 can be marked as the above special event function; correspondingly, since the event buy_candy2 does not contain the type identifier "expose", the event buy_candy2 is a normal event function Instead of the special event function mentioned above.

以太坊支持的高级语言很多,如Solidity、Serpent、LLL语言等,均可以包含上述的类型标识符。通过编译器可以将高级语言编写的智能合约编译为相应的字节码,第一区块链节点最终在EVM虚拟机中执行字节码形式的智能合约。那么,上述的类型标识符在高级语言和字节码形式的智能合约代码中可以相同,或者高级语言的智能合约代码中为第一类型标识符、字节码形式的智能合约代码中为第二类型标识符,第一类型标识符与第二类型标识符之间可以相互对应。Many high-level languages supported by Ethereum, such as Solidity, Serpent, and LLL languages, can contain the above type identifiers. A smart contract written in a high-level language can be compiled into a corresponding bytecode through a compiler, and the first blockchain node will finally execute the smart contract in the form of bytecode in the EVM virtual machine. Then, the above-mentioned type identifier can be the same in high-level language and bytecode smart contract code, or the first type identifier in high-level language smart contract code, and the second type in bytecode smart contract code Type identifier, the first type identifier and the second type identifier can correspond to each other.

在图2所示实施例的基础上,本说明书可以进一步识别收据数据中满足预设条 件的收据内容,从而同时根据交易发起方的用户类型和收据内容对预设条件的满足情况,确定对收据数据的存储方式。因此,上述的步骤208可以改进为:第一区块链节点存储所述收据数据,使所述收据数据中满足预设条件的暴露字段以明文形式存储、其余收据字段以密文形式存储。On the basis of the embodiment shown in Figure 2, this specification can further identify the receipt content in the receipt data that meets the preset conditions, so as to determine the receipt according to the user type of the transaction initiator and the satisfaction of the receipt content to the preset conditions. How the data is stored. Therefore, the above step 208 can be improved as follows: the first blockchain node stores the receipt data, so that the exposed fields in the receipt data that meet the preset conditions are stored in plain text, and the remaining receipt fields are stored in cipher text.

通过将收据数据中的暴露字段与预设条件进行比较,可以将满足预设条件的暴露字段以明文形式存储,而不满足预设条件的暴露字段或其他的收据字段则必然以密文形式存储。其中,预设条件的内容可以包括以下至少之一:相应的收据字段中包含预设内容、相应的收据字段的取值属于预设数值区间等。By comparing the exposed fields in the receipt data with the preset conditions, the exposed fields that meet the preset conditions can be stored in plain text, while the exposed fields or other receipt fields that do not meet the preset conditions must be stored in cipher text. . The content of the preset condition may include at least one of the following: the corresponding receipt field contains the preset content, the value of the corresponding receipt field belongs to a preset numerical interval, and so on.

预设内容可以包括:指定的一个或多个关键词,比如该关键词可以包括预定义的状态变量、预定义的事件函数、用于表示交易执行结果的信息等,使得当某一暴露字段包含作为关键词的状态变量、事件函数或交易执行结果时,可以判定该暴露字段满足预设条件。以交易执行结果为例,交易执行结果可以包括:“success”表示交易成功,“fail”表示交易失败;当关键词为“success”时,包含“success”的暴露字段将采用明文形式存储,而包含“fail”的暴露字段和其他类型的收据字段不允许采用明文形式存储,确保成功的交易才会被查看到并且触发后续操作。The preset content may include: one or more specified keywords. For example, the keywords may include predefined state variables, predefined event functions, information used to indicate the result of transaction execution, etc., so that when an exposed field contains When the state variable, event function, or transaction execution result is used as a keyword, it can be determined that the exposed field meets the preset conditions. Take the transaction execution result as an example, the transaction execution result can include: "success" means the transaction is successful, "fail" means the transaction failed; when the keyword is "success", the exposed fields containing "success" will be stored in plain text, and Exposed fields containing "fail" and other types of receipt fields are not allowed to be stored in plain text, ensuring that successful transactions will be viewed and subsequent operations will be triggered.

预设内容可以包括:预设值。比如该预设值可以为数值,该数值可与状态变量的取值等进行比较,以确定状态变量的取值是否符合预期;再比如该预设值可以为数值、字母、特殊符号等构成的字符串,该字符串可与交易发起方的账户地址、交易目标方的账户地址、事件函数的内容等进行比较,以识别出特定的交易发起方、特定的交易目标方或特定的事件函数等。以预设内容为字符串为例,假定该字符串为交易目标方的账户地址,可使用户在针对特定的交易目标方发起交易且交易类型对应的暴露字段包括To字段时,将To字段采用明文形式存储,而针对其他交易目标方发起交易时,To字段不允许采用明文形式存储,避免泄露隐私。The preset content may include: preset values. For example, the preset value can be a numeric value, which can be compared with the value of a state variable, etc., to determine whether the value of the state variable meets expectations; for another example, the preset value can be composed of numeric values, letters, special symbols, etc. String, which can be compared with the account address of the transaction initiator, the account address of the transaction target, the content of the event function, etc. to identify the specific transaction initiator, specific transaction target or specific event function, etc. . Taking the default content as a string as an example, assuming that the string is the account address of the transaction target, the user can use the To field when the user initiates a transaction for a specific transaction target and the exposed field corresponding to the transaction type includes the To field. It is stored in plain text, and when a transaction is initiated for other transaction targets, the To field is not allowed to be stored in plain text to avoid privacy leakage.

预设数值区间可以表明相关收据字段的隐私保护需求情况,比如在转账场景中,预设数值区间可以为数值较小、隐私保护需求较低的数值区间,使得即便公开相关收据字段也不会造成严重的用户隐私泄露,但可以用于自动触发如DAPP客户端的相关操作,从而在隐私保护与便捷性之间取得一定平衡。因此,当暴露字段的取值处于该预设数值区间时,可以将该暴露字段以明文形式存储。The preset value range can indicate the privacy protection requirements of the relevant receipt fields. For example, in a transfer scenario, the preset value range can be a value range with a smaller value and a lower privacy protection requirement, so that even if the relevant receipt field is disclosed, it will not cause Serious user privacy leakage, but it can be used to automatically trigger related operations such as DAPP client, so as to achieve a certain balance between privacy protection and convenience. Therefore, when the value of the exposed field is within the preset numerical range, the exposed field can be stored in plain text.

在一实施例中,预设条件可以包括收据数据中的所有收据字段对应的通用条件,即收据数据中的任意收据字段被识别为暴露字段时,均被用于与该预设条件进行比较。 例如,当预设条件为“包含预设关键词”时,可以将收据数据中的所有暴露字段与该预设条件所含的关键词进行比较,以确定出包含该关键词的暴露字段,作为满足上述预设条件的暴露字段。In an embodiment, the preset condition may include a general condition corresponding to all receipt fields in the receipt data, that is, when any receipt field in the receipt data is identified as an exposed field, it is used for comparison with the preset condition. For example, when the preset condition is "Contains preset keywords", all the exposed fields in the receipt data can be compared with the keywords contained in the preset conditions to determine the exposed fields containing the keywords, as The exposed fields that meet the above preset conditions.

在一实施例中,预设条件可以包括收据数据中的每一收据字段分别对应的专用条件,即收据数据中的各个收据字段分别存在对应的预设条件,使得确定出的每一暴露字段被用于与对应的预设条件进行比较。不同收据字段对应的预设条件之间相互独立,但可能相同,也可能不同。例如,From字段和To字段对应的预设条件可以为“是否包含预设内容”,且该预设内容可以为预设的账户地址,表明由该账户地址发起或针对该账户地址发起的交易,允许将From字段或To字段以明文形式存储(可以在From字段或To字段属于暴露字段时以明文形式存储)。再例如,Topic字段对应的预设条件可以为“是否属于预设取值区间”,而Topic字段中可以记录相关事件引用的状态变量的取值,譬如转账场景下可以包括代表“转账金额”的状态变量,表明转账金额处于预设取值区间(通常可以为较小金额对应的小额数值区间)时,允许将该转账金额以明文形式存储(可以在Topic字段属于暴露字段时以明文形式存储)。In an embodiment, the preset condition may include a dedicated condition corresponding to each receipt field in the receipt data, that is, each receipt field in the receipt data has a corresponding preset condition, so that each determined exposed field is Used to compare with the corresponding preset conditions. The preset conditions corresponding to different receipt fields are independent of each other, but may be the same or different. For example, the preset condition corresponding to the From field and the To field may be "whether the preset content is included", and the preset content may be a preset account address, indicating a transaction initiated by or directed to the account address. It is allowed to store the From field or To field in plain text (it can be stored in plain text when the From field or To field is an exposed field). For another example, the preset condition corresponding to the Topic field can be "whether it belongs to the preset value range", and the value of the state variable referenced by the related event can be recorded in the Topic field. For example, in a transfer scenario, it can include a value representing "transfer amount" State variable, indicating that the transfer amount is in the preset value range (usually the small value range corresponding to the smaller amount), the transfer amount is allowed to be stored in clear text (it can be stored in clear text when the Topic field is an exposed field) ).

在一实施例中,预设条件可以位于交易中,使得不同交易所采用的预设条件可以存在差异,以满足不同交易所面临的需求差异;当然,不同交易也可以采用相同的预设条件。预设条件的不同可以表现为:预设条件的内容、预设条件适用的收据字段、对暴露字段是否满足预设条件进行判断的处理逻辑中的至少一个维度的差异。In an embodiment, the preset conditions may be located in the transaction, so that the preset conditions adopted by different exchanges may be different to meet the differences in demand faced by different exchanges; of course, different transactions may also use the same preset conditions. The difference in the preset conditions can be expressed as: differences in at least one dimension in the content of the preset conditions, the receipt fields to which the preset conditions apply, and the processing logic for determining whether the exposed fields meet the preset conditions.

在一实施例中,预设条件可以位于交易调用的智能合约中,或者预设条件可以位于交易调用的智能合约所调用的另一智能合约中,使得交易可以通过选取所调用的智能合约,以确定是否使用相应的预设条件。智能合约可由交易发起方自身或其他任意用户预先创建;当然,如果智能合约存在相应的调用条件,那么需要在该调用条件被满足时才能够使得上述交易调用该智能合约,比如该调用条件可以包括:交易发起方属于预设白名单、交易发起方不属于预设黑名单或其他条件。In one embodiment, the preset condition may be located in the smart contract called by the transaction, or the preset condition may be located in another smart contract called by the smart contract called by the transaction, so that the transaction can be selected by selecting the called smart contract to Determine whether to use the corresponding preset conditions. The smart contract can be pre-created by the transaction initiator or any other user; of course, if the smart contract has a corresponding calling condition, then the above-mentioned transaction can call the smart contract only when the calling condition is met. For example, the calling condition may include : The transaction initiator belongs to the preset whitelist, the transaction initiator does not belong to the preset blacklist or other conditions.

在一实施例中,预设条件可以位于系统合约或链代码中,使得该预设条件为适用于区块链上的所有交易的全局条件,而区别于上述的交易或智能合约所含的预设条件,使得即便交易或交易调用的智能合约并未包含预设条件的情况下,可以基于系统合约或链代码中定义的预设条件,并结合交易发起方的用户类型,确定收据字段的存储方式。In an embodiment, the preset condition may be located in the system contract or chain code, so that the preset condition is a global condition applicable to all transactions on the blockchain, and is different from the foregoing transaction or the preset contained in the smart contract. Set conditions so that even if the smart contract invoked by the transaction or transaction does not contain preset conditions, the storage of the receipt field can be determined based on the preset conditions defined in the system contract or chain code and combined with the user type of the transaction initiator the way.

需要指出的是:交易或智能合约所含的预设条件,与链代码或系统合约所含的 预设条件之间并不矛盾:两者可以分别包含不同维度的预设条件,比如预设条件适用的收据字段不同;或者,当两者包含的预设条件之间存在冲突时,可以默认为优先采用交易或智能合约所含的预设条件,或者优先采用链代码或系统合约所含的预设条件,这取决于预定义的选择逻辑。It should be pointed out that there is no contradiction between the preset conditions contained in the transaction or smart contract and the preset conditions contained in the chain code or system contract: the two can contain preset conditions of different dimensions, such as preset conditions. The applicable receipt fields are different; or, when there is a conflict between the preset conditions contained in the two, the preset conditions contained in the transaction or smart contract may be used by default, or the preset conditions contained in the chain code or system contract may be preferred. Set conditions, which depend on the predefined selection logic.

在图2所示实施例的基础上,本说明书可以进一步识别智能合约的代码所含的暴露标识符和交易发起方的用户类型,从而同时根据交易类型对应的暴露字段、暴露标识符标明的字段和交易发起方的用户类型,确定对收据数据的存储方式。因此,上述的步骤208可以改进为:第一区块链节点存储所述收据数据,当交易发起方属于预设用户类型时,使所述收据数据中由所述暴露标识符标明的暴露字段以明文形式存储、其余收据字段以密文形式存储。On the basis of the embodiment shown in Figure 2, this specification can further identify the exposed identifier contained in the smart contract code and the user type of the transaction initiator, thereby simultaneously according to the exposed fields corresponding to the transaction type and the fields indicated by the exposed identifier And the user type of the transaction initiator determines the storage method of the receipt data. Therefore, the above step 208 can be improved to: the first blockchain node stores the receipt data, and when the transaction initiator belongs to the preset user type, the exposed field in the receipt data marked by the exposure identifier is changed to Stored in plain text, and the rest of the receipt fields are stored in cipher text.

前述的代码示例可以基于交易发起方的用户类型实现改进。在上述的代码示例2中,通过在智能合约的代码最前方添加暴露标识符“plain”,使得收据数据中的所有字段均允许以明文形式进行存储,因而如果交易发起方属于预设用户类型,那么对于该智能合约所属交易的交易类型对应的暴露字段,在智能合约的代码被执行后,产生的收据数据中对应的收据内容将以明文形式进行存储,而后续可以针对这些收据内容实施检索操作;例如,当From字段属于上述的暴露字段时,该From字段以明文形式存储后,可以用于统计某一账户所发起的交易量等。The foregoing code example can be improved based on the user type of the transaction initiator. In the code example 2 above, by adding the exposed identifier "plain" to the front of the smart contract code, all fields in the receipt data are allowed to be stored in plain text. Therefore, if the transaction initiator belongs to the preset user type, Then for the exposed fields corresponding to the transaction type of the transaction to which the smart contract belongs, after the code of the smart contract is executed, the corresponding receipt content in the generated receipt data will be stored in plain text, and subsequent retrieval operations can be performed on the receipt content ; For example, when the From field belongs to the above-mentioned exposed field, the From field can be used to count the transaction volume initiated by a certain account after being stored in plain text.

上述暴露标识符plain对应于收据数据中的所有字段;而在其他实施例中,也可以具体指明需要明文存储的字段。比如,通过暴露标识符对From字段进行标注时,只需要针对该From字段进行判断:当该From字段为上述的暴露字段时,在交易发起方属于预设用户类型的情况下,对于智能合约的代码被执行后产生的收据数据,可以将From字段对应的收据内容以明文形式存储,而其他收据内容均以密文形式存储。The above-mentioned exposure identifier plain corresponds to all the fields in the receipt data; in other embodiments, the fields that need to be stored in plain text can also be specified. For example, when annotating the From field with an exposed identifier, only the From field needs to be judged: when the From field is the above-mentioned exposed field, when the transaction initiator belongs to the preset user type, for the smart contract The receipt data generated after the code is executed can store the contents of the receipt corresponding to the From field in plain text, and the contents of other receipts are stored in cipher text.

需要指出的是:在上述的代码示例2及其相关实施例中,由暴露标识符“plain”所标明的字段(所有字段或From字段)为合约级字段,使得第一区块链节点在存储收据数据时,如果交易发起方属于预设用户类型且该From字段为暴露字段,那么第一区块链节点会将收据数据中对应于该合约级字段的所有收据内容以明文形式存储。尤其是,当智能合约的代码中包含多个事件时,合约级字段可以适用于智能合约中的所有事件,那么以From字段为例:当交易发起方属于预设用户类型且From字段为交易类型对应的暴露字段时,对于多个事件分别的产生各自对应的Logs字段,每一Logs字段所含的From字段均会采用明文形式进行存储,而无需针对每一事件分别添加暴露标识符。It should be pointed out that in the above code example 2 and related embodiments, the fields (all fields or From fields) marked by the exposed identifier "plain" are contract-level fields, so that the first blockchain node is storing When receiving the receipt data, if the transaction initiator belongs to the preset user type and the From field is an exposed field, the first blockchain node will store all the receipt contents corresponding to the contract-level field in the receipt data in plain text. In particular, when the code of a smart contract contains multiple events, the contract-level field 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 and the From field is the transaction type When corresponding exposed fields are generated 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.

除了合约级字段之外,暴露标识符标明的字段可以包括:对应于智能合约中定义的至少一个事件的事件级字段,使得第一区块链节点在存储收据数据时,如果交易发起方属于预设用户类型且事件级字段属于交易类型对应的暴露字段,可以确定出收据数据中对应于该至少一个事件的收据内容,并将确定出的收据内容中对应于上述事件级字段的部分以明文形式存储。尤其是,当智能合约中包含多个事件时,可以针对至少一部分事件设定上述的事件级字段,使得这部分事件对应的收据内容中对应于事件级字段的部分以明文形式存储,而这部分事件对应的收据内容中的剩余部分、其余事件对应的收据内容等均以密文形式存储。以From字段为例,在上述的代码示例3中,通过在事件currentPrice对应的事件函数“event currentPrice(int price)”中添加From字段对应的字符from,并且该字符from所采用的暴露标识符区别于前述的plain,而是通过引号对该字符from进行修饰,则代码示例3中的引号相当于前述的暴露标识符,使得From字段被标记为事件级字段,因而当交易发起方属于预设用户类型且From字段属于交易类型对应的暴露字段时,在该事件对应产生的Logs字段中,From字段将以明文形式进行存储。除了上述事件currentPrice之外,如果智能合约的代码还包含另一事件,那么上述的事件级字段不会影响该另一事件、该另一事件对应的收据内容将以密文形式进行存储。而在上述的代码示例4中,通过在事件currentPrice对应的事件函数“event currentPrice(int price)”之前添加暴露标识符“plain”,使得事件级字段包括该事件currentPrice对应的日志Logs中的所有字段,譬如前述的From字段、To字段、Topic字段、Log Data字段等,当交易发起方属于预设用户类型时,可以根据交易类型确定出这些字段中的暴露字段,并将确定出的暴露字段以明文形式存储。In addition to the contract-level fields, the fields indicated by the exposure identifier may include: event-level fields corresponding to at least one event defined in the smart contract, so that when the first blockchain node stores the receipt data, if the transaction initiator belongs to the pre- Assuming that the user type and the event-level field belong to the exposed field corresponding to the transaction type, the receipt content corresponding to the at least one event in the receipt data can be determined, and the part of the determined receipt content corresponding to the above-mentioned event-level field can be in plaintext form storage. In particular, when the smart contract contains multiple events, the above event-level fields can be set for at least some of the events, so that the part of the receipt content corresponding to these events that corresponds to the event-level field is stored in plain text, and this part The remaining part of the receipt content corresponding to the event and the receipt content corresponding to the remaining events are stored in cipher text. Take the From field as an example. In the above code example 3, 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 by the character from is different For the aforementioned plain, the character from is modified by quotation marks. The quotation marks in code example 3 are equivalent to the aforementioned exposed identifier, so that the From field is marked as an event-level field. Therefore, when the transaction initiator belongs to the default user When the type and the From field belongs to the exposed field corresponding to the transaction type, the From field will be stored in plain text in the Logs field corresponding to the event. In addition to the aforementioned event currentPrice, if the code of the smart contract also contains another event, the aforementioned event-level field will not affect the other event, and the content of the receipt corresponding to the other event will be stored in ciphertext. In the above code example 4, by adding the exposure identifier "plain" before the event function "event currentPrice(int price)" corresponding to the event currentPrice, the event-level fields include all the fields in the log Logs corresponding to the event currentPrice For example, the aforementioned From field, To field, Topic field, Log Data field, etc., when the transaction initiator belongs to the preset user type, the exposed fields in these fields can be determined according to the transaction type, and the determined exposed fields are Stored in clear text.

由于暴露标识符为智能合约的编程语言中所定义的全局性标识,因而只要在智能合约中写入暴露标识符后,就难以修改该暴露标识符所标明的字段。因此,通过结合对用户类型和交易类型的考量,可以根据交易发起方所属的用户类型、交易类型对应的暴露字段,更准确地选取采用明文形式进行存储的字段,而并非仅基于暴露标识符进行确定,从而在不同用户调用同一智能合约或通过不同类型的交易调用同一智能合约时,使得明文存储的字段配合于用户类型和交易类型,可使针对收据数据的存储方式满足不同情形下的实际需求,能够兼顾隐私保护和功能扩展。Since the exposed identifier is a global identifier defined in the programming language of the smart contract, it is difficult to modify the fields marked by the exposed identifier as long as the exposed identifier is written in the smart contract. Therefore, by combining the consideration of user type and transaction type, it is possible to more accurately select the fields stored in plain text based on the user type of the transaction initiator and the exposed fields corresponding to the transaction type, rather than just based on the exposed identifier. Determined, so that when different users call the same smart contract or call the same smart contract through different types of transactions, the fields stored in plaintext are matched to the user type and transaction type, so that the storage method of receipt data can meet the actual needs in different situations , Can take into account privacy protection and function expansion.

在图2所示实施例的基础上,本说明书可以进一步识别智能合约的代码所含的暴露标识符和智能合约所含的事件函数,从而同时根据交易类型对应的暴露字段、暴露标识符标明的字段和智能合约所含的特殊事件函数,确定对收据数据的存储方式。因此,上述的步骤208可以改进为:第一区块链节点存储所述收据数据,使对应于所述特殊事 件函数的日志中的至少一部分收据内容以明文形式存储、所述收据数据的其余内容以密文形式存储,所述至少一部分收据内容包括由所述暴露标识符标明的暴露字段。暴露标识符为智能合约的编程语言中所定义的全局性标识,适用于采用该编程语言编写的所有智能合约。因此,通过在编程语言中定义暴露标识符,使得在任一智能合约的代码使用该暴露标识符,即可实现对收据数据的存储控制。例如,用户在编写智能合约的代码时,可以通过在代码中添加暴露标识符来标明一个或多个字段,以表明用户希望收据数据中对应于这部分字段的收据内容采用明文存储,而剩余未标注暴露标识符的字段所对应的收据内容不允许采用明文存储、必须采用密文存储,以实现相应的隐私保护。换言之,对于暴露标识符标明的字段,从编程语言的维度上而言,允许将相应的收据内容以明文形式存储;但是,本说明书还可以进一步考量交易类型和智能合约所含的事件函数,并从编程语言、交易类型和事件函数的维度上实现综合考量,确定是否将暴露标识符标明的字段所对应的收据内容以明文形式存储。On the basis of the embodiment shown in Figure 2, this specification can further identify the exposure identifier contained in the code of the smart contract and the event function contained in the smart contract, so that at the same time, according to the exposed field corresponding to the transaction type, the exposure identifier marked Fields and special event functions included in the smart contract determine how to store receipt data. Therefore, the above step 208 can be improved as: the first blockchain node stores the receipt data, so that at least part of the receipt content in the log corresponding to the special event function is stored in plaintext, and the rest of the receipt data It is stored in a ciphertext form, and the at least a part of the receipt content includes an exposed field indicated by the exposure identifier. The exposed identifier is a global identifier defined in the programming language of the smart contract and is applicable to all smart contracts written in this programming language. Therefore, by defining the exposure identifier in a programming language, so that the code of any smart contract uses the exposure identifier, the storage control of the receipt data can be realized. For example, when a user writes the code of a smart contract, he can add an exposed identifier to the code to indicate one or more fields to indicate that the user wants the receipt content corresponding to this part of the field in the receipt data to be stored in plain text, and the remaining The content of the receipt corresponding to the field marked with the exposed identifier is not allowed to be stored in plain text, but must be stored in cipher text to achieve corresponding privacy protection. In other words, for the fields marked by the exposed identifier, from the perspective of the programming language, the corresponding receipt content is allowed to be stored in plain text; however, this manual can further consider the transaction type and the event function contained in the smart contract, and Comprehensive consideration is achieved from the dimensions of programming language, transaction type, and event function to determine whether to store the content of the receipt corresponding to the field indicated by the exposure identifier in plain text.

前述的代码示例可以基于智能合约所含的事件函数实现改进。在上述的代码示例2中,在智能合约的代码最前方添加暴露标识符plain,仅从编程语言的维度而言,该暴露标识符plain表明:使得智能合约的代码被执行后,产生的收据数据中的所有字段均允许以明文形式进行存储,那么后续可以针对这些字段中的收据内容实施检索操作,比如对于From字段而言,可以用于统计某一账户所发起的交易量等。而通过进一步结合交易类型和事件函数等维度,对收据数据的存储方案可能存在不同。The aforementioned code example can be improved based on the event function contained in the smart contract. In the above code example 2, the exposed identifier plain is added to the front of the code of the smart contract. From the perspective of the programming language, the exposed identifier plain indicates: the receipt data generated after the code of the smart contract is executed All fields in are allowed to be stored in plain text, so subsequent retrieval operations can be performed on the receipt content in these fields. For example, the From field can be used to count the transaction volume initiated by an account. By further combining dimensions such as transaction types and event functions, there may be differences in storage solutions for receipt data.

在智能合约的代码中,暴露标识符可以标明一个或多个字段,这些字段在收据数据中存在对应的收据内容。不同类型的交易往往存在不同的隐私保护需求,可以允许相应的暴露字段以明文形式存储。而特殊事件函数被执行后,收据数据中包含对应于特殊事件函数的日志,该日志实际为收据数据中的部分收据内容。而本说明书中通过对暴露标识符、交易类型和特殊事件函数进行综合考量,可以筛选出上述三部分收据内容的交叉内容,并针对该交叉内容实施明文存储,收据数据的其余内容均采用密文存储。In the code of the smart contract, the exposed identifier can indicate one or more fields, and these fields have corresponding receipt content in the receipt data. Different types of transactions often have different privacy protection requirements, and the corresponding exposed fields can be allowed to be stored in plain text. After the special event function is executed, the receipt data contains a log corresponding to the special event function, which is actually part of the receipt content in the receipt data. In this manual, by comprehensively considering the exposure identifier, transaction type, and special event function, the cross content of the above three parts of receipt content can be filtered out, and the cross content can be stored in plain text. The rest of the receipt data is in cipher text. storage.

由于暴露标识符为智能合约的编程语言中所定义的全局性标识,因而只要在智能合约中写入暴露标识符后,就难以修改该暴露标识符所标明的字段。而交易类型与编程语言无关,可由用户根据实际需求进行选择;同时,特殊事件函数的定义也不一定基于编程语言实现,比如在基于特殊事件函数列表等方式记录特殊事件函数时,即便智能合约中包含的某一事件函数原本属于特殊事件函数,也可以通过对特殊事件函数列表进行更改的方式,将原有的特殊事件函数更新为普通事件函数,从而避免该事件函数产生 的日志以明文形式存储,或者将原有的普通事件函数更新为特殊事件函数,使得该事件函数产生的日志中的至少一部分内容以明文形式存储。Since the exposed identifier is a global identifier defined in the programming language of the smart contract, it is difficult to modify the fields marked by the exposed identifier as long as the exposed identifier is written in the smart contract. The transaction type has nothing to do with the programming language and can be selected by the user according to the actual needs. At the same time, the definition of the special event function is not necessarily based on the programming language. For example, when recording the special event function based on the special event function list, even in the smart contract A certain event function included is originally a special event function. You can also update the original special event function to a normal event function by changing the list of special event functions, so as to prevent the log generated by the event function from being stored in plain text , Or update the original ordinary event function to a special event function, so that at least part of the content in the log generated by the event function is stored in plain text.

以上述的代码示例2为例:假定事件currentPrice原本并未记录于特殊事件函数列表中,即事件currentPrice对应于普通事件函数,那么即便在智能合约的代码中添加了暴露标识符plain,事件currentPrice产生的日志中的各个字段(包括暴露字段)仍以密文形式存储。但是,如果将事件currentPrice添加至特殊事件函数列表中,那么代码示例2不需要调整的情况下,即可使得事件currentPrice对应的日志中的暴露字段以明文形式存储;比如,当From字段和To字段为暴露字段时,事件currentPrice所产生日志中的From字段和To字段将以明文形式存储,而其余字段则以密文形式存储。Take the above code example 2 as an example: assuming that the event currentPrice was not originally recorded in the special event function list, that is, the event currentPrice corresponds to a normal event function, then even if the exposed identifier plain is added to the smart contract code, the event currentPrice is generated All fields in the log (including exposed fields) are still stored in ciphertext. However, if the event currentPrice is added to the list of special event functions, then the exposed fields in the log corresponding to the event currentPrice can be stored in plain text without the need to adjust the code example 2; for example, when the From field and the To field To expose fields, the From field and To field in the log generated by the event currentPrice will be stored in plain text, while the remaining fields will be stored in cipher text.

需要指出的是:在上述的代码示例2中,通过在代码最前方声明“plain”,该暴露标识符“plain”所标明的字段为收据数据中的所有字段,且这些字段均为合约级字段,使得第一区块链节点在存储收据数据时,收据数据中所有对应于该合约级字段的收据内容,均被允许以明文形式存储。当然,如果代码示例2中通过暴露标识符标注了譬如From字段,那么该From字段为上述的合约级字段,当该From字段进一步属于交易类型对应的暴露字段时,可使第一区块链节点在存储收据数据时,收据数据中所有对应于该From字段的收据内容,均被允许以明文形式存储。It should be pointed out that: in the code example 2 above, by declaring "plain" at the front of the code, the fields marked by the exposed identifier "plain" are all fields in the receipt data, and these fields are contract-level fields , So that when the first blockchain node stores the receipt data, all the receipt contents corresponding to the contract-level field in the receipt data are allowed to be stored in plain text. Of course, if the From field is marked with the exposed identifier in Code Example 2, then the From field is the contract-level field mentioned above. When the From field is further an exposed field corresponding to the transaction type, the first blockchain node can be used When storing receipt data, all the receipt contents corresponding to the From field in the receipt data are allowed to be stored in plain text.

当智能合约的代码中包含多个事件函数时,在多个事件函数分别产生的各自对应的Logs字段中,均可能存在属于合约级字段的暴露字段;进一步地,可以通过识别各个事件函数的类型为普通事件函数或特殊事件函数,从而将所有特殊事件函数所产生的日志中属于合约级字段的暴露字段以明文形式存储。例如,智能合约可以包括下述的代码示例5:When the code of a smart contract contains multiple event functions, in the respective Logs fields generated by the multiple event functions, there may be exposed fields belonging to contract-level fields; further, the type of each event function can be identified It is a normal event function or a special event function, so that the exposed fields belonging to the contract-level fields in the logs generated by all special event functions are stored in plaintext. For example, a smart contract can include the following code example 5:

plain Contract Example{plain Contract Example{

int price;int price;

int price1;int price1;

event currentPrice1(int price);event currentPrice1(int price);

event currentPrice2(int price1);event currentPrice2(int price1);

在上述的代码示例5中,与代码示例2相类似地,暴露标识符“plain”位于智能合约的代码最前方,使得收据数据中的所有字段均被标注为合约级字段;同时,智能 合约中包含了事件currentPrice1和事件currentPrice2:假定From字段为交易类型对应的暴露字段,并且事件currentPrice1对应于特殊事件函数列表中定义的特殊事件函数、事件currentPrice2对应于普通事件函数,那么在事件currentPrice1和事件currentPrice2分别产生的日志Log1、Log2中,日志Log1包含的From字段以明文形式存储、日志Log2包含的From字段以密文形式存储;类似地,日志Log1中属于暴露字段的其他字段也以明文形式存储、非暴露字段以密文形式存储,而日志Log2的所有字段均以密文形式存储。并且,如果通过对特殊事件函数列表进行更新后,将事件currentPrice2更新为对应于特殊事件函数,那么日志Log2包含的属于暴露字段的所有字段将以明文形式存储,而无需对智能合约的代码做任何变动。In the above code example 5, similar to the code example 2, the exposed identifier "plain" is located at the forefront of the code of the smart contract, so that all fields in the receipt data are marked as contract-level fields; at the same time, in the smart contract Contains events currentPrice1 and event currentPrice2: Assuming that the From field is the exposed field corresponding to the transaction type, and the event currentPrice1 corresponds to the special event function defined in the special event function list, and the event currentPrice2 corresponds to the normal event function, then in the event currentPrice1 and event currentPrice2 In the generated logs Log1 and Log2, the From field contained in log Log1 is stored in plain text, and the From field contained in log Log2 is stored in cipher text; similarly, other fields in log Log1 that are exposed fields are also stored in plain text. Non-exposed fields are stored in cipher text, and all fields of log Log2 are stored in cipher text. Moreover, if the event currentPrice2 is updated to correspond to the special event function by updating the list of special event functions, all the fields that belong to the exposed fields contained in the log Log2 will be stored in plain text, without the need to do anything to the smart contract code change.

对于上述的合约级字段而言,可以通过前述的类型标识符来标明智能合约所含的事件函数是否为特殊事件函数。例如,可以将上述的代码示例5调整为下述的代码示例6:For the aforementioned contract-level fields, the aforementioned type identifier can be used to indicate whether the event function included in the smart contract is a special event function. For example, the above code sample 5 can be adjusted to the following code sample 6:

plain Contract Example{plain Contract Example{

int price;int price;

int price1;int price1;

event currentPrice1 expose(int price);event currentPrice1 expose(int price);

event currentPrice2(int price1);event currentPrice2(int price1);

在上述的代码示例6中,与代码示例2相类似地,合约级字段包括收据数据中的所有字段;同时,智能合约中包含了事件currentPrice1和事件currentPrice2:由于事件currentPrice1在包含如前所述的类型标识符expose,使得该事件currentPrice1被标注为对应于特殊事件函数,而事件currentPrice2并未包含类型标识符expose,使得事件currentPrice2被标注为对应于普通事件函数,那么在事件currentPrice1和事件currentPrice2分别产生的日志Log1、Log2中,日志Log1中对应于交易类型的所有暴露字段均以明文形式存储、日志Log2包含的所有字段均以密文形式存储。In the above code example 6, similar to the code example 2, the contract-level fields include all fields in the receipt data; at the same time, the smart contract contains the event currentPrice1 and the event currentPrice2: because the event currentPrice1 contains the above mentioned The type identifier expose causes the event currentPrice1 to be marked as corresponding to the special event function, while the event currentPrice2 does not contain the type identifier expose, so that the event currentPrice2 is marked as corresponding to the normal event function, then the event currentPrice1 and event currentPrice2 are generated respectively In the logs Log1 and Log2, all the exposed fields corresponding to the transaction type in the log Log1 are stored in plain text, and all the fields contained in the log Log2 are stored in cipher text.

虽然类型标识符与暴露标识符相类似的,都是智能合约的编程语言中所定义的全局性标识,但是暴露标识符作用于合约级字段、类型标识符作用于事件函数,使得通过将暴露标识符与类型标识符配合使用,仅需单次添加暴露标识符即可设定形成上述的合约级字段,并且进而可以灵活地标注希望对合约级字段进行明文存储的事件函数,尤 其是当智能合约中包含的事件函数的数量较多、事件函数中涉及的字段的数量较多时,仅需添加类似于上述的“plain”即可,无需针对每一事件函数分别实施设定操作,可以简化代码逻辑、防止错标或漏标。Although the type identifier and the exposed identifier are similar, they are both global identifiers defined in the programming language of the smart contract, but the exposed identifier acts on the contract-level fields and the type identifier acts on the event function, so that by In conjunction with the type identifier, you only need to add a single exposure identifier to set the contract-level fields mentioned above, and then you can flexibly mark the event functions that you want to store the contract-level fields in plaintext, especially when smart contracts When there are a large number of event functions included in the event function and the number of fields involved in the event function is large, you only need to add a "plain" similar to the above. There is no need to implement settings for each event function separately, which can simplify the code logic , Prevent mislabeling or missing labels.

除了合约级字段之外,暴露标识符标明的字段可以包括:对应于智能合约中定义的至少一个事件的事件级字段,使得第一区块链节点在存储收据数据时,可以确定出所述至少一个事件对应的特殊事件函数产生的日志,并将确定出的日志中属于事件级字段的暴露字段以明文形式存储。尤其是,当智能合约中包含多个事件时,可以针对至少一部分事件设定上述的事件级字段,使得这部分事件对应的日志中属于事件级字段的暴露字段以明文形式存储,而这部分事件对应的日志中的其他字段、其余事件对应的收据内容均以密文形式存储。以From字段为例,可以将上述的代码示例6调整为下述的代码示例7:In addition to the contract-level fields, the fields marked by the exposure identifier may include: event-level fields corresponding to at least one event defined in the smart contract, so that the first blockchain node can determine the at least one event when storing the receipt data. A log generated by a special event function corresponding to an event, and the determined exposed fields belonging to the event-level field in the log are stored in plain text. In particular, when the smart contract contains multiple events, the above event-level fields can be set for at least some of the events, so that the exposed fields belonging to the event-level fields in the logs corresponding to these events are stored in plain text, and this part of the events Other fields in the corresponding log and the contents of receipts corresponding to other events are stored in cipher text. Taking the From field as an example, the above code example 6 can be adjusted to the following code example 7:

Contract Example{Contract Example{

int price;int price;

int price1;int price1;

event currentPrice1(“from”,int price);event currentPrice1("from",int price);

event currentPrice2(int price1);event currentPrice2(int price1);

在上述的代码示例7中,事件currentPrice1虽然未添加暴露标识符“plain”,但是包含了内容“from”,该内容“from”对应于From字段,用于表明事件currentPrice1所产生日志中的From字段需要以明文形式存储,因而该内容“from”既属于上述的暴露标识符,又标明了需要明文存储的From字段。并且,由于内容“from”位于事件currentPrice1中,因而From字段为事件级字段,使得当From字段为交易类型对应的暴露字段且该事件currentPrice1对应于特殊事件函数时,在该事件currentPrice1对应产生的日志Logs中,From字段将以明文形式进行存储、其他字段以密文形式存储。而对于代码示例7所含的另一事件currentPrice2,由于并未针对该事件currentPrice2添加暴露标识符,因而不论该事件currentPrice2对应于特殊事件函数或普通事件函数,所产生的日志Logs均以密文形式存储。In the above code example 7, although the event currentPrice1 does not add the exposed identifier "plain", it contains the content "from". The content "from" corresponds to the From field and is used to indicate the From field in the log generated by the event currentPrice1 It needs to be stored in plain text, so the content "from" not only belongs to the above exposed identifier, but also indicates the From field that needs to be stored in plain text. Moreover, since the content "from" is in the event currentPrice1, the From field is an event-level field, so that when the From field is an exposed field corresponding to the transaction type and the event currentPrice1 corresponds to a special event function, the log generated in the event currentPrice1 corresponds to In Logs, the From field will be stored in plain text, and other fields will be stored in cipher text. As for the other event currentPrice2 contained in code example 7, since no exposure identifier is added for the event currentPrice2, regardless of whether the event currentPrice2 corresponds to a special event function or a normal event function, the generated log Logs are in ciphertext form storage.

上述的关键词“from”指明了将From字段设定为事件级字段;而在其他实施例中,也可以并不指明具体的字段。例如,可以将上述的代码示例6调整为下述的代码示 例8:The above keyword "from" indicates that the From field is set as an event-level field; however, in other embodiments, the specific field may not be specified. For example, the above code example 6 can be adjusted to the following code example 8:

Contract Example{Contract Example{

int price;int price;

int price1;int price1;

plain event currentPrice1(int price);plain event currentPrice1(int price);

event currentPrice2(int price1);event currentPrice2(int price1);

在上述的代码示例8中,通过在事件currentPrice1之前添加暴露标识符“plain”,可以将该事件currentPrice1所产生的日志中的所有字段均作为上述的事件级字段,譬如前述的From字段、To字段、Topic字段、Log Data字段等。那么,当该事件currentPrice1对应于特殊事件函数时,可以从该事件currentPrice1所产生日志中的确定出既属于上述的事件级字段又属于交易类型对应的暴露字段的日志字段,以采用明文形式存储;如果上述的From字段、To字段、Topic字段、Log Data字段等均为暴露字段,那么相当于将该事件currentPrice1对应的所有收据内容(比如产生的日志)均以明文形式存储。In the above code example 8, by adding the exposure identifier "plain" before the event currentPrice1, all the fields in the log generated by the event currentPrice1 can be used as the aforementioned event-level fields, such as the aforementioned From field and To field. , Topic field, Log Data field, etc. Then, when the event currentPrice1 corresponds to a special event function, the log field that belongs to both the above event-level field and the exposed field corresponding to the transaction type can be determined from the log generated by the event currentPrice1, and stored in plain text; If the above-mentioned From field, To field, Topic field, Log Data field, etc. are all exposed fields, it is equivalent to storing all receipt content (such as the generated log) corresponding to the event currentPrice1 in plain text.

在上述的代码示例7-8对应的实施例中,即对于事件级字段而言,可以通过特殊事件函数列表或者类型标识符的方式识别智能合约所含的事件函数是否为特殊事件函数,此处不再一一赘述。In the embodiment corresponding to the above code examples 7-8, that is, for event-level fields, whether the event function contained in the smart contract is a special event function can be identified by means of a special event function list or type identifier. Do not repeat them one by one.

在图2所示实施例的基础上,本说明书可以进一步识别智能合约的代码所含的暴露标识符和收据数据中满足预设条件的收据内容,从而同时根据交易类型对应的暴露字段、暴露标识符标明的字段和收据内容对预设条件的满足情况,确定对收据数据的存储方式。因此,上述的步骤208可以改进为:第一区块链节点存储所述收据数据,使所述收据数据中由所述暴露标识符标明且满足预设条件的暴露字段以明文形式存储、其余收据字段以密文形式存储。On the basis of the embodiment shown in Figure 2, this specification can further identify the exposure identifier contained in the smart contract code and the receipt content in the receipt data that meets the preset conditions, thereby simultaneously according to the exposure field and exposure identifier corresponding to the transaction type The fields marked by the symbol and the content of the receipt meet the preset conditions and determine the storage method of the receipt data. Therefore, the above step 208 can be improved to: the first blockchain node stores the receipt data, so that the exposed fields in the receipt data that are marked by the exposure identifier and meet the preset conditions are stored in plain text, and the remaining receipts The fields are stored in cipher text.

前述的代码示例可以基于收据数据中满足预设条件的收据内容实现改进。在上述的代码示例2中,通过在智能合约的代码最前方添加暴露标识符plain,使得智能合约的代码被执行后,对于该智能合约所属交易的交易类型对应的暴露字段,产生的收据数据中对应于上述暴露字段且满足预设条件的收据内容均以明文形式进行存储。The foregoing code example can be improved based on the receipt content that meets the preset conditions in the receipt data. In the above code example 2, by adding the exposing identifier plain to the front of the smart contract code, after the smart contract code is executed, for the exposed fields corresponding to the transaction type of the smart contract to which the transaction belongs, the generated receipt data The contents of the receipt corresponding to the above exposed fields and meeting the preset conditions are all stored in plain text.

当然,在其他实施例中,也可以具体指明需要明文存储的字段。比如,通过暴露标识符对From字段进行标注时,可以仅对该From字段进行判断:如果From字段为 该智能合约所属交易的交易类型对应的暴露字段,那么在智能合约的代码被执行后,产生的收据数据中满足预设条件的From字段对应的收据内容以明文形式进行存储,而后续可以针对上述明文存储的From字段中的收据内容实施检索操作,比如可以统计某一账户所发起的交易量等;而除了From字段之前的其他字段,则均以密文形式存储。Of course, in other embodiments, the fields that need to be stored in plaintext can also be specified. For example, when annotating the From field with an exposed identifier, only the From field can be judged: if the From field is the exposed field corresponding to the transaction type of the transaction to which the smart contract belongs, then after the code of the smart contract is executed, it will be generated The content of the receipt corresponding to the From field that meets the preset conditions in the receipt data is stored in plain text, and subsequent retrieval operations can be performed on the content of the receipt in the From field stored in plain text, for example, the transaction volume initiated by a certain account can be counted And so on; except for the other fields before the From field, they are all stored in cipher text.

需要指出的是:在上述的代码示例2及其相关实施例中,由暴露标识符“plain”所标明的字段(所有字段或From字段)为合约级字段,使得第一区块链节点在存储收据数据时,如果该合约级字段为暴露字段,那么第一区块链节点会将收据数据中对应于该合约级字段且满足预设条件的所有收据内容以明文形式存储。尤其是,当智能合约的代码中包含多个事件时,合约级字段可以适用于智能合约中的所有事件,那么以From字段为例:当From字段为合约级字段以及交易类型对应的暴露字段时,对于多个事件分别的产生各自对应的Logs字段,每一Logs字段所含的From字段可以分别与预设条件进行比较,从而将满足该预设条件的From字段以明文形式进行存储,而无需针对每一事件分别添加暴露标识符。It should be pointed out that in the above code example 2 and related embodiments, the fields (all fields or From fields) marked by the exposed identifier "plain" are contract-level fields, so that the first blockchain node is storing When receiving the receipt data, if the contract-level field is an exposed field, the first blockchain node will store all the receipt contents in the receipt data that correspond to the contract-level field and meet the preset conditions in plain text. In particular, when the code of a smart contract contains multiple events, the contract-level field can be applied to all events in the smart contract. Take the From field as an example: when the From field is a contract-level field and the exposed field corresponding to the transaction type For multiple events to generate their corresponding Logs fields, the From field contained in each Logs field can be compared with preset conditions, so that the From field that meets the preset conditions is stored in plain text without Add an exposure identifier for each event.

除了合约级字段之外,暴露标识符标明的字段可以包括:对应于智能合约中定义的至少一个事件的事件级字段,使得第一区块链节点在存储收据数据时,如果事件级字段属于交易类型对应的暴露字段,可以确定出收据数据中对应于该至少一个事件的收据内容,并将确定出的收据内容中对应于上述事件级字段且满足预设条件的部分以明文形式存储。尤其是,当智能合约中包含多个事件时,可以针对至少一部分事件设定上述的事件级字段,使得这部分事件对应的收据内容中对应于事件级字段且满足预设条件的部分以明文形式存储,而这部分事件对应的收据内容中的剩余部分、其余事件对应的收据内容等均以密文形式存储。以From字段为例,在上述的代码示例3中,通过在事件currentPrice对应的事件函数“event currentPrice(int price)”中添加From字段对应的字符from,并且该字符from所采用的暴露标识符区别于前述的plain,而是通过引号对该字符from进行修饰,则代码示例3中的引号相当于前述的暴露标识符,将From字段配置为事件级字段,使得当From字段属于交易类型对应的暴露字段时,在该事件对应产生的Logs字段中,From字段可以在满足预设条件的情况下以明文形式进行存储,否则From字段仍将以密文形式存储。除了上述事件currentPrice之外,如果智能合约的代码还包含另一事件,那么上述的“from”不会影响该另一事件、该另一事件对应的收据内容将以密文形式进行存储,除非存在针对该另一事件而添加的“from”。而在上述的代码示例4中,通过在事件currentPrice对应的事件函数“event currentPrice(int price)”之前添加暴露标识符“plain”,而区别于代码示例3中添加的“from”,使得此处并未指 明事件级字段为From字段,那么可以将事件currentPrice所产生的日志中的所有字段均作为上述的事件级字段,譬如前述的From字段、To字段、Topic字段、Log Data字段等,这些字段被均用于与预设条件进行比较,使得满足该预设条件的字段以明文形式存储、未满足预设条件的字段以密文形式存储;如果前述的From字段、To字段、Topic字段、Log Data字段等均满足预设条件,那么这些字段均以明文形式存储,相当于将该事件currentPrice对应的所有收据内容均以明文形式存储。In addition to the contract-level fields, the fields indicated by the exposure identifier may include: event-level fields corresponding to at least one event defined in the smart contract, so that when the first blockchain node stores the receipt data, if the event-level field belongs to the transaction The exposed field corresponding to the type can determine the receipt content corresponding to the at least one event in the receipt data, and store the determined part of the receipt content corresponding to the event-level field and meeting preset conditions in plain text. In particular, when the smart contract contains multiple events, the above event-level fields can be set for at least some of the events, so that the part of the receipt content corresponding to these events that corresponds to the event-level field and meets the preset conditions is in plain text Store, and the remaining part of the receipt content corresponding to this part of the event and the receipt content corresponding to the remaining events are stored in cipher text. Take the From field as an example. In the above code example 3, 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 by the character from is different For the aforementioned plain, the character from is modified by quotation marks. The quotation marks in code example 3 are equivalent to the aforementioned exposure identifier, and the From field is configured as an event-level field, so that when the From field belongs to the exposure corresponding to the transaction type In the Logs field corresponding to the event, the From field can be stored in plain text when the preset conditions are met, otherwise the From field will still be stored in cipher text. In addition to the above event currentPrice, if the code of the smart contract also contains another event, then the above “from” will not affect the other event, and the receipt content corresponding to the other event will be stored in ciphertext unless it exists "From" added for this other event. In the above code example 4, the exposure identifier "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 example 3, so that It is not specified that the event-level field is the From field, so all fields in the log generated by the event currentPrice can be used as the above-mentioned event-level fields, such as the aforementioned From field, To field, Topic field, Log Data field, etc. Are used to compare with preset conditions, so that fields that meet the preset conditions are stored in plain text, and fields that do not meet the preset conditions are stored in cipher text; if the aforementioned From field, To field, Topic field, Log If the Data field meets the preset conditions, these fields are stored in plain text, which is equivalent to storing all the contents of the receipt corresponding to the event currentPrice in plain text.

在图2所示实施例的基础上,本说明书可以进一步识别交易发起方的用户类型和智能合约所含的事件函数,从而同时根据交易类型对应的暴露字段、交易发起方的用户类型和智能合约所含的特殊事件函数,确定对收据数据的存储方式。因此,上述的步骤208可以改进为:第一区块链节点存储所述收据数据,当交易发起方属于预设用户类型时,使对应于所述特殊事件函数的日志中的暴露字段以明文形式存储、所述收据数据的其余内容以密文形式存储。在保护用户隐私的前提下,通过对交易类型予以识别,可以根据不同类型的交易对于隐私保护的差异化需求,确定出允许明文存储的暴露字段;进一步地,不同类型的用户对于隐私保护的需求并不相同,比如当交易发起方属于预设用户类型时,允许通过暴露部分收据内容来触发DAPP客户端等实施相关后续操作,以提升便捷度,而其他类型的用户可能不允许暴露隐私信息;更进一步地,即便对于预设用户类型的交易发起方而言,仍然在不同场景下存在差异化的隐私保护需求,可以根据交易调用的智能合约所含的事件函数的类型,在存储过程中体现出不同类型的事件函数对于隐私保护的差异化需求,例如特殊事件函数涉及的暴露字段以明文形式存储,而特殊事件函数涉及的非暴露字段、普通事件函数所涉及的所有收据字段等,均以密文形式存储,具有较高的灵活性。On the basis of the embodiment shown in Figure 2, this specification can further identify the user type of the transaction initiator and the event function contained in the smart contract, thereby simultaneously according to the exposed fields corresponding to the transaction type, the user type of the transaction initiator, and the smart contract The special event function included determines the storage method of the receipt data. Therefore, the above step 208 can be improved as: the first blockchain node stores the receipt data, and when the transaction initiator belongs to the preset user type, the exposed field in the log corresponding to the special event function is made in plain text The remaining content of the receipt data is stored in cipher text. Under the premise of protecting user privacy, by identifying transaction types, the exposed fields that allow plaintext storage can be determined according to the differentiated needs of different types of transactions for privacy protection; further, the needs of different types of users for privacy protection It is not the same. For example, when the transaction initiator belongs to the preset user type, it is allowed to trigger the DAPP client to implement related follow-up operations by exposing part of the receipt content to improve convenience, while other types of users may not be allowed to expose private information; Furthermore, even for transaction initiators with preset user types, there are still differentiated privacy protection requirements in different scenarios, which can be reflected in the storage process according to the type of event function contained in the smart contract called by the transaction Different types of event functions have differentiated requirements for privacy protection. For example, the exposed fields involved in special event functions are stored in plain text, while the non-exposed fields involved in special event functions and all receipt fields involved in common event functions are all stored in Stored in ciphertext form, with high flexibility.

在图2所示实施例的基础上,本说明书可以进一步识别交易发起方的用户类型和收据数据中满足预设条件的收据内容,从而同时根据交易类型对应的暴露字段、交易发起方的用户类型和收据内容对预设条件的满足情况,确定对收据数据的存储方式。因此,上述的步骤208可以改进为:第一区块链节点存储所述收据数据,当交易发起方属于预设用户类型时,所述收据数据中满足预设条件的暴露字段以明文形式存储、其余收据字段以密文形式存储。在保护用户隐私的前提下,通过对交易类型予以识别,可以根据不同类型的交易对于隐私保护的差异化需求,确定出允许明文存储的暴露字段;进一步地,不同类型的用户对于隐私保护的需求并不相同,比如当交易发起方属于预设用户类型时,允许通过暴露部分收据内容来触发DAPP客户端等实施相关后续操作,以提升便捷度,而其他类型的用户可能不允许暴露隐私信息;更进一步地,即便对于预设用户 类型的交易发起方而言,仍然在不同场景下存在差异化的隐私保护需求,可以根据暴露字段对预设条件的满足情况,在存储过程中体现出对隐私保护的差异化需求和处理,例如:通过将收据数据中的暴露字段与预设条件进行比较,可以将满足预设条件的暴露字段以明文形式存储,而不满足预设条件的暴露字段或其他的收据字段则必然以密文形式存储。On the basis of the embodiment shown in Figure 2, this specification can further identify the user type of the transaction initiator and the receipt content in the receipt data that meets the preset conditions, thereby simultaneously according to the exposed fields corresponding to the transaction type and the user type of the transaction initiator And the content of the receipt to meet the preset conditions, determine the storage method of the receipt data. Therefore, the above step 208 can be improved as follows: the first blockchain node stores the receipt data, and when the transaction initiator belongs to the preset user type, the exposed fields in the receipt data that meet the preset conditions are stored in plain text, The remaining receipt fields are stored in cipher text. Under the premise of protecting user privacy, by identifying transaction types, the exposed fields that allow plaintext storage can be determined according to the differentiated needs of different types of transactions for privacy protection; further, the needs of different types of users for privacy protection It is not the same. For example, when the transaction initiator belongs to the preset user type, it is allowed to trigger the DAPP client to implement related follow-up operations by exposing part of the receipt content to improve convenience, while other types of users may not be allowed to expose private information; Furthermore, even for the transaction initiator of the preset user type, there are still differentiated privacy protection requirements in different scenarios. The privacy protection requirements can be reflected in the storage process according to the satisfaction of the preset conditions by the exposed fields. Differentiated requirements and processing for protection, for example: By comparing the exposed fields in the receipt data with preset conditions, the exposed fields that meet the preset conditions can be stored in plain text, and the exposed fields that do not meet the preset conditions or other The receipt field must be stored in ciphertext.

在图2所示实施例的基础上,本说明书可以进一步识别智能合约所含的事件函数和收据数据中满足预设条件的收据内容,从而同时根据交易类型对应的暴露字段、智能合约所含的特殊事件函数和收据内容对预设条件的满足情况,确定对收据数据的存储方式。因此,上述的步骤208可以改进为:第一区块链节点存储所述收据数据,使对应于所述特殊事件函数的日志中满足预设条件的暴露字段以明文形式存储、所述收据数据的其余内容以密文形式存储。在保护用户隐私的前提下,通过对交易类型予以识别,可以根据不同类型的交易对于隐私保护的差异化需求,确定出允许明文存储的暴露字段;进一步地,由于不同事件函数往往涉及到不同信息,使得不同事件函数对应于不同的隐私保护需求,比如涉及到转账金额的事件函数的隐私保护需求相对较高、涉及到存证的事件函数的隐私保护需求相对较低(此处仅用于举例;实际上,转账金额较低的情况下,相关事件函数的隐私保护需求也可能相对较低,以及存证内容比较重要的情况下,相关事件函数的隐私保护需求也可能相对较高),因而可以将隐私保护需求相对较低的事件函数配置为上述的特殊事件函数,并在特殊事件函数产生的日志中包含上述的暴露字段时,允许暴露该暴露字段对应的收据内容;更进一步地,即便对于特殊事件函数所产生日志中的暴露字段而言,仍然在不同场景下存在差异化的隐私保护需求,可以根据暴露字段对预设条件的满足情况,在存储过程中体现出对隐私保护的差异化需求和处理:通过将收据数据中的暴露字段与预设条件进行比较,可以将满足预设条件的暴露字段以明文形式存储,而不满足预设条件的暴露字段或其他的收据字段则必然以密文形式存储。例如,假定特殊事件函数涉及存证操作,当该特殊事件函数所产生的日志包含上述的暴露字段,并且该暴露字段中的存证内容包含预设条件涉及的关键词时,可以将该暴露字段以明文形式存储,否则以密文形式存储。On the basis of the embodiment shown in Figure 2, this specification can further identify the event function contained in the smart contract and the receipt content in the receipt data that meets the preset conditions, so as to at the same time according to the exposed fields corresponding to the transaction type and the content contained in the smart contract. The special event function and the content of the receipt satisfy the preset conditions and determine the storage method of the receipt data. Therefore, the above step 208 can be improved as: the first blockchain node stores the receipt data, so that the exposed fields in the log corresponding to the special event function that meet the preset conditions are stored in plaintext, and the receipt data The rest of the content is stored in cipher text. Under the premise of protecting user privacy, by identifying transaction types, the exposed fields allowed to be stored in plaintext can be determined according to the differentiated requirements of different types of transactions for privacy protection; further, because different event functions often involve different information , So that different event functions correspond to different privacy protection requirements. For example, the privacy protection requirements of event functions related to the transfer amount are relatively high, and the privacy protection requirements of event functions related to evidence are relatively low (here only for example ; In fact, when the transfer amount is low, the privacy protection requirement of the related event function may also be relatively low, and when the deposit content is more important, the privacy protection requirement of the related event function may also be relatively high), therefore The event function with relatively low privacy protection requirements can be configured as the above special event function, and when the above exposed field is included in the log generated by the special event function, the receipt content corresponding to the exposed field is allowed to be exposed; furthermore, even For the exposed fields in the logs generated by the special event function, there are still differentiated privacy protection requirements in different scenarios. The difference in privacy protection can be reflected in the storage process according to the satisfaction of the preset conditions by the exposed fields Modification requirements and processing: By comparing the exposed fields in the receipt data with preset conditions, the exposed fields that meet the preset conditions can be stored in plaintext, while the exposed fields or other receipt fields that do not meet the preset conditions are inevitable Stored in cipher text. For example, assuming that a special event function involves a deposit operation, when the log generated by the special event function contains the above-mentioned exposed fields, and the deposit content in the exposed field contains keywords related to preset conditions, the exposed field can be Store in plain text, otherwise store in cipher text.

在图2所示实施例的基础上,本说明书可以进一步识别交易发起方的用户类型、智能合约所含的事件函数和收据数据中满足预设条件的收据内容,从而同时根据交易类型对应的暴露字段、交易发起方的用户类型、智能合约所含的特殊事件函数和收据内容对预设条件的满足情况,确定对收据数据的存储方式。因此,上述的步骤208可以改进为:第一区块链节点存储所述收据数据,当交易发起方属于预设用户类型时,使对应于 所述特殊事件函数的日志中满足预设条件的暴露字段以明文形式存储、所述收据数据的其余内容以密文形式存储。在保护用户隐私的前提下,通过对交易类型予以识别,可以根据不同类型的交易对于隐私保护的差异化需求,确定出允许明文存储的暴露字段;进一步地,由于不同事件函数往往涉及到不同信息,使得不同事件函数对应于不同的隐私保护需求,比如涉及到转账金额的事件函数的隐私保护需求相对较高、涉及到存证的事件函数的隐私保护需求相对较低(此处仅用于举例;实际上,转账金额较低的情况下,相关事件函数的隐私保护需求也可能相对较低,以及存证内容比较重要的情况下,相关事件函数的隐私保护需求也可能相对较高),因而可以将隐私保护需求相对较低的事件函数配置为上述的特殊事件函数,并在特殊事件函数产生的日志中包含上述的暴露字段时,允许暴露该暴露字段对应的收据内容;更进一步地,即便对于特殊事件函数所产生日志中的暴露字段而言,仍然在不同场景下存在差异化的隐私保护需求,可以根据暴露字段对预设条件的满足情况,在存储过程中体现出对隐私保护的差异化需求和处理:通过将收据数据中的暴露字段与预设条件进行比较,可以将满足预设条件的暴露字段以明文形式存储,而不满足预设条件的暴露字段或其他的收据字段则必然以密文形式存储。例如,假定特殊事件函数涉及存证操作,当该特殊事件函数所产生的日志包含上述的暴露字段,并且该暴露字段中的存证内容包含预设条件涉及的关键词时,可以将该暴露字段以明文形式存储,否则以密文形式存储。On the basis of the embodiment shown in Figure 2, this specification can further identify the user type of the transaction initiator, the event function contained in the smart contract, and the receipt content that meets the preset conditions in the receipt data, thereby simultaneously revealing the corresponding exposure according to the transaction type Fields, the user type of the transaction initiator, the special event functions contained in the smart contract, and the satisfaction of the receipt content to the preset conditions determine the storage method of the receipt data. Therefore, the above step 208 can be improved to: the first blockchain node stores the receipt data, and when the transaction initiator belongs to the preset user type, the log corresponding to the special event function is exposed to the preset condition. The fields are stored in plain text, and the rest of the receipt data is stored in cipher text. Under the premise of protecting user privacy, by identifying transaction types, the exposed fields allowed to be stored in plaintext can be determined according to the differentiated requirements of different types of transactions for privacy protection; further, because different event functions often involve different information , So that different event functions correspond to different privacy protection requirements. For example, the privacy protection requirements of event functions related to the transfer amount are relatively high, and the privacy protection requirements of event functions related to evidence are relatively low (here only for example ; In fact, when the transfer amount is low, the privacy protection requirement of the related event function may also be relatively low, and when the deposit content is more important, the privacy protection requirement of the related event function may also be relatively high), therefore The event function with relatively low privacy protection requirements can be configured as the above special event function, and when the above exposed field is included in the log generated by the special event function, the receipt content corresponding to the exposed field is allowed to be exposed; furthermore, even For the exposed fields in the logs generated by the special event function, there are still differentiated privacy protection requirements in different scenarios. The difference in privacy protection can be reflected in the storage process according to the satisfaction of the preset conditions by the exposed fields Modification requirements and processing: By comparing the exposed fields in the receipt data with preset conditions, the exposed fields that meet the preset conditions can be stored in plaintext, while the exposed fields or other receipt fields that do not meet the preset conditions are inevitable Stored in cipher text. For example, assuming that a special event function involves a deposit operation, when the log generated by the special event function contains the above-mentioned exposed fields, and the deposit content in the exposed field contains keywords related to preset conditions, the exposed field can be Store in plain text, otherwise store in cipher text.

在图2所示实施例的基础上,本说明书可以进一步识别智能合约的代码所含的暴露标识符、交易发起方的用户类型和智能合约所含的事件函数,从而同时根据交易类型对应的暴露字段、暴露标识符标明的字段、交易发起方的用户类型和智能合约所含的特殊事件函数,确定对收据数据的存储方式。因此,上述的步骤208可以改进为:第一区块链节点存储所述收据数据,以在交易发起方属于预设用户类型时,使对应于所述特殊事件函数的日志中的至少一部分收据内容以明文形式存储、所述收据数据的其余内容以密文形式存储,所述至少一部分收据内容匹配于所述暴露标识符标明的暴露字段。本说明书通过在一定程度上暴露收据内容,以用于实现对DAPP客户端的驱动或其他的功能扩展。并且,本说明书通过综合考虑交易发起方所属的用户类型、交易类型对应的暴露字段、暴露标识符标明的字段和特殊事件函数产生的日志,可以准确选取用于明文存储的收据内容,即同时满足“交易发起方属于预设用户类型”、“属于交易类型对应的暴露字段”、“匹配于暴露标识符标明的字段”和“属于特殊事件函数产生的日志”的收据内容,从而在满足上述功能扩展需求的同时,确保绝大部分的用户隐私能够得到保护。尤其是,当第一区块链节点是根据区块链网络上记载的信息(如特殊事件函数列表) 来识别特殊事件函数时,可以在智能合约已经创建之后,通过对“特殊事件函数”进行更新,以调整收据数据的存储方式,比如将原本明文存储的收据内容改为密文存储,或者将原本密文存储的收据内容改为明文存储。On the basis of the embodiment shown in Figure 2, this specification can further identify the exposure identifier contained in the code of the smart contract, the user type of the transaction initiator, and the event function contained in the smart contract, thereby simultaneously corresponding exposure according to the transaction type The fields, the fields indicated by the exposed identifier, the user type of the transaction initiator, and the special event function contained in the smart contract determine the storage method of the receipt data. Therefore, the above step 208 can be improved to: the first blockchain node stores the receipt data so that when the transaction initiator belongs to the preset user type, at least part of the receipt content in the log corresponding to the special event function It is stored in plain text, and the rest of the receipt data is stored in cipher text, and the at least a part of the receipt content matches the exposed field indicated by the exposure identifier. This manual exposes the content of the receipt to a certain extent to realize the driver of the DAPP client or other function extensions. In addition, this manual comprehensively considers the user type of the transaction initiator, the exposed field corresponding to the transaction type, the field indicated by the exposure identifier, and the log generated by the special event function, and can accurately select the receipt content for plaintext storage, that is, simultaneously satisfy Receipt content of "transaction initiator belongs to the preset user type", "belongs to the exposed field corresponding to the transaction type", "matches the field indicated by the exposure identifier" and "belongs to the log generated by the special event function", thus satisfying the above functions While expanding the demand, ensure that the privacy of most users can be protected. In particular, when the first blockchain node recognizes the special event function based on the information recorded on the blockchain network (such as the list of special event functions), it can perform the "special event function" after the smart contract has been created. Update to adjust the storage method of receipt data, such as changing the original receipt content stored in plain text to cipher text storage, or changing the original receipt content stored in cipher text to plain text storage.

前述的代码示例可以基于交易发起方的用户类型和智能合约所含的事件函数实现改进。在上述的代码示例2中,在智能合约的代码最前方添加暴露标识符plain,使得智能合约的代码被执行后,当交易发起方属于预设用户类型时,对于收据数据中由特殊事件函数产生的日志,允许该智能合约所属交易的交易类型对应的暴露字段对应的收据内容以明文形式进行存储,比如当日志中的From字段属于暴露字段、To字段并不属于暴露字段时,可以将收据数据中所有日志的From字段以明文形式存储、To字段以密文形式存储,那么后续可以针对该From字段中的收据内容实施检索操作,比如可以统计某一账户所发起的交易量等。The foregoing code example can be improved based on the user type of the transaction initiator and the event function contained in the smart contract. In the code example 2 above, the exposed identifier plain is added to the front of the smart contract code, so that after the smart contract code is executed, when the transaction initiator belongs to the preset user type, the receipt data is generated by the special event function The log of the smart contract allows the contents of the receipt corresponding to the exposed field corresponding to the transaction type of the transaction to which the smart contract belongs to be stored in clear text. For example, when the From field in the log is an exposed field and the To field is not an exposed field, the receipt data can be stored The From field of all logs in the log is stored in plain text, and the To field is stored in cipher text. Then, subsequent retrieval operations can be performed on the receipt content in the From field, for example, the transaction volume initiated by an account can be counted.

由于暴露标识符为智能合约的编程语言中所定义的全局性标识,因而只要在智能合约中写入暴露标识符后,就难以修改该暴露标识符所标明的字段。而用户类型则取决于交易发起方、与编程语言无关,使得不同交易发起方即便调用同一智能合约时,对收据数据的存储方式(密文或明文)也可能存在不同。交易类型也可以由交易发起方根据需求而选取,以表明交易发起方的实际需求。同时,特殊事件函数的定义并不一定基于编程语言实现,比如在基于特殊事件函数列表等方式记录特殊事件函数时,即便智能合约中包含的某一事件函数原本属于特殊事件函数,也可以通过对特殊事件函数列表进行更改的方式,将原有的特殊事件函数更新为普通事件函数,从而避免该事件函数产生的日志以明文形式存储,或者将原有的普通事件函数更新为特殊事件函数,使得该事件函数产生的日志中的至少一部分内容以明文形式存储。因此,通过由不同用户对智能合约进行调用,或者发起不同类型的交易,或者调整智能合约所含事件函数的类型,可以跳脱暴露标识符的限制,调整需要明文或密文存储的收据内容。Since the exposed identifier is a global identifier defined in the programming language of the smart contract, it is difficult to modify the fields marked by the exposed identifier as long as the exposed identifier is written in the smart contract. The user type depends on the transaction initiator and has nothing to do with the programming language, so that even when different transaction initiators call the same smart contract, the storage method (ciphertext or plaintext) of the receipt data may be different. The transaction type can also be selected by the transaction initiator according to demand to indicate the actual needs of the transaction initiator. At the same time, the definition of special event functions is not necessarily based on programming languages. For example, when recording special event functions based on a list of special event functions, even if an event function included in the smart contract originally belongs to a special event function, it can be To change the list of special event functions, update the original special event function to a normal event function, so as to avoid storing the log generated by the event function in clear text, or update the original normal event function to a special event function, so that At least part of the content in the log generated by the event function is stored in plain text. Therefore, by invoking smart contracts by different users, or initiating different types of transactions, or adjusting the types of event functions contained in smart contracts, you can escape the restriction of exposing identifiers and adjust the content of receipts that require plaintext or ciphertext storage.

以上述的代码示例2为例:假定事件currentPrice原本并未记录于特殊事件函数列表中,即事件currentPrice对应于普通事件函数,那么即便在智能合约的代码中添加了暴露标识符plain且交易发起方属于预设用户类型,事件currentPrice产生的日志中的各个字段(包括暴露字段)仍以密文形式存储。但是,如果将事件currentPrice添加至特殊事件函数列表中,那么代码示例2不需要调整的情况下,当交易发起方属于预设用户类型时,可使事件currentPrice对应的日志中的暴露字段以明文形式存储。Take the above code example 2 as an example: assuming that the event currentPrice was not originally recorded in the special event function list, that is, the event currentPrice corresponds to a normal event function, then even if the exposure identifier plain is added to the smart contract code and the transaction initiator It belongs to a preset user type, and all fields (including exposed fields) in the log generated by the event currentPrice are still stored in cipher text. However, if the event currentPrice is added to the list of special event functions, the code sample 2 does not need to be adjusted, and when the transaction initiator belongs to the preset user type, the exposed fields in the log corresponding to the event currentPrice can be made clear storage.

需要指出的是:在上述的代码示例2中,通过在代码最前方声明“plain”,该 暴露标识符“plain”所标明的字段为收据数据中的所有字段,且这些字段均为合约级字段,使得在交易发起方属于预设用户类型且该合约级字段属于暴露字段时,使事件currentPrice产生的日志中对应于该合约级字段的收据内容,均被允许以明文形式存储。当然,如果代码示例2中通过暴露标识符标注了譬如From字段,那么该From字段为上述的合约级字段,当该From字段进一步属于交易类型对应的暴露字段时,可在交易发起方属于预设用户类型的情况下,使第一区块链节点在存储收据数据时,收据数据中所有对应于该From字段的收据内容,均被允许以明文形式存储。It should be pointed out that: in the code example 2 above, by declaring "plain" at the front of the code, the fields marked by the exposed identifier "plain" are all fields in the receipt data, and these fields are contract-level fields , So that when the transaction initiator belongs to the preset user type and the contract-level field is an exposed field, the content of the receipt corresponding to the contract-level field in the log generated by the event currentPrice is allowed to be stored in plain text. Of course, if the From field is marked with the exposed identifier in Code Example 2, then the From field is the contract-level field mentioned above. When the From field is further an exposed field corresponding to the transaction type, it can be preset at the transaction initiator In the case of the user type, when the first blockchain node stores the receipt data, all the receipt contents corresponding to the From field in the receipt data are allowed to be stored in plain text.

尤其是,当智能合约的代码中包含多个事件函数时,在多个事件函数分别产生的各自对应的Logs字段中,均可能存在合约级字段所对应的收据内容;进一步地,可以通过识别交易发起方所属的用户类型、交易的交易类型对应的暴露字段以及各个事件函数的类型为普通事件函数或特殊事件函数,从而在交易发起方属于预设用户类型且合约级字段属于暴露字段的情况下,将所有特殊事件函数所产生的日志中对应于合约级字段的收据内容以明文形式存储。例如,智能合约可以包括下述的代码示例9:In particular, when the code of the smart contract contains multiple event functions, in the respective Logs fields generated by the multiple event functions, there may be the receipt content corresponding to the contract-level field; further, the transaction can be identified by The user type to which the initiator belongs, the exposed field corresponding to the transaction type of the transaction, and the type of each event function are ordinary event functions or special event functions, so when the transaction initiator belongs to the preset user type and the contract-level field belongs to the exposed field , Store the receipt content corresponding to the contract-level field in the log generated by all special event functions in plain text. For example, a smart contract can include the following code example 9:

plain Contract Example{plain Contract Example{

int price;int price;

int price1;int price1;

event currentPrice1(int price);event currentPrice1(int price);

event currentPrice2(int price1);event currentPrice2(int price1);

在上述的代码示例9中,与代码示例2相类似地,暴露标识符“plain”位于智能合约的代码最前方,使得收据数据中的所有字段均被标注为合约级字段;同时,智能合约中包含了事件currentPrice1和事件currentPrice2:假定事件currentPrice1对应于特殊事件函数列表中定义的特殊事件函数、事件currentPrice2对应于普通事件函数,那么在交易发起方属于预设用户类型且From字段属于暴露字段的情况下,在事件currentPrice1和事件currentPrice2分别产生的日志Log1、Log2中,日志Log1包含的From字段以明文形式存储、日志Log2包含的From字段以密文形式存储;类似地,日志Log1中属于暴露字段的其他字段也以明文形式存储、非暴露字段以密文形式存储,而日志Log2的所有字段均以密文形式存储。并且,如果通过对特殊事件函数列表进行更新后,将事件currentPrice2更新为对应于特殊事件函数,那么日志Log2包含的属于暴露字段的所有字段将以明文形式存储,而无需对智能合约的代码做任何变动。In the above code example 9, similar to the code example 2, the exposed identifier "plain" is located at the forefront of the smart contract code, so that all fields in the receipt data are marked as contract-level fields; at the same time, in the smart contract Contains the event currentPrice1 and the event currentPrice2: assuming that the event currentPrice1 corresponds to the special event function defined in the special event function list, and the event currentPrice2 corresponds to the normal event function, then the transaction initiator belongs to the preset user type and the From field is an exposed field. Below, in the logs Log1 and Log2 generated by the event currentPrice1 and event currentPrice2, the From field contained in the log Log1 is stored in plain text, and the From field contained in the log Log2 is stored in cipher text; similarly, the log Log1 belongs to the exposed field. Other fields are also stored in plain text, non-exposed fields are stored in cipher text, and all fields of log Log2 are stored in cipher text. Moreover, if the event currentPrice2 is updated to correspond to the special event function by updating the list of special event functions, all the fields that belong to the exposed fields contained in the log Log2 will be stored in plain text, without the need to do anything to the smart contract code change.

对于上述的合约级字段而言,可以通过前述的类型标识符来标明智能合约所含的事件函数是否为特殊事件函数。例如,可以将上述的代码示例9调整为下述的代码示例10:For the aforementioned contract-level fields, the aforementioned type identifier can be used to indicate whether the event function included in the smart contract is a special event function. For example, the above code sample 9 can be adjusted to the following code sample 10:

plain Contract Example{plain Contract Example{

int price;int price;

int price1;int price1;

event currentPrice1 expose(int price);event currentPrice1 expose(int price);

event currentPrice2(int price1);event currentPrice2(int price1);

在上述的代码示例10中,与代码示例2相类似地,合约级字段包括收据数据中的所有字段;同时,智能合约中包含了事件currentPrice1和事件currentPrice2:由于事件currentPrice1在包含如前所述的类型标识符expose,使得该事件currentPrice1被标注为对应于特殊事件函数,而事件currentPrice2并未包含类型标识符expose,使得事件currentPrice2被标注为对应于普通事件函数,那么在交易发起方属于预设用户类型的情况下,在事件currentPrice1和事件currentPrice2分别产生的日志Log1、Log2中,日志Log1中对应于交易类型的所有暴露字段均以明文形式存储、日志Log2包含的所有字段均以密文形式存储。In the above code example 10, similar to the code example 2, the contract-level fields include all the fields in the receipt data; at the same time, the smart contract contains the event currentPrice1 and the event currentPrice2: because the event currentPrice1 contains the aforementioned The type identifier expose, so that the event currentPrice1 is marked as corresponding to the special event function, and the event currentPrice2 does not contain the type identifier expose, so that the event currentPrice2 is marked as corresponding to the normal event function, then the transaction initiator belongs to the default user In the case of type, in the logs Log1 and Log2 respectively generated by the event currentPrice1 and the event currentPrice2, all the exposed fields corresponding to the transaction type in the log Log1 are stored in plain text, and all the fields contained in the log Log2 are stored in cipher text.

除了合约级字段之外,暴露标识符标明的字段可以包括:对应于智能合约中定义的至少一个事件的事件级字段,使得在交易发起方属于预设用户类型且该事件级字段属于暴露字段的情况下,第一区块链节点将特殊事件函数产生的收据内容中对应于该事件级字段的部分以明文形式存储。尤其是,当智能合约中包含多个事件时,可以针对至少一部分事件设定上述的事件级字段,使得这部分事件产生的日志中对应于上述事件级字段的收据内容以明文形式存储,而这部分事件产生的日志中的其余收据内容、其余事件对应的收据内容均以密文形式存储。以From字段为例,可以将上述的代码示例10调整为下述的代码示例11:In addition to the contract-level fields, the fields indicated by the exposure identifier may include: event-level fields corresponding to at least one event defined in the smart contract, so that the transaction initiator belongs to the preset user type and the event-level field belongs to the exposed field In this case, the first blockchain node stores the part of the receipt content generated by the special event function that corresponds to the event-level field in plain text. In particular, when the smart contract contains multiple events, the above event-level fields can be set for at least some of the events, so that the contents of the receipts corresponding to the above-mentioned event-level fields in the logs generated by these events are stored in plain text, and this The content of the remaining receipts in the log generated by some events and the content of the receipts corresponding to the remaining events are stored in ciphertext. Taking the From field as an example, the above code sample 10 can be adjusted to the following code sample 11:

Contract Example{Contract Example{

int price;int price;

int price1;int price1;

event currentPrice1(“from”,int price);event currentPrice1("from",int price);

event currentPrice2(int price1);event currentPrice2(int price1);

在上述的代码示例11中,事件currentPrice1虽然未添加暴露标识符“plain”,但是包含了内容“from”,该内容“from”对应于From字段,用于表明事件currentPrice1所产生日志中的From字段需要以明文形式存储,因而该内容“from”既属于上述的暴露标识符,又标明了需要明文存储的From字段。并且,由于内容“from”位于事件currentPrice1中,因而From字段为事件级字段,使得在交易发起方属于预设用户类型且From字段属于暴露字段的情况下,当该事件currentPrice1对应于特殊事件函数时,在该事件currentPrice1对应产生的日志Logs中,From字段将以明文形式进行存储、其他字段以密文形式存储。而对于代码示例11所含的另一事件currentPrice2,由于并未针对该事件currentPrice2添加暴露标识符,因而不论该事件currentPrice2对应于特殊事件函数或普通事件函数,所产生的日志Logs均以密文形式存储。该代码示例11对应的实施例中,即对于事件级字段而言,可以通过特殊事件函数列表或者类型标识符的方式识别智能合约所含的事件函数是否为特殊事件函数,此处不再一一赘述。In the code example 11 above, although the event currentPrice1 does not add the exposed identifier "plain", it contains the content "from". The content "from" corresponds to the From field and is used to indicate the From field in the log generated by the event currentPrice1 It needs to be stored in plain text, so the content "from" not only belongs to the above exposed identifier, but also indicates the From field that needs to be stored in plain text. Moreover, since the content "from" is in the event currentPrice1, the From field is an event-level field, so that when the transaction initiator belongs to the preset user type and the From field is an exposed field, when the event currentPrice1 corresponds to a special event function In the log Logs generated corresponding to the event currentPrice1, the From field will be stored in plain text, and other fields will be stored in cipher text. As for the other event currentPrice2 contained in code example 11, since no exposure identifier is added for the event currentPrice2, regardless of whether the event currentPrice2 corresponds to a special event function or a normal event function, the generated log Logs are in ciphertext form storage. In the embodiment corresponding to this code example 11, that is, for event-level fields, it is possible to identify whether the event functions contained in the smart contract are special event functions by means of a special event function list or type identifier. Repeat.

在图2所示实施例的基础上,本说明书可以进一步识别智能合约的代码所含的暴露标识符、交易发起方的用户类型和收据数据中满足预设条件的收据内容,从而同时根据交易类型对应的暴露字段、暴露标识符标明的字段、交易发起方的用户类型和收据内容对预设条件的满足情况,确定对收据数据的存储方式。因此,上述的步骤208可以改进为:第一区块链节点存储所述收据数据,当交易发起方属于预设用户类型时,使所述收据数据中由所述暴露标识符标明且满足预设条件的暴露字段以明文形式存储、其余收据字段以密文形式存储。由于暴露标识符为智能合约的编程语言中所定义的全局性标识,因而只要在智能合约中写入暴露标识符后,就难以修改该暴露标识符所标明的字段。因此,通过结合对用户类型、交易类型和预设条件的考量,可以根据交易发起方所属的用户类型、交易类型对应的暴露字段、收据内容对预设条件的满足情况,更准确地选取采用明文形式进行存储的字段,而并非仅基于暴露标识符进行确定,从而在不同用户调用同一智能合约、或通过不同类型的交易调用同一智能合约、或采用差异化的预设条件时,使得明文存储的字段配合于用户类型、交易类型和预设条件,可使针对收据数据的存储方式满足不同情形下的实际需求,能够兼顾隐私保护和功能扩展。可见,本说明书通过在一定程度上暴露收据内容,可以用于实现对DAPP客户端的驱动或其他的功能扩展。并且,本说明书通过综合考虑暴露标识符标明的字段、交易类型对应的暴露字段、 交易发起方所属的用户类型和收据内容对预设条件的满足情况,可以准确选取用于明文存储的字段,即同时满足“由暴露标识符标明”、“匹配于交易类型”和“满足预设条件”的字段,从而在满足上述功能扩展需求的同时,确保绝大部分的用户隐私能够得到保护。On the basis of the embodiment shown in Figure 2, this specification can further identify the exposure identifier contained in the smart contract code, the user type of the transaction initiator, and the receipt content that meets the preset conditions in the receipt data, thereby simultaneously according to the transaction type The corresponding exposure field, the field indicated by the exposure identifier, the user type of the transaction initiator, and the content of the receipt meet the preset conditions, and the storage method of the receipt data is determined. Therefore, the above step 208 can be improved to: the first blockchain node stores the receipt data, and when the transaction initiator belongs to the preset user type, the receipt data is marked by the exposure identifier and meets the preset requirements. The exposed fields of the conditions are stored in plain text, and the remaining receipt fields are stored in cipher text. Since the exposed identifier is a global identifier defined in the programming language of the smart contract, it is difficult to modify the fields marked by the exposed identifier as long as the exposed identifier is written in the smart contract. Therefore, by combining the consideration of user types, transaction types, and preset conditions, it is possible to more accurately select and use plain text based on the user type of the transaction initiator, the exposure field corresponding to the transaction type, and the satisfaction of the preset conditions by the content of the receipt. The fields stored in the form are not only determined based on the exposed identifier, so that when different users call the same smart contract, or call the same smart contract through different types of transactions, or use differentiated preset conditions, the plaintext stored The fields are matched with user types, transaction types and preset conditions, so that the storage method of receipt data can meet the actual needs in different situations, and can take into account privacy protection and function expansion. It can be seen that by exposing the content of the receipt to a certain extent, this manual can be used to drive the DAPP client or expand other functions. In addition, this manual can accurately select the fields for plaintext storage by comprehensively considering the fields indicated by the exposure identifier, the exposed fields corresponding to the transaction type, the user type of the transaction initiator and the content of the receipt to meet the preset conditions. At the same time, it satisfies the fields of "indicated by the exposed identifier", "matched to the transaction type" and "satisfy the preset conditions", so as to meet the above functional expansion requirements while ensuring that most user privacy can be protected.

前述的代码示例可以基于交易发起方的用户类型和收据数据中满足预设条件的收据内容实现改进。在上述的代码示例2中,通过在智能合约的代码最前方添加暴露标识符plain,使得智能合约的代码被执行后,在交易发起方属于预设用户类型的情况下,对于该智能合约所属交易的交易类型对应的暴露字段,产生的收据数据中对应于上述暴露字段且满足预设条件的收据内容均以明文形式进行存储。The foregoing code example can be improved based on the user type of the transaction initiator and the receipt content that meets the preset conditions in the receipt data. In the above code example 2, by adding the exposed identifier plain to the front of the smart contract code, after the smart contract code is executed, when the transaction initiator belongs to the preset user type, the transaction to which the smart contract belongs The exposed fields corresponding to the transaction types of the generated receipt data corresponding to the above exposed fields and meeting the preset conditions are stored in plain text.

当然,在其他实施例中,也可以具体指明需要明文存储的字段。比如,通过暴露标识符对From字段进行标注时,可以仅对该From字段进行判断:如果交易发起方属于预设用户类型且From字段为该智能合约所属交易的交易类型对应的暴露字段,那么在智能合约的代码被执行后,产生的收据数据中的From字段在满足预设条件的情况下以明文形式进行存储,而后续可以针对上述From字段实施检索操作,比如可以统计某一账户所发起的交易量等;而除了From字段之前的其他字段,则均以密文形式存储。Of course, in other embodiments, the fields that need to be stored in plaintext can also be specified. For example, when annotating the From field with an exposed identifier, you can only judge the From field: if the transaction initiator belongs to the preset user type and the From field is the exposed field corresponding to the transaction type of the transaction to which the smart contract belongs, then After the code of the smart contract is executed, the From field in the generated receipt data is stored in plain text when the preset conditions are met, and subsequent retrieval operations can be performed on the From field above, such as statistics initiated by an account Transaction volume, etc.; except for the other fields before the From field, they are all stored in cipher text.

需要指出的是:在上述的代码示例2及其相关实施例中,由暴露标识符“plain”所标明的字段(所有字段或From字段)为合约级字段,使得第一区块链节点在存储收据数据时,如果交易发起方属于预设用户类型且该合约级字段为暴露字段,那么第一区块链节点会将收据数据中对应于该合约级字段且满足预设条件的所有收据内容以明文形式存储。尤其是,当智能合约的代码中包含多个事件时,合约级字段可以适用于智能合约中的所有事件,那么以From字段为例:当交易发起方属于预设用户类型、From字段为合约级字段以及交易类型对应的暴露字段时,对于多个事件分别的产生各自对应的Logs字段,每一Logs字段所含的From字段均会采用明文形式进行存储,而无需针对每一事件分别添加暴露标识符。It should be pointed out that in the above code example 2 and related embodiments, the fields (all fields or From fields) marked by the exposed identifier "plain" are contract-level fields, so that the first blockchain node is storing When receiving receipt data, if the transaction initiator belongs to the preset user type and the contract-level field is an exposed field, then the first blockchain node will use all the receipt contents in the receipt data that correspond to the contract-level field and meet the preset conditions with Stored in clear text. In particular, when the code of a smart contract contains multiple events, the contract-level field 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, the From field is at the contract level When the fields and the exposed fields corresponding to the transaction type are generated, the Logs fields corresponding to multiple events are generated separately, and the From field contained in each Logs field will be stored in plain text, without the need to add exposure identifiers for each event. symbol.

除了合约级字段之外,暴露标识符标明的字段可以包括:对应于智能合约中定义的至少一个事件的事件级字段,使得第一区块链节点在存储收据数据时,如果交易发起方属于预设用户类型且事件级字段属于交易类型对应的暴露字段,可以确定出收据数据中对应于该至少一个事件的日志,并将确定出的日志中对应于上述事件级字段的收据内容与预设条件进行比较,从而将满足该预设条件的收据内容以明文形式存储。尤其是,当智能合约中包含多个事件时,可以针对至少一部分事件设定上述的事件级字段,使得 这部分事件对应的收据内容中对应于事件级字段且满足预设条件的部分以明文形式存储,而这部分事件对应的收据内容中的剩余部分、其余事件对应的收据内容等均以密文形式存储。以From字段为例,在上述的代码示例3中,通过在事件currentPrice对应的事件函数“event currentPrice(int price)”中添加From字段对应的字符from,并且该字符from所采用的暴露标识符区别于前述的plain,而是通过引号对该字符from进行修饰,则代码示例3中的引号相当于前述的暴露标识符,将From字段配置为事件级字段,使得From字段被标记为事件级字段,因而当交易发起方属于预设用户类型且From字段属于交易类型对应的暴露字段时,在该事件对应产生的Logs字段中,From字段在满足预设条件时将以明文形式进行存储。除了上述事件currentPrice之外,如果智能合约的代码还包含另一事件,那么上述的“from”不会影响该另一事件、该另一事件对应的收据内容将以密文形式进行存储。而在上述的代码示例4中,通过在事件currentPrice对应的事件函数“event currentPrice(int price)”之前添加关键字“plain”,使得事件级字段包括该事件currentPrice对应的日志Logs中的所有字段,譬如前述的From字段、To字段、Topic字段、Log Data字段等,当交易发起方属于预设用户类型时,可以根据交易类型确定出这些字段中的暴露字段,并将确定出的暴露字段与预设条件进行比较,从而将满足预设条件的暴露字段以明文形式存储。因此,如果上述的From字段、To字段、Topic字段、Log Data字段等均满足预设条件时,相当于将事件currentPrice产生的所有收据内容均以明文形式存储。In addition to the contract-level fields, the fields indicated by the exposure identifier may include: event-level fields corresponding to at least one event defined in the smart contract, so that when the first blockchain node stores the receipt data, if the transaction initiator belongs to the pre- Assuming that the user type and the event-level field belong to the exposed field corresponding to the transaction type, the log corresponding to the at least one event in the receipt data can be determined, and the content of the receipt corresponding to the event-level field in the determined log and the preset conditions The comparison is performed so that the content of the receipt meeting the preset condition is stored in plain text. In particular, when the smart contract contains multiple events, the above event-level fields can be set for at least some of the events, so that the part of the receipt content corresponding to these events that corresponds to the event-level field and meets the preset conditions is in plain text Store, and the remaining part of the receipt content corresponding to this part of the event and the receipt content corresponding to the remaining events are stored in cipher text. Take the From field as an example. In the above code example 3, 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 by the character from is different For the aforementioned plain, the character from is modified by quotation marks. The quotation marks in Code Example 3 are equivalent to the aforementioned exposed identifier. The From field is configured as an event-level field, so that the From field is marked as an event-level field. Therefore, when the transaction initiator belongs to the preset user type and the From field belongs to the exposed field corresponding to the transaction type, in the Logs field corresponding to the event, the From field will be stored in plain text when the preset conditions are met. In addition to the aforementioned event currentPrice, if the code of the smart contract also contains another event, the aforementioned "from" will not affect the other event, and the content of the receipt corresponding to the other event will be stored in ciphertext. In the above code example 4, by adding the keyword "plain" before the event function "event currentPrice(int price)" corresponding to the event currentPrice, the event-level fields include all the fields in the log Logs corresponding to the event currentPrice. For example, the aforementioned From field, To field, Topic field, Log Data field, etc., when the transaction initiator belongs to the preset user type, the exposed fields in these fields can be determined according to the transaction type, and the determined exposed fields are compared with the preset user types. Set conditions for comparison, so that the exposed fields that meet the preset conditions are stored in plain text. Therefore, if the aforementioned From field, To field, Topic field, Log Data field, etc. all meet the preset conditions, it is equivalent to storing all the contents of the receipt generated by the event currentPrice in plain text.

在图2所示实施例的基础上,本说明书可以进一步识别智能合约的代码所含的暴露标识符、智能合约所含的事件函数和收据数据中满足预设条件的收据内容,从而同时根据交易类型对应的暴露字段、暴露标识符标明的字段、智能合约所含的特殊事件函数和收据内容对预设条件的满足情况,确定对收据数据的存储方式。因此,上述的步骤208可以改进为:第一区块链节点存储所述收据数据,使对应于所述特殊事件函数的日志中的至少一部分收据内容以明文形式存储、所述收据数据的其余内容以密文形式存储,所述至少一部分收据内容包括由所述暴露标识符标明且满足预设条件的暴露字段。On the basis of the embodiment shown in Figure 2, this specification can further identify the exposure identifier contained in the code of the smart contract, the event function contained in the smart contract, and the content of the receipt meeting preset conditions in the receipt data, so as to be based on the transaction at the same time. The exposure field corresponding to the type, the field indicated by the exposure identifier, the special event function contained in the smart contract, and the satisfaction of the preset conditions by the receipt content determine the storage method of the receipt data. Therefore, the above step 208 can be improved as: the first blockchain node stores the receipt data, so that at least part of the receipt content in the log corresponding to the special event function is stored in plaintext, and the rest of the receipt data It is stored in a ciphertext form, and the at least a part of the receipt content includes exposed fields that are marked by the exposure identifier and meet a preset condition.

前述的代码示例可以基于智能合约所含的事件函数和收据数据中满足预设条件的收据内容实现改进。在上述的代码示例2中,在智能合约的代码最前方添加暴露标识符plain,仅从编程语言的维度而言,暴露标识符plain表明:使得智能合约的代码被执行后,产生的收据数据中的所有字段均允许以明文形式进行存储,那么后续可以针对这些字段中的收据内容实施检索操作,比如对于From字段而言,可以用于统计某一账户所发起的交易量等。而通过进一步结合交易类型、事件函数和预设条件等维度,对收据 数据的存储方案可能存在不同,仍以From字段为例:收据数据中的From字段可能并非均以明文形式存储,以事件currentPrice为例,当该事件currentPrice为特殊事件函数且From字段满足预设条件时,将该事件currentPrice所产生日志中的From字段以明文形式存储,否则以密文形式存储。The foregoing code example can be improved based on the event function contained in the smart contract and the receipt content that meets the preset conditions in the receipt data. In the above code example 2, the exposed identifier plain is added to the front of the code of the smart contract. From the perspective of the programming language, the exposed identifier plain indicates that after the code of the smart contract is executed, the generated receipt data All fields of are allowed to be stored in plain text, so subsequent retrieval operations can be performed on the receipt content in these fields. For example, for the From field, it can be used to count the transaction volume initiated by an account. By further combining dimensions such as transaction type, event function, and preset conditions, the storage scheme for receipt data may be different. Take the From field as an example: the From field in the receipt data may not all be stored in plain text, but the event currentPrice As an example, when the event currentPrice is a special event function and the From field meets a preset condition, the From field in the log generated by the event currentPrice is stored in plain text, otherwise it is stored in cipher text.

以上述的代码示例2为例:假定事件currentPrice原本并未记录于特殊事件函数列表中,即事件currentPrice对应于普通事件函数,那么即便在智能合约的代码中添加了暴露标识符plain且From字段属于暴露字段,事件currentPrice产生的日志中的各个字段(包括暴露字段)仍以密文形式存储。但是,如果将事件currentPrice添加至特殊事件函数列表中,那么代码示例2不需要调整的情况下,即可使得事件currentPrice对应的日志中的暴露字段以明文形式存储;比如,当From字段和To字段为暴露字段时,事件currentPrice所产生日志中的From字段和To字段将以明文形式存储,而其余字段则以密文形式存储。Take the above code example 2 as an example: Assuming that the event currentPrice was not originally recorded in the special event function list, that is, the event currentPrice corresponds to the normal event function, then even if the exposed identifier plain is added to the smart contract code and the From field belongs to Exposed fields, all fields (including exposed fields) in the log generated by the event currentPrice are still stored in cipher text. However, if the event currentPrice is added to the list of special event functions, then the exposed fields in the log corresponding to the event currentPrice can be stored in plain text without the need to adjust the code example 2; for example, when the From field and the To field To expose fields, the From field and To field in the log generated by the event currentPrice will be stored in plain text, while the remaining fields will be stored in cipher text.

需要指出的是:在上述的代码示例2中,通过在代码最前方声明“plain”,该暴露标识符“plain”所标明的字段为收据数据中的所有字段,且这些字段均为合约级字段,使得第一区块链节点在存储收据数据时,收据数据中所有对应于该合约级字段的收据内容,均被允许以明文形式存储。当然,如果代码示例2中通过暴露标识符标注了譬如From字段,那么该From字段为上述的合约级字段,当该From字段进一步属于交易类型对应的暴露字段时,可使第一区块链节点在存储收据数据时,收据数据中所有对应于该From字段且满足预设条件的收据内容,均被允许以明文形式存储。It should be pointed out that: in the code example 2 above, by declaring "plain" at the front of the code, the fields marked by the exposed identifier "plain" are all fields in the receipt data, and these fields are contract-level fields , So that when the first blockchain node stores the receipt data, all the receipt contents corresponding to the contract-level field in the receipt data are allowed to be stored in plain text. Of course, if the From field is marked with the exposed identifier in Code Example 2, then the From field is the contract-level field mentioned above. When the From field is further an exposed field corresponding to the transaction type, the first blockchain node can be used When storing receipt data, all the receipt contents corresponding to the From field and meeting preset conditions in the receipt data are allowed to be stored in plain text.

当智能合约的代码中包含多个事件函数时,在多个事件函数分别产生的各自对应的Logs字段中,均可能存在属于合约级字段的暴露字段;进一步地,可以通过识别各个事件函数的类型为普通事件函数或特殊事件函数,从而将所有特殊事件函数所产生的日志中属于合约级字段的暴露字段以明文形式存储。例如,在上述的代码示例5中,与代码示例2相类似地,暴露标识符“plain”位于智能合约的代码最前方,使得收据数据中的所有字段均被标注为合约级字段;同时,智能合约中包含了事件currentPrice1和事件currentPrice2:假定From字段为交易类型对应的暴露字段,并且事件currentPrice1对应于特殊事件函数列表中定义的特殊事件函数、事件currentPrice2对应于普通事件函数,那么在事件currentPrice1和事件currentPrice2分别产生的日志Log1、Log2中,日志Log1包含的From字段在满足预设条件时以明文形式存储、日志Log2包含的From字段以密文形式存储;类似地,日志Log1中属于暴露字段的其他字段也以明文形式存 储、非暴露字段以密文形式存储,而日志Log2的所有字段均以密文形式存储。并且,如果通过对特殊事件函数列表进行更新后,将事件currentPrice2更新为对应于特殊事件函数,那么日志Log2包含的属于暴露字段且满足预设条件的所有字段将以明文形式存储,而无需对智能合约的代码做任何变动。When the code of a smart contract contains multiple event functions, in the respective Logs fields generated by the multiple event functions, there may be exposed fields belonging to contract-level fields; further, the type of each event function can be identified It is a normal event function or a special event function, so that the exposed fields belonging to the contract-level fields in the logs generated by all special event functions are stored in plaintext. For example, in the above code example 5, similar to the code example 2, the exposed identifier "plain" is located at the forefront of the smart contract code, so that all fields in the receipt data are marked as contract-level fields; at the same time, smart The contract contains the event currentPrice1 and event currentPrice2: Assume that the From field is the exposed field corresponding to the transaction type, and the event currentPrice1 corresponds to the special event function defined in the special event function list, and the event currentPrice2 corresponds to the normal event function. Then in the event currentPrice1 and In the logs Log1 and Log2 generated by the event currentPrice2, the From field contained in log Log1 is stored in plain text when the preset conditions are met, and the From field contained in log Log2 is stored in cipher text; similarly, the exposed fields in log Log1 Other fields are also stored in plain text, non-exposed fields are stored in cipher text, and all fields of log Log2 are stored in cipher text. Moreover, if the event currentPrice2 is updated to correspond to the special event function after the special event function list is updated, then all the fields contained in the log Log2 that belong to the exposed fields and meet the preset conditions will be stored in plain text, without the need for smart Make any changes to the contract code.

对于上述的合约级字段而言,可以通过前述的类型标识符来标明智能合约所含的事件函数是否为特殊事件函数。例如,在上述的代码示例6中,与代码示例2相类似地,合约级字段包括收据数据中的所有字段;同时,智能合约中包含了事件currentPrice1和事件currentPrice2:由于事件currentPrice1在包含如前所述的类型标识符expose,使得该事件currentPrice1被标注为对应于特殊事件函数,而事件currentPrice2并未包含类型标识符expose,使得事件currentPrice2被标注为对应于普通事件函数,那么在事件currentPrice1和事件currentPrice2分别产生的日志Log1、Log2中,日志Log1中对应于交易类型的所有暴露字段在满足预设条件的情况下均以明文形式存储、日志Log2包含的所有字段均必然以密文形式存储。For the aforementioned contract-level fields, the aforementioned type identifier can be used to indicate whether the event function included in the smart contract is a special event function. For example, in the above code example 6, similar to the code example 2, the contract-level fields include all fields in the receipt data; at the same time, the smart contract contains the event currentPrice1 and the event currentPrice2: because the event currentPrice1 contains the same as before The type identifier expose mentioned above makes the event currentPrice1 be marked as corresponding to the special event function, while the event currentPrice2 does not contain the type identifier expose, so that the event currentPrice2 is marked as corresponding to the normal event function, then the event currentPrice1 and event currentPrice2 In the generated logs Log1 and Log2, all the exposed fields corresponding to the transaction type in the log Log1 are stored in plain text when the preset conditions are met, and all the fields contained in the log Log2 must be stored in cipher text.

除了合约级字段之外,暴露标识符标明的字段可以包括:对应于智能合约中定义的至少一个事件的事件级字段,使得第一区块链节点在存储收据数据时,可以确定出所述至少一个事件对应的特殊事件函数产生的日志,并将确定出的日志中属于事件级字段且满足预设条件的暴露字段以明文形式存储。尤其是,当智能合约中包含多个事件时,可以针对至少一部分事件设定上述的事件级字段,使得这部分事件对应的日志中属于事件级字段且满足预设条件的暴露字段以明文形式存储,而这部分事件对应的日志中的其他字段、其余事件对应的收据内容均以密文形式存储。以From字段为例,在上述的代码示例7中,事件currentPrice1虽然未添加暴露标识符“plain”,但是包含了内容“from”,该内容“from”对应于From字段,用于表明事件currentPrice1所产生日志中的From字段需要以明文形式存储,因而该内容“from”既属于上述的暴露标识符,又标明了需要明文存储的From字段。并且,由于内容“from”位于事件currentPrice1中,因而From字段为事件级字段,使得当From字段为交易类型对应的暴露字段且该事件currentPrice1对应于特殊事件函数时,在该事件currentPrice1对应产生的日志Logs中,From字段在满足预设条件的情况下将以明文形式进行存储、在未满足预设条件的情况下以密文形式进行存储,而其他字段必然以密文形式存储。而对于代码示例7所含的另一事件currentPrice2,由于并未针对该事件currentPrice2添加暴露标识符,因而不论该事件currentPrice2对应于特殊事件函数或普通事件函数,所产生的日志Logs均以密文形式存储。In addition to the contract-level fields, the fields marked by the exposure identifier may include: event-level fields corresponding to at least one event defined in the smart contract, so that the first blockchain node can determine the at least one event when storing the receipt data. A log generated by a special event function corresponding to an event, and the determined exposed fields belonging to event-level fields and meeting preset conditions in the determined log are stored in plain text. In particular, when the smart contract contains multiple events, the above event-level fields can be set for at least some of the events, so that the exposed fields that belong to the event-level fields and meet the preset conditions in the logs corresponding to this part of the events are stored in plain text , And other fields in the log corresponding to this part of the event, and the content of the receipt corresponding to the remaining events are stored in cipher text. Take the From field as an example. In the above code sample 7, although the event currentPrice1 does not add the exposed identifier "plain", it contains the content "from". The content "from" corresponds to the From field and is used to indicate the event currentPrice1. The From field in the generated log needs to be stored in plain text, so the content "from" not only belongs to the above exposed identifier, but also indicates the From field that needs to be stored in plain text. Moreover, since the content "from" is in the event currentPrice1, the From field is an event-level field, so that when the From field is an exposed field corresponding to the transaction type and the event currentPrice1 corresponds to a special event function, the log generated in the event currentPrice1 corresponds to In Logs, the From field will be stored in plain text when the preset conditions are met, and in cipher text when the preset conditions are not met, and other fields must be stored in cipher text. As for the other event currentPrice2 contained in code example 7, since no exposure identifier is added for the event currentPrice2, regardless of whether the event currentPrice2 corresponds to a special event function or a normal event function, the generated log Logs are in ciphertext form storage.

上述的关键词“from”指明了将From字段设定为事件级字段;而在其他实施例中,也可以并不指明具体的字段。例如,在上述的代码示例8中,通过在事件currentPrice1之前添加暴露标识符“plain”,可以将该事件currentPrice1所产生的日志中的所有字段均作为上述的事件级字段,譬如前述的From字段、To字段、Topic字段、Log Data字段等。那么,当该事件currentPrice1对应于特殊事件函数时,可以从该事件currentPrice1所产生日志中的确定出既属于上述的事件级字段又属于交易类型对应的暴露字段的日志字段,并在确定出的日志字段满足预设条件时采用明文形式存储;如果上述的From字段、To字段、Topic字段、Log Data字段等均为暴露字段且满足预设条件,那么相当于将该事件currentPrice1对应的所有收据内容(比如产生的日志)均以明文形式存储。The above keyword "from" indicates that the From field is set as an event-level field; however, in other embodiments, the specific field may not be specified. For example, in the above code example 8, by adding the exposure identifier "plain" before the event currentPrice1, all the fields in the log generated by the event currentPrice1 can be used as the aforementioned event-level fields, such as the aforementioned From field, To field, Topic field, Log Data field, etc. Then, when the event currentPrice1 corresponds to a special event function, it can be determined from the log generated by the event currentPrice1 that it belongs to both the above event-level field and the exposed field corresponding to the transaction type, and the log field is determined in the log When the fields meet the preset conditions, they are stored in plain text; if the above-mentioned From field, To field, Topic field, Log Data field, etc. are all exposed fields and meet the preset conditions, then it is equivalent to the content of all receipts corresponding to the event currentPrice1 ( For example, the generated logs are stored in plain text.

在图2所示实施例的基础上,本说明书可以进一步识别智能合约的代码所含的暴露标识符、交易发起方的用户类型、智能合约所含的事件函数和收据数据中满足预设条件的收据内容,从而同时根据交易类型对应的暴露字段、暴露标识符标明的字段、交易发起方的用户类型、智能合约所含的特殊事件函数和收据内容对预设条件的满足情况,确定对收据数据的存储方式。因此,上述的步骤208可以改进为:第一区块链节点存储所述收据数据,以在交易发起方属于预设用户类型时,使对应于所述特殊事件函数的日志中的至少一部分收据内容以明文形式存储、所述收据数据的其余内容以密文形式存储,所述至少一部分收据内容匹配于所述暴露标识符标明的暴露字段且满足预设条件。本说明书通过在一定程度上暴露收据内容,以用于实现对DAPP客户端的驱动或其他的功能扩展。并且,本说明书通过综合考虑交易发起方所属的用户类型、交易类型对应的暴露字段、暴露标识符标明的字段、特殊事件函数产生的日志和收据内容对预设条件的满足情况,可以准确选取用于明文存储的收据内容,即同时满足“交易发起方属于预设用户类型”、“属于交易类型对应的暴露字段”、“匹配于暴露标识符标明的字段”、“属于特殊事件函数产生的日志”和“满足预设条件”的收据内容,从而在满足上述功能扩展需求的同时,确保绝大部分的用户隐私能够得到保护。尤其是,当第一区块链节点是根据区块链网络上记载的信息(如特殊事件函数列表)来识别特殊事件函数时,可以在智能合约已经创建之后,通过对“特殊事件函数”进行更新,以调整收据数据的存储方式,比如将原本明文存储的收据内容改为密文存储,或者将原本密文存储的收据内容改为明文存储。Based on the embodiment shown in Figure 2, this specification can further identify the exposure identifier contained in the code of the smart contract, the user type of the transaction initiator, the event function contained in the smart contract, and the receipt data that meet the preset conditions. Receipt content, so as to determine the receipt data at the same time according to the exposed fields corresponding to the transaction type, the fields indicated by the exposed identifier, the user type of the transaction initiator, the special event function included in the smart contract, and the satisfaction of the receipt content to the preset conditions Storage method. Therefore, the above step 208 can be improved to: the first blockchain node stores the receipt data so that when the transaction initiator belongs to the preset user type, at least part of the receipt content in the log corresponding to the special event function Stored in plain text, and the remaining content of the receipt data is stored in cipher text, and the at least part of the receipt content matches the exposure field indicated by the exposure identifier and meets a preset condition. This manual exposes the content of the receipt to a certain extent to realize the driver of the DAPP client or other function extensions. In addition, this manual considers the user type of the transaction initiator, the exposed field corresponding to the transaction type, the field indicated by the exposure identifier, the log generated by the special event function, and the content of the receipt to meet the preset conditions, and can accurately select the application. The content of the receipt stored in plaintext meets the requirements of "transaction initiator belongs to the preset user type", "belongs to the exposed field corresponding to the transaction type", "matches the field indicated by the exposure identifier", and "belongs to the log generated by the special event function" "" and "meeting the preset conditions", so as to meet the above-mentioned function expansion requirements, while ensuring that most of the user privacy can be protected. In particular, when the first blockchain node recognizes the special event function based on the information recorded on the blockchain network (such as the list of special event functions), it can perform the "special event function" after the smart contract has been created. Update to adjust the storage method of receipt data, such as changing the original receipt content stored in plain text to cipher text storage, or changing the original receipt content stored in cipher text to plain text storage.

前述的代码示例可以基于交易发起方的用户类型、智能合约所含的事件函数和收据数据中满足预设条件的收据内容实现改进。在上述的代码示例2中,在智能合约的代码最前方添加暴露标识符plain,使得智能合约的代码被执行后,当交易发起方属于预 设用户类型时,对于收据数据中由特殊事件函数产生的日志,允许该智能合约所属交易的交易类型对应的暴露字段且满足预设条件的收据内容以明文形式进行存储,比如当日志中的From字段属于暴露字段、To字段并不属于暴露字段时,可以将收据数据中所有日志的From字段在满足预设条件时以明文形式存储、To字段以密文形式存储,那么后续可以针对该From字段中的收据内容实施检索操作,比如可以统计某一账户所发起的交易量等。The foregoing code example can be improved based on the user type of the transaction initiator, the event function contained in the smart contract, and the receipt content that meets the preset conditions in the receipt data. In the code example 2 above, the exposed identifier plain is added to the front of the smart contract code, so that after the smart contract code is executed, when the transaction initiator belongs to the preset user type, the receipt data is generated by the special event function The log allows the exposed field corresponding to the transaction type of the transaction to which the smart contract belongs and the content of the receipt meeting preset conditions is stored in clear text. For example, when the From field in the log is an exposed field and the To field is not an exposed field, The From field of all logs in the receipt data can be stored in plain text when the preset conditions are met, and the To field is stored in cipher text. Then, subsequent retrieval operations can be performed on the receipt content in the From field, for example, a certain account can be counted The volume of transactions initiated, etc.

由于暴露标识符为智能合约的编程语言中所定义的全局性标识,因而只要在智能合约中写入暴露标识符后,就难以修改该暴露标识符所标明的字段。而用户类型则取决于交易发起方、与编程语言无关,使得不同交易发起方即便调用同一智能合约时,对收据数据的存储方式(密文或明文)也可能存在不同。交易类型也可以由交易发起方根据需求而选取,以表明交易发起方的实际需求。预设条件可以由交易发起方根据实际需求而选取,与编程语言无关。同时,特殊事件函数的定义并不一定基于编程语言实现,比如在基于特殊事件函数列表等方式记录特殊事件函数时,即便智能合约中包含的某一事件函数原本属于特殊事件函数,也可以通过对特殊事件函数列表进行更改的方式,将原有的特殊事件函数更新为普通事件函数,从而避免该事件函数产生的日志以明文形式存储,或者将原有的普通事件函数更新为特殊事件函数,使得该事件函数产生的日志中的至少一部分内容以明文形式存储。因此,通过由不同用户对智能合约进行调用,或者发起不同类型的交易,或者调整智能合约所含事件函数的类型,或者选用不同的预设条件,可以跳脱暴露标识符的限制,调整需要明文或密文存储的收据内容。Since the exposed identifier is a global identifier defined in the programming language of the smart contract, it is difficult to modify the fields marked by the exposed identifier as long as the exposed identifier is written in the smart contract. The user type depends on the transaction initiator and has nothing to do with the programming language, so that even when different transaction initiators call the same smart contract, the storage method (ciphertext or plaintext) of the receipt data may be different. The transaction type can also be selected by the transaction initiator according to demand to indicate the actual needs of the transaction initiator. The preset conditions can be selected by the transaction initiator according to actual needs, regardless of the programming language. At the same time, the definition of special event functions is not necessarily based on programming languages. For example, when recording special event functions based on a list of special event functions, even if an event function included in the smart contract originally belongs to a special event function, it can be To change the list of special event functions, update the original special event function to a normal event function, so as to avoid storing the log generated by the event function in clear text, or update the original normal event function to a special event function, so that At least part of the content in the log generated by the event function is stored in plain text. Therefore, by calling the smart contract by different users, or initiating different types of transactions, or adjusting the type of event function contained in the smart contract, or selecting different preset conditions, you can escape the restriction of exposing identifiers. The adjustment requires clear text Or the content of the receipt stored in ciphertext.

以上述的代码示例2为例:假定事件currentPrice原本并未记录于特殊事件函数列表中,即事件currentPrice对应于普通事件函数,那么即便在智能合约的代码中添加了暴露标识符plain且交易发起方属于预设用户类型,事件currentPrice产生的日志中的各个字段(包括暴露字段)仍以密文形式存储。但是,如果将事件currentPrice添加至特殊事件函数列表中,那么代码示例2不需要调整的情况下,当交易发起方属于预设用户类型时,可使事件currentPrice对应的日志中的暴露字段在满足预设条件的情况下以明文形式存储。Take the above code example 2 as an example: assuming that the event currentPrice was not originally recorded in the special event function list, that is, the event currentPrice corresponds to a normal event function, then even if the exposure identifier plain is added to the smart contract code and the transaction initiator It belongs to a preset user type, and all fields (including exposed fields) in the log generated by the event currentPrice are still stored in cipher text. However, if the event currentPrice is added to the list of special event functions, the code sample 2 does not need to be adjusted, and when the transaction initiator belongs to the preset user type, the exposed field in the log corresponding to the event currentPrice can be made to meet the requirements. If the conditions are set, it will be stored in plain text.

需要指出的是:在上述的代码示例2中,通过在代码最前方声明“plain”,该暴露标识符“plain”所标明的字段为收据数据中的所有字段,且这些字段均为合约级字段,使得在交易发起方属于预设用户类型且该合约级字段属于暴露字段时,使事件currentPrice产生的日志中对应于该合约级字段且满足预设条件的收据内容均被允许以 明文形式存储。当然,如果代码示例2中通过暴露标识符标注了譬如From字段,那么该From字段为上述的合约级字段,当该From字段进一步属于交易类型对应的暴露字段时,可在交易发起方属于预设用户类型的情况下,使第一区块链节点在存储收据数据时,收据数据中所有对应于该From字段且满足预设条件的收据内容,均被允许以明文形式存储。It should be pointed out that: in the code example 2 above, by declaring "plain" at the front of the code, the fields marked by the exposed identifier "plain" are all fields in the receipt data, and these fields are contract-level fields , So that when the transaction initiator belongs to the preset user type and the contract-level field is an exposed field, the contents of the receipt corresponding to the contract-level field and meeting the preset conditions in the log generated by the event currentPrice are allowed to be stored in plain text. Of course, if the From field is marked with the exposed identifier in Code Example 2, then the From field is the contract-level field mentioned above. When the From field is further an exposed field corresponding to the transaction type, it can be preset at the transaction initiator In the case of the user type, when the first blockchain node stores receipt data, all receipt content in the receipt data that corresponds to the From field and meets the preset conditions is allowed to be stored in plain text.

尤其是,当智能合约的代码中包含多个事件函数时,在多个事件函数分别产生的各自对应的Logs字段中,均可能存在合约级字段所对应的收据内容;进一步地,可以通过识别交易发起方所属的用户类型、交易的交易类型对应的暴露字段、各个事件函数的类型为普通事件函数或特殊事件函数以及收据内容对预设条件的满足情况,从而在交易发起方属于预设用户类型且合约级字段属于暴露字段的情况下,将所有特殊事件函数所产生的日志中对应于合约级字段且满足预设条件的收据内容以明文形式存储。例如,在上述的代码示例5中,与代码示例2相类似地,暴露标识符“plain”位于智能合约的代码最前方,使得收据数据中的所有字段均被标注为合约级字段;同时,智能合约中包含了事件currentPrice1和事件currentPrice2:假定事件currentPrice1对应于特殊事件函数列表中定义的特殊事件函数、事件currentPrice2对应于普通事件函数,那么在交易发起方属于预设用户类型且From字段属于暴露字段的情况下,在事件currentPrice1和事件currentPrice2分别产生的日志Log1、Log2中,日志Log1包含的From字段在满足预设条件的情况下以明文形式存储、在未满足预设条件的情况下以密文形式存储,而日志Log2包含的From字段必然以密文形式存储;类似地,日志Log1中属于暴露字段的其他字段在满足预设条件时也以明文形式存储、非暴露字段以密文形式存储,而日志Log2的所有字段均以密文形式存储。并且,如果通过对特殊事件函数列表进行更新后,将事件currentPrice2更新为对应于特殊事件函数,那么日志Log2包含的属于暴露字段的所有字段可以在满足预设条件的情况下以明文形式存储、在未满足预设条件的情况下以密文形式存储,而无需对智能合约的代码做任何变动。In particular, when the code of the smart contract contains multiple event functions, in the respective Logs fields generated by the multiple event functions, there may be the receipt content corresponding to the contract-level field; further, the transaction can be identified by The user type to which the initiator belongs, the exposed fields corresponding to the transaction type of the transaction, the type of each event function is ordinary event function or special event function, and the content of the receipt meets the preset conditions, so that the transaction initiator belongs to the preset user type And when the contract-level field is an exposed field, the contents of the receipt corresponding to the contract-level field and satisfying the preset conditions in the logs generated by all special event functions are stored in plain text. For example, in the above code example 5, similar to the code example 2, the exposed identifier "plain" is located at the forefront of the smart contract code, so that all fields in the receipt data are marked as contract-level fields; at the same time, smart The contract contains the event currentPrice1 and the event currentPrice2: assuming that the event currentPrice1 corresponds to the special event function defined in the special event function list, and the event currentPrice2 corresponds to the normal event function, then the transaction initiator belongs to the preset user type and the From field is an exposed field In the case of the event currentPrice1 and event currentPrice2 generated logs Log1 and Log2, the From field contained in the log Log1 is stored in plain text when the preset conditions are met, and in cipher text when the preset conditions are not met The From field contained in log Log2 must be stored in cipher text; similarly, other fields in log Log1 that are exposed fields are also stored in plain text when the preset conditions are met, and non-exposed fields are stored in cipher text. All the fields of the log Log2 are stored in cipher text. Moreover, if the event currentPrice2 is updated to correspond to the special event function after updating the list of special event functions, all the fields belonging to the exposed fields contained in the log Log2 can be stored in plain text under the condition that the preset conditions are met. If the preset conditions are not met, it is stored in ciphertext form, without any changes to the code of the smart contract.

对于上述的合约级字段而言,可以通过前述的类型标识符来标明智能合约所含的事件函数是否为特殊事件函数。例如,在上述的代码示例6中,与代码示例2相类似地,合约级字段包括收据数据中的所有字段;同时,智能合约中包含了事件currentPrice1和事件currentPrice2:由于事件currentPrice1在包含如前所述的类型标识符expose,使得该事件currentPrice1被标注为对应于特殊事件函数,而事件currentPrice2并未包含类型标识符expose,使得事件currentPrice2被标注为对应于普通事件函数,那么在交易发起方属于预设用户类型的情况下,在事件currentPrice1和事件currentPrice2分别产生的 日志Log1、Log2中,日志Log1中对应于交易类型的所有暴露字段在满足预设条件的情况下以明文形式存储、在未满足预设条件的情况下以密文形式存储,而日志Log2包含的所有字段必然以密文形式存储。For the aforementioned contract-level fields, the aforementioned type identifier can be used to indicate whether the event function included in the smart contract is a special event function. For example, in the above code example 6, similar to the code example 2, the contract-level fields include all fields in the receipt data; at the same time, the smart contract contains the event currentPrice1 and the event currentPrice2: because the event currentPrice1 contains the same as before The type identifier expose mentioned above makes the event currentPrice1 be marked as corresponding to the special event function, and the event currentPrice2 does not contain the type identifier expose, so that the event currentPrice2 is marked as corresponding to the normal event function, then the event currentPrice2 is marked as corresponding to the normal event function. In the case of the user type, in the logs Log1 and Log2 generated by the event currentPrice1 and event currentPrice2 respectively, all the exposed fields in the log Log1 corresponding to the transaction type are stored in clear text when the preset conditions are met. When the conditions are set, it is stored in cipher text, and all fields contained in the log Log2 must be stored in cipher text.

除了合约级字段之外,暴露标识符标明的字段可以包括:对应于智能合约中定义的至少一个事件的事件级字段,使得在交易发起方属于预设用户类型且该事件级字段属于暴露字段的情况下,第一区块链节点将特殊事件函数产生的收据内容中对应于该事件级字段且满足预设条件的部分以明文形式存储。尤其是,当智能合约中包含多个事件时,可以针对至少一部分事件设定上述的事件级字段,使得这部分事件产生的日志中对应于上述事件级字段且满足预设条件的收据内容以明文形式存储,而这部分事件产生的日志中的其余收据内容、其余事件对应的收据内容均以密文形式存储。以From字段为例,在上述的代码示例7中,事件currentPrice1虽然未添加暴露标识符“plain”,但是包含了内容“from”,该内容“from”对应于From字段,用于表明事件currentPrice1所产生日志中的From字段需要以明文形式存储,因而该内容“from”既属于上述的暴露标识符,又标明了需要明文存储的From字段。并且,由于内容“from”位于事件currentPrice1中,因而From字段为事件级字段,使得在交易发起方属于预设用户类型且From字段属于暴露字段的情况下,当该事件currentPrice1对应于特殊事件函数时,在该事件currentPrice1对应产生的日志Logs中,From字段在满足预设条件的情况下以明文形式进行存储、在未满足预设条件的情况下以密文形式存储,而其他字段必然以密文形式存储。而对于代码示例7所含的另一事件currentPrice2,由于并未针对该事件currentPrice2添加暴露标识符,因而不论该事件currentPrice2对应于特殊事件函数或普通事件函数,所产生的日志Logs均以密文形式存储。该代码示例7对应的实施例中,即对于事件级字段而言,可以通过特殊事件函数列表或者类型标识符的方式识别智能合约所含的事件函数是否为特殊事件函数,此处不再一一赘述。In addition to the contract-level fields, the fields indicated by the exposure identifier may include: event-level fields corresponding to at least one event defined in the smart contract, so that the transaction initiator belongs to the preset user type and the event-level field belongs to the exposed field In this case, the first blockchain node stores the part of the receipt content generated by the special event function that corresponds to the event-level field and meets the preset condition in plain text. In particular, when the smart contract contains multiple events, the above event-level fields can be set for at least some of the events, so that the contents of the receipts that correspond to the above-mentioned event-level fields and meet the preset conditions in the logs generated by this part of the events are in plain text The content of the remaining receipts in the log generated by this part of the event and the content of the receipt corresponding to the remaining events are stored in the form of ciphertext. Take the From field as an example. In the above code sample 7, although the event currentPrice1 does not add the exposed identifier "plain", it contains the content "from". The content "from" corresponds to the From field and is used to indicate the event currentPrice1. The From field in the generated log needs to be stored in plain text, so the content "from" not only belongs to the above exposed identifier, but also indicates the From field that needs to be stored in plain text. Moreover, since the content "from" is in the event currentPrice1, the From field is an event-level field, so that when the transaction initiator belongs to the preset user type and the From field is an exposed field, when the event currentPrice1 corresponds to a special event function In the log Logs corresponding to the event currentPrice1, the From field is stored in plain text when the preset conditions are met, and stored in cipher text when the preset conditions are not met, and other fields must be stored in cipher text Form storage. As for the other event currentPrice2 contained in code example 7, since no exposure identifier is added for the event currentPrice2, regardless of whether the event currentPrice2 corresponds to a special event function or a normal event function, the generated log Logs are in ciphertext form storage. In the embodiment corresponding to this code example 7, that is, for event-level fields, it is possible to identify whether the event functions included in the smart contract are special event functions by means of a special event function list or type identifier. Repeat.

与图2所示实施例相类似的,上述扩展后的各个实施例同样可以通过链代码实现相应的逻辑功能,或者采用链代码与系统合约相结合的方式。其中,图2所示实施例采用的是与交易类型相关的收据数据存储逻辑,而上述扩展后的实施例在此基础上还进一步考量下述因素中至少之一:暴露标识符标明的对象、交易发起方的用户类型、收据数据中满足预设条件的收据内容和智能合约所含的事件函数。上述的一个或多个因素可以与用户类型相结合,以得到相应的收据数据存储逻辑。Similar to the embodiment shown in FIG. 2, the above-expanded embodiments can also implement corresponding logic functions through chain codes, or adopt a combination of chain codes and system contracts. Among them, the embodiment shown in FIG. 2 adopts the receipt data storage logic related to the transaction type, and the expanded embodiment described above further considers at least one of the following factors: exposing the object indicated by the identifier, The user type of the transaction initiator, the content of the receipt meeting preset conditions in the receipt data, and the event function contained in the smart contract. One or more of the above factors can be combined with the user type to obtain the corresponding receipt data storage logic.

当收据数据存储逻辑与暴露标识符标明的对象相关时,该收据数据存储逻辑包 括基于暴露标识符对收据内容进行存储的逻辑,该逻辑用于指示第一区块链节点:针对暴露标识符标明的字段、暴露标识符未标明的字段等,分别采用何种方式存储相应的收据内容。When the receipt data storage logic is related to the object indicated by the exposure identifier, the receipt data storage logic includes logic for storing the content of the receipt based on the exposure identifier, and the logic is used to instruct the first blockchain node: to indicate the exposure identifier The corresponding receipt content should be stored in the fields of, and fields not marked by the exposed identifier.

当收据数据存储逻辑与交易发起方的用户类型相关时,该收据数据存储逻辑包括:对用户类型的识别逻辑。对用户类型的识别逻辑用于指示第一区块链节点:识别交易发起方的用户类型。比如:系统合约中可以记录有预定义的外部账户与用户类型之间的关联关系,或者系统合约中可以记录有用户类型字段的取值与用户类型之间的对应关系。具体可以参考上文中识别用户类型的相关描述,此处不再赘述。When the receipt data storage logic is related to the user type of the transaction initiator, the receipt data storage logic includes: identification logic for the user type. 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.

当收据数据存储逻辑与智能合约所含的事件函数相关时,该收据数据存储逻辑包括:对事件函数的识别逻辑。对事件函数的识别逻辑用于指示第一区块链节点:识别交易对应的智能合约所含的事件函数的类型。比如:根据事件函数所含的类型标识符进行识别,或者根据区块链网络中记载的特殊事件函数列表进行识别。具体可以参考上文中识别特殊事件函数的相关描述,此处不再赘述。When the receipt data storage logic is related to the event function contained in the smart contract, the receipt data storage logic includes: identification logic for the event function. The identification logic of the event function is used to instruct the first blockchain node to identify the type of event function contained in the smart contract corresponding to the transaction. For example: according to the type identifier contained in the event function, or according to the list of special event functions recorded in the blockchain network. For details, please refer to the relevant description of identifying special event functions above, which will not be repeated here.

当收据数据存储逻辑与收据数据中满足预设条件的收据内容相关时,该收据数据存储逻辑包括:对预设条件的确定逻辑。对预设条件的确定逻辑用于指示第一区块链节点:获取暴露标识符标明的对象所对应的收据内容所适用的预设条件。比如:获取适用于所有收据字段的通用条件,或者获取适用于暴露标识符标明的对象所对应的收据内容的所处字段的专用条件等。具体可以参考上文中预设条件的相关描述,此处不再赘述。When the receipt data storage logic is related to the receipt content that meets the preset condition in the receipt data, the receipt data storage logic includes: logic for determining the preset condition. The determination logic of the preset condition is used to instruct the first blockchain node to obtain the preset condition applicable to the content of the receipt corresponding to the object indicated by the exposure identifier. For example, obtain general conditions applicable to all receipt fields, or obtain special conditions applicable to the field of the receipt content corresponding to the object indicated by the exposure identifier. For details, please refer to the relevant description of the preset conditions above, which will not be repeated here.

以下结合图6介绍本说明书一种基于交易类型的收据存储节点的实施例,包括:The following describes an embodiment of a receipt storage node based on transaction type in this specification with reference to FIG. 6, including:

接收单元61,接收经过加密的交易;The receiving unit 61 receives the encrypted transaction;

解密单元62,在可信执行环境中解密所述交易,获得交易内容;The decryption unit 62 decrypts the transaction in a trusted execution environment to obtain transaction content;

执行单元63,在所述可信执行环境中执行所述交易内容,得到收据数据;The execution unit 63 executes the transaction content in the trusted execution environment to obtain receipt data;

确定单元64,根据所述交易的交易类型,确定所述收据数据中的暴露字段;The determining unit 64 determines the exposed fields in the receipt data according to the transaction type of the transaction;

存储单元65,存储所述收据数据,使所述暴露字段对应的至少一部分收据内容以明文形式存储、其余收据内容以密文形式存储。The storage unit 65 stores the receipt data so that at least part of the receipt content corresponding to the exposed field is stored in plain text, and the rest of the receipt content is stored in cipher text.

可选的,所述交易包括交易类型字段,所述交易类型字段的取值用于标明相应的交易类型。Optionally, the transaction includes a transaction type field, and the value of the transaction type field is used to indicate the corresponding transaction type.

可选的,所述确定单元64具体用于:Optionally, the determining unit 64 is specifically configured to:

获取预定义的交易类型与暴露字段之间的映射关系;Obtain the mapping relationship between predefined transaction types and exposed fields;

根据所述交易的交易类型和所述映射关系,确定所述收据数据中的暴露字段。Determine the exposed field in the receipt data according to the transaction type of the transaction and the mapping relationship.

可选的,所述映射关系记录于系统合约中。Optionally, the mapping relationship is recorded in a system contract.

可选的,所述存储单元65具体用于:Optionally, the storage unit 65 is specifically configured to:

读取系统合约的代码,所述系统合约的代码中定义了与交易类型相关的收据数据存储逻辑;Read the code of the system contract, which defines the receipt data storage logic related to the transaction type;

执行所述系统合约的代码,以将所述暴露字段以明文形式存储、其余收据字段以密文形式存储。The code of the system contract is executed to store the exposed fields in plaintext and the remaining receipt fields in ciphertext.

可选的,所述系统合约包括:记录于创世块中的预置系统合约,或所述预置系统合约对应的更新后系统合约。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.

可选的,所述交易的交易类型包括:存证类型、资产转移类型、合约创建类型、合约调用类型。Optionally, the transaction type of the transaction includes: deposit certificate type, asset transfer type, contract creation type, contract call type.

可选的,所述存储单元65具体用于:Optionally, the storage unit 65 is specifically configured to:

存储所述收据数据,使交易发起方属于预设用户类型的情况下,所述暴露字段对应的至少一部分收据内容以明文形式存储、其余收据内容以密文形式存储。When the receipt data is stored so that the transaction initiator belongs to a preset user type, at least a part of the receipt content corresponding to the exposed field is stored in plain text, and the rest of the receipt content is stored in cipher text.

可选的,所述存储单元65通过下述方式确定所述交易发起方所属的用户类型:Optionally, the storage unit 65 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 user type field recorded on the blockchain, and the value of the user 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.

可选的,以明文形式存储的所述至少一部分收据内容满足下述规则中至少之一:Optionally, the at least part of the receipt content stored in plaintext meets at least one of the following rules:

所述至少一部分收据内容由所述交易对应的智能合约所含的特殊事件函数所产生;The at least part of the receipt content is generated by a special event function included in the smart contract corresponding to the transaction;

所述至少一部分收据内容所含的信息满足预设条件;The information contained in the at least part of the receipt content meets a preset condition;

所述至少一部分收据内容对应于由所述智能合约的代码所含的暴露标识符标明的对象。The at least a part of the receipt content corresponds to the object indicated by the exposure identifier contained in the code of the smart contract.

可选的,所述智能合约中的事件函数包含类型标识符,所述类型标识符用于将所述事件函数标记为特殊事件函数。Optionally, the event function in the smart contract includes a type identifier, and the type identifier is used to mark the event function as a special event function.

可选的,当所述智能合约包含的事件函数位于区块链上记录的特殊函数列表中时,所述智能合约包含的事件函数被判定为特殊事件函数。Optionally, when the event function included in the smart contract is in the special function list recorded on the blockchain, the event function included in the smart contract is determined to be a special event function.

可选的,所述预设条件包括以下至少之一:相应的收据内容中包含预设内容、相应的收据内容的取值属于预设数值区间。Optionally, the preset condition includes at least one of the following: the corresponding receipt content includes the preset content, and the value of the corresponding receipt content belongs to the preset numerical interval.

可选的,Optional,

所述预设条件包括所述收据数据中的所有收据字段对应的通用条件;或,The preset conditions include general conditions corresponding to all receipt fields in the receipt data; or,

所述预设条件包括所述收据数据中的每一收据字段分别对应的专用条件。The preset condition includes a dedicated condition corresponding to each receipt field in the receipt data.

可选的,Optional,

所述预设条件位于所述交易中;或,The preset condition is in the transaction; or,

所述预设条件位于所述交易对应的智能合约中,或所述交易对应的智能合约所调用的另一智能合约中;或,The preset condition is located in the smart contract corresponding to the transaction, or in another smart contract called by the smart contract corresponding to the transaction; or,

所述预设条件位于系统合约或链代码中。The preset conditions are located in the system contract or chain code.

可选的,所述接收单元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, the smart contract written in the high-level language and the smart contract in bytecode form have the same or corresponding exposure identifier.

可选的,所述暴露标识符标明的对象包括:收据字段和/或状态变量。Optionally, the objects indicated by the exposure identifier include: receipt fields and/or state variables.

可选的,所述暴露标识符标明的对象包括下述至少之一:适用于所述智能合约 中定义的所有事件的合约级对象,对应于所述智能合约中定义的至少一个事件的事件级对象。Optionally, the object indicated by the exposure identifier includes at least one of the following: a contract-level object applicable to all events defined in the smart contract, and an event-level object corresponding to at least one event defined in the smart contract Object.

可选的,所述存储单元65具体用于:Optionally, the storage unit 65 is specifically configured to:

在所述可信执行环境之外执行存储功能代码,以将所述收据数据存储至所述可信执行环境之外的外部存储空间。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 key used by the first blockchain node to encrypt the receipt data 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 a 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 decrypt the transaction with the initial key to obtain the transaction content.

可选的,所述初始密钥由客户端生成;或,所述初始密钥由密钥管理服务器发送至所述客户端。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.

计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(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, commodity or equipment including a series of elements not only includes those elements, but also includes Other elements that are not explicitly listed, or they also include elements inherent to such processes, methods, commodities, 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 (32)

一种基于交易类型的收据存储方法,包括:A receipt storage method based on transaction type, including: 第一区块链节点接收经过加密的交易;The first blockchain node receives the encrypted transaction; 第一区块链节点在可信执行环境中解密所述交易并执行获得的交易内容,得到收据数据;The first blockchain node decrypts the transaction in the trusted execution environment and executes the obtained transaction content to obtain receipt data; 第一区块链节点根据所述交易的交易类型,确定所述收据数据中的暴露字段;The first blockchain node determines the exposed field in the receipt data according to the transaction type of the transaction; 第一区块链节点存储所述收据数据,使所述暴露字段对应的至少一部分收据内容以明文形式存储、其余收据内容以密文形式存储。The first blockchain node stores the receipt data so that at least part of the receipt content corresponding to the exposed field is stored in plain text, and the rest of the receipt content is stored in cipher text. 根据权利要求1所述的方法,所述交易包括交易类型字段,所述交易类型字段的取值用于标明相应的交易类型。The method according to claim 1, wherein the transaction includes a transaction type field, and the value of the transaction type field is used to indicate the corresponding transaction type. 根据权利要求1所述的方法,第一区块链节点根据所述交易的交易类型,确定所述收据数据中的暴露字段,包括:The method according to claim 1, wherein the first blockchain node determines the exposed field in the receipt data according to the transaction type of the transaction, including: 第一区块链节点获取预定义的交易类型与暴露字段之间的映射关系;The first blockchain node obtains the mapping relationship between the predefined transaction type and the exposed field; 第一区块链节点根据所述交易的交易类型和所述映射关系,确定所述收据数据中的暴露字段。The first blockchain node determines the exposed field in the receipt data according to the transaction type of the transaction and the mapping relationship. 根据权利要求3所述的方法,所述映射关系记录于系统合约中。According to the method of claim 3, the mapping relationship is recorded in a system contract. 根据权利要求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 transaction type; 第一区块链节点执行所述系统合约的代码,以将所述暴露字段以明文形式存储、其余收据字段以密文形式存储。The first blockchain node executes the code of the system contract to store the exposed fields in plain text and the remaining receipt fields in cipher text. 根据权利要求4或5所述的方法,所述系统合约包括:记录于创世块中的预置系统合约,或所述预置系统合约对应的更新后系统合约。The method according to claim 4 or 5, the system contract comprises: a preset system contract recorded in the genesis block, or an updated system contract corresponding to the preset system contract. 根据权利要求1所述的方法,所述交易的交易类型包括:存证类型、资产转移类型、合约创建类型、合约调用类型。The method according to claim 1, wherein the transaction type of the transaction includes: deposit certificate type, asset transfer type, contract creation type, contract call type. 根据权利要求1所述的方法,第一区块链节点存储所述收据数据,包括:The method according to claim 1, wherein the first blockchain node storing the receipt data includes: 第一区块链节点存储所述收据数据,使交易发起方属于预设用户类型的情况下,所述暴露字段对应的至少一部分收据内容以明文形式存储、其余收据内容以密文形式存储。The first blockchain node stores the receipt data so that when the transaction initiator belongs to a preset user type, at least part of the receipt content corresponding to the exposed field is stored in plain text, and the rest of the receipt content is stored in cipher text. 根据权利要求8所述的方法,第一区块链节点通过下述方式确定所述交易发起方所属的用户类型:According to the method of claim 8, 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. 根据权利要求9所述的方法,所述外部账户包括记录于区块链上的用户类型字段,所述用户类型字段的取值对应于所述用户类型。The method according to claim 9, wherein the external account includes a user type field recorded on the blockchain, and the value of the user type field corresponds to the user type. 根据权利要求9所述的方法,在创建所述外部账户时,所述用户类型被配置为关联至所述外部账户,使所述用户类型与所述外部账户之间的关联关系被记录于区块链中。The method according to claim 9, wherein 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. 根据权利要求11所述的方法,还包括:The method according to claim 11, 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. 根据权利要求1所述的方法,以明文形式存储的所述至少一部分收据内容满足下述规则中至少之一:The method according to claim 1, wherein the at least part of the receipt content stored in plaintext meets at least one of the following rules: 所述至少一部分收据内容由所述交易对应的智能合约所含的特殊事件函数所产生;The at least part of the receipt content is generated by a special event function included in the smart contract corresponding to the transaction; 所述至少一部分收据内容所含的信息满足预设条件;The information contained in the at least part of the receipt content meets a preset condition; 所述至少一部分收据内容对应于由所述智能合约的代码所含的暴露标识符标明的对象。The at least a part of the receipt content corresponds to the object indicated by the exposure identifier contained in the code of the smart contract. 根据权利要求13所述的方法,所述智能合约中的事件函数包含类型标识符,所述类型标识符用于将所述事件函数标记为特殊事件函数。The method according to claim 13, wherein the event function in the smart contract includes a type identifier, and the type identifier is used to mark the event function as a special event function. 根据权利要求13所述的方法,当所述智能合约包含的事件函数位于区块链上记录的特殊函数列表中时,所述智能合约包含的事件函数被判定为特殊事件函数。According to the method of claim 13, when the event function included in the smart contract is in the special function list recorded on the blockchain, the event function included in the smart contract is determined to be a special event function. 根据权利要求13所述的方法,所述预设条件包括以下至少之一:相应的收据内容中包含预设内容、相应的收据内容的取值属于预设数值区间。The method according to claim 13, wherein the preset condition includes at least one of the following: the corresponding receipt content contains the preset content, and the value of the corresponding receipt content belongs to the preset numerical interval. 根据权利要求13所述的方法,According to the method of claim 13, 所述预设条件包括所述收据数据中的所有收据字段对应的通用条件;或,The preset conditions include general conditions corresponding to all receipt fields in the receipt data; or, 所述预设条件包括所述收据数据中的每一收据字段分别对应的专用条件。The preset condition includes a dedicated condition corresponding to each receipt field in the receipt data. 根据权利要求13所述的方法,According to the method of claim 13, 所述预设条件位于所述交易中;或,The preset condition is in the transaction; or, 所述预设条件位于所述交易对应的智能合约中,或所述交易对应的智能合约所调用的另一智能合约中;或,The preset condition is located in the smart contract corresponding to the transaction, or in another smart contract called by the smart contract corresponding to the transaction; or, 所述预设条件位于系统合约或链代码中。The preset conditions are located in the system contract or chain code. 根据权利要求13所述的方法,第一区块链节点接收的交易对应的智能合约,包括:According to the method of claim 13, 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. 根据权利要求19所述的方法,所述高级语言编写的智能合约与所述字节码形式的智能合约具有相同或对应的暴露标识符。According to the method of claim 19, the smart contract written in the high-level language and the smart contract in the bytecode form have the same or corresponding exposure identifier. 根据权利要求13所述的方法,所述暴露标识符标明的对象包括:收据字段和/或状态变量。The method according to claim 13, wherein the objects indicated by the exposure identifier include: receipt fields and/or state variables. 根据权利要求13所述的方法,所述暴露标识符标明的对象包括下述至少之一:适用于所述智能合约中定义的所有事件的合约级对象,对应于所述智能合约中定义的至少一个事件的事件级对象。The method according to claim 13, wherein the object indicated by the exposure identifier includes at least one of the following: a contract-level object applicable to all events defined in the smart contract, corresponding to at least one defined in the smart contract The event-level object of an event. 根据权利要求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. 根据权利要求1所述的方法,第一区块链节点对所述收据数据进行加密的密钥包括:对称加密算法的密钥或非对称加密算法的密钥。According to the method of claim 1, the key used by the first blockchain node to encrypt the receipt data comprises: a key of a symmetric encryption algorithm or a key of an asymmetric encryption algorithm. 根据权利要求24所述的方法,所述对称加密算法的密钥包括所述客户端提供的初始密钥;或,所述对称加密算法的密钥包括所述初始密钥与影响因子生成的衍生密钥。The method according to claim 24, wherein 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 derivative generated by the initial key and an impact factor Key. 根据权利要求25所述的方法,所述交易由所述初始密钥进行加密,且所述初始密钥被非对称加密算法的公钥进行加密;第一区块链节点在可信执行环境中解密所述交易,包括:The method according to claim 25, 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 Decrypt the transaction, including: 第一区块链节点用所述非对称加密算法的私钥解密得到所述初始密钥,并用所述初始密钥对所述交易进行解密,以得到所述交易内容。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 transaction content. 根据权利要求25所述的方法,所述初始密钥由客户端生成;或,所述初始密钥由密钥管理服务器发送至所述客户端。According to the method of claim 25, the initial key is generated by a client; or, the initial key is sent to the client by a key management server. 根据权利要求25所述的方法,所述影响因子与所述交易相关。The method of claim 25, wherein the impact factor is related to the transaction. 根据权利要求28所述的方法,所述影响因子包括:所述交易的哈希值的指定位。The method according to claim 28, wherein the impact factor comprises: a designated bit of a hash value of the transaction. 一种基于交易类型的收据存储节点,包括:A receipt storage node based on transaction type, including: 接收单元,接收经过加密的交易;The receiving unit receives encrypted transactions; 解密单元,在可信执行环境中解密所述交易,获得交易内容;The decryption unit decrypts the transaction in a trusted execution environment to obtain transaction content; 执行单元,在所述可信执行环境中执行所述交易内容,得到收据数据;The execution unit executes the transaction content in the trusted execution environment to obtain receipt data; 确定单元,根据所述交易的交易类型,确定所述收据数据中的暴露字段;The determining unit determines the exposed fields in the receipt data according to the transaction type of the transaction; 存储单元,存储所述收据数据,使所述暴露字段对应的至少一部分收据内容以明文形式存储、其余收据内容以密文形式存储。The storage unit stores the receipt data so that at least part of the receipt content corresponding to the exposed field is stored in plain text, and the rest of the receipt content is stored in cipher text. 一种电子设备,包括:An electronic device including: 处理器;processor; 用于存储处理器可执行指令的存储器;A memory for storing processor executable instructions; 其中,所述处理器通过运行所述可执行指令以实现如权利要求1-29中任一项所述的方法。Wherein, the processor executes the executable instruction to implement the method according to any one of claims 1-29. 一种计算机可读存储介质,其上存储有计算机指令,该指令被处理器执行时实现如权利要求1-29中任一项所述方法的步骤。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-29.
PCT/CN2020/089384 2019-05-20 2020-05-09 Receipt storage method and node based on transaction type Ceased WO2020233423A1 (en)

Applications Claiming Priority (32)

Application Number Priority Date Filing Date Title
CN201910419943.0 2019-05-20
CN201910420663.1A CN110245946B (en) 2019-05-20 2019-05-20 Receipt storage method and node combining code labeling and multi-type dimensionality
CN201910419943.0A CN110245504B (en) 2019-05-20 2019-05-20 Receipt storage method and node combined with condition limitation of multi-type dimensionality
CN201910419140.5A CN110264192B (en) 2019-05-20 2019-05-20 Receipt storage method and node based on transaction type
CN201910420679.2A CN110266644B (en) 2019-05-20 2019-05-20 Receipt storage method and node combining code marking and transaction types
CN201910420663.1 2019-05-20
CN201910420679.2 2019-05-20
CN201910419930.3 2019-05-20
CN201910420680.5 2019-05-20
CN201910419908.9A CN110223172B (en) 2019-05-20 2019-05-20 Conditional receipt storage method and node combining code labeling and type dimension
CN201910419887.0 2019-05-20
CN201910419140.5 2019-05-20
CN201910420689.6A CN110276684B (en) 2019-05-20 2019-05-20 Receipt storage method and node combining transaction type and event function type
CN201910420675.4A CN110263544B (en) 2019-05-20 2019-05-20 Receipt storage method and node combining transaction type and judgment condition
CN201910419925.2A CN110263089B (en) 2019-05-20 2019-05-20 Receipt storage method and node combining conditional restrictions of transaction and event types
CN201910420668.4A CN110264198B (en) 2019-05-20 2019-05-20 Conditional receipt storage method and node combining code labeling and transaction type
CN201910419887.0A CN110264195B (en) 2019-05-20 2019-05-20 Receipt storage method and node combining code marking with transaction and user type
CN201910419728.0 2019-05-20
CN201910419898.9 2019-05-20
CN201910419925.2 2019-05-20
CN201910420668.4 2019-05-20
CN201910419728.0A CN110264193B (en) 2019-05-20 2019-05-20 Receipt storage method and node combining user type and transaction type
CN201910419908.9 2019-05-20
CN201910420689.6 2019-05-20
CN201910419897.4A CN110278193B (en) 2019-05-20 2019-05-20 Receipt storage method and node combining code marking with transaction and event types
CN201910419898.9A CN110263087B (en) 2019-05-20 2019-05-20 Receipt storage method and node based on multi-dimensional information and with conditional restriction
CN201910420675.4 2019-05-20
CN201910419930.3A CN110263090B (en) 2019-05-20 2019-05-20 Receipt storage method and node with multiple types of dimensions
CN201910419897.4 2019-05-20
CN201910419900.2 2019-05-20
CN201910419900.2A CN110245490B (en) 2019-05-20 2019-05-20 Conditional receipt storage method and node combining code labeling and type dimension
CN201910420680.5A CN110245947B (en) 2019-05-20 2019-05-20 Receipt storage method and node combining conditional restrictions of transaction and user types

Publications (1)

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

Family

ID=73459099

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/089384 Ceased WO2020233423A1 (en) 2019-05-20 2020-05-09 Receipt storage method and node based on transaction type

Country Status (1)

Country Link
WO (1) WO2020233423A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114172667A (en) * 2021-06-15 2022-03-11 支付宝(杭州)信息技术有限公司 Privacy evidence storing method and device based on contract

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106709360A (en) * 2015-11-17 2017-05-24 福州瑞芯微电子股份有限公司 Data transmission and storage method and system
CN106850200A (en) * 2017-01-25 2017-06-13 中钞信用卡产业发展有限公司北京智能卡技术研究院 A kind of method for using the digital cash based on block chain, system and terminal
WO2018031212A1 (en) * 2016-08-11 2018-02-15 Intel Corporation Secure public cloud
CN108418689A (en) * 2017-11-30 2018-08-17 矩阵元技术(深圳)有限公司 A zero-knowledge proof method and medium suitable for blockchain privacy protection
CN109033855A (en) * 2018-07-18 2018-12-18 腾讯科技(深圳)有限公司 A kind of data transmission method based on block chain, device and storage medium
CN109299217A (en) * 2018-11-02 2019-02-01 符安文 A kind of secure storage and search method based on block chain
CN110263544A (en) * 2019-05-20 2019-09-20 阿里巴巴集团控股有限公司 In conjunction with the receipt storage method and node of type of transaction and Rule of judgment
CN110264192A (en) * 2019-05-20 2019-09-20 阿里巴巴集团控股有限公司 Receipt storage method and node based on type of transaction

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106709360A (en) * 2015-11-17 2017-05-24 福州瑞芯微电子股份有限公司 Data transmission and storage method and system
WO2018031212A1 (en) * 2016-08-11 2018-02-15 Intel Corporation Secure public cloud
CN106850200A (en) * 2017-01-25 2017-06-13 中钞信用卡产业发展有限公司北京智能卡技术研究院 A kind of method for using the digital cash based on block chain, system and terminal
CN108418689A (en) * 2017-11-30 2018-08-17 矩阵元技术(深圳)有限公司 A zero-knowledge proof method and medium suitable for blockchain privacy protection
CN109033855A (en) * 2018-07-18 2018-12-18 腾讯科技(深圳)有限公司 A kind of data transmission method based on block chain, device and storage medium
CN109299217A (en) * 2018-11-02 2019-02-01 符安文 A kind of secure storage and search method based on block chain
CN110263544A (en) * 2019-05-20 2019-09-20 阿里巴巴集团控股有限公司 In conjunction with the receipt storage method and node of type of transaction and Rule of judgment
CN110264192A (en) * 2019-05-20 2019-09-20 阿里巴巴集团控股有限公司 Receipt storage method and node based on type of transaction

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114172667A (en) * 2021-06-15 2022-03-11 支付宝(杭州)信息技术有限公司 Privacy evidence storing method and device based on contract

Similar Documents

Publication Publication Date Title
CN110223172B (en) Conditional receipt storage method and node combining code labeling and type dimension
WO2020233616A1 (en) Receipt storage method and node employing code marking in combination with transaction type and user type
CN110263087B (en) Receipt storage method and node based on multi-dimensional information and with conditional restriction
CN110245490B (en) Conditional receipt storage method and node combining code labeling and type dimension
CN110278193B (en) Receipt storage method and node combining code marking with transaction and event types
CN110263544B (en) Receipt storage method and node combining transaction type and judgment condition
CN110245942B (en) Receipt storage method and node combining user type and judgment condition
CN110263091B (en) Receipt storage method and node combining code marking with user and event type
CN110245947B (en) Receipt storage method and node combining conditional restrictions of transaction and user types
CN110245946B (en) Receipt storage method and node combining code labeling and multi-type dimensionality
WO2020233613A1 (en) Conditional receipt storage method and node which combine code marking with transaction type
CN110264196B (en) Conditional receipt storage method and node combining code labeling and user type
CN110264197B (en) Receipt storage method and node combining event function type and judgment condition
WO2020233630A1 (en) User type-based receipt storing method and node
CN110245504B (en) Receipt storage method and node combined with condition limitation of multi-type dimensionality
WO2020233631A1 (en) Transaction type-based receipt storage method and node
WO2020233638A1 (en) Receipt storage method and node based on code labeling and transaction type
CN110263088B (en) Conditional receipt storage method and node combining code labeling and event type
WO2020233640A1 (en) Receipt storage method and node based on code labeling and determination condition
WO2020233637A1 (en) Receipt storage method combining code labelling with user type, and node
WO2020233615A1 (en) Receipt storage method combining user type and event function type and node
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
WO2020233639A1 (en) Receipt storage method and node based on code labeling and event function type
WO2020233627A1 (en) Receipt storage method and node based on multiple types of dimensions

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

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

Country of ref document: EP

Kind code of ref document: A1

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载