Two-dimensional code identity authentication method, device and system

By caching the QR code index on the user terminal and generating a QR code in conjunction with the SIM card token, the security and cost issues of QR code identity authentication in offline scenarios are solved, achieving efficient and secure offline identity authentication.

CN116684111BActive Publication Date: 2026-05-01CHINA MOBILE FINANCIAL TECHNOLOGY CO LTD +2
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA MOBILE FINANCIAL TECHNOLOGY CO LTD
Filing Date
2022-02-23
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

In existing technologies, offline QR code identity authentication has poor security and high cost, and cannot be successfully completed when the mobile phone has no network or poor network.

Method used

A semi-offline QR code authentication method is adopted. The QR code index generated by the server is cached in the user terminal's cache, and a QR code is generated by combining it with the QR code token in the SIM card. The QR code index is encrypted using the user terminal's public and private keys and protected by the SM4 key for authentication.

Benefits of technology

It improves the accuracy and security of QR code identity authentication, reduces costs, enables identity authentication in offline scenarios, and simplifies management processes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116684111B_ABST
    Figure CN116684111B_ABST
Patent Text Reader

Abstract

The application provides a two-dimensional code identity authentication method, device and system, the method selects an unused two-dimensional code index from the cache of a user terminal, and reads a two-dimensional code token in a SIM card of the user terminal; wherein the two-dimensional code index is generated by a server when the user terminal communicates normally, and is sent to the user terminal, the user terminal saves the two-dimensional code index to the cache after receiving the two-dimensional code index; a two-dimensional code is generated according to the unused two-dimensional code index and the two-dimensional code token, so that a scanning terminal scans the two-dimensional code, and the two-dimensional code is sent to the server for identity authentication. The application improves the accuracy and security of two-dimensional code identity authentication, is simple to realize, low in cost, and convenient for managing two-dimensional codes.
Need to check novelty before this filing date? Find Prior Art

Description

QR code authentication methods, devices and systems Technical Field

[0001] This invention relates to the field of identity authentication technology, and in particular to a QR code identity authentication method, device and system. Background Technology

[0002] In recent years, with the continuous advancement of digital identity authentication technology, the application of digital identity QR code authentication has become increasingly widespread. This new authentication method provides digital identity authentication services when an ID card cannot be provided, facilitating people to use their digital identities for applications such as hotel check-in, travel ticket purchase, and air travel.

[0003] Existing solutions include offline and online QR code authentication methods. The online QR code authentication process is shown in Figure 1, and the steps are as follows:

[0004] 1. The user opens the APP (Application) QR code page.

[0005] 2. The app detects the current network environment. If the network environment is abnormal, it will directly generate a message indicating that the QR code generation failed.

[0006] 3. If the network environment is normal, request the QR code in real time.

[0007] The offline QR code authentication process is shown in Figure 2, and the steps are as follows:

[0008] 1. The user opens the APP's QR code page.

[0009] 2. The APP generates a QR code according to the rules defined by the QR code platform.

[0010] 3. The terminal scans the QR code.

[0011] While digital identity authentication is rapidly developing, its online authentication nature limits its application in offline scenarios. Specifically, it cannot be successfully completed when a mobile phone has no network or a poor network connection, forcing offline users to continue using outdated methods like traditional ID card authentication. Furthermore, existing offline QR code technology suffers from security vulnerabilities and high implementation costs. The payment industry may need to employ hardware devices to protect sensitive information, and QR codes are generated by the app, making management inconvenient. Summary of the Invention

[0012] This invention provides a QR code identity authentication method, device, and system to address the shortcomings of existing technologies that use offline QR code identity authentication when the mobile phone has no network or a poor network, resulting in poor security and high cost. It achieves semi-offline QR code identity authentication, thereby improving security and reducing costs.

[0013] This invention provides a QR code authentication method, comprising:

[0014] Select an unused QR code index from the user terminal's cache and read the QR code token from the user terminal's SIM card;

[0015] The QR code index is generated by the server when the user terminal is communicating normally and sent to the user terminal. The user terminal receives the QR code index and saves it in the cache.

[0016] A QR code is generated based on the unused QR code index and the QR code token, which is then scanned by a scanning terminal and sent to the server for identity authentication.

[0017] According to a QR code authentication method provided by the present invention, before selecting an unused QR code index from the user terminal's cache, the method further includes:

[0018] If the number of unused QR code indices in the cache is less than a preset threshold, a QR code index request is sent to the server when the user terminal is communicating normally, and the public key of the user terminal is sent to the server.

[0019] The system receives multiple QR code indices encrypted with an SM4 key and an SM4 key encrypted with the public key of the user terminal, returned by the server according to the QR code index request, and stores the encrypted QR code indices and the encrypted SM4 key in the cache.

[0020] The step of generating a QR code based on the unused QR code index and the QR code token includes:

[0021] The user terminal's private key is used to decrypt the SM4 key corresponding to the selected unused QR code index, and the decrypted SM4 key is used to decrypt the selected QR code index to obtain the decrypted QR code index.

[0022] A QR code is generated based on the decrypted QR code index and the QR code token.

[0023] According to a QR code authentication method provided by the present invention, the step of generating a QR code based on the QR code index and the QR code token includes:

[0024] The verification bit in the QR code is calculated based on the QR code index and the counter in the SIM card; wherein, the counter in the SIM card is used to count the number of times the QR code token is stored in the SIM card;

[0025] The QR code is generated based on the counter, QR code index, check digit, and QR code token.

[0026] The present invention also provides a QR code identity authentication method, comprising:

[0027] When communication between the user terminal and the user terminal is normal, a QR code index is generated and sent to the user terminal so that the user terminal can receive the QR code index and save it in the cache.

[0028] Receive the QR code provided by the user terminal scanned by the scanning terminal, and perform identity authentication based on the QR code;

[0029] The QR code is generated by the user terminal based on an unused QR code index selected from the cache and a QR code token in the user terminal's SIM card.

[0030] According to a QR code authentication method provided by the present invention, the step of generating a QR code index when the user terminal is communicating normally includes:

[0031] When the user terminal is communicating normally, a flag bit corresponding to the purpose of the QR code is determined according to the purpose of the QR code, and a random number corresponding to each QR code index is generated; wherein, the purpose and the flag bit are pre-associated.

[0032] The offset position corresponding to each QR code index is determined based on whether the random numbers corresponding to the QR code indices are the same.

[0033] Based on the flag bit, the generation date of the QR code index, the user ID number corresponding to the user terminal, the random number and offset bit corresponding to each QR code index, generate a string corresponding to each QR code index;

[0034] The string corresponding to each QR code index is encrypted, and a character is selected from the encrypted string based on the random number corresponding to each QR code index as the check bit corresponding to each QR code index.

[0035] The QR code index is generated based on the flag bit, the generation date of the QR code index, the user ID corresponding to the user terminal, the random number corresponding to each QR code index, the offset bit, and the check bit.

[0036] According to a QR code authentication method provided by the present invention, sending the QR code index to the user terminal includes:

[0037] Receive the public key sent by the user terminal;

[0038] The QR code index is encrypted using the SM4 key, and the SM4 key is encrypted using the public key;

[0039] The encrypted QR code index and the encrypted SM4 key are sent to the user terminal so that the user terminal can store the encrypted QR code index and the encrypted SM4 key in the cache.

[0040] According to a QR code authentication method provided by the present invention, the step of authenticating identity based on the QR code includes:

[0041] The QR code is parsed to obtain the counter, QR code index, and QR code token from the QR code;

[0042] The QR code index is parsed to obtain the generation date and user ID number from the QR code index;

[0043] Query the user information corresponding to the user's ID number and generation date, and verify the QR code token based on the user information;

[0044] The number of times the QR code token is sent to the user terminal is compared with the counter to determine whether the QR code token has been replayed in the SIM card;

[0045] The validity of the QR code index is verified; the validity verification of the QR code index includes determining whether the parsed QR code index exists in the QR code index generated for the user terminal, whether the QR code index is being used for the first time, whether the QR code index is being used in a preset order, and whether the generation date exceeds a preset time range, or one or more of the following:

[0046] The identity authentication result of the QR code is determined based on the verification result of the QR code token, whether it is replayed, and the validity verification result of the QR code index.

[0047] The present invention also provides a QR code identity authentication device, comprising:

[0048] The acquisition module is used to select unused QR code indexes from the user terminal's cache and read QR code tokens from the user terminal's SIM card.

[0049] The QR code index is generated by the server when the user terminal is communicating normally and sent to the user terminal. The user terminal receives the QR code index and saves it in the cache.

[0050] The first generation module is used to generate a QR code based on the unused QR code index and the QR code token, so that the scanning terminal can scan the QR code and send the QR code to the server for identity authentication.

[0051] The present invention also provides a QR code identity authentication device, comprising:

[0052] The second generation module is used to generate a QR code index when the user terminal is communicating normally, and send the QR code index to the user terminal so that the user terminal can receive the QR code index and save it in the cache.

[0053] The authentication module is used to receive the QR code provided by the user terminal scanned by the scanning terminal, and to perform identity authentication based on the QR code;

[0054] The QR code is generated by the user terminal based on an unused QR code index selected from the cache and a QR code token in the user terminal's SIM card.

[0055] The present invention also provides a QR code identity authentication system, including the two QR code identity authentication devices mentioned above.

[0056] The present invention also provides an electronic device, 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 any of the QR code authentication methods described above.

[0057] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the QR code authentication methods described above.

[0058] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the QR code authentication methods described above.

[0059] The QR code authentication method, device, and system provided by this invention employ a semi-offline approach for QR code authentication. When the user is connected to the internet, the server generates a QR code index in advance and caches it on the user terminal for easy QR code management. In offline scenarios, the user terminal can retrieve the QR code index from the cache and generate a QR code by combining it with the QR code token on the user terminal's SIM card. This requires both the user terminal and the SIM card to participate simultaneously, improving the accuracy and security of QR code authentication. The method is simple to implement and low in cost. Attached Figure Description

