Method, System, Computer Device and Storage Medium for Transmitting Soil Data

The API service layer recognizes the port number and generates public keys for homomorphic encryption, and uses the lattigo algorithm library to calculate the mean ciphertext, which solves the problems of privacy and authenticity of soil data on the blockchain and realizes the confidentiality and traceability of data transmission.

CN114786175BActive Publication Date: 2025-08-05华润数字科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210419837.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-20
Publication Date
2025-08-05
Estimated Expiration
2042-04-20

AI Technical Summary

Technical Problem

The existing technology cannot effectively protect the privacy and authenticity of farm soil data, especially when data transmission is carried out on the blockchain, there are problems of data tampering and no human intervention.

Method used

The port number is identified through the API service layer, and the corresponding public key is generated or obtained for homomorphic encryption, homomorphic ciphertext is generated and transmitted to the blockchain. The mean ciphertext calculation is performed in combination with the lattigo algorithm library to ensure the confidentiality and authenticity of data transmission.

Benefits of technology

It realizes privacy protection of soil data on the blockchain, prevents tampering, and ensures authenticity and traceability during data transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114786175B_ABST
    Figure CN114786175B_ABST
Patent Text Reader

Abstract

The embodiments of the present application belong to the field of blockchain technology and relate to a method, system, computer device, and storage medium for transmitting soil data, including determining whether the port for transmitting soil data is a newly added port; if so, generating an initial ciphertext of the number of times and a homomorphic ciphertext based on the initial public key and transmitting them to the blockchain; if not, obtaining an intermediate public key and an intermediate ciphertext of the number of times, performing a homomorphic encryption operation on the soil data through the intermediate public key to obtain target soil encrypted data, and generating a target ciphertext of the number of times based on the intermediate ciphertext of the number of times; obtaining the ciphertext with the latest upload time in the blockchain based on the port number as the target on-chain ciphertext, generating a mean ciphertext based on the target soil encrypted data, the target ciphertext of the number of times, and the target on-chain ciphertext, and transmitting it to the blockchain; when receiving a ciphertext acquisition request, reading the ciphertext in the blockchain as the target ciphertext. The present application ensures the authenticity of soil data and privacy on the blockchain while effectively distinguishing the soil data of different farm alliance parties.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of blockchain technology, and in particular to a method, system, computer device and storage medium for transmitting soil data. Background Art

[0002] Homomorphic encryption is a cryptographic technology based on the computational complexity theory of mathematical problems. Processing the data encrypted by homomorphic encryption yields an output, and decrypting this output results in the same outcome as processing the unencrypted original data using the same method. That is, the result obtained after homomorphic calculation (such as addition, subtraction, multiplication, and division) of two ciphertexts in the homomorphic encryption algorithm is the same as the result obtained by directly calculating the real data of the original text after decryption. It realizes data computability while ensuring data privacy. A blockchain can be a distributed database, and the data uploaded to the chain is jointly maintained by each node, featuring decentralization, traceability, and immutability. Soil data collected by Internet of Things devices for soil (such as comprehensive soil sensors) is transmitted through a gateway connection, usually to a data platform specified by the gateway.

[0003] Currently, agricultural product traceability solutions based on blockchain are being widely popularized. However, the fact that each node of the blockchain jointly maintains data means that the privacy data of some farms cannot be protected. If simple encryption is used, data computability cannot be guaranteed. Moreover, during the process of uploading farm soil data to the blockchain, most of it is input through an artificial interface or collected to an Internet of Things platform and then transmitted to the blockchain. Since the Internet of Things platform is a private database, there is a risk of tampering, and the authenticity of the intermediate link cannot be guaranteed, nor can it be ensured that there is no human intervention throughout the process, thus unable to guarantee the authenticity of the data on the chain.

[0004] The solution of simultaneously transmitting the soil data collected by the Internet of Things devices of different farms to the API service layer (API server layer) ensures no human intervention, but it is difficult for the API service layer to identify and distinguish the sources of soil data. Among them, the API service layer is used for API interface settings, connecting to the blockchain to send requests, obtaining get requests, and obtaining post requests, etc. Summary of the Invention

[0005] The purpose of the embodiments of this application is to propose a method, system, computer device and storage medium for transmitting soil data, which can effectively distinguish the soil data of different farm alliance parties while ensuring the authenticity and privacy of soil data on the blockchain.

[0006] To solve the above technical problems, the embodiments of this application provide a method for transmitting soil data, which adopts the following technical solutions:

[0007] A method for transmitting soil data includes the following steps:

[0008] The API service layer receives the soil data transmitted by the gateway through the port associated with the farm alliance party, where there is a one-to-one correspondence between the farm alliance party and the port;

[0009] The API service layer determines whether the port is a newly added port according to the port number of the port;

[0010] If the port is a newly added port, a request for generating a homomorphic public-private key is sent to the farm alliance party server;

[0011] The API service layer receives the initial public key transmitted by the farm alliance party server, generates an initial ciphertext of the number of times based on the initial public key, and stores the port number, the initial public key, and the initial ciphertext of the number of times in the state database in an associated manner. A homomorphic encryption operation is performed on the soil data through the initial public key to generate a homomorphic ciphertext, and the homomorphic ciphertext is transmitted to the blockchain;

[0012] If the port is not a newly added port, the public key and the ciphertext of the number of times associated with the port number are obtained from the state database as the intermediate public key and the intermediate ciphertext of the number of times, and a homomorphic encryption operation is performed on the soil data through the intermediate public key to obtain the target soil encrypted data, and the target ciphertext of the number of times is generated based on the intermediate ciphertext of the number of times;

