# Application of Edge Computing and Blockchain in Smart Agriculture System

Authors: Yuhan Feng
Journal: Mathematical Problems in Engineering
 (2022)

---

## Abstract

The development of Internet technology provides a lot of convenience for the promotion of smart agriculture. At present, smart agriculture has gradually realized unmanned and automatic management, which can realize monitoring, supervision, and real-time image monitoring. However, the data in smart agriculture system cannot be guaranteed to be complete and vulnerable to attack. Based on this, this paper studies and analyzes the application of edge computing and blockchain in smart agriculture systems. Based on the simple analysis of the development of smart agriculture, the edge computing framework and the advantages of blockchain are used to build the framework system of smart agriculture. The classical architecture of edge computing and the confidentiality of blockchain are used to realize the analysis and storage of data. In view of the shortcomings of crop image overlap detection, it is proposed to detect the overlapping area and determine the feature points to analyze the image based on the edge computing and hash algorithm. In terms of data integrity, based on the advantages of blockchain, an edge data detection method based on short signature is proposed, and experiments are designed to analyze the accuracy and effectiveness of the algorithm. The simulation results show that the image mosaic algorithm can extract the contour information of the image and realize the fast image matching. The edge data integrity calculation based on short signature can meet the requirements and shorten the response time.


---

## Body

## 1. Introduction

Compared with traditional agriculture, smart agriculture makes comprehensive use of cloud computing and sensor technology, which has high efficiency and has attracted much attention. In the development of smart agriculture, the intelligent system is used to replace the traditional field inspection, which reduces the waste of resources and optimizes agricultural products and agricultural services [1]. In the smart agriculture system, big data are generally stored in the database, which is based on the Internet of things. In the development of agricultural information platform, sensor technology provides great convenience for the implementation of remote monitoring [2]. At present, the research on smart agriculture system focuses on large fields, such as the construction of big data platform, the operation mode of smart agriculture, and the application of Internet of things [3]. Few can analyze the information covered by the data from the perspective of data information [4]. Moreover, in the agricultural system, the data in the database is easy to be leaked, which is unfavorable to agricultural development. As a digital currency technology, blockchain has attracted attention because of its decentralized security record, which can ensure the security of data, but the storage capacity is insufficient [5]. Edge computing technology can make up for the shortcomings of blockchain.Based on this background, this paper studies the application of edge computing and blockchain in smart agriculture system, which is mainly divided into four sections. Section1 briefly introduces the smart agriculture system, the existing research situation of smart agriculture, and the chapters of this study; Section 2 analyzes the application of smart agricultural technology, edge computing, and blockchain algorithm; analyzes the common application fields and improvement methods of the algorithm; and summarizes the shortcomings of the current research. Section 3 constructs a smart agriculture system based on edge computing and blockchain to realize the storage and security of data and ensure that the data are not easy to be tampered with. In the image data processing, aiming at the shortcomings of the edge algorithm, this paper improves the algorithm based on the Hash algorithm to detect the overlapping area of the image and match the feature points in a specific area. At the same time, in order to ensure the integrity of data, an edge data inspection algorithm based on short signature is proposed. In Section 4, the algorithm proposed in this paper is simulated and analyzed and the response time and image similarity of the algorithm are measured. The simulation results show that compared with the traditional algorithm, the proposed algorithm has a shorter response time and higher image similarity. On the basis of ensuring the quality, it can shorten the time and improve the detection efficiency.The innovation of this paper lies in the design of an intelligent agriculture system and the improvement of the algorithm. Edge computing and blockchain are introduced into the intelligent agriculture system. At the same time, the advantages of both are used to supplement the shortcomings, ensure the integrity and nontamperability of data, experiment with the problem of data storage, and provide a reference for the traceability of agricultural products. On the other hand, in the algorithm improvement, aiming at the problem of crop growth image, a stitching algorithm of perceptual Hash coincidence region detection is proposed to realize the matching of feature points, which can provide data support for the development of agriculture.


## 2. State of the Art