[0060] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0061] Figure 1 is a schematic diagram of the online QR code authentication process provided by existing technology;

[0062] Figure 2 is a schematic diagram of the offline QR code authentication process provided by existing technology;

[0063] Figure 3 is one of the flowcharts of the QR code authentication method provided by the present invention;

[0064] Figure 4 is a schematic diagram of the process of writing a QR code token into the SIM card of the user terminal in the QR code authentication method provided by the present invention.

[0065] Figure 5 is a schematic diagram of the QR code generation process in the QR code authentication method provided by the present invention;

[0066] Figure 6 is a second schematic flowchart of the QR code authentication method provided by the present invention;

[0067] Figure 7 is a schematic diagram of the process of generating a QR code index based on the SM4 algorithm in the QR code authentication method provided by the present invention;

[0068] Figure 8 is a schematic diagram of the QR code identity authentication process in the QR code authentication method provided by the present invention;

[0069] Figure 9 is one of the structural schematic diagrams of the QR code authentication device provided by the present invention;

[0070] Figure 10 is a second structural schematic diagram of the QR code authentication device provided by the present invention;

[0071] Figure 11 is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation

[0072] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention 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 invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0073] The following describes a QR code authentication method of the present invention with reference to Figure 3, including: step 301, selecting an unused QR code index from the cache of the user terminal, and reading the QR code token in the SIM card of the user terminal;

[0074] The QR code index is generated by the server when the user terminal is communicating normally and sent to the user terminal. The user terminal receives the QR code index and saves it in the cache.

[0075] In this embodiment, the execution entity is the user terminal. The QR code index is used to retrieve the information represented by the QR code. The QR code token is the identity identifier of the user performing QR code authentication.

[0076] This embodiment employs a semi-offline QR code authentication method. When the user terminal is online, the server generates a batch of QR code indexes in advance and caches them on the user terminal. In offline scenarios, the user terminal can generate a QR code for identity authentication using the pre-cached QR code indexes.

[0077] The SIM (Subscriber Identity Module) card in the user terminal can be a Super SIM card. The server issues a write token command, and the app on the user terminal writes the QR code token to the SIM card through the SIM card interface for QR code generation. The process of writing the QR code token to the user terminal's SIM card is shown in Figure 4.

[0078] The app opens the SIM card channel to read the QR code token on the SIM card. This process can be performed offline and the time taken can be controlled within 10ms. It has the characteristics of high efficiency, security and offline reading.

[0079] When a user needs to authenticate their identity via QR code, they are directed to a QR code display page. The app on the user's device selects an unused QR code index from the cache, generates a QR code, displays it, and opens it.

[0080] Step 302: Generate a QR code based on the unused QR code index and the QR code token, so that the scanning terminal can scan the QR code and send the QR code to the server for identity authentication.

[0081] Optionally, the selected QR code index and QR code token are combined according to a preset format to generate a QR code. After scanning the plaintext QR code, the scanning terminal sends an authentication request to the server, performing symmetric encryption and signature on the request parameters to ensure their legitimacy, especially the user terminal's public key, to prevent tampering during transmission. Simultaneously, the plaintext QR code is separately encrypted before being sent to the server for authentication. Upon receiving the authentication request, the server first verifies the signature; if the signature verification is successful, it then verifies the QR code and returns the verification result to the user terminal.

[0082] This embodiment uses a semi-offline method for QR code authentication. When the user is connected to the internet, the server generates a QR code index in advance and caches it on the user terminal for easy QR code management. In offline scenarios, the user terminal can retrieve the QR code index from the cache and generate a QR code by combining it with the QR code token on the user terminal's SIM card. Both the user terminal and the SIM card need to participate, which improves the accuracy and security of QR code authentication. It is simple to implement and low in cost.

[0083] Based on the above embodiments, before selecting unused QR code indexes from the user terminal's cache in this embodiment, the method further includes: if the number of unused QR code indexes in the cache is less than a preset threshold, then when the user terminal is communicating normally, a QR code index request is sent to the server, and the user terminal's public key is sent to the server.

[0084] Optionally, if there are no unused QR codes in the cache or the number of remaining unused QR code indexes is insufficient (e.g., less than 5), the user terminal, upon entering the QR code display page, requests the server to generate a batch of QR code indexes, such as 20 QR code indexes in a batch. The currently unused QR code indexes in the cache are then discarded. Upon receiving the new batch of QR code indexes generated by the server, the previously cached QR code indexes are set to invalid.

[0085] When a user terminal requests a QR code index, it transmits its own public key, such as the key store public key, to the server. Each user terminal has a unique public key, thus ensuring the security of the SM4 key and minimizing the impact even if it is compromised.

[0086] Optionally, when a user logs into the app on their device, they upload their public key to the server for storage. If the public key uploaded by the user changes later, it indicates that the user has changed devices, and in this case, all existing QR code indices corresponding to that user are invalidated.

[0087] The system receives multiple QR code indices encrypted with an SM4 key and an SM4 key encrypted with the public key of the user terminal, returned by the server according to the QR code index request, and stores the encrypted QR code indices and the encrypted SM4 key in the cache.

