CN110222067B - Method and system for anchoring trusted external database by block chain intelligent contract - Google Patents

Method and system for anchoring trusted external database by block chain intelligent contract Download PDF

Info

Publication number
CN110222067B
CN110222067B CN201910473107.0A CN201910473107A CN110222067B CN 110222067 B CN110222067 B CN 110222067B CN 201910473107 A CN201910473107 A CN 201910473107A CN 110222067 B CN110222067 B CN 110222067B
Authority
CN
China
Prior art keywords
intelligent contract
data
external database
chain
hash
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910473107.0A
Other languages
Chinese (zh)
Other versions
CN110222067A (en
Inventor
朱益祺
张成成
阳胜
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Timestamp Information Technology Co ltd
Original Assignee
Hangzhou Timestamp Information Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Timestamp Information Technology Co ltd filed Critical Hangzhou Timestamp Information Technology Co ltd
Priority to CN201910473107.0A priority Critical patent/CN110222067B/en
Publication of CN110222067A publication Critical patent/CN110222067A/en
Application granted granted Critical
Publication of CN110222067B publication Critical patent/CN110222067B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • Computing Systems (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Strategic Management (AREA)
  • Technology Law (AREA)
  • General Business, Economics & Management (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The invention discloses a method and a system for anchoring a trusted external database by a block chain intelligent contract, which comprises the following steps: stripping the data of the intelligent contract from the storage space of the intelligent contract and storing the data in a database under any type of chains; adding a fixed-length hash to represent the root hash of a tachr tree of an external database under a chain mapped by the intelligent contract in a continuous storage layer of the intelligent contract; if data needs to be inserted into the intelligent contract or data needs to be deleted or called from the intelligent contract, the invention utilizes the data structure of the Mercker tree to compress an infinite data set into the Hash with a certain length to optimize virtual space for continuous storage of the intelligent contract, ensures that the verification expense of the intelligent contract is always kept in a reasonable range by utilizing the characteristics of the balance tree in the process of adding, deleting and modifying external data, and fully utilizes the CPU resources of the block chain nodes in the reasonable range to replace the trusted lower-chain storage resources which are almost without the upper limit.

Description

Method and system for anchoring trusted external database by block chain intelligent contract
Technical Field
The invention belongs to the technical field of block chains, and particularly relates to a method and a system for anchoring a trusted external database by an intelligent contract of a block chain.
Background
The block chain technology is a decentralized distributed database technology, has the characteristics of decentralized, public transparency, no tampering, trustiness and the like, and is suitable for application scenes with high requirements on data reliability.
The intelligent contract is a script executed at the upper layer of a block chain and has the characteristics of complete graphics and high plasticity. The user can realize complex business logic in a mode of intelligent contracts, and the business mode which can be completed only by multi-party trust is changed into a mode without trust by submitting the intelligent contracts to a mode managed by a block chain bottom layer.
The precondition for the intelligent contract to achieve unnecessary trust is to store data related to the contract on the blockchain, so that the contract data cannot be tampered. However, the nature of the blockchain being a decentralized database makes it difficult to store a large amount of data for a single application as with a conventional database, thereby limiting the difficulty in carrying large applications with large amounts of data.
The intelligent contract at the present stage supports the operation of the intelligent contract by storing data sustainably on the KV memory space of the intelligent contract, and the upper limit of the KV memory space of the intelligent contract limits the depth of the intelligent contract which can process the data.
Disclosure of Invention
In order to solve the problems, the invention provides a method for anchoring a trusted external database by a block chain intelligent contract, which uses a block chain node CPU resource to replace a trusted downlink storage resource.
The technical scheme of the invention is as follows: a method for blockchain intelligent contract anchoring of trusted external databases, comprising the steps of:
s1: linking the intelligent contract, stripping the data of the intelligent contract from the storage space of the intelligent contract, and storing the data in a database under any type of chains to obtain an external database under the chains;
s2: when the initialization of the intelligent contract is completed, adding a fixed-length Hash to represent the root Hash of the tacher tree of the external database under the chain mapped by the intelligent contract in the continuous storage layer of the intelligent contract;
s3: if data needs to be inserted into the intelligent contract or data needs to be deleted from the intelligent contract, after the data needing to be inserted is inserted into the external database under the chain or the data needing to be deleted is deleted, calculating the merkel tree existence certification and the root hash of the external database under the chain, converting the structural change of the merkel tree into the transaction of the block chain for uplink, and after the intelligent contract detects the uplink of the database information related to the intelligent contract, updating the hash of the contract according to the uplink transaction;
if the intelligent contract needs to use data in a certain existing external database under the chain, providing the hash of the native data of the data and the sibling node generating the current Mercker tree, and calling the data proved by the existence of the Mercker tree.
In the invention, on the aspect of the intelligent contract, an external data verification module is added to the intelligent contract to ensure that the intelligent contract can not process the incredible external data. The core function of the data verification module is to map one state of an external large number of data sets using limited storage resources and to provide three support functions for intelligent contracts: firstly, when new data is inserted into an external database of the intelligent contract, updating a mapping state to ensure the synchronization of a data verification module and a linked database; secondly, verifying the authenticity of the data when the intelligent contract calls the external data set; and thirdly, when the data is deleted from the external database, updating a mapping state to ensure the synchronization of the data verification module and the linked external database.
Through the three functions, the data verification module becomes a middle key for communicating the intelligent contract on the chain and the external database under the chain, the consistency of the external storage state of the intelligent contract and the storage data of the external database under the chain is ensured, and any external database can be called without trust.
Preferably, in step S2, an infinite data set in the off-chain external database is mapped with a fixed-length byte, each piece of data in the off-chain external database is compressed into a fixed-length byte through a hash algorithm, all hashes are combined into a binary tree structure, all hashes are compressed into a root hash through a collection mode of the merkel tree data structure, and the compressed root hash is stored in the data verification layer in the on-chain intelligent contract to map the off-chain external database. When the first initialization of the intelligent contract is completed, the hash is set to 64 null bytes to indicate that the database is empty. When data is inserted or deleted, the intelligent contract can use hash verification with controllable quantity to ensure the correctness of the information because the Mercker tree path change containing the state change of the whole database exists in the uplink transaction of the data insertion information or the data deletion information. And when detecting that the corresponding transaction occurs, the intelligent contract verifies the validity of the deletion through the path change verification of the Mercker tree. When data in some pre-existing external database needs to be used in an intelligent contract, the native data of the data needs to be provided and hashed with the sibling node generating the current-year Mercker tree. Data that is proven to exist through the merkel tree may then be invoked in the contract.
Preferably, in step S2, adding a hash of 64 dummy bytes represents the root hash of the merck tree of the external database under the chain of the intelligent contract mapping.
The invention also provides a system for anchoring the trusted external database by the intelligent contract of the block chain, which comprises the following steps:
the downlink external database is used for storing data stripped from the storage space of the intelligent contract;
and the on-chain intelligent contract data verification module is used for communicating the on-chain intelligent contract with the intermediate key of the off-chain external database, so that the external storage state of the intelligent contract is ensured to be consistent with the storage data of the off-chain external database, and any external database can be called without trust.
Preferably, the intelligent contract data verification module on the chain maps infinite data sets in the external database under the chain by using a byte with a fixed length, each piece of data of the external database under the chain is compressed into a byte with a fixed length by a hash algorithm, all hashes form a binary tree structure, all hashes are compressed into root hashes by a collection mode of a merkel tree data structure, and the root hashes obtained by compression are stored in the intelligent contract data verification module on the chain to map the external database under the chain.
Compared with the prior art, the invention has the beneficial effects that:
the invention utilizes the data structure of the Mercker tree to compress an infinite data set into the Hash with a certain length to optimize the virtual space of the continuous storage of the intelligent contract, ensures that the verification expense of the intelligent contract is always kept in a reasonable range by utilizing the characteristic of the balanced tree in the process of adding, deleting and modifying and checking external data, and fully utilizes the CPU resource of the block chain node in the reasonable range to exchange for the trusted chain lower storage resource with almost no upper limit.
Drawings
FIG. 1 is an initialization flowchart of a method for intelligent contract anchoring a trusted external database according to the present invention.
FIG. 2 is a flow chart of data update (insert, delete) of the intelligent contract anchoring trusted external database method of the present invention.
FIG. 3 is a flow chart of a data called process of the intelligent contract anchoring trusted external database method of the present invention.
Detailed Description
Example 1 (insert data)
As shown in fig. 1 and 2, a method for anchoring a trusted external database by a blockchain intelligent contract comprises the following steps:
s1: initializing and compiling an intelligent contract, linking the intelligent contract, stripping data of the intelligent contract from a storage space of the intelligent contract, storing the data in a database under any type of chains to obtain an external database under the chains, and initializing the external database under the chains;
s2: initializing an intelligent contract data verification module on a chain, and when the intelligent contract is initialized, adding a 64-byte hash representing the root hash of a tacer tree of an external database under the chain mapped by the intelligent contract in a continuous storage layer of the intelligent contract;
s3: when data is inserted into the intelligent contract, after the data required to be inserted is inserted into the external database under the chain, the merkel tree existence certification and the root hash of the external database under the chain are calculated, the structural change of the merkel tree is converted into the block chain transaction for uplink, and after the intelligent contract detects the uplink of the database information related to the intelligent contract, the hash of the contract is updated according to the uplink transaction.
Example 2 (delete data)
As shown in fig. 1 and 2, a method for anchoring a trusted external database by a blockchain intelligent contract comprises the following steps:
s1: initializing and compiling an intelligent contract, linking the intelligent contract, stripping data of the intelligent contract from a storage space of the intelligent contract, storing the data in a database under any type of chains to obtain an external database under the chains, and initializing the external database under the chains;
s2: initializing an intelligent contract data verification module on a chain, and when the intelligent contract is initialized, adding a 64-byte hash representing the root hash of a tacer tree of an external database under the chain mapped by the intelligent contract in a continuous storage layer of the intelligent contract;
s3: when data needs to be deleted from the intelligent contract, after the data needing to be deleted is deleted from the external database under the chain, the merkel tree existence certification and the root hash of the external database under the chain are calculated, the structural change of the merkel tree is converted into the block chain transaction for uplink, and after the intelligent contract detects the information of the database relevant to the intelligent contract and the uplink, the hash of the contract is updated according to the uplink transaction.
Example 3 (Call data)
As shown in fig. 1 and 3, a method for anchoring a trusted external database by a blockchain intelligent contract comprises the following steps:
s1: initializing and compiling an intelligent contract, linking the intelligent contract, stripping data of the intelligent contract from a storage space of the intelligent contract, storing the data in a database under any type of chains to obtain an external database under the chains, and initializing the external database under the chains;
s2: initializing an intelligent contract data verification module on a chain, and when the intelligent contract is initialized, adding a 64-byte hash representing the root hash of a tacer tree of an external database under the chain mapped by the intelligent contract in a continuous storage layer of the intelligent contract;
s3: when data in an external database existing under a chain needs to be used in the intelligent contract, the native data of the data is provided and hashed with the sibling node generating the current Mercker tree, and the data proved by the existence of the Mercker tree can be called.

Claims (5)

1. A method for anchoring a trusted external database by a blockchain intelligent contract, comprising the steps of:
s1: linking the intelligent contract, stripping the data of the intelligent contract after the intelligent contract is linked from the storage space of the intelligent contract, and storing the data in a database under any type of chains to obtain an external database under the chains;
s2: when the initialization of the intelligent contract is completed, adding a fixed-length Hash to represent the root Hash of the tacher tree of the external database under the chain mapped by the intelligent contract in the continuous storage layer of the intelligent contract;
s3: if data needs to be inserted into the intelligent contract or data needs to be deleted from the intelligent contract, after the data needing to be inserted is inserted into the external database under the chain or the data needing to be deleted is deleted, calculating the merkel tree existence certification and the root hash of the external database under the chain, converting the structural change of the merkel tree into the transaction of the block chain for uplink, and after the intelligent contract detects the uplink of the database information related to the intelligent contract, updating the hash of the contract according to the uplink transaction;
if the intelligent contract needs to use data in a certain existing external database under the chain, providing the hash of the native data of the data and the sibling node generating the current Mercker tree, and calling the data proved by the existence of the Mercker tree.
2. The method for anchoring the trusted external database by the blockchain intelligent contract according to claim 1, wherein in step S2, an infinite data set in the chained external database is mapped by a fixed-length byte, each piece of data in the chained external database is compressed into a fixed-length byte by a hash algorithm, all hashes are combined into a binary tree structure, all hashes are compressed into a root hash by a collection mode of the merkel tree data structure, and the compressed root hash is stored in a data verification layer in the chained intelligent contract to map the chained external database.
3. The method for blockchain intelligent contract anchoring a trusted external database according to claim 1 or 2, wherein in step S2, adding a hash of 64 null bytes represents the root hash of the mercker tree of the external database under the chain to which the intelligent contract maps.
4. A system for block chain intelligent contract anchoring a trusted external database, comprising:
the downlink external database is used for storing data stripped from the storage space of the intelligent contract;
and the on-chain intelligent contract data verification module is used for communicating the on-chain intelligent contract with an intermediate key of the off-chain external database, so that the external storage state of the intelligent contract is ensured to be consistent with the storage data of the external database, and any external database can be called without trust.
5. The system for blockchain intelligent contract anchoring a trusted external database as claimed in claim 4, wherein the on-chain intelligent contract data verification module maps an infinite data set in the off-chain external database with a fixed-length byte, each piece of data of the off-chain external database is compressed into a fixed-length byte through a hash algorithm, all hashes are combined into a binary tree structure, all hashes are compressed into a root hash through a collection mode of the mercker tree data structure, and the compressed root hash is stored in the on-chain intelligent contract data verification module to map the off-chain external database.
CN201910473107.0A 2019-05-31 2019-05-31 Method and system for anchoring trusted external database by block chain intelligent contract Active CN110222067B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910473107.0A CN110222067B (en) 2019-05-31 2019-05-31 Method and system for anchoring trusted external database by block chain intelligent contract

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910473107.0A CN110222067B (en) 2019-05-31 2019-05-31 Method and system for anchoring trusted external database by block chain intelligent contract

Publications (2)

Publication Number Publication Date
CN110222067A CN110222067A (en) 2019-09-10
CN110222067B true CN110222067B (en) 2021-04-30

Family

ID=67819369

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910473107.0A Active CN110222067B (en) 2019-05-31 2019-05-31 Method and system for anchoring trusted external database by block chain intelligent contract

Country Status (1)

Country Link
CN (1) CN110222067B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111222160B (en) * 2019-12-30 2022-07-29 联动优势科技有限公司 Intelligent contract execution method and system
CN111552738B (en) * 2020-04-20 2023-11-03 山东共智云科技发展有限公司 Block chain ecological system and block chain uplink method based on Internet of things
CN112417055B (en) * 2020-12-10 2024-04-26 孔令超 Method for mapping blockchain intelligent contracts to real contracts
CN112667675B (en) * 2021-03-17 2021-06-01 杭州趣链科技有限公司 Data checking method, electronic device and storage medium

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180123779A1 (en) * 2016-11-01 2018-05-03 Jiangang Zhang Flexible Blockchain Smart-Contract Deployment
CN107464118A (en) * 2017-08-16 2017-12-12 济南浪潮高新科技投资发展有限公司 A kind of data trade method based on block chain intelligence contract
CN109284197B (en) * 2018-10-25 2024-02-23 中思博安科技(北京)有限公司 Distributed application platform based on intelligent contract and implementation method

Also Published As

Publication number Publication date
CN110222067A (en) 2019-09-10

Similar Documents

Publication Publication Date Title
CN110222067B (en) Method and system for anchoring trusted external database by block chain intelligent contract
CN113329031A (en) Method and device for generating state tree of block
CN110599169B (en) Data processing method, device, terminal and medium
CN112257118B (en) Method and system for locking cross-fragment transactions in a blockchain system containing fragments
US10489117B2 (en) Method and apparatus for generating random character string
CN111221780B (en) Server file safe storage method based on block chain
CN110941676A (en) Configuration method, device, equipment and medium
CN112765270B (en) Block chain data processing method and device, computer equipment and medium
CN110955658B (en) Data organization and storage method based on Java intelligent contract
US20210342334A1 (en) Method, device, and computer program product for data management
CN112511629B (en) Data compression method and system for account tree of MPT structure
CN115687474A (en) Cross-chain verification system for PoW block chain
CN112269423B (en) Method for locking global clock in blockchain system and blockchain system
CN112287032B (en) Block chain data storage method and device and block chain link points
CN116303425A (en) Method for creating account in block chain and block chain link point
CN112261161B (en) Method for locking partitioned blocks in block chain system and block chain system
CN113254537A (en) Block chain state storage and reading method and block chain link point
US20160299820A1 (en) Processing method, device and system for data of distributed storage system
CN107609423A (en) File system integrity remote certification method based on state
CN117421369A (en) Block chain-based data processing method, device, equipment and readable storage medium
CN101997864A (en) System architecture for realizing electronic document packaging and constructing method thereof
CN117390117A (en) Block chain-based data processing method, device, equipment and readable storage medium
CN116226129A (en) Data access method, device, storage medium and equipment in intelligent contract
CN115314215A (en) User data integrity verification method based on Ether house intelligent contract
KR20220136628A (en) Method And System for Generating Blockchain Database

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant