Fine-grained contract data privacy protection and verification method, system and storage medium

Through homomorphic encryption technology, the basic and advanced privacy fields of the contract are identified and encrypted, and the effectiveness of the contract is verified through the public key, which solves the problems of coarse encryption granularity, low efficiency and inability to verify the validity of the contract in the existing technology, and realizes efficient privacy protection and verification of fine-grained contract data.

CN117521129BActive Publication Date: 2025-05-23HANGZHOU DBAPPSECURITY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311445256.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2023-07-13
Filing Date
2023-10-31
Publication Date
2025-05-23
Estimated Expiration
2043-10-31

AI Technical Summary

Technical Problem

The existing contract encryption technology has problems such as coarse encryption granularity, low encryption efficiency, inability to verify the validity of encrypted contracts, and few types of support contracts.

Method used

By identifying the homomorphic type of the contract and the corresponding basic privacy fields and advanced privacy fields, encrypt these fields using the homomorphic encryption public key, generate an encrypted contract, and verify the validity of the contract through the public key.

Benefits of technology

It realizes privacy protection and verification of fine-grained contract data, improves encryption efficiency, ensures the effectiveness of the contract, and supports the privacy protection of various contract types in the contract law.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117521129B_ABST
    Figure CN117521129B_ABST
Patent Text Reader

Abstract

The present invention discloses a fine-grained contract data privacy protection and verification method, system and storage medium, the method comprising the following steps: the contracting parties identify the homomorphic type of the contract and the corresponding basic privacy field and advanced privacy field, and generate a plain text contract; the contracting parties generate a homomorphic encryption public-private key pair; the basic privacy field and the advanced privacy field are encrypted using the homomorphic encryption public key to obtain an encrypted contract; the contracting parties confirm the encrypted contract and make the encrypted contract and the homomorphic encryption public key public; the public identifies the homomorphic type of the contract and verifies the validity of the contract according to the corresponding homomorphic algorithm and public key. The present invention solves the problems of coarse encryption granularity, low encryption efficiency, inability to verify the validity of encrypted contracts and few supported contract types in the related art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of information security technology, and in particular relates to a fine-grained contract data privacy protection and verification method, system and storage medium. Background Art

[0002] With the rapid development of mobile Internet, big data, cloud computing, and artificial intelligence industries, more and more personal and corporate data are generated. However, due to the lack of standardization of data security operations in various applications and platforms, there are more and more cases of data privacy leakage and economic losses. The confidentiality requirements for contracts signed between enterprises or individuals are getting higher and higher.

[0003] The mainstream encryption technology means are to use symmetric encryption algorithms such as AES, searchable encryption algorithms based on matrix operations, homomorphic encryption algorithms, etc. Symmetric encryption algorithms such as AES cannot recalculate the ciphertext, which weakens the functionality of encryption to a certain extent; searchable encryption algorithms based on matrix operations encrypt all the contents of the contract, and the encryption efficiency is low; homomorphic encryption algorithms are currently used in smart contracts in the blockchain field, but only integer amount values ​​such as contract amounts, transaction amounts, and account balances are homomorphically encrypted. Once the encrypted contract is signed, the public users cannot effectively verify the amount in the encrypted contract, and the validity of the contract is difficult to guarantee. In addition, the types of contracts that support homomorphic encryption are limited, and cannot support privacy protection for all types of contracts in contract law.

[0004] In order to solve the problems of coarse encryption granularity, low encryption efficiency, inability to verify the validity of encrypted contracts and few supported contract types in existing contract encryption technologies, a fine-grained contract data privacy protection and verification method, system and storage medium are proposed. Summary of the invention

[0005] The embodiments of the present invention propose a fine-grained contract data privacy protection and verification method, system and storage medium to at least solve the problems in the related art of coarse encryption granularity, low encryption efficiency, inability to verify the validity of encrypted contracts and few supported contract types.

[0006] According to an embodiment of the present invention, a fine-grained contract data privacy protection and verification method is proposed, including:

[0007] The contracting parties identify the homomorphic type of the contract and the corresponding basic privacy fields and advanced privacy fields, and generate a plain text contract;

[0008] The two parties to the contract generate a homomorphic encryption public and private key pair;

[0009] Use the homomorphic encryption public key to encrypt the basic privacy field and the advanced privacy field to obtain an encrypted contract;

[0010] The two parties to the contract confirm the encrypted contract and make the encrypted contract and homomorphic encryption public key public;

[0011] The public identifies the homomorphic type of the contract and verifies the validity of the contract based on the corresponding homomorphic algorithm and public key.

[0012] In an exemplary embodiment, the contracting parties identify the homomorphic type of the contract and the corresponding basic privacy fields and advanced privacy fields, and generate a plain text contract, including the steps of:

[0013] The parties to the contract shall determine the method of calculating the amount involved in the contract based on the specific type of the contract signed. The specific types of the contract include loan contracts, lease contracts, warehousing contracts, commission contracts, financial lease contracts, sales contracts, transportation contracts, undertaking contracts, donation contracts, construction contracts, technical contracts, custody contracts, entrustment contracts, brokerage contracts, and electricity / water / gas / heat supply and use contracts; the amount involved in the contract includes any one or more combinations of unit price, total price, loan amount, interest amount, and various fees; the calculation method includes one or more combinations of multiplication, addition, a combination of multiplication and addition, and no calculation;

[0014] The contracts are classified into ciphertext homomorphic categories according to the calculation method of the amount involved in the contract; the ciphertext homomorphic categories include multiplication homomorphic contracts, addition homomorphic contracts, multiplication and addition homomorphic contracts, no homomorphic contracts, and no encryption contracts;

[0015] A basic privacy field and an advanced privacy field are obtained according to a contract amount calculation method corresponding to the ciphertext homomorphic type of the contract; the value of the advanced privacy field is calculated by the value of the basic privacy field;

[0016] The parties to the contract determine the contract type and the corresponding basic privacy field and advanced privacy field values ​​and then generate a plain text contract.

