A sales contract evidence storage method and system based on blockchain

Through multiple hash functions and smart contract automated execution, combined with CRC check and timestamp technology, the problem of tampering and low automation execution efficiency in electronic contract storage is solved, and efficient and safe contract storage and automated execution are achieved, enhancing improve the reliability and efficiency of e-commerce transactions.

CN118364517BActive Publication Date: 2024-10-22NANJING TORTOISE & HARE RACE SOFTWARE RES INST CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410793702.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-19
Publication Date
2024-10-22
Estimated Expiration
2044-06-19

AI Technical Summary

Technical Problem

The existing blockchain-based electronic contract certification technology has problems such as the possibility of tampering and low efficiency of automated execution, especially because the hash collision probability is low but there is still a risk of tampering, and it cannot be executed automatically, leading to human errors and disputes. Increase.

Method used

Use a variety of hash functions to calculate the hash value of electronic contracts, automatically execute the contract through smart contracts, and combine it with CRC check and timestamp technology to determine whether the contract has been tampered with. At the same time, the contract is converted into an image for grayscale analysis to enhance tampering. Detection capabilities.

Benefits of technology

It realizes safe and reliable storage of electronic contracts, guarantees the security and traceability of contracts, improves the efficiency and automated execution capabilities of e-commerce transactions, and reduces disputes and legal risks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118364517B_ABST
    Figure CN118364517B_ABST
Patent Text Reader

Abstract

The present invention belongs to the technical field of contract evidence storage, and discloses a sales contract evidence storage method and system based on blockchain; the method comprises: creating an electronic contract; calculating a corresponding hash value for the electronic contract, and encrypting the hash value by using an encryption algorithm; constructing a smart contract according to the electronic contract; deploying the encrypted electronic contract and the smart contract on the blockchain, and automatically executing the electronic contract according to the smart contract; analyzing the electronic contract to determine whether the electronic contract has been tampered with; the present invention not only realizes the safe and reliable evidence storage of the electronic contract, ensures the security and traceability of the electronic contract information, but also improves the efficiency of e-commerce transactions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of contract notarization, and more specifically, to a sales contract notarization method and system based on blockchain. Background Art

[0002] With the rapid development of the digital economy, e-commerce is booming around the world. In e-commerce, the storage and execution of electronic contracts are very important links. The main purpose of electronic contract storage is to ensure the traceability, provability and security of transactions. Different from traditional paper contracts, it has the advantages of environmental protection, portability and high efficiency, but at the same time there is the possibility of tampering, and the authenticity of the contract content cannot be ensured.

[0003] The blockchain is jointly maintained by multiple parties, using cryptography to ensure transmission and access security, enabling consistent data storage and making it difficult to tamper with. Electronic contracts are stored on the blockchain, maintaining an unchangeable, timestamp-based, blockchain electronic contract data network. For example, the Chinese patent with authorization announcement number CN112597545B discloses a medical electronic contract evidence storage method based on blockchain technology. This includes: editing and filling out electronic contracts in turn by medical institutions, distributors, and drug and medical device manufacturers, and using the national secret SM2 algorithm for digital signatures and electronic seals. After all parties have signed, the electronic contract is uploaded to the blockchain. When there is a subsequent need for authentication, the hash value is calculated using the national secret SM3 algorithm and compared with the pre-stored hash value to confirm whether tampering has occurred. This can ensure mutual trust among all parties in the medical insurance procurement process, contract tamper-proofing, and credible data preservation, strengthen supervision in the medical procurement process, and achieve autonomous control in the medical insurance procurement blockchain security encryption process.

[0004] However, the core invention of the above technology is to use different algorithms to calculate the hash values ​​corresponding to the electronic contract during pre-storage and authentication, and to determine whether the electronic contract has been tampered with by comparing the hash values. However, due to the existence of hash collisions, although the probability is low, there is still a possibility that the electronic contract has been tampered with. At the same time, the electronic contract cannot be automatically executed, which will lead to human errors and disputes, reducing the efficiency of contract execution.

[0005] In view of this, the present invention proposes a sales contract notarization method and system based on blockchain to solve the above problems. Summary of the invention

[0006] In order to overcome the above-mentioned defects of the prior art and to achieve the above-mentioned purpose, the present invention provides the following technical solution: a sales contract evidence storage method based on blockchain, comprising:

[0007] Create electronic contracts;

[0008] Calculate the corresponding hash value for the electronic contract and encrypt the hash value using an encryption algorithm;

[0009] Building smart contracts based on electronic contracts;

[0010] Deploy the encrypted electronic contract and smart contract on the blockchain, and automatically execute the electronic contract according to the smart contract;

[0011] Analyze the electronic contract to determine whether it has been tampered with.

[0012] Furthermore, the electronic contract is a sales contract.

[0013] Furthermore, n different hash functions are used to calculate the hash value of the electronic contract, and the calculated The hash values ​​are concatenated into a string, and the string is encrypted using an asymmetric encryption algorithm. , n is an integer greater than 1.

[0014] Furthermore, the step of constructing a smart contract based on the electronic contract includes:

[0015] Step 1: Analyze the electronic contract and extract key information;

[0016] Step 2: Build a smart contract based on key information.

[0017] Furthermore, in step 1, the step of extracting key information includes:

[0018] Step 101: Split the electronic contract into word sequences of length F , F is an integer greater than 1, get f word sequences, ;

[0019] Step 102: Word Sequence Perform preprocessing to obtain Q candidate words , , ;

[0020] Step 103: Q candidate words Perform vectorization processing to obtain Q corresponding candidate word vectors ;