With the development of Internet of Things technology, intelligent agriculture has developed rapidly. In their research, Colao et al. pointed out that, under the background of intelligent agricultural development, most sensor-based decision tools supporting fertilizer management rely on a simple mechanical framework usually notified by a single sensor, and the decision-making system also needs to make corresponding changes. They proposed options based on commercial sensors and a novel, multivariable, and data-driven method [6]. Horng et al. analyzed the development of smart agriculture from a technical point of view and proposed an acquisition system based on Internet of Things technology and intelligent image recognition. Using the image recognition system, the crop maturity is determined through target detection through a training neural network model, and then the mature crops are harvested by a robot arm [7]. When mobile terminals enter people’s daily life, the distance between the central cloud and terminal equipment is far, and conventional cloud computing is difficult to meet the needs of users. Edge computing technology can solve these problems. Although edge computing can reduce the burden of ECS (Elastic Compute Service), it is also vulnerable to attack, which has been studied by many scholars. In their research, Nhat-Duc et al. combined a convolutional neural network with an edge calculation algorithm for automatic pavement crack identification to improve the effectiveness of single edge calculation algorithm detection [8]. For the blurred image, Dhivya et al. segmented the image into multiple parts through a binary matrix, and the pixels at the edge were planned as a series of separate standards [9]. Yu et al. proposed an improved Canny algorithm based on morphology in the edge calculation of agricultural products. The opening and closing operation of morphology is used to replace the Gaussian filter to form a morphological filter to remove image noise, strengthen the protection of image edges, improve the traditional Canny operator, increase the horizontal and vertical templates to 45° and 135°, respectively, to improve the edge positioning of the image, and use the adaptive threshold segmentation method for rough segmentation. On this basis, double detection thresholds are used for further segmentation to obtain the final edge points [10]. Xiao et al. used software-defined network (SDN), edge computing, blockchain, Bayesian network, and other technologies in their research. The blockchain server accommodates the reports submitted by vehicles, calculates the probability of traffic events, and provides time sensitive services for passing vehicles [11]. Huang et al. proposed a blockchain system to adapt to the limitations of edge devices, found the best peer node for transaction data storage, proposed a block storage allocation scheme for fast retrieval of missing blocks, and developed a data migration algorithm to dynamically reallocate data and block storage to adapt to the changes of network topology [12]. Taking advantage of the security advantages provided by the blockchain, Hammi et al. proposed an original decentralized system to ensure the robust identification and authentication of equipment and protect the integrity and availability of data [13]. Polina et al. proposed a roadmap for a blockchain-based decentralized personal health data ecosystem. A secure and transparent distributed personal data market using blockchain and deep learning technology may be able to solve the challenges faced by regulators and return control over personal data (including medical records) to individuals [14].To sum up, we can see that there are many research studies on edge computing at present. The development research of intelligent agriculture covers Internet of Things technology, sensors, etc., but ignores the research on data. As relatively novel algorithms, edge computing and blockchain have great advantages in data analysis, and they also have their own shortcomings. These two technologies also have a lot in mobile network research. Edge computing focuses on image detection. The advantages of blockchain are mostly used in data analysis, with many application fields, but rarely used in the field of intelligent agriculture. Therefore, it is of great significance to study the application of edge computing and blockchain in smart agriculture system.


## 3. Methodology

### 3.1. Intelligent Agriculture System Design

Confidentiality of data means that authenticated and authorized users should ensure that the data are accurate and correct when accessing the data. Ensure that only authorized users and processes can modify data through approved methods. The data integrity risk in the construction of the smart clothing industry mainly involves the modification of agricultural data. It will cause food safety problems, affect the trading order of the agricultural products market, even cause social panic, and cause a hit to national security and social stability. Data leakage may cause a large number of key equipment to make wrong operations, resulting in too many or too few automatic ports, excessive pesticide spraying, or large errors in environmental monitoring that can seriously affect agricultural economic benefits. In addition, if important statistical monitoring data such as agricultural production conditions, agricultural production statistics, and agricultural economic benefit statistics are illegally changed, the scientificity and accuracy of relevant reform policies may be reduced. In the design of a smart agriculture system, in addition to storing corresponding data, it is also necessary to ensure the integrity and confidentiality of data. With the rise of digital currency, blockchain is widely used because of its own security records, such as Internet of Things, medical field, data storage, financial statistics, and other fields. Different fields have their own business processes. Although the blockchain itself has many advantages, it also has some shortcomings. For example, the scalability of the blockchain is not strong, and the number of users that can be supported by expanding the scale of the blockchain network needs to be improved. In terms of delay, the realization of the functions of the blockchain itself depends on the consensus reached, so the response time is long.In this paper, blockchain is combined with edge computing. The construction of smart agriculture system architecture is shown in Figure1. The classic architecture of edge computing is adopted in the architecture design [15]. Blockchain is developed based on a P2P network and uses a signature algorithm in cryptography to encrypt digital [16]. The system combines wireless sensor technology, IPFs mechanism, and edge algorithm. It is mainly divided into three layers, which can realize the collection, upload, analysis, and storage of crop data. The application of blockchain can ensure that the information will not be changed and the integrity of data.Figure 1
Smart agriculture architecture design.In the design of an intelligent agriculture framework, the physical layer is the top layer, which mainly realizes data collection. In the physical layer, various sensors and cameras are mainly used to collect and collect agricultural information to form a local area network [17]. The edge gateway mainly realizes the analysis of data and stores and uploads these pieces of information to the LAN. The data will be uploaded to the application layer in JSON format. In the data service layer, it is mainly used to store information, mainly including edge computing and blockchain. This service layer cannot realize computing, and the data transmitted from the physical layer are backed up in this layer. The edge gateway mainly realizes computing and can reduce the delay time [18]. In the data storage, select JSON format, and the blockchain saves the transaction form. In this system design, because only the hash value of the file is stored, the file information cannot be obtained even if it is attacked, which can ensure the integrity of the data. In addition, the storage Hash of data is constructed by leaf nodes, and whether the information has been modified can be seen by comparing and analyzing the Hash value data. The application layer can store and query files, covering cloud servers and IPFs. During file storage, the data are uploaded from the edge gateway to the cloud, the edge calculates the file storage file, stores the data information in the cloud and can even realize point-to-point storage. The files of each node form a Hash table and finally send the information to the query users through the cloud. In this blockchain design, only the edge calculation file needs to be saved.