[0017] In an exemplary embodiment, the contracting parties generate a homomorphic encryption public-private key pair, comprising the steps of:

[0018] Select random 1024-bit prime numbers p and q, and calculate the modulus n = p·q, g = n+1, λ = (p-1)·(q-1);

[0019] Calculate μ = λ -1 mod n;

[0020] The generated homomorphic encryption public key is pk = (n, g), and the homomorphic encryption private key is sk = (λ, μ);

[0021] Both parties to the contract keep the private key sk = (λ,μ).

[0022] In an exemplary embodiment, the method of encrypting the basic privacy field and the advanced privacy field using the homomorphic encryption public key to obtain an encrypted contract includes the following steps:

[0023] The value of the basic privacy field is denoted as ep 1 ,…,ep N , where N represents the number of values ​​of the basic privacy field;

[0024] According to the homomorphic encryption public key pk = (n, g), select a random number r in (0, N) such that r and n are relatively prime. For i = 1, 2, ..., N, calculate the ciphertext of the basic privacy field

[0025] The value of the advanced privacy field is denoted by ap 1 ,…,ap M , where M represents the number of values ​​of the advanced privacy field;

[0026] According to the homomorphic encryption public key pk = (n, g), a random number u is selected from (0, M) such that u and n are relatively prime. For j = 1, 2, ..., M, the key of the advanced privacy field is calculated.

[0027] The values ​​of the basic privacy field and the advanced privacy field are replaced by the corresponding ciphertexts to obtain the encrypted contract.

[0028] In an exemplary embodiment, the contracting parties confirm the encrypted contract and make the encrypted contract and the homomorphic encryption public key public, including the steps of:

[0029] Both parties of the contract will sign and confirm the encrypted contract;

[0030] Binding the signed and confirmed encrypted contract to the homomorphic encryption public key; the binding is to add the homomorphic encryption public key to the top or end of the encrypted contract or any one or more combinations of the encrypted position;

[0031] The encryption contract bound to the homomorphic encryption public key is published publicly.

[0032] In an exemplary embodiment, the public identifies the homomorphic type of the contract and verifies the validity of the contract according to the corresponding homomorphic algorithm and public key, including the steps of:

[0033] The public obtains the encrypted contract bound to the homomorphic encryption public key and identifies the homomorphic type of the contract;

[0034] According to the contract amount calculation method corresponding to the contract homomorphic type, the homomorphic calculation formula between the basic privacy field ciphertext and the advanced privacy field ciphertext is obtained, that is, the homomorphic algorithm corresponding to the contract type; if the calculation method is multiplication, the homomorphic algorithm is expressed as ac=ec k mod n2 , where k is the multiplier term; if the calculation method is addition, the homomorphic algorithm is expressed as ac = ec 1 *…*ec t mod n 2 ; If the calculation method is a combination of multiplication and addition, the homomorphic algorithm is expressed as Where k1, k2, …, kt are weighted terms:

[0035] Substitute the basic privacy field ciphertext and the advanced privacy field ciphertext in the encrypted contract into the homomorphic algorithm to determine whether the equation holds. If so, the contract is valid; otherwise, the contract is invalid.

[0036] In an exemplary embodiment, the step of: both parties to the contract verifying the correctness of the contract privacy data after homomorphically decrypting the encrypted contract includes:

[0037] The two parties to the contract use the homomorphic encryption private key sk = (λ, μ) to encrypt the basic privacy field ciphertext ec of the contract 1 ,…,ec N and Advanced Privacy Field Ciphertext ac 1 ,…,ac M Perform decryption, that is, for i=1,2,…,N, calculate Get the decrypted basic privacy field value ep′ 1 ,…,ep′ N , for j = 1, 2, ..., M, calculate Get the advanced privacy field value ap′ 1 ,…,ap′ M ;

[0038] Obtain the decrypted contract based on the decrypted basic privacy field value and advanced privacy field value;

[0039] The contracting parties determine the decrypted basic privacy field value ep′ 1 ,…,ep′ N and the advanced privacy field value ap′ 1 ,…,ap′ M Whether it is consistent with the original value, if so, the contract privacy data is judged to be correct, otherwise, the contract privacy data is judged to be incorrect.

[0040] In an exemplary embodiment, when the value of the basic privacy field and / or the advanced privacy field is a non-integer, the contracting parties convert the value of the basic privacy field and / or the advanced privacy field into an integer according to a preset precision parameter and then perform contract encryption and verification, including:

[0041] The contracting parties set the precision parameter w, that is, the amount and multiplier in the contract are retained to w decimal places;

[0042] Multiply the value and multiplier of the base privacy field by 10 w , that is, the numerical value is converted into an integer, and the expansion order is recorded as S;

[0043] Calculate the integer value of the corresponding advanced privacy field according to the contract amount calculation method;

[0044] Generate a plaintext contract based on the integer value of the basic privacy field and the integer value of the advanced privacy field and perform homomorphic encryption to obtain an encrypted contract;

[0045] The contracting parties decrypt the contract according to the homomorphic encryption type of the contract and verify the correctness of the contract; if the homomorphic encryption type of the contract is additive homomorphic, the decrypted private field value is divided by 10 w Then determine whether it is consistent with the original data; if the homomorphic encryption type of the contract is multiplication homomorphism or multiplication and addition homomorphism, the decrypted advanced privacy field value ap′ 1 ,…,ap′ M Divide by 10 w*S , and divide all expanded basic privacy field values ​​and multiplier terms by 10 w , and then determine whether it is consistent with the original data.

[0046] According to another embodiment of the present invention, a computer-readable storage medium is provided, which stores a computer program for electronic data exchange, wherein the computer program executes the above method.

[0047] According to another embodiment of the present invention, a fine-grained contract data privacy protection and verification system is provided, including:

[0048] processor;

[0049] Memory;

[0050] as well as

[0051] One or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, the programs causing the computer to perform the above method.

[0052] The fine-grained contract data privacy protection and verification method, system and storage medium of the present invention have the following advantages:

[0053] (1) According to the different types of contracts and the different calculation methods of the amounts involved, the private content of the contract is divided into basic privacy fields and advanced privacy fields and homomorphically encrypted separately. Compared with traditional encryption technology, it can not only effectively provide fine-grained privacy protection of contract amount data, but also avoid encrypting the entire text of the contract, thereby improving the efficiency of contract encryption.

[0054] (2) When the value of the basic privacy field and / or the advanced privacy field is a non-integer, the parties to the contract convert the value of the basic privacy field and / or the advanced privacy field into an integer according to the preset precision parameters and then generate a plain text contract. Compared with the traditional technical solution that can only perform homomorphic encryption on integer amounts, this can effectively improve the encryption functionality and applicability of the homomorphic encryption algorithm.

[0055] (3) The public uses the homomorphic encryption public key bound to the encrypted contract to verify the validity of the relationship between multiple ciphertext amounts in the encrypted contract. Compared with the traditional technical solution in which the public cannot verify the validity of the encrypted contract, this can effectively ensure the validity of the publicly circulated version of the encrypted contract.

[0056] (4) Designing homomorphic encryption methods for various types of contracts in contract law can effectively improve the scope of application of contract data privacy protection compared to traditional privacy protection schemes that only support some types of contracts. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] Figure 1 is a flow chart of a fine-grained contract data privacy protection method according to an embodiment of the present invention;

[0058] Figure 2 is a flowchart of sub-step S01 of an embodiment of the present invention;

[0059] Figure 3 is a flowchart of sub-step S02 of an embodiment of the present invention;

[0060] Figure 4 is a flowchart of sub-step S03 of an embodiment of the present invention;

[0061] Figure 5 is a flowchart of sub-step S04 of an embodiment of the present invention;

[0062] Figure 6 is a flowchart of sub-step S05 of an embodiment of the present invention

[0063] Figure 7 is a flowchart of additional sub-step S04' of an embodiment of the present invention;

[0064] Figure 8 is a flow chart of a fine-grained contract data privacy protection method according to another embodiment of the present invention;

[0065] Fig. 9 It is a schematic diagram of the structure of a fine-grained contract data privacy protection and verification system according to an embodiment of the present invention. DETAILED DESCRIPTION

[0066] The present invention is described in detail below in conjunction with specific embodiments. The following embodiments will help those skilled in the art to further understand the invention, but are not intended to limit the present invention in any form. It should be noted that, for those of ordinary skill in the art, several changes and improvements can be made without departing from the concept of the present invention. These all belong to the protection scope of the present invention.

[0067] A fine-grained contract data privacy protection method according to an embodiment of the present invention is shown in the flowchart as follows: Figure 1 As shown, the steps include:

[0068] Step S01: Both parties to the contract identify the homomorphic type of the contract and the corresponding basic privacy fields and advanced privacy fields, and generate a plain text contract;

[0069] Step S02: Both parties to the contract generate a homomorphic encryption public and private key pair;

[0070] Step S03: Use the homomorphic encryption public key to encrypt the basic privacy field and the advanced privacy field to obtain an encrypted contract;

[0071] Step S04: Both parties to the contract confirm the encrypted contract and make the encrypted contract and homomorphic encryption public key public;

[0072] Step S05: The public identifies the homomorphic type of the contract and verifies the validity of the contract based on the corresponding homomorphic algorithm and public key.

[0073] In an exemplary embodiment, the step S01, the flow chart is as follows Figure 2 As shown, including:

[0074] Step S011, the contracting parties determine the calculation method of the amount involved in the contract according to the specific type of the signed contract; the specific types of the contract include loan contracts, lease contracts, warehousing contracts, commission contracts, financial lease contracts, sales contracts, transportation contracts, undertaking contracts, donation contracts, construction contracts, technical contracts, custody contracts, entrustment contracts, brokerage contracts, electricity / water / gas / heat supply and use contracts; the amount involved in the contract includes any one or more combinations of unit price, total price, loan amount, interest amount, and various fees; the calculation method includes one or more combinations of multiplication, addition, a combination of multiplication and addition, and no calculation;

[0075] Step S012, classifying the contract into ciphertext homomorphic categories according to the calculation method of the amount involved in the contract; the ciphertext homomorphic categories include multiplication homomorphic contracts, addition homomorphic contracts, multiplication and addition homomorphic contracts, no homomorphic contracts, and no encryption contracts;

[0076] Step S013: obtaining a basic privacy field and an advanced privacy field according to a contract amount calculation method corresponding to the ciphertext homomorphic type of the contract; the value of the advanced privacy field is calculated by the value of the basic privacy field;

[0077] Step S014: The contracting parties determine the homomorphic classification of the contract and the corresponding basic privacy field and advanced privacy field values ​​and then generate a plain text contract.

[0078] In this embodiment, the contract types and codes in the Contract Law are shown in Table 1. That is, the specific types of the contract include loan contracts, lease contracts, warehousing contracts, commission contracts, financial lease contracts, sales contracts, transportation contracts, contracting contracts, donation contracts, construction contracts, technical contracts, custody contracts, entrustment contracts, brokerage contracts, and electricity / water / gas / heat supply contracts.

[0079] Table 1 Contract types and codes

[0080]

[0081]

[0082] The parties to the contract agree on the specific contents of the contract;

[0083] According to the signing rules and amount calculation methods in the specific contract types, the calculation methods of the amounts of different contract types are obtained, as shown in Table 2.

[0084] Table 2 Contract amount calculation method and ciphertext homomorphic type

[0085]

[0086]

[0087]

[0088] The ciphertext homomorphism classification includes multiplication homomorphic contracts, addition homomorphic contracts, multiplication and addition combined homomorphic contracts, no homomorphic contracts, and no encryption contracts. As shown in Table 2, the ciphertext homomorphism types are multiplication homomorphic contracts (Type A), addition homomorphic contracts (Type B), and multiplication and addition homomorphic contracts (Type C). The field corresponding to the unit price amount or multiplier amount used for calculation (the amount involved 1) is the basic privacy field, and the field corresponding to the final payment amount or transaction amount or interest amount (the amount involved 2) is the advanced privacy field; the value of the advanced privacy field is calculated through the value of the basic privacy field (the calculation formula is shown in Table 2); the no homomorphic encryption contract only contains one of the basic privacy field or the advanced privacy field, and the no encryption contract has no basic privacy field or the advanced privacy field.