[0021] Step 104: Q candidate word vectors Perform candidate word deduplication processing to obtain q candidate keyword vectors. ;

[0022] Step 105: vectorize the electronic contract to obtain an electronic contract vector;

[0023] Step 106: Calculate the similarities between the q candidate keyword vectors and the electronic contract vector in turn, sort the similarities from large to small, and extract N target keywords in positive order. ; Among them, N target keywords are key information;

[0024] In step 102, the word sequence The preprocessing methods include: Perform part-of-speech screening, entity recognition, and term recognition; part-of-speech screening is to filter word sequences Perform part-of-speech tagging and filter out common parts of speech, and remove words corresponding to uncommon parts of speech;

[0025] In step 103, Q candidate words are The method for vectorization processing includes: dividing the electronic contract into single word sequences: , is the total number of electronic contract words, A single word for electronic contract, candidate word The word in Within the range, Candidate word The minimum position number of a single word in the single word sequence, Candidate word The maximum position number of a single word in the single word sequence, is the position number in the word sequence The single word, is the position number in the word sequence The candidate word The corresponding word sequence is , the corresponding single word vector sequence is , for Corresponding word vector; the candidate word The average vector of the corresponding single-word vector sequence is used as the word vector corresponding to the candidate word .

[0026] Furthermore, in step 104, the Q candidate word vectors are The method for performing candidate word deduplication processing includes: firstly transforming Q candidate word vectors As a class, calculate Q candidate word vectors respectively The distance to the cluster center, and according to the distance, the Q candidate word vectors are The corresponding candidate words are classified into the corresponding classes, with a total of q classes; after completing a calculation, recalculate the cluster center of each class, calculate the distance again, and iterate until convergence; after clustering is completed, take out the candidate word vector closest to each cluster center As the candidate keyword vector output, there are q candidate keyword vectors in total;

[0027] Candidate word vectors The distance to the cluster center location is calculated as follows:

[0028] ;

[0029] In the formula, is the candidate word vector The distance to the cluster center, is the dimension of the candidate word vector, is the candidate word vector The coordinates of the u-th dimension, is the coordinate of the u-th dimension of the cluster center position, ;

[0030] The method for calculating the similarity between the candidate keyword vector and the electronic contract vector in step 106 includes:

[0031] The electronic contract vector can be expressed as , the candidate keyword vector can be expressed as ;

[0032] ;

[0033] In the formula, is the similarity, is the uth component in the electronic contract vector, is the uth component in the candidate keyword vector.

[0034] Furthermore, in step 2, the step of constructing a smart contract based on key information includes:

[0035] Step 201: define state variables;

[0036] Step 202: Setting a value-getting function and a value-setting function;

[0037] Step 203: Add a constructor;

[0038] Step 204: Add an event;

[0039] Step 205: Design basic functional functions;

[0040] Step 206: Determine the business logic;

[0041] Step 207: Design control authority.

[0042] Further, analyzing the cyclic redundancy check code and timestamp of the electronic contract to determine whether the electronic contract has been tampered with;

[0043] The method for obtaining the cyclic redundancy check code is as follows: when the electronic contract is encrypted, The string formed by concatenating the hash values ​​is converted into a binary number form and marked as a binary string; the CRC algorithm is selected and the register is initialized, and the register value and CRC polynomial are obtained according to the CRC algorithm; starting from the highest bit of the binary string, each bit is XORed with the register value, and the result of the operation is determined to be or , if the result of the operation is , then perform CRC polynomial operation and then shift the register left. If the result is , directly shift the register left until all bits in the binary string are XORed with the register value, and then obtain the cyclic redundancy check code; the left shift register is to shift the highest bit of the register value out, and the remaining bits are shifted one bit to the left, and the filling number is obtained according to the CRC algorithm, and the filling number is filled into the lowest bit; the cyclic redundancy check code is deployed on the blockchain together with the encrypted electronic contract;

[0044] The method for obtaining the timestamp is as follows: when the encrypted electronic contract is deployed on the blockchain, a corresponding timestamp will be generated on the blockchain; the timestamp is the deployment time of the encrypted electronic contract on the blockchain.

[0045] Furthermore, the method for determining whether an electronic contract has been tampered with according to a cyclic redundancy check code includes:

[0046] Use the same n hash functions to calculate electronic contracts Hash values ​​are concatenated into a string, and the string is checked again by CRC to obtain the corresponding cyclic redundancy check code, which is marked as a comparison check code; the comparison check code is compared with the cyclic redundancy check code on the blockchain. If the comparison check code is consistent with the cyclic redundancy check code on the blockchain, the electronic contract has not been tampered with; if the comparison check code is inconsistent with the cyclic redundancy check code on the blockchain, the electronic contract has been tampered with;

[0047] Methods for determining whether an electronic contract has been tampered with based on timestamps include:

[0048] The deployment time corresponding to the encrypted electronic contract is queried on the blockchain and marked as the comparison time; the comparison time is compared with the deployment time. If the comparison time is consistent with the deployment time, the electronic contract has not been tampered with; if the comparison time is inconsistent with the deployment time, the electronic contract has been tampered with.

[0049] Further, the electronic contract is converted into an image form and analyzed to determine whether the electronic contract has been tampered with;

[0050] When an electronic contract is created, the image form of the electronic contract is marked as a contract image, the contract image is grayed, and the gray values ​​of Y pixels are collected, where Y is the number of all pixels in a contract image;

[0051] Preset a grayscale value threshold, compare and analyze the grayscale values ​​of Y pixels with the grayscale value threshold respectively, mark the pixels whose grayscale values ​​are greater than or equal to the grayscale value threshold as text points, and do not mark the pixels whose grayscale values ​​are less than the grayscale value threshold;

