Reservation code verification method and system of embedded water control terminal
By employing a reservation code verification method that combines bit-level compression and SM4 encryption (a national cryptographic algorithm), along with ESAM module decryption and ring cache management, the verification efficiency and security issues of embedded water control terminals are resolved, enabling fast and secure reservation code verification.
Patent Information
- Application Number
- CN202511605115.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-05
- Publication Date
- 2025-12-09
- Estimated Expiration
- 2045-11-05
AI Technical Summary
Embedded water control terminals, with limited storage space and computing power, struggle to efficiently and securely perform complex reservation code verifications, resulting in slow response times or failure to complete verification tasks.
A reservation code verification method using bit-level compression and the national cryptographic algorithm SM4 encryption, combined with ESAM module decryption and ring buffer management, is used to verify the validity of the reservation code, including generating a signature digest, transmitting the encrypted reservation code, and local decryption verification.
It improves the system performance and response speed of embedded water control terminals, enhances data security, avoids replay attacks and unauthorized reservations, and is suitable for resource-constrained embedded devices.
Smart Images

Figure CN121098519A_ABST
Abstract
Description
Technical Field
[0001] The embodiments disclosed herein relate to the field of water control terminal management technology, and more specifically, to a reservation code verification method and system for an embedded water control terminal. Background Technology
[0002] Embedded water control terminals are widely used in multi-node water control scenarios such as campuses and bathhouses. In scenarios involving remote control and management of water flow, reservation codes play a crucial role as a key technology for reserving and verifying water flow control. However, many embedded devices face resource constraints in terms of storage space, computing power, and communication.
[0003] For example, embedded water control terminals typically use small amounts of memory (e.g., 64KB SRAM) and processors, which makes it difficult to execute complex verification algorithms locally on the device, especially when it involves encryption and large amounts of data verification. This can result in slow device response, insufficient performance, or even failure to complete the verification task. Summary of the Invention
[0004] To address the aforementioned issues, the embodiments described herein provide a reservation code verification method, system, computing device, and computer-readable storage medium storing a computer program for an embedded water control terminal. Without relying on a high-performance edge server, reservation code verification can be implemented efficiently and securely on a resource-constrained embedded water control terminal, significantly improving system performance and response speed.
[0005] According to a first aspect of this disclosure, a method for verifying a reservation code in an embedded water control terminal is provided, comprising: generating a reservation code based on a user's reservation request to the water control terminal; performing bit-level compression on the structure of the reservation code and generating a corresponding signature digest; encrypting the reservation code and its signature digest using the national cryptographic algorithm SM4 to generate a ciphertext reservation code; receiving the ciphertext reservation code; decrypting the ciphertext reservation code using an ESAM module to obtain the plaintext reservation code and its digest; and verifying the validity of the reservation code based on the successfully verified signature digest and reservation time quantization value stored in a local circular cache for the received plaintext reservation code and its digest.
[0006] In some embodiments of this disclosure, generating a reservation code based on a user's reservation request for a water control terminal, and performing bit-level compression on the reservation code and generating a corresponding signature digest includes: generating a reservation code based on the user's reservation request for the water control terminal, wherein the reservation code is uniquely bound to the device ID of the water control terminal requested by the user; compressing the reservation code into a 64-bit field structure, wherein the 64-bit field structure includes a 14-bit device field, a 20-bit reservation time quantization value, a 14-bit usage time, an 8-bit permission policy, and an 8-bit random factor; and generating a 32-bit signature digest from the compressed reservation code using the SipHash-2-4 algorithm.
[0007] In some embodiments of this disclosure, the device field is used to identify the water control terminal. If the value of the device field is all 0, it means that there is no device restriction. If the highest bit of the device field is 1, it means that mandatory verification is required. The reservation time quantization value represents the quantization value of the reservation time from the base time in 10-minute units.
[0008] In some embodiments of this disclosure, receiving a encrypted reservation code, decrypting the encrypted reservation code based on the ESAM module, and obtaining the plaintext reservation code and its digest include: decrypting the encrypted reservation code based on the built-in key of the ESAM module, obtaining the plaintext reservation code and its digest, and verifying the digest; determining whether the number of times the reservation code is verified exceeds the maximum number of verifications, and if it exceeds the maximum number of verifications, locking the device for a preset time.
[0009] In some embodiments of this disclosure, for the received plaintext reservation code and its digest, the validity of the reservation code is verified based on the successfully verified signature digest and reservation time quantization value stored in the local circular cache. This includes: checking whether the length of the reservation code meets the preset length; if not, the reservation code is directly rejected; if it does, checking whether the device ID in the reservation code is consistent with the device ID of the current water control terminal; if not, the reservation is rejected; generating a signature digest for the new reservation code using the SipHash-2-4 hash algorithm, checking whether the signature digest of the new reservation code already exists in the local circular cache; if it exists, the reservation is rejected; otherwise, the generated digest is stored in the local circular cache; comparing the reservation time quantization value of the new reservation code with the maximum reservation time quantization value; if the reservation time quantization value of the new reservation code is less than or equal to the maximum reservation time quantization value, the reservation is rejected; otherwise, the reservation is allowed, and the maximum reservation time quantization value stored locally is updated; calculating the difference between the reservation time point and the local time of the current device based on the current device's base time point and the reservation time quantization value, and determining whether the difference is within the allowed time window range; if the difference is not within the range, the reservation is rejected.
[0010] In some embodiments of this disclosure, a local circular cache is used to store the signature digests and maximum reservation time quantification values of the most recently verified successful reservation codes. If a new digest needs to be added to the cache and the cache is full, the oldest added digest is removed according to the LRU policy.
[0011] In some embodiments of this disclosure, the water control terminal pre-allocates a static memory pool and uses a constant stack to store data that does not need to be modified during the reservation code parsing and verification process.
[0012] According to a second aspect of this disclosure, an embedded water control terminal reservation code verification system is provided, including a water control terminal and a reservation platform. The reservation platform is used to generate a reservation code based on a user's reservation request to the water control terminal, perform bit-level compression on the structure of the reservation code, and generate a corresponding signature digest; encrypt the reservation code and its signature digest based on the national cryptographic algorithm SM4 to generate a ciphertext reservation code; the water control terminal is used to receive the ciphertext reservation code, decrypt the ciphertext reservation code based on the ESAM module, and obtain the plaintext reservation code and its digest; for the received plaintext reservation code and its digest, the validity of the reservation code is verified based on the successfully verified signature digest and reservation time quantization value stored in the local circular cache.
[0013] According to a third aspect of this disclosure, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of a reservation code verification method for an embedded water control terminal.
[0014] According to a fourth aspect of this disclosure, a computer-readable storage medium storing a computer program is provided, wherein the computer program, when executed by a processor, implements the steps of the reservation code verification method for an embedded water control terminal according to a first aspect of this disclosure.
[0015] The reservation code verification and system for embedded water control terminals according to embodiments of this disclosure effectively prevents the reservation code from being stolen or tampered with by encrypting the reservation code and its signature digest using the national cryptographic algorithm SM4, thus improving data security. By performing bit-level compression and ring cache management on the reservation code structure, unnecessary computation and storage overhead is reduced, enabling rapid validity verification and preventing replay attacks or unauthorized reservations. This solution is applicable to embedded devices, especially in scenarios requiring efficient and secure real-time verification. Attached Figure Description
[0016] To more clearly illustrate the technical solutions of the embodiments of this disclosure, the accompanying drawings of the embodiments will be briefly described below. It should be understood that the drawings described below only relate to some embodiments of this disclosure and are not intended to limit this disclosure, wherein: Figure 1 An exemplary flowchart illustrating a reservation code verification method for an embedded water control terminal according to an embodiment of the present disclosure is shown. Figure 2 A structural block diagram of a reservation code verification system for an embedded water control terminal according to an embodiment of the present disclosure is shown. Figure 3 This is a schematic block diagram of a computing device according to embodiments of the present disclosure.
[0017] It should be noted that the elements in the attached diagram are schematic and not drawn to scale. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this disclosure. All other embodiments obtained by those skilled in the art based on the described embodiments of this disclosure without creative effort are also within the scope of protection of this disclosure.
[0019] Unless otherwise defined, all terms used herein (including technical and scientific terms) shall have the same meaning as commonly understood by one of ordinary skill in the art to which this subject matter pertains. It will be further understood that terms such as those defined in commonly used dictionaries shall be interpreted as having the meaning consistent with their meaning in the context of the specification and in the relevant art, and shall not be interpreted in an idealized or overly formal form unless otherwise explicitly defined herein.
[0020] This disclosure proposes an efficient and low-resource-consumption reservation code verification method for resource-constrained embedded water control terminals (such as MCUs with 64KB SRAM). Figure 1 An exemplary flowchart illustrates a reservation code verification method for an embedded water control terminal according to an embodiment of the present disclosure. (Refer to...) Figure 1 As shown, in Figure 1 In step S102, a reservation code is generated based on the user's reservation request for the water control terminal. The reservation code is then compressed at the bit level, and a corresponding signature digest is generated.
[0021] When a user schedules a reservation to use a water control terminal, they can log in to the water control system reservation platform via a WeChat mini-program, select the water control terminal, and apply for a reservation. The reservation platform generates a reservation code based on the user's reservation information and preset rules. This reservation code is uniquely bound to the device ID of the requested water control terminal and includes information such as a timestamp, device ID, and validity period. This one-to-one binding of devices and reservation codes ensures that each device can only use the reservation code it is bound to. Even if the encrypted reservation code is intercepted, it cannot be used on other devices, further enhancing system security.
[0022] To reduce storage footprint and communication overhead, according to one embodiment of this disclosure, the reservation code is compressed into a 64-bit field structure, which includes a 14-bit device field, a 20-bit reservation time quantization value, a 14-bit usage time, an 8-bit permission policy, and an 8-bit random factor.
[0023] The 14-bit device field identifies the water control terminal. If the device field is all 0s, it indicates no device restrictions; if the highest bit is 1, it means the device needs to be forcibly matched and verified against the local device address. The reservation time quantization value represents the reservation time's distance from the base time in 10-minute increments. For example, if the base time is January 1, 2023, 00:00:00, then the reservation time quantization value for January 1, 2023, 00:10 is 1, for January 1, 2023, 00:20 is 2, and so on, so that reservations within the entire time period can be represented by a small number. The usage time indicates the validity period or usage duration of the reservation code, in seconds. The permission policy represents the platform rules or permission policies related to the reservation. This field allows for flexible control over the operation permissions that different users or devices can perform. The random factor is maintained by the server and is used to increase the randomness and security of the reservation code. The random factor increments each time a new reservation code is generated, resetting to 0 after reaching its maximum value, effectively preventing the abuse of duplicate reservation codes. The above fields are compressed into a 64-bit container using a bit-packed method and serialized into a byte sequence.
[0024] The SipHash-2-4 algorithm is used to generate a 32-bit signature digest from the compressed reservation code. Because the reservation code contains a random factor, the generated signature digest will be different each time. Therefore, even for the same reservation code, the encryption result will dynamically change, effectively improving security against replay attacks. Only water control terminals with the same key can regenerate the same digest and verify the validity of the reservation code.
[0025] Subsequently, in step S104, the reservation code and its signature digest are encrypted based on the national cryptographic algorithm SM4 to generate a ciphertext reservation code.
[0026] SM4 is a symmetric encryption algorithm that uses a 128-bit key length and a 128-bit block length, employing 32 rounds of non-linear iterations to ensure data is not leaked or tampered with during transmission. The final ciphertext reservation code consists of 64 bits of compressed data and a 32-bit authentication digest, totaling 12 bytes. In the CAN protocol, this can be split into two frames for transmission, significantly improving communication efficiency and reducing bandwidth consumption.
[0027] In step S106, the encrypted reservation code is received, and the encrypted reservation code is decrypted based on the ESAM module to obtain the plaintext reservation code and its digest.
[0028] After obtaining the encrypted reservation code, the water control terminal can decrypt it using the built-in key of the ESAM module (security module) to obtain the original plaintext reservation code and its digest. The digest is then verified to ensure consistency between the signature digest and the original data, preventing forgery and tampering. The terminal also checks if the reservation code verification attempts have exceeded the maximum number of attempts. If so, the device is locked for a preset time. For example, if a device fails to verify its reservation code more than five times, the device will be locked for a period to prevent brute-force attacks.
[0029] Finally, in step S108, for the received reservation code plaintext and its digest, the validity of the reservation code is verified based on the successfully verified signature digest and reservation time quantization value stored in the local ring cache.
[0030] According to one embodiment of this disclosure, a coarse-to-fine verification strategy is adopted when verifying the reservation code. First, a simple and quick verification (such as length verification) is performed. If this passes, a more detailed signature verification is then performed.
[0031] Specifically, the system checks whether the length of the reservation code meets the preset length. If it does not, the reservation code is rejected directly. If it does, the system checks whether the device ID in the reservation code matches the device ID of the current water control terminal. If they do not match, the reservation is rejected. Subsequently, a signature digest is generated for the new reservation code using the SipHash-2-4 hash algorithm. The system checks whether the signature digest of the new reservation code already exists in the local circular cache. If it exists, it means that it is a duplicate reservation code, so the reservation is rejected. Otherwise, the generated digest is saved in the local circular cache.
[0032] Subsequently, the quantized reservation time value of the new reservation code is compared with the quantized reservation time value of the maximum reservation time. If the quantized reservation time value of the new reservation code is less than or equal to the quantized reservation time value of the maximum reservation time, the reservation is rejected; otherwise, the reservation is allowed, and the locally stored quantized reservation time value is updated. Based on the current device's base time and the quantized reservation time value, the difference between the reservation time and the current device's local time is calculated. It is then determined whether the difference is within the allowed time window. If the difference is not within the range, the reservation is rejected.
[0033] To optimize memory usage, the water control terminal pre-allocates a static memory pool and uses a constant stack to store data that does not need to be modified during reservation code parsing and verification. This memory structure design effectively reduces memory fragmentation and improves system stability. A local circular cache is used to store the signature digests and maximum reservation time quantization values of the most recently verified reservation codes. If a new digest needs to be added to the cache and the cache is full, the oldest added digest is removed according to the LRU policy. Using a constant stack to control stack spikes ensures that memory does not exceed the preset stack size limit (64KB), preventing runtime memory spikes from causing system instability. The entire process does not require dynamic memory management; instead, it manages memory through a predefined static memory pool, avoiding the overhead of malloc / free and memory fragmentation problems, reducing latency during memory allocation and release, and improving program execution efficiency.
[0034] Figure 2 A structural block diagram of a reservation code verification system for an embedded water control terminal according to an embodiment of the present disclosure is shown. (Refer to...) Figure 2 As shown, the reservation code verification system for an embedded water control terminal includes a water control terminal and a reservation platform. The reservation platform generates a reservation code based on the user's reservation request to the water control terminal, performs bit-level compression on the reservation code structure, and generates a corresponding signature digest. It then encrypts the reservation code and its signature digest using the national cryptographic algorithm SM4 to generate a ciphertext reservation code. The water control terminal receives the ciphertext reservation code, decrypts it using the ESAM module, and obtains the plaintext reservation code and its digest. For the received plaintext reservation code and its digest, the validity of the reservation code is verified based on the successfully verified signature digest and reservation time quantization value stored in the local circular cache.
[0035] Specifically, the reservation platform generates a reservation code based on the user's reservation request for the water control terminal. This reservation code is uniquely bound to the device ID of the requested water control terminal. The reservation code is compressed into a 64-bit field structure, including a 14-bit device field, a 20-bit reservation time quantization value, a 14-bit usage time, an 8-bit permission policy, and an 8-bit random factor. The device field identifies the water control terminal; if all bits are 0, there are no device restrictions; if the highest bit is 1, mandatory verification is required. The reservation time quantization value represents the distance from the base time to the reservation time in 10-minute increments. The SipHash-2-4 algorithm is used to generate a 32-bit signature digest from the compressed reservation code.
[0036] The water control terminal can decrypt the encrypted reservation code based on the built-in key of the ESAM module, obtain the plaintext reservation code and its digest, and verify the digest; it can also determine whether the number of verification attempts exceeds the maximum number of verification attempts. If the maximum number of verification attempts is exceeded, the device will be locked for a preset time. The system checks if the reservation code's length meets the preset length. If not, the reservation code is rejected. If it does, the system checks if the device ID in the reservation code matches the device ID of the current water control terminal. If they don't match, the reservation is rejected. A signature digest is generated for the new reservation code using the SipHash-2-4 hash algorithm. The system checks if the signature digest of the new reservation code already exists in the local circular cache. If it does, the reservation is rejected; otherwise, the generated digest is stored in the local circular cache. The system compares the reservation time quantization value of the new reservation code with the maximum reservation time quantization value. If the reservation time quantization value of the new reservation code is less than or equal to the maximum reservation time quantization value, the reservation is rejected; otherwise, the reservation is allowed, and the locally stored maximum reservation time quantization value is updated. Based on the current device's base time and the reservation time quantization value, the system calculates the difference between the reservation time and the current device's local time and determines if the difference is within the allowed time window. If the difference is not within the allowed window, the reservation is rejected.
[0037] In summary, the reservation code verification and system for embedded water control terminals according to embodiments of this disclosure effectively prevents the reservation code from being stolen or tampered with by encrypting the reservation code and its signature digest using the national cryptographic algorithm SM4, thus improving data security. By performing bit-level compression and ring cache management on the reservation code structure, unnecessary computational and storage overhead is reduced, enabling rapid validity verification and preventing replay attacks or unauthorized reservations. This solution is suitable for embedded devices, especially in scenarios requiring efficient and secure real-time verification.
[0038] Figure 3 This is a schematic block diagram of a computing device according to embodiments of the present disclosure. Figure 3 As shown, the computing device 300 may include a processor 310 and a memory 320 storing a computer program. When the computer program is executed by the processor 310, the computing device 300 is made capable of performing tasks such as... Figure 1 The steps of method 100 shown.
[0039] In embodiments of this disclosure, processor 310 may be, for example, a central processing unit (CPU), a microprocessor, a digital signal processor (DSP), a processor based on a multi-core processor architecture, etc. Memory 320 may be any type of memory implemented using data storage technologies, including but not limited to random access memory, read-only memory, semiconductor-based memory, flash memory, disk storage, etc.
[0040] Furthermore, in embodiments of this disclosure, the computing device 300 may also include an input device 330, such as a keyboard or mouse. Additionally, the computing device 300 may also include an output device 340, such as a display.
[0041] In other embodiments of this disclosure, a computer-readable storage medium storing a computer program is also provided, wherein the computer program, when executed by a processor, is capable of performing the following functions: Figure 1 The steps of the reservation code verification method for the embedded water control terminal are shown. For example, when the processor executes the computer program, it implements the following steps: Step S102: Generate a reservation code based on the user's reservation request for the water control terminal, perform bit-level compression on the structure of the reservation code, and generate the corresponding signature digest; Step S104: Encrypt the reservation code and its signature digest based on the national cryptographic algorithm SM4 to generate a ciphertext reservation code; Step S106: Receive the encrypted reservation code, decrypt the encrypted reservation code based on the ESAM module, and obtain the plaintext reservation code and its digest; Step S108: For the received reservation code plaintext and its digest, verify the validity of the reservation code based on the successfully verified signature digest and reservation time quantization value stored in the local circular cache.
[0042] As described above, this application embodiment uses the national cryptographic algorithm SM4 to encrypt the reservation code and its signature digest, which effectively prevents the reservation code from being stolen or tampered with, thus improving data security. By performing bit-level compression and ring cache management on the reservation code structure, unnecessary computation and storage overhead is reduced, enabling rapid validity verification and preventing replay attacks or illegal reservations. This solution is suitable for embedded devices, especially in scenarios requiring efficient and secure real-time verification.
[0043] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatuses and methods according to various embodiments of the present disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of an instruction containing one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0044] Unless otherwise expressly indicated by the context, the singular form of words used herein and in the appended claims includes the plural form, and vice versa. Thus, when referring to the singular, the plural form of the corresponding term is generally included. Similarly, the terms “comprising” and “including” shall be interpreted as including rather than exclusively. Likewise, the terms “including” and “or” shall be interpreted as including unless such interpretation is expressly prohibited herein. Where the term “example” is used herein, particularly when it follows a set of terms, the “example” is merely exemplary and illustrative and should not be considered exclusive or extensive.
[0045] Further aspects and scope of adaptation become apparent from the description provided herein. It should be understood that various aspects of this application may be implemented individually or in combination with one or more other aspects. It should also be understood that the descriptions and specific embodiments herein are for illustrative purposes only and are not intended to limit the scope of this application.
[0046] Several embodiments of this disclosure have been described in detail above. However, it is obvious that those skilled in the art can make various modifications and variations to the embodiments of this disclosure without departing from the spirit and scope of this disclosure. The scope of protection of this disclosure is defined by the appended claims.
Claims
1. A reservation code verification method for an embedded water control terminal, characterized in that, include: A reservation code is generated based on the user's reservation request for the water control terminal. The structure of the reservation code is then compressed at the bit level to generate a corresponding signature digest. The reservation code and its signature digest are encrypted using the national cryptographic algorithm SM4 to generate a ciphertext reservation code. Receive the encrypted reservation code, decrypt the encrypted reservation code based on the ESAM module, and obtain the plaintext reservation code and its digest; For the received plaintext reservation code and its digest, the validity of the reservation code is verified based on the successfully verified signature digest and reservation time quantization value stored in the local circular cache.
2. The reservation code verification method for the embedded water control terminal according to claim 1, characterized in that, The process of generating a reservation code based on a user's reservation request for the water control terminal, and then performing bit-level compression on the structure of the reservation code to generate a corresponding signature digest includes: A reservation code is generated based on the user's reservation request for the water control terminal, and the reservation code is uniquely bound to the device ID of the water control terminal requested by the user. The reservation code is compressed into a 64-bit field structure, which includes a 14-bit device field, a 20-bit reservation time quantification value, a 14-bit usage time, an 8-bit permission policy, and an 8-bit random factor. The SipHash-2-4 algorithm was used to generate a 32-bit signature digest from the compressed reservation code.
3. The reservation code verification method for the embedded water control terminal according to claim 2, characterized in that, The device field is used to identify the water control terminal. If all values in the device field are 0, it means there is no device restriction. If the highest bit of the device field is 1, it means that mandatory verification is required. The reservation time quantization value represents the quantization value of the reservation time from the base time in 10-minute increments.
4. The reservation code verification method for the embedded water control terminal according to claim 1, characterized in that, The step of receiving the encrypted reservation code and decrypting the encrypted reservation code based on the ESAM module to obtain the plaintext reservation code and its digest includes: The encrypted reservation code is decrypted using the built-in key of the ESAM module to obtain the plaintext reservation code and its digest, and the digest is verified. Determine if the number of verification attempts for the reservation code exceeds the maximum number of verification attempts. If it does, lock the device for a preset time.
5. The reservation code verification method for the embedded water control terminal according to claim 1, characterized in that, The verification of the validity of the received reservation code plaintext and its digest, based on the successfully verified signature digest and reservation time quantization value stored in the local circular cache, includes: Check if the length of the reservation code meets the preset length. If it does not meet the preset length, reject the reservation code directly. If it does meet the preset length, check if the device ID in the reservation code matches the device ID of the current water control terminal. If they do not match, reject the reservation. A signature digest is generated for the new reservation code using the SipHash-2-4 hash algorithm. The system checks whether the signature digest of the new reservation code already exists in the local circular cache. If it does, the reservation is rejected; otherwise, the generated digest is stored in the local circular cache. Compare the reservation time quantization value of the new reservation code with the maximum reservation time quantization value. If the reservation time quantization value of the new reservation code is less than or equal to the maximum reservation time quantization value, the reservation is rejected; otherwise, the reservation is allowed, and the maximum reservation time quantization value stored locally is updated. Based on the current device's base time and the quantized value of the reservation time, the difference between the reservation time and the current device's local time is calculated. It is then determined whether the difference is within the allowed time window. If the difference is not within the allowed time window, the reservation is rejected.
6. The reservation code verification method for the embedded water control terminal according to claim 5, characterized in that, The local circular cache is used to store the signature digests and maximum reservation time quantification values of the most recently verified successful reservation codes. If a new digest needs to be added to the cache and the cache is full, the oldest digest is removed according to the LRU policy.
7. The reservation code verification method for the embedded water control terminal according to claim 1, characterized in that, The water control terminal pre-allocates a static memory pool and uses a constant stack to store data that does not need to be modified during the reservation code parsing and verification process.
8. A reservation code verification system for an embedded water control terminal, characterized in that, The system includes a water control terminal and a reservation platform. The reservation platform generates a reservation code based on a user's reservation request to the water control terminal, performs bit-level compression on the reservation code, and generates a corresponding signature digest. It then encrypts the reservation code and its signature digest using the national cryptographic algorithm SM4 to generate a ciphertext reservation code. The water control terminal receives the ciphertext reservation code, decrypts it using the ESAM module, and obtains the plaintext reservation code and its digest. For the received plaintext reservation code and its digest, the validity of the reservation code is verified based on the successfully verified signature digest and reservation time quantization value stored in the local circular cache.
9. A computing device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the reservation code verification method for the embedded water control terminal according to any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When executed by a processor, the computer program implements the steps of the reservation code verification method for the embedded water control terminal according to any one of claims 1 to 7.
Citation Information
Patent Citations
Service processing method and apparatus
CN105721413A
Image acquisition device, server, encryption method and decryption method
CN110460580A
Batch signature verification method and device based on national cipher SM2 algorithm, equipment and medium
CN112636915A
Control method, system and device of reservation code water outlet type water control machine
CN115761989A
Internet of Things water controller capable of reserving water
CN211319319U