### 3.2. Hash Algorithm Based on Crop Image

This paper makes full use of the small UAV equipped with a color camera in the process of obtaining crop images. The important RGB images obtained by UAV remote sensing technology are studied, and the relevant indexes are constructed by using the band reflection characteristics and band absorption characteristics of plants. Smart agriculture system can not only store information but also process information to help the development of agriculture. In crop growth, the disease is a problem that can not be ignored. Different pictures will be formed in different states of crops. Effective analysis of these pictures can analyze the growth state of crops and find the diseases in time. The monitoring of crop growth can be realized by splicing crop sequence images and mining data. Through image processing, we can evaluate the planting area of crops and the disaster and epidemic situation. In addition, image mosaic is also of great value for crop species identification and quality detection.In image processing, image gradient (frequency domain information) can reflect the change of gray level. For the image, the edge information is the area where the gray information of the image changes the most, that is, the high-frequency part. Secondly, the noise also belongs to the high-frequency information, and the other parts are the low-frequency part [19]. Therefore, the performance of the high-frequency part of the image can be analyzed accordingly. Assuming that there is M×N image fx,y, it can be described by the two-dimensional Fourier transform formula.(1)Fu,v=∑x=0M−1∑y=0N−1fx,ygx,y,u,vfu,v=∑u=0M−1∑v=0N−1Fx,yhx,y,u,v.Here,gx,y,u,v represents the positive transformation kernel, and hx,y,u,v represents the inverse transformation kernel. The data image itself belongs to a real matrix. In order to simplify the calculation, the formula can be changed to matrix form, expressed as follows:(2)Fu,v=∑x=0M−1∑y=0N−1Px,ufx,yQy,v=PfQ,where F represents M×N matrix, P represents M×M matrix, and Q represents N×N matrix.The hash function can generate nonreversible digital information from the original data and has uniqueness. It maps the input data into a hash code with constant length [20]. Perceptual hash should be robust, and it is required to generate the same perceptual summary when the content is the same; it has unique characteristics. For the same image, the perceptual summary required to be generated is different from other images; it is brief and requires that the generated perceptual summary should be as concise as possible. In the detection of image coincidence area algorithm, the perceptual hash algorithm is widely used. This algorithm has good results in analyzing scale, proportion change, and brightness, but it also has its own limitations. When the image rotation angle is large, the Hash algorithm has weak stability and insufficient accuracy. Therefore, this algorithm needs to be improved to make it more suitable for general images [21]. In the improvement, the image normalization processing method is adopted to reduce the computational complexity on the basis of ensuring the data information. Among the various algorithms related to image scanning, the invariant moment was proposed earlier. It is considered that the overall information of the content can be described by low-order moments, such as shape and contour, but many details are vulnerable to high-order influence. Therefore, it is considered that the surface features of the image can be represented by invariant moments. Assuming that the size of the image is M×N, the p+q order geometric moment can be expressed as follows:(3)mpq=∑x=0N1−1∑y=0N2−1xpypfx,y,where mpq is the geometric moment. The center distance can be expressed as follows:(4)upq=∑x=0N1−1∑y=0N2−1x−x−py−y−qfx,y,where upq represents the central moment, x¯,y¯ represents the centroid coordinate, and there is x¯=m10/m00andy¯=m01/m00 in the centroid coordinate. According to this theory, the image is normalized, and the coordinate transformation, shear transformation, scaling, and rotation are normalized in turn. It can be regarded as the affine transformation of decomposition, and the formula is as follows:(5)xy=A⋅x/y/+D.First, centralize the original image, cut, and transform thex direction, and the parameters β meet the following conditions:(6)u302=u201+3βu211+3β2u121+β3u031.The same method is used fory direction shear transformation. The corresponding amplitude is transformed according to the set scale parameters, and the image is normalized to generate image perception features.


### 3.3. Edge Computation Based on Short Signature