[0052] Count the number of text points and calculate the text area;

[0053] The expression for the text area is: ;

[0054] In the formula, is the text area, Count the words. is the area of ​​a text point;

[0055] The area of ​​a text point is obtained from the resolution of the contract image, and the resolution of the contract image is obtained from the properties of the contract image;

[0056] When determining whether an electronic contract has been tampered with, the electronic contract is converted into an image again, and image analysis is performed to obtain the corresponding text area and mark it as a comparison area; the comparison area is compared with the text area. If the comparison area is consistent with the text area, the electronic contract has not been tampered with; if the comparison area is inconsistent with the text area, the electronic contract has been tampered with.

[0057] A sales contract notarization system based on blockchain, implementing a sales contract notarization method based on blockchain, comprising:

[0058] Contract creation module, used to create electronic contracts;

[0059] A contract encryption module is used to calculate the corresponding hash value of the electronic contract and encrypt the hash value using an encryption algorithm;

[0060] A deployment module for building smart contracts based on electronic contracts;

[0061] Smart contract building module, used to deploy encrypted electronic contracts and smart contracts on the blockchain, and automatically execute electronic contracts according to smart contracts;

[0062] The tampering analysis module is used to analyze the electronic contract and determine whether the electronic contract has been tampered with.

[0063] An electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the blockchain-based sales contract notarization method when executing the computer program.

[0064] A computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed, implements the sales contract notarization method based on blockchain.

[0065] The technical effects and advantages of the blockchain-based sales contract storage method and system of the present invention are as follows:

[0066] 1. By storing electronic contract information on the blockchain platform and encrypting and preserving the electronic contract information in combination with cryptographic technology, the leakage of electronic contracts during transmission can be effectively prevented; at the same time, the corresponding smart contracts are automatically constructed and executed using blockchain technology to realize the automatic operation and supervision of the electronic contract business process, ensuring the efficiency and compliance of the transaction process; in addition, CRC checksum and timestamp technologies are used to identify and trace the electronic contract information to verify the authenticity and integrity of the electronic contract and prevent the electronic contract from being tampered with at will; this not only realizes the safe and reliable storage of electronic contracts, ensures the security and traceability of electronic contract information, but also improves the efficiency of e-commerce transactions.

[0067] 2. By converting the electronic contract into an image for analysis and processing, graying and threshold processing are used to separate the text area in the image, the number of text points is counted as feature parameters, and the text area is calculated to determine whether the electronic contract has been tampered with, thereby increasing the ability to detect tampering with the electronic contract; it provides more reliable, accurate and detailed electronic contract verification, combined with the blockchain evidence storage mechanism to ensure the integrity and timeliness of the contract; through multiple verification levels, it enhances the anti-tampering capability, provides a safer trading environment, and reduces disputes and legal risks. BRIEF DESCRIPTION OF THE DRAWINGS

[0068] Figure 1 This is a schematic diagram of a sales contract notarization system based on blockchain according to Embodiment 1 of the present invention;

[0069] Figure 2 This is a schematic diagram of a sales contract notarization system based on blockchain according to Embodiment 2 of the present invention;

[0070] Figure 3 This is a flow chart of a sales contract evidence storage method based on blockchain according to Embodiment 3 of the present invention;

[0071] Figure 4 This is a schematic diagram of an electronic device according to Embodiment 4 of the present invention;

[0072] Figure 5This is a schematic diagram of a storage medium according to Embodiment 5 of the present invention. DETAILED DESCRIPTION

[0073] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0074] Embodiment 1:

[0075] See also Figure 1 As shown, the sales contract evidence storage system based on blockchain described in this embodiment includes a contract creation module, a contract encryption module, a smart contract construction module, a deployment module and a tampering analysis module; each module is connected by wired and / or wireless means to realize data transmission between modules;

[0076] Contract creation module, used to create electronic contracts;

[0077] The electronic contract is a sales contract; the electronic contract shall at least include the information of both parties (such as address, contact information), payment terms (such as sales price, currency unit, payment method), product description (such as specifications, quantity, quality requirements), delivery conditions (such as delivery method, performance period), etc.

[0078] A contract encryption module is used to calculate the corresponding hash value of the electronic contract and encrypt the hash value using an encryption algorithm;

[0079] Use n different hash functions to calculate the hash value of the electronic contract, and The hash values ​​are concatenated into a string, and the string is encrypted using an asymmetric encryption algorithm. , n is an integer greater than 1;

[0080] Hash functions include SM2, SM3, SHA3-512, Whirlpool, etc. Asymmetric algorithms use keys to encrypt and decrypt data. The keys include public keys and private keys. The public key is used to encrypt the string, and the private key is used to decrypt the string.

[0081] It should be noted that the purpose of calculating the hash value is that the hash value is the unique identifier of the electronic contract, which can be used to determine whether the electronic contract has been tampered with; the purpose of encrypting the hash value is to protect the confidentiality and privacy of the electronic contract and prevent unauthorized third parties from browsing and viewing the content;

[0082] A smart contract building module, used to build smart contracts based on electronic contracts;

[0083] The steps to build a smart contract based on an electronic contract include:

[0084] Step 1: Analyze the electronic contract and extract key information;

[0085] Step 2: Build a smart contract based on key information;

[0086] In the above step 1, the steps of extracting key information include:

[0087] Step 101: Split the electronic contract into word sequences of length F , F is an integer greater than 1, get f word sequences, ;

[0088] Step 102: Word Sequence Perform preprocessing to obtain Q candidate words , , ;

[0089] Step 103: Q candidate words Perform vectorization processing to obtain Q corresponding candidate word vectors ;

