Tamper-proofing method and system for cryptographic instructions based on shared ledger

CN123020231APending Publication Date: 2026-10-30北京佳芯信息科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611426300.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-15
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

若某个数据包被恶意替换或序号被修改,接收端无法检测到篡改,仍会将其与其他数据包一起重组,导致还原出的指令错误

Benefits of technology

(1)本发明通过预设分隔符对待防篡改指令进行分割,再按粒度范围长度规整得到均衡碎片,并为每个碎片附加唯一标识和顺序标识,由于长度规整保证了碎片大小均衡,顺序标识确保了重组时的可追溯性,解决了现有技术碎片无序且无法验证完整性的问题;实现了指令碎片的规范化生成与可追溯标识绑定。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123020231A_ABST
    Figure CN123020231A_ABST
Patent Text Reader

Abstract

The application relates to the technical field of information security, and discloses an encryption instruction tamper-proofing method and system based on a shared account book. The method comprises the following steps: obtaining a to-be-tamper-proofing instruction and a real-time path load, and performing fragmentation preprocessing to obtain an initial fragment set; performing redundancy coding storage scheduling according to the initial fragment set to obtain a protected fragment sequence; performing load minimization resource allocation according to the protected fragment sequence and the real-time path load to obtain a transmission channel combination; performing branch transmission according to the protected fragment sequence to obtain a transmission-after-fragment sequence; performing receiving check abnormality statistics according to the transmission-after-fragment sequence and traceable verification records to obtain an abnormal fragment quantity, and performing abnormal threshold feedback type re-division verification to obtain a screened fragment sequence; and performing fragment repair recombination check according to the screened fragment sequence to obtain a tamper-proofing verification instruction. The method can realize tamper-proofing and traceability of instruction transmission.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of information security technology, and in particular to a method and system for preventing tampering with encrypted instructions based on a shared ledger. Background Technology

[0002] Currently, control commands for infrastructure transmission in distributed networks face risks such as data tampering, loss, and difficulties in fragmented reassembly. A single transmission path or simple encryption is insufficient to address dynamic threats; fragments are easily replaced or out of order in different paths, making it impossible for the receiving end to accurately reconstruct the tamper-proof commands. To solve the problems of secure fragment arrival and integrity verification, a data security technology is needed that can both ensure the reliability of fragment transmission and enable traceable verification.

[0003] In one existing technology, the system splits the instruction to be tampered with into multiple numbered data packets, which are transmitted sequentially through a single fixed path. The sending end uses a symmetric encryption algorithm to encrypt each data packet independently, and the receiving end receives and decrypts the data packets in sequence, then reassembles the instruction. If the receiving end does not receive a data packet with a certain sequence number within a preset timeout period, it requests a retransmission from the sending end. The transmission path remains fixed, and the load status or link quality of each node in the network is not monitored. The receiving end only checks whether the sequence numbers of the data packets are consecutive, without verifying whether the content of each data packet has been tampered with or replaced during transmission. If a data packet is maliciously replaced or its sequence number is modified, the receiving end cannot detect the tampering and will still reassemble it with other data packets, resulting in an incorrect reconstructed instruction. When network congestion or node failure occurs, a large number of data packets on the fixed path are easily lost, frequently triggering the retransmission mechanism and severely affecting the overall transmission efficiency. Existing technologies protect instructions through fixed-path transmission and sequence number checks, resulting in the inability to detect data packet tampering and low efficiency during network congestion.

[0004] Therefore, existing technologies cannot achieve tamper-proof and traceable instruction transmission. Summary of the Invention

[0005] This invention provides a method and system for preventing tampering of encrypted instructions based on a shared ledger, so as to achieve tamper-proof and traceable instruction transmission.

[0006] In a first aspect, to address the aforementioned technical problems, this invention provides a method for preventing tampering with encrypted instructions based on a shared ledger, comprising: Obtain the instruction to be tampered with and the real-time path load, and perform fragmentation preprocessing on the instruction to be tampered with to obtain an initial fragment set; Based on the initial fragment set, redundant coding and storage scheduling are performed to obtain the protected fragment sequence; Based on the protection fragment sequence and the real-time path load, a path load switching calculation is performed to obtain the switching transmission path, and a load minimization resource allocation is performed based on the switching transmission path to obtain the transmission channel combination. Based on the protection fragment sequence, a hash ledger is solidified to obtain a traceable and verifiable record. The protection fragment sequence is then split and transmitted according to the transmission channel combination to obtain the transmitted fragment sequence. Based on the transmitted fragment sequence and the traceable verification record, receive verification anomaly filtering is performed to obtain the filtered fragment sequence; Based on the selected fragment sequence, fragment repair and recombination verification is performed to obtain tamper-proof verification instructions.

[0007] Secondly, the present invention provides an encryption instruction anti-tampering system based on a shared ledger, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the method described above.

[0008] Thirdly, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described above.

[0009] Compared with the prior art, the present invention has the following beneficial effects: (1) The present invention divides the instructions to be tampered with by a preset separator, and then obtains balanced fragments by regularizing the length according to the granular range. Each fragment is given a unique identifier and a sequence identifier. Since the length regularization ensures the balance of fragment size, the sequence identifier ensures the traceability during reassembly. This solves the problem of disordered fragments and inability to verify integrity in the prior art. It realizes the standardized generation of instruction fragments and the binding of traceable identifiers.