[0088] The server generates a batch of QR code indexes according to the QR code index generation method and stores the QR code indexes in the database.

[0089] The SM4 key is dynamically generated using the SM4 cryptographic algorithm. The SM4 cryptographic algorithm is a block cipher algorithm that is simple in design, secure, and efficient.

[0090] The QR code index is encrypted using an SM4 key, and the SM4 key is encrypted using the user terminal's public key. The user terminal receives the encrypted SM4 key and encrypted QR code index returned by the server and caches them locally for QR code generation and display. Encrypting the SM4 key with the public key prevents unauthorized decryption to obtain the plaintext QR code index, protecting the user's sensitive information. Each user terminal has a unique key store key pair.

[0091] The step of generating a QR code based on the unused QR code index and the QR code token includes: using the user terminal's private key to decrypt the SM4 key corresponding to the selected unused QR code index; using the decrypted SM4 key to decrypt the selected QR code index to obtain the decrypted QR code index; and generating a QR code based on the decrypted QR code index and the QR code token.

[0092] The QR code generation process involves the app on the user terminal selecting an available QR code index according to its generation time. The app then uses the user terminal's private key to decrypt the SM4 key (leaking this private key is costly). The decrypted SM4 key is then used to decrypt the QR code index. Finally, the decrypted QR code index is used to generate the QR code. The QR code generation process is shown in Figure 5.

[0093] This embodiment generates a QR code index by using the public and private key pair of the user terminal plus the SIM card QR code token. This public and private key pair has high security and is costly to crack. At the same time, the QR code token is stored in the super SIM card using the SIM card channel, which enables efficient token reading with a reading response time of less than 10ms. This protects against the risk of token theft by NFC (Near Field Communication) technology in the single SIM card token mode.

[0094] Based on the above embodiments, the generation of a QR code according to the QR code index and the QR code token in this embodiment includes: calculating a check digit in the QR code according to the QR code index and a counter in the SIM card; wherein, the counter in the SIM card is used to count the number of times the QR code token is stored in the SIM card; and generating the QR code according to the counter, the QR code index, the check digit, and the QR code token.

[0095] The content read from the SIM card by the app on the user terminal includes the encrypted information of the QR code token and the counter.

[0096] Optionally, the app combines the QR code index, QR code token, and counter as follows:

[0097] The code consists of a counter (5 digits), a QR code index (20 digits), a check digit (5 digits or less), and a SIM card token (64 digits or less). The plus sign indicates a concatenation operation.

[0098] The check bit is obtained by dividing the last 6 bits (offset bit + check bit) of the QR code index by the remainder of the counter. If the divisor is greater than the dividend, the check bit is taken from the divisor to further enhance the randomness of the QR code composition.

[0099] The following describes a QR code authentication method of the present invention with reference to Figure 6, including: step 601, generating a QR code index when the user terminal is communicating normally, and sending the QR code index to the user terminal so that the user terminal can receive the QR code index and save it in the cache;

[0100] In this embodiment, the execution entity is the server. When the user terminal is online, the server generates a batch of QR code indexes in advance and caches them on the user terminal. In offline scenarios, the user terminal can generate a QR code for identity authentication using the pre-cached QR code indexes.

[0101] Step 602: Receive the QR code provided by the user terminal scanned by the scanning terminal, and perform identity authentication based on the QR code;

[0102] The QR code is generated by the user terminal based on an unused QR code index selected from the cache and a QR code token in the user terminal's SIM card.

[0103] Optionally, the user terminal combines the selected QR code index and QR code token according to a preset format to generate a QR code. After scanning the plaintext QR code, the scanning terminal sends an authentication request to the server, performing symmetric encryption and signature on the request parameters to prevent tampering. Simultaneously, the plaintext QR code is separately encrypted and sent to the server for authentication. Upon receiving the authentication request, the server first verifies the signature; only after successful signature verification does it verify the QR code.

[0104] This embodiment uses a semi-offline method for QR code authentication. When the user is connected to the internet, the server generates a QR code index in advance and caches it on the user terminal for easy QR code management. In offline scenarios, the user terminal can retrieve the QR code index from the cache and generate a QR code by combining it with the QR code token on the user terminal's SIM card. Both the user terminal and the SIM card need to participate, which improves the accuracy and security of QR code authentication. It is simple to implement and low in cost.

[0105] Based on the above embodiments, the generation of QR code indexes when the user terminal is communicating normally in this embodiment includes: determining a flag bit corresponding to the purpose of the QR code according to the purpose of the QR code when the user terminal is communicating normally, and generating a random number corresponding to each QR code index; wherein, the purpose and the flag bit are pre-associated.

[0106] The flags in a QR code are used to distinguish its purpose. The server can verify QR codes for different purposes based on these flags.

[0107] Random numbers are generated using a random number generation algorithm. These random numbers are used to ensure the security of the QR code and prevent forgery and credential stuffing attacks.