[0090] Step 104: Q candidate word vectors Perform candidate word deduplication processing to obtain q candidate keyword vectors. ;

[0091] Step 105: vectorize the electronic contract to obtain an electronic contract vector;

[0092] Step 106: Calculate the similarities between the q candidate keyword vectors and the electronic contract vector in turn, sort the similarities from large to small, and extract N target keywords in positive order. ; The N target keywords are key information, such as product description, information about Party A and Party B, price, payment terms, etc.;

[0093] In the above step 102, the word sequence The preprocessing methods include: Perform part-of-speech screening, entity recognition, and term recognition; part-of-speech screening is to filter word sequences Parts of speech are tagged and common parts of speech are screened out, such as nouns, proper nouns, noun-verbs, etc., and words corresponding to uncommon parts of speech are eliminated; entity recognition is to identify specific entities in electronic contracts, such as information about Party A and Party B, product descriptions, etc.; term recognition is to identify professional terms in electronic contracts, such as delivery conditions, payment terms, etc.; both entity recognition and term recognition can be recognized using a trained NER model. The training process of the NER model is an existing technology and will not be described in detail here;

[0094] In the above step 103, Q candidate words are The method for vectorization processing includes: dividing the electronic contract into single word sequences: , is the total number of electronic contract words, A single word for electronic contract, candidate word The word in Within the range, Candidate word The minimum position number of a single word in the single word sequence, Candidate word The maximum position number of a single word in the single word sequence, is the position number in the word sequence The single word, is the position number in the word sequence The candidate word The corresponding word sequence is , the corresponding single word vector sequence is , for Corresponding word vector; the candidate word The average vector of the corresponding single-word vector sequence is used as the word vector corresponding to the candidate word ;

[0095] In the above step 104, the Q candidate word vectors are The method for performing candidate word deduplication processing includes: firstly transforming Q candidate word vectors As a class, calculate Q candidate word vectors respectively The distance to the cluster center, and according to the distance, the Q candidate word vectors are The corresponding candidate words are classified into the corresponding classes, with a total of q classes; after completing a calculation, recalculate the cluster center of each class, calculate the distance again, and iterate until convergence; after clustering is completed, take out the candidate word vector closest to each cluster center As the candidate keyword vector output, there are q candidate keyword vectors in total; among them, the class corresponding to the candidate word is, multiple semantically similar or synonymous candidate words are regarded as one class;

[0096] Candidate word vectors The distance to the cluster center location is calculated as follows:

[0097] ;

[0098] In the formula, is the candidate word vector The distance to the cluster center, is the dimension of the candidate word vector, is the candidate word vector The coordinates of the u-th dimension, is the coordinate of the u-th dimension of the cluster center position, ;

[0099] The method for calculating the similarity between the candidate keyword vector and the electronic contract vector in the above step 106 includes:

[0100] The electronic contract vector can be expressed as , the candidate keyword vector can be expressed as ;

[0101] ;

[0102] In the formula, is the similarity, is the uth component in the electronic contract vector, is the uth component in the candidate keyword vector;

[0103] In step 2 above, the steps of building a smart contract based on key information include:

[0104] Step 201: Define state variables; used to record key information required for the smart contract to run;

[0105] contract SaleContract {

[0106] string public productName;

[0107] uint public price;

[0108] }

[0109] Step 202: Set the value-getting function and the value-setting function to realize the reading and modification control of the state variables;

[0110] function setProductName(string memory _name) public {

[0111] productName = _name;

[0112] }

[0113] Step 203: Add a constructor; use the constructor to initialize the default values ​​of the state variables;

[0114] constructor() public {

[0115] productName = "Phone";

[0116] price = 1000;

[0117] }

[0118] Step 204: Add events; record important event information during the operation of the smart contract, such as payment events, order confirmation events, delivery events, etc.;

[0119] event OrderPlaced(address buyer, uint value);

[0120] function placeOrder() public payable {

[0121] emit OrderPlaced(msg.sender, msg.value);

[0122] }

[0123] Step 205: Design basic functional functions; implement the basic functional interfaces provided by the smart contract, such as order functions (such as create order function, get order function, pay order function), product functions (such as add product function, update product function), payment functions (such as payment function, refund function), etc.;

[0124] function placeOrder() public payable returns() {}

[0125] Step 206: Determine the business logic; implement specific business execution logic under different contract conditions;

[0126] enum OrderStatus {Pending, Paid, Shipped, Completed}

[0127] function updateStatus() public {

[0128] if(order.status == OrderStatus.Paid) {

[0129] order.status = OrderStatus.Shipped;

[0130] }

[0131] }

[0132] Step 207: Design control permissions; limit control permissions through modifiers to prevent illegal access and calls;

[0133] modifier onlyOwner() {

[0134] require(msg.sender == owner);

[0135] }

[0136] function transferOwnership(address newOwner) public onlyOwner {

[0137] owner = newOwner;

[0138] }

[0139] A deployment module is used to deploy the encrypted electronic contract and smart contract on the blockchain and automatically execute the electronic contract according to the smart contract;

[0140] A tampering analysis module is used to analyze the electronic contract and determine whether the electronic contract has been tampered with;

[0141] Analyze the cyclic redundancy check code and timestamp of the electronic contract to determine whether the electronic contract has been tampered with;