[0010] (2) This invention uses Reed-Solomon coding to generate redundant fragments, allocates storage nodes through hash mapping and migrates to subsequent nodes of the hash ring in case of failure, calculates the initial path through shortest path search and switches according to load, and finally selects the path with the least load to allocate transmission channels. Since the redundant coding provides fault tolerance, the dynamic path switching avoids congested nodes, overcoming the defects of fixed single path being easy to lose and inefficient retransmission; it realizes highly reliable storage of fragments and adaptive efficient transmission.

[0011] (3) The present invention uses a hash algorithm to re-verify the fragments after transmission and compares them with the ledger reference value to obtain the number of abnormal fragments. After verification by feedback re-segmentation, the fragments are repaired by Reed-Solomon decoding, and the fragments are reassembled in sequence and the integrity of the instructions is verified by cyclic redundancy. Since the ledger solidified verification value provides an immutable comparison benchmark, the repair and reassembly ensures the accuracy of the fragment content, solving the problem of being unable to detect tampering and reassembly errors; and realizing full-process anti-tampering and traceable verification of instruction transmission. Attached Figure Description

[0012] Figure 1 This is a schematic diagram of the tamper-proof method for encrypted instructions based on a shared ledger provided in the first embodiment of the present invention; Detailed Implementation

[0013] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0014] Reference Figure 1 The first embodiment of the present invention provides a method for preventing tampering with encrypted instructions based on a shared ledger, comprising the following steps: S11, obtain the instruction to be tampered with and the real-time path load, and perform fragmentation preprocessing on the instruction to be tampered with to obtain an initial fragment set; S12, Based on the initial fragment set, perform redundant coding storage scheduling to obtain a protection fragment sequence; S13, perform path load switching calculation based on the protection fragment sequence and the real-time path load to obtain the switching transmission path, and perform load minimization resource allocation based on the switching transmission path to obtain the transmission channel combination; S14, based on the protection fragment sequence, perform hash ledger solidification to obtain traceable and verifiable records, and then split and transmit the protection fragment sequence according to the transmission channel combination to obtain the transmitted fragment sequence; S15, based on the transmitted fragment sequence and the traceable verification record, perform reception verification anomaly filtering to obtain the filtered fragment sequence; S16, perform fragment repair and recombination verification based on the selected fragment sequence to obtain anti-tampering verification instructions.

[0015] In step S11, the instruction to be tampered with and the real-time path load are obtained, and the instruction to be tampered with is preprocessed into fragments to obtain an initial fragment set, including: Based on the instruction to be tampered with, the instruction is segmented using a preset delimiter to obtain a logical segment sequence; According to a preset granularity range, the logical segment sequence is length-normalized to obtain a balanced fragment sequence; Based on the balanced fragment sequence, a unique identifier is generated, and an order identifier is added according to the fragment order to obtain the initial fragment set.

[0016] Specifically, the instructions to be tampered with are segmented according to preset delimiters to obtain a sequence of logical segments. The preset delimiter set is determined by statistically analyzing the delimiters appearing in historical instruction samples. At least 100 historical instruction samples from the past month are collected, and the frequency of periods, semicolons, commas, newlines, and conjunctions such as "firstly," "then," and "secondly" is counted. The top 5 most frequent characters or words are used as the delimiter set. The instructions to be tampered with are scanned from the beginning, and an empty list is initialized to store the logical segments. The current scan position is set as the instruction start position. The positions of delimiters in the instructions are searched sequentially. Whenever a delimiter is encountered, the substring from the current scan position to the delimiter position is treated as a logical segment and added to the list. Then, the current scan position is moved after the delimiter. After the scan is complete, if there is any remaining content after the last delimiter, it is also added to the list as a logical segment, thus obtaining the sequence of logical segments.

[0017] The logical segment sequence is length-normalized according to a preset granularity range to obtain a balanced fragment sequence. The preset granularity range is determined as follows: The total number of characters in the tamper-proof instruction is counted, denoted as L. Based on network transmission efficiency and storage node capacity, the expected number of fragments N is set to a fixed integer between 4 and 8, for example, 4. The target granularity is calculated as L divided by N, and then the lower limit of the granularity range is set to 0.9 times the target granularity, and the upper limit is set to 1.1 times the target granularity. Each logical segment in the logical segment sequence is traversed, and the number of characters in each logical segment is counted. If the number of characters in a logical segment exceeds the upper limit of the granularity range, the logical segment is split into multiple sub-segments. Starting from the beginning of the logical segment, each time a semantic boundary is encountered, such as a space, comma, or period, and the cumulative number of characters is close to the upper limit, the segment is cut off to form a sub-segment, until the length of each sub-segment does not exceed the upper limit. If the number of characters in a logical segment is below the lower limit of the granularity range, it is merged with the next adjacent logical segment. If the number of characters after merging is still below the lower limit, merging continues until the length of the merged segment reaches or exceeds the lower limit, or merging can no longer be performed. This splitting and merging adjustment is repeated using a loop and character counting method until the number of characters in all fragments is within the preset granularity range, between the lower and upper limits. After adjustment, these fragments are arranged in their original order to obtain a balanced fragment sequence.