In order to ensure the integrity of data in mobile edge computing, it generally needs to be cached. This is the simplest way, but it will have network overhead and increase the response time. If it needs to be backed up regularly, it is also easy to cause some data loss. With the continuous emergence of edge mobile devices, the difficulty of cloud data computing and transmission is gradually increasing. Edge computing is a new computing method, which can deploy services near mobile terminals and process data. However, it will also cause the increase of server cache, which leads to the increase of destructiveness and affect the data integrity. Introducing third-party design is one of the common ways to analyze data integrity, but if there is malicious TPA (file extension in this article), it will directly affect the data analysis results. If edge caching is adopted, it also has many advantages. It needs low cost and is suitable for long-term storage. The time between the equipment and the base station can be communicated quickly. However, this method needs to regularly store the information to a certain physical location to avoid data loss. Compared with ECS, there are many base stations and the data are easy to be stolen.Edge data are generally introduced into TPA to perform authentication and send data according to the user request. However, not all TPAs are completely credible and the accuracy of the results cannot be guaranteed [22]. At present, the research on data integrity is based on server data verification. Only by realizing interaction, we can ensure data integrity. However, in edge computing, the user’s data come from the edge database, and the integrity itself is insufficient. Therefore, it is difficult to supplement the data through cloud computing [23]. For the untrusted problem in edge computing, the area chain technology is used for decentralization, as shown in Figure 2. Different users initiate data integrity verification. The edge node is not on the server, and the mobile phone information is sent to the smart contract for verification. Cloud services store large-scale files and send missing data to TPS (transaction processing system) for verification. A smart contract is the executor of verification.Figure 2
Decentralization of regional chain technology.An edge database is a small database, which is vulnerable to attack. On the basis of considering data integrity, we also need to consider the problem of delay. Therefore, this paper considers different situations in the analysis. Zsdiv-mec is divided into several steps in the calculation. In the data defect, it needs to be divided into three cases: unilateral defect, multilateral defect, and the combination of multilateral and cloud. Different cases need to be treated differently.Suppose that theq cyclic addition and subtraction group is represented by G1, p is the generating set, and the cyclic multiplication group is represented by G2. The bilinear mapping is established, and the segment signature secure Hash function is selected for calculation. Consumers choose their own private key and calculate the public key, which is represented by Y. The data are divided into blocks of equal length according to the user file F. These lengths can be expressed as follows:(7)δi=1Hmi+αP.The signature set of the fileF is obtained according to this formula, and then the consumer uploads the data file. These pieces of information will be sent to the smart contract, and the consumer requests to query the data integrity. Assuming that the consumer extracts c elements, the constructed data set is represented by I, generates a random function, and sends the random value and index to the nearest interedge node. When analyzing data integrity, it needs to be divided into different situations. In case of a unit defect, the provider will calculate after receiving and querying the information. The formula is(8)R=∑i=s1seviY,u=∑i=s1seviHmiP,η=P−P2∑i=s1seviHmiP.The edge node feeds back the data directly to the smart contract. If it is a multilateral case, the data block of the above method is insufficient and the nodes need to be used to calculate the surrounding nodes [24]. Suppose there are t edge nodes, and the data block index set of each node is represented by Oj. These edge nodes can provide effective index sets, which are expressed as follows:(9)Ij=1−l∩O1∪O2∪O3∪…∪Oj−1∩Oj.If the conditionO1∪O2∪O3∪…∪Ot−1∪Ot=1 is satisfied, this point is considered to be the last edge node. If lj=s1,s2,…,sej exists,(10)R=∑j=1t∑i=s1sejviY,u=∑j=1t∑i=s1sejviHmiP,η=P−P2∑j=1t∑i=s1sejvisi.The last node obtained is fed back to the smart contract. The third case is the combination of multilateral and cloud. Due to the dissatisfaction of a single edge point and nearby nodes, you need to turn to the central cloud, find the missing data after passing, repeat the above calculation again, and feed back the results to the smart contract. This formula is as follows:(11)eη,P⋅eu+R,p=ep,pIf it can be established, it is considered that the data is complete. Then, take true as the verification result; otherwise, the false result will be directly output.


## 3.1. Intelligent Agriculture System Design

Confidentiality of data means that authenticated and authorized users should ensure that the data are accurate and correct when accessing the data. Ensure that only authorized users and processes can modify data through approved methods. The data integrity risk in the construction of the smart clothing industry mainly involves the modification of agricultural data. It will cause food safety problems, affect the trading order of the agricultural products market, even cause social panic, and cause a hit to national security and social stability. Data leakage may cause a large number of key equipment to make wrong operations, resulting in too many or too few automatic ports, excessive pesticide spraying, or large errors in environmental monitoring that can seriously affect agricultural economic benefits. In addition, if important statistical monitoring data such as agricultural production conditions, agricultural production statistics, and agricultural economic benefit statistics are illegally changed, the scientificity and accuracy of relevant reform policies may be reduced. In the design of a smart agriculture system, in addition to storing corresponding data, it is also necessary to ensure the integrity and confidentiality of data. With the rise of digital currency, blockchain is widely used because of its own security records, such as Internet of Things, medical field, data storage, financial statistics, and other fields. Different fields have their own business processes. Although the blockchain itself has many advantages, it also has some shortcomings. For example, the scalability of the blockchain is not strong, and the number of users that can be supported by expanding the scale of the blockchain network needs to be improved. In terms of delay, the realization of the functions of the blockchain itself depends on the consensus reached, so the response time is long.In this paper, blockchain is combined with edge computing. The construction of smart agriculture system architecture is shown in Figure1. The classic architecture of edge computing is adopted in the architecture design [15]. Blockchain is developed based on a P2P network and uses a signature algorithm in cryptography to encrypt digital [16]. The system combines wireless sensor technology, IPFs mechanism, and edge algorithm. It is mainly divided into three layers, which can realize the collection, upload, analysis, and storage of crop data. The application of blockchain can ensure that the information will not be changed and the integrity of data.Figure 1
Smart agriculture architecture design.In the design of an intelligent agriculture framework, the physical layer is the top layer, which mainly realizes data collection. In the physical layer, various sensors and cameras are mainly used to collect and collect agricultural information to form a local area network [17]. The edge gateway mainly realizes the analysis of data and stores and uploads these pieces of information to the LAN. The data will be uploaded to the application layer in JSON format. In the data service layer, it is mainly used to store information, mainly including edge computing and blockchain. This service layer cannot realize computing, and the data transmitted from the physical layer are backed up in this layer. The edge gateway mainly realizes computing and can reduce the delay time [18]. In the data storage, select JSON format, and the blockchain saves the transaction form. In this system design, because only the hash value of the file is stored, the file information cannot be obtained even if it is attacked, which can ensure the integrity of the data. In addition, the storage Hash of data is constructed by leaf nodes, and whether the information has been modified can be seen by comparing and analyzing the Hash value data. The application layer can store and query files, covering cloud servers and IPFs. During file storage, the data are uploaded from the edge gateway to the cloud, the edge calculates the file storage file, stores the data information in the cloud and can even realize point-to-point storage. The files of each node form a Hash table and finally send the information to the query users through the cloud. In this blockchain design, only the edge calculation file needs to be saved.