[0142] The method for obtaining the cyclic redundancy check code is as follows: when the electronic contract is encrypted, The string formed by concatenating the hash values ​​is converted into a binary number form and marked as a binary string; the CRC algorithm is selected and the register is initialized, and the register value and CRC polynomial are obtained according to the CRC algorithm; starting from the highest bit (i.e. the leftmost bit) of the binary string, each bit is XORed with the register value, and the result of the operation is determined to be or , if the result of the operation is , then perform CRC polynomial operation and then shift the register left. If the result is , directly shift the register left until all bits in the binary string are XORed with the register value, and then obtain the cyclic redundancy check code; the left shift register is to shift the highest bit of the register value out, and the remaining bits are shifted one bit to the left, and the filling number is obtained according to the CRC algorithm, and the filling number is filled into the lowest bit; the cyclic redundancy check code is deployed on the blockchain together with the encrypted electronic contract; this embodiment is preferred is 1, is 0;

[0143] The method for obtaining the timestamp is as follows: when the encrypted electronic contract is deployed on the blockchain, a corresponding timestamp will be generated on the blockchain; the timestamp is the deployment time of the encrypted electronic contract on the blockchain;

[0144] Methods for determining whether an electronic contract has been tampered with based on a cyclic redundancy check code include:

[0145] Use the same n hash functions to calculate electronic contracts Hash values ​​are concatenated into a string, and the string is checked again by CRC to obtain the corresponding cyclic redundancy check code, which is marked as a comparison check code; the comparison check code is compared with the cyclic redundancy check code on the blockchain. If the comparison check code is consistent with the cyclic redundancy check code on the blockchain, the electronic contract has not been tampered with; if the comparison check code is inconsistent with the cyclic redundancy check code on the blockchain, the electronic contract has been tampered with;

[0146] Methods for determining whether an electronic contract has been tampered with based on timestamps include:

[0147] Query the deployment time corresponding to the encrypted electronic contract on the blockchain and mark it as the comparison time; compare the comparison time with the deployment time. If the comparison time is consistent with the deployment time, the electronic contract has not been tampered with; if the comparison time is inconsistent with the deployment time, the electronic contract has been tampered with;

[0148] This embodiment stores the electronic contract information on the blockchain platform and encrypts and saves the electronic contract information in combination with cryptographic technology, thereby effectively preventing the leakage of electronic contracts during transmission; at the same time, it uses blockchain technology to automatically build and execute corresponding smart contracts, realize the automatic operation and supervision of the electronic contract business process, and ensure the efficiency and compliance of the transaction process; in addition, it also uses CRC verification and timestamp and other technologies to identify and trace the electronic contract information to verify the authenticity and integrity of the electronic contract and prevent the electronic contract from being tampered with at will; it not only realizes the safe and reliable storage of electronic contracts, ensures the security and traceability of electronic contract information, but also improves the efficiency of e-commerce transactions.

[0149] Embodiment 2:

[0150] See also Figure 2 As shown, this embodiment further improves the design on the basis of embodiment 1. In order to further increase the verification of the integrity of the electronic contract, in embodiment 1, based on the cyclic redundancy check code and timestamp of the electronic contract, whether the electronic contract has been tampered with is determined, and then combined with image analysis technology to further analyze whether the electronic contract has been tampered with; therefore, this embodiment provides a sales contract evidence storage system based on blockchain, and also includes a secondary analysis module for converting the electronic contract into an image form and analyzing it to determine whether the electronic contract has been tampered with;

[0151] When an electronic contract is created, the image form of the electronic contract is marked as a contract image, the contract image is grayed, and the gray values ​​of Y pixels are collected, where Y is the number of all pixels in a contract image;

[0152] Preset a grayscale value threshold, compare and analyze the grayscale values ​​of Y pixels with the grayscale value threshold respectively, mark the pixels whose grayscale values ​​are greater than or equal to the grayscale value threshold as text points, and do not mark the pixels whose grayscale values ​​are less than the grayscale value threshold;

[0153] It should be noted that the grayscale value threshold is determined by a technician in the field in the past who collects multiple contract images and grayscales them in the process of judging whether an electronic contract has been tampered with. The grayscale values ​​of all the pixels corresponding to the text in each contract image are used as an analysis set, and the average of the lowest grayscale values ​​in the multiple analysis sets is used as the grayscale value threshold;

[0154] Count the number of text points and calculate the text area;

[0155] The expression for the text area is: ;

[0156] In the formula, is the text area, Count the words. is the area of ​​a text point;

[0157] The area of ​​a text point is obtained from the resolution of the contract image, and the resolution of the contract image is obtained from the properties of the contract image;

[0158] When determining whether the electronic contract has been tampered with, the electronic contract is converted into an image form again, and image analysis is performed to obtain the corresponding text area and mark it as a comparison area; the comparison area is compared with the text area, and if the comparison area is consistent with the text area, the electronic contract has not been tampered with; if the comparison area is inconsistent with the text area, the electronic contract has been tampered with;

[0159] This embodiment converts the electronic contract into an image form for analysis and processing, uses grayscale and threshold processing to separate the text area in the image, counts the number of text points as feature parameters, and calculates the text area to determine whether the electronic contract has been tampered with, thereby increasing the ability to detect electronic contract tampering; provides more reliable, accurate and detailed electronic contract verification, combined with the blockchain evidence storage mechanism to ensure the integrity and timeliness of the contract; through multiple verification levels, it enhances the anti-tampering capability, provides a safer trading environment, and reduces disputes and legal risks.

[0160] Embodiment 3:

[0161] See also Figure 3 As shown, the parts not described in detail in this embodiment are described in Examples 1 and 2. A sales contract evidence storage method based on blockchain is provided, and the method includes:

[0162] Create electronic contracts;

[0163] Calculate the corresponding hash value for the electronic contract and encrypt the hash value using an encryption algorithm;

[0164] Building smart contracts based on electronic contracts;