[0018] Based on the balanced fragment sequence, unique identifiers are generated, and sequence identifiers are appended according to the fragment order to obtain the initial fragment set. The unique identifier is a fixed-length string (e.g., 128 bits) generated by combining the current timestamp (in milliseconds), the machine's unique identifier (e.g., MAC address), and a sequence number that increments with each fragment. A standard implementation is used, such as concatenating the timestamp, MAC address, and sequence number in order and then performing a fixed-length modulo operation to ensure a fixed length. Specifically, the concatenated string is converted to a fixed-length string (e.g., 128 bits) using a hash function like SHA-1. The sequence identifier is generated according to the natural order of the fragments in the balanced fragment sequence, incrementing from 1, and an integer sequence number is appended to each fragment. The unique identifier and sequence identifier are written into the header metadata of each fragment in a fixed format, such as "ID: unique identifier string; SEQ: sequence number". The fragments with the identifiers are then arranged in their original order to obtain the initial fragment set.

[0019] This preprocessing step ensures balanced fragment sizes through normalized segmentation and length regularization, facilitating subsequent distributed transmission and storage; unique and sequential identifiers ensure the distinguishability of each fragment and traceability during reassembly, providing a reliable data foundation for subsequent redundant coding, distributed storage, and tamper-proof verification.

[0020] In step S12, based on the initial fragment set, redundant coding storage scheduling is performed to obtain a protected fragment sequence, including: Based on the initial fragment set, redundant fragment sequence is obtained by performing redundant coding using the Reed-Solomon error correction coding algorithm; Based on the redundant fragment sequence, storage nodes are allocated through hash mapping to obtain a distributed fragment sequence; When the storage node in the distributed fragment sequence is in a preset fault state, the distributed fragments are migrated to subsequent nodes on the hash ring to obtain a protected fragment sequence. When the state of the storage node in the distributed fragment sequence is not the fault state, the current storage node remains unchanged, and a protected fragment sequence is obtained.

[0021] Specifically, redundancy encoding is performed based on the initial fragment set. The initial fragment set contains several fragments of balanced size, each with a unique and sequential identifier; for example, there are four original fragments. The Reed-Solomon error correction coding algorithm is used for redundancy encoding, with the encoding parameters set to (n, k), where k is the number of original fragments (e.g., k=4), n is the total number of encoded fragments, and the number of redundant fragments is n minus k (e.g., n=6, resulting in 2 redundant fragments). During encoding, a finite field is first constructed, and the generator polynomial of this finite field uses a primitive polynomial; for example, for byte data, an 8th-degree primitive polynomial is used. A k-row, n-column generator matrix is ​​constructed over this finite field. The first k columns of this matrix are a k-order identity matrix, and the last n-k columns are the transpose of the Vandermonde matrix, meaning each element of the Vandermonde matrix represents the power of the evaluation point. The data blocks of the k original fragments are treated as k-dimensional row vectors, with each fragment corresponding to a vector element; that is, the fragment data is decomposed into finite field elements in byte order. This row vector is multiplied by the generator matrix to obtain an n-dimensional result vector, where each component represents an encoded fragment. Multiplication is performed over a finite field and includes both multiplication and addition, with addition being an XOR operation. Of the n fragments obtained after encoding, the first k are identical to the original fragments, and the remaining n minus k are redundancy check fragments. Arranging these fragments in order yields the redundancy fragment sequence.

[0022] Storage nodes are allocated based on the redundant fragment sequence using a hash mapping method. Multiple storage nodes are pre-deployed, each with a unique name or identifier, such as node 1, node 2, node 3, node 4, and node 5. A ring-shaped hash space is constructed, with values ​​ranging from 0 to 2^32 minus 1. Using a standard hash function, such as MD5-based hash modulo, but without relying on a specific algorithm, the hash value of each storage node name is calculated and mapped to a position on the ring, distributing all nodes on the ring. For each fragment in the redundant fragment sequence, its unique identifier is extracted, such as the identifier string generated in step S11. The same hash function is used to calculate the hash value of this identifier, and the first node on the ring is located clockwise from the hash value position. The fragment is then allocated to that node. After all fragments are allocated, each fragment is associated with a storage node, forming a distributed fragment sequence.

[0023] The status of each storage node is monitored in real time. Each node sends a heartbeat signal to the central controller at a preset heartbeat interval. The heartbeat interval is determined by collecting heartbeat interval data from all nodes operating normally over the past week, calculating the 95th percentile of these interval values ​​as the base heartbeat interval, for example, 30 seconds. A node is considered faulty if it fails to receive three consecutive heartbeats; therefore, the fault determination time is three times the heartbeat interval, for example, 90 seconds. The central controller maintains the last heartbeat reception time for each node and checks it every 10 seconds. If the difference between the current time and the last heartbeat time exceeds three times the heartbeat interval, the node is determined to be in a preset fault state. Furthermore, when a node actively returns an error code or reports a communication timeout, it is also immediately determined to be in a fault state.

[0024] For each fragment in the distributed fragment sequence, check the status of its allocated storage node. If the node is faulty, migrate the fragment to a subsequent node on the hash ring. Starting from the faulty node's position on the ring, search for the first healthy node in a clockwise direction, copy or move the fragment's data to that healthy node, and update the node association information in the distributed fragment sequence. If the node is healthy, keep the current storage node unchanged. After traversing all fragments, a protected fragment sequence is obtained. Each fragment in this sequence is stored on a healthy node, and due to redundant coding, even if at most n minus k fragments are lost, the original data can still be recovered from the remaining fragments. This step, through redundant coding and dynamic fault migration, achieves highly reliable storage of fragments, laying the foundation for subsequent transmission and verification.