[0108] The offset position corresponding to each QR code index is determined based on whether the random numbers corresponding to the QR code indices are the same.

[0109] The offset bit is used to prevent the generation of duplicate QR code indices. If the random numbers generated for QR code indices within the same batch are identical, the offset bit corresponding to the identical random numbers is gradually increased to ensure that QR code indices generated within the same batch are not duplicated. For example, if three random numbers are identical, the offset bits corresponding to these three random numbers are 2, 3, and 4 respectively, while the offset bit corresponding to other random numbers is 2. The starting position of the offset bit is determined by the batch of QR code indices; the starting position of the offset bit is different in different batches of QR code indices, thus ensuring that QR code indices from different batches are not duplicated.

[0110] Based on the flag bit, the generation date of the QR code index, the user ID number corresponding to the user terminal, the random number and offset bit corresponding to each QR code index, generate a string corresponding to each QR code index;

[0111] Optionally, the QR code index format is: 2 flag bits (based on the QR code function definition) + 4 date bits (current year) + 2 random numbers + 4 date bits (current month + day) + 4 last 4 digits of the user's ID card number + 2 offset bits + 4 check bits (calculated based on the first 18 bits). The plus sign indicates a concatenation operation. The generation date and the last digit of the user's ID card number in the QR code index are used to improve database retrieval performance, thereby increasing the efficiency of QR code authentication.

[0112] The string corresponding to each QR code index is encrypted, and a character is selected from the encrypted string based on the random number corresponding to each QR code index as the check bit corresponding to each QR code index.

[0113] Optionally, the first 18 bits of the QR code index are encrypted using AES (Advanced Encryption Standard) to obtain an encrypted string, and 4 characters of the encrypted string are taken as a check digit based on the composition of two random numbers.

[0114] For example, if the values ​​of the two random numbers are x and y, then two characters are extracted from the encrypted string starting from the x-th position, and similarly, two characters are extracted from the encrypted string starting from the y-th position. Finally, the four extracted characters are concatenated together to form the check digit.

[0115] The AES encryption key is randomly generated by the user, ensuring that different users use different encryption keys to enhance security. The checksum is generated privately on the server side, further preventing forgery and credential stuffing attacks.

[0116] The QR code index is generated based on the flag bit, the generation date of the QR code index, the user ID corresponding to the user terminal, the random number corresponding to each QR code index, the offset bit, and the check bit.

[0117] Based on the above embodiments, the step of sending the QR code index to the user terminal in this embodiment includes: receiving the public key sent by the user terminal;

[0118] When a user terminal requests a QR code index, it transmits its own public key, such as the key store public key, to the server. The server receives the public key sent by the user terminal. Each user terminal has a unique public key, thus ensuring the security of the SM4 key.

[0119] The QR code index is encrypted using the SM4 key, and the SM4 key is encrypted using the public key;

[0120] The server generates a batch of QR code indexes according to the QR code index generation method and stores the QR code indexes in the database. The QR code indexes are encrypted using an SM4 key, and the SM4 key is encrypted using the user terminal's public key. The encrypted SM4 key and the encrypted QR code indexes are then returned to the user terminal.

[0121] The encrypted QR code index and the encrypted SM4 key are sent to the user terminal, so that the user terminal can store the encrypted QR code index and the encrypted SM4 key in the cache. The QR code index requires the user terminal's key and the SIM card's QR code token to be generated, thus improving security.

[0122] As shown in Figure 7, the steps for generating a QR code index based on the SM4 algorithm are as follows:

[0123] 1. When a user logs in, the APP transmits the public key to the server for storage.

[0124] 2. The server generates a QR code index based on the code generation method and stores it in the database. The QR code index is then encrypted with an SM4 key, which is dynamically generated by the SM4 cryptographic algorithm.

[0125] 3. The server encrypts the SM4 key using the APP's public key.

[0126] 4. The server returns the encrypted QR code and the encrypted SM4 key to the APP.

[0127] This embodiment generates a QR code index by using the public and private key pair of the user terminal plus the SIM card QR code token. This public and private key pair has high security and is costly to crack. At the same time, by using the SIM card channel to store the QR code token to the super SIM card, token reading can be performed efficiently, thus protecting against the risk of token theft by NFC technology in the single SIM card token mode.

[0128] Based on the above embodiments, as shown in Figure 8, the identity authentication based on the QR code in this embodiment includes: parsing the QR code to obtain the counter, QR code index and QR code token in the QR code;

[0129] Optionally, if the QR code is encrypted, the server first decrypts the QR code to obtain the plaintext, and then extracts each component according to its position.

[0130] For example, the first 5 bits of the plaintext QR code are extracted to obtain a counter. Bits 6 through 20 are extracted to obtain the QR code index. The check digit is calculated based on the QR code index and the counter to determine the check digit length. The starting bit of the QR code token is determined based on the check digit length, which is 21 plus the check digit length. The ciphertext of the QR code token is obtained by extracting bits from the starting bit to the end of the QR code token.

[0131] The QR code index is parsed to obtain the generation date and user ID number from the QR code index;