[0165] Deploy the encrypted electronic contract and smart contract on the blockchain, and automatically execute the electronic contract according to the smart contract;

[0166] Analyze the electronic contract to determine whether it has been tampered with.

[0167] Furthermore, the electronic contract is a sales contract.

[0168] Furthermore, n different hash functions are used to calculate the hash value of the electronic contract, and the calculated The hash values ​​are concatenated into a string, and the string is encrypted using an asymmetric encryption algorithm. , n is an integer greater than 1.

[0169] Furthermore, the step of constructing a smart contract based on the electronic contract includes:

[0170] Step 1: Analyze the electronic contract and extract key information;

[0171] Step 2: Build a smart contract based on key information.

[0172] Furthermore, in step 1, the step of extracting key information includes:

[0173] Step 101: Split the electronic contract into word sequences of length F , F is an integer greater than 1, get f word sequences, ;

[0174] Step 102: Word Sequence Perform preprocessing to obtain Q candidate words , , ;

[0175] Step 103: Q candidate words Perform vectorization processing to obtain Q corresponding candidate word vectors ;

[0176] Step 104: Q candidate word vectors Perform candidate word deduplication processing to obtain q candidate keyword vectors. ;

[0177] Step 105: vectorize the electronic contract to obtain an electronic contract vector;

[0178] Step 106: Calculate the similarities between the q candidate keyword vectors and the electronic contract vector in turn, sort the similarities from large to small, and extract N target keywords in positive order. ; Among them, N target keywords are key information;

[0179] In step 102, the word sequence The preprocessing methods include: Perform part-of-speech screening, entity recognition, and term recognition; part-of-speech screening is to filter word sequences Perform part-of-speech tagging and filter out common parts of speech, and remove words corresponding to uncommon parts of speech;

[0180] In step 103, Q candidate words are The method for vectorization processing includes: dividing the electronic contract into single word sequences: , is the total number of electronic contract words, A single word for electronic contract, candidate word The word in Within the range, Candidate word The minimum position number of a single word in the single word sequence, Candidate word The maximum position number of a single word in the single word sequence, is the position number in the word sequence The single word, is the position number in the word sequence The candidate word The corresponding word sequence is , the corresponding single word vector sequence is , for Corresponding word vector; the candidate word The average vector of the corresponding single-word vector sequence is used as the word vector corresponding to the candidate word .

[0181] Furthermore, in step 104, the Q candidate word vectors are The method for performing candidate word deduplication processing includes: firstly transforming Q candidate word vectors As a class, calculate Q candidate word vectors respectively The distance to the cluster center, and according to the distance, the Q candidate word vectors are The corresponding candidate words are classified into the corresponding classes, with a total of q classes; after completing a calculation, recalculate the cluster center of each class, calculate the distance again, and iterate until convergence; after clustering is completed, take out the candidate word vector closest to each cluster center As the candidate keyword vector output, there are q candidate keyword vectors in total;

[0182] Candidate word vectors The distance to the cluster center location is calculated as follows:

[0183] ;

[0184] In the formula, is the candidate word vector The distance to the cluster center, is the dimension of the candidate word vector, is the candidate word vector The coordinates of the u-th dimension, is the coordinate of the u-th dimension of the cluster center position, ;

[0185] The method for calculating the similarity between the candidate keyword vector and the electronic contract vector in step 106 includes:

[0186] The electronic contract vector can be expressed as , the candidate keyword vector can be expressed as ;

[0187] ;

[0188] In the formula, is the similarity, is the uth component in the electronic contract vector, is the uth component in the candidate keyword vector.

[0189] Furthermore, in step 2, the step of constructing a smart contract based on key information includes:

[0190] Step 201: define state variables;

[0191] Step 202: Setting a value-getting function and a value-setting function;

[0192] Step 203: Add a constructor;

[0193] Step 204: Add an event;

[0194] Step 205: Design basic functional functions;

[0195] Step 206: Determine the business logic;

[0196] Step 207: Design control authority.

[0197] Further, analyzing the cyclic redundancy check code and timestamp of the electronic contract to determine whether the electronic contract has been tampered with;

[0198] The method for obtaining the cyclic redundancy check code is as follows: when the electronic contract is encrypted, The string formed by concatenating the hash values ​​is converted into a binary number form and marked as a binary string; the CRC algorithm is selected and the register is initialized, and the register value and CRC polynomial are obtained according to the CRC algorithm; starting from the highest bit of the binary string, each bit is XORed with the register value, and the result of the operation is determined to be or , if the result of the operation is , then perform CRC polynomial operation and then shift the register left. If the result is , directly shift the register left until all bits in the binary string are XORed with the register value, and then obtain the cyclic redundancy check code; the left shift register is to shift the highest bit of the register value out, and the remaining bits are shifted one bit to the left, and the filling number is obtained according to the CRC algorithm, and the filling number is filled into the lowest bit; the cyclic redundancy check code is deployed on the blockchain together with the encrypted electronic contract;

[0199] The method for obtaining the timestamp is as follows: when the encrypted electronic contract is deployed on the blockchain, a corresponding timestamp will be generated on the blockchain; the timestamp is the deployment time of the encrypted electronic contract on the blockchain.

[0200] Furthermore, the method for determining whether an electronic contract has been tampered with according to a cyclic redundancy check code includes:

[0201] Use the same n hash functions to calculate electronic contracts Hash values ​​are concatenated into a string, and the string is checked again by CRC to obtain the corresponding cyclic redundancy check code, which is marked as a comparison check code; the comparison check code is compared with the cyclic redundancy check code on the blockchain. If the comparison check code is consistent with the cyclic redundancy check code on the blockchain, the electronic contract has not been tampered with; if the comparison check code is inconsistent with the cyclic redundancy check code on the blockchain, the electronic contract has been tampered with;