[0013] When the port is not a newly added port, the API service layer obtains the ciphertext with the latest upload time in the blockchain based on the port number as the target on-chain ciphertext, generates an average ciphertext based on the target soil encrypted data, the target ciphertext of the number of times, the intermediate ciphertext of the number of times, and the target on-chain ciphertext, and transmits the average ciphertext to the blockchain;

[0014] When the API service layer receives the ciphertext acquisition request sent by the farm alliance party server, it reads the ciphertext with the latest upload time in the blockchain as the target ciphertext, and transmits the target ciphertext to the farm alliance party server;

[0015] The farm alliance party server receives the target ciphertext and decrypts the target ciphertext through the locally stored private key to obtain the soil average data.

[0016] Further, the step of generating the initial ciphertext of the number of times through the initial public key includes:

[0017] Performing a homomorphic encryption operation on the pre-assigned number 1 through the initial public key to obtain the initial ciphertext of the number of times.

[0018] Further, the step of generating the target ciphertext of the number of times based on the intermediate ciphertext of the number of times includes:

[0019] Perform a single homomorphic calculation operation on the intermediate - degree ciphertext based on the intermediate public key to obtain the target - degree ciphertext.

[0020] Further, the step of performing a single homomorphic calculation operation on the intermediate - degree ciphertext based on the intermediate public key to obtain the target - degree ciphertext includes:

[0021] Perform a homomorphic encryption operation on the number 1 using the intermediate public key to obtain a number ciphertext;

[0022] Use a homomorphic calculation algorithm to add the intermediate - degree ciphertext and the number ciphertext to obtain the target - degree ciphertext.

[0023] Further, the step of determining whether the port is a newly added port according to the port number of the port includes:

[0024] Query in the status database according to the port number to determine whether there is a public key and a degree ciphertext corresponding to the port number;

[0025] If there is no public key and degree ciphertext corresponding to the port number, determine that the port is a newly added port;

[0026] If there is a public key and degree ciphertext corresponding to the port number, determine that the port is not a newly added port.

[0027] Further, the step of generating a mean ciphertext based on the target soil encrypted data, the target - degree ciphertext, the intermediate - degree ciphertext, and the target on - chain ciphertext includes:

[0028] Call the pre - stored lattigo algorithm library to perform ciphertext addition and mean operation on the target soil encrypted data, the target - degree ciphertext, the intermediate - degree ciphertext, and the target on - chain ciphertext to obtain the mean ciphertext.

[0029] Further, the step of reading the ciphertext with the latest upload time in the blockchain as the target ciphertext includes:

[0030] Identify the identity information of the farm alliance party server, and read the ciphertext with the latest upload time corresponding to the identity information in the blockchain as the target ciphertext.

[0031] To solve the above - mentioned technical problems, an embodiment of the present application also provides a soil data transmission system, which adopts the following technical solutions:

[0032] A soil data transmission system, the transmission system includes an API service layer, and the API service layer includes:

[0033] A receiving module, configured to receive soil data transmitted by a gateway through a port associated with a farm alliance party, wherein there is a one-to-one correspondence between the farm alliance party and the port;

[0034] A judging module, configured to determine whether the port is a newly added port according to the port number of the port;

[0035] A sending module, configured to send a homomorphic public-private key generation request to the farm alliance party server when the port is a newly added port;

[0036] A generating module, configured to receive the initial public key transmitted by the farm alliance party server, generate an initial ciphertext of a certain number of times based on the initial public key, and associatively store the port number, the initial public key, and the initial ciphertext of a certain number of times in a state database, perform a homomorphic encryption operation on the soil data through the initial public key, generate a homomorphic ciphertext, and transmit the homomorphic ciphertext to a blockchain;

[0037] An encryption module, configured to, when the port is not a newly added port, obtain the public key and the ciphertext of a certain number of times associated with the port number from the state database as an intermediate public key and an intermediate ciphertext of a certain number of times, perform a homomorphic encryption operation on the soil data through the intermediate public key to obtain target soil encrypted data, and generate a target ciphertext of a certain number of times based on the intermediate ciphertext of a certain number of times;

[0038] A transmission module, configured to obtain the ciphertext with the latest upload time in the blockchain based on the port number as a target on-chain ciphertext, generate an average ciphertext based on the target soil encrypted data, the target ciphertext of a certain number of times, the intermediate ciphertext of a certain number of times, and the target on-chain ciphertext, and transmit the average ciphertext to the blockchain;

[0039] A reading module, configured to, when receiving a ciphertext acquisition request sent by the farm alliance party server, read the ciphertext with the latest upload time in the blockchain as a target ciphertext, and transmit the target ciphertext to the farm alliance party server;

[0040] The farm alliance party server receives the target ciphertext and decrypts the target ciphertext through the locally stored private key to obtain soil average data.

[0041] To solve the above technical problems, an embodiment of the present application further provides a computer device, which adopts the following technical solutions:

[0042] A computer device includes a memory and a processor, wherein computer-readable instructions are stored in the memory, and when the processor executes the computer-readable instructions, the steps of the above-mentioned soil data transmission method are implemented.

[0043] To solve the above technical problems, an embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solutions:

[0044] A computer-readable storage medium, on which computer-readable instructions are stored, and when the computer-readable instructions are executed by a processor, the steps of the above-mentioned soil data transmission method are implemented.

[0045] Compared with the prior art, the embodiments of the present application mainly have the following beneficial effects:

[0046] The API service layer identifies different farm alliance parties through port numbers and extracts the corresponding public keys for encryption, and uses the public keys to calculate the ciphertext of the number of transmissions. While ensuring that the average value of soil data can be calculated, the confidentiality of the number of transmissions is achieved. Moreover, the API service layer only saves the homomorphic public keys generated and sent locally by the farm alliance parties, and does not save the private keys, effectively solving the problem of saving the public and private keys of each alliance party. By transmitting the finally calculated homomorphic ciphertext or average value ciphertext to the blockchain, the situation of soil data being tampered with is prevented. When receiving the ciphertext acquisition request sent by the farm alliance party server, the ciphertext data, that is, the target ciphertext, is read from the chain and sent to the farm alliance party server. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] To more clearly illustrate the solutions in the present application, the following will briefly introduce the drawings required for the description of the embodiments of the present application. Obviously, the drawings in the following description are some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0048] Figure 1 is an exemplary system architecture diagram to which the present application can be applied;

[0049] Figure 2 is a flowchart of an embodiment of the soil data transmission method according to the present application;

[0050] Figure 3 is a schematic structural diagram of an embodiment of the soil data transmission system according to the present application;

[0051] Figure 4 is a schematic structural diagram of an embodiment of the computer device according to the present application.

[0052] Figure numerals: 100, farm alliance party's soil integrated sensor; 200, gateway; 300, API service layer; 301, receiving module; 302, judgment module; 303, sending module; 304, generation module; 305, encryption module; 306, transmission module; 307, reading module; 400, farm alliance party server; 500, blockchain; 600, computer equipment; 601, memory; 602, processor; 603, network interface. DETAILED DESCRIPTION

[0053] Unless otherwise defined, all technical and scientific terms used herein have the same meanings as commonly understood by those skilled in the art to which this application belongs. The terms used in the specification of the application are for the purpose of describing specific embodiments only and are not intended to limit this application. The terms "including" and "having" and any variations thereof in the specification and claims of this application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of this application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.

[0054] References herein to "embodiments" mean that a particular feature, structure, or characteristic described in connection with the embodiments may be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0055] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.

[0056] like Figure 1 As shown, the transmission system includes the farm alliance's integrated soil sensor 100, a gateway 200, an API service layer 300, a farm alliance server 400, and a blockchain 500. The network is used as a medium to provide a communication link between the farm alliance's integrated soil sensor 100, the gateway 200, the API service layer 300, the farm alliance server 400, and the blockchain 500. The network can include various connection types, such as wired or wireless communication links or fiber optic cables.

[0057] Users can use the terminal devices corresponding to the farm alliance server to interact with the API service layer through the network to receive or send messages, etc. Various communication client applications can be installed on the terminal devices, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0058] The terminal device can be various electronic devices with a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III), MP4 (Moving Picture Experts Group Audio Layer IV) players, laptop computers, desktop computers, and so on.

[0059] The farm alliance party server 400 can be a server that provides various services, such as a background server that supports the pages displayed on the terminal device.

[0060] It should be noted that the soil data transmission method provided by the embodiments of the present application is generally executed by a soil data transmission system.

[0061] It should be understood that Figure 1 the numbers of the soil comprehensive sensors 100, gateways 200, API service layers 300, farm alliance party servers 400, and blockchains 500 of the farm alliance party in are merely illustrative. According to the implementation requirements, there can be any number of soil comprehensive sensors 100, gateways 200, API service layers 300, farm alliance party servers 400, and blockchains 500 of the farm alliance party.

[0062] Continuing to refer to Figure 2 , a flowchart showing an embodiment of the soil data transmission method according to the present application is shown. The soil data transmission method includes the following steps:

[0063] S1: The API service layer receives the soil data transmitted by the gateway through a port associated with the farm alliance party, where the farm alliance party has a one-to-one correspondence with the port.

[0064] In this embodiment, the soil comprehensive sensor of the farm alliance party collects soil data and transmits the collected soil data to the gateway. Among them, the soil data includes the nitrogen, phosphorus, and potassium content in the soil, the pH value of the soil, the humidity of the soil, and the temperature of the soil, etc. The gateway receives the soil data transmitted by the soil comprehensive sensor and sends the soil data to the port associated with the farm alliance party, that is, the designated port of the farm alliance party. In this application, each farm alliance party corresponds to a designated port, and the port transmits the soil data to the API service layer. The API service layer receives the soil data and determines whether the port is a newly added port according to the port number of the port.

[0065] This application further includes that the soil comprehensive sensor first analyzes the soil data to obtain the analyzed soil data, and sends the analyzed soil data to the gateway. The analysis process is that after installing the corresponding driver and configuring the correct com port, the pre-configured sensor monitoring software will automatically convert the high byte of the 16-bit data into the corresponding data value. For example, the soil humidity 4AH (hexadecimal) = 74 = 7.4%RH. This is convenient for subsequent encryption and calculation processes of the soil data.

[0066] In this embodiment, the electronic device (such as Figure 1 the API service layer shown) on which the soil data transmission method runs can receive the soil data transmitted by the gateway through the port associated with the farm alliance party in a wired connection manner or a wireless connection manner. It should be noted that the above wireless connection manner may include, but is not limited to, 3G / 4G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultra wideband) connection, and other currently known or future-developed wireless connection manners.

[0067] S2: The API service layer determines whether the port is a newly added port according to the port number of the port.

[0068] In this embodiment, the API service layer determines whether the port is a newly added port through the port number that has a unique corresponding relationship with the farm alliance party. It is convenient and fast to judge through the port number. If it is a newly added port, it can be known that the corresponding farm alliance party is a newly added farm alliance party. Then the API service layer realizes the identification and differentiation of the soil data collected by the Internet of Things devices (i.e., soil comprehensive sensors) of different farm alliance parties.

[0069] Specifically, in step S2, that is, the step of determining whether the port is a newly added port according to the port number of the port includes:

[0070] Query in the status database according to the port number to determine whether there is a public key and a number ciphertext corresponding to the port number;