[0025] In step S13, based on the protected fragment sequence and the real-time path load, a path load switching calculation is performed to obtain a switching transmission path. Then, based on the switching transmission path, a load-minimizing resource allocation is performed to obtain a transmission channel combination, including: Based on the protected fragment sequence, a shortest path search is performed to obtain the initial transmission path; When the real-time path load exceeds the preset path load threshold, the shortest path is re-searched based on the initial transmission path to obtain a switching transmission path. When the real-time path load is not greater than the path load threshold, the initial transmission path is directly used as the switching transmission path. The switching transmission path with the lowest real-time path load is selected sequentially for overall network resource allocation to obtain a transmission channel combination.

[0026] Specifically, a shortest path search is performed based on the protection fragment sequence to obtain the initial transmission path. Each fragment in the protection fragment sequence needs to be transmitted from the sender to the designated receiver. The network topology consists of multiple routing nodes and links between nodes. The weight of each link is obtained by weighted summation of the link's transmission delay and bandwidth utilization. The delay weight and bandwidth utilization weight are determined through regression analysis of transmission success rate data for different load combinations under historical normal operating conditions; for example, the delay weight is 0.6 and the bandwidth utilization weight is 0.4. The sender is the source node, and the destination receiver for each fragment is the target node. Using the classic shortest path search process, the distance from the source node to itself is initialized to 0, and the distance to all other nodes is infinite. A queue of nodes to be processed is maintained. The source node is added to the queue, and the nodes in the queue are processed iteratively. Each time, the head node is removed, and all its adjacent nodes are traversed. If the distance from the current node to the source node plus the link weight from the current node to its adjacent node is less than the currently recorded distance of the adjacent node, then the distance is updated, and the adjacent node is added to the end of the queue. This process is repeated until the queue is empty. The sequence of nodes traversed by the shortest distance from the source node to each target node is the initial transmission path for that fragment. This calculation is performed on all fragments to obtain the initial transmission path for each fragment.

[0027] The system acquires real-time load data for each initial transmission path, including bandwidth utilization and transmission latency for all links on the path. A preset path load threshold is determined through statistical analysis of historical network traffic data during normal operation. Bandwidth utilization data for all links during peak network periods (e.g., 2:00 PM to 6:00 PM daily) over the past month is collected, and the 95th percentile of all data is used as the bandwidth utilization threshold. Simultaneously, transmission latency data for the links during the same time period is collected, and the 95th percentile of all data is used as the latency threshold. When the bandwidth utilization of any link on a path exceeds the bandwidth threshold or the transmission latency exceeds the latency threshold, the real-time path load for that path is determined to be greater than the preset path load threshold.

[0028] For each fragment, check the real-time path load of its initial transmission path. If the load exceeds a threshold, it indicates that the current path is nearing congestion, and a backup path needs to be recalculated. In this case, the source and destination nodes of the initial transmission path are used as the new source and destination nodes, and the same shortest path search process as the initial path is adopted, but congested nodes or links are excluded. For example, the outgoing edge weight of congested nodes is set to infinity. A new shortest path is then recalculated and used as the switching transmission path. If the load is not greater than the threshold, the initial transmission path is directly retained as the switching transmission path.

[0029] Once all fragments have been assigned a switching transmission path, overall network resources are allocated to obtain a transmission channel combination. The real-time load value of each switching transmission path is represented by the maximum bandwidth utilization rate among all links on that path. All fragment switching transmission paths are sorted in ascending order of this load value. Each fragment is processed sequentially in this sorted order. For the current fragment, the switching transmission path with the lowest load is selected as its transmission channel, and the remaining bandwidth of all links traversed by that path is updated by subtracting the bandwidth occupied by the allocated fragment from the total bandwidth of the links. This process is repeated until all fragments are allocated. After allocation, each fragment corresponds to a specific transmission channel, and the set of all channels constitutes the transmission channel combination. This combination ensures that high-load paths are not overused, achieving a balanced allocation of network resources and providing a reliable routing scheme for subsequent splitting transmission.

[0030] In step S14, based on the protection fragment sequence, a hash ledger is solidified to obtain a traceable and verifiable record. The protection fragment sequence is then split and transmitted according to the transmission channel combination to obtain a transmitted fragment sequence, including: Based on the protected fragment sequence, a hash verification calculation is performed using the SHA-256 algorithm to obtain a reference verification value; Based on the reference verification value, a distributed ledger is written using a practical Byzantine fault-tolerant algorithm to obtain traceable and verifiable records.

[0031] Specifically, a reference check value is obtained by performing hash verification calculations based on the protection fragment sequence. The protection fragment sequence is a set of fragments obtained after redundancy coding and storage scheduling. Each fragment contains the original data block, a unique identifier, a sequence identifier, and redundancy check information. The hash value of each fragment's data block is calculated using the SHA-256 algorithm. Simultaneously, the original complete data of the tamper-proof instruction is checked using the CRC-32 algorithm, adopting the IEEE 802.3 standard, with an initial value of 0xFFFFFFFF, a polynomial of 0x04C11DB7, and a final XOR of 0xFFFFFFFF, to obtain the instruction's reference CRC value. This value, along with the reference check values ​​of each fragment, is written into the distributed ledger. The specific process of the SHA-256 algorithm is as follows: the fragment data block is treated as a binary bit string. First, a 1 bit is added to the end of the data, followed by consecutive 0 bits, making the length of the padded bits modulo 512 equal to 448. Then, 64 bits of the original data length are appended to the end. The padded message is then divided into several 512-bit message blocks. Eight 32-bit registers are initialized with fixed initial hash values, determined by the first 32 bits of the fractional part of the square root of the first eight prime numbers. For each message block, 64 rounds of iterative compression are performed. Each round includes a selection function, a majority function, a circular shift, and a modular addition operation, using a fixed constant array determined by the first 32 bits of the fractional part of the cube root of the first 64 prime numbers. After processing each message block, the current hash value is modulo-added with the compression result to obtain the initial hash value for the next message block. After the last message block is processed, the values ​​of the eight registers are concatenated sequentially into a 256-bit binary string, converted to hexadecimal representation, and this yields the reference check value for that fragment. This calculation is performed sequentially for each fragment in the protected fragment sequence to obtain the reference check value for each fragment, forming a reference check value set.