[0089] The two parties to the contract determine the ciphertext homomorphic type of the contract, and determine that there are N (N≥1) basic privacy fields in the contract according to the fields corresponding to the ciphertext homomorphic type in Table 1, represented as ElemAmt 1,…,ElemAmt N , the corresponding amount plain text value ep 1 ,…,ep N , M advanced privacy fields (M ≥ 1) are represented as AdvAmt 1 ,…,AdvAmt M , and determine the corresponding amount plaintext value ap 1 ,…,ap M . Generate a plain text contract, denoted as Con. The ciphertext homomorphic type of the contract marked in the plain text contract (type A or type B or type C or type D)

[0090] In an exemplary embodiment, the step S02, the flow chart is as follows Figure 3 As shown, including:

[0091] Step S021, select random 1024-bit prime numbers p and q, calculate the modulus n=p·q, g=n+1, λ=(p-1)·(q-1);

[0092] Step S022, calculate μ=λ -1 mod n;

[0093] Step S023, the generated homomorphic encryption public key is pk=(n,g), and the homomorphic encryption private key is sk=(λ,μ);

[0094] Step S024: Both parties to the contract save the private key sk=(λ,μ).

[0095] In this embodiment, after the contracting parties meet, they select random 1024-bit prime numbers p and q, calculate the modulus n = p·q, g = n+1, λ = (p-1)·(q-1), and calculate μ = λ -1 mod n; generate the Paillier encryption public key pk = (n, g), the Paillier encryption private key sk = (λ, μ), and both parties to the contract shall properly keep the private key sk = (λ, μ).

[0096] In an exemplary embodiment, the step S03, the flow chart is as follows Figure 4 As shown, including:

[0097] Step S031: The value of the basic privacy field is recorded as ep 1 ,…,ep N , where N represents the number of values ​​of the basic privacy field;

[0098] Step S032: According to the homomorphic encryption public key pk=(n,g), a random number r is selected from (0,N) such that r and n are relatively prime. For i=1,2,…,N, the ciphertext of the basic privacy field is calculated.

[0099]

[0100] Step S033: The value of the advanced privacy field is recorded as ap 1 ,…,ap M , where M represents the number of values ​​of the advanced privacy field;

[0101] Step S034: According to the homomorphic encryption public key pk=(n,g), a random number u is selected from (0,M) such that u and n are relatively prime. For j=1,2,…,M, the ciphertext of the advanced privacy field is calculated.

[0102]

[0103] Step S035: Replace the values ​​of the basic privacy field and the advanced privacy field with corresponding ciphertexts to obtain an encrypted contract.

[0104] In one embodiment, one party to the contract uses the Paillier public key pk=(n,g) to calculate the plaintext amount ep of N basic privacy fields. 1 ,…,ep N , randomly select and encrypt it into ciphertext data ec 1 ,…,ec N , that is, select a random number r in (0,N) such that r and n are relatively prime, and for i = 1, 2, ..., N, calculate the basic privacy field ciphertext According to the homomorphic encryption public key pk = (n, g), select a random number u in (0, M) such that u and n are relatively prime. For j = 1, 2, ..., M, calculate the ciphertext of the advanced privacy field The values ​​of the basic privacy field and the advanced privacy field are replaced by the corresponding ciphertexts to obtain an encrypted contract, and then one party to the contract sends the encrypted contract to the other party.

[0105] In another embodiment, one party to the contract uses the Paillier public key pk=(n,g) to calculate the plaintext amount ep of N basic privacy fields. 1 ,…,ep N , randomly select and encrypt it into ciphertext data ec 1 ,…,ec N , that is, select a random number r in (0,N) such that r and n are relatively prime, and for i = 1, 2, ..., N, calculate the ciphertext of the basic privacy field The ciphertext data ec 1 ,…,ec N Send it to the other party, who selects a random number u from (0, M) based on the homomorphic encryption public key pk = (n, g), satisfying that u and n are relatively prime, and for j = 1, 2, ..., M, calculates the ciphertext of the advanced privacy field Then, the values ​​of the basic privacy field and the advanced privacy field are replaced with the corresponding ciphertexts, and the encrypted contract is obtained and sent to the other party.

[0106] In another embodiment, one party to the contract uses the Paillier public key pk=(n,g) to calculate the plaintext amount ep of N basic privacy fields. 1 ,…,ep N , randomly select and encrypt it into ciphertext data ec 1 ,…,ec N , that is, select a random number r in (0,N) such that r and n are relatively prime, and for i = 1, 2, ..., N, calculate the ciphertext of the basic privacy field According to the amount calculation method corresponding to the ciphertext homomorphic type of the contract, the ciphertext data ec 1 ,…,ec N Homomorphically calculate the ciphertext ac of the advanced privacy field 1 ,…,ac M ; Then replace the values ​​of the basic privacy field and the advanced privacy field with the corresponding ciphertext, obtain the encrypted contract and send it to the other party.

[0107] In another embodiment, one party to the contract uses the Paillier public key pk=(n,g) to calculate the plaintext amount ep of N basic privacy fields. 1 ,…,ep N , randomly select and encrypt it into ciphertext data ec 1 ,…,ec N , that is, select a random number r in (0,N) such that r and n are relatively prime, and for i = 1, 2, ..., N, calculate the ciphertext of the basic privacy field The ciphertext data ec 1 ,…,ec N Send it to the other party; the other party will send the ciphertext data ec according to the amount calculation method corresponding to the ciphertext homomorphic type of the contract 1 ,…,ec N Homomorphically calculate the ciphertext ac of the advanced privacy field 1 ,…,ac M ; Then replace the values ​​of the basic privacy field and the advanced privacy field with the corresponding ciphertext, obtain the encrypted contract and send it to the other party.

