Invention content
The purpose of the present invention is to provide the block chain implementation methods and equipment of a kind of intelligent contract of operation.
To solve the above problems, the present invention provides a kind of block chain implementation method of the intelligent contract of operation, including:
It is client, accounting nodes and common recognition node cluster by block chain node Partition of role;
One group of public and private secret key is preserved in the client, the client is provided for initiate transaction;
A group key pair is preserved in the accounting nodes, sets the accounting nodes to distributed storage account book, and transport
Row intelligence contract and verification are merchandised;
A group key pair is preserved in the common recognition node, sets the common recognition node to distributed storage account book, and transport
The common recognition of sequence is reached in row intelligence contract, verification transaction between multiple transaction sequence in block and all common recognition nodes;
Intelligent contract call instruction is packaged as transaction and proposed by the client, is initiated transaction and is proposed to multiple book keeping operations to save
Point;
Each accounting nodes, which respectively verify the validity that the transaction is proposed and execute to be verified as effectively merchandising, to be proposed,
Proposed issue is returned to the client;
The client waits for multiple accounting nodes to respond the transaction proposal, the proposed issue is compared, if differed
Cause then re-initiates transaction and proposes, submits the proposed issue to node cluster of knowing together if consistent;
The common recognition node cluster collects the proposed issue, verifies the validity of the proposed issue, effective to being verified as
Proposed issue add serial number, reach when the stand-by period that the serial number reaches default serial number threshold value or collects the proposed issue
After preset time threshold, the proposed issue is packaged into block undetermined, sends the block undetermined to the accounting nodes, together
When verify transaction in the block undetermined and propose, will contain only the transaction being proved to be successful after rejecting the transaction proposal of authentication failed
After proposal is packaged into block and is added to block chain, while accounting nodes receive the block undetermined of common recognition node, verification is described undetermined
Transaction in block proposes, reject authentication failed transaction propose after will contain only the transaction proposal being proved to be successful and be packaged into block
It is added to block chain.
Further, in the above-mentioned methods, intelligent contract call instruction is packaged as transaction proposal by the client, is initiated
Transaction is proposed to before multiple accounting nodes, further includes:
By the client, accounting nodes and know together node cluster correspondence operating system be divided into including data Layer, network layer,
Six parts of common recognition layer, contract layer, authorization layer and application layer;
It sets the data Layer to include key value database and database management module, for preserving block data and intelligence
The data of energy contract generation, offer do additions and deletions to intelligent contract data and change the interface looked into, and the block is defined in the data Layer
The structure of distributed account book, account book are made of block chain and world state in chain, wherein the block chain is made of block
Retrospective chained list, block are made of block head, block data, metadata, and block is proposed to form by transaction, and the transaction is proposed
There are two types of types:Deployment transaction and calling transaction, wherein deployment transaction is that intelligent obligating document is written to the record of block, is remembered
Record content includes file source code, deployment people, version number, configuration information, transaction unique mark;It is intelligent contract tune to call transaction
With the record of process, record content includes block height where intelligent contract source code, transaction unique mark, intelligent contract method
The digital signature of name, call parameters and trade initiator, executor;World state is the collection of the state of all intelligent contracts
It closes, state is after intelligent contract is run finally to the expression way of database manipulation;Intelligent contract operation result collects table by read-write
Show, read-write collection is made of readset with collection is write, wherein write the set that collection is the state that an intelligent contract once calls generation;
One point to point network of the network layer-management is set, and the network layer includes Data Transport Protocol, node exploration
Module, data simultaneous module and broadcast transaction modules, wherein Data Transport Protocol is a kind of final consistency algorithm, is realized
Gossip agreements, the data for synchronizing each node of block chain, synchronizing process are that transmission-reception-is more within a synchronizing cycle
It newly-beams back-and updates-beam back again-newer flow again, each period randomly chooses a node, finally by data dissemination to institute
There is node;Node explores the list of known node IP address in one network of module management, this list is initially in deployment block
It is manually entered when chain network, when network is added in a new node, exploration module, which generates, explores message, and it includes the node to explore message
The mandate and known node list obtained in block chain network, mandate are provided by the authorization layer, Data Transport Protocol hair
It send and receives and explore message, first select recipient's node from node listing, then broadcast one and explore message to recipient, recipient
Exploration module receive message after compare local known node list, if explored in message comprising locally no node IP
Then this IP is increased newly to local node list, if not updating local list not comprising if, exploration is beamed back after the completion of comparison and is rung
Should be to the sender for exploring message, probe response content includes the mandate of node itself and updated known node list, is connect
It receives people and receives after probe response that content updates local node list in the same fashion according to response, beam back probe response after update again
Response message, recipient updates node listing again;Data simultaneous module sends and receives data synchronization message, synchronization message
It is divided into synchronous block height and synchronous block data, wherein the synchronous block height includes the block height of node local, disappears
The digital signature of breath, the synchronous block data include that newer block content, the digital signature of message, described synchronize is needed to disappear
Breath equally follows Data Transport Protocol to other node broadcasts, and node timing sends synchronous block height message, when discovery receives
Person's block height then sends synchronous block data message to obtain newest block more than itself block height;Broadcast transaction modules
It is divided into client-side, accounting nodes side and common recognition node side, different function is provided for different role.Client-side produces application layer
Raw transaction proposal is sent to accounting nodes, and operation result is beamed back client by accounting nodes side, and result treatment is by client-side
Transaction message is simultaneously sent to common recognition node, and transaction message includes the handling result of accounting nodes, the digital signature of message, node of knowing together
Side receives transaction message, and common recognition result is sent after processing to accounting nodes;
The common recognition layer is set, all common recognition nodes are formed into common recognition node cluster, the common recognition node cluster receives client hair
Rise transaction and by know together algorithm sort to multiple transaction, it is described know together algorithm be PBFT algorithms realization;
It includes that intelligent contract is packaged and operating system, contract code check device and transaction flow revolving die that the contract layer, which is arranged,
Block, wherein merchandise for deployment, elder generation is by the contract code check device to intelligent contract code static scanning to intercept malice journey
Sequence, by after inspection by the packing and the intelligent contract of operating system verification whether can by system operation, by after verification by institute
It states transaction flow revolving die block and intelligent obligating document is sent to network layer handles;It merchandises for calling, is first examined by the contract code
Device is looked into intelligent contract code static scanning to intercept rogue program, by inputting the input parameter for including in transaction after inspection
To the packing and operating system, the packing and output operation result after the intelligent contract code of operating system operation to the friendship
Operation result processing is that the read-write collection with version number is sent to network layer handles by easily circulation module, the circulation module;
It includes that digital certificate signs and issues mechanism, Node registry and authentication module that the authorization layer, which is arranged, wherein the authorization layer
Block chain network is added in authorization node, verifies the legitimacy of node;
It includes that digital certificate and secret key management, client SDK, command line interface and far call connect that the application layer, which is arranged,
Mouthful, wherein the application layer provides the interactive mode of client and block chain, to client in a manner of code call and order line
It includes application authorization API that end, which provides, merchandises and proposes API, Authorization result readjustment API, executes intelligence and about API and implementing result time
Adjust API.
Further, in the above-mentioned methods, the digital certificate signs and issues mechanism, and the linked groups by participating in intelligent contract are total to
With safeguarding, the digital certificate signs and issues mechanism and holds a group key pair, and key pair is generated by ECDSA algorithms, the digital certificate
It signs and issues whole nodes, the private key of cipher key pair in the public key informing network for the cipher key pair that mechanism holds and only signs and issues mechanism itself
Possess, node, which is signed and issued through digital certificate after mechanism authorizes digital certificate and private key, could be added block chain network, by digital signature
Algorithm ensures that digital certificate and private key can not be forged, and digital signature uses a group key pair, the key pair that digital signature uses by
The digital certificate signs and issues authority signature and granting, and must sign and issue mechanism application to the digital certificate before node addition network awards
Power, digital certificate sign and issue mechanism by being that node generates a group key pair after application, public key and nodal information are saved as number
Certificate, digital certificate sign and issue mechanism and are counted word signature to certificate with own private key, the digital certificate after signature and node private key by
Node preserves, and digital certificate and does digital signature to message with own private key on all message bands that node is broadcasted in a network,
Other nodes verify the legitimacy of sender after receiving broadcast, and verification is divided into certificate validity checking and certificate holds inspection
Look into, certificate validity checking be verification certificate whether by the digital certificate sign and issue mechanism generate, use ECC algorithm verification number
Whether the content of certificate by the digital certificate signs and issues authority signature, and certificate, which holds inspection, ensures node from the digital certificate label
The certificate that mechanism obtains certificate and other non-copied nodes is sent out, the digital signature using ECC algorithm verification broadcasted content, broadcast is
The no public key met in digital certificate.
Further, in the above-mentioned methods, the client SDK is divided into Java SDK, PHP SDK, Go SDK, respectively
Different programming language codes are converted to JSON character strings by the client that corresponding different programming languages are realized, the client SDK
It is sent to far call interface;The input of order line is converted to JSON character strings and is sent to far call by the command line interface
Interface;The reception of the far call interface and output data format are JSON character strings, by http protocol transmission data,
Wherein, for applying for authorization API, the data of receiving is resolved into application information and are sent to network layer, are adjusted back by Authorization result
API notifies client;API is proposed for transaction, the data of reception are resolved into intelligent contract call instruction, transaction is generated and carries
View uses private key to generate transaction proposal digital signature and is attached to digital certificate and proposes that message is sent to network layer, node as transaction
API is adjusted back by the implementing result after local account book update and notifies client.
Another side according to the present invention also provides a kind of block chain realization equipment of the intelligent contract of operation, including::
Client is used to preserve one group of public and private secret key, and for initiating transaction, wherein the client is used for will be intelligent
Contract call instruction, which is packaged as transaction, to be proposed, is initiated transaction and is proposed to multiple accounting nodes, and multiple accounting nodes is waited for respond
The transaction is proposed, the proposed issue is compared, and transaction is re-initiated if inconsistent and is proposed, if consistent described in submission
Proposed issue is to node cluster of knowing together;
Accounting nodes are handed over for preserving a group key pair, and for distributed storage account book, the intelligent contract of operation and verification
Easily, wherein each accounting nodes are used to respectively verify the validity that the transaction is proposed and execute to be verified as effectively merchandising and carry
View after returning to the block undetermined that proposed issue to the client and accounting nodes receives common recognition node, verifies the area undetermined
Transaction in block proposes, reject authentication failed transaction propose after will contain only the transaction proposal being proved to be successful and be packaged into block and add
It is added to block chain;
Node of knowing together is used for distributed storage account book, and run intelligent contract, verification is handed over for preserving a group key pair
Easily, the common recognition of sequence is reached between multiple transaction sequence in block and all common recognition nodes;Wherein, the common recognition node cluster
For collecting the proposed issue, the validity of the proposed issue is verified, serial number is added to effective proposed issue is verified as,
After the stand-by period that the serial number reaches default serial number threshold value or collects the proposed issue reaching preset time threshold, by institute
It states proposed issue and is packaged into block undetermined, send the block undetermined to the accounting nodes, while verifying the block undetermined
Interior transaction proposes, reject authentication failed transaction propose after will contain only the transaction proposal being proved to be successful and be packaged into block addition
To block chain.
Further, in above equipment, further include:
Data Layer, including key value database and database management module, the data Layer is for preserving block data and intelligence
The data of energy contract generation, offer do additions and deletions to intelligent contract data and change the interface looked into, and the block is defined in the data Layer
The structure of distributed account book, account book are made of block chain and world state in chain, wherein the block chain is made of block
Retrospective chained list, block are made of block head, block data, metadata, and block is proposed to form by transaction, and the transaction is proposed
There are two types of types:Deployment transaction and calling transaction, wherein deployment transaction is that intelligent obligating document is written to the record of block, is remembered
Record content includes file source code, deployment people, version number, configuration information, transaction unique mark;It is intelligent contract tune to call transaction
With the record of process, record content includes block height where intelligent contract source code, transaction unique mark, intelligent contract method
The digital signature of name, call parameters and trade initiator, executor;World state is the collection of the state of all intelligent contracts
It closes, state is after intelligent contract is run finally to the expression way of database manipulation;Intelligent contract operation result collects table by read-write
Show, read-write collection is made of readset with collection is write, wherein writing the set that collection is the state that an intelligent contract once calls generation;
Network layer, for managing a point to point network, the network layer includes Data Transport Protocol, node exploration mould
Block, data simultaneous module and broadcast transaction modules, wherein Data Transport Protocol is a kind of final consistency algorithm, is realized
Gossip agreements, the data for synchronizing each node of block chain, synchronizing process are that transmission-reception-is more within a synchronizing cycle
It newly-beams back-and updates-beam back again-newer flow again, each period randomly chooses a node, finally by data dissemination to institute
There is node;Node explores module, and the list for managing known node IP address in a network, this list is initially being disposed
It is manually entered when block chain network, when network is added in a new node, exploration module, which generates, explores message, and it includes to be somebody's turn to do to explore message
The mandate and known node list that node obtains in block chain network, mandate are provided by the authorization layer, data transmission association
View sends and receives exploration message, first selects recipient's node from node listing, then broadcasts one and explore message to recipient, connects
The exploration module of receipts person compares local known node list after receiving message, if explored in message comprising locally no section
Point IP is then increased this IP to local node list newly, and if not updating local list not comprising if, spy is beamed back after the completion of comparison
Rope is responded to the sender for exploring message, and probe response content includes mandate and the updated known node row of node itself
Table, recipient receive after probe response that content updates local node list in the same fashion according to response, beam back spy after update again
The response message of rope response, recipient update node listing again;The data simultaneous module, it is same for sending and receiving data
Message is walked, synchronization message is divided into synchronous block height and synchronous block data, wherein the synchronous block height includes node sheet
Block height, the digital signature of message on ground, the synchronous block data include to need newer block content, the number of message
Signature, the synchronization message equally follow Data Transport Protocol to other node broadcasts, and node timing sends synchronous block height
Message, when discovery recipient's block height then sends synchronous block data message to obtain newest area more than itself block height
Block;The broadcast transaction modules provide not for being divided into client-side, accounting nodes side and common recognition node side for different role
Congenerous.The transaction proposal that application layer generates is sent to accounting nodes by client-side, and operation result is beamed back visitor by accounting nodes side
Family end, result treatment is transaction message and is sent to common recognition node by client-side, and transaction message includes the processing knot of accounting nodes
Fruit, the digital signature of message, common recognition node side receive transaction message, and common recognition result is sent after processing to accounting nodes;
Common recognition layer, for all common recognition nodes to be formed common recognition node cluster, the common recognition node cluster receives client initiation
Transaction and by know together algorithm sort to multiple transaction, it is described know together algorithm be PBFT algorithms realization;
Contract layer, including intelligent contract is packaged and operating system, contract code check device and transaction flow revolving die block, wherein
For deployment merchandise, first by the contract code check device to intelligent contract code static scanning to intercept rogue program, pass through
After inspection by the packing and the intelligent contract of operating system verification whether can by system operation, by after verification by the transaction flow
Intelligent obligating document is sent to network layer handles by revolving die block;It merchandises for calling, first by the contract code check device to intelligence
Energy contract code static scanning is to intercept rogue program, by the way that the input parameter for including in transaction is input to described beat after inspection
Packet and operating system, it is described to be packaged and output operation result after the intelligent contract code of operating system operation to the transaction flow revolving die
Operation result processing is that the read-write collection with version number is sent to network layer handles by block, the circulation module;
Authorization layer, including digital certificate sign and issue mechanism, Node registry and authentication module, wherein the authorization layer mandate section
Point verifies the legitimacy of node for block chain network to be added;
Application layer, including digital certificate and secret key management, client SDK, command line interface and far call interface,
In, the application layer, the interactive mode for providing client and block chain, to client in a manner of code call and order line
It includes application authorization API that end, which provides, merchandises and proposes API, Authorization result readjustment API, executes intelligence and about API and implementing result time
Adjust API.
Further, in above equipment, the digital certificate signs and issues mechanism, common by the linked groups for participating in intelligent contract
It safeguards, the digital certificate signs and issues mechanism and holds a group key pair, and key pair is generated by ECDSA algorithms, the digital certificate label
Whole nodes, the private key of cipher key pair are only signed and issued mechanism itself and are gathered around in the public key informing network for the cipher key pair that hair mechanism holds
Have, node, which is signed and issued through digital certificate after mechanism authorizes digital certificate and private key, could be added block chain network, be calculated by digital signature
Method ensures that digital certificate and private key can not be forged, and digital signature uses a group key pair, and the key pair that digital signature uses is by institute
It states digital certificate and signs and issues authority signature and granting, node must sign and issue mechanism application mandate before network is added to the digital certificate,
Digital certificate signs and issues mechanism by being that node generates a group key pair after application, and public key and nodal information are saved as digital card
Book, digital certificate sign and issue mechanism and are counted word signature to certificate with own private key, and the digital certificate after signature is with node private key by saving
Point preserves, and digital certificate and does digital signature to message with own private key on all message bands that node is broadcasted in a network,
His node verifies the legitimacy of sender after receiving broadcast, and verification is divided into certificate validity checking and certificate holds inspection,
Certificate validity checking be verification certificate whether by the digital certificate sign and issue mechanism generate, use ECC algorithm verification number card
Whether the content of book by the digital certificate signs and issues authority signature, and certificate, which holds inspection, ensures that node is signed and issued from the digital certificate
Mechanism obtains the certificate of certificate and other non-copied nodes, using ECC algorithm verification broadcasted content, broadcast digital signature whether
Meet the public key in digital certificate.
Further, in above equipment, the client SDK is divided into Java SDK, PHP SDK, Go SDK, right respectively
The client for answering different programming languages to realize, the client SDK, for different programming language codes to be converted to JSON characters
String is sent to far call interface;The command line interface is sent to for the input of order line to be converted to JSON character strings
Far call interface;The reception of the far call interface and output data format are JSON character strings, for passing through HTTP
Agreement transmission data, wherein for applying for authorization API, the data of receiving are resolved into application information and are sent to network layer, are passed through
Authorization result adjusts back API and notifies client;API is proposed for transaction, the data of reception are resolved into intelligent contract call instruction,
It generates transaction to propose, uses private key generation transaction to propose digital signature and be attached to digital certificate and propose that message is sent to net as transaction
Network layers adjust back API by the implementing result after the account book update of node local and notify client.
According to the another side of the application, a kind of computer-readable medium is also provided, computer-readable instruction is stored thereon with,
The computer-readable instruction can be executed by processor to realize method described in any one of the above embodiments.
According to the another side of the application, a kind of equipment for being handled in network equipment client information, the equipment packet are also provided
Include the memory for storing computer program instructions and the processor for executing program instructions, wherein when the computer journey
When sequence instruction is executed by the processor, triggers the equipment and execute method described in any one of the above embodiments.
Compared with prior art, intelligent contract call instruction is packaged as transaction proposal by the present invention by family end, initiates to hand over
Easily propose to multiple accounting nodes;Each accounting nodes are respectively verified the validity that the transaction is proposed and are executed and have been verified as
The transaction of effect is proposed, returns to proposed issue to the client;The client waits for multiple accounting nodes to respond the transaction
Propose, compare the proposed issue, transaction is re-initiated if inconsistent and is proposed, the proposed issue is submitted if consistent
To common recognition node cluster;The common recognition node cluster collects the proposed issue, verifies the validity of the proposed issue, to being verified as
Effective proposed issue adds serial number, when the serial number reaches default serial number threshold value or collects the stand-by period of the proposed issue
After reaching preset time threshold, the proposed issue is packaged into block undetermined, the block undetermined to the book keeping operation is sent and saves
Point, while verifying the proposal of the transaction in the block undetermined, reject authentication failed transaction propose after will contain only and be proved to be successful
Transaction proposal be packaged into block and be added to block chain, while after accounting nodes receive the block undetermined of common recognition node, verifying institute
The transaction stated in block undetermined is proposed, the transaction proposal packing being proved to be successful will be contained only after rejecting the transaction proposal of authentication failed
It is added to block chain at block, optimizes the process of the intelligent contract of block chain operation, can effectively reduces operation block chain link point
Server burden.
Specific implementation mode
In order to make the foregoing objectives, features and advantages of the present invention clearer and more comprehensible, below in conjunction with the accompanying drawings and specific real
Applying mode, the present invention is described in further detail.
As shown in Figure 1, the present invention provides a kind of block chain implementation method of the intelligent contract of operation, including:
Block chain node Partition of role is client, accounting nodes and common recognition node cluster by step S1;
Step S2 preserves one group of public and private secret key in the client, and the client is provided for initiate transaction;
Step S3 preserves a group key pair in the accounting nodes, sets the accounting nodes to distributed storage account
This, and run intelligent contract and verification transaction;
Step S4 preserves a group key pair in the common recognition node, sets the common recognition node to distributed storage account
This, and intelligent contract is run, verification transaction sorts between multiple transaction in block and reaches sequence all common recognition nodes
Common recognition;
Intelligent contract call instruction is packaged as transaction and proposed, initiated transaction and propose to multiple by step S5, the client
Accounting nodes;
Step S6, each accounting nodes are respectively verified the validity that the transaction is proposed and are executed and are verified as effectively handing over
Easily propose, returns to proposed issue to the client;
Step S7, the client wait for multiple accounting nodes to respond the transaction proposal, compare the proposed issue, such as
Fruit is inconsistent, re-initiates transaction and proposes, submits the proposed issue to node cluster of knowing together if consistent;
Step S8, the common recognition node cluster collect the proposed issue, verify the validity of the proposed issue, to verification
Serial number is added for effective proposed issue, when the serial number reaches default serial number threshold value or collects the waiting of the proposed issue
Between reach preset time threshold after, the proposed issue is packaged into block undetermined, sends the block undetermined to the book keeping operation
Node, at the same verify the transaction in the block undetermined proposal, reject authentication failed transaction propose after will contain only verification at
After the transaction proposal of work(is packaged into block and is added to block chain, while accounting nodes receive the block undetermined of common recognition node, verification
Transaction in the block undetermined proposes, reject authentication failed transaction propose after will contain only the transaction proposal being proved to be successful and beat
It is bundled into block and is added to block chain.
Here, the entire flow that intelligent contract is run on block catenary system is:The client calls intelligent contract
Instruction is packaged as transaction and proposes, initiates transaction and proposes to multiple accounting nodes;Each accounting nodes are respectively verified the transaction and are carried
The validity of view simultaneously executes to be verified as effectively merchandising and proposes, returns to proposed issue to the client;The client waits for
Multiple accounting nodes, which respond the transaction, to be proposed, the proposed issue is compared, and transaction is re-initiated if inconsistent and is proposed, such as
Fruit unanimously then submits the proposed issue to node cluster of knowing together;Node cluster of knowing together collects the proposed issue, verifies the proposal
As a result validity adds serial number, when the serial number reaches default serial number threshold value or collection to effective proposed issue is verified as
After the stand-by period of the proposed issue reaches preset time threshold, the proposed issue is packaged into block undetermined, sends institute
Block undetermined is stated to the accounting nodes, while verifying the proposal of the transaction in the block undetermined, rejects the transaction of authentication failed
The transaction being proved to be successful will be contained only after proposal and proposes that being packaged into block is added to block chain, while accounting nodes receive common recognition section
It does identical verification operation after the block undetermined of point and is packaged into block and be added to block chain.
Heretofore described block chain is realized with Go programming languages, when intelligent contract running environment is that Golang is run, area
The message broadcasted on block chain is that intelligent contract executes instruction and as a result, present invention optimizes the mistakes that block chain runs intelligent contract
Journey can effectively reduce the server burden of operation block chain link point.
In one embodiment of block chain implementation method of the intelligent contract of operation of the present invention, step S5, the client is by intelligence
Energy contract call instruction, which is packaged as transaction, to be proposed, before initiating transaction proposal to multiple accounting nodes, further includes:
By the client, accounting nodes and know together node cluster correspondence operating system be divided into including data Layer, network layer,
Six parts of common recognition layer, contract layer, authorization layer and application layer;
It sets the data Layer to include key value database and database management module, for preserving block data and intelligence
The data of energy contract generation, offer do additions and deletions to intelligent contract data and change the interface looked into, and the block is defined in the data Layer
The structure of distributed account book, account book are made of block chain and world state in chain, wherein the block chain is made of block
Retrospective chained list, block are made of block head, block data, metadata, and block is proposed to form by transaction, and the transaction is proposed
There are two types of types:Deployment transaction and calling transaction, wherein deployment transaction is that intelligent obligating document is written to the record of block, is remembered
Record content includes file source code, deployment people, version number, configuration information, transaction unique mark;It is intelligent contract tune to call transaction
With the record of process, record content includes block height where intelligent contract source code, transaction unique mark, intelligent contract method
The digital signature of name, call parameters and trade initiator, executor;World state is the collection of the state of all intelligent contracts
It closes, state is after intelligent contract is run finally to the expression way of database manipulation;Intelligent contract operation result collects table by read-write
Show, read-write collection is made of readset with collection is write, wherein writing the set that collection is the state that an intelligent contract once calls generation, block
Data structure can be as shown in Figure 2;
One point to point network of the network layer-management is set, and the network layer includes Data Transport Protocol, node exploration
Module, data simultaneous module and broadcast transaction modules, wherein
Data Transport Protocol is a kind of final consistency algorithm, realizes Gossip agreements, is respectively saved for synchronizing block chain
The data of point, synchronizing process, which is that transmission-reception-updates within a synchronizing cycle-beaming back-, to be updated-beams back again-newer stream again
Journey, each period randomly chooses a node, finally by data dissemination to all nodes;
Node explores the list of known node IP address in one network of module management, this list is initially in deployment block
It is manually entered when chain network, when network is added in a new node, exploration module, which generates, explores message, and it includes the node to explore message
The mandate and known node list obtained in block chain network, mandate are provided by the authorization layer, Data Transport Protocol hair
It send and receives and explore message, first select recipient's node from node listing, then broadcast one and explore message to recipient, recipient
Exploration module receive message after compare local known node list, if explored in message comprising locally no node IP
Then this IP is increased newly to local node list, if not updating local list not comprising if, exploration is beamed back after the completion of comparison and is rung
Should be to the sender for exploring message, probe response content includes the mandate of node itself and updated known node list, is connect
It receives people and receives after probe response that content updates local node list in the same fashion according to response, beam back probe response after update again
Response message, recipient updates node listing again;
Data simultaneous module sends and receives data synchronization message, and synchronization message is divided into synchronous block height and synchronous block
Data, wherein the synchronous block height includes block height, the digital signature of message of node local, the synchronous block
Data include to need newer block content, the digital signature of message, the synchronization message equally follow Data Transport Protocol to
Other node broadcasts, node timing send synchronous block height message, when discovery recipient's block height is high more than itself block
Degree then sends synchronous block data message to obtain newest block;
Broadcast transaction modules are divided into client-side, accounting nodes side and common recognition node side, and different work(are provided for different role
Energy.The transaction proposal that application layer generates is sent to accounting nodes by client-side, and operation result is beamed back client by accounting nodes side,
Result treatment is transaction message and is sent to common recognition node by client-side, and transaction message includes the handling result of accounting nodes, disappears
The digital signature of breath, common recognition node side receive transaction message, and common recognition result is sent after processing to accounting nodes;
The common recognition layer is set, all common recognition nodes are formed into common recognition node cluster, the common recognition node cluster receives client hair
Rise transaction and by know together algorithm sort to multiple transaction, it is described know together algorithm be PBFT algorithms realization, can ensure to save
Reach an agreement to the sequence of each transaction inside point group;
It includes that intelligent contract is packaged and operating system, contract code check device and transaction flow revolving die that the contract layer, which is arranged,
Block, wherein merchandise for deployment, elder generation is by the contract code check device to intelligent contract code static scanning to intercept malice journey
Sequence, by after inspection by the packing and the intelligent contract of operating system verification whether can by system operation, by after verification by institute
It states transaction flow revolving die block and intelligent obligating document is sent to network layer handles;It merchandises for calling, is first examined by the contract code
Device is looked into intelligent contract code static scanning to intercept rogue program, by inputting the input parameter for including in transaction after inspection
To the packing and operating system, the packing and output operation result after the intelligent contract code of operating system operation to the friendship
Operation result processing is that the read-write collection with version number is sent to network layer handles by easily circulation module, the circulation module;
It includes that digital certificate signs and issues mechanism, Node registry and authentication module that the authorization layer, which is arranged, wherein the authorization layer
Block chain network is added in authorization node, verifies the legitimacy of node;The digital certificate signs and issues mechanism by participating in intelligent contract
Linked groups safeguard that the digital certificate signs and issues mechanism and holds a group key pair, and key pair is generated by ECDSA algorithms, institute jointly
It states digital certificate and signs and issues whole nodes in the public key informing network of the cipher key pair that mechanism holds, the private key of cipher key pair is only signed
Hair mechanism itself possesses, and node, which is signed and issued through digital certificate after mechanism authorizes digital certificate and private key, could be added block chain network,
Ensure that digital certificate and private key can not be forged by Digital Signature Algorithm, digital signature uses a group key pair, digital signature to use
Key pair authority signature and granting are signed and issued by the digital certificate, node must sign and issue machine before network is added to the digital certificate
Structure application mandate, digital certificate sign and issue mechanism by being that node generates a group key pair after application, public key and nodal information are protected
Save as digital certificate, digital certificate signs and issues mechanism and counted word signature to certificate with own private key, digital certificate and section after signature
Point private key is preserved by node, and digital certificate and number is done to message with own private key on all message bands that node is broadcasted in a network
Word is signed, other nodes verify the legitimacy of sender after receiving broadcast, and verification is divided into certificate validity checking and certificate
Hold inspection, certificate validity checking is whether verification certificate is signed and issued mechanism by the digital certificate and generated, and is tested using ECC algorithm
Whether the content for demonstrate,proving digital certificate by the digital certificate signs and issues authority signature, and certificate, which holds inspection, ensures node from the number
Certificate issuance mechanism obtains the certificate of certificate and other non-copied nodes, uses ECC algorithm verification broadcasted content, the number of broadcast
Whether signature meets the public key in digital certificate;
It includes that digital certificate and secret key management, client SDK, command line interface and far call connect that the application layer, which is arranged,
Mouthful, wherein the application layer provides the interactive mode of client and block chain, to client in a manner of code call and order line
It includes application authorization API that end, which provides, merchandises and proposes API, Authorization result readjustment API, executes intelligence and about API and implementing result time
Adjust API;
The client SDK points are Java SDK, PHP SDK, Go SDK, correspond to the visitor that different programming languages are realized respectively
Different programming language codes are converted to JSON character strings and are sent to far call interface by family end, the client SDK;The life
It enables line interface that the input of order line is converted to JSON character strings and is sent to far call interface;The far call interface connects
It receives and output data format is JSON character strings, pass through http protocol transmission data, wherein
For applying for authorization API, the data of receiving are resolved into application information and are sent to network layer, are returned by Authorization result
API is adjusted to notify client;API is proposed for transaction, the data of reception are resolved into intelligent contract call instruction, transaction is generated and carries
View uses private key to generate transaction proposal digital signature and is attached to digital certificate and proposes that message is sent to network layer, node as transaction
API is adjusted back by the implementing result after local account book update and notifies client.
Another side according to the present invention also provides a kind of block chain realization equipment of the intelligent contract of operation, including::
Client is used to preserve one group of public and private secret key, and for initiating transaction, wherein the client is used for will be intelligent
Contract call instruction, which is packaged as transaction, to be proposed, is initiated transaction and is proposed to multiple accounting nodes, and multiple accounting nodes is waited for respond
The transaction is proposed, the proposed issue is compared, and transaction is re-initiated if inconsistent and is proposed, if consistent described in submission
Proposed issue is to node cluster of knowing together;
Accounting nodes are handed over for preserving a group key pair, and for distributed storage account book, the intelligent contract of operation and verification
Easily, wherein each accounting nodes are used to respectively verify the validity that the transaction is proposed and execute to be verified as effectively merchandising and carry
View after returning to the block undetermined that proposed issue to the client and accounting nodes receives common recognition node, verifies the area undetermined
Transaction in block proposes, reject authentication failed transaction propose after will contain only the transaction proposal being proved to be successful and be packaged into block and add
It is added to block chain;
Node of knowing together is used for distributed storage account book, and run intelligent contract, verification is handed over for preserving a group key pair
Easily, the common recognition of sequence is reached between multiple transaction sequence in block and all common recognition nodes;Wherein, the common recognition node cluster
For collecting the proposed issue, the validity of the proposed issue is verified, serial number is added to effective proposed issue is verified as,
After the stand-by period that the serial number reaches default serial number threshold value or collects the proposed issue reaching preset time threshold, by institute
It states proposed issue and is packaged into block undetermined, send the block undetermined to the accounting nodes, while verifying the block undetermined
Interior transaction proposes, reject authentication failed transaction propose after will contain only the transaction proposal being proved to be successful and be packaged into block addition
To block chain.
In block chain realization one embodiment of equipment of the intelligent contract of operation of the present invention, including:
Data Layer, including key value database and database management module, the data Layer is for preserving block data and intelligence
The data of energy contract generation, offer do additions and deletions to intelligent contract data and change the interface looked into, and the block is defined in the data Layer
The structure of distributed account book, account book are made of block chain and world state in chain, wherein the block chain is made of block
Retrospective chained list, block are made of block head, block data, metadata, and block is proposed to form by transaction, and the transaction is proposed
There are two types of types:Deployment transaction and calling transaction, wherein deployment transaction is that intelligent obligating document is written to the record of block, is remembered
Record content includes file source code, deployment people, version number, configuration information, transaction unique mark;It is intelligent contract tune to call transaction
With the record of process, record content includes block height where intelligent contract source code, transaction unique mark, intelligent contract method
The digital signature of name, call parameters and trade initiator, executor;World state is the collection of the state of all intelligent contracts
It closes, state is after intelligent contract is run finally to the expression way of database manipulation;Intelligent contract operation result collects table by read-write
Show, read-write collection is made of readset with collection is write, wherein writing the set that collection is the state that an intelligent contract once calls generation;
Network layer, for managing a point to point network, the network layer includes Data Transport Protocol, node exploration mould
Block, data simultaneous module and broadcast transaction modules, wherein Data Transport Protocol is a kind of final consistency algorithm, is realized
Gossip agreements, the data for synchronizing each node of block chain, synchronizing process are that transmission-reception-is more within a synchronizing cycle
It newly-beams back-and updates-beam back again-newer flow again, each period randomly chooses a node, finally by data dissemination to institute
There is node;Node explores module, and the list for managing known node IP address in a network, this list is initially being disposed
It is manually entered when block chain network, when network is added in a new node, exploration module, which generates, explores message, and it includes to be somebody's turn to do to explore message
The mandate and known node list that node obtains in block chain network, mandate are provided by the authorization layer, data transmission association
View sends and receives exploration message, first selects recipient's node from node listing, then broadcasts one and explore message to recipient, connects
The exploration module of receipts person compares local known node list after receiving message, if explored in message comprising locally no section
Point IP is then increased this IP to local node list newly, and if not updating local list not comprising if, spy is beamed back after the completion of comparison
Rope is responded to the sender for exploring message, and probe response content includes mandate and the updated known node row of node itself
Table, recipient receive after probe response that content updates local node list in the same fashion according to response, beam back spy after update again
The response message of rope response, recipient update node listing again;The data simultaneous module, it is same for sending and receiving data
Message is walked, synchronization message is divided into synchronous block height and synchronous block data, wherein the synchronous block height includes node sheet
Block height, the digital signature of message on ground, the synchronous block data include to need newer block content, the number of message
Signature, the synchronization message equally follow Data Transport Protocol to other node broadcasts, and node timing sends synchronous block height
Message, when discovery recipient's block height then sends synchronous block data message to obtain newest area more than itself block height
Block;The broadcast transaction modules provide not for being divided into client-side, accounting nodes side and common recognition node side for different role
Congenerous.The transaction proposal that application layer generates is sent to accounting nodes by client-side, and operation result is beamed back visitor by accounting nodes side
Family end, result treatment is transaction message and is sent to common recognition node by client-side, and transaction message includes the processing knot of accounting nodes
Fruit, the digital signature of message, common recognition node side receive transaction message, and common recognition result is sent after processing to accounting nodes;
Common recognition layer, for all common recognition nodes to be formed common recognition node cluster, the common recognition node cluster receives client initiation
Transaction and by know together algorithm sort to multiple transaction, it is described know together algorithm be PBFT algorithms realization;
Contract layer, including intelligent contract is packaged and operating system, contract code check device and transaction flow revolving die block, wherein
For deployment merchandise, first by the contract code check device to intelligent contract code static scanning to intercept rogue program, pass through
After inspection by the packing and the intelligent contract of operating system verification whether can by system operation, by after verification by the transaction flow
Intelligent obligating document is sent to network layer handles by revolving die block;It merchandises for calling, first by the contract code check device to intelligence
Energy contract code static scanning is to intercept rogue program, by the way that the input parameter for including in transaction is input to described beat after inspection
Packet and operating system, it is described to be packaged and output operation result after the intelligent contract code of operating system operation to the transaction flow revolving die
Operation result processing is that the read-write collection with version number is sent to network layer handles by block, the circulation module;
Authorization layer, including digital certificate sign and issue mechanism, Node registry and authentication module, wherein the authorization layer mandate section
Point verifies the legitimacy of node for block chain network to be added;
Application layer, including digital certificate and secret key management, client SDK, command line interface and far call interface,
In, the application layer, the interactive mode for providing client and block chain, to client in a manner of code call and order line
It includes application authorization API that end, which provides, merchandises and proposes API, Authorization result readjustment API, executes intelligence and about API and implementing result time
Adjust API.
The block chain of the intelligent contract of operation of the present invention realizes in one embodiment of equipment that the digital certificate signs and issues mechanism,
Linked groups by participating in intelligent contract safeguard jointly, and the digital certificate signs and issues mechanism and holds a group key pair, key pair by
ECDSA algorithms generate, and the digital certificate signs and issues whole nodes, key in the public key informing network of the cipher key pair that mechanism holds
The private key of centering is only signed and issued mechanism itself and is possessed, and node signs and issues ability after mechanism authorizes digital certificate and private key through digital certificate
Block chain network is added, ensures that digital certificate and private key can not be forged by Digital Signature Algorithm, digital signature uses a group key
Right, the key pair that digital signature uses signs and issues authority signature and granting by the digital certificate, and node must be to institute before network is added
It states digital certificate and signs and issues mechanism application mandate, digital certificate is signed and issued mechanism by being that node generates a group key pair after application, incited somebody to action
Public key and nodal information save as digital certificate, and digital certificate signs and issues mechanism and counted word signature to certificate with own private key, signature
Digital certificate afterwards is preserved with node private key by node, on all message bands that node is broadcasted in a network digital certificate and with from
Body private key does digital signature to message, other nodes verify the legitimacy of sender after receiving broadcast, and verification is divided into certificate
Validity check and certificate hold inspection, and certificate validity checking is whether verification certificate by the digital certificate signs and issues mechanism life
At whether the content for verifying digital certificate using ECC algorithm by the digital certificate signs and issues authority signature, and it is true that certificate holds inspection
Guarantor's node signs and issues mechanism from the digital certificate and obtains certificate and the certificate of other non-copied nodes, is verified using ECC algorithm wide
Broadcast content, whether the digital signature of broadcast meets public key in digital certificate.
The block chain of the intelligent contract of operation of the present invention realizes in one embodiment of equipment that the client SDK is divided into Java
SDK, PHP SDK, Go SDK correspond to the client that different programming languages are realized respectively, and the client SDK, being used for will be different
Programming language code is converted to JSON character strings and is sent to far call interface;The command line interface is used for order line
Input is converted to JSON character strings and is sent to far call interface;The reception of the far call interface and output data format are equal
For JSON character strings, it is used to pass through http protocol transmission data, wherein for applying for authorization API, the data of receiving are resolved to
Application information is sent to network layer, and adjusting back API by Authorization result notifies client;API is proposed for transaction, by the number of reception
It according to intelligent contract call instruction is resolved to, generates transaction and proposes, generated to merchandise with private key and propose digital signature and be attached to digital card
Book proposes that message is sent to network layer as transaction, logical by implementing result readjustment API after the account book update of node local
Know client.
According to the another side of the application, a kind of computer-readable medium is also provided, computer-readable instruction is stored thereon with,
The computer-readable instruction can be executed by processor to realize method described in any one of the above embodiments.
According to the another side of the application, a kind of equipment for being handled in network equipment client information, the equipment packet are also provided
Include the memory for storing computer program instructions and the processor for executing program instructions, wherein when the computer journey
When sequence instruction is executed by the processor, triggers the equipment and execute method described in any one of the above embodiments.
The detailed content of above-mentioned each equipment and storage medium embodiment, for details, reference can be made to the correspondence portions of each method embodiment
Point, here, repeating no more.
Each embodiment is described by the way of progressive in this specification, the highlights of each of the examples are with other
The difference of embodiment, just to refer each other for identical similar portion between each embodiment.
Professional further appreciates that, unit described in conjunction with the examples disclosed in the embodiments of the present disclosure
And algorithm steps, can be realized with electronic hardware, computer software, or a combination of the two, in order to clearly demonstrate hardware and
The interchangeability of software generally describes each exemplary composition and step according to function in the above description.These
Function is implemented in hardware or software actually, depends on the specific application and design constraint of technical solution.Profession
Technical staff can use different methods to achieve the described function each specific application, but this realization is not answered
Think beyond the scope of this invention.
Obviously, those skilled in the art can carry out invention spirit of the various modification and variations without departing from the present invention
And range.If in this way, these modifications and changes of the present invention belong to the claims in the present invention and its equivalent technologies range it
Interior, then the present invention is also intended to including these modification and variations.