CN116388990A - Intelligent contract system of block chain - Google Patents

Intelligent contract system of block chain Download PDF

Info

Publication number
CN116388990A
CN116388990A CN202211699114.0A CN202211699114A CN116388990A CN 116388990 A CN116388990 A CN 116388990A CN 202211699114 A CN202211699114 A CN 202211699114A CN 116388990 A CN116388990 A CN 116388990A
Authority
CN
China
Prior art keywords
blockchain
intelligent contract
contract
block
transaction
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.)
Pending
Application number
CN202211699114.0A
Other languages
Chinese (zh)
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.)
Huaneng Energy Transportation Industry Holding Co ltd
Shanghai Huaneng E Commerce Co ltd
Original Assignee
Huaneng Energy Transportation Industry Holding Co ltd
Shanghai Huaneng E Commerce 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 Huaneng Energy Transportation Industry Holding Co ltd, Shanghai Huaneng E Commerce Co ltd filed Critical Huaneng Energy Transportation Industry Holding Co ltd
Priority to CN202211699114.0A priority Critical patent/CN116388990A/en
Publication of CN116388990A publication Critical patent/CN116388990A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3247Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials involving digital signatures
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/06Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols the encryption apparatus using shift registers or memories for block-wise or stream coding, e.g. DES systems or RC4; Hash functions; Pseudorandom sequence generators
    • H04L9/0643Hash functions, e.g. MD5, SHA, HMAC or f9 MAC
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3236Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The invention provides an intelligent contract system of a blockchain, which can recover the intelligent contract system in case of hackers or faults by setting a tamper and migration system of the intelligent contract, prevent or filter the operation of an attacker, pause the contract first, be more transparent to users, prevent the hackers from attacking the users who do not understand migration, then calculate the memory offset of variables, and then search or scan the blockchain and search a holder by self by using a getStorageAt function; the method can rely on Google BigTable archiving disclosed by an Ethernet blockchain to restore intelligent contract data, and finally, a new intelligent contract system is constructed by setting values through a constructor of the intelligent contract.

Description