[0108] In an exemplary embodiment, the step S04, the flow chart is as follows Figure 5 As shown, including:

[0109] Step S041, both parties to the contract sign and confirm the encrypted contract;

[0110] Step S042: Bind the signed and confirmed encryption contract to the homomorphic encryption public key; the binding is to add the homomorphic encryption public key to any one or more combinations of the top or the end or the encryption position of the encryption contract;

[0111] Step S043: publicly publish the encryption contract bound to the homomorphic encryption public key.

[0112] In this embodiment, the two parties to the contract sign and confirm the encrypted contract C_Con. The two parties to the contract bind the signed encrypted contract C_Con with the Paillier public key pk=(n,g) (pk can also be added to the end of the contract), and make public (publish on the Internet or other public distribution channels) this encrypted contract and the bound public key pk.

[0113] In an exemplary embodiment, the step S05, the flow chart is as follows Figure 6 As shown, including:

[0114] Step S051: The public obtains an encrypted contract bound to a homomorphic encryption public key and identifies the homomorphic type of the contract;

[0115] Step S052: Obtain the homomorphic calculation formula between the basic privacy field ciphertext and the advanced privacy field ciphertext according to the contract amount calculation method corresponding to the contract homomorphic type, that is, the homomorphic algorithm corresponding to the contract type; if the calculation method is multiplication, the homomorphic algorithm is expressed as ac=ec k mod n 2 , where k is the multiplier term; if the calculation method is addition, the homomorphic algorithm is expressed as ac = ec 1 *…*ec t mod n 2 ; If the calculation method is a combination of multiplication and addition, the homomorphic algorithm is expressed as Among them, k1, k2, …, kt are weighted items;

[0116] Step S053: Substitute the basic privacy field ciphertext and the advanced privacy field ciphertext in the encrypted contract into the homomorphic algorithm to determine whether the equation holds. If so, the contract is deemed valid; otherwise, the contract is deemed invalid.

[0117] In this embodiment, the public obtains the encrypted contract C_Con and the bound public key pk through public channels, and obtains the homomorphic calculation formula between the basic privacy field ciphertext and the advanced privacy field ciphertext according to the contract amount calculation method corresponding to the contract homomorphic type, that is, the homomorphic algorithm corresponding to the contract type; if the calculation method is multiplication, the homomorphic algorithm is expressed as ac=ec k modn 2 , where k is the multiplier term; if the calculation method is addition, the homomorphic algorithm is expressed as ac = ec 1 *…*ec tmod n 2 ; If the calculation method is a combination of multiplication and addition, the homomorphic algorithm is expressed as ac = ec 1 k1 *…*ec t kt mod n 2 Where k1, k2,…, kt are weighted terms.

[0118] According to the ciphertext homomorphic types corresponding to different contract types shown in Table 2, determine the type code of the current contract, so that the ciphertext homomorphic type is multiplication or addition or a combination of multiplication and addition, and select the corresponding homomorphic calculation equation; substitute the ciphertext of the basic privacy field in the encrypted contract into the calculation result on the right side of the homomorphic calculation equation. If the calculation result is equal to the ciphertext of the advanced privacy field in the encrypted contract, the homomorphic calculation equation is established and the contract is determined to be valid. If the calculation result is not equal to the ciphertext of the advanced privacy field in the encrypted contract, the homomorphic calculation equation is not established and the public encrypted contract is determined to be invalid.

[0119] In an exemplary embodiment, after the two parties to the contract obtain the encrypted contract in step S03, the following step is further included: the two parties to the contract perform homomorphic decryption on the encrypted contract and verify the correctness of the contract privacy data, which is recorded as step S04'. The flowchart is as follows: Figure 7 As shown, including:

[0120] Step S04'1. Both parties to the contract use the homomorphic encryption private key sk = (λ, μ) to encrypt the basic privacy field ciphertext ec of the contract 1 ,…,ec N and Advanced Privacy Field Ciphertext ac 1 ,…,ac M Perform decryption, that is, for i=1,2,…,N, calculate Get the decrypted basic privacy field value ep′ 1 ,…,ep′ N , for j = 1, 2, ..., M, calculate Get the advanced privacy field value ap′ 1 ,…,ap′ M ;

[0121] Step S04'2, obtaining the decrypted contract according to the decrypted basic privacy field value and the advanced privacy field value;

[0122] Step S04'3: Both parties to the contract determine the decrypted basic privacy field value ep' 1 ,…,ep′ N and the advanced privacy field value ap′ 1 ,…,ap′ MWhether it is consistent with the original value, if so, the contract privacy data is judged to be correct, otherwise, the contract privacy data is judged to be incorrect.

[0123] In this embodiment, the contracting parties encrypt the basic privacy field ciphertext ec in the contract C_Con according to the negotiated Paillier private key sk = (λ, μ) 1 ,…,ec N and Advanced Privacy Fields ac 1 ,…,ac M Execute decryption to obtain the decrypted basic privacy field value (amount) ep′ 1 ,…,ep′ N and the advanced privacy field value (amount) ap′ 1 ,…,ap′ M , that is, for i = 1, 2, ..., N, j = 1, 2, ..., M, calculate calculate The decrypted contract Con' is obtained. Both parties of the contract can verify the decrypted basic privacy amount ep' in the decrypted contract Con' 1 ,…,ep′ N With the original base privacy amount ep 1 ,…,ep N and advanced privacy amount ap′ 1 ,…,ap′ M With advanced privacy ap 1 ,…,ap M If the amount matches, the private amount in the encrypted contract is correct, otherwise it is wrong. Once the private amount in the encrypted contract is wrong, both parties need to check the initial contract amount and re-execute the above encryption algorithm.