[0132] The QR code index is parsed to obtain the detailed information in the QR code index, including the user's ID number and the generation date.

[0133] Query the user information corresponding to the user's ID number and generation date, and verify the QR code token based on the user information;

[0134] The database is queried using the user's ID number and the generation date of the QR code index as conditions to obtain user information, including basic user information such as name and age. This embodiment is not limited to the specific content of the user information. This method effectively improves the database retrieval efficiency.

[0135] The QR code token is used as a condition to query the database and obtain user information. The user information retrieved under different conditions is compared to determine if they match. If they do not match, the QR code token verification fails; otherwise, the verification passes.

[0136] Furthermore, if the QR code token is encrypted and the server cannot decrypt it or the decryption result is inconsistent with the QR code token sent by the server to the user terminal, then the QR code token is considered invalid.

[0137] The number of times the QR code token is sent to the user terminal is compared with the counter to determine whether the QR code token has been replayed in the SIM card;

[0138] The server records the number of times the QR code token is sent to the user terminal. Optionally, it determines whether the value recorded by the server minus the counter on the SIM card is greater than or equal to 1 and less than or equal to 3. If not, it is considered that the QR code token may be replayed on the SIM card, and the QR code authentication process is terminated.

[0139] The validity of the QR code index is verified; the validity verification of the QR code index includes determining whether the parsed QR code index exists in the QR code index generated for the user terminal, whether the QR code index is being used for the first time, whether the QR code index is being used in a preset order, and whether the generation date exceeds a preset time range, or one or more of the following:

[0140] The validity of the QR code index is determined by checking its timeliness, consistency, non-reusability, and order. If no relevant record is found, the QR code authentication process is terminated.

[0141] The timeliness refers to the time between the generation and use of the QR code index being within a specified preset range; it cannot be used after the expiration date. For example, the validity period of the QR code index is 7 days.

[0142] Correctness refers to the QR code index. The QR code index must be correct and cannot be tampered with. It must be generated by the server for the user terminal to be usable.

[0143] Non-reusability means that each QR code index can only be used once.

[0144] Orderliness means that QR code indices within the same batch are used in a specific sequence and cannot be used in reverse order. After a user terminal displays a QR code once (duration ≤ 60 seconds), the next QR code will be displayed in the same order. The server establishes a usage counter for QR code indices within the same batch. Each QR code index has a serial number, and the serial number of each used QR code index should be higher than the serial number of the previously used QR code index. Cross-serial number usage is supported to prevent QR code theft by taking photos.

[0145] The identity authentication result of the QR code is determined based on the verification result of the QR code token, whether it is replayed, and the validity verification result of the QR code index.

[0146] If the QR code token verification passes without replay and the QR code index is valid, then the QR code identity authentication is considered successful; otherwise, it fails.

[0147] For scenarios with higher security levels, additional verification can be supported after QR code identity authentication, such as facial recognition or basic information comparison.

[0148] The QR code authentication device provided by the present invention is described below. The QR code authentication device described below can be referred to in correspondence with the QR code authentication method described above.

[0149] As shown in Figure 9, the device includes an acquisition module 901 and a first generation module 902, wherein:

[0150] The acquisition module 901 is used to select an unused QR code index from the user terminal's cache and read the QR code token from the user terminal's SIM card;

[0151] The QR code index is generated by the server when the user terminal is communicating normally and sent to the user terminal. The user terminal receives the QR code index and saves it in the cache.

[0152] The first generation module 902 is used to generate a QR code based on the unused QR code index and the QR code token, so that the scanning terminal can scan the QR code and send the QR code to the server for identity authentication.

[0153] This embodiment uses a semi-offline method for QR code authentication. When the user is connected to the internet, the server generates a QR code index in advance and caches it on the user terminal for easy QR code management. In offline scenarios, the user terminal can retrieve the QR code index from the cache and generate a QR code by combining it with the QR code token on the user terminal's SIM card. Both the user terminal and the SIM card need to participate, which improves the accuracy and security of QR code authentication. It is simple to implement and low in cost.

[0154] As shown in Figure 10, the device includes a second generation module 1001 and an authentication module 1002, wherein:

[0155] The second generation module 1001 is used to generate a QR code index when the user terminal is communicating normally, and send the QR code index to the user terminal so that the user terminal can receive the QR code index and save it in the cache.

[0156] The authentication module 1002 is used to receive the QR code provided by the user terminal scanned by the scanning terminal, and to perform identity authentication based on the QR code;

[0157] The QR code is generated by the user terminal based on an unused QR code index selected from the cache and a QR code token in the user terminal's SIM card.

[0158] This embodiment uses a semi-offline method for QR code authentication. When the user is connected to the internet, the server generates a QR code index in advance and caches it on the user terminal for easy QR code management. In offline scenarios, the user terminal can retrieve the QR code index from the cache and generate a QR code by combining it with the QR code token on the user terminal's SIM card. Both the user terminal and the SIM card need to participate, which improves the accuracy and security of QR code authentication. It is simple to implement and low in cost.

[0159] This embodiment provides a QR code identity authentication system, including the QR code identity authentication device in the above two embodiments.

