Intelligent measurement switch program upgrading system and method based on block chain
By constructing an intelligent measurement switch program upgrade system using blockchain technology, the problems of data tampering and identity forgery in traditional upgrade methods are solved. It realizes the legality and integrity verification of upgrade packages, ensures the security and stability of the upgrade process, provides reliable identity authentication and rollback mechanisms, and improves the security and reliability of the power system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-14
- Publication Date
- 2026-04-07
AI Technical Summary
Traditional intelligent metering switch program upgrade methods suffer from problems such as data tampering, identity forgery, and upgrade failure. They lack effective trust mechanisms and reliable rollback mechanisms, which affect the stability and security of the power system.
A decentralized upgrade system is built using blockchain technology. The upgrade package hash value and device identity information are stored through consensus nodes. The upgrade process is defined using smart contracts. The smart measurement switch device with built-in blockchain client performs identity authentication and upgrade package verification, and realizes automated management and rollback mechanism of upgrade package.
Ensuring the legality and integrity of the upgrade package improves the security and stability of the upgrade process, prevents malicious tampering, provides reliable identity authentication and traceable operation records, avoids equipment malfunction due to upgrade failure, and enhances the system's reliability and anti-attack capabilities.
Smart Images

Figure CN121807330A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent measurement switch technology, specifically to a blockchain-based intelligent measurement switch program upgrade system and method. Background Technology
[0002] With the rapid development of smart grids and the Internet of Things (IoT) technologies, smart metering switches are increasingly widely used in power systems. As key devices for power data acquisition and control, program upgrades for smart metering switches are crucial for ensuring functional updates, performance optimization, and security vulnerability patching. However, traditional program upgrade methods primarily rely on centralized servers for distributing and managing upgrade packages, which has numerous drawbacks.
[0003] First, upgrade packages may be maliciously tampered with during transmission, leading to equipment malfunctions or exploitation of security vulnerabilities. For example, attackers could use man-in-the-middle attacks to modify the upgrade package content, inject malicious code, and thereby control the equipment or disrupt the normal operation of the power system. Second, traditional upgrade methods lack effective trust mechanisms, making it difficult to ensure the legitimacy and integrity of upgrade packages. Upgrade packages are typically generated by equipment manufacturers, but they may be tampered with by third parties during transmission and storage, and the equipment cannot verify their authenticity. Furthermore, when upgrade processes fail, the lack of reliable rollback mechanisms may cause equipment to malfunction, affecting the stability and reliability of the power system.
[0004] Furthermore, traditional centralized upgrade servers are prone to becoming single points of failure and targets for attacks. Once a server is compromised or malfunctions, it will affect the upgrade security of a large number of devices, and may even paralyze the entire upgrade system. Existing technologies, such as digital signatures and encryption, attempt to enhance security, but these solutions still rely on centralized institutions and cannot completely solve trust issues and the risk of data tampering.
[0005] Blockchain technology, as a distributed ledger technology, features decentralization, immutability, traceability, and automated smart contract execution, offering a new approach to solving the aforementioned problems. Blockchain ensures data consistency through a consensus mechanism, guarantees data immutability through a hash chain, and automates processes through smart contracts. Therefore, applying blockchain technology to the upgrade of smart metering switch programs can effectively improve the security and stability of the upgrade process. Summary of the Invention
[0006] The technical problem this invention aims to solve is to provide a blockchain-based intelligent measurement switch program upgrade system and method. By constructing a secure and reliable upgrade system through blockchain technology, it ensures data integrity, identity legitimacy, and operational traceability during the intelligent measurement switch program upgrade process. This invention aims to address problems such as data tampering, identity forgery, and upgrade failure in traditional upgrade methods, thereby improving the security and stability of the upgrade process.
[0007] To address the aforementioned technical problems, embodiments of the present invention provide the following technical solution: a blockchain-based intelligent measurement switch program upgrade system, comprising...
[0008] The blockchain network consists of multiple consensus nodes, used to store, but not limited to, hash values of upgrade packages, identity information of smart metering switches, and upgrade record information; the consensus nodes achieve data consistency through consensus algorithms and use consortium blockchains or private blockchains for permission management; Smart contracts, deployed on the blockchain network, define the rules and logic of the upgrade process, including the verification, authorization, distribution, and rollback of upgrade packages. The smart contracts are executed automatically through event-driven mechanisms and support dynamic updates to the upgrade strategy. The upgrade management node is used to generate and publish upgrade packages, calculate the hash value of the upgrade package, and write the hash value of the upgrade package and data information including but not limited to version number, applicable device type, encryption key digest and digital signature into the blockchain network, and interact with smart measurement switch devices; The intelligent measurement switch device has a built-in blockchain client and a secure communication module, which are used to connect to the blockchain network, perform identity authentication, verify the legality and integrity of the upgrade package, execute the upgrade operation, and record the upgrade status and progress to the blockchain network. The user terminal is used to interact with the blockchain network, view the upgrade status, manage upgrade tasks, and perform audit operations; the user terminal provides a graphical interface to support upgrade monitoring and historical queries.
[0009] Preferably, the smart measurement switch generates a public-private key pair at the time of manufacture, and the public key is registered with the blockchain network as an identity identifier; the smart measurement switch also includes a device identifier, including a MAC address, serial number or IMEI number, which is used for identity authentication by binding and verifying with the public key.
[0010] Preferably, after generating the upgrade package, the upgrade management node calculates the hash value of the upgrade package and encrypts and compresses the upgrade package using an encryption algorithm; the upgrade management node packages the hash value, version number, applicable device type, encryption key digest, and digital signature into transaction data and writes it into the blockchain through the blockchain network consensus node.
[0011] Preferably, the blockchain network employs a practical Byzantine fault-tolerant consensus algorithm, and the blockchain network also integrates an IPFS storage system for storing large-size upgrade packages.
[0012] Preferably, the smart contract includes an upgrade rule module, an authorization verification module, and a rollback management module; the upgrade rule module defines device upgrade conditions, including device batch, version compatibility, and security policies; the authorization verification module makes authorization decisions based on device identity and upgrade rules; the rollback management module is triggered when an upgrade fails, automatically retrieves the most recently successfully upgraded version, and executes a rollback.
[0013] This invention also proposes a method for upgrading the intelligent measurement switch program, comprising the following steps: The upgrade management node generates an upgrade package, calculates the hash value of the upgrade package, and writes the hash value of the upgrade package and data information (not limited to version number, applicable device type, encryption key digest, and digital signature) into the blockchain, and performs signing and verification through a smart contract. Before initiating an upgrade request, the intelligent measurement switchgear submits its device public key and unique device identifier to the blockchain network. The device is authenticated by the distributed and tamper-proof device registration information stored on the blockchain network. The intelligent measurement switch connects to the blockchain network to check if there is an upgrade package suitable for itself; if so, the device sends an upgrade request to the upgrade management node, which includes the device's identity information, current version number, and target version number. After receiving the upgrade request, the upgrade management node sends the upgrade package to the smart measurement switch device. The smart measurement switch device verifies the integrity and legality of the upgrade package through the blockchain network. After the upgrade package is verified, the smart measurement switch calls the smart contract on the blockchain network to request upgrade authorization; the smart contract performs authorization verification based on the device identity information, current version number and upgrade rules; After obtaining authorization, the intelligent measurement switch device performs an upgrade operation. During the upgrade process, the intelligent measurement switch device records the upgrade progress and status information to the blockchain network in real time. After the upgrade is completed, the smart measurement switch device verifies the upgrade result; if the verification is successful, the upgrade success information is recorded on the blockchain; if the verification fails, the rollback mechanism of the smart contract is triggered, and the rollback result is recorded on the blockchain.
[0014] Preferably, the intelligent measurement switch device verifies the integrity and legitimacy of the upgrade package through a blockchain network, specifically: After receiving the upgrade package, the intelligent measurement switch device uses the same cryptographic hash algorithm as when the upgrade package was generated to recalculate the hash value of the upgrade package locally, and records it as the first hash value; The intelligent measurement switch device initiates a query request to the blockchain network through its built-in blockchain client to obtain the standard hash value corresponding to the upgrade package version, which is pre-written into the blockchain by the upgrade management node and is recorded as the second hash value. The intelligent measurement switch device compares the first hash value with the second hash value; only when the first hash value and the second hash value are completely consistent is the upgrade package determined to be complete and untampered, and the verification passed; if they are inconsistent, the upgrade process is immediately terminated and the verification failure event is recorded to the blockchain network.
[0015] Preferably, the smart contract performs authorization verification based on device identity information, current version number, and upgrade rules as follows: The smart contract receives the upgrade authorization request sent by the device, extracts the identity public key of the smart measurement switch device from it, and queries the pre-stored, tamper-proof official device registry on the blockchain to verify whether the public key exists in the list of authorized devices. After the device identity verification is successful, the smart contract extracts the current version number of the device and the target upgrade version number from the request; then, the contract queries the upgrade rule matrix stored internally to verify whether the upgrade of the device from the current version to the target version conforms to the preset version upgrade path; The smart contract checks whether the device or its batch of devices meets the specific strategies and conditions for this upgrade according to the upgrade rules. These conditions include, but are not limited to: upgrade window time limits, geographical location permission of the device's location, or whether the device's self-inspection report on its security status has passed.
[0016] Preferably, the mechanism for triggering the rollback of the smart contract specifically includes: When the upgrade verification fails, the smart measurement switch sends a rollback request to the blockchain network. The smart contract responds automatically, retrieving and returning the version number of the device's most recent successful upgrade and the on-chain hash value of its corresponding upgrade package from the immutable upgrade history on the blockchain. The smart measurement switch device requests the corresponding historical stable version upgrade package from the upgrade management node based on the version information and hash value returned by the smart contract, and performs hash calculation again to compare with the on-chain data to verify the integrity of the rollback package; After the rollback package is verified, the rollback operation is performed to restore the program to the historical stable version. After the operation is completed, the successful rollback result and the new device status are written to the blockchain as transaction records.
[0017] Preferably, all upgrade-related operation records, including identity authentication requests, upgrade requests, verification results, authorization information, execution processes, and rollback operations, are recorded in the form of transactions on the blockchain network and distributed and synchronized on multiple consensus nodes of the blockchain network; any write operation to blockchain data, including uploading upgrade package information to the chain, upgrade authorization, and status recording, must be verified by the consensus algorithm of multiple consensus nodes before it can be confirmed.
[0018] The beneficial effects of the above-described technical solution of the present invention are as follows: 1. High data security: The immutability of blockchain ensures that the hash value and related information of the upgrade package cannot be tampered with once it is on the chain, effectively preventing malicious tampering of the upgrade package during transmission and storage, and guaranteeing the legality and integrity of the upgrade package.
[0019] 2. Reliable identity authentication: Utilizing the decentralized identity authentication mechanism of blockchain, the system ensures the authenticity of the smart measurement switchgear, prevents unauthorized device access and malicious upgrade requests, and improves system security.
[0020] 3. The upgrade process is traceable. All upgrade-related operation records are stored on the blockchain. Managers can query the upgrade history at any time, trace the problems that occurred during the upgrade process, and facilitate problem analysis and responsibility determination.
[0021] 4. The rollback mechanism is robust. When the upgrade fails, the rollback mechanism of the smart contract can quickly restore the device program to the previous stable version, avoiding the device from failing to work properly due to the upgrade failure and improving the stability of the upgrade.
[0022] 5. Decentralized architecture: Adopting the decentralized architecture of blockchain, it avoids the single point of failure problem of traditional centralized upgrade servers. Even if some nodes are attacked, the entire system can still operate normally, improving the system's reliability and resistance to attacks.
[0023] 6. Smart contract automation: By defining the rules and logic of the upgrade process through smart contracts, the upgrade process is automated, reducing human intervention, improving the efficiency and accuracy of the upgrade, and also reducing the risk of human error. Attached Figure Description
[0024] Figure 1 This is a topology diagram of the blockchain-based intelligent measurement switch program upgrade system of the present invention; Figure 2 This is a flowchart of the blockchain-based smart measurement switch program upgrade method of the present invention. Detailed Implementation
[0025] To make the technical problems, technical solutions and advantages of the present invention clearer, a detailed description will be given below in conjunction with the accompanying drawings and specific embodiments.
[0026] like Figure 1 As shown, this invention proposes a blockchain-based intelligent measurement switch program upgrade system, including...
[0027] Blockchain network 1 consists of multiple consensus nodes used to store, but not limited to, hash values of upgrade packages, identity information of smart meter switches, and upgrade record information. Consensus nodes achieve data consistency through consensus algorithms and use consortium blockchains or private blockchains for permission management to ensure that only authorized nodes can participate in consensus and data storage.
[0028] Smart Contract 2, deployed on the blockchain network, defines the rules and logic of the upgrade process, including the verification, authorization, distribution, and rollback of the upgrade package. The smart contract is executed automatically through event-driven mechanisms and supports dynamic updates of the upgrade strategy. Smart Contract 2 is written in Solidity to achieve automated control of the upgrade process.
[0029] Upgrade management node 3, managed by the equipment manufacturer or authorized service provider, is responsible for generating upgrade packages and maintaining upgrade strategies. It is used to generate and release upgrade packages, calculate the hash value of upgrade packages, and write the hash value of upgrade packages and data information (not limited to version number, applicable device type, encryption key digest, and digital signature) into the blockchain network, and interact with smart measurement switch devices.
[0030] The intelligent measurement switchgear 4 incorporates a blockchain client and a secure communication module for connecting to the blockchain network. This allows for identity authentication, verification of the legality and integrity of upgrade packages, execution of upgrade operations, and recording of upgrade status and progress on the blockchain network. The intelligent measurement switchgear 4 also features a lightweight blockchain client that connects to the blockchain network via the secure communication module.
[0031] User terminal 5, which can be a PC or mobile device, is used by administrators to monitor and manage upgrade tasks, interact with the blockchain network, view upgrade status, manage upgrade tasks, and perform audit operations; the user terminal provides a graphical interface to support upgrade monitoring and historical queries.
[0032] In this embodiment, the smart measurement switch generates a public-private key pair when it leaves the factory. The public key is registered with the blockchain network as an identity identifier. The smart measurement switch also includes a device identifier, including a MAC address, serial number or IMEI number, which is used to bind and verify the identity with the public key.
[0033] In this embodiment, after the upgrade management node generates the upgrade package, it calculates the hash value of the upgrade package and uses an encryption algorithm to encrypt and compress the upgrade package. The upgrade management node packages the hash value, version number, applicable device type, encryption key digest, and digital signature into transaction data and writes it into the blockchain through the blockchain network consensus node.
[0034] In this embodiment, the blockchain network employs a practical Byzantine fault-tolerant consensus algorithm, based on a majority-rule mechanism, requiring nodes to exchange information and reach consensus through a majority result. Its fault tolerance is controlled at 1 / 3 of the total number of nodes; the system can operate stably when more than 2 / 3 of the nodes are normal. The consensus process includes three phases: pre-preparation, preparation, and commit. The blockchain network also integrates the IPFS storage system for storing large upgrade packages. IPFS is a distributed network transmission protocol that can divide files into many small chunks and place them in different locations on servers, then use a special method to find and transmit these chunks. This allows for faster, more secure, and more fault-tolerant file storage. IPFS is a decentralized file system that does not rely on a single centralized server, thus offering higher availability and robustness. IPFS uses content addressing to uniquely identify files, ensuring file uniqueness and verifiability, and avoiding single points of failure. IPFS utilizes peer-to-peer communication and content caching to improve network efficiency and file access speed, especially in a distributed environment. IPFS makes file sharing and distribution simpler and more efficient, allowing any node to become a content producer and consumer.
[0035] In this embodiment, the smart contract includes an upgrade rule module, an authorization verification module, and a rollback management module; 1. The upgrade rules module defines device upgrade conditions, including device batches, version compatibility, and security policies. This module is responsible for defining and managing all access conditions and business rules for device upgrades. These rules are stored on the blockchain in a programmable form, ensuring that the rules themselves are public, transparent, and tamper-proof. Specific rules include, but are not limited to: 1) Equipment batch strategy: Only equipment from specific production batches or models can be upgraded to prevent incompatible equipment from being upgraded incorrectly.
[0036] 2) Version Compatibility Matrix: Define a multi-dimensional version upgrade path table, clearly specifying which older versions are allowed to be upgraded to which newer versions, avoiding logical errors that may be caused by cross-version upgrades. For example, only allow devices to upgrade from V1.1 or V1.2 to V1.3, but not directly from V1.0.
[0037] 3) Security Policy Engine: Integrates more granular security control conditions, such as requiring the device to be in a healthy security self-check state before initiating an upgrade; or requiring the device to be in a specific trusted network environment.
[0038] 4) Dynamic rule update mechanism: Authorized administrators can dynamically update and publish rules through multi-signature transactions, enabling the system to flexibly adapt to new security threats or business needs.
[0039] 2. The authorization verification module makes authorization decisions based on device identity and upgrade rules. This module executes automated, decentralized authorization decisions based on the policies and device identity defined in the upgrade rules module. Its verification process is a multi-factor, step-by-step on-chain logical judgment: 1) Identity Verification: After receiving the upgrade authorization request from the device, the module first extracts the device's digital certificate or public key attached to the request. Then, it queries the pre-stored, tamper-proof official device registry on the blockchain to verify whether the device's identity is legally registered and within the validity period, initially excluding illegal or unauthorized devices.
[0040] 2) Version Path Compliance Check: After the device identity verification is passed, the module further extracts the device's current version number and the target upgrade version number from the request. By calling the version compatibility matrix in the upgrade rules module, it verifies whether this upgrade request conforms to the preset, linear version evolution path, preventing the risks caused by version rollback or skip upgrades.
[0041] 3) Dynamic Policy Compliance Review: Finally, the module verifies whether the device or its batch meets all the additional conditions for this upgrade, based on the real-time policy defined in the upgrade rules module. These conditions may include: ① Time window restriction: The upgrade operation must be performed within a preset maintenance time window. ② Geofence permission: Confirm that the device is in a geographically permitted area for upgrade based on the location information reported by the device. ③ System load check: The device needs to report its current CPU and memory load to ensure that it is within the threshold for safe upgrade. Only when all the above checks pass will the authorization verification module generate a valid, timestamped upgrade authorization credential and record it on the blockchain. This credential is the only permission for the device to perform the upgrade operation.
[0042] 3. The rollback management module is triggered when an upgrade fails, automatically retrieving the most recently successfully upgraded version and performing a rollback. This module is specifically designed to handle upgrade failure scenarios. When post-upgrade verification fails, or the device actively reports a fault, this module is triggered to ensure that the device can automatically and quickly recover to the previous known good state.
[0043] 1) Smart Triggering and Version Retrieval: The module monitors upgrade failure events on the blockchain. Once triggered, it automatically queries the device's upgrade history on the blockchain. Leveraging the immutability and traceability of the blockchain, it accurately locates and returns the version number of the device's most recent successful upgrade and the on-chain storage hash value of its corresponding upgrade package.
[0044] 2) Trusted Rollback Package Acquisition and Verification: Based on the version information and hash value returned by the smart contract, the device requests the download of the corresponding historical stable version upgrade package (rollback package) from the upgrade management node. After downloading, the device recalculates the hash value of the rollback package locally and compares it with the standard value recorded on the chain to ensure the integrity and authenticity of the rollback package itself and prevent the introduction of new risks during the rollback process.
[0045] 3) Automatic Execution and State Consolidation: After the rollback package verification is successful, the device automatically executes the rollback operation, restoring the program to the historical stable version. The key steps of the entire rollback operation (such as start, progress, and completion) and the final successful result are all written to the blockchain in real time as new transaction records, forming a closed-loop and reliable rollback audit trail.
[0046] like Figure 2 As shown, this invention also proposes a method for upgrading a smart measurement switch program, comprising the following steps: S1. The upgrade management node generates an upgrade package, calculates the hash value of the upgrade package, and writes the hash value of the upgrade package and data information (not limited to version number, applicable device type, encryption key digest and digital signature) into the blockchain, and performs signing and verification through a smart contract. S2. Before initiating an upgrade request, the intelligent measurement switch submits its device public key and unique device identifier to the blockchain network. The device is authenticated by the distributed and tamper-proof device registration information stored on the blockchain network. S3. The intelligent measurement switch connects to the blockchain network to check if there is an upgrade package suitable for itself; if so, the device sends an upgrade request to the upgrade management node, which includes the device's identity information, current version number, and target version number. S4. After receiving the upgrade request, the upgrade management node sends the upgrade package to the intelligent measurement switch device. The intelligent measurement switch device verifies the integrity and legality of the upgrade package through the blockchain network. S5. After the upgrade package verification is successful, the smart measurement switch device calls the smart contract on the blockchain network to apply for upgrade authorization; the smart contract performs authorization verification based on the device identity information, current version number and upgrade rules. S6. After obtaining authorization, the intelligent measurement switch device performs an upgrade operation. During the upgrade process, the intelligent measurement switch device records the upgrade progress and status information to the blockchain network in real time. S7. After the upgrade is completed, the intelligent measurement switch device verifies the upgrade result. If the verification is successful, the upgrade success information is recorded on the blockchain. If the verification fails, the rollback mechanism of the smart contract is triggered, and the rollback result is recorded on the blockchain.
[0047] In this embodiment, the intelligent measurement switch device verifies the integrity and legality of the upgrade package through a blockchain network, specifically as follows: After receiving the upgrade package, the intelligent measurement switch device uses the same cryptographic hash algorithm as when the upgrade package was generated to recalculate the hash value of the upgrade package locally, and records it as the first hash value; The intelligent measurement switchgear initiates a query request to the blockchain network through its built-in blockchain client to obtain the standard hash value corresponding to the upgrade package version, which is pre-written into the blockchain by the upgrade management node and is recorded as the second hash value. The device compares the first hash value with the second hash value; only when the first hash value and the second hash value are completely consistent is the upgrade package determined to be complete and tamper-proof, and the verification passed; if they are inconsistent, the upgrade process is immediately terminated and the verification failure event is recorded to the blockchain network.
[0048] In this embodiment, the smart contract performs authorization verification based on device identity information, current version number, and upgrade rules as follows: The smart contract receives the upgrade authorization request sent by the device, extracts the identity public key of the smart measurement switch device from it, and queries the pre-stored, tamper-proof official device registry on the blockchain to verify whether the public key exists in the list of authorized devices. After the device identity verification is successful, the smart contract extracts the current version number of the device and the target upgrade version number from the request; then, the contract queries the upgrade rule matrix stored internally to verify whether the upgrade of the device from the current version to the target version conforms to the preset version upgrade path; According to the upgrade rules, the smart contract checks whether the device or its batch of devices meets the specific strategies and conditions for this upgrade. These conditions include, but are not limited to: upgrade window time limits, geographical location permission of the device's location, or whether the device's self-inspection report on its security status has passed.
[0049] In this embodiment, the mechanism for triggering the rollback of the smart contract is specifically as follows: When the upgrade verification fails, the smart measurement switch sends a rollback request to the blockchain network. The smart contract responds automatically, retrieving and returning the version number of the device's most recent successful upgrade and the on-chain hash value of its corresponding upgrade package from the immutable upgrade history on the blockchain. The smart measurement switch device requests the corresponding historical stable version upgrade package from the upgrade management node based on the version information and hash value returned by the smart contract, and performs hash calculation again to compare with the on-chain data to verify the integrity of the rollback package; After the rollback package is verified, the rollback operation is performed to restore the program to a historical stable version. After the operation is completed, the successful rollback result and the new device status are written to the blockchain as transaction records.
[0050] In this embodiment, all upgrade-related operation records, including identity authentication requests, upgrade requests, verification results, authorization information, execution processes, and rollback operations, are recorded in the form of transactions on the blockchain network and distributed and synchronized on multiple consensus nodes of the blockchain network. Any write operation to blockchain data, including uploading upgrade package information to the chain, upgrade authorization, and status recording, must be verified by the consensus algorithm of multiple consensus nodes before it can be confirmed.
[0051] like Figure 2 As shown, the specific steps of the intelligent measurement switch program upgrade method are as follows: (1) Upgrade package generation and on-chain Upgrade management node 3 generates a corresponding upgrade package based on the functional requirements and security vulnerabilities of the smart measurement switchgear. The upgrade package uses an encrypted compressed format and includes program code, configuration files, and upgrade instructions. Upgrade management node 3 calculates the hash value of the upgrade package, for example, using the SHA-256 algorithm to obtain a unique hash value H. Then, upgrade management node 3 packages the hash value H, version number V, applicable device type T, release time, and other information of the upgrade package into transaction data and writes it into a block of the blockchain through the consensus nodes of blockchain network 1. Simultaneously, upgrade management node 3 signs the transaction data using its private key to ensure the authenticity and immutability of the data. After receiving the transaction data, smart contract 2 verifies the validity of the signature and stores the upgrade package information on the blockchain.
[0052] (2) Device authentication
[0053] Upon leaving the factory, the intelligent measurement switch device 4 generates a unique public-private key pair and registers the public key on the blockchain as its identity identifier. When the intelligent measurement switch device 4 needs to initiate an upgrade request, it first connects to the blockchain network 1 via a secure communication module and sends an authentication request containing the device's public key and device identifier (such as a MAC address). After receiving the request, the consensus node in the blockchain network 1 queries the device registration information on the blockchain to verify the consistency of the device's public key and identifier. If the verification is successful, the device 4 obtains a legitimate identity and is allowed to proceed with subsequent upgrade operations.
[0054] (3) Initiation of upgrade request
[0055] The smart measurement switch device 4 queries the upgrade package information stored in the smart contract 2 through the blockchain network 1. Based on its own device type and current program version, it determines whether an available upgrade package exists. If one exists, the smart measurement switch device 4 initiates an upgrade request to the upgrade management node 3. The request includes the device's identity information, current version number, and upgrade package version number. Upon receiving the request, the upgrade management node 3 verifies the device's identity and upgrade permissions. If the conditions are met, it approves the upgrade request of device 4.
[0056] (4) Upgrade package verification
[0057] Upgrade management node 3 sends the upgrade package to device 4. Upon receiving the upgrade package, device 4 first decrypts and decompresses it, then calculates its hash value H'. Device 4 queries the hash value H of the upgrade package stored in smart contract 2 via blockchain network 1 and compares H' with H. If H' matches H, it means the upgrade package has not been tampered with during transmission, and its integrity is guaranteed; otherwise, the upgrade package may have been maliciously tampered with, device 4 refuses to execute the upgrade operation, and sends an error message back to upgrade management node 3.
[0058] (5) Smart contract authorization
[0059] After verifying the integrity of the upgrade package, device 4 invokes smart contract 2 on the blockchain to request upgrade authorization. Smart contract 2 queries the preset upgrade rules based on device 4's identity information, current version number, and upgrade package version number. For example, it checks whether the device belongs to an allowed upgrade batch and whether the current version supports upgrading to the target version. If the upgrade rules are met, smart contract 2 generates an authorization certificate and records the authorization information on the blockchain; otherwise, authorization is denied, and device 4 cannot perform the upgrade.
[0060] (6) Upgrade execution
[0061] After obtaining authorization, Device 4 begins the upgrade process. During the upgrade, Device 4 sends upgrade progress and key status information, such as completed upgrade steps and currently running modules, to Blockchain Network 1 via transactions. These transactions are then packaged and recorded on the blockchain by consensus nodes. This enables real-time monitoring and traceability of the upgrade process. Furthermore, Device 4 employs incremental upgrades, updating only the necessary program modules, thus reducing upgrade time and resource consumption.
[0062] (7) Upgrade verification and rollback
[0063] After the upgrade is complete, device 4 restarts and enters the upgrade verification phase. Device 4 conducts comprehensive testing of the upgraded program, including functional testing, performance testing, and security testing. For example, it checks whether the measurement accuracy of power parameters meets requirements, whether the communication module is working properly, and whether the device can withstand common security attacks. If the verification passes, device 4 sends the upgrade success information to blockchain network 1, and smart contract 2 updates the device's version status and records the upgrade success time and related information. If the verification fails, device 4 triggers the rollback mechanism of smart contract 2. Smart contract 2 queries the blockchain for the most recently successfully upgraded version information and the corresponding upgrade package hash value of device 4. Device 4 obtains the upgrade package for that version from upgrade management node 3 based on the hash value, executes the rollback operation, and restores the program to the previous stable version. After the rollback is complete, device 4 records the rollback result on the blockchain and reports the upgrade failure and rollback reason to upgrade management node 3 for problem analysis and repair.
[0064] (8) Upgrade records are uploaded to the blockchain
[0065] Throughout the upgrade process, all operation records, including identity authentication requests, upgrade requests, upgrade package verification results, smart contract authorization information, upgrade execution process, upgrade verification results, and rollback operations, are recorded on the blockchain in the form of transactions. These records are immutable, facilitating subsequent auditing and traceability. Administrators can query the upgrade history of any device through user terminal 5 to understand the problems encountered during the upgrade process and their solutions, providing a basis for subsequent upgrade optimizations.
[0066] The above description represents the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A blockchain-based intelligent measurement switch program upgrade system, characterized in that, include: A blockchain network, composed of multiple consensus nodes, is used to store information including but not limited to the hash value of upgrade packages, the identity information of smart metering switches, and upgrade records. The consensus nodes achieve data consistency through a consensus algorithm and manage permissions using a consortium blockchain or a private blockchain. Smart contracts, deployed on the blockchain network, define the rules and logic of the upgrade process, including the verification, authorization, distribution, and rollback of upgrade packages. The smart contracts are executed automatically through event-driven mechanisms and support dynamic updates to the upgrade strategy. The upgrade management node is used to generate and publish upgrade packages, calculate the hash value of the upgrade package, and write the hash value of the upgrade package and data information including but not limited to version number, applicable device type, encryption key digest and digital signature into the blockchain network, and interact with smart measurement switch devices; The intelligent measurement switch device has a built-in blockchain client and a secure communication module, which are used to connect to the blockchain network, perform identity authentication, verify the legality and integrity of the upgrade package, execute the upgrade operation, and record the upgrade status and progress to the blockchain network. The user terminal is used to interact with the blockchain network, view the upgrade status, manage upgrade tasks, and perform audit operations; the user terminal provides a graphical interface to support upgrade monitoring and historical queries.
2. The blockchain-based intelligent measurement switch program upgrade system according to claim 1, characterized in that, The intelligent measurement switch generates a public-private key pair at the factory, and the public key is registered with the blockchain network as an identity identifier; the intelligent measurement switch also includes a device identifier, including a MAC address, serial number or IMEI number, which is used for identity authentication and is bound to the public key for verification.
3. The blockchain-based intelligent measurement switch program upgrade system according to claim 1, characterized in that, After generating the upgrade package, the upgrade management node calculates the hash value of the upgrade package and uses an encryption algorithm to encrypt and compress the upgrade package. The upgrade management node packages the hash value, version number, applicable device type, encryption key digest, and digital signature into transaction data, and writes it into the blockchain through the blockchain network consensus node.
4. The blockchain-based intelligent measurement switch program upgrade system according to claim 1, characterized in that, The blockchain network employs a practical Byzantine fault-tolerant consensus algorithm and also integrates an IPFS storage system for storing large-size upgrade packages.
5. The blockchain-based intelligent measurement switch program upgrade system according to claim 1, characterized in that, The smart contract includes an upgrade rules module, an authorization verification module, and a rollback management module. The upgrade rules module defines device upgrade conditions, including device batch, version compatibility, and security policies. The authorization verification module makes authorization decisions based on device identity and upgrade rules. The rollback management module is triggered when an upgrade fails, automatically retrieving the most recently successfully upgraded version and executing a rollback.
6. A method for upgrading the intelligent measurement switch program based on the system according to any one of claims 1-5, characterized in that, Includes the following steps: The upgrade management node generates an upgrade package, calculates the hash value of the upgrade package, and writes the hash value of the upgrade package and data information (not limited to version number, applicable device type, encryption key digest, and digital signature) into the blockchain, and performs signing and verification through a smart contract. Before initiating an upgrade request, the intelligent measurement switchgear submits its device public key and unique device identifier to the blockchain network. The device is authenticated by the distributed and tamper-proof device registration information stored on the blockchain network. The intelligent measurement switchgear connects to the blockchain network to check if there is an upgrade package suitable for it. If present, the device sends an upgrade request to the upgrade management node. The request includes the device's identity information, the current version number, and the target version number. After receiving the upgrade request, the upgrade management node sends the upgrade package to the smart measurement switch device. The smart measurement switch device verifies the integrity and legality of the upgrade package through the blockchain network. After the upgrade package is verified, the smart measurement switch calls the smart contract on the blockchain network to request upgrade authorization; the smart contract performs authorization verification based on the device identity information, current version number and upgrade rules; After obtaining authorization, the intelligent measurement switch device performs an upgrade operation. During the upgrade process, the intelligent measurement switch device records the upgrade progress and status information to the blockchain network in real time. After the upgrade is completed, the intelligent measurement switch equipment verifies the upgrade results; If the verification is successful, the upgrade success information will be recorded in the blockchain; If the verification fails, the smart contract's rollback mechanism is triggered, and the rollback result is recorded on the blockchain.
7. The method for upgrading a smart measurement switch program according to claim 6, characterized in that, The intelligent measurement switch device verifies the integrity and legitimacy of the upgrade package through a blockchain network, specifically: After receiving the upgrade package, the intelligent measurement switch device uses the same cryptographic hash algorithm as when the upgrade package was generated to recalculate the hash value of the upgrade package locally, and records it as the first hash value; The intelligent measurement switch device initiates a query request to the blockchain network through its built-in blockchain client to obtain the standard hash value corresponding to the upgrade package version, which is pre-written into the blockchain by the upgrade management node and is recorded as the second hash value. The intelligent measurement switch device compares the first hash value with the second hash value; only when the first hash value and the second hash value are completely consistent is the upgrade package determined to be complete and untampered, and the verification passed; if they are inconsistent, the upgrade process is immediately terminated and the verification failure event is recorded to the blockchain network.
8. The method for upgrading a smart measurement switch program according to claim 6, characterized in that, The smart contract performs authorization verification based on device identity information, current version number, and upgrade rules as follows: The smart contract receives the upgrade authorization request sent by the device, extracts the identity public key of the smart measurement switch device from it, and queries the pre-stored, tamper-proof official device registry on the blockchain to verify whether the public key exists in the list of authorized devices. After the device identity verification is successful, the smart contract extracts the current version number of the device and the target upgrade version number from the request; then, the contract queries the upgrade rule matrix stored internally to verify whether the upgrade of the device from the current version to the target version conforms to the preset version upgrade path; The smart contract checks whether the device or its batch of devices meets the specific strategies and conditions for this upgrade according to the upgrade rules. These conditions include, but are not limited to: upgrade window time limits, geographical location permission of the device's location, or whether the device's self-inspection report on its security status has passed.
9. The method for upgrading a smart measurement switch program according to claim 6, characterized in that, The specific mechanism for triggering the rollback of the smart contract is as follows: When the upgrade verification fails, the smart measurement switch sends a rollback request to the blockchain network. The smart contract responds automatically, retrieving and returning the version number of the device's most recent successful upgrade and the on-chain hash value of its corresponding upgrade package from the immutable upgrade history on the blockchain. The smart measurement switch device requests the corresponding historical stable version upgrade package from the upgrade management node based on the version information and hash value returned by the smart contract, and performs hash calculation again to compare with the on-chain data to verify the integrity of the rollback package; After the rollback package is verified, the rollback operation is performed to restore the program to the historical stable version. After the operation is completed, the successful rollback result and the new device status are written to the blockchain as transaction records.
10. A method for upgrading a smart measurement switch program according to claim 6, characterized in that, All upgrade-related operation records, including identity authentication requests, upgrade requests, verification results, authorization information, execution processes, and rollback operations, are recorded in the form of transactions on the blockchain network and distributed and synchronized across multiple consensus nodes. Any write operation to blockchain data, including uploading upgrade package information to the chain, upgrade authorization, and status recording, must be verified by the consensus algorithm of multiple consensus nodes before it can be confirmed.