[0124] In an exemplary embodiment, when the value of the basic privacy field and / or the advanced privacy field is a non-integer, the contracting parties convert the value of the basic privacy field and / or the advanced privacy field into an integer according to a preset precision parameter and then perform contract encryption and verification, which is recorded as step S0'. The flowchart is as follows: Figure 8 As shown, the steps include:

[0125] Step S0'1, the contracting parties set the precision parameter w, that is, the amount and multiplier in the contract retain w decimal places;

[0126] Step S0'2: Multiply the value of the basic privacy field and the multiplier by 10 w , that is, the numerical value is converted into an integer, and the expansion order is recorded as S;

[0127] Step S0'3, calculating the integer value of the corresponding advanced privacy field according to the contract amount calculation method;

[0128] Step S0'4: Generate a plain text contract according to the integer value of the basic privacy field and the integer value of the advanced privacy field;

[0129] Step S0'5, obtaining an encrypted contract according to the encryption method described in the above embodiment;

[0130] Step S0'6: The public verifies the validity of the encrypted contract using the public verification method described in the above embodiment;

[0131] Step S0'7: The contracting parties decrypt the contract according to the homomorphic encryption type of the contract and verify the correctness of the contract; if the homomorphic encryption type of the contract is additive homomorphic, the decrypted private field value is divided by 10. w Then determine whether it is consistent with the original data; if the homomorphic encryption type of the contract is multiplication homomorphism or multiplication and addition homomorphism, the decrypted advanced privacy field value ap′ 1 ,…,ap′ M Divide by 10 w*S , and divide all expanded basic privacy field values ​​and multiplier terms by 10 w , and then determine whether it is consistent with the original data.

[0132] In this embodiment, the contracting parties set the precision parameter w (for example, w=2), that is, the amount and multiplier in the contract are rounded to 2 decimal places; the value of the basic privacy field and the multiplier are multiplied by 10. w =100, convert the value of the basic privacy field and the multiplier term into integers, and the order S = 2; calculate the integer value of the corresponding advanced privacy field according to the contract amount calculation method; generate a plain text contract based on the integer value of the basic privacy field and the integer value of the advanced privacy field;

[0133] Using any encryption method described in the above implementation manner to encrypt the values ​​of the basic privacy field and the advanced privacy field in the plain text contract to obtain an encrypted contract, and making the encrypted contract public;

[0134] The public verifies the validity of the encrypted contract using the public verification method described in the above embodiment;

[0135] The contracting parties decrypt the contract according to the homomorphic encryption type of the contract and verify the correctness of the contract; if the homomorphic encryption type of the contract is additive homomorphic, the decrypted private field value is divided by 10 2 Then determine whether it is consistent with the original data; if the homomorphic encryption type of the contract is multiplication homomorphism or multiplication and addition homomorphism, the decrypted advanced privacy field value ap′ 1 ,…,ap′ M Divide by 10 2*2 , and divide all expanded basic privacy field values ​​and multiplier terms by 102 , and then determine whether it is consistent with the original data.

[0136] In order to help better understand the details of the present invention, the following are specific implementation examples of an additive homomorphic encryption contract and a multiplication homomorphic encryption contract, respectively, with the same Paillier encryption parameters selected for the two examples. Due to the limitation of data size, only the case where the modulus n=p*q in Paillier encryption is 128 bits is used for illustration. In actual processes, a larger security parameter should be used.

[0137] Paillier encryption parameter settings:

[0138] p=18057271325696423047,

[0139] q=18121540475127151501,

[0140] pk:n=p*q=327225573198960646961959887385757043547,

[0141] Its base64 encoding is: 'W0uRcvfu0V4W3cMpXlot9g=='.

[0142] sk:λ=(p-1)*(q-1)=327225573198960646925781075584933469000,

[0143] μ=λ -1 mod N=245944869826209634899884780017605683636.

[0144] In actual practice, larger safety parameters should be adopted.

[0145] 1. Example of multiplication homomorphic encryption contract:

[0146] 1) Contract details: Assume that the two parties sign a sample loan contract. Since the annual loan interest rate is involved (which is usually a decimal), the data precision is uniformly taken as w=4, that is, the annual loan interest rate is expanded by 10. w = 10000 times to make it an integer. The data involved in the contract are shown in Table 3:

[0147] Table 3 Example loan contract plain text data details

[0148]

[0149] 2) Use the public key pk to encrypt the basic privacy field: the total amount of the loan data ep = 400000, and get the ciphertext of the basic privacy field ec = 145307757615005921164379226455345013768, whose base64 encoding is 'yCog4d9EQf+kJqQJ3p4RkAlvxZ19rT0 / AEKCGukTxDc='. The total multiplier k = 430*5 = 2150, according to the plaintext amount calculation formula ap = k*ep, the ciphertext amount calculation formula is: ac = ec k mod n 2 , and the ciphertext of the advanced privacy field ac=25223646114416081696899198737271194677147587858810719752066980099695795251912 is calculated, and its base64 encoding is: 'To4VwY4CiaY1D42eqtUlF9sgNnfDJyLt7K0SwGpwwQo='. Therefore, in the ciphertext contract that can be circulated publicly, the ciphertext of each privacy field (which can be encoded by its base64) is used to replace its original data to obtain the encrypted contract. The details of the encrypted contract are shown in Table 4.

[0150] Table 4 Example of loan contract ciphertext data details

[0151]

[0152] 3) During the public circulation of the loan contract, the public can use the ciphertext base64 encoding of the total loan amount, interest amount, and public key stated in the ciphertext contract to restore it to integers ec, ac, and pk=n, and then verify the equation ac=ec based on the total multiplier k=430*5=2150 k mod n 2 Is it established? If established, it is determined that the multiplication amount calculation formula in the contract is correct and the encrypted contract is valid.

[0153] 4) Both parties of the contract can use the private key sk to decrypt the data in the ciphertext contract and obtain the plaintext data items: the total loan amount, annual loan interest rate, number of loan periods, and interest amount are 400,000, 430, 5, and 860,000,000 respectively. Then, the annual loan interest rate and interest amount are reduced by 10. w =10000 times, and obtained several data items 400000, 4.30%, 5, 86000, which were verified to be consistent with the original data, thus determining that the contract privacy data is correct.