Intelligent contract system of block chain
Technical Field
The invention relates to the field of intelligent contract correlation, in particular to an intelligent contract system of a blockchain.
Background
The idea of smart contracts can be traced back to 1995, almost simultaneously with the internet, as the bit coin lays the foundation and the widely praised cryptist nike sabot first proposes the term "smart contracts", which essentially operate on principles similar to the i f-then statement of other computer programs, the smart contracts only interacting with real world assets in this way, the smart contracts executing corresponding contract terms when a pre-programmed condition is triggered.
However, when the intelligent contract is used with the blockchain, the intelligent contract is easy to attack, namely, the bug existing on the contract, the loophole of the wallet of the user or negligence on the setting can cause the attack, and the normal use of the user is affected.
Disclosure of Invention
In order to solve the above technical problems, an object of the present invention is to provide an intelligent contract system for a blockchain.
Based on the above, the invention provides an intelligent contract system of a block chain, wherein the intelligent contract system of the block chain is constructed and executed as follows:
step S1: the multiparty users participate in the appointed intelligent contract system together;
step S2: contracts are spread through the P2P network and stored in the blockchain;
step S3: an intelligent contract automatic execution system constructed by a block chain;
step S4: a tamper and migration system for smart contracts.
Optionally, step S1.1: firstly, a user must register the user becoming a blockchain, the blockchain returns a pair of public keys and private keys to the user, the public keys are used as account addresses of the user on the blockchain, and the private keys are used as unique keys for operating the account;
step S1.2: two or more users agree on a commitment together as needed, the commitment including rights and obligations of both parties, the rights and obligations programming the machine language in an electronic manner; the participants sign with the private keys respectively; to ensure validity of the contract;
step S1.3: the signed intelligent contract is transmitted into the blockchain network according to the promised content.
Optionally, step S2.1: the contracts are diffused in the whole block chain network in a P2P mode, each node receives one contract, a verification node in the block chain stores the received contracts in a memory first, waits for the new consensus time and triggers the consensus and processing of the contracts;
step S2.1: when the consensus time is up, the verification node packages all contracts stored in the last period of time together into a contract set (set), calculates the Hash value of the contract set, finally assembles the Hash value of the contract set into a block structure, diffuses the block structure to the whole network, and after receiving the block structure, other verification nodes can take out the Hash of the contract set contained therein and compare the Hash with the contract set stored by the verification node; simultaneously sending a contract set approved by the user to other verification nodes; through such multiple rounds of transmission and comparison; all verification nodes finally agree on the latest contract set in a specified time;
step S2.1: the newly agreed contract set is spread over the whole network in the form of blocks.
Optionally, step S3.1: the intelligent contracts can periodically check the state of the automaton, traverse the state machine, the transaction and the triggering condition contained in each contract one by one, push the transaction meeting the condition into a queue to be verified, and wait for consensus; transactions that do not meet the trigger condition will continue to be deposited on the blockchain;
step S3.2: the transaction entering the latest round of verification is diffused to each verification node, and the verification nodes firstly perform signature verification as common blockchain transactions or transactions, so that the validity of the transaction is ensured, the verified transaction enters a set to be agreed, and after most verification nodes reach agreement, the transaction is successfully executed and a user is notified;
step S3.3: after the transaction is successfully executed, the state opportunity of the intelligent contract is carried by the intelligent contract to judge the state of the contract.
Optionally, step S3.31: when all transactions included in the contract have been sequentially executed, the state opportunity marks the state of the contract as complete and removes the contract from the latest block;
step S3.32: otherwise, the processing is marked as in progress, the processing is continuously stored in the latest block to wait for the next round of processing until the processing is finished, and the whole transaction and the processing of the state are automatically completed by an intelligent contract system built in the bottom layer of the block chain, so that the whole process is transparent and can not be clenched.
Optionally, step S4.1: restoring the data to be migrated;
step S4.2: writing data to the new contract.
Optionally, step S4.11: the method has the advantages that data needs to be read from a specific block in the blockchain, if the data is recovered from an event (a hacker or a fault), and before the event occurs, the contract is paused first by preventing or filtering the operation of an attacker, so that the method is more transparent to the user, and the user who cannot understand migration is prevented from being attacked by the hacker;
step S4.12: for private variables, events can be relied on, memory offset of the variables can be calculated, and then the getStorageAt function is used for searching, so that the array is easy to recover because the number of elements is known;
step S4.13: for the mapping case, the mapped keys are not stored, to simplify offline tracking, the blockchain is scanned and the holder is retrieved by itself; googl e BigTab l e archiving, which may rely on ethernet blockchain disclosure, may use the google e BigQuery API if there is no synchronized blockchain, bigQuery provides access to block numbers, so this query may be adjusted to return transactions to a particular block;
step S4.14: restoring the addresses of all holders, the bal and anceOf function may be queried offline to restore the balance associated with each holder.
Optionally, step S4.21: simple variables, values can be set by the constructors of the smart contracts;
step S4.22: if the data cannot be kept in a single piece, each transaction is contained in a block that limits the total Gas that can be used for its transaction (the so-called "Gas Limit"), and if the Gas cost of the transaction approaches or exceeds this Limit, the miners will not be packaged any more. To migrate large amounts of data, the migration must be split into multiple tasks;
step S4.23: the initialization state is added in the intelligent contract, only the owner can change the state variable, and the user cannot execute any operation to construct a new intelligent contract system.
The invention has the following advantages: the present invention provides a blockchain intelligent contract system by improving the system, which has the following improvements compared with the same type of equipment:
the invention provides an intelligent contract system of a blockchain, which can recover the intelligent contract system in case of hackers or faults through setting a tamper and migration system of the intelligent contract, prevent or filter the operation of an attacker, pause the contract first, be more transparent to users, prevent the hackers from attacking the users who cannot understand migration, then calculate the memory offset of variables, and then search or scan the blockchain by using a getStorageAt function and search a holder by oneself; the method can rely on Goog l e BigTab l e archiving disclosed by an Ethernet blockchain to recover the intelligent contract data, and finally, a new intelligent contract system is constructed by setting values through the constructors of the intelligent contracts.
Drawings
FIG. 1 is a schematic diagram of the construction and execution of the present invention;
FIG. 2 is a flow chart of a specified smart contract of the present invention;
FIG. 3 is a block chain flow diagram of a contract store in accordance with the present invention;
FIG. 4 is a flowchart of the automatic execution of contracts according to the present invention;
FIG. 5 is a diagram of Hash values according to the present invention;
FIG. 6 is a flow chart of a tamper and migration system of the smart contract of the present invention;
FIG. 7 is a flow chart of the present invention for restoring data to be migrated;
FIG. 8 is a flow chart of the new contract for writing data in accordance with the present invention.
Detailed Description
In the description of the present invention, it should be noted that the terms "center", "longitudinal", "lateral", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", etc. indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings, are merely for convenience in describing the present invention and simplifying the description, and do not indicate or imply that the apparatus or elements referred to must have a specific orientation, be configured and operated in a specific orientation, and thus should not be construed as limiting the present invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance.
In the description of the present invention, it should be noted that, unless explicitly specified and limited otherwise, the terms "mounted," "connected," and "connected" are to be construed broadly, and may be either fixedly connected, detachably connected, or integrally connected, for example; can be mechanically or electrically connected; can be directly connected or indirectly connected through an intermediate medium, and can be communication between two elements. The specific meaning of the above terms in the present invention will be understood in specific cases by those of ordinary skill in the art.
Furthermore, in the description of the present invention, unless otherwise indicated, the meaning of "a plurality" is two or more.
The specific meaning of the above terms in the present invention will be understood in specific cases by those of ordinary skill in the art.
The following describes in further detail the embodiments of the present invention with reference to the drawings and examples. The following examples are illustrative of the invention and are not intended to limit the scope of the invention.
Referring to fig. 1-8, the present embodiment provides a blockchain intelligent contract system, firstly, constructing the blockchain intelligent contract system, constructing a multiparty user to participate in the appointed intelligent contract system, firstly, the user must register to become the blockchain user, the blockchain returns to a pair of public key and private key of the user, the public key is used as the account address of the user on the blockchain, the private key is used as the unique key for operating the account, two or more users agree on a commitment together according to the need, the commitment includes rights and obligations of both sides, and the rights and obligations program the machine language in an electronic manner; the participants sign with the private keys respectively; to ensure the validity of the contract, the signed intelligent contract is transmitted into the blockchain network according to the promised content;
then, contracts are diffused through a P2P network and stored in a blockchain, each node receives one contract, a verification node in the blockchain stores the received contracts in a memory first, waits for the consensus time of a new round, and triggers the consensus and processing of the contracts; when the consensus time is reached, the verification node packages all contracts stored in the last period of time together into a contract set (set), calculates the Hash value of the contract set, and finally assembles the Hash value of the contract set into a block structure, and spreads the block structure to the whole network, as shown in fig. 5, each block contains the following information: the Hash value of the current block, the Hash value of the previous block, the timestamp when consensus is reached, and other descriptive information; meanwhile, the most important information of the blockchain is a set of consensus-reached set; each contract is verified after the nodes receiving the contract set, the contracts passing through verification are written back into the block chain finally, the verification content is mainly whether the private key signature of the contract participant is matched with an account, and after other verification nodes receive the block structure, the Hash of the contract set contained in the block structure is taken out and compared with the contract set stored by the nodes; simultaneously sending a contract set approved by the user to other verification nodes; through such multiple rounds of transmission and comparison; all verification nodes finally agree on the latest contract set in a specified time;
then constructing an intelligent contract automatic execution system constructed by a block chain, then signing contracts on line by a user through the block chain, periodically checking the state of an automaton by the intelligent contract, traversing state machines, transactions and triggering conditions contained in each contract one by one, pushing the transactions meeting the conditions into a queue to be verified, and waiting for consensus; transactions which do not meet the triggering condition are stored on the blockchain continuously, the transactions entering the latest round of verification are spread to each verification node, the verification nodes firstly perform signature verification as common blockchain transactions or transactions, the validity of the transactions is ensured, the transactions passing verification enter a set to be agreed, and after most verification nodes reach agreement, the transactions are successfully executed and notified to a user, and after the transaction execution is successful; the state opportunity of the intelligent contract self judges the state of the contract, after all transactions included in the contract are sequentially executed, the state opportunity marks the state of the contract as complete, and the contract is removed from the latest block;
otherwise, the processing is marked as in progress, the processing is continuously stored in the latest block to wait for the next round of processing until the processing is finished, and the whole transaction and the processing of the state are automatically completed by an intelligent contract system arranged in the bottom layer of the block chain, so that the whole process is transparent and can not be clenched and changed;
finally, constructing a tamper and migration system of the intelligent contract, recovering the intelligent contract system when the tamper and migration system is subjected to data migration and upgrading of the intelligent contract, preventing or filtering the operation of an attacker when a hacker or a fault occurs, suspending the contract, enabling the contract to be more transparent to a user, preventing the hacker from attacking the user who cannot know the migration, then calculating the memory offset of a variable, and then searching or scanning a blockchain by using a getStorageAt function and searching a holder by himself; the method can rely on Goog l e B i gTab l e archiving disclosed by an Ethernet blockchain to recover the intelligent contract data, and finally, a new intelligent contract system is constructed by setting values through the constructors of the intelligent contracts.
The foregoing is merely a preferred embodiment of the present invention, and it should be noted that modifications and substitutions can be made by those skilled in the art without departing from the technical principles of the present invention, and these modifications and substitutions should also be considered as being within the scope of the present invention.

