Specific embodiment
Example embodiments are described in detail here, and the example is illustrated in the accompanying drawings.Following description is related to
When attached drawing, unless otherwise indicated, the same numbers in different drawings indicate the same or similar elements.Following exemplary embodiment
Described in embodiment do not represent all embodiments consistent with this specification one or more embodiment.Phase
Instead, they are only some aspects phases with the one or more embodiments of as detailed in the attached claim, this specification
The example of consistent device and method.
It should be understood that the sequence that might not show and describe according to this specification in other embodiments executes
The step of correlation method.In some other embodiments, step included by method can than described in this specification more
It is more or less.In addition, single step described in this specification, may be broken down into other embodiments multiple steps into
Row description;And multiple steps described in this specification, it may also be merged into single step progress in other embodiments
Description.
Block chain is normally divided into three types: publicly-owned chain (Public Blockchain), privately owned chain (Private
) and alliance's chain (Consortium Blockchain) Blockchain.In addition, there are also a plurality of types of combinations, such as privately owned chain
The different combinations such as+alliance chain, alliance's chain+publicly-owned chain.It is publicly-owned chain that wherein decentralization degree is highest.Publicly-owned chain with than
Special coin, ether mill are representative, and the participant that publicly-owned chain is added can read data record on chain, participate in business and compete newly
Book keeping operation power of block etc..Moreover, each participant's (i.e. node) freely can be added and exit network, and carry out relevant operation.It is private
There is chain then on the contrary, the write-in permission of the network is by some tissue or mechanism controls, reading data permission is by organization prescribed.Simply
For, privately owned chain can be weak center's system, and participating in node has stringent limitation and less.Such block chain is more
It is suitable for using inside particular organization.Alliance's chain is then block chain between publicly-owned chain and privately owned chain, it can be achieved that " part
Decentralization ".Each node usually has corresponding physical mechanism or tissue in alliance's chain;Participant is added by authorization
Enter network and composition interests correlation alliance, it is common to safeguard the operation of block chain.
Whether publicly-owned chain, privately owned chain or alliance's chain, the node in block chain network is after executing the transaction received, meeting
Corresponding receipt (receipt) data are generated, for recording the relevant receipt information of the transaction.By taking ether mill as an example, node
Executing resulting receipt data of trading may include following content:
Result field indicates the implementing result of transaction;
Gas used field indicates the gas value of transaction consumption;
Logs field indicates that the log that transaction generates, log may further include From field, To field, Topic word
Section and Log data field etc., wherein From field indicates that the account address of the initiator called, To field indicate called pair
As the account address of (such as intelligent contract), Topic field indicate that the theme of log, Log data field indicate daily record data;
Output field indicates the output of transaction.
For node when executing each transaction contained by a certain block, each transaction can all generate corresponding receipt after being performed
Data, and node can organize each corresponding receipts of trading contained by the block according to predefined tree and processing logic
According to data, a receipt tree is formed.Receipt tree is generated by tissue, so that when being inquired or being verified for receipt data,
Corresponding inquiry or verification efficiency can greatly be promoted.For example, using MPT (Merkle Patricia Tree) in ether mill
Structure organization generates above-mentioned receipt tree, and the leaf of the receipt tree is the Kazakhstan of each corresponding receipt data of trading contained by the block
Uncommon value, and receipt tree root (receiptRoot) is to be breathed out according to the root that the cryptographic Hash of the receipt data of leaf generates upwards in turn
It is uncommon.Certainly, other kinds of tree can also be used in other block chain networks.
In general, the receipt data that transaction generates after executing is stored with plaintext version, anyone is it can be seen that receive
According to the content of above-mentioned each receipt field contained by data, the setting and ability of no secret protection.And in some block chains and TEE
In the solution that (Trusted Execution Environment, credible performing environment) combines, for secret protection
Purpose needs to store receipt data with ciphertext form.
Such as shown in Fig. 1, the first block chain node includes the conventional environment (being located at left side in figure) and TEE in left side, client
The transaction that end (or other sources) is submitted initially enters " transaction/query interface " in conventional environment, then extremely by transaction transport
It is handled in TEE.TEE is mutually isolated with conventional environment.For example, the transaction needs to be passed to TEE when transaction is encrypted
The transaction content for plaintext is inside decrypted, thus under the premise of ensuring data safety, enables the transaction content of the plaintext
Efficient process is enough realized in TEE, and the receipt data of plaintext is generated in TEE.
TEE is the security extension based on CPU hardware, and the credible performing environment completely isolated with outside.TEE be earliest by
The concept that Global Platform is proposed, for solving the security isolation of resource in mobile device, being parallel to operating system is to answer
Credible and secure performing environment is provided with program.The Trust Zone technology of ARM realizes the TEE technology of real commercialization earliest.
Along with the high speed development of internet, safe demand is higher and higher, is not limited only to mobile device, cloud device, data center
More demands all are proposed to TEE.The concept of TEE has also obtained the development and expansion of high speed.Now described TEE compare with
The concept initially proposed has been the TEE of more broad sense.For example, server chips manufacturer Intel, AMD etc. are successively proposed
The TEE of hardware auxiliary and the concept and characteristic for enriching TEE, have been widely recognized in industry.The TEE lifted now is logical
Often more refer to the TEE technology of this kind of hardware auxiliary.Different from mobile terminal, cloud access needs to remotely access, and terminal user is to hard
Part platform is invisible, therefore seeks to the genuine and believable of confirmation TEE using the first step of TEE.Therefore present TEE technology is all drawn
Enter remote proving mechanism, endorsed by hardware vendor (mainly CPU manufacturer) and ensures user to TEE by digital signature technology
State can verify that.It is simultaneously only the demand for security that the resource isolation of safety is also unable to satisfy, further data-privacy protection
Also it is suggested.Including Intel SGX, the commercial TEE including AMD SEV also both provides memory encryption technology, by reliable hardware
It is limited to inside CPU, the data of bus and memory are that ciphertext prevents malicious user from being spied upon.For example, the software of Intel
Protection extends code execution, remote proving, security configuration, the secure storage of data such as (SGX) TEE technology insulation and is used for
Execute the trusted path of code.The application program run in TEE is kept safe, as a consequence it is hardly possible to be accessed by third party.
By taking Intel SGX technology as an example, SGX provides enclosure (enclave, also referred to as enclave), i.e., one adds in memory
Close credible execution region, protects data not to be stolen by CPU.By taking the first block chain node is using the CPU for supporting SGX as an example,
Using newly-increased processor instruction, a part of region EPC (Enclave Page Cache, enclosure page can be distributed in memory
Face caching or enclave page cache), by the crypto engine MEE (Memory Encryption Engine) in CPU to wherein
Data encrypted.The content encrypted in EPC, which only enters after CPU, can just be decrypted into plain text.Therefore, in SGX, user
It can distrust operating system, VMM (Virtual Machine Monitor, monitor of virtual machine), even BIOS (Basic
Input Output System, basic input output system), it is only necessary to trust CPU just and can ensure that private data will not leak.
It in practical application, is transferred in enclosure after private data being encrypted with ciphertext form, and will be corresponding by remote proving
Code key is also passed to enclosure.Then, operation is carried out using data under the encipherment protection of CPU, as a result can be returned with ciphertext form.This
Under kind mode, powerful calculating power not only can use, but also do not have to concern of data and leak.
In the related art, the full content of the receipt data generated in TEE is taken as the data for needing secret protection
It is stored on block chain.The block chain is stored in data acquisition system made of certain logic tissue in the database of node.Institute
Database is stated, as described later, physical support can store medium, such as persistent storage medium.In fact, different user pair
It is not identical in the secret protection demand of receipt data.For example, a part of user may relatively more focus on secret protection, that
The receipt data that the transaction that the user can be initiated as far as possible generates is stored using ciphertext form;Another part user
Availability of data may be relatively more focused on, for example wishes to support the search operaqtion to receipt data, to drive such as DAPP
(Decentralized Application, Distributed Application) client executing relevant treatment operations etc..
Below in conjunction with the implementation for illustrating that the application one combines the receipt storage method of user type and type of transaction shown in Fig. 2
The realization process of example:
Step 202, the first block chain node receives the transaction by encryption.
In one embodiment, user can generate transaction directly on the first block chain node;Alternatively, user can be in visitor
Transaction is generated on the end of family, and the transaction is sent to by the first block chain node by client;Alternatively, client can will be above-mentioned
Transaction is sent to the second block chain node, and the transaction is sent to the first block chain node by the second block chain node.
Transaction in this specification can be used to implement relatively simple processing logic, for example be similar in the related technology
It transfers accounts logic.At this point, above-mentioned transaction can be unrelated with intelligent contract.
Transaction in this specification can be also used for realizing relative complex processing logic, here can be by means of above-mentioned
Intelligent contract is realized.Intelligent contract on block chain is the contract that can be executed by transaction triggering on block catenary system.Intelligence
Energy contract can pass through the formal definition of code.
By taking ether mill as an example, user is supported to create in the network of ether mill and call the logic of some complexity, this is ether
Mill is different from the ultimate challenge of bit coin block chain technology.Ether mill is ether mill void as the core of a programmable block chain
Quasi- machine (EVM), each ether mill node can run EVM.EVM is the complete virtual machine of figure spirit, it means that can be with
The logic of various complexity is realized by it.It is exactly to run on EVM that user, which issues in ether mill and call intelligent contract,.It is real
On border, what virtual machine was directly run is virtual machine code (Virtual Machine bytecodes, lower abbreviation " bytecode ").It is deployed on block chain
Intelligent contract can be the form of bytecode.
Such as shown in Fig. 3, after a transaction comprising the intelligent contract information of creation is sent ether mill network by Bob, section
The EVM of point 1 can execute this and trade and generate corresponding contract example." 0x6f8ae93 ... " in 3 in figure represents this
The address of contract, what the data field of transaction saved can be bytecode, and the to field of transaction is sky.Pass through common recognition machine between node
After system is reached an agreement, this contract is successfully created, and can be called in the follow-up process.After contract creation, on block chain
There is a contract account corresponding with the intelligence contract, and possess a specific address, contract code will be stored in the conjunction
About in account.The behavior of intelligent contract is controlled by contract code.In other words, intelligent contract to generate on block chain comprising closing
The about virtual account of code and account storage (Storage).
As shown in figure 4, one is used to call the transaction of intelligent contract to be sent to ether mill by Bob still by taking ether mill as an example
After network, the EVM of a certain node can execute this and trade and generate corresponding contract example.The from word traded in 2 in figure
Section is the address of the account of transaction initiator (i.e. Bob), and " 0x6f8ae93 ... " in field represents called intelligence and close
Address about, value field are the value of ether coin, the side of the intelligent contract of the calling that the data field of transaction saves in ether mill
Method and parameter.Intelligent contract in a prescribed manner in block chain network each node disjoint execution, all execution record and
Data are all stored on block chain, so just saving the transaction that can not be distorted, will not lose on block chain after the completion of transaction
Voucher.
As it can be seen that transaction content may include the generation of the intelligent contract of required creation when transaction is for creating intelligent contract
Code;When transaction is for calling intelligent contract, transaction content may include the account address of called intelligent contract, need to pass
Method and parameter for entering etc..
Step 204, the first block chain node is decrypted in credible performing environment in the transaction traded and execute acquisition
Hold, obtains receipt data.
In one embodiment, by encrypting to transaction content, the above-mentioned transaction by encryption can be made to be in privacy guarantor
The state of shield, avoids transaction content from exposing.It for example, may the account address comprising transaction initiator, friendship in transaction content
The information such as the account address of easy target, may insure these transaction contents by encryption can not be read directly.
In one embodiment, above-mentioned transaction can be encrypted by way of symmetric encipherment algorithm, can also be used non-
The mode of symmetry algorithm is encrypted.The Encryption Algorithm that symmetric cryptography uses, e.g. DES algorithm, 3DES algorithm, TDEA are calculated
Method, Blowfish algorithm, RC5 algorithm, IDEA algorithm etc..Rivest, shamir, adelman, e.g. RSA, Elgamal, knapsack algorithm,
Rabin, D-H, ECC (elliptic curve encryption algorithm) etc..
In one embodiment, above-mentioned transaction can be carried out by way of symmetric encipherment algorithm combination rivest, shamir, adelman
Encryption.By taking above-mentioned transaction is committed to the first block chain node by client as an example, client can be added using symmetric encipherment algorithm
Close transaction content encrypts transaction content using the key of symmetric encipherment algorithm, and is added with rivest, shamir, adelman cryptographic symmetrical
The key used in close algorithm, for example using the key used in the public key encryption symmetric encipherment algorithm of rivest, shamir, adelman.
In this way, can be first decrypted using the private key of rivest, shamir, adelman after the first block chain node receives the transaction of encryption,
The key of symmetric encipherment algorithm is obtained, and then decrypts to obtain transaction content with the key of symmetric encipherment algorithm.
When transaction is for calling intelligent contract, the calling of multinest structure can be.For example, transaction calls directly intelligence
Can and about 1, and the intelligence and about 1 code have invoked intelligence and about 2, and the code in intelligence and about 2 be directed toward it is intelligent with about 3
Contract address so that transaction actually have invoked indirectly intelligence and about 3 codes.Specific implementation process and above process class
Seemingly, details are not described herein.
As previously mentioned, the first received transaction of block chain node, such as can be creation and/or call the friendship of intelligent contract
Easily.Such as in ether mill, the first block chain node receives the creation that client is sent and/or calls the transaction of intelligent contract
Afterwards, can check transaction whether effectively, format it is whether correct, whether the signature for verifying transaction legal etc..
In general, the node in ether mill is typically also the node of contention book keeping operation power, and therefore, the first block chain node is made
Node for contention book keeping operation power can be performed locally the transaction.If one in the node of contention book keeping operation power is striven in epicycle
It wins during taking book keeping operation power by force, then becomes accounting nodes.If the first block chain node is in the process of epicycle contention book keeping operation power
In win, just become accounting nodes;Certainly, if if the first block chain node does not have during epicycle contention is kept accounts and weighed
It wins, is not then accounting nodes, and other nodes are likely to become accounting nodes.
Intelligent contract is similar to the class in Object-Oriented Programming, and the contract that the result of execution generates the corresponding intelligence contract is real
Example is similar to and generates the corresponding object of class.It executes in transaction for creating the process of the code of intelligent contract, will create contract account
Family, and contract is disposed in account space.In ether mill, the address of intelligent contract account is address (such as Fig. 3-4 by sender
In " 0xf5e ... ") and transaction random number (nonce) as input, pass through what Encryption Algorithm generated, such as the conjunction in Fig. 3-4
About address " 0x6f8ae93 ... " is generated by the encrypted algorithm of nonce in the address of sender " 0xf5e ... " and transaction.
In general, proved using proof of work (Proof of Work, POW) and equity (Proof of Stake,
POS), equity is appointed to prove the area of support intelligence contract of the common recognition such as (Delegated Proof of Stake, DPOS) algorithm
In block chain network, the node of contention book keeping operation power can execute the friendship after receiving the transaction comprising the intelligent contract of creation
Easily.Contention book keeping operation power node in may one of them epicycle contention keep accounts weigh during win, become accounting nodes.Note
This can be included transaction of intelligent contract by account node and other transaction be packaged together and generate new block, and by the new of generation
Block be sent to other nodes and know together.
For using machines such as practical Byzantine failure tolerance (Practical Byzantine Fault Tolerance, PBFT)
In the block chain network of the support intelligence contract of system, there is the node of book keeping operation power to have agreed upon before epicycle book keeping operation.Therefore,
After one block chain node receives above-mentioned transaction, if itself not being the accounting nodes of epicycle, which can be sent to
Accounting nodes.For the accounting nodes (can be the first block chain node) of epicycle, which is being packaged and is generating new block
During perhaps before or by the transaction with it is other transaction be packaged together and generate new block during or before,
The transaction can be executed.The transaction is packaged (or further including that other transaction are packaged together) and generates new area by the accounting nodes
After block, the new block of generation or block head are sent to other nodes and known together.
As described above, in block chain network using the support intelligence contract of POW mechanism, or using POS, DPOS,
In the block chain network of the support intelligence contract of PBFT mechanism, which can be packaged and generate new by the accounting nodes of epicycle
Block, and the new block back zone build of generation is sent to other nodes and is known together.If other nodes receive institute
It states after block that there is no problem through verifying, which can be appended to original block chain end, to complete to keep accounts
Journey is reached common understanding;If transaction completes deployment of the intelligent contract in block chain network, if handing over for creating intelligent contract
It is easy for calling intelligent contract, then completes the calling and execution of intelligent contract.Other node verification accounting nodes are sent new
Block or block head during, the transaction in the block can also be executed.
As described above, by executing the transaction content after decrypting in TEE, it can be ensured that implementation procedure is in trusted context
Interior completion, to ensure that privacy information will not leak.It is used to create intelligent conjunction there are the transaction of privacy process demand when above-mentioned
It include the code of intelligent contract when about, in the transaction, the first block chain node can be decrypted to obtain in TEE to the transaction
The code of its contained intelligent contract, and the code is executed in TEE in turn.When the above-mentioned transaction there are privacy process demand is used for
When calling intelligent contract, the first block chain node can execute the code (if called intelligent contract processing encryption in TEE
State then needs that first the intelligence contract is decrypted in TEE, to obtain corresponding code).Specifically, the first block chain
Node can use the processor instruction increased newly in CPU, distributes a part of region EPC in memory, is drawn by the encryption in CPU
MEE is held up to carry out in the encryption deposit EPC above-mentioned plaintext code.The content encrypted in EPC enter after CPU be decrypted into it is bright
Text.In CPU, operation is carried out to the code of plaintext, completes implementation procedure.For example, executing intelligent contract in SGX technology
Plaintext code can load EVM into enclosure.During remote proving, Key Management server can calculate local EVM
The hash value of code, and compared with the hash value of the EVM code loaded in the first block chain node, comparison result is correctly as logical
A necessary condition of remote proving is crossed, to complete the measurement of the code loaded to the first block chain node SGX enclosure.By
Measurement, correct EVM can execute the code of above-mentioned intelligent contract in SGX.
Step 206, the first block chain node determines the exposure in the receipt data according to the type of transaction of the transaction
Field.
In one embodiment, transaction may include type of transaction field (such as TransType field), the type of transaction field
Value for indicating corresponding type of transaction.Therefore, it by reading the value for contained type of transaction field of trading, can determine
Type of transaction out, for example deposit card type, assets transfer and (such as transfer accounts) type, contract creation type, contract call type, this theory
Bright book is limited not to this.
In one embodiment, different types of transaction can be respectively present corresponding exposed field.Exposure field is receipt
The one or more fields specified in data can combine under the premise of receipt data needs ciphertext to store to protect privacy
The user type of transaction initiator described below is selectively carried out the corresponding receipt contents of exposure field with plaintext version
Storage, so that the subsequent receipt contents for plaintext version storage implement the operation such as retrieval.
In one embodiment, the mapping relations between each type of transaction and exposure field can be pre-defined, so that the
The available predefined mapping relations of one block chain node, and further according to the type of transaction of above-mentioned transaction and the mapping
Relationship determines the exposure field in receipt data.For example, depositing the corresponding exposed field of card type may include above-mentioned From field
Except all fields, the corresponding exposed field of assets transfer type may include above-mentioned To field, contract create type and
The corresponding exposed field of contract call type may include all fields except above-mentioned From field, and for other classes of trading
The case where type, no longer repeats one by one herein.
Wherein, above-mentioned mapping relations can recorde in system contract.The mapping relations can also be recorded in block
In the chain code of chain network.By the way that mapping relations are recorded in system contract, carried out more convenient for subsequent for the mapping relations
It is new to upgrade, and the mapping relations being recorded in chain code are then not easy to realize relatively and update upgrading, the subsequent difference that will be directed to the two
It is described, wouldn't repeat herein.
Step 208, the first block chain node stores the receipt data, and when transaction, initiator belongs to pre-set user type
When, the exposed field is stored with plaintext version, remaining receipt field is stored with ciphertext form, and when transaction, initiator is not belonging to institute
When stating pre-set user type, the receipt data is stored with ciphertext form.
In one embodiment, there are corresponding external accounts on block chain by user, and initiate to hand over based on the external account
Easily or implement other operations.So, pre-set user type, i.e. pre-set user belonging to the external account belonging to transaction initiator
Type.Therefore, the first block chain node can determine the corresponding external account of the transaction initiator, and pass through inquiry block chain
The corresponding user type of the external account of upper record, using as user type belonging to the transaction initiator.
In one embodiment, external account may include user type field (such as UserType being recorded on block chain
Field), the value of the user type field corresponds to user type.For example, when the value of user type field is 00, user
Type is ordinary user, and when the value of user type field is 01, user type is advanced level user, when user type field
When value is 11, user type is management user etc..Therefore, the first block chain node can be by reading above-mentioned external account
User type field, corresponding user type can be determined based on value.
In one embodiment, when creating above-mentioned external account, user type, which can be configured as, to be associated with to outside this
Account is recorded in the incidence relation between user type and external account in block chain, such as by user type and outside
Above-mentioned incidence relation is established in the account address of portion's account, so that the data structure of external account does not need to change, i.e., it is outer
Portion's account is without including above-mentioned user type field.Therefore, the first block chain node can be recorded on block chain by reading
Incidence relation determine the corresponding above-mentioned pre-set user class of the external account and based on the corresponding external account of transaction initiator
Type.
In one embodiment, it can modify under certain condition to the user type of external account.For example, management is used
Family can have modification claim, allow the first block chain node according to management Client-initiated change request, change above-mentioned
The corresponding user type of external account.Management user can correspond to external account preset, with administration authority in wound generation block
Family allows management user to carry out Type Change to other ordinary users, advanced level user etc., for example ordinary user is changed
Ordinary user etc. is changed to for advanced level user, by advanced level user.
It in one embodiment,, can be according to not by being identified to user type under the premise of protecting privacy of user
With user for the differentiated demand of secret protection degree, implement differentiation for the exposure field in generated receipt data
Storage operation, flexibility with higher.For example, the demand of the secret protection of ordinary user it is relatively lower, to be based on receipt
The trigger action demand of data is relatively higher, then receipt data caused by the transaction initiated for ordinary user, can incite somebody to action
The corresponding receipt contents of exposure field are stored using plaintext version, to implement to retrieve and touch for the receipt contents of stored in clear
It sends out relatively further types of operation associated.For another example the demand of the secret protection of advanced level user it is relatively higher, to be based on receipt number
According to trigger action demand it is relatively lower, can will be sudden and violent then receipt data caused by the transaction initiated for advanced level user
Reveal the corresponding receipt contents of field using ciphertext form storage, so as to support section type it is operation associated while, it is ensured that
The receipt contents of ciphertext form are able to safe preservation.
By program code (the hereinafter referred to as chain generation for running block chain on calculating equipment (physical machine or virtual machine)
Code), it can be the block chain node in block chain network, such as the first above-mentioned block chain node by the calculating device configuration
Deng.In other words, the first block chain node is by running above-mentioned chain code, to realize corresponding function logic.Therefore, Ke Yi
When creating block chain network, receipt data storage logic described above is written in chain code, so that each block chain node
Receipt data storage logic may be implemented.By taking the first block chain node as an example, receipt data storage logic is included at least:
According to the storage logic that user type implements receipt field, i.e., when the initiator that trades belongs to pre-set user type, by institute
It states exposed field to store with plaintext version storage, remaining receipt field with ciphertext form, be not belonging in transaction initiator described pre-
If when user type, the receipt data is stored with ciphertext form;Further, receipt data storage logic can also include
It is at least one following: the recognition logic of the recognition logic (referring to step 206 and its associated description) of type of transaction, user type
(referring to step 208 and its associated description).
In fact, the receipt data of this specification stores logic, what is actually embodied is tieed up for transaction dimension and user
The comprehensive consideration of degree: by identifying type of transaction, can determine from transaction dimension can be with the exposure field of stored in clear, this
A little exposure fields may be information more significant in the transaction of correlation type, can be more precisely real based on these information
Apply the operations such as subsequent retrieval;And by the user type of identification transaction initiator, user can be determined from user's dimension
Secret protection demand, thus trade initiator belong to pre-set user type when confirmation user secret protection demand relatively
It is low, exposure field can be stored with plaintext version but other fields are still stored with ciphertext form, and trade initiator not
The secret protection demand of confirmation user is relatively high when belonging to pre-set user type, needs all receipt fields with ciphertext shape
Formula storage.
However, the upgrading update of chain code is relatively difficult, so that realizing the storage to receipt data using chain code
There is a problem of that flexibility is low, scalability is insufficient.In order to realize the Function Extension to chain code, as shown in figure 5, can use
The mode that chain code is combined with system contract: chain code for realizing block chain network basic function, and in operational process
Function Extension can be realized by way of system contract.Similar with above-mentioned intelligent contract, system contract includes example
Such as the code of bytecode form, the first block chain node can be by the code of operating system contract (for example, according to unique corresponding
Address " 0x53a98 ... " read the code in the system contract), realize and the function of chain code supplemented.
It is different from the above-mentioned intelligent contract that block chain is distributed to by user, system contract can not freely be issued by user.The
The system contract that one block chain node is read may include the preset system contract being configured in the wound generation block of block chain network;With
And the administrator (i.e. above-mentioned management user) in block chain network can have the renewal authority for system contract, thus
It is updated for such as above-mentioned preset system contract, then the system contract that above-mentioned first block chain node is read can also wrap
Include system contract after updating accordingly.Certainly, system contract can be implemented once preset system contract by administrator after update
It is obtained after update;Alternatively, system contract obtains after can implementing successive ignition update to preset system contract by administrator after updating
Arrive, for example, by preset system contract update to obtain system and about 1, to system and about 1 update the system that obtains and about 2, system is closed
About 2 updates obtain system and about 3, and the system and about 1, system and about 2, system and about 3 can be considered as system contract after update,
But the first block chain node would generally be subject to the system contract of latest edition, for example the first block chain node can be with system contract
Subject to code in 3, and the code in nonsystematic and about 1 or system and about 2.
Other than the preset system contract for including in wound generation block, administrator can also close delivery system in subsequent block
About, and for the system contract issued it is updated.In short, should be closed by modes such as rights managements to system
Publication about and update and implement a degree of limitation, with ensure block chain network function logic can normal operation, and
It avoids causing unnecessary loss to any user.
Therefore, the first block chain node can read the code of system contract, define receipts in the code of the system contract
According to data storage logic;Then, the first block chain node can execute the code of the system contract, to belong in transaction initiator
When pre-set user type, at least one receipt field of receipt data is stored with plaintext version, and not belonged in transaction initiator
When pre-set user type, receipt data is stored with ciphertext form.
In one embodiment, the first block chain node is encrypted by key pair receipt contents.The encryption can adopt
With symmetric cryptography, asymmetric encryption can also be used.If the first block chain node symmetric cryptography mode, that is, use symmetric cryptography
The symmetric key of algorithm encrypts receipt contents, then client (or other hold the object of key) can be calculated with the symmetric cryptography
Encrypted receipt contents are decrypted in the symmetric key of method.
In one embodiment, the symmetric key of the first block chain node symmetric encipherment algorithm encrypts receipt contents
When, which can be provided previously to the first block chain node by client.So, due to only having client (actually should
For the corresponding user of logon account in client) and the first block chain node grasp the symmetric key so that the only client
End can decrypt corresponding encrypted receipt contents, avoid unrelated user even criminal to encrypted receipt contents into
Row decryption.
For example, client, when initiating to trade to the first block chain node, client can use the first of symmetric encipherment algorithm
Beginning key pair transaction content is encrypted, to obtain the transaction;Correspondingly, the first block chain node can be initial by obtaining this
Key, for directly or indirectly being encrypted to receipt contents.For example, which can be by client and the first block
Chain node is negotiated to obtain in advance, perhaps by Key Management server is sent to client and the first block chain node or by visitor
Family end is sent to the first block chain node.When initial key is sent to the first block chain node by client, client can be with
After encrypting by the public key of rivest, shamir, adelman to the initial key, encrypted initial key is sent to the firstth area
Block chain node, and the first block chain node solves the encrypted initial key by the private key of rivest, shamir, adelman
It is close, initial key is obtained, i.e., digital envelope encryption described above, details are not described herein again.
In one embodiment, the first block chain node can encrypt receipt contents using above-mentioned initial key.
Difference transaction use initial keys can be identical so that the All Activity that same user is submitted be all made of the initial key into
Row encryption, or the initial key that different transaction use can be different, for example client can be generated for each transaction is random
One initial key, to promote safety.
In one embodiment, the first block chain node can generate derivative key according to initial key and impact factor, and
Receipt contents are encrypted by the derivative key.It is encrypted compared to initial key is directlyed adopt, derivative key can be with
Increase degree of randomness, to promote the difficulty being broken, facilitates the safeguard protection for optimizing data.Impact factor can be with transaction phase
It closes;For example, impact factor may include trade cryptographic Hash specific bit, such as the first block chain node can by initial key with
First 16 (or first 32,16 latter, rear 32 or other positions) of transaction cryptographic Hash are spliced, and to spliced word
Symbol string carries out Hash operation, to generate derivative key.
In one embodiment, the first block chain node can also use asymmetric encryption mode, i.e., calculated with asymmetric encryption
The public key of method encrypts receipt contents, then correspondingly, client can be decrypted above-mentioned with the private key of the rivest, shamir, adelman
Encrypted receipt contents.The key of rivest, shamir, adelman, such as can be and a pair of of public key and private key are generated by client, and
Public key is sent to the first block chain node in advance, so that the first block chain node can be by the receipt contents public key encryption.
First block chain node is by running the code for realizing a certain function, to realize the function.Therefore, for needing
The function to realize in TEE also needs to execute correlative code.And the code for being executed in TEE, it needs to meet TEE
Related specifications and requirement;Accordingly for the rule for realizing the code of a certain function, needed in the related technology in conjunction with TEE
Model and requirement re-start written in code, and there is only relatively bigger exploitation amounts, and are easy to produce during rewriting
Raw loophole (bug) influences the reliability and stability of function realization.
Therefore, the first block chain node can be by executing store function code, the receipts that will be generated in TEE except TEE
According to data (including needing the receipt contents of the plaintext version of stored in clear, and the receipt of the ciphertext form that needs ciphertext to store
Content) external memory space to except TEE is stored, allow the store function code to be in the related technology for realizing depositing
It stores up the code of function, need to re-start written in code in conjunction with the specification and requirement of TEE, can realize peace for receipt data
Complete reliable storage, on the basis of not influencing safe and reliable degree, can not only reduce the exploitation amount of correlative code, and
TCB (Trusted Computing Base, trusted computing base) can be reduced by reducing the correlative code of TEE, so that TEE
During technology and block chain technology are combined, it is additional caused by security risk be in controlled range.
In one embodiment, the first block chain node can execute write buffer function code in TEE, by above-mentioned receipts
It is stored in the write buffer in TEE according to data, for example the write buffer can correspond to " caching " as shown in Figure 1.Further,
One block chain node exports the data in write buffer from credible performing environment, to store to external memory space.Wherein, it writes slow
Depositing function code can be stored in TEE with plaintext version, and the caching function generation of the plaintext version can be directly executed in TEE
Code;Or, write buffer function code can be stored in except TEE with ciphertext form, for example it is stored in above-mentioned external memory space
(such as " packing+storage " shown in FIG. 1, wherein " packing " indicates the first block chain node except credible performing environment to friendship
Easily be packaged blocking), the write buffer function code of the ciphertext form can be read in TEE, be decrypted in TEE as in plain text
Code, and execute the plaintext code.
Write buffer refers to when writing data into external memory space, in order to avoid causing " the punching to external memory space
Hit " and " buffering " mechanism of offer.For example, can realize above-mentioned write buffer using buffer;Certainly, write buffer can also adopt
It is realized with cache, this specification is limited not to this.In fact, due to the security context that TEE is isolation, and it is external
Memory space is located at except TEE, so that can carry out batch by using write buffer mechanism to the data in caching and outside is written
Memory space promotes data storage efficiency to reduce the interaction times between TEE and external memory space.Meanwhile TEE exists
During constantly executing each item transaction, it may be necessary to transfer generated data, be write if the data that need to be called are located exactly at
In caching, the data can be directly read from write buffer, on the one hand can reduce the friendship between external memory space in this way
Mutually, it on the other hand eliminates to the decrypting process from external memory space data streams read, thus at the data being lifted in TEE
Manage efficiency.
It is of course also possible to write buffer be built on except TEE, for example the first block chain node can execute except TEE
Write buffer function code, thus by the write buffer outside above-mentioned receipt data deposit TEE, and further by the number in write buffer
According to storing to external memory space.
In conclusion this specification is under the premise of protecting privacy of user, by type of transaction and user type difference
Identified, even if so that be directed to same type transaction, also can be according to different types of user for secret protection degree
Differentiated demand so that exposure field contained by receipt data can be realized differentiation storage operation, compared to all receipts
It is stored completely with ciphertext form according to data, there is relatively higher flexibility, and the receipt contents of stored in clear can be direct
It realizes the operations such as subsequent retrieval, to meet application scenarios more abundant, for example drives such as DAPP
(Decentralized Application, Distributed Application) client executing relevant treatment operations etc..
The implementation of the receipt memory node of a kind of combination user type of this specification and type of transaction is introduced below in conjunction with Fig. 6
Example, comprising:
Receiving unit 61 receives the transaction by encryption;
Decryption unit 62 decrypts the transaction in credible performing environment, obtains transaction content;
Execution unit 63 executes the transaction content in the credible performing environment, obtains receipt data;
Determination unit 64 determines the exposure field in the receipt data according to the type of transaction of the transaction;
Storage unit 65 stores the receipt data, when the initiator that trades belongs to pre-set user type, the exposed word
Section is stored with plaintext version storage, remaining receipt field with ciphertext form, and when transaction, initiator is not belonging to the pre-set user class
When type, the receipt data is stored with ciphertext form.
Optionally, user type belonging to the transaction initiator is determined by following manner:
Determine the corresponding external account of the transaction initiator;
The corresponding user type of the external account recorded on inquiry block chain, as belonging to the transaction initiator
User type.
Optionally, the external account includes the user type field being recorded on block chain, the user type field
Value correspond to the user type.
Optionally, when creating the external account, the user type is configured as association to the external account, makes
Incidence relation between the user type and the external account is recorded in block chain.
Optionally, further includes:
Changing unit 66 changes the corresponding user type of the external account according to management Client-initiated change request.
Optionally, the transaction includes type of transaction field, and the value of the type of transaction field is corresponding for indicating
Type of transaction.
Optionally, determination unit 64 is specifically used for:
Obtain the mapping relations between predefined type of transaction and exposure field;
According to the type of transaction of the transaction and the mapping relations, the exposure field in the receipt data is determined.
Optionally, the mapping relations are recorded in system contract.
Optionally, storage unit 65 is specifically used for:
The code of reading system contract defines receipt data storage logic in the code of the system contract;
Execute the code of the system contract, with trade initiator belong to pre-set user type when, by the exposed word
Section is stored with plaintext version storage, remaining receipt field with ciphertext form, and in transaction, initiator is not belonging to the pre-set user class
When type, the receipt data is stored with ciphertext form.
Optionally, the system contract includes: that the preset system contract being recorded in wound generation block or the preset system close
System contract after about corresponding update.
Optionally, the type of transaction of the transaction includes: to deposit card type, assets transfer type, contract creation type, contract
Call type.
Optionally, storage unit 65 is specifically used for:
Store function code is executed except the credible performing environment, and the receipt data is stored to described credible
External memory space except performing environment.
Optionally, the key that the first block chain node encrypts the receipt data includes: symmetric encipherment algorithm
The key of key or rivest, shamir, adelman.
Optionally, the key of the symmetric encipherment algorithm includes the initial key that the client provides;Or, described symmetrical
The key of Encryption Algorithm includes the derivative key that the initial key and impact factor generate.
Optionally, the transaction is encrypted by the initial key, and the initial key is by rivest, shamir, adelman
Public key encrypted;Decryption unit 62 is specifically used for:
It is decrypted to obtain the initial key with the private key of the rivest, shamir, adelman, and with the initial key to described
Transaction is decrypted, to obtain the transaction content.
Optionally, the initial key is generated by client;Or, the initial key is sent to by Key Management server
The client.
Optionally, the impact factor is related to the transaction.
Optionally, the impact factor includes: the specific bit of the cryptographic Hash of the transaction.
In the 1990s, the improvement of a technology can be distinguished clearly be on hardware improvement (for example,
Improvement to circuit structures such as diode, transistor, switches) or software on improvement (improvement for method flow).So
And with the development of technology, the improvement of current many method flows can be considered as directly improving for hardware circuit.
Designer nearly all obtains corresponding hardware circuit by the way that improved method flow to be programmed into hardware circuit.Cause
This, it cannot be said that the improvement of a method flow cannot be realized with hardware entities module.For example, programmable logic device
(Programmable LogicDevice, PLD) (such as field programmable gate array (Field Programmable Gate
Array, FPGA)) it is exactly such a integrated circuit, logic function determines device programming by user.By designer
Voluntarily programming comes a digital display circuit " integrated " on a piece of PLD, designs and makes without asking chip maker
Dedicated IC chip.Moreover, nowadays, substitution manually makes IC chip, this programming is also used instead mostly " is patrolled
Volume compiler (logic compiler) " software realizes that software compiler used is similar when it writes with program development,
And the source code before compiling also write by handy specific programming language, this is referred to as hardware description language
(Hardware Description Language, HDL), and HDL is also not only a kind of, but there are many kind, such as ABEL
(Advanced Boolean Expression Language)、AHDL(Altera Hardware Description
Language)、Confluence、CUPL(Cornell University Programming Language)、HDCal、JHDL
(Java Hardware Description Language)、Lava、Lola、MyHDL、PALASM、RHDL(Ruby
Hardware Description Language) etc., VHDL (Very-High-Speed is most generally used at present
Integrated Circuit Hardware Description Language) and Verilog.Those skilled in the art also answer
This understands, it is only necessary to method flow slightly programming in logic and is programmed into integrated circuit with above-mentioned several hardware description languages,
The hardware circuit for realizing the logical method process can be readily available.
Controller can be implemented in any suitable manner, for example, controller can take such as microprocessor or processing
The computer for the computer readable program code (such as software or firmware) that device and storage can be executed by (micro-) processor can
Read medium, logic gate, switch, specific integrated circuit (Application Specific Integrated Circuit,
ASIC), the form of programmable logic controller (PLC) and insertion microcontroller, the example of controller includes but is not limited to following microcontroller
Device: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20 and Silicone Labs C8051F320 are deposited
Memory controller is also implemented as a part of the control logic of memory.It is also known in the art that in addition to
Pure computer readable program code mode is realized other than controller, can be made completely by the way that method and step is carried out programming in logic
Controller is obtained to come in fact in the form of logic gate, switch, specific integrated circuit, programmable logic controller (PLC) and insertion microcontroller etc.
Existing identical function.Therefore this controller is considered a kind of hardware component, and to including for realizing various in it
The device of function can also be considered as the structure in hardware component.Or even, it can will be regarded for realizing the device of various functions
For either the software module of implementation method can be the structure in hardware component again.
System, device, module or the unit that above-described embodiment illustrates can specifically realize by computer chip or entity,
Or it is realized by the product with certain function.It is a kind of typically to realize that equipment is computer.Specifically, computer for example may be used
Think personal computer, laptop computer, cellular phone, camera phone, smart phone, personal digital assistant, media play
It is any in device, navigation equipment, electronic mail equipment, game console, tablet computer, wearable device or these equipment
The combination of equipment.
For convenience of description, it is divided into various units when description apparatus above with function to describe respectively.Certainly, implementing this
The function of each unit can be realized in the same or multiple software and or hardware when specification.
It should be understood by those skilled in the art that, the embodiment of the present invention can provide as method, system or computer program
Product.Therefore, complete hardware embodiment, complete software embodiment or reality combining software and hardware aspects can be used in the present invention
Apply the form of example.Moreover, it wherein includes the computer of computer usable program code that the present invention, which can be used in one or more,
The computer program implemented in usable storage medium (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.) produces
The form of product.
The present invention be referring to according to the method for the embodiment of the present invention, the process of equipment (system) and computer program product
Figure and/or block diagram describe.It should be understood that every one stream in flowchart and/or the block diagram can be realized by computer program instructions
The combination of process and/or box in journey and/or box and flowchart and/or the block diagram.It can provide these computer programs
Instruct the processor of general purpose computer, special purpose computer, Embedded Processor or other programmable data processing devices to produce
A raw machine, so that being generated by the instruction that computer or the processor of other programmable data processing devices execute for real
The device for the function of being specified in present one or more flows of the flowchart and/or one or more blocks of the block diagram.
This specification can describe in the general context of computer-executable instructions executed by a computer, such as journey
Sequence module.Generally, program module include routines performing specific tasks or implementing specific abstract data types, programs, objects,
Component, data structure etc..This specification can also be practiced in a distributed computing environment, in these distributed computing environment
In, by executing task by the connected remote processing devices of communication network.In a distributed computing environment, program module
It can be located in the local and remote computer storage media including storage equipment.
These computer program instructions, which may also be stored in, is able to guide computer or other programmable data processing devices with spy
Determine in the computer-readable memory that mode works, so that it includes referring to that instruction stored in the computer readable memory, which generates,
Enable the manufacture of device, the command device realize in one box of one or more flows of the flowchart and/or block diagram or
The function of being specified in multiple boxes.
These computer program instructions also can be loaded onto a computer or other programmable data processing device, so that counting
Series of operation steps are executed on calculation machine or other programmable devices to generate computer implemented processing, thus in computer or
The instruction executed on other programmable devices is provided for realizing in one or more flows of the flowchart and/or block diagram one
The step of function of being specified in a box or multiple boxes.In a typical configuration, computer includes at one or more
Manage device (CPU), input/output interface, network interface and memory.
Memory may include the non-volatile memory in computer-readable medium, random access memory (RAM) and/or
The forms such as Nonvolatile memory, such as read-only memory (ROM) or flash memory (flash RAM).Memory is computer-readable medium
Example.
Computer-readable medium includes permanent and non-permanent, removable and non-removable media can be by any method
Or technology come realize information store.Information can be computer readable instructions, data structure, the module of program or other data.
The example of the storage medium of computer includes, but are not limited to phase change memory (PRAM), static random access memory (SRAM), moves
State random access memory (DRAM), other kinds of random access memory (RAM), read-only memory (ROM), electric erasable
Programmable read only memory (EEPROM), flash memory or other memory techniques, read-only disc read only memory (CD-ROM) (CD-ROM),
Digital versatile disc (DVD) or other optical storage, magnetic cassettes, disk storage, quantum memory, based on graphene
Storage medium or other magnetic storage devices or any other non-transmission medium, can be used for storing can be accessed by a computing device
Information.As defined in this article, computer-readable medium does not include temporary computer readable media (transitory media),
Such as the data-signal and carrier wave of modulation.
It should also be noted that, the terms "include", "comprise" or its any other variant are intended to nonexcludability
It include so that the process, method, commodity or the equipment that include a series of elements not only include those elements, but also to wrap
Include other elements that are not explicitly listed, or further include for this process, method, commodity or equipment intrinsic want
Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including described want
There is also other identical elements in the process, method of element, commodity or equipment.
It is above-mentioned that this specification specific embodiment is described.Other embodiments are in the scope of the appended claims
It is interior.In some cases, the movement recorded in detail in the claims or step can be come according to the sequence being different from embodiment
It executes and desired result still may be implemented.In addition, process depicted in the drawing not necessarily require show it is specific suitable
Sequence or consecutive order are just able to achieve desired result.In some embodiments, multitasking and parallel processing be also can
With or may be advantageous.
The term that this specification one or more embodiment uses be only merely for for the purpose of describing particular embodiments, and
It is not intended to be limiting this specification one or more embodiment.In this specification one or more embodiment and the appended claims
Used in the "an" of singular, " described " and "the" be also intended to including most forms, unless context understands earth's surface
Show other meanings.It is also understood that term "and/or" used herein refers to and includes one or more associated list
Any or all of project may combine.
It will be appreciated that though this specification one or more embodiment may using term first, second, third, etc. come
Various information are described, but these information should not necessarily be limited by these terms.These terms are only used to same type of information area each other
It separates.For example, the first information can also be referred to as in the case where not departing from this specification one or more scope of embodiments
Two information, similarly, the second information can also be referred to as the first information.Depending on context, word as used in this is " such as
Fruit " can be construed to " ... when " or " when ... " or " in response to determination ".
The foregoing is merely the preferred embodiments of this specification one or more embodiment, not to limit this theory
Bright book one or more embodiment, all within the spirit and principle of this specification one or more embodiment, that is done is any
Modification, equivalent replacement, improvement etc. should be included within the scope of the protection of this specification one or more embodiment.