[0160] This embodiment uses a semi-offline method for QR code authentication. When the user is connected to the internet, the server generates a QR code index in advance and caches it on the user terminal for easy QR code management. In offline scenarios, the user terminal can retrieve the QR code index from the cache and generate a QR code by combining it with the QR code token on the user terminal's SIM card. Both the user terminal and the SIM card need to participate, which improves the accuracy and security of QR code authentication. It is simple to implement and low in cost.

[0161] Figure 11 illustrates a schematic diagram of the physical structure of an electronic device. As shown in Figure 11, the electronic device may include: a processor 1110, a communications interface 1120, a memory 1130, and a communication bus 1140. The processor 1110, communications interface 1120, and memory 1130 communicate with each other via the communication bus 1140. The processor 1110 can call logical instructions in the memory 1130 to execute a QR code authentication method. This method includes: selecting an unused QR code index from the user terminal's cache and reading a QR code token from the user terminal's SIM card; wherein the QR code index is generated by the server when the user terminal is communicating normally and sent to the user terminal, and the user terminal saves the QR code index to its cache after receiving it; generating a QR code based on the unused QR code index and the QR code token for a scanning terminal to scan, and sending the QR code to the server for authentication.

[0162] Furthermore, the logical instructions in the aforementioned memory 1130 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0163] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the QR code authentication method provided by the above methods. The method includes: selecting an unused QR code index from the cache of a user terminal and reading a QR code token from the SIM card of the user terminal; wherein the QR code index is generated by a server when the user terminal is communicating normally and sent to the user terminal, and the user terminal saves the QR code index in the cache after receiving it; generating a QR code based on the unused QR code index and the QR code token for a scanning terminal to scan the QR code, and sending the QR code to the server for authentication.

[0164] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements the QR code authentication method provided by the above methods. The method includes: selecting an unused QR code index from the cache of a user terminal and reading a QR code token from the SIM card of the user terminal; wherein the QR code index is generated by a server when the user terminal is communicating normally and sent to the user terminal, and the user terminal saves the QR code index in the cache after receiving it; generating a QR code based on the unused QR code index and the QR code token for a scanning terminal to scan, and sending the QR code to the server for authentication.

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

[0166] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0167] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A QR code authentication method, characterized in that, include: The system selects an unused QR code index from the user terminal's cache and reads a QR code token from the user terminal's SIM card. The QR code index is generated by the server when the user terminal is communicating normally and sent to the user terminal, which then saves it to its cache. The QR code token serves as the user's identity identifier for QR code authentication. After the server issues a write token command, the app on the user terminal writes the QR code token to the SIM card via the SIM card channel. A QR code is generated based on the unused QR code index and the QR code token for scanning by a scanning terminal, which then sends the QR code to the server for authentication. The authentication process includes generating a QR code based on the QR code index and the QR code token, comprising: calculating a check digit in the QR code based on the QR code index and a counter in the SIM card; wherein the counter in the SIM card is used to count the number of times the QR code token is stored in the SIM card; generating the QR code based on the counter, QR code index, check digit, and QR code token; wherein the QR code index, QR code token, counter, and check digit are combined in the following manner: counter + QR code index + check digit + QR code token; wherein the plus sign indicates a concatenation operation, and the check digit is obtained by dividing the last 6 digits of the QR code index by the counter.

2. The QR code authentication method according to claim 1, characterized in that, Before selecting an unused QR code index from the user terminal's cache, the method further includes: if the number of unused QR code indices in the cache is less than a preset threshold, then when the user terminal is communicating normally, a QR code index request is sent to the server, and the user terminal's public key is sent to the server; receiving multiple QR code indices encrypted with an SM4 key and the SM4 key encrypted with the user terminal's public key returned by the server according to the QR code index request, and storing the encrypted QR code indexes and the encrypted SM4 key in the cache; generating a QR code based on the unused QR code indexes and the QR code token includes: decrypting the SM4 key corresponding to the selected unused QR code index using the user terminal's private key, decrypting the selected QR code index using the decrypted SM4 key, obtaining the decrypted QR code index; and generating a QR code based on the decrypted QR code index and the QR code token.

3. A QR code authentication method, applied to the server side, characterized in that, include: When communication with the user terminal is normal, a QR code index is generated and sent to the user terminal so that the user terminal can receive the QR code index and save it in the cache; the user terminal receives the QR code provided by the user terminal scanned by the scanning terminal and performs identity authentication based on the QR code; wherein, the QR code is generated by the user terminal based on an unused QR code index selected from the cache and a QR code token in the user terminal's SIM card; the QR code token is the identity identifier of the user performing QR code identity authentication, and after the server issues a write card token instruction, the APP on the user terminal writes the QR code token to the SIM card through the SIM card channel; wherein The QR code is generated by the user terminal based on the following steps: calculating the check digit in the QR code according to the QR code index and the counter in the SIM card; wherein, the counter in the SIM card is used to count the number of times the QR code token is stored in the SIM card; generating the QR code according to the counter, QR code index, check digit, and QR code token; wherein, the QR code index, QR code token, counter, and check digit are combined in the following manner: counter + QR code index + check digit + QR code token; wherein, the plus sign indicates a concatenation operation, and the check digit is obtained by dividing the last 6 digits of the QR code index by the counter.