[0202] Methods for determining whether an electronic contract has been tampered with based on timestamps include:

[0203] The deployment time corresponding to the encrypted electronic contract is queried on the blockchain and marked as the comparison time; the comparison time is compared with the deployment time. If the comparison time is consistent with the deployment time, the electronic contract has not been tampered with; if the comparison time is inconsistent with the deployment time, the electronic contract has been tampered with.

[0204] Further, the electronic contract is converted into an image form and analyzed to determine whether the electronic contract has been tampered with;

[0205] When an electronic contract is created, the image form of the electronic contract is marked as a contract image, the contract image is grayed, and the gray values ​​of Y pixels are collected, where Y is the number of all pixels in a contract image;

[0206] Preset a grayscale value threshold, compare and analyze the grayscale values ​​of Y pixels with the grayscale value threshold respectively, mark the pixels whose grayscale values ​​are greater than or equal to the grayscale value threshold as text points, and do not mark the pixels whose grayscale values ​​are less than the grayscale value threshold;

[0207] Count the number of text points and calculate the text area;

[0208] The expression for the text area is: ;

[0209] In the formula, is the text area, Count the words. is the area of ​​a text point;

[0210] The area of ​​a text point is obtained from the resolution of the contract image, and the resolution of the contract image is obtained from the properties of the contract image;

[0211] When determining whether an electronic contract has been tampered with, the electronic contract is converted into an image again, and image analysis is performed to obtain the corresponding text area and mark it as a comparison area; the comparison area is compared with the text area. If the comparison area is consistent with the text area, the electronic contract has not been tampered with; if the comparison area is inconsistent with the text area, the electronic contract has been tampered with.

[0212] Embodiment 4:

[0213] See also Figure 4 As shown, according to another aspect of the present application, an electronic device 500 is also provided. The electronic device 500 may include one or more processors and one or more memories. The memories store computer readable codes, and when the computer readable codes are executed by one or more processors, a sales contract notarization method based on blockchain as described above may be executed.

[0214] The method or system according to the embodiment of the present application can also be used by Figure 4 The electronic device architecture shown in FIG. Figure 4 As shown, the electronic device 500 may include a bus 501, one or more CPUs 502, ROM 503, RAM 504, a communication port 505 connected to a network, an input / output 506, a hard disk 507, etc. The storage device in the electronic device 500, such as ROM 503 or hard disk 507, may store a sales contract evidence storage method based on blockchain provided in the present application. Furthermore, the electronic device 500 may also include a user interface 508. Of course, Figure 4 The architecture shown is only exemplary and can be omitted according to actual needs when implementing different devices. Figure 4 One or more components of an electronic device are shown.

[0215] Embodiment 5:

[0216] See also Figure 5 As shown, a computer-readable storage medium 600 according to an embodiment of the present application is shown. Computer-readable instructions are stored on the computer-readable storage medium 600. When the computer-readable instructions are executed by the processor, a sales contract storage method based on blockchain according to an embodiment of the present application described with reference to the above figures can be executed. The storage medium 600 includes, but is not limited to, for example, volatile memory and / or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and cache memory (cache), etc. Non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc.

[0217] In addition, according to the implementation of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the present application provides a non-transitory machine-readable storage medium, which stores machine-readable instructions, and the machine-readable instructions can be executed by a processor to execute instructions corresponding to the method steps provided by the present application, for example: a sales contract notarization method based on blockchain. When the computer program is executed by a central processing unit (CPU), the above functions defined in the method of the present application are executed.

[0218] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

[0219] Finally: The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A sales contract evidence storage method based on blockchain, characterized in that: include: Create electronic contracts; Calculate the corresponding hash value for the electronic contract and encrypt the hash value using an encryption algorithm; Building smart contracts based on electronic contracts; The steps of constructing a smart contract based on an electronic contract include: Step 1: Analyze the electronic contract and extract key information; Step 2: Build a smart contract based on key information; In step 1, the step of extracting key information includes: Step 101: Split the electronic contract into word sequences of length F , F is an integer greater than 1, get f word sequences, ; Step 102: Word Sequence Perform preprocessing to obtain Q candidate words , , ; Step 103: Q candidate words Perform vectorization processing to obtain Q corresponding candidate word vectors ; Step 104: Q candidate word vectors Perform candidate word deduplication processing to obtain q candidate keyword vectors. ; Step 105: vectorize the electronic contract to obtain an electronic contract vector; Step 106: Calculate the similarities between the q candidate keyword vectors and the electronic contract vector in turn, sort the similarities from large to small, and extract N target keywords in positive order. ; Among them, N target keywords are key information; Deploy the encrypted electronic contract and smart contract on the blockchain, and automatically execute the electronic contract according to the smart contract; Analyze the electronic contract to determine whether it has been tampered with; Convert the electronic contract into an image and analyze it to determine whether the electronic contract has been tampered with; When an electronic contract is created, the image form of the electronic contract is marked as a contract image, the contract image is grayed, and the gray values ​​of Y pixels are collected, where Y is the number of all pixels in a contract image; Preset a grayscale value threshold, compare and analyze the grayscale values ​​of Y pixels with the grayscale value threshold respectively, mark the pixels whose grayscale values ​​are greater than or equal to the grayscale value threshold as text points, and do not mark the pixels whose grayscale values ​​are less than the grayscale value threshold; Count the number of text points and calculate the text area; The expression for the text area is: ; In the formula, is the text area, Count the words. is the area of ​​a text point; The area of ​​a text point is obtained from the resolution of the contract image, and the resolution of the contract image is obtained from the properties of the contract image; When determining whether an electronic contract has been tampered with, the electronic contract is converted into an image again, and image analysis is performed to obtain the corresponding text area and mark it as a comparison area; the comparison area is compared with the text area. If the comparison area is consistent with the text area, the electronic contract has not been tampered with; if the comparison area is inconsistent with the text area, the electronic contract has been tampered with.