[0032] The distributed ledger is written based on the reference check value to obtain a traceable and verifiable record. The distributed ledger network consists of multiple verification nodes, for example, 10 nodes. The Practical Byzantine Fault Tolerance (PBFT) algorithm is used to ensure the consistency and immutability of the ledger data. The specific process of this algorithm is as follows: First, the master node of the current view is determined. The master node is generated in a round-robin manner, with each node taking turns in sequence. The client, i.e., the execution end of this method, packages the reference check value along with the unique identifier of the corresponding fragment, timestamp, and other information into a transaction request and sends it to the master node. After receiving the request, the master node assigns an incrementing sequence number to the transaction and broadcasts a pre-ready message to all replica nodes. After receiving the pre-ready message, each replica node verifies whether the signature, sequence number, and view number in the message are correct. If the verification passes, it broadcasts a ready message to all other nodes. When a node receives ready messages from more than two-thirds of the nodes, it enters the ready state and broadcasts a commit message. When a node receives commit messages from more than two-thirds of the nodes, it considers the transaction to have reached consensus, writes the transaction record to its local ledger, and returns an execution response to the client. Once the client receives the same response from more than two-thirds of the nodes, it confirms that the transaction has been successfully written to the ledger. After writing, the ledger permanently records the reference check value, unique identifier, timestamp, and signature of the writing node for each fragment, forming a traceable and verifiable record. Due to the immutable nature of the distributed ledger, this record provides a reliable comparison benchmark for subsequent verification by the receiving end.

[0033] After the hash ledger is solidified, the protection fragment sequence is distributed and transmitted according to the transmission channel combination determined in step S13. Each fragment is assigned a specific network transmission path. The system performs transmission operations independently for each fragment, encapsulating the fragment data into data packets based on the fragment's transmission path and forwarding them hop-by-hop to the receiving end through the routing nodes along that path. Different fragments may follow different paths during transmission, and synchronous arrival between fragments is not required. The receiving end continuously monitors each path, collects arriving fragments, and temporarily stores them in the order they were received. After all fragments have been transmitted, the receiving end obtains a fragment set. The order of fragments in this set may differ from that at the time of transmission, or they may have been damaged or lost during transmission; this set is called the post-transmission fragment sequence. This step provides an immutable verification benchmark through hash ledger solidification and improves the parallelism and security of transmission through distributed transmission, laying the foundation for subsequent receiving end verification and anomaly screening.

[0034] In step S15, based on the post-transmission fragment sequence and the traceable verification record, reception verification anomaly filtering is performed to obtain a filtered fragment sequence, including: Based on the transmitted fragment sequence, a hash verification value is obtained by performing a hash check using the SHA-256 algorithm. From the post-transmission fragment sequence, fragments whose received check value is inconsistent with the reference check value in the traceable verification record are marked to obtain an anomaly marking sequence; The number of anomaly fragments is obtained by counting the number of marked fragments in the anomaly marking sequence.

[0035] An anomaly threshold feedback-based resegmentation verification is performed on the transmitted fragment sequence and the number of abnormal fragments to obtain a filtered fragment sequence.

[0036] The process involves performing anomaly threshold feedback-based resegmentation verification on the transmitted fragment sequence and the number of abnormal fragments to obtain a filtered fragment sequence, including: When the number of abnormal fragments is less than a preset threshold for the number of abnormal fragments, the transmitted fragment sequence is directly used as the filtered fragment sequence. When the number of abnormal fragments is not less than the abnormal fragment number threshold, the transmitted fragment sequence is discarded, and the instruction segmentation is repeated until the number of abnormal fragments is less than the abnormal fragment number threshold, thus obtaining a filtered fragment sequence.

[0037] Specifically, a hash checksum is calculated based on the post-transmission fragment sequence to obtain the received checksum. The post-transmission fragment sequence is the set of all fragments obtained by the receiving end through network transmission. Each fragment contains a data block, a unique identifier, and a sequence identifier. For each received fragment, the hash value of its data block is calculated using the SHA-256 algorithm. During the calculation, the fragment data block is treated as a binary bit string. First, a 1 bit is added to the end, followed by consecutive 0 bits, making the length of the padded bits modulo 512 equal to 448. Then, 64 bits of the original data length are appended to the end. The padded message is divided into multiple 512-bit message blocks. The initial values ​​of eight 32-bit registers are initialized, determined by a set of fixed constants predefined in the national SHA-256 standard specification. 64 rounds of iterative compression operations are performed on each message block. Each round includes selection functions, majority functions, circular shifts, and modulo addition operations. The constants used in each round also come from a set of fixed constants predefined in the standard. After processing each message block, the current hash value is modulo-added with the compression result to obtain the initial hash value for the next message block. After the last message block is processed, the values ​​of the eight registers are concatenated sequentially to form a 256-bit hash value, which is the receive checksum for that fragment. This calculation is performed on each fragment in the transmitted fragment sequence to obtain the receive checksum for each fragment, forming a set of receive checksums.