Claims (8)

1. The intelligent contract system of the block chain is characterized by comprising the following construction and execution steps:
step S1: the multiparty users participate in the appointed intelligent contract system together;
step S2: contracts are spread through the P2P network and stored in the blockchain;
step S3: an intelligent contract automatic execution system constructed by a block chain;
step S4: a tamper and migration system for smart contracts.
2. The intelligent contract system of a blockchain according to claim 1, characterized by the step S1 as described above, comprising the steps of:
step S1.1: firstly, a user must register a user becoming a blockchain, and the blockchain returns a pair of public keys and private keys to the user;
step S1.2: two or more users agree on a commitment together according to the needs, wherein the commitment comprises rights and obligations of both sides;
step S1.3: the signed intelligent contract is transmitted into the blockchain network according to the promised content.
3. The intelligent contract system of a blockchain according to claim 1, characterized by the step S2 as described above, comprising the steps of:
step S2.1: the contracts are diffused in the block chain full network in a P2P mode, and each node receives one copy;
step S2.1: when the consensus time is up, the verification node packages all contracts stored in the last period of time together into a contract set, calculates the Hash value of the contract set, and finally assembles the Hash value of the contract set into a block structure and spreads the block structure to the whole network;
step S2.1: the newly agreed contract set is spread over the whole network in the form of blocks.
4. The intelligent contract system of a blockchain according to claim 1, characterized by the step S3 as described above, comprising the steps of:
step S3.1: the intelligent contracts can periodically check the state of the automaton, and traverse the state machines, the transactions and the triggering conditions contained in each contract one by one;
step S3.2: the transaction entering the latest round of verification is diffused to each verification node, and the verification node performs signature verification first as common blockchain transaction or transaction, so that the validity of the transaction is ensured;
step S3.3: after the transaction is successfully executed, the state opportunity of the intelligent contract is carried by the intelligent contract to judge the state of the contract.
5. The intelligent contract system of a blockchain of claim 4, characterized by the step S3.3 as described above, including the steps of:
step S3.31: when all transactions included in the contract have been sequentially executed, the state opportunity marks the state of the contract as complete and removes the contract from the latest block;
step S3.32: otherwise, the processing is marked as in progress, and the processing is continued in the latest block to wait for the next round of processing until the processing is completed.
6. The intelligent contract system of a blockchain according to claim 1, characterized by the step S4 as described above, comprising the steps of:
step S4.1: restoring the data to be migrated;
step S4.2: writing data to the new contract.
7. The intelligent contract system of a blockchain of claim 6, characterized by the step S4.1 as described above, including the steps of:
step S4.11: the need to read data from a particular block in the blockchain, if recovered from an event, requires the use of operations to block or filter the attacker before the event occurs;
step S4.12: for private variables, events can be relied on, memory offset of the variables can be calculated, and then the getStorageAt function is used for searching, so that the array is easy to recover because the number of elements is known;
step S4.13: for the mapping case, the mapped keys are not stored, to simplify offline tracking, the blockchain is scanned and the holder is retrieved by itself; the Google BigTable archive, which may rely on the Ethernet blockchain disclosure, may be used GoogleBigQueryAPI, bigQuery to provide access to the block numbers if the blockchain is not synchronized, so this query may be adjusted to return transactions to a particular block;
step S4.14: restoring the addresses of all holders, the balance of function may be queried offline to restore the balance associated with each holder.
8. The intelligent contract system of a blockchain according to claim 1, characterized by the step S4.2 as described above, comprising the steps of:
step S4.21: simple variables, values can be set by the constructors of the smart contracts;
step S4.22: if the data cannot be kept in a single piece, each transaction is contained in a block that limits the total gas that can be used for its transaction, and if the gas cost of the transaction approaches or exceeds this limit, the miners will not repackage. To migrate large amounts of data, the migration must be split into multiple tasks;
step S4.23: the initialization state is added in the intelligent contract, only the owner can change the state variable, and the user cannot perform any operation.
CN202211699114.0A 2022-12-28 2022-12-28 Intelligent contract system of block chain Pending CN116388990A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211699114.0A CN116388990A (en) 2022-12-28 2022-12-28 Intelligent contract system of block chain

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211699114.0A CN116388990A (en) 2022-12-28 2022-12-28 Intelligent contract system of block chain