[0071] If there is no public key and number ciphertext corresponding to the port number, it is determined that the port is a newly added port;

[0072] If there is a public key and number ciphertext corresponding to the port number, it is determined that the port is not a newly added port.

[0073] In this embodiment, when the API service layer (i.e., the API server layer) receives the port transmission request and queries the status database (i.e., the k / v database) with the port number as the key and finds no value, it determines that the port is newly added. When querying the status database (i.e., the k / v database) with the port number as the key and finding that there are a public key and a ciphertext of the number of times, it determines that the port is not newly added.

[0074] S3: If the port is a newly added port, send a request for generating homomorphic public and private keys to the farm alliance party server.

[0075] In this embodiment, the API service layer sends a request for generating homomorphic public and private keys to the farm alliance party server. The farm alliance party server receives the generation request, generates a homomorphic public and private key pair locally, transmits the generated initial public key back to the API service layer, and locally saves the private key.

[0076] S4: The API service layer receives the initial public key transmitted by the farm alliance party server, generates an initial ciphertext of the number of times based on the initial public key, and stores the port number, the initial public key, and the initial ciphertext of the number of times in an associated manner in the status database. Perform a homomorphic encryption operation on the soil data through the initial public key to generate a homomorphic ciphertext, and transmit the homomorphic ciphertext to the blockchain.

[0077] In this embodiment, the API service layer receives the public key transmitted by the farm alliance party server as the initial public key. Generate an initial ciphertext of the number of times based on the initial public key. Use the port number as the key and the initial public key and the ciphertext of the number of times as the value, and store the port number, the initial public key, and the initial ciphertext of the number of times in an associated manner in the status database (i.e., the k / v database), effectively solving the problem of storing homomorphic public keys of each farm alliance party and the privacy problem of counting the number of times during subsequent mean calculation. Perform a homomorphic encryption operation on the soil data through the initial public key to generate a homomorphic ciphertext, and transmit the homomorphic ciphertext to the blockchain.

[0078] Specifically, in step S4, that is, the step of generating the initial ciphertext of the number of times through the initial public key includes:

[0079] Perform a homomorphic encryption operation on the pre-assigned number 1 through the initial public key to obtain the initial ciphertext of the number of times.

[0080] In this embodiment, when the soil comprehensive sensor first transmits soil data to the API service layer, the initial public key encrypts the number 1, indicating the first transmission of the soil data, and generates the initial ciphertext of the number of times.

[0081] S5: If the port is not a newly added port, obtain the public key and the ciphertext of the number of times associated with the port number from the status database as the intermediate public key and the intermediate ciphertext of the number of times, perform a homomorphic encryption operation on the soil data through the intermediate public key to obtain the target encrypted soil data, and generate the target ciphertext of the number of times based on the intermediate ciphertext of the number of times.

[0082] In this embodiment, if the port is not a newly added port, it means that the corresponding soil comprehensive sensor has transmitted soil data to the API service layer before. Then, obtain the public key and the ciphertext of the number of times associated with the port number from the status database as the intermediate public key and the intermediate ciphertext of the number of times. Perform a homomorphic encryption operation on the soil data through the intermediate public key to obtain the target encrypted soil data. Generate the target ciphertext of the number of times based on the intermediate ciphertext of the number of times, and update the target ciphertext of the number of times to the status database, that is, replace the intermediate ciphertext of the number of times originally stored in the status database with the target ciphertext of the number of times. The ciphertext of the number of times in this application is continuously updated. Each time data is transmitted, a new target ciphertext of the number of times is continuously generated based on the currently stored ciphertext of the number of times in the status database. For example, if the currently stored ciphertext of the number of times is 24 times, after calculation, it becomes 25 times and needs to be updated to the status database.

[0083] In this application, the soil comprehensive sensor will transmit soil data to the gateway multiple times according to the actual situation, including soil data at sowing time, soil data at harvest time, and other actual situations.

[0084] In addition, in step S5, that is, the step of generating the target ciphertext of the number of times based on the intermediate ciphertext of the number of times includes:

[0085] Perform a homomorphic calculation operation of adding one to the intermediate ciphertext of the number of times based on the intermediate public key to obtain the target ciphertext of the number of times.

[0086] In this embodiment, each time the port is called in this application, the ciphertext of the number of times in the status database is read, and a homomorphic calculation of adding one is performed on the ciphertext of the number of times to obtain the target ciphertext of the number of times. The ciphertext of the number of times is used not only for subsequent participation in the calculation process of the mean ciphertext but also for recording the number of times of soil data upload. Each time soil data is uploaded, the ciphertext of the number of times is updated once, that is, a homomorphic calculation operation of adding one is performed on the intermediate ciphertext of the number of times to record the number of times of soil data upload.

[0087] Further, the step of performing a homomorphic calculation operation of adding one to the intermediate ciphertext of the number of times based on the intermediate public key to obtain the target ciphertext of the number of times includes:

[0088] Perform a homomorphic encryption operation on the number 1 through the intermediate public key to obtain the digital ciphertext;

[0089] Use a homomorphic computing algorithm to add the intermediate-degree ciphertext and the digital ciphertext to obtain the target-degree ciphertext.

[0090] In this embodiment, after reading the degree ciphertext in the status database, a digital public key is called to homomorphically encrypt the number 1 to obtain a digital ciphertext; a homomorphic computing algorithm is used to add the degree ciphertext and the digital ciphertext to obtain a new ciphertext, completing a single homomorphic computing operation on the degree ciphertext. Homomorphic encryption is a special encryption method that allows calculations to be performed on ciphertexts, generating ciphertext data after calculation, and the result is the same as performing relevant operations on the plaintext after decrypting the ciphertext. The purpose of homomorphic encryption is to complete data calculations without knowing the plaintext. From the perspective of abstract algebra, it maintains homomorphicity. Among them, the homomorphic computing algorithm can use the Paillier algorithm, which is a public key encryption algorithm based on the composite residue class problem proposed in 1999 and is also the most commonly used and practical additive homomorphic encryption algorithm at present, and has been implemented in many application scenarios with homomorphic encryption requirements.

