A Distributed Data Collaboration Method for Narrowband IoT Water Meters and Card-Swiping Water Meters
By employing a collaborative approach combining hybrid logical clock marking and dual-domain conservation ledgers, the problem of synchronizing the billing status of narrowband IoT water meters and card-swipe water meters was solved, achieving accurate billing status synchronization and efficient data recovery under complex network conditions.
Patent Information
- Application Number
- CN202611345891.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-01
- Publication Date
- 2026-11-10
AI Technical Summary
Existing smart water meter systems suffer from issues such as duplicate or out-of-order records, delayed rate information, and missing serial numbers due to power outages on narrowband IoT links and IC card-carrying links. These issues prevent accurate synchronization and closure of billing status, increase network traffic and storage read volume, and make it difficult to distinguish between event differences and rate environment differences.
By establishing a deterministic processing sequence through the collaborative event recording of hybrid logical clock markers and source authentication markers, and using a dual-domain conservative ledger and Merkle tree to recover discrepancy records, combined with the discrepancy IBLT mechanism, the consistency of charging status is ensured under conditions of power outage, duplication, out-of-order, and rate pending.
It achieves accurate synchronization of water volume and fee status under complex network conditions, reduces transmission volume, improves the auditability of billing data and resource utilization efficiency, and ensures the certainty and consistency of billing status.
Smart Images