[0038] From the post-transmission fragment sequence, fragments whose received checksums do not match the reference checksums in the traceable verification record are marked, resulting in an anomaly marker sequence. The traceable verification record is the record written to the distributed ledger in step S14, which stores the reference checksum corresponding to the unique identifier of each fragment. Each fragment in the post-transmission fragment sequence is traversed, its unique identifier is extracted, and the corresponding reference checksum is searched in the traceable verification record. The received checksum of the current fragment is compared byte-by-byte with the reference checksum. If all bytes are identical, the fragment passes verification; if any byte differs, the fragment is determined to have been tampered with or damaged during transmission, and is marked as an anomaly fragment. After all fragments are compared, an anomaly marker sequence is obtained, where each element corresponds to a fragment, with 1 indicating anomaly and 0 indicating normal.

[0039] The number of fragments marked as abnormal in the anomaly marker sequence is counted to obtain the number of abnormal fragments. The anomaly marker sequence is traversed, and the total number of fragments marked with a value of 1 is accumulated; this total number is the number of abnormal fragments. This number of abnormal fragments is used in subsequent steps to determine whether to trigger re-segmentation verification or directly use the current fragment sequence. This step, through hash verification comparison, verifies the integrity and tamper-proof nature of the received fragments, providing an accurate basis for subsequent anomaly handling and repair.

[0040] Obtain the number of abnormal fragments and the fragment sequence after transmission calculated in step S15. The preset threshold for the number of abnormal fragments is determined through statistical analysis of historical normal transmission case data. Collect data from the past 100 transmission tasks completed under conditions of no malicious attacks and good network conditions, record the number of abnormal fragments in each task, and take the maximum value among these values ​​as the preset threshold for the number of abnormal fragments, for example, a maximum value of 2. Alternatively, it can be determined based on a fixed proportion of the total number of fragments. For example, when the total number of fragments is 6, the threshold is set to 30% of the total number of fragments and rounded up, i.e., 2. This threshold represents the upper limit of abnormal fragments that can be tolerated under normal conditions.

[0041] The number of abnormal fragments calculated at the moment is compared with the threshold. When the number of abnormal fragments is less than the preset threshold, it indicates that the number of damaged or tampered fragments in the current post-transmission fragment sequence is within an acceptable range and can be repaired through error correction decoding. Therefore, the entire post-transmission fragment sequence is directly output as the filtered fragment sequence, and the process proceeds to step S16.

[0042] When the number of abnormal fragments is not less than a preset threshold, it indicates that the number of damaged or tampered fragments has exceeded the fault tolerance capacity, and continued processing cannot recover the original instruction. At this point, the system abandons the current post-transmission fragment sequence and returns to the instruction segmentation operation in step S11, that is, restarts the entire fragmentation, encoding, transmission, and verification process from the source. The above loop is repeated, and the same parameters may be used each time the instruction is re-segmented, until the number of abnormal fragments obtained after a certain transmission is less than the preset threshold. At this point, the post-transmission fragment sequence that meets the condition is output as the filtered fragment sequence; if the condition is still not met after the number of retries reaches the preset maximum number of retries (e.g., 3 times), the transmission is judged to have failed and terminated. This feedback re-segmentation and verification mechanism ensures that only fragment sequences with the number of abnormal fragments within the repairable range enter the subsequent repair steps, avoiding invalid calculations, and ensuring the integrity of the final data through cyclic retries.

[0043] In step S16, based on the selected fragment sequence, fragment repair and recombination verification is performed to obtain an anti-tampering verification instruction, including: Based on the selected fragment sequence, the fragments are repaired using the Reed-Solomon decoding algorithm to obtain the complete fragment sequence; Extract the sequence identifier of each fragment from the complete fragment sequence to obtain a sequence identifier sequence; When the sequence of sequential identifiers is continuous, the complete fragment sequence is sorted and integrated according to the sequence of sequential identifiers to obtain the integrated content; Based on the integrated content, the integrity of the instruction is verified using the CRC-32 algorithm to obtain the tamper-proof verification instruction; When the sequence of sequential identifiers is not continuous, the complete fragment sequence is discarded, and the instruction segmentation is repeated until the sequence of sequential identifiers is continuous, thus obtaining the anti-tampering verification instruction.