[0154] 2. Additive homomorphic encryption contract example:

[0155] 1) Contract details: Assume that the two parties sign a certain example financial leasing contract. Since the cost of purchasing the leased item and the lease fee may be decimals, the data precision is uniformly set to w=2, that is, all amount data is expanded by 10 w = 100 times to make it an integer. The details of the data involved in the contract are shown in Table 5:

[0156] Table 5 Example of clear text data details of financial lease contract

[0157]

[0158] 2) Use the public key pk for the basic privacy field: purchase rental cost data ep 1 =26814032 and rental fee data ep 2 =355750 to encrypt and obtain the corresponding ciphertext ec 1 =11386412327905939604303215807067144098252647402748648753419015323568829888139 and its base64 encoding 'i / YXGheIjN+1hPnF6Wgd4GEERZZwCcQ / Aw / JaCJ7LBk=', and ec 2 =77549872383732016667194824829995978029905762043256824951430964501352598279486 and its base64 encoding 'PhVZ4aLU5GGHOkJjZy / 4SYty2LfCTJd5jBnBThysc6s='.

[0159] According to the clear amount calculation formula ap=ep 1 +ep 2 , get the ciphertext amount calculation formula: ac = ec 1 *ec 2 mod n 2 , and thus the ciphertext of the advanced privacy field ac=87969586130874517668882172634874913931249426653602200256424234544986614068568 is calculated, and its base64 encoding is: 'WPWaqPBYvVboUrav3Tsq8RMcNju4tx6qcKwrgHMFfcI='.

[0160] Therefore, in the ciphertext contract that can be circulated publicly, the ciphertext of each private amount field (which can be encoded in base64) is used to replace its original data to obtain the encrypted contract. The details of the encrypted contract are shown in Table 6:

[0161] Table 6 Example of ciphertext data details of financial lease contract

[0162]

[0163] 3) During the public circulation of the financial leasing contract, the public can restore it to an integer ec according to the ciphertext base64 encoding of the purchase cost of the leased item, the lease fee, the rent, and the public key stated in the ciphertext contract 1 ,ec 2 , ac and pk = n, and verify the equation: ac = ec 1 *ec 2 mod n 2 Is it established? If established, it is considered that the addition amount calculation formula in the contract is correct and the contract is valid.

[0164] 4) Both parties of the contract can use the private key sk to decrypt the data in the ciphertext contract and obtain the plaintext data items: the cost of purchasing the leased item, the lease fee, and the rent are 26814032, 355750, and 27169782 respectively, and then reduce all the amount data by 10 w =100 times, and obtained several data items 268140.32, 3557.5, 271697.82, which were verified to be consistent with the original data, thus determining that the contract privacy data is correct.

[0165] A computer-readable storage medium according to an embodiment of the present invention stores a computer program for electronic data exchange, wherein the computer program enables a computer to execute the method of the above-mentioned embodiment. The computer-readable storage medium according to this embodiment can be used as any one or more of the storage medium of the contract signing system client, the storage medium of the contract signing cloud server, and the storage medium of the public inquiry system cloud or client.

[0166] A fine-grained contract data privacy protection and verification system according to an embodiment of the present invention, the structural diagram is as follows Fig. 9 As shown, including:

[0167] processor;

[0168] Memory;

[0169] as well as

[0170] One or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, the programs causing the computer to execute the method of the above-mentioned embodiment. The processor can be any one or more of a processor of a contract signing system client, a processor of a contract signing cloud server, and a processor of a public inquiry system cloud or client.

[0171] Of course, those skilled in the art should realize that the above embodiments are only used to illustrate the present invention, and are not intended to limit the present invention. As long as they are within the scope of the present invention, any changes or modifications to the above embodiments will fall within the protection scope of the present invention.

Claims

1. A fine-grained contract data privacy protection and verification method, It is characterized in that include: The contracting parties identify the homomorphic type of the contract and the corresponding basic privacy fields and advanced privacy fields, and generate a plain text contract; The contracting parties identify the homomorphic type of the contract and the corresponding basic privacy field and advanced privacy field, and generate a plain text contract, including the following steps: the contracting parties determine the calculation method of the amount involved in the contract according to the specific type of the signed contract; the contract is classified into ciphertext homomorphic categories according to the calculation method of the amount involved in the contract; the ciphertext homomorphic classification includes multiplication homomorphic contracts, addition homomorphic contracts, multiplication and addition homomorphic contracts, no homomorphic contracts, and no encryption contracts; the basic privacy field and the advanced privacy field are obtained according to the calculation method of the contract amount corresponding to the ciphertext homomorphic type of the contract; the value of the advanced privacy field is calculated based on the value of the basic privacy field; the contracting parties generate a plain text contract according to the homomorphic type of the contract and the corresponding basic privacy field and advanced privacy field values; The two parties to the contract generate a homomorphic encryption public and private key pair; Use the homomorphic encryption public key to encrypt the basic privacy field and the advanced privacy field to obtain an encrypted contract; The two parties to the contract confirm the encrypted contract and make the encrypted contract and homomorphic encryption public key public; The public identifies the homomorphic type of the contract and verifies the validity of the contract based on the corresponding homomorphic algorithm and public key.

2. The fine-grained contract data privacy protection and verification method according to claim 1, It is characterized in that The specific types of the contracts include loan contracts, lease contracts, warehousing contracts, commission contracts, financial lease contracts, sales contracts, transportation contracts, undertaking contracts, donation contracts, construction project contracts, technical contracts, custody contracts, entrustment contracts, brokerage contracts, and electricity / water / gas / heat supply and use contracts; the amounts involved in the contracts include any one or more combinations of unit price, total price, loan amount, interest amount, and various fees; the calculation methods include multiplication, addition, a combination of multiplication and addition, and one or more combinations without calculation.