Publications (1)

Publication Number Publication Date
CN116388990A true CN116388990A (en) 2023-07-04

Family

ID=86964418

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211699114.0A Pending CN116388990A (en) 2022-12-28 2022-12-28 Intelligent contract system of block chain

Country Status (1)

Country Link
CN (1) CN116388990A (en)

Similar Documents

Publication Publication Date Title
JP6882474B2 (en) Systems and methods for detecting replay attacks
CN110633323B (en) Service data storage method, device, storage medium and computer equipment
JP7199775B2 (en) Data processing method, data processing device, node device, and computer program based on smart contract
US10681083B2 (en) System and method for detecting replay attack
TWI737944B (en) Block chain-based transaction execution method and device, and electronic equipment
JP6905059B2 (en) Systems and methods for detecting replay attacks
US10735464B2 (en) System and method for detecting replay attack
CN108898390A (en) Intelligent contract call method and device, electronic equipment based on block chain
CN109003078A (en) Intelligent contract call method and device, electronic equipment based on block chain
CN113570466B (en) Transaction data processing method and device and readable storage medium
CN109656778A (en) Data capture method, device, computer equipment and storage medium
CN110851535B (en) Data processing method and device based on block chain, storage medium and terminal
CN110933040B (en) Block chain based data uplink method, device, equipment and medium
CN113326165B (en) Data processing method and device based on block chain and computer readable storage medium
CN110197075A (en) Resource access method, calculates equipment and storage medium at device
CN109254956A (en) Method, the method, apparatus and electronic equipment of data downloading of a kind of data storage
CN109299116A (en) A kind of method of data synchronization, device, equipment and readable storage medium storing program for executing
CN111177171A (en) Service data authentication and management method and system based on block chain
CN116388990A (en) Intelligent contract system of block chain
CN112417052B (en) Data synchronization method, device, equipment and storage medium in block chain network
CN115174594B (en) Data synchronization method, device, equipment and medium of distributed system
US20240061916A1 (en) Systems and methods for access authentication using prioritized personal information questions for data access and deletion in distributed service systems
KR20220007483A (en) Peer terminal and method for processing a block data at a peer terminal
CN117056318A (en) Filter management method and transaction deduplication method applied to blockchain system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication