Summary of the invention
Purpose of this disclosure is to provide a kind of method, system, device, storage medium and electronics for auditing intelligent contract to set
It is standby, for solving by setting specific algorithm according to the bytecode of certain pattern match intelligence contract, to come in the related technology
The lower technical problem of the accuracy rate audited to intelligent contract.
To achieve the goals above, the embodiment of the present disclosure in a first aspect, providing a kind of method of intelligent contract of auditing, institute
The method of stating includes:
Obtain the bytecode of the intelligent contract;
The bytecode is mapped based on word2vec algorithm to obtain target input matrix;
By in the trained intelligent contract audit model of target input matrix input, obtain for characterizing the intelligence
The auditing result of the safety height of contract.
Optionally, the intelligent contract audit model is convolutional neural networks CNN model, the training sample of the CNN model
It originally include the input matrix mapped based on bytecode of the word2vec algorithm to intelligent contract, and for characterizing the intelligence
The sample data pair of the probability composition of the safety height of contract.
Optionally, the width of the convolution kernel of the CNN model and the target input matrix is of same size, and/or, institute
State the size phase of characteristic pattern of the size of the filter of the pond layer of CNN model with the target input matrix after convolution
Together.
Optionally, the value range of the width of the width and convolution kernel of the target input matrix is 50~100,
The value range of the quantity of the convolution kernel is 50~200, and the stride of the CNN model is 1.
Optionally, the method also includes:
The auditing result is stored to the block chain where the intelligent contract, and/or, the auditing result is sent
To terminal, the auditing result is stored in the caching of the terminal.
Optionally, the auditing result is used for before the transaction event in corresponding intelligent contract is performed, and is examined based on this
Meter result determines whether the safety of the intelligent contract meets the execution condition of the transaction event.
The second aspect of the embodiment of the present disclosure provides a kind of system of intelligent contract of auditing, comprising:
Console, the intelligent contract monitoring device being connect with the console, and with the intelligent contract monitoring device
The intelligent contract audit device of connection;
The console is used for, and generates audit order, and audit order is sent to the intelligent contract monitoring dress
It sets;
The intelligence contract monitoring device is used for, and intelligence to be audited is obtained from block catenary system according to audit order
The bytecode of energy contract, and the bytecode of the intelligence contract is sent to the intelligent contract audit device;
The intelligence contract audit device is for method described in perform claim requirement 1.
Optionally, the console is used for, and when detecting that terminal disposes transaction event to intelligent contract, is generated for referring to
Show the audit order audited to the intelligent contract.
Optionally, the intelligent contract audit device is also used to, and the auditing result is sent to the intelligent contract prison
Control device;
The intelligence contract monitoring device is also used to, and the safety of the intelligent contract is determined based on the auditing result received
Property whether meet the execution condition of transaction event on the intelligent contract;
If the safety of the intelligence contract is unsatisfactory for the execution condition of the transaction event, refuse the transaction event
Execution.
The third aspect of the embodiment of the present disclosure provides a kind of device of intelligent contract of auditing, comprising:
Module is obtained, is configured as obtaining the bytecode of the intelligent contract;
Mapping block is configured as mapping the bytecode to obtain target input matrix based on word2vec algorithm;
Audit Module is configured as inputting the target input matrix in trained intelligent contract audit model, obtain
To the auditing result of the safety height for characterizing the intelligent contract.
The fourth aspect of the embodiment of the present disclosure provides a kind of computer readable storage medium, is stored thereon with computer journey
The step of sequence, which realizes any one of above-mentioned first aspect the method when being executed by processor.
5th aspect of the embodiment of the present disclosure, provides a kind of electronic equipment, comprising:
Memory is stored thereon with computer program;
Processor, it is any in above-mentioned first aspect to realize for executing the computer program in the memory
The step of item the method.
Through the above technical solutions, obtaining the bytecode of the intelligent contract;Based on word2vec algorithm to the byte
Code mapping obtains target input matrix;By in the trained intelligent contract audit model of target input matrix input, obtain
For characterizing the auditing result of the safety height of the intelligent contract.Wherein, intelligent contract audit model is based on machine learning
Algorithm is established, and machine learning algorithm has preferable working efficiency in pattern-recognition, is audited by trained intelligent contract
Model identifies the target input matrix that the bytecode of intelligent contract maps, and improves for the audit of intelligent contract
Accuracy rate.
Other feature and advantage of the disclosure will the following detailed description will be given in the detailed implementation section.
Specific embodiment
It is described in detail below in conjunction with specific embodiment of the attached drawing to the disclosure.It should be understood that this place is retouched
The specific embodiment stated is only used for describing and explaining the disclosure, is not limited to the disclosure.
Fig. 1 is a kind of block diagram of the system of intelligent contract of auditing shown according to an exemplary embodiment, as shown in Figure 1,
The system 10 includes:
Console 101, the intelligent contract monitoring device 102 being connect with the console 101, and with the intelligent contract
The intelligent contract audit device 103 that monitoring device 102 connects;
The console 101 is used for, and generates audit order, and audit order is sent to the intelligent contract monitoring
Device 102;
The intelligence contract monitoring device 102 is used for, and is obtained from block catenary system wait audit according to audit order
Intelligent contract bytecode, and the bytecode of the intelligence contract is sent to the intelligent contract audit device 103;
The intelligence contract audit device 103 is used to execute method as shown in Figure 2, specifically includes:
S11 obtains the bytecode of the intelligent contract.
In the disclosure, console 101, intelligent contract monitoring device 102 and intelligent contract audit device 103 can both be adopted
With formal implementation of hardware, can also realize in the form of software functional units.SFU software functional unit is stored in a storage
In medium, including several power functions.Specifically, above-mentioned SFU software functional unit is stored in a computer readable storage medium
In, including some instructions use is so that a computer equipment (can be personal computer, server or the network equipment etc.)
It executes.And storage medium above-mentioned includes: read-only memory (Read-Only Memory, abbreviation ROM), random access memory
The various media that can store program code such as (Random Access Memory, abbreviation RAM).Such as in a kind of possible reality
It applies in mode, console 101 is deployed in local computer, intelligent contract monitoring device 102 and intelligent contract audit dress
103 are set to be deployed in Cloud Server.
Intelligent contract is deployed in block catenary system as shown in Figure 1, and intelligent contract monitoring device 102 is receiving control
After the audit order that platform 101 is sent, intelligence specifically to be audited is obtained from the block catenary system according to the audit order and is closed
It may include the address information for the intelligent contract to be obtained in bytecode about, such as audit order, and then according to address information
Obtain the bytecode of intelligent contract to be audited.Intelligent contract monitoring device 102 sends the bytecode of the intelligence contract later
To the intelligent contract audit device 103.
Optionally, the console 101 is used for, and when detecting that terminal disposes transaction event to intelligent contract, is generated and is used
In the audit order that instruction audits to the intelligent contract.
Specifically, the safety of the intelligent contract as where the safety of transaction event execution by the transaction event
Influence, and the transaction event being deployed on intelligent contract meeting certain condition, or while reaching the time of setting can hold automatically
Row, in order to guarantee the safety of transaction event execution, console 101 is detecting terminal to intelligent contract deployment transaction event
When, above-mentioned audit order is generated, so that intelligent contract audit device 103 examines the intelligent contract where transaction event
Meter allows system 10 itself or user to determine whether the transaction event executes according to auditing result, ensures to a certain extent
The safety that transaction event executes.
Certainly, in other possible embodiments, console 101 also can receive being used to indicate from user's triggering
To the audit order that the intelligent contract is audited, and then user can be decided whether according to actual needs to intelligent conjunction
About audit.
In a kind of possible embodiment, in order to examine multiple intelligent contracts simultaneously, multiple intelligent contracts can be disposed
Audit device 103, and the bytecode of different intelligent contract is distributed to specific intelligent contract and examined by one reverse proxy device of deployment
In counter device 103, to increase audit efficiency.
S12 maps the bytecode based on word2vec algorithm to obtain target input matrix.
Due to not of uniform size, byte of the intelligent contract audit device 103 in the intelligent contract of acquisition of different bytecodes
After code, target input matrix is converted for the bytecode by word2vec algorithm, on the one hand can input square with unified goal
The size of battle array is convenient for subsequent calculating, on the other hand by word2vec algorithm, can be simplified to bytecode to reject redundancy
Information reduces subsequent calculation amount.It should be noted that word2vec algorithm belongs to the prior art, the disclosure is not made to have to it
Body illustrates.
S13 is obtained in the trained intelligent contract audit model of target input matrix input described for characterizing
The auditing result of the safety height of intelligent contract.
Specifically, in a kind of possible embodiment, the intelligence contract audit model is convolutional neural networks CNN
(Convolutional Neural Networks) model, the training sample of the CNN model include being based on word2vec algorithm
To the input matrix that the bytecode of intelligent contract maps, and the probability of the safety height for characterizing the intelligence contract
The sample data pair of composition, the corresponding intelligent contract of the input matrix of sample data centering can be chosen known to existing safety
Intelligent contract, or voluntarily write as needed, the probability of corresponding input matrix can be by manually being evaluated to obtain.CNN
Model accuracy rate with higher in pattern-recognition, carrying out audit to intelligent contract by trained CNN model can improve
The accuracy of obtained auditing result.
In addition, it should be noted that, for the method for intelligent contract shown in Fig. 2 of auditing, application is not limited to
Intelligence contract audit device 103 shown in FIG. 1, the disclosure is not specifically limited the effective object of this method.
Optionally, the intelligent contract audit device 103 is also used to, and the auditing result is sent to the intelligent contract
Monitoring device 102;
The intelligence contract monitoring device 102 is also used to, and determines the intelligent contract based on the auditing result received
Whether safety meets the execution condition of the transaction event on the intelligent contract;
If the safety of the intelligence contract is unsatisfactory for the execution condition of the transaction event, refuse the transaction event
Execution.
For example, there is the corresponding characterization intelligence contract of intelligent contract of the execution condition of a transaction event where it
The probability of the auditing result of safety needs to be greater than or equal to 70%, if the transaction that intelligent contract monitoring device 102 receives
The probability of the auditing result of intelligent contract where event is 60%, i.e., the safety of intelligent contract is unsatisfactory for holding for transaction event
Row condition then refuses the execution of the transaction event, and then even if reaching the predetermined time that transaction event executes, does not also execute the friendship
Easy event.If the probability of the auditing result of the intelligent contract where the transaction event that intelligent contract monitoring device 102 receives
It is 80%, i.e., the safety of intelligent contract meets the execution condition of transaction event, when the predetermined time for reaching transaction event execution
When, allow the execution of the transaction event.Such system 10 voluntarily can refuse the lower transaction thing of safety according to auditing result
The execution of part has ensured the safety of transaction event.
In other words, in the disclosure, the auditing result is used for before the transaction event in corresponding intelligent contract is performed,
Determine whether the safety of the intelligent contract meets the execution condition of the transaction event based on the auditing result.
Through the above technical solutions, obtaining the bytecode of the intelligent contract;Based on word2vec algorithm to the byte
Code mapping obtains target input matrix;By in the trained intelligent contract audit model of target input matrix input, obtain
For characterizing the auditing result of the safety height of the intelligent contract.Wherein, intelligent contract audit model is based on machine learning
Algorithm is established, and machine learning algorithm has preferable working efficiency in pattern-recognition, is audited by trained intelligent contract
Model identifies the target input matrix that the bytecode of intelligent contract maps, and improves for the audit of intelligent contract
Accuracy rate.
Optionally, in the disclosure, the width phase of the width of the convolution kernel of the CNN model and the target input matrix
Together, and/or, the size of the filter of the pond layer of the CNN model and feature of the target input matrix after convolution
The size of figure is identical.
Specifically, it is contemplated that a line of the bytecode of intelligent peace treaty includes a complete information, cannot be split,
Therefore width and the target input matrix of the convolution kernel of setting CNN model is of same size, the characteristic pattern that convolution obtains
Width is 1, for characterizing the feature of a line bytecode.And in order to be further simplified the information that bytecode includes, CNN model is set
Pond layer filter size it is identical as the size of characteristic pattern of the target input matrix after convolution, and then convolution
Any feature figure afterwards passes through filter Chi Huahou, and the size of obtained characteristic pattern is 1*1, and the information content for including reduces, adds
Fast calculating speed.
For example, the size of target input matrix is n*k1*1, wherein n is the height of target input matrix, size
It can be as unit of operation code, i.e., when being mapped by word2vec algorithm, as a unit with 32 bytes, in turn
1 unit height of target input matrix corresponds to 32 bytes of bytecode, and k1 indicates the width of target input matrix, and target is defeated
Entering 1 in matrix size indicates that target input matrix is single channel.The size of convolution kernel is h*k2*w, wherein h is that convolution kernel is high
Degree, k2 is convolution kernel width, and k2=k1, w indicate the quantity of convolution kernel.The size of the characteristic pattern obtained after convolution is c*
1*w, the i.e. height of characteristic pattern after convolution are c, width 1, quantity w, wherein c=(n-h)/stride+1, stride are
The stride of CNN model.The size of the filter of pond layer be c*1*w, i.e., the height of filter be c, width 1, quantity w,
Size obtained from by every characteristic pattern of filter Chi Huahou is 1*1.It can choose effect pair when filter pond
Characteristic pattern of the maximum value as Chi Huahou as in.Chi Huahou, can full articulamentum by the characteristic pattern of Chi Huahou through CNN model
Classified by softmax and exports auditing result.
Optionally, the value range of the width of the width and convolution kernel of the target input matrix is 50~100,
The value range of the quantity of the convolution kernel is 50~200, and the stride of the CNN model is 1.
Above-mentioned example is continued to use, in a kind of possible embodiment, k1=k2=100, w=200, stride=1, h=
2, it should be noted that for different convolution kernels, the value of convolution kernel height h can be different, such as have 3 convolution kernels, the
The height h=1 of one convolution kernel, the height h=2 of second convolution kernel, the height h=5 of third convolution kernel are so wrapped
Characteristic pattern containing different information.It can be avoided using Dropout (random inactivation) algorithm when the full articulamentum training of CNN model
The activation primitive of fitting, CNN model uses ReLu (Rectified Linear Unit, line rectification function).
Optionally, in the disclosure, the method for auditing intelligent contract can also include:
The auditing result is stored to the block chain where the intelligent contract, and/or, the auditing result is sent
To terminal, the auditing result is stored in the caching of the terminal.
Specifically, above-mentioned steps S13 execution after, obtained auditing result is stored, for example, simultaneously store to
In block chain and in the caching of terminal, and then when user needs to inquire auditing result, can first in the caching of terminal into
Row search, if search in block chain less than scanning for.It is of course also possible to which auditing result is led to according to user instructions
Terminal output is crossed, such as is shown by the display screen of terminal.
The another aspect of the embodiment of the present disclosure also provides a kind of device of intelligent contract of auditing, as shown in figure 3, the device
200 include:
Module 210 is obtained, is configured as obtaining the bytecode of the intelligent contract;
Mapping block 220 is configured as mapping the bytecode to obtain target input matrix based on word2vec algorithm;
Audit Module 230 is configured as inputting the target input matrix in trained intelligent contract audit model,
Obtain the auditing result of the safety height for characterizing the intelligent contract.
Through the above technical solutions, obtaining the bytecode of the intelligent contract;Based on word2vec algorithm to the byte
Code mapping obtains target input matrix;By in the trained intelligent contract audit model of target input matrix input, obtain
For characterizing the auditing result of the safety height of the intelligent contract.Wherein, intelligent contract audit model is based on machine learning
Algorithm is established, and machine learning algorithm has preferable working efficiency in pattern-recognition, is audited by trained intelligent contract
Model identifies the target input matrix that the bytecode of intelligent contract maps, and improves for the audit of intelligent contract
Accuracy rate.
About the device in above-described embodiment, wherein modules execute the concrete mode of operation in related this method
Embodiment in be described in detail, no detailed explanation will be given here.
Fig. 4 is the block diagram of a kind of electronic equipment shown according to an exemplary embodiment.For example, electronic equipment 1900 can be with
It is provided as a server.Referring to Fig. 4, electronic equipment 1900 includes processor 1922, and quantity can be one or more, with
And memory 1932, for storing the computer program that can be executed by processor 1922.The computer stored in memory 1932
Program may include it is one or more each correspond to one group of instruction module.In addition, processor 1922 can be by
It is configured to execute the computer program, the method to execute the intelligent contract of above-mentioned audit.
In addition, electronic equipment 1900 can also include power supply module 1926 and communication component 1950, the power supply module 1926
It can be configured as the power management for executing electronic equipment 1900, which can be configured as realization electronic equipment
1900 communication, for example, wired or wireless communication.In addition, the electronic equipment 1900 can also include that input/output (I/O) connects
Mouth 1958.Electronic equipment 1900 can be operated based on the operating system for being stored in memory 1932, such as Windows
ServerTM, Mac OS XTM, UnixTM, LinuxTM etc..
In a further exemplary embodiment, a kind of computer readable storage medium including program instruction is additionally provided, it should
The step of method of the intelligent contract of above-mentioned audit is realized when program instruction is executed by processor.For example, this computer-readable is deposited
Storage media can be the above-mentioned memory 1932 including program instruction, and above procedure instruction can be by the processor of electronic equipment 1900
1922 methods executed to complete the intelligent contract of above-mentioned audit.
In a further exemplary embodiment, a kind of computer program product is also provided, which includes energy
Enough computer programs executed by programmable device, which has is used for when being executed by the programmable device
Execute the code section of the method for the intelligent contract of above-mentioned audit.
The preferred embodiment of the disclosure is described in detail in conjunction with attached drawing above, still, the disclosure is not limited to above-mentioned reality
The detail in mode is applied, in the range of the technology design of the disclosure, a variety of letters can be carried out to the technical solution of the disclosure
Monotropic type, these simple variants belong to the protection scope of the disclosure.
It is further to note that specific technical features described in the above specific embodiments, in not lance
In the case where shield, can be combined in any appropriate way, in order to avoid unnecessary repetition, the disclosure to it is various can
No further explanation will be given for the combination of energy.
In addition, any combination can also be carried out between a variety of different embodiments of the disclosure, as long as it is without prejudice to originally
Disclosed thought equally should be considered as disclosure disclosure of that.