## 3.2. Hash Algorithm Based on Crop Image

This paper makes full use of the small UAV equipped with a color camera in the process of obtaining crop images. The important RGB images obtained by UAV remote sensing technology are studied, and the relevant indexes are constructed by using the band reflection characteristics and band absorption characteristics of plants. Smart agriculture system can not only store information but also process information to help the development of agriculture. In crop growth, the disease is a problem that can not be ignored. Different pictures will be formed in different states of crops. Effective analysis of these pictures can analyze the growth state of crops and find the diseases in time. The monitoring of crop growth can be realized by splicing crop sequence images and mining data. Through image processing, we can evaluate the planting area of crops and the disaster and epidemic situation. In addition, image mosaic is also of great value for crop species identification and quality detection.In image processing, image gradient (frequency domain information) can reflect the change of gray level. For the image, the edge information is the area where the gray information of the image changes the most, that is, the high-frequency part. Secondly, the noise also belongs to the high-frequency information, and the other parts are the low-frequency part [19]. Therefore, the performance of the high-frequency part of the image can be analyzed accordingly. Assuming that there is M×N image fx,y, it can be described by the two-dimensional Fourier transform formula.(1)Fu,v=∑x=0M−1∑y=0N−1fx,ygx,y,u,vfu,v=∑u=0M−1∑v=0N−1Fx,yhx,y,u,v.Here,gx,y,u,v represents the positive transformation kernel, and hx,y,u,v represents the inverse transformation kernel. The data image itself belongs to a real matrix. In order to simplify the calculation, the formula can be changed to matrix form, expressed as follows:(2)Fu,v=∑x=0M−1∑y=0N−1Px,ufx,yQy,v=PfQ,where F represents M×N matrix, P represents M×M matrix, and Q represents N×N matrix.The hash function can generate nonreversible digital information from the original data and has uniqueness. It maps the input data into a hash code with constant length [20]. Perceptual hash should be robust, and it is required to generate the same perceptual summary when the content is the same; it has unique characteristics. For the same image, the perceptual summary required to be generated is different from other images; it is brief and requires that the generated perceptual summary should be as concise as possible. In the detection of image coincidence area algorithm, the perceptual hash algorithm is widely used. This algorithm has good results in analyzing scale, proportion change, and brightness, but it also has its own limitations. When the image rotation angle is large, the Hash algorithm has weak stability and insufficient accuracy. Therefore, this algorithm needs to be improved to make it more suitable for general images [21]. In the improvement, the image normalization processing method is adopted to reduce the computational complexity on the basis of ensuring the data information. Among the various algorithms related to image scanning, the invariant moment was proposed earlier. It is considered that the overall information of the content can be described by low-order moments, such as shape and contour, but many details are vulnerable to high-order influence. Therefore, it is considered that the surface features of the image can be represented by invariant moments. Assuming that the size of the image is M×N, the p+q order geometric moment can be expressed as follows:(3)mpq=∑x=0N1−1∑y=0N2−1xpypfx,y,where mpq is the geometric moment. The center distance can be expressed as follows:(4)upq=∑x=0N1−1∑y=0N2−1x−x−py−y−qfx,y,where upq represents the central moment, x¯,y¯ represents the centroid coordinate, and there is x¯=m10/m00andy¯=m01/m00 in the centroid coordinate. According to this theory, the image is normalized, and the coordinate transformation, shear transformation, scaling, and rotation are normalized in turn. It can be regarded as the affine transformation of decomposition, and the formula is as follows:(5)xy=A⋅x/y/+D.First, centralize the original image, cut, and transform thex direction, and the parameters β meet the following conditions:(6)u302=u201+3βu211+3β2u121+β3u031.The same method is used fory direction shear transformation. The corresponding amplitude is transformed according to the set scale parameters, and the image is normalized to generate image perception features.