3. The fine-grained contract data privacy protection and verification method according to claim 1, It is characterized in that The contracting parties generate a homomorphic encryption public and private key pair, including the steps of: Select random 1024-bit prime numbers p and q, and calculate the modulus n = p·q, g = n+1, λ = (p-1)·(q-1); Calculate μ = λ -1 mod n; The generated homomorphic encryption public key is pk = (n, g), and the homomorphic encryption private key is sk = (λ, μ); Both parties to the contract keep the private key sk = (λ,μ).

4. The fine-grained contract data privacy protection and verification method according to claim 3, It is characterized in that The method of using a homomorphic encryption public key to encrypt a basic privacy field and an advanced privacy field to obtain an encrypted contract includes the following steps: The value of the basic privacy field is denoted as ep 1 ,…,ep N , where N represents the number of values ​​of the basic privacy field; According to the homomorphic encryption public key pk = (n, g), select a random number r in (0, N) such that r and n are relatively prime. For i = 1, 2, ..., N, calculate the ciphertext of the basic privacy field The value of the advanced privacy field is denoted by ap 1 ,…,ap M , where M represents the number of values ​​of the advanced privacy field; According to the homomorphic encryption public key pk = (n, g), select a random number u in (0, M) such that u and n are relatively prime. For j = 1, 2, ..., M, calculate the ciphertext of the advanced privacy field The values ​​of the basic privacy field and the advanced privacy field are replaced by the corresponding ciphertexts to obtain the encrypted contract.

5. The fine-grained contract data privacy protection and verification method according to claim 1, It is characterized in that The two parties of the contract confirm the encrypted contract and make the encrypted contract and the homomorphic encryption public key public, including the steps of: Both parties of the contract will sign and confirm the encrypted contract; Bind the signed and confirmed encrypted contract to the homomorphic encryption public key; The binding is any one or more combinations of adding the homomorphic encryption public key to the top or end of the encryption contract or other encryption location; Publicly publish a cryptographic contract that binds a homomorphic encryption public key.

6. The fine-grained contract data privacy protection and verification method according to claim 5, It is characterized in that The public identifies the homomorphic type of the contract and verifies the validity of the contract according to the corresponding homomorphic algorithm and public key, including the steps of: The public obtains the encrypted contract bound to the homomorphic encryption public key and identifies the homomorphic type of the contract; According to the contract amount calculation method corresponding to the contract homomorphic type, the homomorphic calculation formula between the basic privacy field ciphertext and the advanced privacy field ciphertext is obtained, that is, the homomorphic algorithm corresponding to the contract type; if the calculation method is multiplication, the homomorphic algorithm is expressed as ac=ec k mod n 2 , where k is the multiplier term; if the calculation method is addition, the homomorphic algorithm is expressed as ac = ec 1 *…*ec t mod n 2 ; If the calculation method is a combination of multiplication and addition, the homomorphic algorithm is expressed as ac = ec 1 k1 *…*ec t kt mod n 2 , where k1, k2, …, kt are weighted terms: Substitute the basic privacy field ciphertext and the advanced privacy field ciphertext in the encrypted contract into the homomorphic algorithm to determine whether the equation holds. If so, the contract is valid; otherwise, the contract is invalid.

7. The fine-grained contract data privacy protection and verification method according to claim 5, It is characterized in that The steps also include: the contracting parties verify the correctness of the contract privacy data after homomorphically decrypting the encrypted contract, including: The two parties to the contract use the homomorphic encryption private key sk = (λ, μ) to encrypt the basic privacy field ciphertext ec of the contract 1 ,…,ec N and Advanced Privacy Field Ciphertext ac 1 ,…,ac M Perform decryption, that is, for i=1,2,…,N, calculate Get the decrypted basic privacy field value ep′ 1 ,…,ep′ N , for j = 1, 2, ..., M, calculate Get the advanced privacy field value ap′ 1 ,…,ap′ M ; Obtain the decrypted contract based on the decrypted basic privacy field value and advanced privacy field value; The contracting parties determine the decrypted basic privacy field value ep′ 1 ,…,ep′ N and the advanced privacy field value ap′ 1 ,…,ap′ M Whether it is consistent with the original value, if so, the contract privacy data is judged to be correct, otherwise, the contract privacy data is judged to be incorrect.

8. The fine-grained contract data privacy protection and verification method according to claim 7, It is characterized in that When the value of the basic privacy field and / or advanced privacy field is a non-integer, the contracting parties shall convert the value of the basic privacy field and / or advanced privacy field into an integer according to the preset precision parameters and then perform contract encryption and verification, including: The contracting parties set the precision parameter w, that is, the number of decimal places retained for the amount and multiplier in the contract is w; Convert the value and multiplier of the basic privacy field containing decimal places into integers, and the total order of expansion is denoted as S; Calculate the integer value of the corresponding advanced privacy field according to the contract amount calculation method; Generate a plaintext contract based on the integer value of the basic privacy field and the integer value of the advanced privacy field and perform homomorphic encryption to obtain an encrypted contract; The contracting parties decrypt the contract according to the homomorphic encryption type of the contract and verify the correctness of the contract; if the homomorphic encryption type of the contract is additive homomorphic, the decrypted private field value is divided by 10 w Then determine whether it is consistent with the original data; if the homomorphic encryption type of the contract is multiplication homomorphism or multiplication and addition homomorphism, the decrypted advanced privacy field value ap′ 1 ,…,ap′ M Divide by 10 w*S , and divide all expanded basic privacy field values ​​and multiplier terms by 10 w , and then determine whether it is consistent with the original data.

9. A computer-readable storage medium storing a computer program for electronic data exchange, in, The computer program enables a computer to execute the method according to any one of claims 1 to 8.

10. A fine-grained contract data privacy protection and verification system, Features include: processor; Memory; as well as One or more programs, wherein the one or more programs are stored in a memory and configured to be executed by the processor, the programs causing the computer to execute the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Block chain privacy protection method based on addition homomorphic encryption

    CN106549749A

  • Intelligent contract bill recording and processing method based on complete homomorphic encryption

    CN113888163A