[0091] S6: When the port is not a newly added port, the API service layer obtains the ciphertext with the latest upload time in the blockchain based on the port number as the target on-chain ciphertext, generates a mean ciphertext based on the target soil encrypted data, the target-degree ciphertext, the intermediate-degree ciphertext, and the target on-chain ciphertext, and transmits the mean ciphertext to the blockchain.

[0092] In this embodiment, when the port is not a newly added port, the API service layer obtains the ciphertext with the latest upload time in the blockchain based on the port number as the target on-chain ciphertext. At this time, if it is the second upload of soil data, there is no mean ciphertext in the blockchain yet, and the ciphertext with the latest upload time should be the homomorphic ciphertext. At this time, the homomorphic ciphertext is obtained as the target on-chain ciphertext. If it is the second or more times (such as the third upload or the fourth upload, etc.) of uploading soil data, the ciphertext with the latest upload time in the blockchain should be the latest mean ciphertext. At this time, the latest mean ciphertext is obtained as the target on-chain ciphertext. By generating the mean ciphertext, the ciphertext uploaded to the blockchain includes historical soil data (which can be known through the target on-chain ciphertext), the number of times the soil is uploaded (which can be known through the target-degree ciphertext), and the latest uploaded soil data (which can be known through the target soil encrypted data). It is realized that the mean ciphertext contains multi-dimensional information.

[0093] In addition, in step S6, that is, the step of generating the mean ciphertext based on the target soil encrypted data, the target-degree ciphertext, the intermediate-degree ciphertext, and the target on-chain ciphertext includes:

[0094] Call the pre-stored lattigo algorithm library to perform ciphertext addition and mean operation on the target soil encrypted data, the target ciphertext of the number of times, the intermediate ciphertext of the number of times, and the target on-chain ciphertext, and obtain the mean ciphertext.

[0095] In this embodiment, call the lattigo algorithm library to perform ciphertext addition to find the mean. The mean is calculated using the ciphertext of the number of times (including the intermediate ciphertext of the number of times and the target ciphertext of the number of times), the newly transmitted soil data ciphertext, and the on-chain data ciphertext, and the mean ciphertext is obtained and the calculated mean ciphertext is uploaded to the chain. Specifically, the calculation formula for the mean ciphertext is: (target on-chain ciphertext × intermediate ciphertext of the number of times + target soil encrypted data) / target ciphertext of the number of times. The lattigo algorithm library is a Go homomorphic encryption library based on the Lattice algebraic structure. This library contains the following sub-packages: lattigo / ring: RNS-accelerated polynomial modular arithmetic operations, including: RNS base extension; RNS rescaling; number theory transform (NTT); uniform, Gaussian, and ternary sampling. lattigo / bfv: RNS-accelerated Fan-Vercauteren version of Brakerski's scale-invariant homomorphic encryption scheme. It provides modular arithmetic of integers. lattigo / ckks: RNS-accelerated version of the approximate digital homomorphic encryption (HEAAN, also known as CKKS) scheme. It provides approximate arithmetic of complex numbers. lattigo / dbfv and lattigo / dckks: Distributed (or threshold) versions of the BFV and CKKS schemes, which can be used to implement secure multi-party computing solutions using shared secret keys. lattigo / examples: Executable Go programs demonstrating the usage of the Lattigo library. Note that each sub-package contains test files that further demonstrate the usage of Lattigo primitives. lattigo / utils: Supported structures and functions. In this application, by calling the homomorphic encryption data mean calculation algorithm in the lattigo algorithm library, ciphertext addition and mean operation are performed on the target soil encrypted data, the target ciphertext of the number of times, and the target on-chain ciphertext, and the mean ciphertext is obtained.

[0096] S7: When the API service layer receives the ciphertext acquisition request sent by the farm alliance party server, read the ciphertext with the latest upload time in the blockchain as the target ciphertext, and transmit the target ciphertext to the farm alliance party server.

[0097] In this embodiment, the ciphertext with the latest upload time in the blockchain is read as the target ciphertext. It should be noted that if the time when the ciphertext acquisition request from the farm alliance party server is received is between the first upload and the second upload of the soil data, then the ciphertext with the latest upload time in the blockchain at this time, that is, the target ciphertext, refers to the homomorphic ciphertext. If the time when the ciphertext acquisition request from the farm alliance party server is received is after the second upload of the soil data, that is, after the port is not a new port, then the ciphertext with the latest upload time in the blockchain at this time, that is, the target ciphertext, refers to the latest mean ciphertext. When the API service layer receives the ciphertext acquisition request sent by the farm alliance party, it calls the sdk to read the target ciphertext from the blockchain and transmits the target ciphertext to the farm alliance party. The farm alliance party uses the local private key to decrypt the target ciphertext to obtain the target soil data.

[0098] It should be noted that: after the mean ciphertext is transmitted to the blockchain, the on-chain ciphertext read and transmitted by the API service layer to the farm alliance party server is this mean ciphertext. The farm alliance party server receives and decrypts this mean ciphertext through the private key stored locally to obtain the target soil data. The API service layer does not store this mean ciphertext and does not need to perform additional processing operations, and only needs to transmit it to the farm alliance party server.

[0099] Specifically, in step S7, that is, the step of reading the ciphertext with the latest upload time in the blockchain as the target ciphertext includes:

[0100] Identify the identity information of the farm alliance party server, and read the ciphertext with the latest upload time corresponding to the identity information in the blockchain as the target ciphertext.

[0101] In this embodiment, the port associated with the farm alliance party is determined through the ID of the farm alliance party server. Based on this port, the ciphertext in the blockchain corresponding to the farm alliance party is determined, and then the ciphertext with the latest upload time is selected from these corresponding ciphertexts as the target ciphertext.

[0102] S8: The farm alliance party server receives the target ciphertext and decrypts the target ciphertext through the private key stored locally to obtain the soil mean data.

[0103] In this embodiment, after the farm alliance party server receives the target ciphertext transmitted by the API service layer, it decrypts the target ciphertext through the private key corresponding to the public key used to encrypt the target ciphertext to obtain the real soil mean data.

[0104] The API service layer identifies different farm alliance parties through port numbers and extracts the corresponding public keys for encryption. It uses these public keys to calculate the ciphertext of the transmission times, achieving the confidentiality of the transmission times while ensuring that the average value of soil data can be calculated. Moreover, the API service layer only stores the homomorphic public keys generated and sent locally by the farm alliance parties and does not store the private keys, effectively solving the problem of storing public and private keys for each alliance party. By transmitting the finally calculated homomorphic ciphertext or average ciphertext to the blockchain, it prevents the tampering of soil data. When receiving a ciphertext acquisition request sent by the farm alliance party server, it reads the ciphertext data, i.e., the target ciphertext, from the chain and sends it to the farm alliance party server. It realizes the whole process of soil data from collection, transmission to homomorphic calculation and then on-chain, without human intervention. The soil data does not need to be relayed through a data platform (i.e., a database) and then transmitted. The API service layer identifies or searches for the corresponding public and private keys through ports, generates the ciphertext of the number of times through the public key, encrypts the soil data through the public key, and transmits it to the blockchain. It ensures that the transmission of soil data is intervention-free, and the data transmitted to the blockchain and the process of calculating the average ciphertext are all carried out through ciphertext, protecting the privacy of the soil data of the farm alliance parties while achieving the characteristics of trustworthiness and traceability of soil data.

[0105] The blockchain referred to in this application is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, and encryption algorithm. Blockchain, in essence, is a decentralized database, a series of data blocks generated by using cryptographic methods. Each data block contains information about a batch of network transactions, used to verify the validity of the information (anti-counterfeiting) and generate the next block. The blockchain can include the blockchain underlying platform, the platform product service layer, and the application service layer, etc.

[0106] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through computer-readable instructions. These computer-readable instructions can be stored in a computer-readable storage medium. When these computer-readable instructions are executed, they can include the processes of the embodiments of the above methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a magnetic disk, an optical disk, a read-only memory (ROM), etc., or a random access memory (RAM), etc.

[0107] It should be understood that although the steps in the flowchart of the accompanying drawings are shown sequentially in the direction of the arrows, these steps are not necessarily executed sequentially in the order indicated by the arrows. Unless there is a clear indication in this document, there is no strict order restriction for the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed alternately or in turn with at least a part of other steps or sub-steps or stages of other steps.

[0108] Further reference is made to Figure 3 , as an implementation of the method shown above Figure 2 , this application provides an embodiment of a soil data transmission system. This system embodiment corresponds to Figure 2 the method embodiment shown, and this system can be specifically applied to various electronic devices.

[0109] As shown in Figure 3 , the soil data transmission system described in this embodiment includes an API service layer 300 and a farm alliance party server 400. The API service layer 300 includes: a receiving module 301, a judging module 302, a sending module 303, a generating module 304, an encrypting module 305, a transmitting module 306, and a reading module 307;

[0110] A receiving module 301, configured to receive soil data transmitted by a gateway through a port associated with a farm alliance party, wherein there is a one-to-one correspondence between the farm alliance party and the port; a determining module 302, configured to determine whether the port is a newly added port according to the port number of the port; a sending module 303, configured to send a homomorphic public-private key generation request to the farm alliance party server when the port is a newly added port; a generating module 304, configured to receive an initial public key transmitted by the farm alliance party server, generate an initial number ciphertext based on the initial public key, and associatively store the port number, the initial public key, and the initial number ciphertext in a status database, perform a homomorphic encryption operation on the soil data through the initial public key, generate a homomorphic ciphertext, and transmit the homomorphic ciphertext to a blockchain; an encrypting module 305, configured to, when the port is not a newly added port, obtain a public key and a number ciphertext associated with the port number from the status database as an intermediate public key and an intermediate number ciphertext, perform a homomorphic encryption operation on the soil data through the intermediate public key to obtain target soil encrypted data, and generate a target number ciphertext based on the intermediate number ciphertext; a transmitting module 306, configured to, when the port is not a newly added port, obtain the ciphertext with the latest upload time in the blockchain based on the port number as a target on-chain ciphertext, generate a mean ciphertext based on the target soil encrypted data, the target number ciphertext, the intermediate number ciphertext, and the target on-chain ciphertext, and transmit the mean ciphertext to the blockchain; a reading module 307, configured to, when receiving a ciphertext acquisition request sent by the farm alliance party server, read the ciphertext with the latest upload time in the blockchain as a target ciphertext, and transmit the target ciphertext to the farm alliance party server; The farm alliance party server 400 receives the target ciphertext and decrypts the target ciphertext through a locally stored private key to obtain soil mean data