## 3.3. Edge Computation Based on Short Signature

In order to ensure the integrity of data in mobile edge computing, it generally needs to be cached. This is the simplest way, but it will have network overhead and increase the response time. If it needs to be backed up regularly, it is also easy to cause some data loss. With the continuous emergence of edge mobile devices, the difficulty of cloud data computing and transmission is gradually increasing. Edge computing is a new computing method, which can deploy services near mobile terminals and process data. However, it will also cause the increase of server cache, which leads to the increase of destructiveness and affect the data integrity. Introducing third-party design is one of the common ways to analyze data integrity, but if there is malicious TPA (file extension in this article), it will directly affect the data analysis results. If edge caching is adopted, it also has many advantages. It needs low cost and is suitable for long-term storage. The time between the equipment and the base station can be communicated quickly. However, this method needs to regularly store the information to a certain physical location to avoid data loss. Compared with ECS, there are many base stations and the data are easy to be stolen.Edge data are generally introduced into TPA to perform authentication and send data according to the user request. However, not all TPAs are completely credible and the accuracy of the results cannot be guaranteed [22]. At present, the research on data integrity is based on server data verification. Only by realizing interaction, we can ensure data integrity. However, in edge computing, the user’s data come from the edge database, and the integrity itself is insufficient. Therefore, it is difficult to supplement the data through cloud computing [23]. For the untrusted problem in edge computing, the area chain technology is used for decentralization, as shown in Figure 2. Different users initiate data integrity verification. The edge node is not on the server, and the mobile phone information is sent to the smart contract for verification. Cloud services store large-scale files and send missing data to TPS (transaction processing system) for verification. A smart contract is the executor of verification.Figure 2
Decentralization of regional chain technology.An edge database is a small database, which is vulnerable to attack. On the basis of considering data integrity, we also need to consider the problem of delay. Therefore, this paper considers different situations in the analysis. Zsdiv-mec is divided into several steps in the calculation. In the data defect, it needs to be divided into three cases: unilateral defect, multilateral defect, and the combination of multilateral and cloud. Different cases need to be treated differently.Suppose that theq cyclic addition and subtraction group is represented by G1, p is the generating set, and the cyclic multiplication group is represented by G2. The bilinear mapping is established, and the segment signature secure Hash function is selected for calculation. Consumers choose their own private key and calculate the public key, which is represented by Y. The data are divided into blocks of equal length according to the user file F. These lengths can be expressed as follows:(7)δi=1Hmi+αP.The signature set of the fileF is obtained according to this formula, and then the consumer uploads the data file. These pieces of information will be sent to the smart contract, and the consumer requests to query the data integrity. Assuming that the consumer extracts c elements, the constructed data set is represented by I, generates a random function, and sends the random value and index to the nearest interedge node. When analyzing data integrity, it needs to be divided into different situations. In case of a unit defect, the provider will calculate after receiving and querying the information. The formula is(8)R=∑i=s1seviY,u=∑i=s1seviHmiP,η=P−P2∑i=s1seviHmiP.The edge node feeds back the data directly to the smart contract. If it is a multilateral case, the data block of the above method is insufficient and the nodes need to be used to calculate the surrounding nodes [24]. Suppose there are t edge nodes, and the data block index set of each node is represented by Oj. These edge nodes can provide effective index sets, which are expressed as follows:(9)Ij=1−l∩O1∪O2∪O3∪…∪Oj−1∩Oj.If the conditionO1∪O2∪O3∪…∪Ot−1∪Ot=1 is satisfied, this point is considered to be the last edge node. If lj=s1,s2,…,sej exists,(10)R=∑j=1t∑i=s1sejviY,u=∑j=1t∑i=s1sejviHmiP,η=P−P2∑j=1t∑i=s1sejvisi.The last node obtained is fed back to the smart contract. The third case is the combination of multilateral and cloud. Due to the dissatisfaction of a single edge point and nearby nodes, you need to turn to the central cloud, find the missing data after passing, repeat the above calculation again, and feed back the results to the smart contract. This formula is as follows:(11)eη,P⋅eu+R,p=ep,pIf it can be established, it is considered that the data is complete. Then, take true as the verification result; otherwise, the false result will be directly output.


## 4. Result Analysis and Discussion

### 4.1. Image Similarity and Integrity Test