4. The QR code identity authentication method according to claim 3, characterized in that, The step of generating a QR code index when the user terminal is communicating normally includes: determining a flag bit corresponding to the purpose of the QR code based on its purpose, and generating a random number corresponding to each QR code index; wherein the purpose and the flag bit are pre-associated; determining an offset bit corresponding to each QR code index based on whether the random numbers corresponding to the QR code indexes are the same; generating a string corresponding to each QR code index based on the flag bit, the generation date of the QR code index, the user ID number corresponding to the user terminal, the random number corresponding to each QR code index, and the offset bit; encrypting the string corresponding to each QR code index, and selecting a character from the encrypted string based on the random number corresponding to each QR code index as a check bit corresponding to each QR code index; and generating the QR code index based on the flag bit, the generation date of the QR code index, the user ID corresponding to the user terminal, the random number corresponding to each QR code index, the offset bit, and the check bit.

5. The QR code identity authentication method according to claim 3, characterized in that, Sending the QR code index to the user terminal includes: receiving a public key sent by the user terminal; encrypting the QR code index using an SM4 key, and encrypting the SM4 key using the public key; sending the encrypted QR code index and the encrypted SM4 key to the user terminal so that the user terminal can store the encrypted QR code index and the encrypted SM4 key in the cache.

6. The QR code identity authentication method according to claim 4, characterized in that, The identity authentication based on the QR code includes: parsing the QR code to obtain a counter, a QR code index, and a QR code token; parsing the QR code index to obtain the generation date and user ID number; querying user information corresponding to the user ID number and generation date, and verifying the QR code token based on the user information; comparing the number of times the QR code token has been issued to the user terminal with the counter to determine whether the QR code token has been replayed in the SIM card; verifying the validity of the QR code index; the validity verification of the QR code index includes determining whether the parsed QR code index exists in the QR code index generated for the user terminal, whether the QR code index is being used for the first time, whether the QR code index is being used in a preset order, and whether the generation date exceeds a preset time range, or one or more of the following: based on the verification result of the QR code token, whether it has been replayed, and the validity verification result of the QR code index, determining the identity authentication result of the QR code.

7. A QR code identity authentication device, characterized in that, include: The acquisition module is used to select an unused QR code index from the user terminal's cache and read the QR code token from the user terminal's SIM card. The QR code index is generated by the server when the user terminal is communicating normally and sent to the user terminal. The user terminal receives the QR code index and saves it in its cache. The QR code token is the identity identifier of the user performing QR code authentication. After the server issues a write token command, the APP on the user terminal writes the QR code token to the SIM card through the SIM card channel. The first generation module is used to generate a QR code based on the unused QR code index and the QR code token, for the scanning terminal to scan the QR code, and send the QR code to the SIM card. The server performs identity authentication; the step of generating a QR code based on the QR code index and the QR code token includes: calculating a check digit in the QR code based on the QR code index and a counter in the SIM card; wherein the counter in the SIM card is used to count the number of times the QR code token is stored in the SIM card; generating the QR code based on the counter, QR code index, check digit, and QR code token; wherein the QR code index, QR code token, counter, and check digit are combined in the following manner: counter + QR code index + check digit + QR code token; wherein the plus sign indicates a concatenation operation, and the check digit is obtained by dividing the last 6 digits of the QR code index by the counter.

8. A QR code identity authentication device, applied on a server side, characterized in that, include: The second generation module is used to generate a QR code index when the user terminal is communicating normally, and send the QR code index to the user terminal so that the user terminal can receive the QR code index and save it in the cache. An authentication module is used to receive a QR code provided by the user terminal scanned by a scanning terminal, and to perform identity authentication based on the QR code. The QR code is generated by the user terminal based on an unused QR code index selected from the cache and a QR code token in the user terminal's SIM card. The QR code token serves as the identity identifier for the user performing QR code authentication. After the server issues a write token instruction, the APP on the user terminal writes the QR code token to the SIM card through the SIM card channel. The QR code is generated by the user terminal based on the following steps: calculating a check digit in the QR code based on the QR code index and a counter in the SIM card; the counter in the SIM card is used to count the number of times the QR code token is stored in the SIM card; generating the QR code based on the counter, QR code index, check digit, and QR code token; the QR code index, QR code token, counter, and check digit are combined as follows: counter + QR code index + check digit + QR code token; the plus sign indicates a concatenation operation, and the check digit is obtained by dividing the last 6 digits of the QR code index by the counter.

9. A QR code identity authentication system, characterized in that, It includes the QR code identity authentication device as described in claim 7 and the QR code identity authentication device as described in claim 8.

Citation Information

Patent Citations

  • System and method for realizing two-dimensional code security by using SIM card

    CN110555693A

  • Two-dimensional code offline generation method and storage medium

    CN111967556A