2. According to the blockchain-based sales contract evidence storage method of claim 1, it is characterized in that: Use n different hash functions to calculate the hash value of the electronic contract, and The hash values ​​are concatenated into a string, and the string is encrypted using an asymmetric encryption algorithm. , n is an integer greater than 1.

3. According to claim 2, a sales contract evidence storage method based on blockchain is characterized in that: In step 102, the word sequence The preprocessing methods include: Perform part-of-speech screening, entity recognition, and term recognition; part-of-speech screening is to filter word sequences Perform part-of-speech tagging and filter out common parts of speech, and remove words corresponding to uncommon parts of speech; In step 103, Q candidate words are The method for vectorization processing includes: dividing the electronic contract into single word sequences: , is the total number of electronic contract words, A single word for electronic contract, candidate word The word in Within the interval, Candidate word The minimum position number of a single word in the single word sequence, Candidate word The maximum position number of a single word in the single word sequence, is the position number in the word sequence The single word, is the position number in the word sequence The candidate word The corresponding word sequence is , the corresponding single word vector sequence is , for Corresponding word vector; the candidate word The average vector of the corresponding single-word vector sequence is used as the word vector corresponding to the candidate word .

4. According to the blockchain-based sales contract evidence storage method of claim 3, it is characterized in that: In step 104, Q candidate word vectors are The method for performing candidate word deduplication processing includes: firstly transforming Q candidate word vectors As a class, calculate Q candidate word vectors respectively The distance to the cluster center, and according to the distance, the Q candidate word vectors are The corresponding candidate words are classified into the corresponding classes, with a total of q classes; after completing a calculation, recalculate the cluster center of each class, calculate the distance again, and iterate until convergence; after clustering is completed, take out the candidate word vector closest to each cluster center As the candidate keyword vector output, there are q candidate keyword vectors in total; Candidate word vectors The distance to the cluster center location is calculated as follows: ; In the formula, is the candidate word vector The distance to the cluster center, is the dimension of the candidate word vector, is the candidate word vector The coordinates of the u-th dimension, is the coordinate of the u-th dimension of the cluster center position, ; The method for calculating the similarity between the candidate keyword vector and the electronic contract vector in step 106 includes: The electronic contract vector can be expressed as , the candidate keyword vector can be expressed as ; ; In the formula, is the similarity, is the uth component in the electronic contract vector, is the uth component in the candidate keyword vector.

5. According to the blockchain-based sales contract evidence storage method of claim 4, it is characterized in that: In step 2, the steps of constructing a smart contract based on key information include: Step 201: define state variables; Step 202: Setting a value-getting function and a value-setting function; Step 203: Add a constructor; Step 204: Add an event; Step 205: Design basic functional functions; Step 206: Determine the business logic; Step 207: Design control authority.

6. According to the blockchain-based sales contract evidence storage method of claim 5, it is characterized in that: Analyze the cyclic redundancy check code and timestamp of the electronic contract to determine whether the electronic contract has been tampered with; The method for obtaining the cyclic redundancy check code is as follows: when the electronic contract is encrypted, The string formed by concatenating the hash values ​​is converted into a binary number form and marked as a binary string; the CRC algorithm is selected and the register is initialized, and the register value and CRC polynomial are obtained according to the CRC algorithm; starting from the highest bit of the binary string, each bit is XORed with the register value, and the result of the operation is determined to be or , if the result of the operation is , then perform CRC polynomial operation and then shift the register left. If the result is , directly shift the register left until all bits in the binary string are XORed with the register value, and then obtain the cyclic redundancy check code; the left shift register is to shift the highest bit of the register value out, and the remaining bits are shifted one bit to the left, and the filling number is obtained according to the CRC algorithm, and the filling number is filled into the lowest bit; the cyclic redundancy check code is deployed on the blockchain together with the encrypted electronic contract; The method for obtaining the timestamp is as follows: when the encrypted electronic contract is deployed on the blockchain, a corresponding timestamp will be generated on the blockchain; the timestamp is the deployment time of the encrypted electronic contract on the blockchain.

7. A sales contract evidence storage method based on blockchain according to claim 6, characterized in that: Methods for determining whether an electronic contract has been tampered with based on timestamps include: The deployment time corresponding to the encrypted electronic contract is queried on the blockchain and marked as the comparison time; the comparison time is compared with the deployment time. If the comparison time is consistent with the deployment time, the electronic contract has not been tampered with; if the comparison time is inconsistent with the deployment time, the electronic contract has been tampered with.

8. A sales contract notarization system based on blockchain, implementing a sales contract notarization method based on blockchain as described in any one of claims 1 to 7, characterized in that: include: Contract creation module, used to create electronic contracts; A contract encryption module is used to calculate the corresponding hash value of the electronic contract and encrypt the hash value using an encryption algorithm; A deployment module for building smart contracts based on electronic contracts; Smart contract building module, used to deploy encrypted electronic contracts and smart contracts on the blockchain, and automatically execute electronic contracts according to smart contracts; The tampering analysis module is used to analyze the electronic contract and determine whether the electronic contract has been tampered with.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the blockchain-based sales contract notarization method described in any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed, it implements the blockchain-based sales contract notarization method described in any one of claims 1 to 7.