[0044] Specifically, fragment repair is performed based on the selected fragment sequence to obtain a complete fragment sequence. The selected fragment sequence is a set of fragments determined after anomaly threshold verification, which may contain a small number of damaged fragments that do not exceed the fault tolerance capability. The Reed-Solomon decoding algorithm is used for fragment repair. Assume the original encoding parameters are (n, k), where k is the original number of fragments, for example 4, n is the total number of fragments, for example 6, and the number of redundant fragments is 2. A few fragments in the selected fragment sequence may be marked as anomalous, but the number does not exceed the number of redundant fragments. During decoding, k fragments are first arbitrarily selected from the available fragments, including normal fragments and redundant fragments, and their data blocks are decomposed into elements in a finite field by bytes. A receiving polynomial is constructed, whose coefficients are the data values ​​of the selected fragments. The adjoint of the receiving polynomial is calculated, that is, the receiving polynomial is evaluated at the roots of the generator matrix. The error location polynomial is solved using the Berlekamp-Massey algorithm, which iteratively calculates the polynomial coefficients so that the roots of the error location polynomial indicate the location of the error. Then, Chan's search is used to find all roots of the error location polynomial in the finite field, with each root corresponding to an index of the error location. Finally, the Forney algorithm is used to calculate the error value at each erroneous location. The corrected value is obtained by subtracting the error value from the received value. The corrected k fragments are then merged with the existing normal fragments and rearranged according to their unique identifiers or sequential identifiers to obtain the repaired complete fragment sequence. Each fragment in this sequence should have been correctly recovered.

[0045] Then, the sequence identifier of each fragment in the complete fragment sequence is extracted to obtain a sequence identifier sequence. The sequence identifier is the integer number appended to the header of each fragment in step S11, incrementing from 1 according to the order of the fragments in the original instructions. Each fragment in the complete fragment sequence is traversed, and the sequence identifier value is parsed from the header metadata. These identifier values ​​are recorded according to the current order of the fragments in the sequence, resulting in a list of integers.

[0046] Determine if the sequence of sequential identifiers is continuous. Continuity means that the values ​​in the sequence increase sequentially from 1, the difference between two adjacent identifiers is equal to 1, and there are no missing or duplicate identifiers. Specifically, after sorting the extracted sequence of sequential identifiers, check if the minimum value is 1, the maximum value equals the total number of fragments, and each integer in the sequence appears exactly once. If these conditions are met, the sequence is considered continuous.

[0047] When the sequence identifiers are consecutive, the corresponding fragments are extracted sequentially according to the sequence identifiers from smallest to largest. The data contents of the fragments are then concatenated sequentially to form a complete binary data stream, i.e., the integrated content. This integrated content should theoretically be a complete copy of the original instruction to be protected against tampering.

[0048] Based on the integrated content, the integrity of the instruction is verified using the CRC-32 algorithm to obtain the tamper-proof verification instruction. The specific parameters of the CRC-32 algorithm are: initial value 0xFFFFFFFF, generator polynomial 0x04C11DB7, bit reversal of both input bytes and output results, and XORing the final result with 0xFFFFFFFF. The calculation process is as follows: all bytes of the integrated content are input sequentially, each byte is XORed with the lower 8 bits of the current CRC register, then each bit is cyclically shifted, and during the shift, the least significant bit is used to determine whether to XOR with the generator polynomial. After all bytes are processed, the CRC register is inverted to obtain a 32-bit check value. This check value is compared with the reference CRC value of the instruction written to the ledger in step S14. If they match, the verification passes, the integrated content is the original, tamper-proof instruction, and the tamper-proof verification instruction is obtained.

[0049] When the sequence identifier is discontinuous, it indicates that the fragments were out of order or lost during transmission or repair, and cannot be correctly reassembled. At this point, the current complete fragment sequence is discarded, and the execution returns to the instruction segmentation operation in step S11. The entire fragmentation, encoding, transmission, verification, and repair process restarts from the source, repeating the above loop until a continuous sequence identifier is generated. At this point, the tamper-proof verification instruction is obtained. This step, through sequence identifier reassembly and CRC integrity verification, ensures the accuracy and integrity of the reassembled instruction, achieving the ultimate goals of tamper-proofing and traceability.

[0050] The second embodiment of the present invention provides an encryption instruction anti-tampering system based on a shared ledger, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the method described above.

[0051] In summary, this invention discloses a method for preventing tampering of encrypted instructions based on a shared ledger. The method includes acquiring the instruction to be prevented from being tampered with and the real-time path load; performing fragmentation preprocessing to obtain an initial fragment set; obtaining a protected fragment sequence through redundant coding, storage, and scheduling; obtaining a transmission channel combination through load minimization resource allocation; performing split transmission and combining traceable verification records for receiving verification anomaly statistics and feedback-based resegmentation verification; and finally performing fragment repair and reassembly verification to obtain the tamper-proof verification instruction. This invention solves the problems of existing technologies' inability to detect tampering and low transmission efficiency through a collaborative mechanism of fragmentation, redundant coding, dynamic path allocation, hash ledger solidification, and feedback-based resegmentation verification, achieving end-to-end tamper-proof and traceable verification of instruction transmission.

[0052] It should be noted that the shared ledger-based encrypted instruction anti-tampering system provided in this embodiment of the invention is used to execute all the process steps of the shared ledger-based encrypted instruction anti-tampering method in the above embodiment. The working principles and beneficial effects of the two are one-to-one, so they will not be described again.

[0053] It should be noted that the system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0054] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. In particular, it should be noted that any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention for those skilled in the art.

Claims

1. A method for preventing tampering with encrypted instructions based on a shared ledger, characterized in that, include: Obtain the instruction to be tampered with and the real-time path load, and perform fragmentation preprocessing on the instruction to be tampered with to obtain an initial fragment set; Based on the initial fragment set, redundant coding and storage scheduling are performed to obtain the protected fragment sequence; Based on the protection fragment sequence and the real-time path load, a path load switching calculation is performed to obtain the switching transmission path, and a load minimization resource allocation is performed based on the switching transmission path to obtain the transmission channel combination. Based on the protection fragment sequence, a hash ledger is solidified to obtain a traceable and verifiable record. The protection fragment sequence is then split and transmitted according to the transmission channel combination to obtain the transmitted fragment sequence. Based on the transmitted fragment sequence and the traceable verification record, receive verification anomaly filtering is performed to obtain the filtered fragment sequence; Based on the selected fragment sequence, fragment repair and recombination verification is performed to obtain tamper-proof verification instructions.