[0111] In this embodiment, the API service layer identifies different farm alliance parties through port numbers and extracts the corresponding public keys for encryption, and uses the public keys to calculate the ciphertext of the transmission times. While ensuring that the mean value of the soil data can be calculated, the confidentiality of the transmission times is achieved. Moreover, the API service layer only saves the homomorphic public keys generated and sent locally by the farm alliance parties and does not save the private keys, effectively solving the problem of saving the public and private keys of each alliance party. By transmitting the finally calculated homomorphic ciphertext or mean ciphertext to the blockchain, the situation of the soil data being tampered with is prevented. When receiving a ciphertext acquisition request sent by the farm alliance party server, the ciphertext data, that is, the target ciphertext, is read from the chain and sent to the farm alliance party server.

[0112] The determination module 302 includes a query sub-module, a first determination sub-module, and a second determination sub-module. Among them, the query sub-module is used to query in the status database according to the port number to determine whether there is a public key and a number ciphertext corresponding to the port number; the first determination sub-module is used to determine that the port is a newly added port when there is no public key and number ciphertext corresponding to the port number; the second determination sub-module is used to determine that the port is not a newly added port when there is a public key and number ciphertext corresponding to the port number.

[0113] In some optional implementation manners of this embodiment, the generation module 304 is further configured to: perform a homomorphic encryption operation on the pre-assigned number 1 through the initial public key to obtain the initial number ciphertext.

[0114] In some optional implementation manners of this embodiment, the encryption module 305 is further configured to: perform a one-time homomorphic calculation operation on the intermediate number ciphertext based on the intermediate public key to obtain the target number ciphertext.

[0115] Among them, the encryption module 305 includes an encryption sub-module and an addition sub-module. Among them, the encryption sub-module is used to perform a homomorphic encryption operation on the number 1 through the intermediate public key to obtain a number ciphertext; the addition sub-module is used to perform an addition operation on the intermediate number ciphertext and the number ciphertext using a homomorphic calculation algorithm to obtain the target number ciphertext.

[0116] In some optional implementation manners of this embodiment, the transmission module 306 is further configured to call the pre-stored lattigo algorithm library to perform a ciphertext addition and averaging operation on the target soil encrypted data, the target number ciphertext, the intermediate number ciphertext, and the target on-chain ciphertext to obtain the average ciphertext.

[0117] In some optional implementation manners of this embodiment, the reading module 307 is further configured to identify the identity information of the farm alliance party server, and read the ciphertext with the latest upload time corresponding to the identity information in the blockchain as the target ciphertext.

[0118] The API service layer identifies different farm alliance parties through port numbers and extracts the corresponding public keys for encryption. It uses these public keys to calculate the ciphertext of the transmission times, achieving the confidentiality of the transmission times while ensuring that the average value of soil data can be calculated. Moreover, the API service layer only stores the homomorphic public keys generated and sent locally by the farm alliance parties and does not store the private keys, effectively solving the problem of storing public and private keys for each alliance party. By transmitting the finally calculated homomorphic ciphertext or average value ciphertext to the blockchain, it prevents the soil data from being tampered with. When receiving a ciphertext acquisition request sent by the farm alliance party server, it reads the ciphertext data, i.e., the target ciphertext, from the chain and sends it to the farm alliance party server.

[0119] To solve the above technical problems, the embodiments of the present application also provide a computer device. For details, please refer to Figure 4 , Figure 4 which is the basic structural block diagram of the computer device in this embodiment.

[0120] The computer device 600 includes a memory 601, a processor 602, and a network interface 603 that communicate with each other through a system bus. It should be noted that only the computer device 600 with components 601 - 603 is shown in the figure, but it should be understood that it is not required to implement all the shown components, and more or fewer components can be implemented alternatively. Among them, those skilled in the art of this technology can understand that a computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.

[0121] The computer device can be a desktop computer, a notebook, a palm computer, a cloud server, and other computing devices. The computer device can interact with users through a keyboard, a mouse, a remote control, a touchpad, a voice control device, or other means.

