A kind of data tamper resistant method and system based on block chain technology
Technical field
This disclosure relates to block chain technical field more particularly to a kind of data tamper resistant method based on block chain technology
And system.
Background technique
Block chain technology is also referred to as distributed account book technology, is a kind of internet database technology, its main feature is that
It is decentralization, open and clear, allow everyone to each may participate in data-base recording.
Website or information system core business data tamper-proof requirement are long-standing, are generally divided into the protection of file driving layer,
Illegal process is forbidden to carry out database write operations;Backup and Restore protection, first backs up to locally or remotely another text for information data
In part, two end data to be detected is restored when inconsistent with backup end data.Both the above traditional solution is all certain
External attack is increased in degree to attempt to distort the difficulty of core business data.And in traditional center type operation system mode
Under, built-in system administrative staff still can be by subjectivity operation easily around protection to altered data.Such as system manager
Stop the protection service of file driving layer, or modification backup end data, covers operation system data using altered data.Therefore, have
Necessity, which provides the new technical solution of one kind, improves one or more problem present in above scheme.
It should be noted that information is only used for reinforcing to the background of the disclosure disclosed in above-mentioned background technology part
Understand, therefore may include the information not constituted to the prior art known to persons of ordinary skill in the art.
Summary of the invention
The disclosure is designed to provide a kind of data tamper resistant method and system based on block chain technology, Jin Erzhi
It is few to overcome the problems, such as caused by the limitation and defect due to the relevant technologies one or more to a certain extent.
According to the first aspect of the embodiments of the present disclosure, a kind of data tamper resistant method based on block chain technology is provided, it should
Method includes:
A data write request and a business datum are received, is determined belonging to the business datum according to default mapping table
Data segment, and calculate the first hash value of the data segment;
The business datum and the first hash value cochain are stored into a block chain, later according to the data
A service database is written in the business datum by write request;
A data read request is received, the business number is obtained from the service database according to the data read request
According to data segment belonging to the determining business datum obtained calculates the second hash value of the data segment;
The first hash value is obtained from the block chain, compares first hash value and the 2nd Hash value, if consistent
The business datum of reading is returned into display.
In embodiment of the disclosure, this method further include:
According to default poll detection cycle, every preset time period calculates business datum described in the service database
The third hash value of affiliated data segment, and by first hash value stored in the third hash value and the block chain into
Row compares;
When the first hash value and third hash value are inconsistent, the business datum stored in the block chain is obtained,
Recovery is updated to business datum corresponding in the service database using the business datum.
It is described to store the business datum and the first hash value cochain to an area in embodiment of the disclosure
In block chain, comprising:
The business datum and first hash value are sent to a block chain network;
Block chain network carries out the business datum of submission and first hash value by default common recognition algorithm
It knows together and records cochain storage;The number of nodes for wherein participating in common recognition is 3N+1.
It is described that a service database is written into the business datum in embodiment of the disclosure, comprising:
If it is unsuccessful that service database process is written, database manipulation rollback, and cochain is stored to the area
The business datum and first hash value on block chain are made to delete label.
In embodiment of the disclosure, this method further include:
If the first hash value and the second hash value are inconsistent, the business datum stored in the block chain is obtained,
Recovery is updated to business datum corresponding in the service database using the business datum.
In embodiment of the disclosure, the business datum and the first hash value cochain are stored to a block chain
Before, private key signature process is carried out to the business datum and first hash value.
In embodiment of the disclosure, the service database includes relevant database, non-relational database, center
Type database or distributed data base.
According to the second aspect of an embodiment of the present disclosure, a kind of data tamper resistant systems based on block chain technology are provided, it should
System includes:
Data receipt unit is determined for receiving a data write request and a business datum according to default mapping table
Data segment belonging to the business datum, and calculate the first hash value of the data segment;
Data storage cell, for storing the business datum and the first hash value cochain to a block chain
In, the business datum is written by a service database according to the data write request later;
Data check unit, for receiving a data read request, according to the data read request from the business datum
Library obtains the business datum, determines data segment belonging to the business datum obtained, calculates the second hash value of the data segment;
The first hash value is obtained from the block chain, compares first hash value and the second hash value, by reading if consistent
The business datum returns to display.
According to the third aspect of an embodiment of the present disclosure, a kind of computer readable storage medium is provided, calculating is stored thereon with
Machine program, the program are realized a kind of based on block chain technology described in any one above-mentioned embodiment when being executed by processor
The step of data tamper resistant method.
According to a fourth aspect of embodiments of the present disclosure, a kind of electronic equipment is provided, comprising:
Processor;And
Memory, for storing the executable instruction of the processor;
Wherein, the processor is configured to execute any one above-mentioned embodiment via the executable instruction is executed
Described in a kind of data tamper resistant method based on block chain technology the step of.
The technical scheme provided by this disclosed embodiment can include the following benefits:
Data tamper resistant method based on block chain technology provided by the disclosure, by the business datum received and
The hash value of the affiliated data segment of the business datum is first stored into a block chain, and business number is written in the business datum again later
It, can be to the hash value of the affiliated data segment of business datum in database then when receiving data read request according in library
The stored hash value to the affiliated data segment of business datum on block chain is compared, if the two data unanimously return
Display then proves that two business datums are also consistent, i.e., the business datum in database is not tampered.As it can be seen that this method
It ensure that the data that user reads are always truthful data, it is therefore prevented that external attack and internal control personnel's subjectivity distort industry
Business data.Furthermore the disclosure also provides a kind of data tamper resistant systems based on block chain technology, and its advantages are same as above institute
It states.
It should be understood that above general description and following detailed description be only it is exemplary and explanatory, not
The disclosure can be limited.
Detailed description of the invention
The drawings herein are incorporated into the specification and forms part of this specification, and shows the reality for meeting the disclosure
Example is applied, and together with specification for explaining the principles of this disclosure.It should be evident that the accompanying drawings in the following description is only this
Disclosed some embodiments without creative efforts, may be used also for those of ordinary skill in the art
To obtain other drawings based on these drawings.
Fig. 1 schematically shows a kind of data tamper resistant method based on block chain technology in disclosure exemplary embodiment
Schematic diagram;
Fig. 2 schematically shows business datum in disclosure exemplary embodiment and flow chart is written;
Fig. 3 schematically shows business datum in disclosure exemplary embodiment and reads flow chart;
Fig. 4 schematically shows poll overhaul flow chart in disclosure exemplary embodiment;
Fig. 5 schematically shows a kind of data tamper resistant systems based on block chain technology in disclosure exemplary embodiment
Schematic diagram;
Fig. 6 schematically shows a kind of computer readable storage medium schematic diagram in disclosure exemplary embodiment;
Fig. 7 schematically shows a kind of electronic equipment schematic diagram in disclosure exemplary embodiment.
Specific embodiment
Example embodiment is described more fully with reference to the drawings.However, example embodiment can be with a variety of shapes
Formula is implemented, and is not understood as limited to example set forth herein;On the contrary, thesing embodiments are provided so that the disclosure will more
Add fully and completely, and the design of example embodiment is comprehensively communicated to those skilled in the art.Described spy
Sign, structure or characteristic can be incorporated in any suitable manner in one or more embodiments.
In addition, attached drawing is only the schematic illustrations of the disclosure, it is not necessarily drawn to scale.Identical attached drawing in figure
Label indicates same or similar part, thus will omit repetition thereof.Some block diagrams shown in the drawings are
Functional entity, not necessarily must be corresponding with physically or logically independent entity.These can be realized using software form
Functional entity, or these functional entitys are realized in one or more hardware modules or integrated circuit, or heterogeneous networks and/
Or these functional entitys are realized in processor device and/or microcontroller device.
A kind of data tamper resistant method based on block chain technology, this method are provided firstly in this example embodiment
It can be applied to a terminal device for having display screen, such as can be mobile phone, personal digital assistant, laptop, put down
The mobile terminals such as plate computer, smartwatch are also possible to the immobile terminals such as desktop computer, smart television.With reference to institute in Fig. 1
Show, this method may include:
Step S101: a data write request and a business datum are received, the business is determined according to default mapping table
Data segment belonging to data, and calculate the first hash value of the data segment;
Step S102: the business datum and the first hash value cochain are stored into a block chain, Zhi Hougen
A service database is written into the business datum according to the data write request;
Step S103: receiving a data read request, obtains institute from the service database according to the data read request
Business datum is stated, data segment belonging to the business datum obtained is determined, calculates the second hash value of the data segment;
Step S104: obtaining the first hash value from the block chain, compares the first Hash value and the 2nd Hash
The business datum of reading is returned to display if consistent by value.
By the above method, the hash value of the business datum received and the affiliated data segment of the business datum is first deposited
In Chu Zhiyi block chain, the business datum is written in service database again later, is then receiving data read request
When, it can hash value to the affiliated data segment of business datum in database and the stored business datum on block chain
The hash value of affiliated data segment is compared, if the two data are consistent, proves that two business datums are also consistent, i.e. database
In business datum be not tampered.As it can be seen that this method ensure that the data that user reads are always truthful data, prevent
External attack is stopped and internal control personnel's subjectivity distorts business datum.
In the following, will be carried out referring to figs. 1 to each step of the Fig. 4 to the above method in this example embodiment more detailed
Explanation.
In step s101, the default mapping table can be voluntarily fixed according to the type of business datum and the demand of user
Justice, the data segment refer to according to the information aggregate presetting the corresponding relationship of corresponding table always while being read by a user.Example
Such as, the fields such as name, home address, identification card number, validity period, issuing authority in customized user identity card information are all right
It reflects to identity information data section, and this enantiomorphic relationship is passed through into storage of linked list.Then each field can correspond to a data
Section, a data segment may include one or more fields.The above enantiomorphic relationship is merely illustrative, does not represent to the disclosure
Limitation.
In step s 102, the business datum and the first hash value cochain are stored into a block chain, also
Including the business datum and first hash value are sent to a block chain network, block chain network passes through default total
Know algorithm, such as using PBFT common recognition algorithm, the business datum and first hash value to submission are known together simultaneously
Cochain storage is recorded, wherein the number of nodes for participating in common recognition is 3N+1, N is natural number.In this step, it stores into block chain
Content not only include business datum, further comprise the first hash value of the affiliated data segment of the data.Its design advantage exists
In successively calculating number when the data of write-in have the data segment that a large amount of fields such as similar user information, company information are constituted
According to each field in library and the whether identical operation of backup field on chain, meeting holding time due to a large amount of chain data query
Expense, and in this method, as long as by the of the data segment stored on the second hash value for reading the affiliated data segment of data and chain
One hash value is compared, so that it may quickly judge data whether there is or not distorting, so that performance is optimized.
In the particular embodiment, the business datum and the first hash value cochain are stored to a block chain
Before, private key signature process is carried out to the business datum and first hash value, and cochain storing process needs to cooperate
Use block chain software or hardware wallet.
In step s 102, it when the business datum and the first hash value cochain process exception, then directly returns
Show abnormal results, related cleaning is done in the operation of block chain;When the business datum and the first hash value cochain success,
And business datum write-in service database process is unsuccessful, then database manipulation rollback, and cochain is stored to the area
The business datum and first hash value on block chain are made to delete label.In the particular embodiment, the business number
It include relevant database, non-relational database, centre type database or distributed data base according to library.
In one embodiment, flow chart is written in more specific business datum, as shown in Figure 2, comprising the following steps:
S11 receives a data write request and a business datum;
S12 determines data segment belonging to the business datum, and calculates the first Hash value of the data segment, and will be described
Business datum and the first hash value cochain are stored into a block chain;
S13 judges whether cochain success, if upper chain process is unsuccessful, returns to display exception, phase is done in the operation of block chain
Close cleaning;If cochain success, enters step S24;
Service database is written in business datum by S14;
S15 judges whether to be written successfully, if write-in is unsuccessful, database manipulation rollback is deposited card data on chain and deleted
Except label;If being written successfully, process terminates.
In step S103 and step S104, if the first hash value and the second hash value are inconsistent, the block is obtained
The business datum stored in chain carries out more business datum corresponding in the service database using the business datum
It is new to restore.The step can ensure that all users for issuing read requests, can obtain really counting always when accessing data
According to.In addition, the data recovery procedure and result in the step will all be recorded into an audit log, to facilitate administrative staff to look into
It askes.
In one embodiment, more specific business datum reads flow chart, as shown in Figure 3, comprising the following steps:
S21 receives a data read request;
S22 obtains business datum according to the data read request from service database, determines the business number obtained
According to affiliated data segment;
S23 calculates the second hash value of the data segment;
S24 obtains the first hash value of the affiliated data segment of the business datum from block chain;
S25, compares the first hash value and the second hash value returns the business datum of reading if two hash values are consistent
Echo is shown;If two hash values are inconsistent, the business datum stored in block chain is obtained, using the business datum to business
Corresponding business datum is updated recovery in database.
In one embodiment, this method further includes poll testing mechanism, can according to default poll detection cycle, every
Preset time period calculates the third hash value of the affiliated data segment of business datum described in the service database, and by the third
First hash value stored in hash value and the block chain is compared;The first hash value and third hash value not
When consistent, the business datum stored in the block chain is obtained, using the business datum to phase in the service database
The business datum answered is updated recovery.In specific operating process, the predetermined period and preset time period can roots
It is set according to different demands, the disclosure is without limitation.Meanwhile the triggering and inspection of poll detection are different to data
Content, the result of recovery often restored are recorded into an audit log, to facilitate administrative staff to inquire.
In one embodiment, more specific business datum poll overhaul flow chart, as shown in figure 4, including following step
It is rapid:
S31 judges whether to preset poll detection cycle, returns if not arriving and judge again;Enter step if reaching
Rapid S32;
S32 extracts business datum in service database, determines the data segment belonging to it;
S33 judges that the data segment whether there is, then terminates if it does not exist;If it exists, then S34 is entered step;
S34 calculates the third hash value of the data segment, and first will stored in the third hash value and block chain
Hash value is compared;
S35 judges whether the first hash value is consistent with third hash value, terminates if consistent;If inconsistent, obtain
The business datum stored in block chain is updated business datum corresponding in service database using the business datum extensive
It is multiple.
It should be noted that although describing each step of method in the disclosure in the accompanying drawings with particular order,
It is that this does not require that or implies must execute these steps in this particular order, or have to carry out shown in whole
Step is just able to achieve desired result.Additional or alternative, it is convenient to omit multiple steps are merged into one by certain steps
Step executes, and/or a step is decomposed into execution of multiple steps etc..In addition, being also easy to understand, these steps
Suddenly it can be and for example either synchronously or asynchronously executed in multiple module/process/threads.
Further, in this example embodiment, a kind of anti-tamper system of data based on block chain technology is additionally provided
System.With reference to shown in Fig. 5, system 400 may include data receipt unit 401, data storage cell 402 and data check list
Member 403.Wherein:
Data receipt unit 401, for receiving a data write request and a business datum, according to default mapping table
It determines data segment belonging to the business datum, and calculates the first hash value of the data segment;
Data storage cell 402, for storing the business datum and the first hash value cochain to a block
In chain, the business datum is written by a service database according to the data write request later;
Data check unit 403, for receiving a data read request, according to the data read request from the business
Database obtains the business datum, determines data segment belonging to the business datum obtained, calculates the 2nd Hash of the data segment
Value;The first hash value is obtained from the block chain, compares first hash value and the second hash value, will be read if consistent
The business datum taken returns to display.
About the system in above-described embodiment, wherein each unit executes the concrete mode of operation in the related party
It is described in detail in the embodiment of method, no detailed explanation will be given here.
It should be noted that although being referred to several units for acting the system executed in the above detailed description,
This division is not enforceable.In fact, according to embodiment of the present disclosure, two or more above-described modules or
The feature and function of person's unit can embody in a unit.Conversely, the feature and function of an above-described unit
It can be to be embodied by multiple units with further division.Component shown as a unit may or may not be object
Manage unit, it can it is in one place, or may be distributed over multiple network units.It can be according to the actual needs
Some or all of unit therein is selected to realize the purpose of the open scheme of wood.Those of ordinary skill in the art are not paying
In the case where creative work, it can understand and implement.
In an exemplary embodiment of the disclosure, a kind of computer readable storage medium is additionally provided, meter is stored thereon with
Calculation machine program, the program may be implemented one kind described in any one above-mentioned embodiment and be based on area when being executed by such as processor
The step of data tamper resistant method of block chain technology.In some possible embodiments, various aspects of the invention can be with
It is embodied as a kind of form of program product comprising program code, when described program product is run on the terminal device, institute
It is anti-tamper for making the terminal device execute a kind of above-mentioned data based on block chain technology of this specification to state program code
Described in method part according to the present invention various illustrative embodiments the step of.
Refering to what is shown in Fig. 6, describing the program product for realizing the above method of embodiment according to the present invention
500, can using portable compact disc read only memory (CD-ROM) and including program code, and can in terminal device,
Such as it is run on PC.However, program product of the invention is without being limited thereto, in this document, readable storage medium storing program for executing can be with
To be any include or the tangible medium of storage program, the program can be commanded execution system, device or device use or
It is in connection.
Described program product can be using any combination of one or more readable mediums.Readable medium can be readable
Signal media or readable storage medium storing program for executing.Readable storage medium storing program for executing for example can be but be not limited to electricity, magnetic, optical, electromagnetic, infrared ray,
Or system, device or the device of semiconductor, or any above combination.The more specific example of readable storage medium storing program for executing is (non-poor
The list of act) include: electrical connection with one or more conducting wires, portable disc, hard disk, random access memory (RAM),
Read-only memory (ROM), erasable programmable read only memory (EPROM or flash memory), optical fiber, portable compact disc is read-only deposits
Reservoir (CD-ROM), light storage device, magnetic memory device or above-mentioned any appropriate combination.
The computer readable storage medium may include in a base band or the data as the propagation of carrier wave a part are believed
Number, wherein carrying readable program code.The data-signal of this propagation can take various forms, including but not limited to electric
Magnetic signal, optical signal or above-mentioned any appropriate combination.Readable storage medium storing program for executing can also be appointing other than readable storage medium storing program for executing
What readable medium, the readable medium can be sent, propagated or transmitted for being made by instruction execution system, device or device
With or program in connection.The program code for including on readable storage medium storing program for executing can pass with any suitable medium
It is defeated, including but not limited to wirelessly, wired, optical cable, RF etc. or above-mentioned any appropriate combination.
The program for executing operation of the present invention can be write with any combination of one or more programming languages
Code, described program design language include object oriented program language-Java, C++ etc., further include conventional
Procedural programming language-such as " C " language or similar programming language.Program code can be fully in user
It calculates and executes in equipment, partly executes on a user device, being executed as an independent software package, partially in user's meter
Upper side point is calculated to execute or execute in remote computing device or server completely on a remote computing.It is relating to
And in the situation of remote computing device, remote computing device can by the network of any kind, including local area network (LAN) or
Wide area network (WAN), is connected to user calculating equipment, or, it may be connected to external computing device (such as taken using internet
Provider be engaged in connect by internet).
In an exemplary embodiment of the disclosure, a kind of electronic equipment is also provided, which may include processing
Device, and the memory of the executable instruction for storing the processor.Wherein, the processor is configured to via execution
The executable instruction executes a kind of anti-tamper side of data based on block chain technology described in any one above-mentioned embodiment
The step of method.
Person of ordinary skill in the field it is understood that various aspects of the invention can be implemented as system, method or
Program product.Therefore, various aspects of the invention can be embodied in the following forms,
The electronic equipment 600 of this embodiment according to the present invention is described referring to Fig. 7.The electronics that Fig. 7 is shown
Equipment 600 is only an example, should not function to the embodiment of the present invention and use scope bring any restrictions.
As shown in fig. 7, electronic equipment 600 is showed in the form of universal computing device.The component of electronic equipment 600 can be with
Including but not limited to: at least one processing unit 610, at least one storage unit 620, the different system components of connection (including are deposited
Storage unit 620 and processing unit 610) bus 630, display unit 640 etc..
Wherein, the storage unit is stored with program code, and said program code can be held by the processing unit 610
Row, so that the processing unit 610 executes a kind of above-mentioned data tamper resistant method part based on block chain technology of this specification
Described according to the present invention various illustrative embodiments the step of.For example, the processing unit 610 can be executed such as Fig. 1
Shown in step.
The storage unit 620 may include the readable medium of volatile memory cell form, such as random access memory
Unit (RAM) 6201 and/or cache memory unit 6202 can further include read-only memory unit (ROM)
6203。
The storage unit 620 can also include program/practical work with one group of (at least one) program module 6205
Tool 6204, such program module 6205 includes but is not limited to: operating system, one or more application program, other programs
It may include the realization of network environment in module and program data, each of these examples or certain combination.
Bus 630 can be to indicate one of a few class bus structures or a variety of, including storage unit bus or storage
Cell controller, peripheral bus, graphics acceleration port, processing unit use any total knot in a variety of bus structures
The local bus of structure.
Electronic equipment 600 can also be with one or more external equipments 700 (such as keyboard, sensing equipment, bluetooth equipment
Deng) communication, can also be enabled a user to one or more equipment interact with the electronic equipment 600 communicate, and/or with make
The electronic equipment 600 can with it is one or more of the other calculating equipment be communicated any equipment (such as router, modulation
Demodulator etc.) communication.This communication can be carried out by input/output (I/O) interface 650.Also, electronic equipment 600 is also
Network adapter 660 and one or more network (such as local area network (LAN), wide area network (WAN) and/or public can be passed through
Network, such as internet) communication.Network adapter 660 can be logical by bus 630 and other modules of electronic equipment 600
Letter.It should be understood that although not shown in the drawings, can in conjunction with electronic equipment 600 use other hardware and/or software module, including
But it is not limited to: microcode, device driver, redundant processing unit, external disk drive array, RAID system, magnetic tape drive
Device and data backup storage system etc..
Through the above description of the embodiments, those skilled in the art is it can be readily appreciated that example described herein is implemented
Mode can also be realized by software realization in such a way that software is in conjunction with necessary hardware.Therefore, according to this public affairs
The technical solution for opening embodiment can be embodied in the form of software products, which can store non-at one
In volatile storage medium (can be CD-ROM, USB flash disk, mobile hard disk etc.) or on network, including some instructions are so that one
Platform calculates equipment (can be personal computer, server or network equipment etc.) and executes according to the upper of disclosure embodiment
State a kind of data tamper resistant method based on block chain technology.
Those skilled in the art after considering the specification and implementing the invention disclosed here, will readily occur to the disclosure
Other embodiments.This application is intended to cover any variations, uses, or adaptations of the disclosure, these modifications, purposes
Or adaptive change follow the general principles of this disclosure and including the disclosure it is undocumented in the art known in often
Knowledge or conventional techniques.The description and examples are only to be considered as illustrative, and the true scope and spirit of the disclosure are by appended
Claim point out.