2. The method for preventing tampering with encrypted instructions based on a shared ledger according to claim 1, characterized in that, The fragmentation preprocessing of the instruction to be tampered with, to obtain an initial fragment set, includes: Based on the instruction to be tampered with, the instruction is segmented using a preset delimiter to obtain a logical segment sequence; According to a preset granularity range, the logical segment sequence is length-normalized to obtain a balanced fragment sequence; Based on the balanced fragment sequence, a unique identifier is generated, and an order identifier is added according to the fragment order to obtain the initial fragment set.

3. The method for preventing tampering with encrypted instructions based on a shared ledger according to claim 1, characterized in that, The step of performing redundant coding and storage scheduling based on the initial fragment set to obtain a protected fragment sequence includes: Based on the initial fragment set, redundant fragment sequence is obtained by performing redundant coding using the Reed-Solomon error correction coding algorithm; Based on the redundant fragment sequence, storage nodes are allocated through hash mapping to obtain a distributed fragment sequence; When the storage node in the distributed fragment sequence is in a preset fault state, the distributed fragments are migrated to subsequent nodes on the hash ring to obtain a protected fragment sequence. When the state of the storage node in the distributed fragment sequence is not the fault state, the current storage node remains unchanged, and a protected fragment sequence is obtained.

4. The method for preventing tampering with encrypted instructions based on a shared ledger according to claim 1, characterized in that, The step of performing path load switching calculations based on the protected fragment sequence and the real-time path load to obtain a switched transmission path, and then performing load-minimizing resource allocation based on the switched transmission path to obtain a transmission channel combination, includes: Based on the protected fragment sequence, a shortest path search is performed to obtain the initial transmission path; When the real-time path load exceeds the preset path load threshold, the shortest path is re-searched based on the initial transmission path to obtain a switching transmission path. When the real-time path load is not greater than the path load threshold, the initial transmission path is directly used as the switching transmission path. The switching transmission path with the lowest real-time path load is selected sequentially for overall network resource allocation to obtain a transmission channel combination.

5. The method for preventing tampering with encrypted instructions based on a shared ledger according to claim 1, characterized in that, The step of solidifying the hash ledger based on the protected fragment sequence to obtain traceable and verifiable records includes: Based on the protected fragment sequence, a hash verification calculation is performed using the SHA-256 algorithm to obtain a reference verification value; Based on the reference verification value, a distributed ledger is written using a practical Byzantine fault-tolerant algorithm to obtain traceable and verifiable records.

6. The method for preventing tampering with encrypted instructions based on a shared ledger according to claim 5, characterized in that, The step of performing reception verification anomaly filtering based on the transmitted fragment sequence and the traceable verification record to obtain the filtered fragment sequence includes: Based on the transmitted fragment sequence, a hash verification value is obtained by performing a hash check using the SHA-256 algorithm. From the post-transmission fragment sequence, fragments whose received check value is inconsistent with the reference check value in the traceable verification record are marked to obtain an anomaly marking sequence; The number of abnormal fragments is obtained by counting the number of marked fragments in the abnormal marking sequence; An anomaly threshold feedback-based resegmentation verification is performed on the transmitted fragment sequence and the number of abnormal fragments to obtain a filtered fragment sequence.

7. The method for preventing tampering with encrypted instructions based on a shared ledger according to claim 6, characterized in that, The step of performing anomaly threshold feedback-based re-segmentation verification on the transmitted fragment sequence and the number of abnormal fragments to obtain a filtered fragment sequence includes: When the number of abnormal fragments is less than a preset threshold for the number of abnormal fragments, the transmitted fragment sequence is directly used as the filtered fragment sequence. When the number of abnormal fragments is not less than the abnormal fragment number threshold, the transmitted fragment sequence is discarded, and the instruction segmentation is repeated until the number of abnormal fragments is less than the abnormal fragment number threshold, thus obtaining a filtered fragment sequence.

8. The method for preventing tampering with encrypted instructions based on a shared ledger according to claim 2, characterized in that, The step of performing fragment repair and recombination verification based on the selected fragment sequence to obtain an anti-tampering verification instruction includes: Based on the selected fragment sequence, the fragments are repaired using the Reed-Solomon decoding algorithm to obtain the complete fragment sequence; Extract the sequence identifier of each fragment from the complete fragment sequence to obtain a sequence identifier sequence; When the sequence of sequential identifiers is continuous, the complete fragment sequence is sorted and integrated according to the sequence of sequential identifiers to obtain the integrated content; Based on the integrated content, the integrity of the instruction is verified using the CRC-32 algorithm to obtain the tamper-proof verification instruction; When the sequence of sequential identifiers is not continuous, the complete fragment sequence is discarded, and the instruction segmentation is repeated until the sequence of sequential identifiers is continuous, thus obtaining the anti-tampering verification instruction.

9. A tamper-proof encryption instruction system based on a shared ledger, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the method according to any one of claims 1 to 8.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the program implements the steps of the method described in any one of claims 1 to 8.