Smart city data sharing method and system based on block chain technology
By using blockchain technology to encrypt data, divide popularity levels, calculate sharing priorities and use differential privacy technology in smart city data sharing, the risks of network attacks and leakage in data sharing are resolved, efficient management and privacy protection are achieved, and the scalability and flexibility of the system are improved.
Patent Information
- Application Number
- CN202510733699.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-04
- Publication Date
- 2025-09-23
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Smart city data sharing is vulnerable to cyber attacks, leading to an increased risk of data leakage. Traditional centralized management methods increase operation and maintenance costs and make it easy to become a target of attack.
Based on blockchain technology, by encrypting data, dividing popularity levels, generating hash values and metadata, using smart contracts to calculate shared priority scores and information entropy, combining differential privacy technology to add noise, and dynamically adjusting privacy budgets and consensus mechanisms, differentiated storage and access control of data can be achieved.
It achieves efficient management and optimized storage of different types of data, maximizes the utilization of data value, protects user privacy, optimizes data reading speed, and improves the scalability and flexibility of the system.
Smart Images

Figure CN120688085A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data sharing technology, and in particular to a smart city data sharing method and system based on blockchain technology. Background Art
[0002] Smart city data refers to the various types of data generated, collected, analyzed, and utilized during the construction and operation of smart cities. This data originates from various sensors, devices, systems, and citizen activities within the city, covering various aspects of the city, such as traffic flow, air quality, energy use, public safety, and waste disposal. By integrating advanced information and communication technologies (ICT), it aims to improve urban management efficiency and service quality.
[0003] In recent years, the rise of blockchain technology, with its decentralized, tamper-proof, and transparent characteristics, has provided a new solution to the trust issues inherent in smart city data sharing. Traditional data sharing methods typically rely on centralized servers for management and distribution, which not only increases data center operation and maintenance costs but also makes them vulnerable to cyberattacks, increasing the risk of data leaks. Summary of the Invention
[0004] In view of the above existing problems, the present invention is proposed.
[0005] Therefore, the present invention provides a smart city data sharing method based on blockchain technology to solve the problem of being vulnerable to network attacks and causing data leakage.
[0006] In order to solve the above technical problems, the present invention provides the following technical solutions:
[0007] In a first aspect, the present invention provides a smart city data sharing method based on blockchain technology, which comprises:
[0008] The owner encrypts the smart city data, classifies the smart city data into popularity levels based on the predicted access frequency, and uploads them to different storage locations;
[0009] Generate smart city data hash values and metadata, and submit them to the blockchain main chain to verify the owner's identity and record transaction logs;
[0010] The blockchain main chain calculates information entropy based on transaction logs and calculates shared priority scores based on timeliness and access frequency. The smart contract allocates consensus mechanisms based on storage locations and forms scheduling logs recorded on the blockchain.
[0011] Based on the sharing priority score and heat level, the privacy budget is adjusted through reinforcement learning, and the access permission rules and privacy logs are generated by adding noise in combination with differential privacy.
[0012] The demander submits the demand, and the blockchain verifies the demander's identity based on access permission rules and privacy logs. It downloads data from the corresponding storage location according to the demanded smart city data popularity level and records the sharing log.
[0013] As a preferred solution of the smart city data sharing method based on blockchain technology described in the present invention, the steps of dividing the popularity level of smart city data are as follows:
[0014] Based on the historical shared logs recorded in the blockchain, the double-parameter exponential smoothing method is used to predict the number of visits to smart city data, and the predicted number of visits to smart city data is obtained;
[0015] Based on the historical shared logs recorded in the blockchain, the actual visits within the set period are collected to generate a visit data set;
[0016] For each time point in the visit volume dataset, the relative visit volume ratio is calculated, and nonlinear least squares fitting is performed to obtain the attenuation coefficient and calculate the timeliness parameter of the smart city data;
[0017] Based on the predicted visits, actual visits and timeliness parameters of smart city data, a comprehensive popularity score is calculated, and smart city data is divided into hot data, warm data and cold data.
[0018] As a preferred solution of the smart city data sharing method based on blockchain technology described in the present invention, the specific steps of calculating the sharing priority score are as follows:
[0019] Obtain the traffic value sequence of all smart city data of the same data type on the blockchain, divide the traffic intervals, and obtain the probability distribution of each traffic interval;
[0020] Calculate the information entropy of smart city data;
[0021] Based on information entropy, timeliness parameter and predicted access volume, the sharing priority score is calculated and expressed as,
[0022]
[0023] Among them, G is the shared priority score. The larger G is, the higher the smart contract scheduling order is. F is the mean of the historical predicted visits of smart city data of the same data type, σ F The standard deviation of the historical predicted visits for smart city data of the same data type.
[0024] As a preferred solution of the smart city data sharing method based on blockchain technology described in the present invention, the specific steps of adjusting the privacy budget are as follows:
[0025] Define the shared priority score and heat level as the state space, and increase and decrease the privacy budget as the action space;
[0026] Calculate the reward function of the reinforcement learning algorithm based on data quality score, popularity bonus and privacy leakage penalty;
[0027] The blockchain main chain uses the reward function to iteratively update the Q table through the Q-Learning algorithm and select the optimal privacy budget;
[0028] Based on the optimal privacy budget, a differential privacy method is adopted to add Laplace noise to smart city data.
[0029] As a preferred solution of the smart city data sharing method based on blockchain technology described in the present invention, the privacy budget represents the degree of privacy leakage allowed during the data sharing process. After the blockchain main chain creates the Q table, the initial privacy budget is defined.
[0030] As a preferred solution of the smart city data sharing method based on blockchain technology described in the present invention, wherein: the Laplace noise is added to the smart city data, the specific steps are as follows:
[0031] The ratio of the optimal privacy budget and sensitivity of smart city data is used as the width of Laplace noise;
[0032] Use a random number generator to generate uniformly distributed random numbers and use the inverse function method to sample noise from the Laplace distribution;
[0033] Add the original value and noise value of smart city data.
[0034] As a preferred solution of the smart city data sharing method based on blockchain technology described in the present invention, uploading smart city data to different storage locations according to different popularity levels means:
[0035] Hot data is transmitted to the edge node closest to the data source via the HTTPS protocol, warm data is uploaded to the consortium chain, and cold data is uploaded to IPFS distributed storage via the ipfs-cli tool.
[0036] In a second aspect, the present invention provides a smart city data sharing system based on blockchain technology, including a data upload module, a transaction verification module, a scheduling module, a privacy log module and a sharing module.
[0037] The data upload module is used by the owner to encrypt the smart city data and classify the smart city data according to the predicted access frequency and upload them to different storage locations;
[0038] The transaction verification module is used to generate smart city data hash values and metadata, and submit them to the blockchain main chain to verify the owner's identity and record transaction logs;
[0039] The scheduling module is used to calculate the information entropy of the blockchain main chain based on the transaction log, and calculate the shared priority score based on timeliness and access frequency. The smart contract allocates the consensus mechanism according to the storage location and forms a scheduling log record on the blockchain;
[0040] The privacy log module is used to adjust the privacy budget through reinforcement learning based on the sharing priority score and heat level, and generate access permission rules and privacy logs after adding noise in combination with differential privacy;
[0041] The sharing module is used for the demander to submit a demand. The blockchain verifies the demander's identity based on access permission rules and privacy logs, downloads data from the corresponding storage location according to the required smart city data popularity level, and records the sharing log.
[0042] In a third aspect, the present invention provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: when the computer program is executed by the processor, any step of the smart city data sharing method based on blockchain technology as described in the first aspect of the present invention is implemented.
[0043] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein: when the computer program is executed by a processor, it implements any step of the smart city data sharing method based on blockchain technology as described in the first aspect of the present invention.
[0044] The beneficial effects of the present invention are as follows: the present invention uses the dual-parameter exponential smoothing method to predict the number of visits to divide the data heat level, thereby realizing efficient management and optimized storage of different types of data, dynamically adjusting the consensus mechanism according to the sharing priority score and heat level of the data through smart contracts, and using differential privacy technology to add noise, thereby maximizing the utilization of data value while protecting user privacy, and optimizing the data reading speed through the differentiated allocation consensus mechanism, thereby improving the scalability and flexibility of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0046] Figure 1This is a flowchart of the smart city data sharing method based on blockchain technology in Example 1.
[0047] Figure 2 This is a module diagram of the smart city data sharing system based on blockchain technology in Example 1.
[0048] Figure 3 This is a flow chart of calculating the shared priority score in Example 1.
[0049] Figure 4 This is a flowchart of adjusting the privacy budget in Example 1. DETAILED DESCRIPTION
[0050] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0051] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0052] Secondly, the term "one embodiment" or "embodiment" herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in various places throughout this specification does not necessarily refer to the same embodiment, nor does it refer to a separate or selective embodiment that is mutually exclusive of other embodiments.
[0053] Example 1, reference Figures 1 to 4 , this embodiment provides a smart city data sharing method based on blockchain technology, comprising the following steps:
[0054] S1. The owner encrypts the smart city data, divides the smart city data into different heat levels according to the predicted access frequency, and uploads them to different storage locations.
[0055] The owner encrypts the smart city data using the AES-256 algorithm (Advanced Encryption Standard, with a key length of 256 bits. The plaintext input of the smart city data is XORed with a randomly generated 256-bit key and then encrypted in blocks, with each block being 128 bits).
[0056] Based on the historical shared logs recorded in the blockchain, the double-parameter exponential smoothing method is used to predict the access volume of smart city data. The calculation formula is as follows:
[0057] F t+1 =αD t +(1-α)(F t+C t );
[0058] C t+1 =β(F t+1 -F t )+(1-β)C t ;
[0059] Among them, F t+1 is the predicted visit volume at time point t+1, α is the horizontal smoothing coefficient, ranging from [0,1], D t is the actual number of visits at time point t, F t is the predicted number of visits at time point t, C t is the trend component at time point t, C t+1 is the trend component at time point t+1, β is the trend smoothing coefficient value range [0α,α], the initial value F0=D0, T0=0, t represents the time point after the data is generated, and t=0 represents the time when the data is just generated;
[0060] Based on the historical shared logs recorded in the blockchain, the actual visits within a set period (e.g., every hour in the past 10 days, i.e., t∈[0,241]) are collected to generate a visit data set;
[0061] Calculate the mean μ and standard deviation σ of the visits in the visit data set, determine the visit data points outside the range of μ±3σ as outliers, and delete them;
[0062] For each time point in the visit volume data set, calculate the relative visit volume ratio using the following formula:
[0063]
[0064] Among them, A(t) is the relative visit volume ratio at time point t, N is the total number of time points, ∑D t is the total number of visits to the visit data set, D t Indicates the actual number of visits at time point t;
[0065] The Levenberg-Marquardt algorithm is used to perform nonlinear least squares fitting on A(t), and the objective function is:
[0066]
[0067] Where λ is the attenuation coefficient, and its value range is [0.001, 2];
[0068] Calculate the timeliness parameter B(t) of smart city data using the following formula:
[0069] B(t)=e -λt ;
[0070] Perform probability density estimation on the data access volume of the smart city;
[0071] Specifically, use the Gaussian kernel function to calculate the probability density function of the smart city data, and the calculation formula is as follows:
[0072]
[0073] where f(D t ) is the probability density function of the actual access volume at time point t, and h is the bandwidth;
[0074] Based on the Silverman criterion, calculate the bandwidth h, and the calculation formula is as follows:
[0075]
[0076] Y = Y3 - Y1;
[0077] where Y represents the interquartile range, Y3 is the 25th percentile in the access volume dataset, and Y1 is the 75th percentile in the access volume dataset;
[0078] According to the probability density function of the smart city data, use the quantile method of the probability distribution to mark the high access volume points, and the calculation formula is as follows:
[0079]
[0080] where D1 is the 90th percentile in the access volume dataset, represents the probability that D t falls within the interval [D1, +∞];
[0081] Calculate the comprehensive heat score of the smart city data, divide the heat level, and the calculation formula is as follows:
[0082]
[0083] where H is the comprehensive heat score;
[0084] When H ≥ 1.2σ, the smart city data is hot data. When 0.6σ < H < 1.2σ, the smart city data is warm data. When H ≤ 0.6σ, the smart city data is cold data;
[0085] Transmit the hot data to the edge node closest to the data source (such as the roadside unit server) through the HTTPS protocol, upload the warm data to the consortium chain (such as write to the Hyperledger Fabric side chain after Base64 encoding), and upload the cold data to the IPFS distributed storage through the ipfs-cli tool.
[0086] S2. Generate a hash value and metadata for smart city data, including the data type, timestamp, and popularity level of the smart city data, and submit it to the blockchain main chain to verify the owner's identity and record transaction logs.
[0087] Perform SHA-256 hashing on the encrypted smart city data to generate a 256-bit (32-byte) hash value, which is stored in the blockchain.
[0088] Use JSON format, fix the order of metadata (data type, timestamp, and popularity level) fields, and ensure hash consistency;
[0089] The data type refers to the data owner's label (e.g. if the data owner is the Traffic Management Bureau, the data is labeled as Traffic Management Bureau data), and the timestamp refers to the time when the smart city data encryption is completed.
[0090] Concatenate the data hash and metadata JSON string to generate the message to be signed, and sign it using the ECDSA-secp256k1 algorithm;
[0091] Use the Cosmos SDK to construct transactions;
[0092] Parse the data owner's certificate fingerprint, query the certificate authority (CA) on-chain registry, and verify the validity of the certificate;
[0093] Obtain encrypted data from edge nodes, consortium chains, or IPFS, recalculate the SHA-256 hash value, and compare it with the hash value stored on the blockchain. The difference must be 0 to verify the legitimacy of the smart city data;
[0094] If the difference between the recalculated hash value and the hash value stored on the blockchain is 0, it means that the hash value comparison has passed, the block has been generated, the transaction log has been recorded, and the owner's identity has been authenticated. Otherwise, the smart city data is illegal and will not be passed.
[0095] S3. The blockchain main chain calculates information entropy based on transaction logs, and calculates shared priority scores based on timeliness and access frequency. The smart contract allocates a consensus mechanism based on the storage location and forms a scheduling log recorded in the blockchain.
[0096] Extract metadata fields from the blockchain main chain transaction log;
[0097] For smart city data of the same data type (such as road condition data), its traffic value distribution is extracted from the blockchain historical transaction log;
[0098] Specifically, all data entries of the same data type of smart city data on the blockchain are queried to obtain their flow value sequences. The flow values are divided into several equal-width flow intervals, and the frequency of each flow interval is counted. The probability distribution of smart city data of the same data type in each flow interval is calculated.
[0099] According to the probability distribution of smart city data of the same data type in each traffic interval, the Shannon entropy formula is applied to calculate the information entropy of smart city data. The calculation formula is as follows:
[0100]
[0101] Among them, E is the information entropy, the unit is bit, which reflects the uncertainty of data flow distribution. The larger the value, the higher the data value (for example, when the distribution is completely uniform, E = log2I). i is the probability of the i-th flow interval, i is the index of the number of flow intervals, and I is the total number of flow intervals;
[0102] Based on information entropy, timeliness parameters and predicted visit volume, a multi-objective weighted comprehensive method is used to calculate the sharing priority score. The calculation formula is as follows:
[0103]
[0104] Among them, G is the shared priority score. The larger G is, the higher the smart contract scheduling order is. F is the mean of the historical predicted visits of smart city data of the same data type, σ F The standard deviation of the historical predicted visits for smart city data of the same data type;
[0105] The Proof of Capacity (PoC) consensus mechanism is used to verify hot data and calculate the cache hit rate. The calculation formula is as follows:
[0106]
[0107] Where R is the cache hit rate of hot data, a is the number of requests from the edge node to return data from the local cache in the past period of time, and b is the number of requests from the edge node to re-pull data from the data source in the past period of time;
[0108] When R>0.8, consensus is reached and there is no need to refresh the cache. Otherwise, the smart contract calls the edge node to continue refreshing the cache until consensus is reached.
[0109] Proof-of-Stake (PoS) consensus mechanism verification for warm and cold data;
[0110] Specifically, the staked token threshold is set at 1% of the total staked tokens on the entire network (the Cosmos Hub security model requires that a single validator maintain a stake of less than 33% to prevent double-spending attacks, with 0.1% being the minimum participation threshold). The staked tokens of all validators are queried from the blockchain state tree, and a list of validator nodes that meet the staked token threshold is screened out.
[0111] The validator node executes the ECDSA-secp256k1 algorithm signature on the smart city data hash and uses the Schnorr signature aggregation algorithm to merge multiple signatures into a single 64-byte aggregate signature. At least five validator nodes provide valid signatures, and the smart contract verifies whether the aggregate signature matches the validator public key list.
[0112] Specifically, the validator node initiates a pledge transaction to the blockchain main chain, and the transaction is accompanied by the public key of the validator node. After successful pledge, the public key is recorded in the blockchain's validator registry. The blockchain dynamically updates the validator registry based on the pledge amount for each block. The smart contract accesses the current validator registry and public key through the Cosmos SDK, and screens out validators that meet the conditions (the amount of pledged tokens ≥ 0.1% of the total amount of pledged tokens in the entire network). The public key field is extracted from the screened validators to generate a list of validator public keys to be matched. The smart contract parses the aggregate signature (Schnorr signature) in the transaction, splits it into a list of individual signatures, and uses the elliptic curve recovery algorithm (ECDSA Recovery) to calculate the corresponding public key for each signature. It checks whether the corresponding public key exists in the list of validator public keys to be matched. If the public keys of at least 5 signatures match successfully, consensus is considered to be reached. Otherwise, consensus is not reached.
[0113] Submit the scheduling log (data hash value, shared priority score and consensus mechanism verification result) to the blockchain main chain as a new transaction.
[0114] S4. Based on the sharing priority score and heat level, the privacy budget is adjusted through reinforcement learning, and the access permission rules and privacy logs are generated after adding noise in combination with differential privacy.
[0115] The blockchain main chain extracts the shared priority scores and popularity levels of smart city data from the scheduling logs and transaction logs, and combines the shared priority scores and popularity levels into a two-dimensional vector, constructing the state space of reinforcement learning. The vector is stored as a memory variable of the blockchain main chain in the form of a key-value pair.
[0116] The blockchain main chain creates a Q-table, which is a two-dimensional matrix with the number of rows equal to the number of possible combinations in the state space (for example, the shared priority score can be divided into 10 levels, the heat level can be divided into 3 levels, and the total number of states is 30), and the number of columns equal to the action space;
[0117] The action space is defined as two operations for adjusting the privacy budget: increasing the privacy budget and decreasing the privacy budget. The gradient of each increase or decrease is 0.1. The initial privacy budget is set to 1. The Q-table and action space are stored in the memory variables of the blockchain main chain. The memory variable format is a key-value pair.
[0118] The privacy budget represents the degree of privacy leakage allowed during data sharing, and its value range is [0, +∞]. After the blockchain main chain creates the Q table, the initial privacy budget is defined as 1, which indicates the starting point of privacy protection at the beginning of the iteration;
[0119] Calculate the reward function based on the state space and action space;
[0120] Specifically, the metadata of smart city data is retrieved from the transaction log. Based on the metadata completeness and the access volume ratio A(t), a weighted summation method is used to calculate the data quality score. The calculation formula is as follows:
[0121] v = 0.6 g + 0.4 A (t);
[0122] Where v is the data quality score, g is the metadata completeness coefficient, and its value range is [0,1], indicating the completeness of metadata fields. For example, if all fields are complete, g = 1;
[0123] Based on the comprehensive popularity score, the popularity bonus is calculated through data normalization and interval division. The calculation formula is as follows:
[0124]
[0125] Among them, r is the heat addition coefficient, and its value range is [0.5, 2];
[0126] Determine the sensitivity of smart city data based on the type of data in the metadata;
[0127] The sensitivity of smart city data indicates the maximum range of variation that smart city data may be exposed to in a single query (in data values, such as the number of vehicles or traffic values), reflecting the actual fluctuation of data distribution.
[0128] Specifically, the data content is determined to be vehicle trajectory or traffic value based on the data type. A sample value sequence of smart city data of the same data type is extracted from the historical shared log. The difference between the maximum and minimum values of the sample value sequence is calculated. This difference is used as a preliminary estimate of the sensitivity. The range is then adjusted according to the characteristics of the smart city data. For example, the typical fluctuation range of traffic flow data is 10 to 30 vehicles / hour (based on urban road statistics). Considering extreme situations (such as peak hours), an upper limit of 50 and a lower limit of 5 are set.
[0129] Based on the privacy budget and sensitivity of the current type of smart city data, a differential privacy risk assessment is performed on the smart city data, and the privacy leakage penalty is calculated as follows:
[0130]
[0131] Where L is the privacy leakage penalty, which represents the risk of smart city data leakage under the current privacy budget. Its value range is [0, 1]. A larger value indicates a higher risk. z is the sensitivity. γ is the privacy budget of the current type of smart city data. k is the adjustment constant. Its value range is [10, 100]. Its function is to control the value of L in [0, 1].
[0132] Based on the data quality score v, the heat bonus r, and the privacy leakage penalty L, the reward function of the reinforcement learning algorithm is calculated as follows:
[0133]
[0134] Among them, U represents the reward function of the reinforcement learning algorithm, τ is the heat addition coefficient, and the value range is [0,1]. is the penalty coefficient, ranging from [0,2];
[0135] The blockchain main chain uses the reward function to iteratively update the Q table through the Q-Learning algorithm and select the optimal privacy budget. The calculation formula is as follows:
[0136] Q(S t ,W t )=Q(S t ,W t )+η(U t +δmaxQ(S t+1 ,W t+1 )-Q(S t ,W t ));
[0137] Among them, Q(S t ,W t ) represents the state space S t and action space W t The Q value under ,η is the learning rate, U t Represents the calculated value of the reward function at time point t, S t represents the state space at time point t, W t represents the action space at time point t, δ is the discount factor, and its value range is [0,1];
[0138] In each iteration, the updated Q table is read, the action with the largest Q value in the current state space is selected, the next state space is calculated, and the reward function is recalculated to update the Q value. The absolute value ΔQ of the difference between the two adjacent updated Q values is calculated. When ΔQ < 0.01, it means that Q(S t ,W t ) converges, completing the update of the Q table, otherwise continue iterating until ΔQ < 0.01 or the maximum number of iterations is reached;
[0139] After the iteration ends, the action space with the largest Q value in the state space in the Q table is selected. Starting from the initial privacy budget, the final privacy budget is calculated as the optimal privacy budget. For example, if "Reduce Privacy Budget" is executed 5 times, the final privacy budget is 1-0.1×5=0.5;
[0140] Based on the optimal privacy budget, a differential privacy method is used to add Laplace noise to smart city data;
[0141] Specifically, the Laplace noise scale z / γ is calculated based on the optimal privacy budget and sensitivity of smart city data. best , where z / γ best Represents the width of the Laplace distribution. The larger the value, the greater the noise and the stronger the privacy protection. A random number generator is used to generate uniformly distributed random numbers in the range [0,1]. The inverse function method is used to sample noise from the Laplace distribution. The probability density function of the Laplace distribution O(x) is:
[0142]
[0143] Among them, γ best is the optimal privacy budget, x is the noise value, ranging from [-∞, +∞], and u is a random number;
[0144] Add the original value of the smart city data to the noise value and round the result to an integer to obtain the new smart city data for protecting sensitive information;
[0145] The blockchain constructs a privacy log using the noise value and the optimal privacy budget and writes it into the blockchain main chain;
[0146] Specifically, the hash value, optimal privacy budget and noise value of the smart city data are extracted, and combined into a privacy log in the key-value pair format. The key-value pair is serialized in JSON format to generate a string. The length of the serialized string is fixed bytes to obtain the privacy log. The blockchain queries the current block height, extracts the latest height value from the blockchain state tree, adds 1 to the current block height, generates the preliminary height of the new block, reads the privacy log, uses it as transaction data, constructs a transaction structure, including the field transaction identifier, privacy log JSON string and current time, uses the ECDSA-secp256k1 algorithm to sign the transaction data, and the signing key is the 256-bit private key of the data owner. A 64-byte signature is generated and attached to the transaction. The transaction format is a key-value pair. The transaction is broadcast to the validator node through the PoS consensus mechanism of the Cosmos public chain. The validator node verifies the signature and reaches a consensus. At least 5 nodes agree to log the transaction to the new block, and the block height is the preliminary height.
[0147] The blockchain main chain reads the shared priority scores from the scheduling log and generates access permission rules based on the optimal privacy budget;
[0148] Specifically, the blockchain main chain compares the current sharing priority score with the average sharing priority score to determine whether the current priority of smart city data is higher than the average level. The blockchain main chain compares the optimal privacy budget with the initial privacy budget to determine whether the privacy protection strength is significantly enhanced.
[0149] If the sharing priority score is higher than the average sharing priority score and the optimal privacy budget is less than the initial privacy budget, the rule is "access only to the management department of the data owner", otherwise, it is "public access";
[0150] The blockchain main chain pairs the access permission rules with the hash value of the smart city data and writes them into the blockchain main chain.
[0151] S5. The demander submits the demand, and the blockchain verifies the demander's identity based on access permission rules and privacy logs. It downloads data from the corresponding storage location according to the demanded smart city data popularity level and records the sharing log.
[0152] The data requester (such as the urban management department) submits a sharing request (such as obtaining real-time traffic data) to the blockchain main chain. The smart contract receives the generated permission rules and privacy logs, verifies the identity of the requester (through DID decentralized identity) and the legitimacy of the request (matching permission rules). After verification, it performs layered downloads based on the data's heat level and storage location. If it is hot data, it is directly obtained from the edge node (PoC verifies cache validity). If it is warm data, it is downloaded from the consortium chain (PoS confirms consistency). If it is cold data, it is extracted from IPFS (through hash positioning). During the download process, the blockchain monitors the access frequency in real time, updates the data heat level (such as cold data is upgraded to warm data due to high frequency access), and triggers storage migration (such as migration from IPFS to the consortium chain). After the download is complete, the smart contract records the transaction details (requester ID, time, data hash) and the updated heat level to form a shared log.
[0153] Based on the shared log, the updated heat level and access frequency data are extracted, and the heat trend of the data is re-predicted through the exponential smoothing method. The storage location is adjusted according to the new heat level (such as migrating hot data to edge nodes), and the consensus mechanism is updated at the same time (hot data is switched to PoC). The adjustment results are recorded in the blockchain to form an optimization log. The smart contract iteratively updates the reinforcement learning reward function based on the optimization log and historical shared data to achieve adaptive optimization.
[0154] This embodiment also provides a smart city data sharing system based on blockchain technology, including: a data upload module, a verification transaction module, a scheduling module, a privacy log module and a sharing module. The data upload module is used by the owner to encrypt the smart city data and upload it to different storage locations according to the heat level of the smart city data divided by the predicted access frequency; the transaction verification module is used to generate a hash value and metadata of the smart city data, and submit it to the blockchain main chain to verify the identity of the owner and record the transaction log; the scheduling module is used by the blockchain main chain to calculate the information entropy based on the transaction log, and calculate the sharing priority score based on timeliness and access frequency. The smart contract allocates a consensus mechanism based on the storage location and forms a scheduling log record on the blockchain; the privacy log module is used to adjust the privacy budget through reinforcement learning based on the sharing priority score and heat level, and generate access permission rules and privacy logs after adding noise in combination with differential privacy; the sharing module is used by the demander to submit the demand. The blockchain verifies the demander's identity based on the access permission rules and privacy log, downloads data from the corresponding storage location according to the heat level of the smart city data required, and records the sharing log.
[0155] This embodiment also provides a computer device, which is suitable for the smart city data sharing method based on blockchain technology, including: a memory and a processor; the memory is used to store computer-executable instructions, and the processor is used to execute computer-executable instructions to implement the smart city data sharing method based on blockchain technology proposed in the above embodiment.
[0156] The computer device may be a terminal, comprising a processor, a memory, a communication interface, a display screen and an input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device comprises a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner may be achieved through WIFI, an operator network, NFC (near field communication) or other technologies. The display screen of the computer device may be a liquid crystal display or an electronic ink display screen, and the input device of the computer device may be a touch layer covering the display screen, or a button, trackball or touchpad provided on the housing of the computer device, or an external keyboard, touchpad or mouse.
[0157] This embodiment also provides a storage medium having a computer program stored thereon, which, when executed by a processor, implements the smart city data sharing method based on blockchain technology proposed in the above embodiment; the storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, disk or optical disk.
[0158] In summary, the present invention achieves efficient management and optimized storage of different types of data by using the two-parameter exponential smoothing method to predict the number of visits to divide the data heat level. It dynamically adjusts the consensus mechanism according to the sharing priority score and heat level of the data through smart contracts, and uses differential privacy technology to add noise, thereby maximizing the utilization of data value while protecting user privacy. Through the differentiated allocation consensus mechanism, the data reading speed is optimized and the scalability and flexibility of the system are improved.
[0159] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.
Claims
1. A smart city data sharing method based on blockchain technology, characterized by: include, The owner encrypts the smart city data, classifies the smart city data into popularity levels based on the predicted access frequency, and uploads them to different storage locations; Generate smart city data hash values and metadata, and submit them to the blockchain main chain to verify the owner's identity and record transaction logs; The blockchain main chain calculates information entropy based on transaction logs and calculates shared priority scores based on timeliness and access frequency. The smart contract allocates consensus mechanisms based on storage locations and forms scheduling logs recorded on the blockchain. Based on the sharing priority score and heat level, the privacy budget is adjusted through reinforcement learning, and the access permission rules and privacy logs are generated by adding noise in combination with differential privacy. The demander submits the demand, and the blockchain verifies the demander's identity based on access permission rules and privacy logs. It downloads data from the corresponding storage location according to the demanded smart city data popularity level and records the sharing log.
2. The smart city data sharing method based on blockchain technology as claimed in claim 1, characterized in that: The specific steps for dividing the heat level of smart city data are as follows: Based on the historical shared logs recorded in the blockchain, the double-parameter exponential smoothing method is used to predict the number of visits to smart city data, and the predicted number of visits to smart city data is obtained; Based on the historical shared logs recorded in the blockchain, the actual visits within the set period are collected to generate a visit data set; For each time point in the visit volume dataset, the relative visit volume ratio is calculated, and nonlinear least squares fitting is performed to obtain the attenuation coefficient and calculate the timeliness parameter of the smart city data; Based on the predicted visits, actual visits and timeliness parameters of smart city data, a comprehensive popularity score is calculated, and smart city data is divided into hot data, warm data and cold data.
3. The smart city data sharing method based on blockchain technology as claimed in claim 1, characterized in that: The specific steps for calculating the shared priority score are as follows: Obtain the traffic value sequence of all smart city data of the same data type on the blockchain, divide the traffic intervals, and obtain the probability distribution of each traffic interval; Calculate the information entropy of smart city data; Based on information entropy, timeliness parameter and predicted access volume, the sharing priority score is calculated and expressed as, Among them, G is the shared priority score, μ F is the mean of the historical predicted visits of smart city data of the same data type, σ F The standard deviation of the historical predicted visits for smart city data of the same data type.
4. The smart city data sharing method based on blockchain technology as claimed in claim 1, characterized in that: The specific steps for adjusting the privacy budget are as follows: Define the shared priority score and heat level as the state space, and increase and decrease the privacy budget as the action space; Calculate the reward function of the reinforcement learning algorithm based on data quality score, popularity bonus and privacy leakage penalty; The blockchain main chain uses the reward function to iteratively update the Q table through the Q-Learning algorithm and select the optimal privacy budget; Based on the optimal privacy budget, a differential privacy method is adopted to add Laplace noise to smart city data. The blockchain-based smart city data sharing method according to claim 1, wherein the privacy budget represents the degree of privacy leakage allowed during the data sharing process, and the initial privacy budget is defined after the blockchain main chain creates the Q table.
5. The smart city data sharing method based on blockchain technology as claimed in claim 1, characterized in that: The specific steps of adding Laplace noise to smart city data are as follows: The ratio of the optimal privacy budget and sensitivity of smart city data is used as the width of Laplace noise; Use a random number generator to generate uniformly distributed random numbers and use the inverse function method to sample noise from the Laplace distribution; Add the original value and noise value of smart city data.
6. The smart city data sharing method based on blockchain technology according to claim 1 is characterized in that: Uploading smart city data to different storage locations according to different heat levels means transmitting hot data to the edge node closest to the data source through the HTTPS protocol, uploading warm data to the consortium chain, and uploading cold data to IPFS distributed storage through the ipfs-cli tool.
7. A smart city data sharing system based on blockchain technology, based on the smart city data sharing method based on blockchain technology according to any one of claims 1 to 7, characterized in that: Including data upload module, transaction verification module, scheduling module, privacy log module and sharing module, The data upload module is used by the owner to encrypt the smart city data and classify the smart city data according to the predicted access frequency and upload them to different storage locations; The transaction verification module is used to generate smart city data hash values and metadata, and submit them to the blockchain main chain to verify the owner's identity and record transaction logs; The scheduling module is used to calculate the information entropy of the blockchain main chain based on the transaction log, and calculate the shared priority score based on timeliness and access frequency. The smart contract allocates the consensus mechanism according to the storage location and forms a scheduling log record on the blockchain; The privacy log module is used to adjust the privacy budget through reinforcement learning based on the sharing priority score and heat level, and generate access permission rules and privacy logs after adding noise in combination with differential privacy; The sharing module is used for the demander to submit a demand. The blockchain verifies the demander's identity based on access permission rules and privacy logs, downloads data from the corresponding storage location according to the required smart city data popularity level, and records the sharing log.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the smart city data sharing method based on blockchain technology described in any one of claims 1 to 7 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the smart city data sharing method based on blockchain technology described in any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Data circulation verification method based on block chain
CN121690581A