Offline transaction method and device
By negotiating the generation of symmetric encryption keys in dual offline transactions of digital currency, the lack of digital currency encryption during the transaction process is solved, and the security and success rate of transactions are improved.
Patent Information
- Application Number
- CN202111165709.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-30
- Publication Date
- 2025-03-07
- Estimated Expiration
- 2041-09-30
AI Technical Summary
In existing digital currency dual offline transactions, there is a lack of description of digital currency encryption during the transaction process, resulting in insufficient transaction security.
After passing the identity authentication between the two parties, the payee and the payee negotiate to generate a symmetric encryption key, which is used to encrypt and decrypt the transaction data, thereby achieving the security of the transaction process.
Improve the security and success rate of offline transactions, ensuring the confidentiality and integrity of transaction data during transmission.
Smart Images

Figure CN114037447B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of digital currency technology, and in particular to a method and device for offline transactions. Background Art
[0002] In the existing public digital currency dual offline transactions, after the payee and the payee have completed mutual identity authentication, the payer encrypts the digital currency encryption string and the dual offline transaction information to generate the dual offline transaction data, and then transmits it to the payee using near field communication technology. However, there is no mention of how to encrypt during the transaction. Therefore, how to encrypt the digital currency during the transaction process to achieve transaction security is a technical problem that needs to be solved urgently. Summary of the invention
[0003] In view of this, an embodiment of the present invention provides a method and apparatus for offline transactions, which can enable both parties to jointly negotiate encryption keys, thereby improving the security and success rate of offline transactions.
[0004] To achieve the above objective, according to one aspect of an embodiment of the present invention, a method for offline transaction is provided.
[0005] An offline transaction method, comprising:
[0006] Authenticate the payer and obtain the payer's public key;
[0007] Generate a first encryption key factor, encrypt the first encryption key factor using the payer's public key to obtain first ciphertext data, and send the first ciphertext data to the payer;
[0008] Receiving second ciphertext data sent by the payer, where the second ciphertext data is obtained by encrypting a second encryption key factor generated by the payer using a payee's public key;
[0009] decrypting the second ciphertext data to obtain the second encryption key factor, and generating a symmetric encryption key according to the first encryption key factor and the second encryption key factor;
[0010] The encrypted transaction data sent by the payee is decrypted using the symmetric encryption key to obtain the transaction data and perform transaction confirmation, and the transaction confirmation information is sent to the payee to complete the transaction. The encrypted transaction data is obtained by the payee encrypting the transaction data using the symmetric encryption key.
[0011] Optionally, authenticating the payer and obtaining the payer's public key includes:
[0012] Authenticate the payer based on the payer's SM2 public-private key pair and obtain the payer's public key;
[0013] Decrypting the second ciphertext data to obtain the second encryption key factor includes:
[0014] Use the private key in the SM2 public-private key pair to decrypt the second ciphertext data to obtain the second encryption key factor.
[0015] Optionally, the payer obtains the symmetric encryption key in the following manner:
[0016] The payer obtains the first encryption key factor after decrypting the first ciphertext data, and generates the symmetric encryption key according to the first encryption key factor and the second encryption key factor.
[0017] Optionally, generating a symmetric encryption key according to the first encryption key factor and the second encryption key factor includes:
[0018] The first encryption key factor and the second encryption key factor are sequentially concatenated and then hashed to generate a symmetric encryption key.
[0019] Optionally, the symmetric encryption key is a 16-byte encryption key;
[0020] If the result of the hash operation is 32 bytes, the first 16 bytes and the last 16 bytes of the hash operation result are subjected to a bitwise XOR operation to obtain the symmetric encryption key.
[0021] Optionally, performing transaction confirmation includes:
[0022] Verify the transaction data and sign the verification result;
[0023] The verification result and signature data are sequentially concatenated to generate transaction confirmation information.
[0024] According to another aspect of an embodiment of the present invention, a method for offline transaction is provided.
[0025] An offline transaction method, comprising:
[0026] Authenticate the recipient and obtain the recipient's public key;
[0027] receiving first ciphertext data sent by the payee, and decrypting the first ciphertext data to obtain the first encryption key factor, wherein the first ciphertext data is obtained by the payee encrypting the first encryption key factor generated by the payee using the payer's public key;
[0028] Generate a second encryption key factor, encrypt the second encryption key factor using the payee's public key to obtain second ciphertext data, and send the second ciphertext data to the payee;
[0029] generating a symmetric encryption key based on the first encryption key factor and the second encryption key factor;
[0030] Encrypting the transaction data using the symmetric encryption key to obtain encrypted transaction data, and sending the encrypted transaction data to the payee, so that the payee uses the symmetric encryption key to decrypt the encrypted transaction data to obtain transaction data and confirm the transaction;
[0031] Receive transaction confirmation information from the payee to complete the transaction.
[0032] Optionally, authenticating the payee and obtaining the payee's public key includes:
[0033] Authenticate the payee based on the payee's SM2 public-private key pair and obtain the payee's public key;
[0034] Decrypting the first ciphertext data to obtain the first encryption key factor includes:
[0035] Use the private key in one's own SM2 public-private key pair to decrypt the first ciphertext data to obtain the first encryption key factor.
[0036] According to yet another aspect of an embodiment of the present invention, a method for offline transaction is provided.
[0037] An offline transaction method, comprising:
[0038] The payee and payer perform identity authentication and obtain each other's public key;
[0039] The payee generates a first encryption key factor, encrypts the first encryption key factor using the payer's public key to obtain first ciphertext data, and sends the first ciphertext data to the payer;
[0040] The payer decrypts the first ciphertext data to obtain the first encryption key factor; generates a second encryption key factor, encrypts the second encryption key factor using the payee's public key to obtain second ciphertext data, and sends the second ciphertext data to the payee; generates a symmetric encryption key based on the first encryption key factor and the second encryption key factor;
[0041] The payee decrypts the second ciphertext data to obtain the second encryption key factor, and generates the symmetric encryption key according to the first encryption key factor and the second encryption key factor;
[0042] The payer encrypts the transaction data using the symmetric encryption key to obtain encrypted transaction data, and sends the encrypted transaction data to the payee;
[0043] The payee uses the symmetric encryption key to decrypt the encrypted transaction data to obtain transaction data and perform transaction confirmation, and sends the transaction confirmation information to the payer to complete the transaction.
[0044] According to yet another aspect of an embodiment of the present invention, an offline transaction device is provided.
[0045] An off-line transaction device, the device is located at a payee, and the device comprises:
[0046] The payer authentication module is used to authenticate the payer and obtain the payer's public key;
[0047] A first ciphertext generation module, used to generate a first encryption key factor, encrypt the first encryption key factor using the payer's public key to obtain first ciphertext data, and send the first ciphertext data to the payer;
[0048] A second ciphertext receiving module, used to receive second ciphertext data sent by the payer, where the second ciphertext data is obtained by encrypting a second encryption key factor generated by the payer using a payee's public key;
[0049] a symmetric key generation module, configured to decrypt the second ciphertext data to obtain the second encryption key factor, and generate a symmetric encryption key according to the first encryption key factor and the second encryption key factor;
[0050] The transaction processing confirmation module is used to use the symmetric encryption key to decrypt the encrypted transaction data sent by the payer to obtain transaction data and perform transaction confirmation, and send the transaction confirmation information to the payer to complete the transaction. The encrypted transaction data is obtained by the payer encrypting the transaction data using the symmetric encryption key.
[0051] According to yet another aspect of an embodiment of the present invention, an offline transaction device is provided.
[0052] A device for offline transactions, the device is located at a payee, and the device comprises:
[0053] The payee authentication module is used to authenticate the payee and obtain the payee's public key;
[0054] a first ciphertext decryption module, configured to receive first ciphertext data sent by the payee, and decrypt the first ciphertext data to obtain the first encryption key factor, wherein the first ciphertext data is obtained by the payee encrypting the first encryption key factor generated by the payee using the payer's public key;
[0055] A second ciphertext generation module, used to generate a second encryption key factor, encrypt the second encryption key factor using the payee's public key to obtain second ciphertext data, and send the second ciphertext data to the payee;
[0056] A key generation module, configured to generate a symmetric encryption key according to the first encryption key factor and the second encryption key factor;
[0057] A transaction processing module, configured to encrypt the transaction data using the symmetric encryption key to obtain encrypted transaction data, and send the encrypted transaction data to the payee, so that the payee uses the symmetric encryption key to decrypt the encrypted transaction data to obtain transaction data and perform transaction confirmation;
[0058] The transaction confirmation module is used to receive the transaction confirmation information sent by the payee to complete the transaction.
[0059] According to yet another aspect of an embodiment of the present invention, an electronic device for offline transactions is provided.
[0060] An electronic device for offline transactions, comprising: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement the offline transaction method provided by an embodiment of the present invention.
[0061] According to still another aspect of the embodiments of the present invention, a computer readable medium is provided.
[0062] A computer-readable medium stores a computer program, which, when executed by a processor, implements the offline transaction method provided by an embodiment of the present invention.
[0063] An embodiment of the above invention has the following advantages or beneficial effects: by authenticating the payer and obtaining the payer's public key; generating a first encryption key factor, using the payer's public key to encrypt the first encryption key factor to obtain first ciphertext data, and sending the first ciphertext data to the payer; receiving second ciphertext data sent by the payer; decrypting the second ciphertext data to obtain a second encryption key factor, and generating a symmetric encryption key based on the first encryption key factor and the second encryption key factor; using the symmetric encryption key to decrypt the encrypted transaction data sent by the payer to obtain transaction data and confirm the transaction, and sending the transaction confirmation information to the payer to complete the transaction. The technical solution, by the payee and the payer each generating a part of the encryption key factor and generating a symmetric encryption key, enables the two parties to jointly negotiate encryption keys, thereby improving the security and success rate of offline transactions.
[0064] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0066] Figure 1 is a schematic diagram of main steps of an offline transaction method according to an embodiment of the present invention;
[0067] Figure 2 is a schematic diagram of main steps of an offline transaction method according to another embodiment of the present invention;
[0068] Figure 3 is a schematic diagram of main steps of an offline transaction method according to another embodiment of the present invention;
[0069] Figure 4 is a timing diagram of an offline transaction process of an embodiment of the present invention;
[0070] Figure 5 is a schematic diagram of main modules of an off-line transaction device according to an embodiment of the present invention;
[0071] Figure 6 is a schematic diagram of main modules of an off-line transaction device according to another embodiment of the present invention;
[0072] Figure 7 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0073] Figure 8 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0074] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0075] In order to solve the technical problems existing in the prior art, the present invention provides a method and device for offline transactions. According to the technical solution of the present invention, the process of the offline transaction between the payee and the payer mainly includes: the payee and the payee perform identity authentication, the payee and the payee negotiate the encryption key, the payee sends the encrypted transaction data to the payee, and the payee sends the transaction confirmation to the payee. Specifically, when conducting encryption key negotiation, it mainly includes three steps: the first step is that after the payee authenticates the identity of the payee, a string of random numbers randA is generated as the encryption key factor, and the ciphertext data cipherA is generated after encryption using the payee's authentication public key and passed to the payee; the second step is that the payee uses the private key corresponding to its own authentication public key to decrypt cipherA to obtain the encryption key factor randA, and then generates a string of random numbers randB as the encryption key factor, and ciphers it using the payee's authentication public key to generate the ciphertext data cipherB and pass it to the payee, and at the same time uses randA and randB to perform a hash operation to generate the encryption key K; the third step is that the payee uses the private key corresponding to its own authentication public key to decrypt cipherB to obtain the encryption key factor randB, and uses randA and randB to perform a hash operation to generate the encryption key K. After these three steps, the payee and the payee have negotiated a symmetric encryption key K, and use K to perform a symmetric encryption operation on the digital currency encryption string and the dual offline transaction information to generate the dual offline ciphertext transaction data.
[0076] In the introduction to the embodiments of the present invention, the meanings of the terms involved are as follows:
[0077] PKI: Public Key Infrastructure, public key infrastructure;
[0078] RSA algorithm: a public key cryptographic algorithm proposed by Ron Rivest, Adi Shamir, and Leonard Adleman;
[0079] SM2: Elliptic curve public key cryptography algorithm released by the State Cryptography Administration on December 17, 2010;
[0080] SM3: A cryptographic hash function standard issued by the State Cryptography Administration on December 17, 2010;
[0081] SM4: SM4 block cipher algorithm was released and implemented by the State Cryptography Administration in 2012.
[0082] Figure 1 FIG. 1 is a schematic diagram of the main steps of an offline transaction method according to an embodiment of the present invention. Figure 1 As shown, the offline transaction method of one embodiment of the present invention is executed by the payee, and the offline transaction method mainly includes the following steps S101 to S105.
[0083] Step S101: Authenticate the payer and obtain the payer's public key;
[0084] Step S102: Generate a first encryption key factor, use the payer's public key to encrypt the first encryption key factor to obtain first ciphertext data, and send the first ciphertext data to the payer;
[0085] Step S103: receiving second ciphertext data sent by the payer, where the second ciphertext data is obtained by the payer using the payee's public key to encrypt a second encryption key factor generated by the payer;
[0086] Step S104: decrypting the second ciphertext data to obtain the second encryption key factor, and generating a symmetric encryption key according to the first encryption key factor and the second encryption key factor;
[0087] Step S105: Use the symmetric encryption key to decrypt the encrypted transaction data sent by the payer to obtain transaction data and perform transaction confirmation, and send the transaction confirmation information to the payer to complete the transaction. The encrypted transaction data is obtained by the payer encrypting the transaction data using the symmetric encryption key.
[0088] According to one embodiment of the present invention, performing identity authentication on the payer and obtaining the payer's public key in step S101 may specifically include:
[0089] Authenticate the payer based on the payer's SM2 public-private key pair and obtain the payer's public key;
[0090] Furthermore, decrypting the second ciphertext data to obtain the second encryption key factor in step S104 may specifically include:
[0091] Use the private key in the SM2 public-private key pair to decrypt the second ciphertext data to obtain the second encryption key factor.
[0092] According to an embodiment of the present invention, the payer obtains the symmetric encryption key in the following manner:
[0093] The payer obtains the first encryption key factor after decrypting the first ciphertext data, and generates the symmetric encryption key according to the first encryption key factor and the second encryption key factor.
[0094] According to an embodiment of the present invention, in step S104, generating a symmetric encryption key according to the first encryption key factor and the second encryption key factor may specifically include:
[0095] The first encryption key factor and the second encryption key factor are sequentially concatenated and then hashed to generate a symmetric encryption key.
[0096] In an embodiment of the present invention, the symmetric encryption key is a 16-byte encryption key; if the result of the hash operation is 32 bytes, the first 16 bytes and the last 16 bytes of the hash operation result are subjected to a bitwise XOR operation to obtain the symmetric encryption key.
[0097] In an embodiment of the present invention, transaction confirmation may specifically include: verifying the transaction data and signing the verification result; and sequentially concatenating the verification result and the signature data to generate transaction confirmation information.
[0098] Figure 2 FIG. 1 is a schematic diagram of the main steps of an offline transaction method according to another embodiment of the present invention. Figure 2 As shown, the offline transaction method of another embodiment of the present invention is executed by the payer, and the offline transaction method mainly includes the following steps S201 to S206.
[0099] Step S201: Authenticate the payee and obtain the payee's public key;
[0100] Step S202: receiving the first ciphertext data sent by the payee, and decrypting the first ciphertext data to obtain the first encryption key factor, where the first ciphertext data is obtained by the payee using the payee's public key to encrypt the first encryption key factor generated by the payee;
[0101] Step S203: Generate a second encryption key factor, use the payee's public key to encrypt the second encryption key factor to obtain second ciphertext data, and send the second ciphertext data to the payee;
[0102] Step S204: generating a symmetric encryption key according to the first encryption key factor and the second encryption key factor;
[0103] Step S205: using the symmetric encryption key to encrypt the transaction data to obtain encrypted transaction data, and sending the encrypted transaction data to the payee, so that the payee uses the symmetric encryption key to decrypt the encrypted transaction data to obtain transaction data and confirm the transaction;
[0104] Step S206: Receive transaction confirmation information from the payee to complete the transaction.
[0105] According to one embodiment of the present invention, performing identity authentication on the payee and obtaining the payee's public key in step S201 may specifically include:
[0106] Authenticate the payee based on the payee's SM2 public-private key pair and obtain the payee's public key;
[0107] Furthermore, in step S202, decrypting the first ciphertext data to obtain the first encryption key factor may specifically include:
[0108] Use the private key in one's own SM2 public-private key pair to decrypt the first ciphertext data to obtain the first encryption key factor.
[0109] According to an embodiment of the present invention, the payee obtains the symmetric encryption key in the following manner:
[0110] The payee obtains the second encryption key factor after decrypting the second ciphertext data, and generates the symmetric encryption key according to the first encryption key factor and the second encryption key factor.
[0111] According to an embodiment of the present invention, in step S204, generating a symmetric encryption key according to the first encryption key factor and the second encryption key factor may specifically include:
[0112] The first encryption key factor and the second encryption key factor are sequentially concatenated and then hashed to generate a symmetric encryption key.
[0113] In an embodiment of the present invention, the symmetric encryption key is a 16-byte encryption key; if the result of the hash operation is 32 bytes, the first 16 bytes and the last 16 bytes of the hash operation result are subjected to a bitwise XOR operation to obtain the symmetric encryption key.
[0114] In an embodiment of the present invention, the transaction confirmation by the payee may specifically include: verifying the transaction data and signing the verification result; and sequentially concatenating the verification result and the signature data to generate transaction confirmation information.
[0115] Figure 3FIG. 1 is a schematic diagram of the main steps of an offline transaction method according to another embodiment of the present invention. Figure 3 As shown, in another embodiment of the present invention, a process of an offline transaction between a payee and a payer is described, and the offline transaction method mainly includes the following steps S301 to S306.
[0116] Step S301: The payee and the payer perform identity authentication and obtain each other's public key;
[0117] Step S302: the payee generates a first encryption key factor, encrypts the first encryption key factor using the payer's public key to obtain first ciphertext data, and sends the first ciphertext data to the payer;
[0118] Step S303: the payer decrypts the first ciphertext data to obtain the first encryption key factor; generates a second encryption key factor, encrypts the second encryption key factor using the payee's public key to obtain second ciphertext data, and sends the second ciphertext data to the payee; generates a symmetric encryption key based on the first encryption key factor and the second encryption key factor;
[0119] Step S304: the payee decrypts the second ciphertext data to obtain the second encryption key factor, and generates the symmetric encryption key according to the first encryption key factor and the second encryption key factor;
[0120] Step S305: the payer uses the symmetric encryption key to encrypt the transaction data to obtain encrypted transaction data, and sends the encrypted transaction data to the payee;
[0121] Step S306: The payee uses the symmetric encryption key to decrypt the encrypted transaction data to obtain transaction data and confirm the transaction, and sends the transaction confirmation information to the payer to complete the transaction.
[0122] The following describes how the payee and the payee perform offline transactions in an embodiment of the present invention in conjunction with the accompanying drawings. Figure 4 is a timing diagram of the offline transaction process of an embodiment of the present invention. Figure 4 As shown, the process of offline transaction between two parties in this embodiment mainly includes the following steps:
[0123] Step 1: The payee and the payer authenticate each other based on the SM2 public-private key pair. The payee sends the payee's SM2 public key certificate and its SM2 private key signature issued by the CA to the payer for authentication. The payer sends the payee's SM2 public key certificate and its SM2 private key signature issued by the CA to the payee for authentication. After both parties authenticate their identities, they obtain each other's public key;
[0124] Step 2: The payee and the payer negotiate the encryption key. The negotiation process includes the following three sub-steps:
[0125] (1) The payee generates a string of random numbers randA as the first encryption key factor, encrypts it using the public key in the public key certificate of the payee SM2 to generate the first ciphertext data cipherA and sends it to the payer;
[0126] (2) The payer uses his own SM2 private key to decrypt the first ciphertext data cipherA and obtain the first encryption key factor randA; then generates a string of random numbers randB as the second encryption key factor, and uses the public key in the payee's SM2 public key certificate to encrypt the second ciphertext data cipherB and send it to the payee; at the same time, the first encryption key factor randA and the second encryption key factor randB are sequentially concatenated and hashed to generate the symmetric encryption key K of the SM4 encryption algorithm. If the SM3 hashing algorithm is used, the result of the operation is 32 bytes. At this time, the first 16 bytes and the last 16 bytes can be taken for bitwise XOR operation to obtain the symmetric encryption key K of the SM4 encryption algorithm with a result of 16 bytes;
[0127] (3) The payee uses his own SM2 private key to decrypt the second ciphertext data cipherB and obtains the second encryption key factor randB. After sequentially concatenating the first encryption key factor randA and the second encryption key factor randB, a hash operation is performed to generate the symmetric encryption key K of the SM4 encryption algorithm. The operation method from the hash operation to obtaining the symmetric encryption key K of the SM4 encryption algorithm is the same as step (2) above;
[0128] Step 3: The payer uses the negotiated symmetric encryption key of the SM4 encryption algorithm to encrypt the digital currency encryption string and offline transaction information (including transaction amount, transaction time, SM2 private key signature of the payer for this transaction, etc.) to generate encrypted transaction data and send it to the payee. In order to improve transaction performance and simplify the transaction process, this step can be combined with (2) in step 2 into one step. The payer sends the second ciphertext data cipherB and the encrypted transaction data to the payee;
[0129] Step 4. The payee uses the negotiated symmetric encryption key of the SM4 encryption algorithm to decrypt the received encrypted transaction data, restore the plaintext transaction data (for example, including: digital currency encrypted string and offline transaction information) and verify it. The verification mainly includes checking the legitimacy of the digital currency string, checking the transaction amount, and verifying the signature of the transaction generated by the payee. After the verification is passed, the verification result is signed to generate the SM2 private key signature of the payee of this transaction, and then the verification result and the signature data are sequentially concatenated to generate transaction confirmation information. Finally, the transaction confirmation information is sent to the payee to complete the transaction. In order to improve transaction performance and simplify the transaction process, this step can be combined with (3) in step 2 into one step. After the payee receives the second ciphertext data cipherB and the encrypted transaction data, it decrypts and verifies to generate transaction confirmation information.
[0130] According to the technical solution of the present invention, the hash algorithm is not limited to the SM3 algorithm, and can also be other algorithms such as SHA256. If a commercial cryptographic algorithm is used, the offline transaction method of the present invention can also use the SM2 key exchange protocol for encryption key negotiation as an alternative. However, this alternative is only applicable to commercial cryptographic algorithms and is not applicable to other PKI algorithms, such as the RSA algorithm.
[0131] Figure 5 FIG. 1 is a schematic diagram of the main modules of an off-line transaction device according to an embodiment of the present invention. Figure 5 As shown, an offline transaction device 500 of an embodiment of the present invention is located at the payee, and mainly includes a payer authentication module 501, a first ciphertext generation module 502, a second ciphertext receiving module 503, a symmetric key generation module 504 and a transaction processing confirmation module 505.
[0132] The payer authentication module 501 is used to authenticate the payer and obtain the payer's public key;
[0133] A first ciphertext generation module 502 is used to generate a first encryption key factor, encrypt the first encryption key factor using the payer's public key to obtain first ciphertext data, and send the first ciphertext data to the payer;
[0134] The second ciphertext receiving module 503 is used to receive the second ciphertext data sent by the payer, where the second ciphertext data is obtained by the payer using the payee's public key to encrypt the second encryption key factor generated by the payer;
[0135] a symmetric key generation module 504, configured to decrypt the second ciphertext data to obtain the second encryption key factor, and generate a symmetric encryption key according to the first encryption key factor and the second encryption key factor;
[0136] The transaction processing confirmation module 505 is used to use the symmetric encryption key to decrypt the encrypted transaction data sent by the payer to obtain the transaction data and perform transaction confirmation, and send the transaction confirmation information to the payer to complete the transaction. The encrypted transaction data is obtained by the payer encrypting the transaction data using the symmetric encryption key.
[0137] According to one embodiment of the present invention, the payer authentication module 501 may also be used for:
[0138] Authenticate the payer based on the payer's SM2 public-private key pair and obtain the payer's public key;
[0139] Furthermore, the symmetric key generation module 504 may also be used for:
[0140] Use the private key in the SM2 public-private key pair to decrypt the second ciphertext data to obtain the second encryption key factor.
[0141] According to an embodiment of the present invention, the payer obtains the symmetric encryption key in the following manner:
[0142] The payer obtains the first encryption key factor after decrypting the first ciphertext data, and generates the symmetric encryption key according to the first encryption key factor and the second encryption key factor.
[0143] According to an embodiment of the present invention, the symmetric key generation module 504 may also be used for:
[0144] The first encryption key factor and the second encryption key factor are sequentially concatenated and then hashed to generate a symmetric encryption key.
[0145] In an embodiment of the present invention, the symmetric encryption key is a 16-byte encryption key;
[0146] If the result of the hash operation is 32 bytes, the first 16 bytes and the last 16 bytes of the hash operation result are subjected to a bitwise XOR operation to obtain the symmetric encryption key.
[0147] In the embodiment of the present invention, the transaction confirmation performed by the transaction processing confirmation module 505 includes:
[0148] Verify the transaction data and sign the verification result;
[0149] The verification result and signature data are sequentially concatenated to generate transaction confirmation information.
[0150] Figure 6 FIG. 1 is a schematic diagram of the main modules of an off-line transaction device according to another embodiment of the present invention. Figure 6 As shown, the offline transaction device 600 of another embodiment of the present invention is located at the payee, and mainly includes a payee authentication module 601, a first ciphertext decryption module 602, a second ciphertext generation module 603, a key generation module 604, a transaction processing module 605 and a transaction confirmation module 606.
[0151] The payee authentication module 601 is used to authenticate the payee and obtain the payee's public key;
[0152] A first ciphertext decryption module 602 is used to receive first ciphertext data sent by the payee, and decrypt the first ciphertext data to obtain the first encryption key factor, where the first ciphertext data is obtained by the payee using the payee's public key to encrypt the first encryption key factor generated by the payee;
[0153] A second ciphertext generation module 603 is used to generate a second encryption key factor, encrypt the second encryption key factor using the payee's public key to obtain second ciphertext data, and send the second ciphertext data to the payee;
[0154] A key generation module 604, configured to generate a symmetric encryption key according to the first encryption key factor and the second encryption key factor;
[0155] The transaction processing module 605 is used to encrypt the transaction data using the symmetric encryption key to obtain encrypted transaction data, and send the encrypted transaction data to the payee, so that the payee uses the symmetric encryption key to decrypt the encrypted transaction data to obtain transaction data and confirm the transaction;
[0156] The transaction confirmation module 606 is used to receive the transaction confirmation information sent by the payee to complete the transaction.
[0157] According to one embodiment of the present invention, the payee authentication module 601 may also be used for:
[0158] Authenticate the payee based on the payee's SM2 public-private key pair and obtain the payee's public key;
[0159] In addition, the first ciphertext decryption module 602 may also be used for:
[0160] Use the private key in one's own SM2 public-private key pair to decrypt the first ciphertext data to obtain the first encryption key factor.
[0161] According to an embodiment of the present invention, the payee obtains the symmetric encryption key in the following manner:
[0162] The payee obtains the second encryption key factor after decrypting the second ciphertext data, and generates the symmetric encryption key according to the first encryption key factor and the second encryption key factor.
[0163] According to an embodiment of the present invention, the key generation module 604 may also be used to:
[0164] The first encryption key factor and the second encryption key factor are sequentially concatenated and then hashed to generate a symmetric encryption key.
[0165] In an embodiment of the present invention, the symmetric encryption key is a 16-byte encryption key; if the result of the hash operation is 32 bytes, the first 16 bytes and the last 16 bytes of the hash operation result are subjected to a bitwise XOR operation to obtain the symmetric encryption key.
[0166] In an embodiment of the present invention, the transaction confirmation by the payee may specifically include: verifying the transaction data and signing the verification result; and sequentially concatenating the verification result and the signature data to generate transaction confirmation information.
[0167] According to the technical solution of the embodiment of the present invention, the payer is authenticated and the payer's public key is obtained; a first encryption key factor is generated, the first encryption key factor is encrypted using the payer's public key to obtain first ciphertext data, and the first ciphertext data is sent to the payer; second ciphertext data sent by the payer is received; the second ciphertext data is decrypted to obtain a second encryption key factor, and a symmetric encryption key is generated based on the first encryption key factor and the second encryption key factor; the encrypted transaction data sent by the payer is decrypted using the symmetric encryption key to obtain transaction data and confirm the transaction, and the transaction confirmation information is sent to the payer to complete the transaction. The technical solution, by the payee and the payer each generating a part of the encryption key factor and generating a symmetric encryption key, enables the two parties to jointly negotiate encryption keys, thereby improving the security and success rate of offline transactions.
[0168] Figure 7 An exemplary system architecture 700 is shown to which the offline transaction method or offline transaction apparatus according to an embodiment of the present invention may be applied.
[0169] like Figure 7 As shown, system architecture 700 may include terminal devices 701, 702, 703, network 704 and server 705. Network 704 is used to provide a medium for communication links between terminal devices 701, 702, 703 and server 705. Network 704 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0170] Users can use terminal devices 701, 702, and 703 to interact with server 705 through network 704 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 701, 702, and 703, such as commercial bank applications, digital currency applications, digital currency wallet applications, instant messaging tools, social platform software, etc. (only as examples).
[0171] The terminal devices 701 , 702 , and 703 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0172] The server 705 may be a server that provides various services, such as a background management server (for example only) that provides support for offline transaction requests sent by users using terminal devices 701, 702, and 703. The background management server may authenticate the payer and obtain the payer's public key for the received offline transaction request and other data; generate a first encryption key factor, encrypt the first encryption key factor using the payer's public key to obtain first ciphertext data, and send the first ciphertext data to the payer; receive second ciphertext data sent by the payer, the second ciphertext data being obtained by the payer using the payee's public key to encrypt the second encryption key factor generated by the payer; decrypt the second ciphertext data to obtain the second encryption key factor, and generate a symmetric encryption key based on the first encryption key factor and the second encryption key factor; use the symmetric encryption key to decrypt the encrypted transaction data sent by the payer to obtain transaction data and confirm the transaction, send the transaction confirmation information to the payer, etc. for processing, and feed back the processing result (for example, transaction confirmation information - for example only) to the terminal device.
[0173] It should be noted that the offline transaction method provided in the embodiment of the present invention is generally executed by the server 705 , and accordingly, the offline transaction device is generally set in the server 705 .
[0174] It should be understood that Figure 7 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0175] Reference below Figure 8 , which shows a schematic diagram of the structure of a computer system 800 of a terminal device or server suitable for implementing an embodiment of the present invention. Figure 8 The terminal device or server shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0176] like Figure 8 As shown, the computer system 800 includes a central processing unit (CPU) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage part 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the system 800 are also stored. The CPU 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0177] The following components are connected to the I / O interface 805: an input section 806 including a keyboard, a mouse, etc.; an output section 807 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN card, a modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as needed. A removable medium 811, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 810 as needed, so that a computer program read therefrom is installed into the storage section 808 as needed.
[0178] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 809, and / or installed from the removable medium 811. When the computer program is executed by the central processing unit (CPU) 801, the above-mentioned functions defined in the system of the present invention are executed.
[0179] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0180] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0181] The units or modules involved in the embodiments of the present invention may be implemented by software or hardware. The units or modules described may also be set in a processor. For example, they may be described as: a processor includes a payer authentication module, a first ciphertext generation module, a second ciphertext receiving module, a symmetric key generation module, and a transaction processing confirmation module. The names of these units or modules do not, in some cases, constitute limitations on the units or modules themselves. For example, the payer authentication module may also be described as a "module for authenticating the payer and obtaining the payer's public key."
[0182] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently and not assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: authenticating the payer and obtaining the payer's public key; generating a first encryption key factor, encrypting the first encryption key factor using the payer's public key to obtain first ciphertext data, and sending the first ciphertext data to the payer; receiving second ciphertext data sent by the payer, the second ciphertext data is obtained by the payer using the payee's public key to encrypt the second encryption key factor generated by the payer; decrypting the second ciphertext data to obtain the second encryption key factor, and generating a symmetric encryption key based on the first encryption key factor and the second encryption key factor; using the symmetric encryption key to decrypt the encrypted transaction data sent by the payer to obtain transaction data and confirm the transaction, and sending the transaction confirmation information to the payer to complete the transaction, the encrypted transaction data is obtained by the payer using the symmetric encryption key to encrypt the transaction data.
[0183] According to the technical solution of the embodiment of the present invention, the payer is authenticated and the payer's public key is obtained; a first encryption key factor is generated, the first encryption key factor is encrypted using the payer's public key to obtain first ciphertext data, and the first ciphertext data is sent to the payer; second ciphertext data sent by the payer is received; the second ciphertext data is decrypted to obtain a second encryption key factor, and a symmetric encryption key is generated based on the first encryption key factor and the second encryption key factor; the encrypted transaction data sent by the payer is decrypted using the symmetric encryption key to obtain transaction data and confirm the transaction, and the transaction confirmation information is sent to the payer to complete the transaction. The technical solution, by the payee and the payer each generating a part of the encryption key factor and generating a symmetric encryption key, enables the two parties to jointly negotiate encryption keys, thereby improving the security and success rate of offline transactions.
[0184] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for offline trading, characterized in that: include: Authenticate the payer and obtain the payer's public key; Generate a first encryption key factor, encrypt the first encryption key factor using the payer's public key to obtain first ciphertext data, and send the first ciphertext data to the payer; Receiving second ciphertext data sent by the payer, where the second ciphertext data is obtained by encrypting a second encryption key factor generated by the payer using a payee's public key; decrypting the second ciphertext data to obtain the second encryption key factor, and generating a symmetric encryption key according to the first encryption key factor and the second encryption key factor; The encrypted transaction data sent by the payee is decrypted using the symmetric encryption key to obtain the transaction data and perform transaction confirmation, and the transaction confirmation information is sent to the payee to complete the transaction. The encrypted transaction data is obtained by the payee encrypting the transaction data using the symmetric encryption key.
2. The method according to claim 1, characterized in that Authentication of the payer and obtaining the payer's public key include: Authenticate the payer based on the payer's SM2 public-private key pair and obtain the payer's public key; Decrypting the second ciphertext data to obtain the second encryption key factor includes: Use the private key in the SM2 public-private key pair to decrypt the second ciphertext data to obtain the second encryption key factor.
3. The method according to claim 1, characterized in that The payer obtains the symmetric encryption key in the following manner: The payer obtains the first encryption key factor after decrypting the first ciphertext data, and generates the symmetric encryption key according to the first encryption key factor and the second encryption key factor.
4. The method according to claim 1 or 3, characterized in that: Generating a symmetric encryption key according to the first encryption key factor and the second encryption key factor comprises: The first encryption key factor and the second encryption key factor are sequentially concatenated and then hashed to generate a symmetric encryption key.
5. The method according to claim 4, characterized in that The symmetric encryption key is a 16-byte encryption key; If the result of the hash operation is 32 bytes, the first 16 bytes and the last 16 bytes of the hash operation result are subjected to a bitwise XOR operation to obtain the symmetric encryption key.
6. The method according to claim 1, characterized in that Transaction confirmation includes: Verify the transaction data and sign the verification result; The verification result and signature data are sequentially concatenated to generate transaction confirmation information.
7. A method for offline trading, characterized in that: include: Authenticate the recipient and obtain the recipient's public key; Receiving first ciphertext data sent by the payee, and decrypting the first ciphertext data to obtain a first encryption key factor, where the first ciphertext data is obtained by the payee encrypting the first encryption key factor generated by the payee using the payer's public key; Generate a second encryption key factor, encrypt the second encryption key factor using the payee's public key to obtain second ciphertext data, and send the second ciphertext data to the payee; generating a symmetric encryption key based on the first encryption key factor and the second encryption key factor; Encrypting the transaction data using the symmetric encryption key to obtain encrypted transaction data, and sending the encrypted transaction data to the payee, so that the payee uses the symmetric encryption key to decrypt the encrypted transaction data to obtain transaction data and confirm the transaction; Receive transaction confirmation information from the payee to complete the transaction.
8. The method according to claim 7, characterized in that Authentication of the payee and obtaining the payee's public key include: Authenticate the payee based on the payee's SM2 public-private key pair and obtain the payee's public key; Decrypting the first ciphertext data to obtain the first encryption key factor includes: Use the private key in one's own SM2 public-private key pair to decrypt the first ciphertext data to obtain the first encryption key factor.
9. A method for offline trading, characterized in that: include: The payee and payer perform identity authentication and obtain each other's public key; The payee generates a first encryption key factor, encrypts the first encryption key factor using the payer's public key to obtain first ciphertext data, and sends the first ciphertext data to the payer; The payer decrypts the first ciphertext data to obtain the first encryption key factor; Generate a second encryption key factor, encrypt the second encryption key factor using the payee's public key to obtain second ciphertext data, and send the second ciphertext data to the payee; generate a symmetric encryption key based on the first encryption key factor and the second encryption key factor; The payee decrypts the second ciphertext data to obtain the second encryption key factor, and generates the symmetric encryption key according to the first encryption key factor and the second encryption key factor; The payer encrypts the transaction data using the symmetric encryption key to obtain encrypted transaction data, and sends the encrypted transaction data to the payee; The payee uses the symmetric encryption key to decrypt the encrypted transaction data to obtain transaction data and perform transaction confirmation, and sends the transaction confirmation information to the payer to complete the transaction.
10. An off-line transaction device, characterized in that: The device is located at the payee, and comprises: The payer authentication module is used to authenticate the payer and obtain the payer's public key; A first ciphertext generation module, used to generate a first encryption key factor, encrypt the first encryption key factor using the payer's public key to obtain first ciphertext data, and send the first ciphertext data to the payer; A second ciphertext receiving module, used to receive second ciphertext data sent by the payer, where the second ciphertext data is obtained by encrypting a second encryption key factor generated by the payer using a payee's public key; a symmetric key generation module, configured to decrypt the second ciphertext data to obtain the second encryption key factor, and generate a symmetric encryption key according to the first encryption key factor and the second encryption key factor; The transaction processing confirmation module is used to use the symmetric encryption key to decrypt the encrypted transaction data sent by the payer to obtain transaction data and perform transaction confirmation, and send the transaction confirmation information to the payer to complete the transaction. The encrypted transaction data is obtained by the payer encrypting the transaction data using the symmetric encryption key.
11. An off-line transaction device, characterized in that: The device is located at the payer, and comprises: The payee authentication module is used to authenticate the payee and obtain the payee's public key; a first ciphertext decryption module, configured to receive first ciphertext data sent by the payee, and decrypt the first ciphertext data to obtain a first encryption key factor, wherein the first ciphertext data is obtained by the payee encrypting the first encryption key factor generated by the payee using the payer's public key; A second ciphertext generation module, used to generate a second encryption key factor, encrypt the second encryption key factor using the payee's public key to obtain second ciphertext data, and send the second ciphertext data to the payee; A key generation module, configured to generate a symmetric encryption key according to the first encryption key factor and the second encryption key factor; A transaction processing module, configured to encrypt the transaction data using the symmetric encryption key to obtain encrypted transaction data, and send the encrypted transaction data to the payee, so that the payee uses the symmetric encryption key to decrypt the encrypted transaction data to obtain transaction data and perform transaction confirmation; The transaction confirmation module is used to receive the transaction confirmation information sent by the payee to complete the transaction.
12. An electronic device for offline transactions, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 9.
13. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Security payment system and method for near field communication mobile terminal
CN107784499A
Credible transaction method and system based on digital currency
CN111539720A