[0122] The memory 601 at least includes one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (such as SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 601 may be an internal storage unit of the computer device 600, such as the hard disk or memory of the computer device 600. In other embodiments, the memory 601 may also be an external storage device of the computer device 600, such as a plug-in hard disk equipped on the computer device 600, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. Of course, the memory 201 may also include both the internal storage unit of the computer device 600 and its external storage device. In this embodiment, the memory 601 is generally used to store the operating system installed on the computer device 600 and various application software, such as computer-readable instructions of the soil data transmission method, etc. In addition, the memory 601 may also be used to temporarily store various data that have been output or will be output.

[0123] In some embodiments, the processor 602 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips. The processor 602 is generally used to control the overall operation of the computer device 600. In this embodiment, the processor 602 is used to run the computer-readable instructions stored in the memory 601 or process data, such as running the computer-readable instructions of the soil data transmission method.

[0124] The network interface 603 may include a wireless network interface or a wired network interface, and the network interface 603 is generally used to establish a communication connection between the computer device 600 and other electronic devices.

[0125] This application also provides another implementation manner, that is, to provide a computer-readable storage medium, and the computer-readable storage medium stores computer-readable instructions, and the computer-readable instructions can be executed by at least one processor, so that the at least one processor executes the steps of the soil data transmission method as described above.

[0126] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-described embodiment methods can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions for causing a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in various embodiments of the present application.

[0127] Obviously, the above-described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The accompanying drawings show the preferred embodiments of the present application, but do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosed content of the present application more thorough and comprehensive. Although the present application has been described in detail with reference to the foregoing embodiments, for those skilled in the art, they can still modify the technical solutions described in the foregoing specific embodiments, or perform equivalent replacements on some of the technical features. Any equivalent structure directly or indirectly using the content of the specification and drawings of the present application in other related technical fields is equally within the scope of the patent protection of the present application.

Claims

1. A soil data transmission method, characterized in that: The steps include: The API service layer receives soil data transmitted by the gateway through a port associated with a farm alliance party, wherein the farm alliance party and the port have a one-to-one association relationship; The API service layer determines whether the port is a newly added port based on the port number of the port; If the port is a newly added port, a request for generating homomorphic public and private keys is sent to the farm alliance server; The API service layer receives the initial public key transmitted by the farm alliance server, generates an initial ciphertext based on the initial public key, associates the port number, the initial public key and the initial ciphertext and stores them in a state database, performs a homomorphic encryption operation on the soil data using the initial public key to generate a homomorphic ciphertext, and transmits the homomorphic ciphertext to the blockchain; If the port is not a newly added port, the public key and the ciphertext associated with the port number are obtained from the state database as the intermediate public key and the intermediate ciphertext, and the soil data is homomorphically encrypted using the intermediate public key to obtain the target soil encrypted data, and the target ciphertext is generated based on the intermediate ciphertext; When the port is not a newly added port, the API service layer obtains the ciphertext with the latest upload time in the blockchain based on the port number as the target chain ciphertext, generates an average ciphertext based on the target soil encrypted data, the target number ciphertext, the intermediate number ciphertext and the target chain ciphertext, and transmits the average ciphertext to the blockchain; When the API service layer receives the ciphertext acquisition request sent by the farm alliance server, it reads the ciphertext with the latest upload time in the blockchain as the target ciphertext, and transmits the target ciphertext to the farm alliance server; The farm alliance server receives the target ciphertext and decrypts the target ciphertext using a locally stored private key to obtain soil mean data; The step of generating the mean ciphertext based on the target soil encrypted data, the target number of ciphertexts, the intermediate number of ciphertexts, and the target chain ciphertext comprises: The pre-stored lattigo algorithm library is called to perform ciphertext addition and average operation on the target soil encryption data, the target number of ciphertexts, the intermediate number of ciphertexts and the target chain ciphertext to obtain the average ciphertext.

2. The soil data transmission method according to claim 1, characterized in that: The step of generating an initial ciphertext using the initial public key comprises: The initial public key is used to perform a homomorphic encryption operation on the pre-assigned number 1 to obtain the initial ciphertext.

3. The soil data transmission method according to claim 1, characterized in that: The step of generating a target-order ciphertext based on the intermediate-order ciphertext comprises: Based on the intermediate public key, a homomorphic computation operation is performed on the intermediate ciphertext to obtain the target ciphertext.

4. The soil data transmission method according to claim 3, characterized in that: The step of performing a homomorphic computation operation on the intermediate ciphertext based on the intermediate public key to obtain the target ciphertext comprises: Performing a homomorphic encryption operation on the number 1 using the intermediate public key to obtain a digital ciphertext; A homomorphic computing algorithm is used to add the intermediate ciphertext and the digital ciphertext to obtain the target ciphertext.

5. The soil data transmission method according to claim 1, characterized in that: The step of determining whether the port is a newly added port according to the port number of the port includes: Searching the state database according to the port number to determine whether there is a public key and a ciphertext corresponding to the port number; If there is no public key and ciphertext corresponding to the port number, determining that the port is a newly added port; If there is a public key and a ciphertext corresponding to the port number, it is determined that the port is not a newly added port.

6. The soil data transmission method according to claim 1, characterized in that: The steps of reading the ciphertext with the latest upload time in the blockchain as the target ciphertext include: Identify the identity information of the farm alliance server, and read the ciphertext with the latest upload time corresponding to the identity information in the blockchain as the target ciphertext.

7. A soil data transmission system, characterized in that: The transmission system includes an API service layer and a farm alliance server. The API service layer includes: A receiving module, configured to receive soil data transmitted by a gateway through a port associated with a farm alliance party, wherein the farm alliance party and the port have a one-to-one association relationship; A judgment module, configured to determine whether the port is a newly added port according to the port number of the port; A sending module, configured to send a homomorphic public and private key generation request to the farm alliance server when the port is a newly added port; A generation module is configured to receive an initial public key transmitted by the farm alliance server, generate an initial ciphertext based on the initial public key, associate the port number, the initial public key, and the initial ciphertext and store them in a state database, perform a homomorphic encryption operation on the soil data using the initial public key to generate a homomorphic ciphertext, and transmit the homomorphic ciphertext to the blockchain; an encryption module configured to, when the port is not a newly added port, obtain a public key and a ciphertext associated with the port number from a state database as an intermediate public key and an intermediate ciphertext, perform a homomorphic encryption operation on the soil data using the intermediate public key to obtain target soil encrypted data, and generate a target ciphertext based on the intermediate ciphertext; A transmission module is configured to obtain the ciphertext with the latest upload time in the blockchain based on the port number, use it as the target chain ciphertext, generate an average ciphertext based on the target soil encryption data, the target number ciphertext, the intermediate number ciphertext and the target chain ciphertext, and transmit the average ciphertext to the blockchain; A reading module is configured to, upon receiving a ciphertext acquisition request sent by the farm alliance server, read the ciphertext with the latest upload time in the blockchain as the target ciphertext, and transmit the target ciphertext to the farm alliance server; The farm alliance server is configured to receive the target ciphertext and decrypt the target ciphertext using a locally stored private key to obtain soil mean data; The transmission module is also used to call the pre-stored lattigo algorithm library to perform ciphertext addition and average operation on the target soil encryption data, the target number of ciphertexts, the intermediate number of ciphertexts and the target chain ciphertext to obtain the average ciphertext.

8. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores computer-readable instructions, and when the processor executes the computer-readable instructions, the steps of the soil data transmission method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of the soil data transmission method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Soil improvement tracking detection system based on blockchain

    CN109358177A

  • Agricultural product traceability information sharing-privacy protection method and system

    CN111859446A