The Hash algorithm and DCT-based Hash algorithm are used for similarity detection to convert the image into 256 level image, reduce the size, remove high-frequency noise, and retain low-frequency information. The image color is 64 gray levels, and the average gray value is calculated. In the hash algorithm and the improved algorithm, the average value of gray value greater than 1 is 1 and the others are 0. The calculation results are shown in Figure3. From the data in the figure, we can see that the similarity detection accuracy of the Hash algorithm itself can basically reach more than 56%, and the results are relatively accurate even if the size and brightness are changed. The Hash algorithm based on DCT has higher detection accuracy. After the scale changes, the accuracy can be improved to 100%. In terms of running speed, it takes only more than ten milliseconds. It shows that, after image coincidence detection, the matching area can be found quickly, and then the feature points can be extracted and the matrix can be transformed.Figure 3
Image similarity detection.In coincidence region detection, it is necessary to find the coefficient with the highest similarity. This range is the coincidence region. Combined with the image, the parameters are calculated from 10%. Different search compensation is set according to the range of coincidence area. When the coincidence area of image pixels is large, the results are shown in Figures4 and 5.Figure 4
Experimental results when the threshold is 86.Figure 5
Experimental results when the threshold is 78.From the data changes in the figure, we can see that the algorithm can reach the threshold of similarity when the search step is small, which is consistent with the actual situation. When the search compensation is 3%, the best parameters can be found fastest, and the detection time performance is better. When the search compensation is set to 5%, the calculation result of the threshold is not ideal, which may be due to the decrease of the similarity result caused by the interference of the coincidence area, and the optimal matching result is not obtained.On the basis of similarity detection and coincidence region detection, the image matching effect is analyzed and compared with the original algorithm. The search step is set to 0.1, and the threshold of similarity is set to 0.85. The algorithm in this paper takes 837.1 ms, and the detection time of surf and sift algorithms are 1456.8 ms and 2036.4 ms, respectively. The algorithm in this paper has a faster matching speed, can find the coincidence area first, and there is no need to detect other image feature points. Feature point detection takes time. This algorithm detects feature points 706, and the feature points of the surf algorithm and sift algorithm are 1245 and 3061, respectively. This algorithm can shorten the time and improve the detection efficiency on the basis of ensuring the quality.


### 4.2. Data Integrity Simulation Analysis

In order to analyze the data integrity of edge computing based on blockchain, in addition to the algorithm proposed in this paper, RSA signature and BLS signature are also used for comparison. These two methods are classical algorithms. In the simulation analysis, the key size is 160 bits and the random number size is 80. All experiments were carried out 30 times, and the average value was calculated.The overall response time of a single side case is measured, and the measurement results are shown in Figure6. From the data changes in the figure, we can see that the response time is delayed with the increase of data blocks, but the response time of the algorithm proposed in this paper is lower than that of the other two algorithms. In contrast, the RSA signature takes the longest time, and the algorithm in this paper is more efficient in verification.Figure 6
Response time of the unilateral case.Four edge nodes are set. The response time of the multilateral case is shown in Figure7. The measured results are similar to the unilateral case. Compared with the unilateral case, the response time of the algorithm in this paper is the shortest. Compared with unilateral correspondence, the response time is increased because the communication time is prolonged under multiple edge nodes.Figure 7
Multilateral response time.The overall response time of the combination of multilateral and cloud is shown in Figure8. Since each calculation increases the communication overhead between edge nodes and cloud, the response time of the combination of multilateral and cloud is longer than that of unilateral and multilateral cases.Figure 8
Overall response time of multilateral and cloud combination.Use some technical means to prove that a piece of certain information is indeed released by an organization (or a person). Because its purpose is somewhat similar to the traditional handwritten signature, it is called a “digital signature.” The technical implementation of a digital signature needs to rely on “asymmetric encryption technology” and “digital certificate system.” In data integrity verification, key and signature take the longest time and are also the basic steps that can not be omitted. Therefore, it is necessary to compare and analyze the time consumption of these two steps. Using data blocks of different sizes to evaluate the time-consuming of the two steps, the sizes are 1, 2, 4, 8, 16, 32, and 64, respectively. The measurement results are shown in Figure9. It can be seen from the data in the figure that the time consumption increases with the increase of data blocks, but the time consumption of the algorithm in this paper is much lower than that of the other two algorithms. This is because the RSA algorithm is difficult to decompose large integers, BLS has a large data scale, and the timeliness rate is relatively low. This algorithm can use the general Hash function, so it takes less time.Figure 9
Key and signature time.


## 4.1. Image Similarity and Integrity Test