Figure CN123072128A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer data synchronization, distributed event processing, and smart metering and billing technologies, specifically to a distributed billing data collaboration method for narrowband IoT water meters and card-swipe water meters. Background Technology
[0002] Smart water meter billing systems often deploy both narrowband IoT water meters capable of continuous reporting via narrowband IoT links and card-swipe water meters that rely on IC cards to intermittently carry data between the card-swiping water meter and the card reader terminal. The former may produce duplicate or out-of-order records due to coverage, power consumption control, and network retransmission, while the latter's billing records, rate information, and time synchronization information may only reach the billing coordination node after multiple card swipes. Existing systems often overwrite remote copies with the latest balance or cumulative water volume, or record entries one by one according to the upload time sequence. When recharge, water metering, compensation, and rate switching come from different event originating ends, the overwriting method cannot prove the completeness of intermediate events, and the upload time order cannot maintain the established causal relationship. Although conventional full log comparison and full historical recalculation can find some differences, they significantly increase narrowband IoT link traffic, IC card write counts, and water meter storage read volume; comparing only record summaries cannot distinguish differences in event sets, billing execution differences, and rate environment differences. Furthermore, rounding residuals, counter wrap-around, late rates, and sequence number gaps caused by power outages in integer billing can all make the water quantity status and fee status appear correct but fail to close together. Therefore, a distributed billing data coordination mechanism is needed that can adapt to the coexistence of continuous cellular links and intermittent portable links, define synchronization boundaries, and recover differences with less transmission. Summary of the Invention
[0003] The purpose of this invention is to provide a distributed billing data collaboration method for narrowband IoT water meters and card-based water meters. Addressing the differences between narrowband IoT links and IC card-based links in terms of online availability, round-trip time, available bandwidth, and power-off write methods, this method establishes an authenticable, replayable, and deterministically terminated data collaboration boundary. It constrains the current event set using the target source front vector, forms a deterministic processing sequence using hybrid logical clock markers and explicit cross-source dependencies, stores the water volume domain state, cost domain state, and conversion residuals using a dual-domain conservation ledger, and completes the difference records using a Merkle tree and a hierarchical recovery mechanism based on difference IBLT. This ensures that the billing collaboration node and the water meter can obtain the same billing status under conditions of late arrival, duplication, out-of-order delivery, pending rate, and power-off recovery.
[0004] To solve the above problems, the technical solution of the present invention is implemented as follows:
[0005] A distributed billing data collaboration method for narrowband IoT water meters and card-swipe water meters is disclosed, applicable to a distributed billing system including a billing collaboration node, narrowband IoT water meters, card-swipe water meters, card readers, and IC cards. The narrowband IoT water meters and card-swipe water meters are collectively referred to as water meters. The method comprises the following steps: S1, the water meter exchanges collaborative event records with the billing collaboration node via a narrowband IoT link or IC card, containing hybrid logical clock markers and source authentication markers, and forms an event tracing log according to the source event chain; S2, the collaborative event records are executed according to a deterministic processing sequence compatible with cross-source dependencies, maintaining a water volume domain. S3. At the start of a collaborative round, freeze the target source frontier vector, fill in the sequence number gaps, and generate common anchor point boundary records; S4. Build a Merkle tree that simultaneously binds difference event keys and dual-domain conservation statistics, locate difference branches as needed, use difference IBLT to restore difference event keys, and retransmit corresponding records; S5. After both parties obtain the same set of collaborative event records, replay the event tracing log from the previous common dual-domain conservation anchor point, generate a common dual-domain conservation anchor point summary based on the replay results, and set the collaborative rounds that meet the closure conditions as stable event segments.
[0006] Further, S1 includes: incrementing the local event sequence number according to the combination of the water meter permanent identifier, water meter epoch, and event source identifier; the collaborative event record includes the water meter permanent identifier, water meter epoch, event source identifier, local event sequence number, event identifier, event type, hybrid logic clock flag, water volume domain change value, cost domain change value, rate version, conversion residual, associated event identifier, previous event digest, current event digest, and source authentication flag; generating the event identifier and current event digest using SHA-256, and generating the HMAC-SHA-256 source authentication flag using the source key; treating the incrementing of the local event sequence number, updating the previous event digest, writing the collaborative event record, and writing the hybrid logic clock flag as the same non-volatile transaction with a prepare flag and a commit flag; after a power outage, the authenticated invalidated event occupies the local event sequence number with only the prepare flag, and the water meter epoch is incremented when the transaction metadata verification fails.
[0007] Furthermore, S1 also includes: when generating a collaborative event record, taking the larger value of the corrected local physical time and the previous physical component as the current physical component; if the physical component has not increased, incrementing the logical component by 1; otherwise, setting it to 0; using a time capsule carrying the authentication reference time and validity period and the local monotonic cumulative duration to correct the real-time clock; if the validity period is exceeded, using the authentication reference time as the lower limit of time; when receiving a collaborative event record, taking the maximum value of the local physical component, the received physical component, and the corrected time to update the physical component; if the updated physical component is equal to both the local physical component and the received physical component, incrementing the larger value of the logical components of both parties by 1; if it is equal to only one of the physical components, incrementing the corresponding logical component by 1; if they are not equal, setting it to 0; and not volatilely saving the update result.
[0008] Further, S2 includes: forming a deterministic processing sequence according to the mixed logic clock mark, event source identifier, and local event sequence number; updating the dual-domain conservation ledger according to water metering events, recharge events, and compensation events, so that the remaining water volume is equal to the sum of the cumulative purchased water volume and the cumulative compensated water volume minus the cumulative consumed water volume, and so that the remaining amount is equal to the sum of the cumulative recharge amount and the cumulative compensation amount minus the cumulative billing amount; when the cumulative water volume counter is rewound, determining the water volume domain change value according to the counter modulus, the reading before rewound, the reading after rewound, and the certified rewound number; multiplying the water volume domain change value by the integer pricing coefficient and adding the value obtained by the pre-execution conversion residual, dividing the result by the fixed conversion scale, using the integer quotient as the cost domain change value, and using the remainder as the post-execution conversion residual.
[0009] Furthermore, S2 also includes: water metering events generated only by a single metering source; when there is a gap in the local event sequence number, writing the water metering events following the continuous leading edge into the pending execution queue; pre-writing the certified rate plan into the water meter and locking the cumulative water volume when the rate takes effect; generating a formal event execution result record when the rate is known, and generating a billing execution conflict event when the replay calculated value is inconsistent with the value carried in the collaborative event record; generating an uncharged water metering event with a cost field change value of 0, the conversion residual retaining the value before execution, and the rate version being a rate pending identifier when the rate is unknown, and writing subsequent water metering events into the pending execution queue; re-executing the uncharged water metering event and the pending execution queue after the certified supplementary metering event arrives, and keeping the collaborative event record read-only.
[0010] Further, S3 includes: generating a collaborative round identifier based on the previous common dual-domain conservation anchor point summary, the water meter permanent identifier, and the round sequence number; both parties freeze and exchange source frontier information stored according to the event source identifier, including the highest consecutive local event sequence number, the highest seen local event sequence number, the missing sequence number interval, and the current event summary at the end; taking the larger value of the highest seen local event sequence number of both parties to form the target source frontier vector, and only processing collaborative event records not higher than the target source frontier vector in this round; requesting missing sequence numbers within the target source frontier vector; when cross-source dependencies are outside the target source frontier vector, transferring the corresponding collaborative event record and subsequent collaborative event records from the same source to the next collaborative round, and reverting the corresponding component to the previous local event sequence number of the corresponding collaborative event record; after the sequence number gap is cleared and the cross-source dependency is satisfied, generating a common anchor point boundary record that binds the previous common dual-domain conservation anchor point summary, the collaborative round identifier, the target source frontier vector, and the current event summary at the end.
[0011] Further, S4 includes: connecting the event identifier, current event summary, and event execution status summary to form a difference event key; the event execution status summary is taken from the SHA-256 value of the formal event execution result record, and a 32-byte all-zero value is taken when it is to be executed; establishing a 64-level segmented Merkle tree, using the first 64 bits of the difference event key hash to determine the leaf node path, and sorting the difference event keys of the same path to form leaf node buckets; bitwise XORing the combined hash of the event identifier, the post-execution conversion residual, and the event execution status summary in the bucket to generate the conversion residual aggregate value; the dual-domain conservation statistics include the number of executed events, the sum of water domain change values, the sum of cost domain change values, and the conversion residual aggregate value; the leaf node hash binds the difference event key, the event execution status summary, and the dual-domain conservation statistics, the parent node hash binds the child node hash and the dual-domain conservation statistics, and the root node hash further binds the previous common dual-domain conservation anchor point summary, the collaboration round identifier, the target source front vector, the initial conversion residual, the final conversion residual, and the execution environment summary; the two parties only exchange child node summaries for nodes with differences.
[0012] Furthermore, S4 also includes: taking the larger of the absolute difference between the number of events on both sides and the number of difference child nodes as the difference estimate; adjusting the larger of 2 times the difference estimate and 8 to an integer power of 2 that is not less than the aforementioned larger value as the initial number of difference IBLT units; calculating three SHA-256 mapping seeds based on the coordination round identifier, difference branch prefix, retry sequence number, and mapping sequence number; obtaining three distinct mapping units by incrementing the collision count value; the mapping unit stores the count value, the XOR value of the difference event key, and the XOR value of the check digest; after subtracting the difference IBLT on the charging coordination node side from the difference IBLT on the water meter side, the mapping units with an absolute count value of 1 and a matching check digest are stripped, and the difference event key is assigned based on the sign of the count value; doubling the number of units and updating the mapping seed when there are non-zero mapping units; subdividing the Merkle difference branch when the number of units reaches or exceeds twice the sum of the number of events on both sides; and exchanging the difference event key sorting list when reaching the leaf node bucket.
[0013] Furthermore, S4 also includes: the water meter retransmitting the record corresponding to the positive difference event key to the billing coordination node, the billing coordination node retransmitting the record corresponding to the negative difference event key to the water meter, and retransmitting the already generated formal event execution result record; the receiver verifies the event identifier, current event digest, source authentication flag, previous event digest, rate version, and event execution status digest and then writes it into the event tracing log; when the event identifier and current event digest are the same, the existing result is reused; when the event identifier is the same and the current event digests are different, a content conflict event is generated; the event generating end uses the source key to calculate the HMAC-SHA-256 response to the random challenge value and the local current event digest, and uses the record corresponding to the verified response as the source version; the data retransmitted by the IC card is divided into blocks according to the coordination round identifier, block sequence number, total number of blocks, cyclic redundancy check value, and source authentication flag, and the breakpoint resume transmission is achieved by using dual storage areas and the last block commit flag.
[0014] Furthermore, S5 includes: after both parties obtain the same set of collaborative event records, comparing the execution environment summaries; when differences exist, unifying the execution environment based on the certified algorithm version, rate table, fixed conversion scale, and arithmetic parameters; replaying the event tracing log from the previous common two-domain conservation anchor point; reconstructing the final Merkle tree root node hash when the replay results are the same, the pending execution queue is cleared, and the two-domain conservation relationship is satisfied; performing field identification, length, and value sequential encoding on the common anchor point boundary records, water domain state, cost domain state, terminal conversion residual, execution environment summary, and final Merkle tree root node hash, and calculating the SHA-256 value to generate a common two-domain conservation anchor point summary; when the water domain state, cost domain state, or terminal conversion residual generated by the replay is inconsistent with the corresponding value in the existing subsequent common two-domain conservation anchor points, Continue replaying subsequent stable event segments in chronological order; stop ledger event execution when the corresponding values are consistent and the pending execution queue is cleared, reconstruct the target source front vector and final Merkle tree root node hash of each subsequent stable event segment based on the archived collaborative event records and formal event execution result records, and recalculate the common two-domain conserved anchor point digest level by level; generate execution environment conflict events when there are differences in the replay results; set the current collaborative round as a stable event segment when the source event chain is continuous, cross-source dependencies are satisfied, all conflict events form certified processing results, and the mixed logical clock mark and local event sequence number are non-volatilely saved; water meters save the common two-domain conserved anchor point and the final Merkle tree root node hash, and charging collaborative nodes archive collaborative event records and formal event execution result records in an append-only manner.
[0015] This invention has the following beneficial effects: By freezing the target source frontier vector according to the highest consecutive local event sequence number, the highest seen local event sequence number, and the missing sequence number interval maintained by the event source identifier, the collaborative process is unaffected by the continuous generation of new events after the current freeze. Furthermore, it backs up the corresponding component when cross-source dependencies are not satisfied, avoiding mistaking an incomplete event chain for a stable state. The hybrid logic clock marker only undertakes deterministic ordering based on causality compatibility. The collaborative event record, source event chain, and non-volatile transactions jointly ensure idempotency for repeated transmissions and the recoverability of power-off sequence numbers. The dual-domain conservation ledger incorporates the water domain state, cost domain state, and conversion residuals into execution and anchor point verification, avoiding integer billing splitting, rate switching, and delayed replay. The cumulative rounding drift caused by this; the Merkle tree simultaneously binds the difference event key and the dual-domain conservation statistics, requesting the summary only for inconsistent branches layer by layer. When the difference is sparse, the difference IBLT directly restores the positive and negative difference event keys. When the stripping fails, it performs a deterministic rollback through expansion, branch subdivision, and leaf node bucket list exchange, thereby adapting to the transmission limitations of narrowband IoT links and IC card links. The restored event set is also subject to execution environment summary verification and deterministic replay starting from the previous common dual-domain conservation anchor point. This can distinguish between data missing, content conflict, and execution environment conflict, and restrict historical recalculation to the relevant anchor point range, improving the auditability, convergence, and resource utilization efficiency of charging data synchronization. Attached Figure Description
[0016] Figure 1 A schematic diagram illustrating the heterogeneous communication link and water meter collaborative storage hardware relationship provided in this embodiment of the invention;
[0017] Figure 2 A schematic diagram of the cooperative boundary of the hybrid logic clock marker, source event chain, and target source frontier vector provided in an embodiment of the present invention;
[0018] Figure 3 This is a schematic diagram illustrating the principle of collaborative event recording non-volatile transactions and power-off recovery storage provided in an embodiment of the present invention.
[0019] Figure 4 This is a schematic diagram illustrating the principle of continuous transfer of dual-domain conservation ledger and conversion residuals provided in an embodiment of the present invention.
[0020] Figure 5 This is a schematic diagram illustrating the principle of segmented Merkle tree differential branch localization and dual-domain conservation statistical value binding provided in an embodiment of the present invention.
[0021] Figure 6 This is a schematic diagram illustrating the principle of differential IBLT mutual mapping, stripping, and differential record retransmission provided in an embodiment of the present invention.
[0022] Figure 7This is a schematic diagram illustrating the common dual-domain conservation anchor chain, state closure, and summary cascade update principle provided in this embodiment of the invention. Detailed Implementation
[0023] One feasible configuration is described below with reference to the accompanying drawings. See also Figure 1 The distributed charging system includes a charging coordination node 100, a narrowband IoT water meter 110, a card-swipe water meter 120, an IC card 130, a card reader terminal 140, and a narrowband IoT base station 150. The narrowband IoT water meter 110 communicates with the charging coordination node 100 via the narrowband IoT base station 150; the reverse and forward data paths between the card-swipe water meter 120 and the charging coordination node 100 both pass through the IC card 130 and the card reader terminal 140 sequentially. The narrowband IoT water meter 110 and the card-swipe water meter 120 are collectively referred to as water meters. The charging coordination node 100 treats the card-swipe water meter 120 as an intermittent communication device, with each contact of the IC card 130 forming one interruptible session. This session uses block confirmation and breakpoint resumption, and does not employ the continuous online response conditions of the narrowband IoT link.
[0024] Each water meter includes a metering unit, a security processing module, a non-volatile event memory, a real-time clock, and a monotonic sequence number register. The narrowband IoT water meter 110 also includes a narrowband communication module, and the card-swipe water meter 120 includes an IC card read / write module. In a specific configuration, the security processing module provides the secure hash algorithm SHA-256, a hash-based message authentication code HMAC-SHA-256, true random numbers, protected key slots, and authenticated wraparound counts; the non-volatile event memory has a capacity of 512 kilobytes, using 4 kilobyte erase / write pages, allocating no more than 512 bytes of slots within a page for each core collaborative event record; event extension data exceeding this slot is written to the same page extension slot, and its event extension data digest is stored in the core collaborative event record; the nominal error of the real-time clock is no greater than 1 / 20,000,000, and the local monotonic timer resolution is 1 second. The above capacity and accuracy are used to illustrate the implementation scale; other hardware configurations can also be used while maintaining the same transaction semantics.
[0025] The toll collection collaboration node 100 includes a collaboration processor, an authentication key area, and an append-only archive. The collaboration processor maintains the event tracing log, dual-domain conservation ledger, source front information, Merkle tree, and common dual-domain conservation anchor point corresponding to each water meter's permanent identifier. The authentication key area stores the source keys of each event generator or independent source keys derived from the master key. The append-only archive retains all collaboration event records and formal event execution result records, and does not allow on-site modification of archived data. One toll collection collaboration node 100 can serve multiple water meters, but local event sequence numbers are maintained separately according to the combination of the water meter's permanent identifier, water meter epoch, and event source identifier; therefore, there is no requirement for sequence number continuity between different water meters.
[0026] Figure 1 The metering unit, security processing module, non-volatile event memory, real-time clock, and monotonic sequence number register are arranged side-by-side within the water meter frame, indicating that these components participate in the same event submission. For the card-swipe water meter 120, the IC card 130 can use an 8-kilobyte non-volatile storage area, of which two 3-kilobyte areas form a dual storage area, and the remaining space stores the card identifier, time capsule, and area status. The payload of each block is 200 bytes, and the block header, cyclic redundancy check value, and source authentication mark do not exceed 96 bytes. A single block does not exceed 296 bytes, so a 3-kilobyte area can store 10 blocks and the last block submission mark. The card reader terminal 140 first writes all blocks of the current transmission batch to the inactive area, and then writes the last block submission mark. The card-swipe water meter 120 only reads the area with the complete total number of blocks, the correct cyclic redundancy check value, and the valid source authentication mark. When writing or swiping is interrupted, the submitted area remains readable, and incomplete blocks will not be parsed as collaborative event records.
[0027] During initialization, each water meter is assigned a unique, permanent water meter identifier, and the water meter epoch is set to 1. Each event generator capable of producing collaborative event records is configured with an event source identifier, source key, and key version. Event generators include a unique metering source, a recharge source for the billing collaboration node 100, a rate source, and a compensation source. The event source identifier remains unchanged within the same water meter epoch, and the source key is only used within the authentication key area of the security processing module or the billing collaboration node 100. During key rotation, an authenticated key switching event carrying the new key version is generated first, and the old key is retained until the collaborative round containing the switching event becomes a stable event segment.
[0028] All fields involved in the digest or source authentication mark calculation are encoded sequentially by field identifier, length, and value. The field identifier is a 2-byte unsigned integer, and the length is a 4-byte unsigned integer. Multi-byte integers use a fixed encoding with the most significant byte first, while character values use a unified character encoding. Default fields are explicitly written with a length of 0. Event type, algorithm version, rate version, and key version all use registered values and are not included in the calculation using local display names. The encoder rejects duplicate field identifiers and unregistered field orders; therefore, the same set of fields has only one byte representation, eliminating the possibility of different digests obtained by the water meter and the billing coordination node 100 due to different field concatenation methods.
[0029] The collaborative event log includes at least the water meter permanent identifier, water meter epoch, event source identifier, local event sequence number, event identifier, event type, hybrid logic clock flag, water volume domain change value, cost domain change value, rate version, conversion residual, associated event identifier, previous event summary, current event summary, and source authentication flag. Optional implementations also store the business credential identifier, cumulative water volume before the event, cumulative water volume after the event, algorithm version, and event extended data summary. The associated event identifier points to the collaborative event record that has been compensated, recalculated, or revoked; the business credential identifier is used to associate with the recharge credential. Cross-source dependencies must be explicitly recorded through the associated event identifier, rate version, or business credential identifier; unrecorded concurrent events are not inferred in terms of their true order.
[0030] When the event-generating end writes a collaborative event record, it first writes a preparation flag, meter epoch, event source identifier, intended local event sequence number, record length, and transaction metadata verification value to the transaction header. Then, it increments the monotonic sequence number register by 1, reads the preceding event summary and mixed logic clock flag, and writes them to the collaborative event record body. Next, it calculates the current event summary and source authentication flag, and reads back to verify the complete record. Finally, it writes the commit flag as a separate atomic word. The preparation flag, monotonic sequence number register update, preceding event summary update, collaborative event record writing, and mixed logic clock flag writing belong to the same non-volatile transaction, and the commit flag is the sole criterion for transaction visibility.
[0031] When the water meter recovers from a power outage, the transaction header is scanned sequentially. Transactions with a prepare flag but lacking a commit flag, and whose transaction metadata verification passes, indicate that the local event sequence number has been preserved. The water meter traces back the committed records corresponding to the same water meter permanent identifier, water meter epoch, and event source identifier, using the current event digest of the most recent committed record as the preceding event digest; if there are no committed records for the water meter epoch, a pre-registered 32-byte epoch initial digest is used. The water meter then generates a certified invalid event using the original event source identifier and the preserved local event sequence number; the changes in the water volume field and cost field of the certified invalid event are both 0, and the residual is converted to retain the values before execution. If the transaction metadata verification fails, the most recent committed record cannot be located, or the source event chain verification fails, the water meter increments the water meter epoch, saves the end digest and fault cause of the original water meter epoch, and seals the original water meter epoch, starting recording from the local event sequence number 1 of the new water meter epoch.
[0032] See Figure 3Non-volatile transactions sequentially undergo four phases: preparation, record body writing, digest authentication, and commit. The transaction header stores the preparation flag, meter epoch, event source identifier, reserved sequence number, record length, and transaction metadata verification value. The record body stores fixed fields, a mixed logical clock flag, two-field fields, a previous event digest, and extended fields. The authentication control area stores the current event digest, source authentication flag, readback verification result, and commit flag. Power failure aspect 1 occurs before record body or digest authentication is completed, and power failure aspect 2 occurs after readback verification is completed but before the commit flag is written. During recovery, transactions with valid commit flags enter the visible state; transactions with only a preparation flag and passed transaction metadata verification use the original reserved sequence number to generate authenticated invalid events; when transaction metadata verification fails, the meter epoch is incremented and the original meter epoch is sealed. Figure 3 The above correspondence is represented by separate write stages and storage areas, with power-off sections set between field areas.
[0033] When generating a coordinated event record, the hybrid logic clock flag consists of physical and logical components. The current physical component follows... ;in, Represents the physical components of the current event. This represents the corrected local physical time. This represents the physical component of the previous mixed logic clock. The current logic component is denoted as... The previous logical component is denoted as .
[0034] When the current physical component equals the previous physical component, the current logical component is the previous logical component plus 1; when the current physical component is greater than the previous physical component, the current logical component is set to 0. Even if the real-time clock is backward corrected, the rule of taking the larger value still maintains the monotonicity of the mixed logic clock mark. The physical component uses milliseconds since the unified epoch, and the logical component uses a 32-bit unsigned integer; before the logical component reaches its maximum value, the water meter waits for the physical component to increase by at least 1 millisecond before generating the next coordinated event record, and logical component wraparound is not allowed.
[0035] When receiving a coordinated event record, the receiving end obtains its own physical component, the received physical component, and the corrected local physical time, and takes the maximum value of the three as the updated physical component. If the updated physical component is equal to both the local and received physical components, the logical component is the larger of the two logical components plus 1; if it is equal only to the local physical component, the logical component is the local logical component plus 1; if it is equal only to the received physical component, the logical component is the received logical component plus 1; if none of the three are equal, the logical component is set to 0. The receiving end non-volatilely saves the update result before returning an acknowledgment message, so even if power is cut off immediately after reception, no subsequent mixed logic clock flags smaller than those of the received events will be generated.
[0036] Narrowband IoT water meter 110 receives time capsules via a narrowband IoT link, while card-swipe water meter 120 receives time capsules via a path formed by billing coordination node 100, card reader terminal 140, and IC card 130. Each time capsule includes an authentication reference time, issuance time, validity period, billing coordination node identifier, and source authentication mark. The water meter stores the most recently received authentication reference time and the local monotonic timer value at the time of receipt. The current local estimated time is calculated by adding the stored authentication reference time to the difference between the current local monotonic timer value and the stored value. When a new time capsule within its validity period and with a verified source authentication mark is received, the correction time is the larger of the current local estimated time and the new authentication reference time. The timing benchmark is updated using the correction time and the current local monotonic timer value. Time capsules exceeding their validity period do not update the timing benchmark; their authentication reference time is only used as a lower time limit, and the correction time is the larger of the current local estimated time and this lower time limit.
[0037] In one implementation, the allowed deviation threshold between the real-time clock and the correction time is 120 seconds. If the deviation is less than 120 seconds, only the estimated error is updated; if the deviation exceeds 120 seconds, the correction time is written to the real-time clock, and a clock correction event is generated. The physical component of the clock correction event is still the larger value of the correction time and the previous physical component. The clock correction event does not change the two-domain conservation ledger, but its current event summary is added to the source event chain. Subsequent audits use this to determine the time basis for the periodic boundaries of the common two-domain conservation anchor point, and backward adjustments to the real-time clock do not disrupt the monotonicity of the hybrid logic clock mark.
[0038] The event identifier is obtained by calculating SHA-256 from the field identifiers of the water meter permanent identifier, water meter epoch, event source identifier, local event sequence number, and event type, as well as the sequential encoding of length and value. The current event digest is obtained by calculating SHA-256 from all fixed fields starting with the event identifier to the end of the previous event digest, and all registered extended fields, without including the current event digest itself or the source authentication mark in its input. The source authentication mark is obtained by calculating HMAC-SHA-256 from the source key pair with the current event digest, key version, and algorithm version. The receiver first selects the source key according to the key version, and then recalculates according to the same field rules. Any change in fields, order, or previous event digests will result in verification failure.
[0039] The receiver uses the event identifier as an idempotent index. Collaborative event records with the same event identifier and current event digest are considered duplicate transmissions and are directly returned to the existing processing state without repeated updates to the dual-domain conservation ledger. Collaborative event records with the same event identifier but different current event digests are all retained as content conflict events and do not enter normal execution. Records with different event identifiers but the same water meter permanent identifier, water meter epoch, event source identifier, and local event sequence number are also grouped into content conflict events, because the same source sequence number can only correspond to one submitted event type. This processing accommodates both narrowband IoT link retransmissions and IC card 130 duplicate swipes, and will not obscure different content with the same identifier due to deduplication.
[0040] Collaborative event records marked with source authentication tags are connected into source event chains according to the water meter permanent identifier, water meter epoch, and event source identifier, respectively. Adjacent records satisfy the condition that the preceding event digest of the subsequent record equals the current event digest of the preceding record. Each source event chain, together with cross-source dependencies, constitutes an event tracing log. The executor first performs topological sorting with collaborative event records as vertices and explicit cross-source dependencies as directed edges. When a directed cycle is detected, the collaborative event records within the cycle are marked as dependency conflict events, and their normal execution is suspended. They are reordered after the authenticated events are revoked or at least one cross-source dependency is modified. When there are no directed cycles, the physical component, logical component, byte order of the event source identifier, and local event sequence number of the mixed logical clock mark are used as stable sorting keys in sequence. This order only selects deterministic positions compatible with known causal relationships and is not used to infer the true time sequence between two event-generating ends that have never communicated.
[0041] Figure 2 Three examples of event sources are given. Hollow circles represent collaborative event records that have been verified and entered the current collaborative round. Gray circles represent collaborative event records that have been transferred to the next collaborative round due to missing sequence numbers or cross-source dependencies. The ordered pairs above the circles represent the physical and logical components, respectively. The local event sequence number 3 of the card-swipe water meter 120 is missing; therefore, even though local event sequence number 4 has been received, the highest consecutive local event sequence number can only be kept at 2. The local event sequence number 3 of the charging collaborative node 100 depends on the local event sequence number 4 of the card-swipe water meter 120 and is transferred to the next collaborative round along with the dependent event. The three dashed lines in the figure represent the components of the target source frontier vector, indicating that the target source frontier vector is a source-specific boundary, not a single physical time section.
[0042] The event executor establishes a two-domain conservation ledger. The water volume domain state must at least store the cumulative purchased water volume, cumulative compensated water volume, cumulative consumed water volume, and remaining water volume. The cost domain state must at least store the cumulative recharge amount, cumulative compensated amount, cumulative billed amount, and remaining amount, and each must satisfy the following conditions: The cost domain satisfies ;in, Indicates the remaining water volume. This indicates the cumulative amount of water purchased. This indicates the cumulative amount of water compensated. This indicates the cumulative water consumption. Indicates the remaining amount. This indicates the total amount recharged. This indicates the total amount of compensation. This indicates the cumulative billing amount.
[0043] Water metering events add cumulative water consumption and cumulative billing amount; recharge events add cumulative purchased water volume and cumulative recharge amount based on the business credential identifier verified by the source authentication mark; compensation events add cumulative compensated water volume and cumulative compensated amount based on the associated event identifier. Cumulative compensated water volume and cumulative compensated amount use 64-bit signed integers, thus positive and negative compensations use the same structure. After each actuator update, it checks the addition and subtraction with a 128-bit intermediate result. If the result exceeds the 64-bit state range, it generates an execution environment conflict event and stops automatic closure, without using silent wraparound.
[0044] The metering unit outputs an unsigned cumulative water volume counter. When a loop occurs, the change in water volume is calculated according to... ;in, This indicates the change in water volume during this period. This indicates the number of authenticated wraparounds saved by the security processing module between two records. This indicates the counter modulus of the cumulative water volume counter. This indicates the reading before rewinding. This indicates the reading after rewinding.
[0045] For example, if the counter modulus is 4294967296, the reading before rewind is 4294967250, the reading after rewind is 54, and the certified rewind count is 1, then the water volume domain change value is 100. If at most one rewind occurs between two records, the certified rewind count is recorded as 0 if no rewind occurs, and as 1 if one rewind occurs. When the reporting interval of a low-power water meter may span multiple rewinds, the security processing module increments the certified rewind count in each hardware overflow interrupt and includes this value in the collaborative event record and current event summary. When the metering reference is reset or the metering unit is replaced, the rewind rule is not followed; instead, the water meter epoch is incremented, and the old and new metering references are saved using certified migration events.
[0046] Each water meter epoch uses a fixed conversion scale, and rate changes only alter the integer pricing coefficient. For water metering events with known rates, the cost domain change value and the post-execution conversion residual are calculated according to... ; ;in, This indicates the change value in the cost field. This indicates the change in water volume during this period. This represents the integer pricing factor for the current rate version. This indicates the conversion of residuals before execution. This indicates a fixed conversion scale that remains constant and greater than 0 within the same water meter era. Indicates the converted residual after execution; symbol This indicates rounding down to the nearest integer.
[0047] The fixed conversion scale, integer pricing coefficient, and water volume range change value all use non-negative integers. The initial conversion residual for the water meter era is 0. After calculation using integer quotients and remainders, the post-execution conversion residual is greater than or equal to 0 and less than the fixed conversion scale. In an implementation dataset of metering by liter and billing by cent, the fixed conversion scale is 1000, the integer pricing coefficient is 375, corresponding to 0.375 cents per liter. Before execution, the conversion residual is 0 and the water volume range change value is 137 liters, while the cost range change value is 51 cents. After execution, the conversion residual is 375. In the next water metering event, when the water volume range change value is 63 liters, the cost range change value is 24 cents, and the post-execution conversion residual returns to 0. The two events total 200 liters and 75 cents, consistent with the combined calculation. If the cumulative purchased water volume is 10,000 liters and the cumulative recharge amount is 3,750 points with no compensation, then after execution, the remaining water volume will be 9,800 liters and the remaining amount will be 3,675 points, and both conservation relationships will hold simultaneously.
[0048] See Figure 4 The dual-domain conservation ledger accumulates the water volume domain status and the cost domain status separately, establishing a correspondence through an integer pricing channel located between the two domains. The water volume domain status takes the cumulative purchased water volume and cumulative compensated water volume as input, and the cumulative consumed water volume and remaining water volume as output; the cost domain status takes the cumulative recharge amount and cumulative compensated amount as input, and the cumulative billed amount and remaining amount as output. The integer pricing channel reads the water volume domain change value generated by the sole metering source and the pre-execution conversion residual, generating the cost domain change value and the post-execution conversion residual according to a fixed conversion scale. The diagram shows that when the water volume domain change value is 137 liters and the pre-execution conversion residual is 0, the cost domain change value is 51 cents and the post-execution conversion residual is 375. The post-execution conversion residual serves as the pre-execution conversion residual for the next continuous water metering event, ensuring that event splitting, rate switching, and partial replay use the same integer billing result.
[0049] The certified rate plan includes a rate version, effective time, tier boundaries, integer pricing coefficients for each tier, fixed conversion scale, issuing end identifier, and source authentication mark. The fixed conversion scale in the water meter verification rate plan is the same as the fixed conversion scale registered in the current water meter epoch; otherwise, an execution environment conflict event is generated, and the rate plan is not enabled. The rate plan is written to the water meter via a narrowband IoT link or IC card 130 before the effective time. When the water meter reaches the effective time, the accumulated water volume is latched by the security processing module. When a water metering event crosses the rate effective time or tier boundary, the integer pricing coefficients for each tier are used sequentially, with the latched accumulated water volume as the dividing point. The identifier of each billing sub-event execution record is obtained by calculating SHA-256 from the event identifier, boundary identifier, and sub-event sequence number starting from 0 of the original water metering event, ensuring the same result when the water meter and the billing coordination node 100 are independently separated.
[0050] If the rate plan does not arrive ahead of schedule, the sole metering source will still generate unbilled water metering events to preserve the essential metering data. The cost field change value for the unbilled water metering event is 0, the conversion residual retains its pre-execution value, and the rate version is marked with a rate pending flag. The unbilled water metering event is entered into the event tracing log, but the dual-domain conservation ledger remains unchanged. Subsequent water metering events are entered into the pending execution queue. After the billing coordination node 100 sends a certified supplementary metering event, the event executor reads the rate version carried by the certified supplementary metering event, recalculates from the first unbilled water metering event, sequentially generates official event execution result records, and clears the pending execution queue that can be executed continuously.
[0051] Water metering events are generated only by a single metering source, and the conversion residual is passed along the execution chain of consecutive water metering events from that single metering source. When there is a gap in the local event sequence number, water metering events after the highest consecutive local event sequence number are only stored in the pending execution queue and the conversion residual is not consumed in advance. The formal event execution result record includes the event identifier, water volume domain change value, cost domain change value, post-execution conversion residual, pre-execution status summary, post-execution status summary, and execution environment summary; the above fields are encoded in the order of field identifier, length, and value, and then SHA-256 is calculated. The resulting 32-byte value is used as the event execution status summary. For water metering events with known rates, the replay value is verified against both the value carried in the collaborative event record and the formal event execution result record; for water metering events without charges, the cost domain change value of 0, the pre-execution conversion residual, and the rate pending status in the collaborative event record are only used to verify the pending status, and the replay value after supplementary metering is only verified against the formal event execution result record. Collaborative event logs are kept read-only. If inconsistencies are found during verification, a billing execution conflict event is generated. The rate version or algorithm version to be used is determined by the result of the authentication process.
[0052] Upon initiation of collaboration, the water meter and the billing collaboration node 100 respectively read the previous shared dual-domain conserved anchor point summary and round number. They then calculate the SHA-256 hash using the sequence of these hashes along with the field identifiers, lengths, and values of the water meter's permanent identifier, resulting in the collaboration round identifier. After the collaboration round identifier is determined, both parties freeze the current source frontier information. New collaboration event records generated or received after the freeze are marked as data for the next collaboration round, without altering the Merkle tree of the current collaboration round. This freezing rule ensures that even when the narrowband IoT water meter 110 continuously generates water metering events, the current collaboration round still possesses a finite and stable set of comparisons.
[0053] The source front information is stored according to the event source identifier, including the highest consecutive local event sequence number, the highest seen local event sequence number, the missing sequence number interval, and the current event summary corresponding to the highest consecutive local event sequence number. Both parties take the larger value of the highest seen local event sequence number to initially form the target source front vector, and only process cooperative event records whose local event sequence number is not higher than the corresponding component. The missing sequence number interval uses closed interval list encoding, and adjacent intervals are merged; the interval is shrunk immediately upon receiving a missing record. Having only the highest consecutive local event sequence number without storing the highest seen local event sequence number will miss out-of-order events received after the consecutive front; therefore, both values are included in the freezing process.
[0054] For example, the highest consecutive local event sequence number and the highest seen local event sequence number of the sole metering source on the water meter side are both 128, while the two sequence numbers on the charging coordination node 100 side are both 127; the highest seen local event sequence number of the card swipe source is 76 on both sides, but 75 is missing on the charging coordination node 100 side; the highest seen local event sequence number of the charging coordination node source is 43. The initial target source frontier vector is 128, 76, and 43. Both parties first request the local event sequence number 128 of the sole metering source and the local event sequence number 75 of the card swipe source; after completion, if the local event sequence number 43 of the charging coordination node source explicitly depends on the yet-to-be-seen local event sequence number 77 of the card swipe source, then the charging coordination node source component is rolled back to 42, and the local event sequence number 43 and subsequent coordination event records of the same source are transferred to the next coordination round.
[0055] After clearing the common missing sequence interval within the target source front vector and satisfying all cross-source dependencies, both parties generate a common anchor boundary record. The common anchor boundary record includes a summary of the previous common two-domain conserved anchor, a cooperative round identifier, the final target source front vector, and a summary of the current event at the end corresponding to each event source identifier. The common anchor boundary record uses the same field identifiers, lengths, and values for sequential encoding as the cooperative event record. Since the current event summary at the end corresponds one-to-one with the highest consecutive local event sequence number, the common anchor boundary record both limits the upper bound of the current round set and guarantees the terminal state of each source event chain reaching that upper bound.
[0056] During difference comparison, a fixed 32-byte event identifier, a fixed 32-byte current event digest, and a fixed 32-byte event execution status digest are concatenated sequentially to form a 96-byte difference event key. When a formal event execution result record has been generated, the event execution status digest is taken as the SHA-256 value of that formal event execution result record; when in the pending execution queue or rate pending state, the event execution status digest is taken as a 32-byte all-zero value. With this structure, even if two replicas have the same collaborative event record, the difference event key will still be different as long as the formal event execution result records are different; pending events explicitly and constantly commit to their state of not yet being included in the two-domain conservation statistics.
[0057] Both parties construct a 64-layer segmented Merkle tree for the difference event keys between the previous common dual-domain conserved anchor point and the target source front vector. First, the SHA-256 value of the difference event key is calculated, and then the leaf node path is selected bit by bit from the first 64 bits. The tree uses sparse storage, only storing the nodes containing the event and their corresponding empty sibling nodes' summaries, without allocating the entire 64-layer space. When multiple difference event keys have the same 64-bit prefix, they are arranged in the same leaf node bucket according to the byte order of the complete 256-bit hash value. The leaf node hash includes all difference event keys and the corresponding event execution status summary within the bucket; therefore, the finite depth will not cause prefix collision ambiguity.
[0058] For each executed event, the water volume domain change value, cost domain change value, and post-execution conversion residual are read from the official event execution result record; events awaiting execution are not included in the number of executed events, the sum of water volume domain change values, and the sum of cost domain change values. For each executed event within a leaf node bucket, SHA-256 is calculated by encoding the event identifier, post-execution conversion residual, and event execution status summary in that order, and then the results are XORed bitwise to obtain the conversion residual aggregate value. The dual-domain conservation statistics of the leaf node include the number of executed events, the sum of water volume domain change values, the sum of cost domain change values, and the conversion residual aggregate value. The conversion residual aggregate value is an auxiliary commitment; the integrity of the event and execution result is still guaranteed by the sorted difference event keys, the event execution status summary, and the leaf node hash.
[0059] The inputs to the leaf node hash include, in sequence, node type, tree depth, 64-bit prefix, sorted difference event keys, event execution status summary, and two-domain conservation statistics. The parent node's executed event count, sum of water domain changes, and sum of cost domain changes are obtained by taking the arithmetic sum of the corresponding values of its left and right child nodes, respectively. The parent node's conversion residual aggregation value is obtained by the bitwise XOR of the conversion residual aggregation values of its left and right child nodes. The inputs to the parent node hash include node type, tree depth, bit prefix, left child node hash, right child node hash, and merged two-domain conservation statistics. The root node hash further binds to the previous common two-domain conservation anchor summary, collaboration round identifier, target source front vector, initial conversion residual, final conversion residual, and execution environment summary. When the event content, execution result, or two-domain conservation statistics change, the corresponding change is entered into the root node hash along the node path.
[0060] See Figure 5 The root node and the three example numbers in each child node represent the number of executed events, the sum of changes in the water volume domain, and the sum of changes in the cost domain, respectively. Nodes with thick lines represent difference branches where the hashes of both parties differ, and thick solid lines indicate the direction of exploration as needed. During collaboration, the root node hash is exchanged first. If the root node hashes are the same, no further sub-nodes are sent. If the root node hashes are different, only the digests of the two child nodes of the node with the hash difference are requested, until the difference leaf node bucket is located. In the difference leaf node bucket, K1, K4, and K7 represent the difference event keys sorted by their complete hash values; X1, X4, and X7 represent the corresponding event execution status digests; and 375, 0, and 625 represent the corresponding post-execution conversion residuals. Each parent node hash is also bound to the child node hash, bit prefix, tree depth, dual-domain conservation statistics, and the aggregated value of the conversion residual.
[0061] Within each difference branch, an Invertible Bloom Lookup Table (IBLT) is created. The initial difference estimate is the larger of the absolute difference between the number of events on both sides and the current number of difference child nodes. The initial number of units in the IBLT is the larger of twice the difference estimate and 8, then adjusted up to the smallest power of 2 that is not less than that value. When both sides have 100 events but different content, even though the absolute difference between the number of events is 0, the number of difference child nodes and subsequent Merkle tree subdivisions will still increase the estimation range. When the number of units reaches or exceeds twice the sum of the number of events on both sides, Merkle tree difference sub-branch subdivision is initiated, and the difference between the number of events is not used as the upper limit of symmetric difference.
[0062] Each mapping unit stores a 32-bit signed counter, a 96-byte XOR value for the difference event key, and a 16-byte XOR value for the checksum. Three SHA-256 mapping seeds are calculated based on the cooperative round identifier, difference branch prefix, retry sequence number, and mapping sequence number. The unit index is then calculated using the mapping seed and the difference event key. If any two indices of the same difference event key are identical, a collision count incrementing from 1 is added to the corresponding mapping input for recalculation, until three distinct mapping units are obtained. When a difference event key is written, the counter values of all three mapping units are incremented by 1, and then XORed with the first 16 bytes of the 96-byte difference event key and its SHA-256 value.
[0063] The IBLT difference on the water meter side is subtracted from the IBLT difference on the billing coordination node 100 side unit by unit; the count value is subtracted by a signed subtraction, and the XOR value of the difference event key and the XOR value of the verification digest are bitwise XORed. During stripping, the mapping unit with an absolute count value of 1 and the same XOR value as the verification digest after recalculating the difference event key is selected, and the difference event key and the sign of the count value are output. The design value sign is 1 or negative 1. For the three mapping units corresponding to the output difference event key, the count value is subtracted by the sign, and the difference event key and the verification digest are XORed again; the operation is repeated until all mapping units are 0 or there are no strippable units. A positive sign indicates that it is unique to the water meter side, and a negative sign indicates that it is unique to the billing coordination node 100 side.
[0064] See Figure 6 One difference event key is entered into three distinct mapping units through three independent mapping values. Each mapping unit sequentially stores a count value, the XOR value of the difference event key, and the XOR value of the checksum. The mapping unit with an absolute count value of 1 and a matching checksum outputs the difference event key and difference symbol, and is removed from the corresponding three mapping units according to the difference symbol. Positive difference event keys correspond to unique records on the water meter side and are retransmitted from the water meter to the billing coordination node 100; negative difference event keys correspond to unique records on the billing coordination node 100 side and are retransmitted from the billing coordination node 100 to the water meter. The receiver verifies the event identifier, current event summary, source authentication mark, and rate version before writing it to the event tracing log. If the stripping is not complete, the unit number is doubled, the Merkle tree difference sub-branch is subdivided, and the difference leaf node bucket sorting list is swapped sequentially to form a deterministic rollback.
[0065] After obtaining the positive difference event key, the water meter retransmits the corresponding collaborative event record and the already generated formal event execution result record to the billing collaboration node 100; after obtaining the negative difference event key, the billing collaboration node 100 retransmits it in reverse to the narrowband IoT water meter 110 via the narrowband IoT link, or retransmits it in reverse to the card-swiping water meter 120 via the card reader terminal 140 and IC card 130. The unilateral differences obtained from the leaf node bucket list exchange adopt the same rules. The receiver sequentially verifies the event identifier, current event summary, source authentication mark, preceding event summary, rate version, and event execution status summary; the formal event execution result record also needs to verify the association between the event identifier, pre-execution status summary, post-execution status summary, and execution environment summary before it is written to the event tracing log.
[0066] When IC card 130 transmits differential data, each block includes a coordination round identifier, transmission batch number, total number of transmission batches, block number, total number of blocks, payload length, cyclic redundancy check value, and source authentication mark. A single transmission batch includes no more than 10 blocks, with block numbers numbered consecutively from 0, and the total number of blocks remains unchanged within the transmission batch. When the differential data of the current coordination round exceeds 10 blocks, it is divided into multiple transmission batches according to the transmission batch number. The source authentication mark covers the block header and payload, and the cyclic redundancy check value is used to quickly eliminate read / write errors before calculating the source authentication mark. If only a portion of the blocks in the current transmission batch is transmitted in one card swipe, the card reader 120 returns the range of consecutive blocks that have been verified, and the card reader terminal 140 only writes the remaining blocks next time. After the entire current transmission batch is verified and imported into the non-volatile event memory by the card reader 120, the card reader terminal 140 writes the next transmission batch to IC card 130. The active storage area is switched only after the last block submission mark verification is passed. Therefore, repeated card swiping, card removal, and momentary power failure will not expose incomplete blocks. Only after the last transmission batch is completed will the integrity verification be performed on the assembled collaborative event record or the formal event execution result record.
[0067] The narrowband IoT link uses the same collaborative round identifier and block sequence number semantics as IC card 130, but does not use dual storage areas. One implementation limits the uplink payload of the narrowband IoT application layer to 512 bytes, with the block header, cyclic redundancy check value, and source authentication flag occupying no more than 96 bytes. Each message carries no more than 416 bytes of record data. When a collaborative event record or formal event execution result record exceeds 416 bytes, it is sent according to consecutive block sequence numbers; the two types of records are not required to be loaded into the same message. Batch confirmation information uses a bitmap to represent the verified block sequence number. If the water meter does not receive confirmation information, it retransmits the same block. The billing collaborative node 100 receives the data idempotently based on the collaborative round identifier, block sequence number, and source authentication flag. After the record is assembled, the event identifier and current event digest are verified. If three consecutive transmission failures occur, the original block is retained, and retrying is performed after waiting 30 minutes, 2 hours, and 6 hours after the first, second, and third failures, respectively. Retrying does not rewrite the hybrid logic clock flag or regenerate the event identifier. Communication retries only change the transmission time, not the event content, the source event chain, or the deterministic processing sequence.
[0068] The common dual-domain conservation anchor point uses two alternately stored anchor pages at the water meter. Each anchor page stores the anchor number, common dual-domain conservation anchor point summary, final Merkle tree root node hash, water volume domain status, cost domain status, end-of-line conversion residual, source frontier information, execution environment summary, and page checksum. The inactive anchor page is first fully written and verified, then the active anchor page is switched using an atomic status word. Upon power-up, the anchor page with a valid status word and a larger anchor number is prioritized. If both anchor pages are damaged, the water meter does not automatically estimate the balance; instead, it requests the most recently confirmed common dual-domain conservation anchor point from the billing coordination node 100 based on the stored water meter epoch and the end of the source event chain, and only appends and archives subsequent coordination event records. This recovery path ensures that anchor point damage does not translate into uncertified ledger overwrite.
[0069] When handling content conflict events, the receiving end sends a challenge request to the event generator containing a collaborative round identifier, an event identifier, and a 128-bit random challenge value. The event generator searches for a local collaborative event record with the same event identifier within its security processing module, calculates an HMAC-SHA-256 response using the source key, the random challenge value, and the local current event digest; the response also returns the key version and the local current event digest. The record corresponding to the verified response is used as the source version, while the other version is retained only for appending to the archive and generating an authenticated processing result. This implementation is for non-Byzantine models with link corruption, duplication, and replica failure; optionally, a digital signature generated by the water meter's private key can be added in addition to the source authentication mark to provide source non-repudiation in deployments where the charging collaborative node 100 also possesses the shared verification key.
[0070] After both parties obtain the same set of collaborative event records, they first compare the execution environment summaries. The execution environment summary is obtained by calculating SHA-256 based on the algorithm version, certified rate table summary, fixed conversion scale, integer bit width, overflow handling method, field encoding version, and billing boundary rules. When there are differences in the execution environment summaries, both parties exchange the above-mentioned sub-summaries and adopt the certified version for unification; if a certified version is missing or the hardware does not support the specified integer bit width, an execution environment conflict event is generated and automatic closure is paused. This step is performed before replay, which can locate the result discrepancies under the same event set as execution environment problems and avoid repeatedly transmitting the same events by expanding the difference window.
[0071] Replay begins with the most recently agreed-upon common dual-domain conservation anchor point, restoring the water domain state, cost domain state, end-point conversion residuals, current event summaries for each source end, and execution environment summaries stored at that point. Then, the event tracing log for the current collaborative round is executed according to a deterministic processing sequence. A temporary event execution result record is generated at each step; if a formal event execution result record exists, it is compared with the temporary record; if no formal event execution result record exists but the rate version, explicit dependencies, and certified business credentials are all available, the verified temporary event execution result record is converted into a formal event execution result record; if the rate is still pending, it is retained in the pending execution queue. Collaborative event records are always read-only. When the replay results from both parties are identical, the pending execution queue is cleared, the source event chain is continuous, and the two dual-domain conservation relationships are valid, the final Merkle tree root node hash is reconstructed using all formal event execution result records; during reconstruction, the 32-byte all-zero value is replaced with the event execution status summary corresponding to the formal event execution result record, and all dual-domain conservation statistics are recalculated.
[0072] This summary of common dual-domain conservation anchor points follows ;in, This represents a summary of the common dual-domain conservation anchor points. This represents a summary of the previous common dual-domain conservation anchor point. Indicates the collaborative round identifier. This represents the target source front vector and a summary of the current events at each source terminal. Indicates the common anchor point boundary record, Indicates the state of the water volume domain. Indicates the state of the cost field. This represents the final conversion residual. This represents a summary of the execution environment. Represents the final Merkle tree root node hash; symbol This indicates the sequential encoding of the field identifier, length, and value.
[0073] The common anchor point boundary record contains duplicate fields with some of the aforementioned inputs. Each input is encoded sequentially using field identifier, length, and value. During decoding, field boundaries are determined according to the field identifier and length, preventing boundary ambiguity caused by duplicate fields. The common two-domain conservation anchor point summary simultaneously binds the anchor chain, collaboration round, source frontier, two-domain state, conversion residual, execution environment, and final event set. The water meter stores the common two-domain conservation anchor point and the hash of the final Merkle tree root node. The charging collaboration node 100 stores the same anchor point and writes the relevant collaboration event records and formal event execution result records to an append-only archive.
[0074] If the recalculated common two-domain conservation anchor summary differs from the existing subsequent common two-domain conservation anchor summary, the parties do not use summary equality as the stopping condition for event replay, because the common two-domain conservation anchor summary includes the previous common two-domain conservation anchor summary. Both parties continue to replay subsequent stable event segments in chronological order, comparing the water domain state, cost domain state, and terminal conversion residual at each segment boundary; when all corresponding values are identical and the pending execution queue is cleared, the boundary is defined as the state closure boundary, and ledger event execution stops. From the state closure boundary, both parties read only append archives according to the range of each existing subsequent stable event segment, re-determine the target source front vector and the current event summary of each source terminal, reconstruct the common anchor boundary record and the final Merkle tree root node hash, and then recalculate the subsequent common two-domain conservation anchor summaries level by level using the newly calculated previous common two-domain conservation anchor summary, until the current source front; this process performs summary calculation but does not re-execute the billing calculation in the corresponding stable event segment. If the common two-domain conservation anchor point summaries, which serve as the starting point for replay, are different, the process first backtracks from the earlier common two-domain conservation anchor point to the most recent common two-domain conservation anchor point where both summaries are identical. If the starting points, event sets, and execution environment summaries are the same, but the replay results are still different, both parties exchange post-event execution state summaries to locate the first divergent event and generate an execution environment conflict event.
[0075] A retrospective event refers to a collaborative event record that is obtained through difference recovery in a subsequent collaborative round and whose processing location, determined by hybrid logic clock marking and explicit cross-source dependency, is located within an existing stable event segment. See also Figure 7The common dual-domain conservation anchors A0 to A4 define adjacent stable event segments, and the trace event e* is inserted between common dual-domain conservation anchors A1 and A2. Both parties restore the water domain state, cost domain state, end-of-pipe conversion residual, and the end of the source event chain stored at common dual-domain conservation anchor A1. The trace event e* is inserted at a deterministic processing position compatible with explicit dependencies, and a post-execution state summary is generated event-by-event according to the replay sequence. The states in the diagram include the water domain state, cost domain state, and end-of-pipe conversion residual. At the boundary corresponding to common dual-domain conservation anchor A2, the replay-formed state 2′ differs from the existing state 2; when replaying continues to the boundary corresponding to common dual-domain conservation anchor A3, the replay-formed state 3′ is the same as the existing state 3, and the pending execution queue is cleared. Therefore, ledger event execution stops at this boundary. The common two-domain conservation anchor summary includes the previous common two-domain conservation anchor summary. The target source front vector, common anchor boundary record, final Merkle tree root node hash, and common two-domain conservation anchor summary after common two-domain conservation anchor A2 are still reconstructed step by step according to the append-only archive. The equality of states in the figure does not mean that the new and old common two-domain conservation anchor summaries are equal.
[0076] For a current collaborative round to become a stable event segment, it must simultaneously satisfy the following conditions: the event chain of each source within the target source front vector is continuous; all cross-source dependencies are satisfied; the missing sequence number interval is empty; content conflict events, billing execution conflict events, dependency conflict events, and execution environment conflict events all generate certified processing results; both parties confirm the source front information and the current event summary at the end; the pending execution queue is cleared; and the hybrid logical clock marker and local event sequence number are non-volatilely stored. When a stable event segment involves a terminated water meter epoch, it must also be confirmed that the terminated water meter epoch has been archived. Water meters can compress earlier events after retaining the common dual-domain conservation anchor point, the final Merkle tree root node hash, and the necessary summary within the audit period; the billing collaborative node 100 still retains the immutable original archive.
[0077] As an optional check for the differential IBLT coding amount, one mapping unit includes a 4-byte signed count value, a 96-byte XOR value for the differential event key, and a 16-byte XOR value for the check digest, totaling 116 bytes. Assuming the differential estimate equals the number of symmetric differential events, the initial number of differential IBLT units is determined according to the aforementioned rules. When the number of symmetric differential events is 1, 2, 4, 8, 16, 32, 64, 128, and 256 respectively, the initial number of units is 8, 8, 8, 16, 32, 64, 128, 256, and 512 respectively, and the coding amount of a single-sided differential IBLT is 928, 928, 928, 1856, 3712, 7424, 14848, 29696, and 59392 bytes respectively. Assuming 1 kilobyte equals 1024 bytes, the above encoding amounts are approximately 0.91, 0.91, 0.91, 1.81, 3.63, 7.25, 14.50, 29.00, and 58.00 kilobytes, respectively. The full key list containing 4096 96-byte difference event keys is 393216 bytes, or 384 kilobytes. These values are used to verify unit allocation and encoding length, and do not include protocol headers, difference event key backhauls, or link retransmissions; in case of stripping failure, the process still proceeds sequentially according to doubling the number of units, subdividing the difference branch, and exchanging the difference leaf node bucket sorting list.
[0078] Under the verification conditions of 128 existing collaborative event records and 1 retrospective event inserted at the current segment starting point between adjacent common dual-domain conservation anchor points, and the state closing at the next boundary, when the number of stable historical events is 512, 1024, 2048, 4096, and 8192 respectively, the number of events to be executed for replaying from the starting record is 513, 1025, 2049, 4097, and 8193 respectively. Replaying from the previous common dual-domain conservation anchor point requires executing 129 events, including 128 existing collaborative event records and 1 retrospective event. When the state closes after several consecutive stable event segments, the number of events to be replayed increases by 128 for each additional segment containing 128 existing collaborative event records. After the state closes, only the subsequent target source front vector, common anchor point boundary record, Merkle tree, and common dual-domain conservation anchor point summary are reconstructed from the appended archives; the billing operations in the corresponding stable event segments are no longer executed. The process recovers the dual-domain state, calculates the residual, source event chain end, and execution environment from the most recent common dual-domain conservation anchor point with the same summary for both parties, without reading earlier event records.
[0079] The specific values mentioned above can be adjusted based on the water meter's storage capacity, the IC card 130's capacity, and the collaboration cycle. For example, the narrowband IoT water meter 110 can initiate collaboration after accumulating 16 collaborative event records or after 6 hours, while the card-swipe water meter 120 can transmit no more than 10 blocks per card swipe. As long as the source event chain, target source front vector freezing, differential IBLT deterministic backoff, and common dual-domain conservation anchor point closure rules are maintained, changes in the collaboration cycle do not alter the protocol results. For the card-swipe water meter 120 with a non-volatile event memory capacity of no more than 128 kilobytes, the internal nodes of the Merkle tree can be calculated and cached on demand by the leaf node buckets, with the charging collaboration node 100 handling the complete tree storage. The water meter still needs to retain the current common dual-domain conservation anchor point and the final Merkle tree root node hash.
[0080] The above configuration implements data exchange between narrowband IoT links and IC card-carried links as an authenticated exchange with collaborative event records as the smallest unit. The target source front vector limits the comparison range, the Merkle tree locates the difference branch, the difference IBLT recovers the difference event key and triggers record retransmission, and the dual-domain conserved ledger and deterministic replay verify the recovered charging status of both parties.
Claims
1. A distributed billing data collaboration method for narrowband IoT water meters and card-swipe water meters, characterized in that, This system is applied to a distributed billing system that includes billing coordination nodes, narrowband IoT water meters, card-swipe water meters, card readers, and IC cards. Narrowband IoT water meters and card-swipe water meters are collectively referred to as water meters. The system includes the following steps: S1, the water meter exchanges collaborative event records with the billing coordination node via a narrowband IoT link or IC card. These records contain hybrid logical clock markers and source authentication markers, and an event tracing log is formed according to the source event chain. S2, the collaborative event records are executed according to a deterministic processing sequence compatible with cross-source dependencies, maintaining a dual-domain system including water volume state, cost state, and conversion residuals. S3, at the start of a collaborative round, freeze the target source frontier vector, fill in the sequence number gaps, and generate common anchor point boundary records; S4, establish a Merkle tree that simultaneously binds difference event keys and dual-domain conservation statistics, locate difference branches as needed, use difference IBLT to restore difference event keys, and retransmit corresponding records; S5, after both parties obtain the same collaborative event record set, replay the event tracing log from the previous common dual-domain conservation anchor point, generate a common dual-domain conservation anchor point summary based on the replay results, and set the collaborative rounds that meet the closure conditions as stable event segments.
2. The distributed charging data collaboration method for narrowband IoT water meters and card-swipe water meters according to claim 1, characterized in that, S1 includes: The local event sequence number is incremented according to the combination of the water meter permanent identifier, water meter epoch, and event source identifier. The collaborative event record includes the water meter permanent identifier, water meter epoch, event source identifier, local event sequence number, event identifier, event type, hybrid logic clock flag, water volume domain change value, cost domain change value, rate version, conversion residual, associated event identifier, previous event digest, current event digest, and source authentication flag. The event identifier and current event digest are generated using SHA-256, and the HMAC-SHA-256 source authentication flag is generated using the source key. The incrementing of the local event sequence number, the updating of the previous event digest, the writing of the collaborative event record, and the writing of the hybrid logic clock flag are treated as the same non-volatile transaction with a prepare flag and a commit flag. After a power outage, the local event sequence number with only the preparation mark is occupied by the certified invalidation event, and the water meter epoch is incremented when the transaction metadata verification fails.
3. The distributed charging data collaboration method for narrowband IoT water meters and card-swipe water meters according to claim 2, characterized in that, S1 also includes: when generating a collaborative event record, taking the larger value of the corrected local physical time and the previous physical component as the current physical component; if the physical component has not increased, incrementing the logical component by 1; otherwise, setting it to 0; using a time capsule carrying the authentication reference time and validity period and the local monotonic cumulative duration to correct the real-time clock; if the validity period is exceeded, using the authentication reference time as the lower limit of time; when receiving a collaborative event record, taking the maximum value of the local physical component, the received physical component, and the corrected time to update the physical component; if the updated physical component is equal to both the local physical component and the received physical component, incrementing the larger value of the logical components of both parties by 1; if it is equal to only one of the physical components, incrementing the corresponding logical component by 1; if they are not equal, setting it to 0; and not volatilely saving the update result.
4. The distributed charging data collaboration method for narrowband IoT water meters and card-swipe water meters according to claim 3, characterized in that, S2 includes: forming a deterministic processing sequence according to the mixed logic clock mark, event source identifier, and local event sequence number; updating the dual-domain conservation ledger according to water metering events, recharge events, and compensation events, so that the remaining water volume is equal to the sum of the cumulative purchased water volume and the cumulative compensated water volume minus the cumulative consumed water volume, and so that the remaining amount is equal to the sum of the cumulative recharge amount and the cumulative compensation amount minus the cumulative billing amount; when the cumulative water volume counter is rewound, the water volume domain change value is determined according to the counter modulus, the reading before rewound, the reading after rewound, and the certified rewound number; the product of the water volume domain change value and the integer pricing coefficient, plus the value obtained by the pre-execution conversion residual, is divided by the fixed conversion scale, with the integer quotient as the cost domain change value and the remainder as the post-execution conversion residual.
5. The distributed charging data collaboration method for narrowband IoT water meters and card-swipe water meters according to claim 4, characterized in that, S2 also includes: water metering events generated only by a single metering source; when there is a gap in the local event sequence number, water metering events following the continuous leading edge are written into the pending execution queue; certified rate plans are pre-written into the water meter and the accumulated water volume is latched when the rate takes effect; when the rate is known, a formal event execution result record is generated, and a billing execution conflict event is generated when the replay calculated value is inconsistent with the value carried in the collaborative event record; when the rate is unknown, an unbilled water metering event is generated with a cost field change value of 0, the conversion residual retains the value before execution, and the rate version is marked as rate pending, and subsequent water metering events are written into the pending execution queue; after the certified supplementary billing event arrives, the unbilled water metering event and the pending execution queue are re-executed, and the collaborative event record remains read-only.
6. The distributed charging data collaboration method for narrowband IoT water meters and card-swipe water meters according to claim 5, characterized in that, S3 includes: generating a collaborative round identifier based on the previous common dual-domain conservation anchor point summary, water meter permanent identifier, and round sequence number; freezing and exchanging source frontier information based on the event source identifier, including the highest consecutive local event sequence number, the highest seen local event sequence number, the missing sequence number interval, and the current event summary at the end; taking the larger value of the highest seen local event sequence number from both parties to form the target source frontier vector, and processing only collaborative event records not higher than the target source frontier vector in this round; requesting missing sequence numbers within the target source frontier vector; when cross-source dependencies are outside the target source frontier vector, transferring the corresponding collaborative event record and subsequent collaborative event records from the same source to the next collaborative round, and reverting the corresponding component to the previous local event sequence number of the corresponding collaborative event record; after the sequence number gap is cleared and the cross-source dependency is satisfied, generating a common anchor point boundary record that binds the previous common dual-domain conservation anchor point summary, collaborative round identifier, target source frontier vector, and current event summary at the end.
7. The distributed charging data collaboration method for narrowband IoT water meters and card-swipe water meters according to claim 6, characterized in that, S4 includes: forming a difference event key by connecting the event identifier, current event summary, and event execution status summary; the event execution status summary is taken from the SHA-256 value of the formal event execution result record, and a 32-byte all-zero value is taken when it is to be executed; a 64-level segmented Merkle tree is established, and the leaf node path is determined by the first 64 bits of the difference event key hash; the difference event keys of the same path are sorted to form leaf node buckets; the combined hash of the event identifier, the post-execution conversion residual, and the event execution status summary in the bucket is bitwise XORed to generate the conversion residual aggregate value; the dual-domain conservation statistics include the number of executed events, the sum of the water domain change value, the sum of the cost domain change value, and the conversion residual aggregate value; the leaf node hash is bound to the difference event key, the event execution status summary, and the dual-domain conservation statistics; the parent node hash is bound to the child node hash and the dual-domain conservation statistics; the root node hash is further bound to the previous common dual-domain conservation anchor point summary, the collaboration round identifier, the target source front vector, the initial conversion residual, the final conversion residual, and the execution environment summary; the two parties only exchange child node summaries for nodes with differences.
8. The distributed charging data collaboration method for narrowband IoT water meters and card-swipe water meters according to claim 7, characterized in that, S4 also includes: taking the larger of the absolute difference between the number of events on both sides and the number of difference child nodes as the difference estimate; adjusting the larger of 2 times the difference estimate and 8 to an integer power of 2 that is not less than the aforementioned larger value as the initial number of difference IBLT units; calculating three SHA-256 mapping seeds based on the coordination round identifier, difference branch prefix, retry sequence number, and mapping sequence number; obtaining three distinct mapping units by incrementing the collision count value; the mapping unit stores the count value, the XOR value of the difference event key, and the XOR value of the check digest; after subtracting the difference IBLT on the charging coordination node side from the difference IBLT on the water meter side, the mapping units with an absolute count value of 1 and a matching check digest are stripped, and the difference event key is assigned based on the sign of the count value; doubling the number of units and updating the mapping seed when there are non-zero mapping units; subdividing the Merkle difference branch when the number of units reaches or exceeds twice the sum of the number of events on both sides; and exchanging the difference event key sorting list when reaching the leaf node bucket.
9. The distributed charging data collaboration method for narrowband IoT water meters and card-swipe water meters according to claim 8, characterized in that, S4 also includes: the water meter retransmitting the record corresponding to the positive difference event key to the billing coordination node, the billing coordination node retransmitting the record corresponding to the negative difference event key to the water meter, and retransmitting the already generated formal event execution result record; the receiver verifies the event identifier, current event digest, source authentication flag, previous event digest, rate version, and event execution status digest and then writes it into the event tracing log; when the event identifier and current event digest are the same, the existing result is reused; when the event identifier is the same and the current event digests are different, a content conflict event is generated; the event generating end uses the source key to calculate the HMAC-SHA-256 response to the random challenge value and the local current event digest, and uses the record corresponding to the verified response as the source version; the data retransmitted by the IC card is divided into blocks according to the coordination round identifier, block sequence number, total number of blocks, cyclic redundancy check value, and source authentication flag, and the breakpoint resume transmission is achieved by using dual storage areas and the last block commit flag.
10. The distributed charging data collaboration method for narrowband IoT water meters and card-swipe water meters according to claim 9, characterized in that, S5 includes: After both parties obtain the same set of collaborative event records, they compare the execution environment summaries. If there are differences, the execution environment is unified according to the certified algorithm version, rate table, fixed conversion scale, and arithmetic parameters. The event source log is replayed from the previous common two-domain conservation anchor point. If the replay results are the same, the pending execution queue is cleared, and the two-domain conservation relationship is satisfied, the final Merkle tree root node hash is reconstructed. The common anchor point boundary records, water domain status, cost domain status, terminal conversion residual, execution environment summary, and final Merkle tree root node hash are sequentially encoded with field identifiers, lengths, and values, and SHA-256 values are calculated to generate a common two-domain conservation anchor point summary. If the water domain status, cost domain status, or terminal conversion residual generated by the replay is inconsistent with the corresponding values in the existing subsequent common two-domain conservation anchor points, the process continues according to... Replay subsequent stable event segments in chronological order; stop ledger event execution when the corresponding values are consistent and the execution queue is cleared; reconstruct the target source front vector and final Merkle tree root node hash of each subsequent stable event segment based on the archived collaborative event records and formal event execution result records, and recalculate the common two-domain conserved anchor point digest level by level; generate execution environment conflict events when there are differences in the replay results; set the current collaborative round as a stable event segment when the source event chain is continuous, cross-source dependencies are satisfied, all conflict events form certified processing results, and the mixed logical clock mark and local event sequence number are non-volatilely saved; water meters save the common two-domain conserved anchor point and the final Merkle tree root node hash, and charging collaborative nodes archive collaborative event records and formal event execution result records in an append-only manner.