The Hash algorithm and DCT-based Hash algorithm are used for similarity detection to convert the image into 256 level image, reduce the size, remove high-frequency noise, and retain low-frequency information. The image color is 64 gray levels, and the average gray value is calculated. In the hash algorithm and the improved algorithm, the average value of gray value greater than 1 is 1 and the others are 0. The calculation results are shown in Figure3. From the data in the figure, we can see that the similarity detection accuracy of the Hash algorithm itself can basically reach more than 56%, and the results are relatively accurate even if the size and brightness are changed. The Hash algorithm based on DCT has higher detection accuracy. After the scale changes, the accuracy can be improved to 100%. In terms of running speed, it takes only more than ten milliseconds. It shows that, after image coincidence detection, the matching area can be found quickly, and then the feature points can be extracted and the matrix can be transformed.Figure 3
Image similarity detection.In coincidence region detection, it is necessary to find the coefficient with the highest similarity. This range is the coincidence region. Combined with the image, the parameters are calculated from 10%. Different search compensation is set according to the range of coincidence area. When the coincidence area of image pixels is large, the results are shown in Figures4 and 5.Figure 4
Experimental results when the threshold is 86.Figure 5
Experimental results when the threshold is 78.From the data changes in the figure, we can see that the algorithm can reach the threshold of similarity when the search step is small, which is consistent with the actual situation. When the search compensation is 3%, the best parameters can be found fastest, and the detection time performance is better. When the search compensation is set to 5%, the calculation result of the threshold is not ideal, which may be due to the decrease of the similarity result caused by the interference of the coincidence area, and the optimal matching result is not obtained.On the basis of similarity detection and coincidence region detection, the image matching effect is analyzed and compared with the original algorithm. The search step is set to 0.1, and the threshold of similarity is set to 0.85. The algorithm in this paper takes 837.1 ms, and the detection time of surf and sift algorithms are 1456.8 ms and 2036.4 ms, respectively. The algorithm in this paper has a faster matching speed, can find the coincidence area first, and there is no need to detect other image feature points. Feature point detection takes time. This algorithm detects feature points 706, and the feature points of the surf algorithm and sift algorithm are 1245 and 3061, respectively. This algorithm can shorten the time and improve the detection efficiency on the basis of ensuring the quality.


## 4.2. Data Integrity Simulation Analysis

In order to analyze the data integrity of edge computing based on blockchain, in addition to the algorithm proposed in this paper, RSA signature and BLS signature are also used for comparison. These two methods are classical algorithms. In the simulation analysis, the key size is 160 bits and the random number size is 80. All experiments were carried out 30 times, and the average value was calculated.The overall response time of a single side case is measured, and the measurement results are shown in Figure6. From the data changes in the figure, we can see that the response time is delayed with the increase of data blocks, but the response time of the algorithm proposed in this paper is lower than that of the other two algorithms. In contrast, the RSA signature takes the longest time, and the algorithm in this paper is more efficient in verification.Figure 6
Response time of the unilateral case.Four edge nodes are set. The response time of the multilateral case is shown in Figure7. The measured results are similar to the unilateral case. Compared with the unilateral case, the response time of the algorithm in this paper is the shortest. Compared with unilateral correspondence, the response time is increased because the communication time is prolonged under multiple edge nodes.Figure 7
Multilateral response time.The overall response time of the combination of multilateral and cloud is shown in Figure8. Since each calculation increases the communication overhead between edge nodes and cloud, the response time of the combination of multilateral and cloud is longer than that of unilateral and multilateral cases.Figure 8
Overall response time of multilateral and cloud combination.Use some technical means to prove that a piece of certain information is indeed released by an organization (or a person). Because its purpose is somewhat similar to the traditional handwritten signature, it is called a “digital signature.” The technical implementation of a digital signature needs to rely on “asymmetric encryption technology” and “digital certificate system.” In data integrity verification, key and signature take the longest time and are also the basic steps that can not be omitted. Therefore, it is necessary to compare and analyze the time consumption of these two steps. Using data blocks of different sizes to evaluate the time-consuming of the two steps, the sizes are 1, 2, 4, 8, 16, 32, and 64, respectively. The measurement results are shown in Figure9. It can be seen from the data in the figure that the time consumption increases with the increase of data blocks, but the time consumption of the algorithm in this paper is much lower than that of the other two algorithms. This is because the RSA algorithm is difficult to decompose large integers, BLS has a large data scale, and the timeliness rate is relatively low. This algorithm can use the general Hash function, so it takes less time.Figure 9
Key and signature time.


## 5. Conclusion

The smart agriculture system covers many parts, of which the data part is all concentrated in the database. Therefore, once the database is attacked, there will be information leakage and even data information will be modified. If the quality of agricultural products is affected, it will cause huge loss. Based on this, this paper studies the application of edge computing and blockchain in smart agriculture system, uses the edge computing framework architecture to build the smart agriculture system architecture, and introduces blockchain to ensure the security of data information, and blockchain can store data directly. In crop image detection and data integrity, the data integrity of blockchain is used to avoid the possible untrusted problem in verification. Edge data detection based on a short signature can shorten the response time. Aiming at the problems of long matching time and large calculation errors in the traditional image mosaic algorithm, this paper proposes to analyze the feature points of the overlapping region. The image matching value starts from the edge region and gradually expands the range with a certain step size to improve the applicability of the algorithm. Through the analysis of simulation results, it can be seen that, after image coincidence detection, the matching area can be found quickly, and then the feature points can be extracted. The matching speed of the algorithm is faster, and the coincidence area can be found first without detecting other image feature points. It should be pointed out that the network smart contract in the blockchain cannot be modified after it is determined. With the increase of user demand, this disadvantage will become increasingly obvious. How to improve this deficiency of edge computing needs in-depth analysis. In image stitching, this paper only considers the transformation of adjacent images and often requires the stitching of multiple images in reality, so it also needs to consider the problem of global optimal matching.



---

*Source: 7198624-2022-05-13.xml*