A method, system and electronic device for generating business records
By using random numbers and key dispersion factors to generate business indexes in offline services, and performing encryption and MAC value verification, the problem of business record inconsistency is solved and the non-repudiation and non-tamperability of business records are achieved.
Patent Information
- Application Number
- CN202111623568.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-28
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2041-12-28
AI Technical Summary
In offline business, the inconsistency problem of business records leads to tampering or forgery during data transmission, resulting in the inability to synchronize the same business in the background.
The business index is generated through random number exchange and key dispersion factor between business parties, and encryption and MAC value verification are used to ensure the non-repudiation and non-tamperability of business data and timestamps.
It realizes the generation of irrevocable, non-tamperable and non-forgeable business records in offline business, ensuring the consistency and reliability of business records.
Smart Images

Figure CN114297682B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information security technology, and in particular to a method, system and electronic device for generating business records. Background Art
[0002] In offline business, after a business is completed, both parties usually generate business records for themselves, so as to send them to the backend for synchronization. This requires that the business records generated by both parties for the same business are the same. In the prior art, business records usually include business data, timestamps, business indexes, etc. Therefore, once one or more of the business data, timestamps, and business indexes are tampered with or forged during the data transmission process, the business records of both parties will be inconsistent, and the backend will be unable to synchronize the same business. Summary of the invention
[0003] To address the deficiencies of the prior art, a method, system and electronic device for generating business records are provided.
[0004] In a first aspect, the present invention provides a method for generating a business record, comprising the following steps:
[0005] Step 101: The first service party sends a service initialization instruction including service data and a timestamp to the second service party, and receives and saves a first random number sent by the second service party;
[0006] Step 102: the first business party generates and saves a second random number and a first key dispersion factor, generates and saves a current business index according to the second random number and the first random number, uses the first business party private key to sign the preset first business party public key certificate, the second random number and the first key dispersion factor to obtain a first signature result, and sends the first business party public key certificate, the second random number, the first key dispersion factor and the first signature result to the second business party;
[0007] Step 103: The first business party receives the second key dispersion factor, the current business credential ciphertext and the first MAC data sent by the second business party, and generates a first process key and a second process key according to a result obtained by performing an XOR operation on the first random number and the second random number and a result obtained by performing an XOR operation on the first key dispersion factor and the second key dispersion factor;
[0008] Step 104: The first service party uses the second process key to verify the first MAC data. When the verification is successful, execute step 105;
[0009] Step 105: The first business party uses the first process key to decrypt the received current business credential ciphertext to obtain the current business credential and verifies the current business credential. When the verification passes, a current business record is generated according to the timestamp, the business data in the current business credential and the current business index, the current business record is added to the business log of the first business party, and a business processing result is generated;
[0010] Step 106: The first business party uses the first process key to encrypt the business processing result to obtain a business processing result ciphertext, uses the second process key to calculate the business processing result ciphertext to obtain second MAC data, and sends the business processing result ciphertext and the second MAC data to the second business party.
[0011] The present invention further provides a method for generating a business record, comprising the following steps:
[0012] Step S1: When the second service party receives the service initialization instruction sent by the first service party, the second service party parses the service initialization instruction to obtain service data and a timestamp and saves them, generates a first random number and saves it, and sends the first random number to the first service party;
[0013] Step S2: the second business party receives and saves the first business party public key certificate, the second random number, the first key dispersion factor and the first signature result sent by the first business party, and verifies the first signature result using the first business party public key certificate. If the verification is successful, step S3 is executed; otherwise, an error message is returned to the first business party.
[0014] Step S3: the second service party generates and saves a current service index according to the first random number and the second random number;
[0015] Step S4: the second service party generates a second key dispersion factor, and generates a first process key and a second process key respectively according to a result obtained by performing an XOR operation on the first random number and the second random number and a result obtained by performing an XOR operation on the first key dispersion factor and the second key dispersion factor;
[0016] Step S5: the second business party obtains the first business party public key from the first business party public key certificate, organizes the current business index, the first business party public key and the business data to obtain the current business chain information, and signs the current business chain information to obtain the current business chain signature result;
[0017] Step S6: the second business party generates a current business credential according to the current business chain information and the current business chain signature result, uses the first process key to encrypt the current business credential to obtain the current business credential ciphertext, uses the second process key to calculate the second key dispersion factor and the current business credential ciphertext to obtain the first MAC data, and sends the second key dispersion factor, the current business credential ciphertext and the first MAC data to the first business party;
[0018] Step S7: The second service party receives the service processing result ciphertext and the second MAC data sent by the first service party, and uses the second process key and the second MAC data for verification. When the verification is successful, execute step S8;
[0019] Step S8: The second business party uses the first process key to decrypt the business processing result ciphertext to obtain the business processing result, and verifies the business processing result. When the verification passes, a current business record is generated according to the timestamp, the business data in the current business credential and the current business index, and the current business record is added to the business log of the second business party.
[0020] In a second aspect, the present invention provides a system for generating a business record, comprising: a first business party and a second business party;
[0021] The first business party is used to execute the method for generating business records in this application;
[0022] The second business party is used to execute the method for generating business records in this application.
[0023] In a third aspect, the present invention provides an electronic device, comprising: a processor and a memory;
[0024] Memory for storing computer programs;
[0025] The processor is used to run the computer program stored in the memory to implement the method of generating business records in the present application.
[0026] In a fourth aspect, the present invention provides a computer-readable storage medium for storing a computer program, which, when executed on a computer, enables the computer to execute the method for generating business records in the present application.
[0027] The present invention provides a method, system and electronic device for generating business records. Business parties generate business indexes respectively according to random numbers generated by the other party and random numbers generated by themselves. Business indexes are no longer transmitted during the entire business interaction process. Business data and timestamps are encrypted and MAC values are calculated during the transmission process, so that the business parties can verify each other, ensuring the non-repudiation and non-tamperability of business records. In offline business, the business parties can generate irrevocable, non-tamperable and non-forgeable business records. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 A flowchart of a method for generating a business record provided in Example 1 of the present invention;
[0029] Figure 2 A flowchart of a method for generating a business record provided in Example 2 of the present invention;
[0030] Figure 3 A flowchart of a method for generating a business record provided in Example 3 of the present invention;
[0031] Figure 4 A flowchart of a method for generating a business record provided in Embodiment 4 of the present invention;
[0032] Figure 5 A module block diagram of an electronic device provided in a specific implementation manner of the present invention. DETAILED DESCRIPTION
[0033] The present application proposes a method, system and electronic device for generating business records. The specific implementation methods of the present application are described in detail below in conjunction with the accompanying drawings. Examples of the embodiments are shown in the accompanying drawings. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be interpreted as limiting the present application.
[0034] It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as those generally understood by those skilled in the art to which this application belongs. It should also be understood that terms such as those defined in general dictionaries should be understood to have meanings consistent with those in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless specifically defined as here.
[0035] In order to make the objectives, technical solutions and advantages of the present invention more clear, the embodiments of the present invention are further described in detail below with reference to the accompanying drawings.
[0036] Example 1
[0037] Embodiment 1 of the present invention provides a method for generating a business record, such as Figure 1 As shown, the following steps are included:
[0038] Step 101: The first service party sends a service initialization instruction including service data and a timestamp to the second service party, and receives and saves a first random number sent by the second service party;
[0039] Step 102: The first business party generates and saves a second random number and a first key dispersion factor, generates and saves a current business index according to the second random number and the first random number, uses the first business party private key to sign the preset first business party public key certificate, the second random number and the first key dispersion factor to obtain a first signature result, and sends the first business party public key certificate, the second random number, the first key dispersion factor and the first signature result to the second business party;
[0040] Step 103: The first business party receives the second key dispersion factor, the current business credential ciphertext and the first MAC data sent by the second business party, and generates a first process key and a second process key according to a result obtained by performing an XOR operation on the first random number and the second random number and a result obtained by performing an XOR operation on the first key dispersion factor and the second key dispersion factor;
[0041] Step 104: The first service party verifies the first MAC data using the second process key. When the verification is successful, execute step 105;
[0042] Step 105: The first business party uses the first process key to decrypt the received current business credential ciphertext to obtain the current business credential and verify the current business credential. When the verification is successful, a current business record is generated according to the timestamp, the business data in the current business credential and the current business index, the current business record is added to the business log of the first business party, and a business processing result is generated.
[0043] Step 106: The first business party uses the first process key to encrypt the business processing result to obtain the business processing result ciphertext, uses the second process key to calculate the business processing result ciphertext to obtain the second MAC data, and sends the business processing result ciphertext and the second MAC data to the second business party.
[0044] Optionally, in this embodiment, step 101 further includes: the first business party receives and saves the second business party public key certificate sent by the second business party;
[0045] Before step 102, the first business party also includes: obtaining a preset trust authority certificate, verifying whether the second business party public key certificate is valid according to the trust authority certificate, if so, executing step 102, otherwise, returning an error message to the second business party.
[0046] Optionally, in this embodiment, the first business party uses the first process key to decrypt the received current business credential ciphertext to obtain the current business credential and verify the current business credential. Specifically, the first business party obtains the current business chain signature result from the current business credential, obtains the second business party public key from the saved second business party public key certificate, and uses the second business party public key to verify the current business chain signature result.
[0047] Optionally, in this embodiment, the current business index is generated and saved based on the second random number and the first random number, specifically: the first business party sequentially concatenates the second random number and the saved first random number or sequentially concatenates the saved first random number and the second random number to obtain the current business index and saves it.
[0048] Optionally, in this embodiment, generating the first process key and the second process key respectively according to the result obtained by performing an XOR operation on the first random number and the second random number and the result obtained by performing an XOR operation on the first key dispersion factor and the second key dispersion factor specifically includes:
[0049] Step B1: The first service party performs an XOR operation on the first key dispersion factor and the second key dispersion factor to obtain a third operation value, and performs an XOR operation on the first random number and the second random number to obtain a fourth operation value;
[0050] Step B2: the first business party obtains the first fixed data, and generates key distributed data according to the third operation value, the fourth operation value and the first fixed data;
[0051] Step B3: the first business party uses a third preset algorithm to perform a hash operation on the key dispersion data to obtain a hash value of the key dispersion data;
[0052] Step B4: the first business party obtains data on a first preset byte from the hash value of the key dispersion data to obtain a first process key, and obtains data on a second preset byte from the hash value of the key dispersion data to obtain a second process key.
[0053] Optionally, in this embodiment, the first business party uses the second process key to verify the received first MAC data, specifically: the first business party uses the second process key to perform an encryption operation on the second key dispersion factor and the current business credential ciphertext according to a second preset algorithm to obtain a first operation value, and determines whether the first operation value and the first MAC data are the same. If so, the verification is determined to be successful, otherwise, the verification is determined to be unsuccessful.
[0054] Optionally, in this embodiment, step 101 further includes: the first business party receives and saves the second business party hardware device name and the second business party hardware device identifier sent by the second business party;
[0055] The current business record is generated according to the timestamp, the business data in the current business voucher and the current business index. Specifically, the first business party generates the current business record according to the saved second business party hardware device name, the second business party hardware device identifier, the timestamp, the business data in the current business voucher and the current business index.
[0056] Embodiment 1 of the present invention further provides a method for generating a business record, comprising the following steps:
[0057] Step S1: When the second service party receives the service initialization instruction sent by the first service party, it parses the service initialization instruction to obtain service data and a timestamp and saves them, generates a first random number and saves it, and sends the first random number to the first service party;
[0058] Step S2: The second business party receives and saves the first business party public key certificate, the second random number, the first key dispersion factor, and the first signature result sent by the first business party, and verifies the first signature result using the first business party public key certificate. If the verification is successful, execute step S3; otherwise, return an error message to the first business party.
[0059] Step S3: The second service party generates and saves the current service index according to the first random number and the second random number;
[0060] Step S4: The second business party generates a second key dispersion factor, and generates a first process key and a second process key respectively according to a result obtained by performing an XOR operation on the first random number and the second random number and a result obtained by performing an XOR operation on the first key dispersion factor and the second key dispersion factor;
[0061] Step S5: the second business party obtains the first business party public key from the first business party public key certificate, organizes the current business index, the first business party public key and business data to obtain the current business chain information, and signs the current business chain information to obtain the current business chain signature result;
[0062] Step S6: The second business party generates a current business credential according to the current business chain information and the current business chain signature result, encrypts the current business credential using the first process key to obtain the current business credential ciphertext, calculates the second key dispersion factor and the current business credential ciphertext using the second process key to obtain the first MAC data, and sends the second key dispersion factor, the current business credential ciphertext and the first MAC data to the first business party;
[0063] Step S7: The second service party receives the service processing result ciphertext and the second MAC data sent by the first service party, and verifies the second MAC data using the second process key. When the verification is successful, execute step S8;
[0064] Step S8: The second business party uses the first process key to decrypt the ciphertext of the business processing result to obtain the business processing result, and verifies the business processing result. When the verification passes, the current business record is generated according to the timestamp, the business data in the current business credential and the current business index, and the current business record is added to the business log of the second business party.
[0065] Optionally, in this embodiment, before generating and saving the first random number, the second business party further includes: determining whether the business data is legal, and if so, generating and saving the first random number; otherwise, returning error information to the first business party.
[0066] Optionally, in this embodiment, the first signature result is verified using the public key certificate of the first business party, and the process also includes: the second business party obtains a preset trust authority certificate, and uses the trust authority certificate to verify the public key certificate of the first business party. If the verification passes, the first signature result is verified using the public key certificate of the first business party. Otherwise, an error message is returned to the first business party.
[0067] Optionally, in this embodiment, the first signature result is verified using the first business party public key certificate, which specifically includes: the second business party obtains the first business party public key from the first business party public key certificate, and uses the first business party public key to verify the first signature result.
[0068] Optionally, in this embodiment, step S3 is specifically: the second service party sequentially concatenates the saved first random number and the second random number or sequentially concatenates the saved second random number and the first random number to obtain the current service index and saves it.
[0069] Optionally, in this embodiment, generating the first process key and the second process key respectively according to the result obtained by performing an XOR operation on the first random number and the second random number and the result obtained by performing an XOR operation on the first key dispersion factor and the second key dispersion factor specifically includes:
[0070] Step A1: The second service party performs an XOR operation on the first key dispersion factor and the second key dispersion factor to obtain a third operation value, and performs an XOR operation on the first random number and the second random number to obtain a fourth operation value;
[0071] Step A2: the second business party obtains the first fixed data, and generates key distributed data according to the third operation value, the fourth operation value and the first fixed data;
[0072] Step A3: the second business party uses a third preset algorithm to perform a hash operation on the key dispersion data to obtain a hash value of the key dispersion data;
[0073] Step A4: the second service party obtains data on a first preset byte from the hash value of the key dispersion data to obtain a first process key, and obtains data on a second preset byte from the hash value of the key dispersion data to obtain a second process key.
[0074] Optionally, in this embodiment, the second process key and the second MAC data are used for verification, specifically: the second business party uses the second process key to perform an encryption operation on the business processing result ciphertext according to a second preset algorithm to obtain a second operation value, and determines whether the second operation value and the second MAC data are the same. If so, the verification is determined to be successful, otherwise, the verification is determined to be unsuccessful.
[0075] Optionally, in this embodiment, the business processing result is verified, specifically: the second business party determines whether the business processing result is a preset value, and if so, determines that the verification is passed, otherwise, determines that the verification is not passed.
[0076] Optionally, in this embodiment, step S2 further includes: the second business party receives and saves the first business party hardware device name and the first business party hardware device identifier sent by the first business party;
[0077] Generate the current business record according to the business data, timestamp and current business index in the current business credential, specifically: the second business party generates the current business record according to the first business party hardware device name, the first business party hardware device identifier, the business data, timestamp and current business index in the current business credential.
[0078] This embodiment provides a method for generating business records. Both business parties generate business indexes according to the random numbers generated by the other party and the random numbers generated by themselves. The business index is no longer transmitted during the entire business interaction process. The business data and timestamp are encrypted and the MAC value is calculated during the transmission process, so that the two business parties can verify each other, ensuring the non-repudiation and non-tamperability of the business records, and realizing that in offline business, both business parties can generate irrevocable, non-tamperable, and non-forgeable business records.
[0079] Example 2
[0080] Embodiment 2 of the present invention provides a method for generating a business record, such as Figure 2 As shown, the following steps are included:
[0081] Step 201: The first service party sends a service initialization instruction including service data and a timestamp to the second service party;
[0082] Optionally, in this embodiment, the first business party is the payee and the second business party is the payee;
[0083] Optionally, in this embodiment, the first business party is specifically a device with a payment function, and the second business party is specifically a card with a payment function;
[0084] Optionally, the first service party may also be a device with a payment function, and the second service party may also be a device with a payment collection function;
[0085] For example, the first service provider sends a service initialization instruction 804000000D 00000000010020210609151154 containing service data 000000000100 and timestamp 20210609151154 to the second service provider;
[0086] Step 202: The second service party parses the received service initialization instruction to obtain service data and timestamp and saves them, and determines whether the service data is legal. If so, step 203 is executed; otherwise, an error message is returned to the first service party.
[0087] Optionally, in this embodiment, the business data is specifically the transaction amount;
[0088] Further optionally, determining whether the business data is legal specifically includes: the second business party determining whether the transaction amount in the business data exceeds the card balance;
[0089] For example: the second business party parses the received business initialization instruction 804000000D00000000010020210609151154 to obtain the business data 000000000100 and the timestamp 20210609151154 and saves them, and determines whether the business data 000000000100 exceeds the card balance 000000001000. If yes, execute step 203; otherwise, return an error message to the first business party;
[0090] In this embodiment, the business data 000000000100 does not exceed the card balance 000000001000, therefore, step 203 is executed;
[0091] Step 203: The second business party generates and saves a first random number, obtains a preset second business party public key certificate, a second business party hardware device name, and a second business party hardware device identifier, and sends business data, a timestamp, a first random number, a second business party public key certificate, a second business party hardware device name, and a second business party hardware device identifier to the first business party;
[0092] Optionally, in this embodiment, the length of the first random number is 8 bytes;
[0093] For example: the second business party generates a first random number A52C0BB093908273 and saves it, obtains the preset second business party public key certificate,The second business party's hardware device name is E4B8ADE8A18CE7A1ACE4BBB6E992B1E58C85 and the second business party's hardware device identifier is 0041020454020016, and the business data 000000000100, the timestamp 20210609151154, the first random number A52C0BB093908273,The second business party's public key certificate, the second business party's hardware device name E4B8ADE8A18CE7A1ACE4BBB6E992B1E58C85, and the second business party's hardware device identifier 0041020454020016;
[0094] Step 204: the first business party receives the business data, timestamp, first random number, second business party public key certificate, second business party hardware device name and second business party hardware device identifier sent by the second business party and saves them, obtains the preset trust authority certificate, verifies whether the second business party public key certificate is valid according to the trust authority certificate, if yes, executes step 205, otherwise, returns an error message to the second business party;
[0095] Optionally, in this embodiment, the trusted authority certificate is a CA (Certification Authority) certificate;
[0096]
[0097] In this embodiment, it is verified that the second service party's public key certificate is valid, therefore, step 205 is executed;
[0098] Step 205: The first service party generates a second random number, generates a current service index according to the second random number and the saved first random number, and saves the index;
[0099] Optionally, in this embodiment, the current business index is generated and saved according to the second random number and the saved first random number, specifically: the first business party sequentially concatenates the second random number and the saved first random number or sequentially concatenates the saved first random number and the second random number to obtain the current business index and saves it;
[0100] Preferably, in this embodiment, the length of the second random number is 8 bytes;
[0101] For example, the first business party generates a second random number 588C8E820E80BD94, concatenates the saved first random number A52C0BB093908273 and the second random number 588C8E820E80BD94 in sequence to obtain the current business index A52C0BB093908273588C8E820E80BD94 and saves it;
[0102] Step 206: The first business party generates a first key dispersion factor, obtains a preset first business party public key certificate and a first business party private key, uses the first business party private key to sign the first business party public key certificate, the second random number, and the first key dispersion factor to obtain a first signature result, and sends the first business party public key certificate, the second random number, the first key dispersion factor, and the first signature result to the second business party;
[0103] Optionally, in this embodiment, the first key dispersion factor is specifically a random number with a length of 16 bytes generated by the first service party;
[0104] Optionally, in this embodiment, the first business party public key certificate, the second random number and the first key dispersion factor are signed using the first business party private key to obtain a first signature result, specifically: the first business party signs the first business party public key certificate, the second random number and the first key dispersion factor using the first business party private key according to the first preset algorithm to obtain the first signature result;
[0105] Specifically, in this embodiment, the first preset algorithm is the SM2 algorithm;
[0106]
[0107] Step 207: The second business party receives and saves the first business party public key certificate, the second random number, the first key dispersion factor, and the first signature result sent by the first business party, and verifies the first business party public key certificate and the first signature result respectively. If both are verified successfully, execute step 208; otherwise, return an error message to the first business party.
[0108] Optionally, in this embodiment, the first business party public key certificate and the first signature result are verified respectively, specifically including: the second business party obtains a preset trust agency certificate, verifies the first business party public key certificate using the trust agency certificate, obtains the first business party public key from the first business party public key certificate, and verifies the first signature result using the first business party public key;
[0109]
[0110] In this embodiment, the second business party verifies the first business party's public key certificate and the first signature result, and the verification results are both verified to be passed, so step 208 is executed;
[0111] Step 208: The second service party generates and saves the current service index according to the saved first random number and the second random number;
[0112] Optionally, in this embodiment, step 208 is specifically: the second service party sequentially concatenates the saved first random number and the second random number or sequentially concatenates the saved second random number and the first random number to obtain the current service index and saves it;
[0113] For example, the second business party sequentially concatenates the saved first random number A52C0BB093908273 and the second random number 588C8E820E80BD94 to obtain the current business index A52C0BB093908273588C8E820E80BD94 and saves it;
[0114] Step 209: The second business party generates a second key dispersion factor, and generates a first process key and a second process key respectively according to a result obtained by performing an XOR operation on the first random number and the second random number and a result obtained by performing an XOR operation on the first key dispersion factor and the second key dispersion factor;
[0115] Preferably, in this embodiment, the second key dispersion factor is specifically a random number with a length of 16 bytes generated by the second business party;
[0116] Optionally, in this embodiment, the first process key is specifically: an Enc key;
[0117] Optionally, in this embodiment, the second process key is specifically: a Mac key (message authentication code key);
[0118] Optionally, in this embodiment, the first process key and the second process key are generated respectively according to the result obtained by performing an XOR operation on the first random number and the second random number and the result obtained by performing an XOR operation on the first key dispersion factor and the second key dispersion factor, specifically:
[0119] Step A1: The second service party performs an XOR operation on the first key dispersion factor and the second key dispersion factor to obtain a third operation value, and performs an XOR operation on the first random number and the second random number to obtain a fourth operation value;
[0120] Step A2: the second business party obtains the first fixed data, and generates key distributed data according to the third operation value, the fourth operation value and the first fixed data;
[0121] Step A3: the second business party uses a third preset algorithm to perform a hash operation on the key dispersion data to obtain a hash value of the key dispersion data;
[0122] Optionally, in this embodiment, the third preset algorithm is specifically an SM3 algorithm;
[0123] Step A4: the second service party obtains the data on the first 10 bytes from the hash value of the key dispersion data to obtain the first process key, and obtains the data on the last 10 bytes from the hash value of the key dispersion data to obtain the second process key;
[0124] For example, the second business party generates a second key dispersion factor B43EBDEC477CE89BDE2ECD80D1D9305A, and generates a first process key E1D1D482DD7431F21C69BA3CDC8D6918 and a second process key 144D5BCF36A8AE1963069BA9F7E28FA3 according to the first key dispersion factor B43EBDEC477CE89BDE2ECD80D1D9305A, the second key dispersion factor B43EBDEC477CE89BDE2ECD80D1D9305A, the first random number A52C0BB093908273 and the second random number 588C8E820E80BD94;
[0125] Step 210: The second business party obtains the first business party public key from the saved first business party public key certificate, organizes the current business index, the first business party public key and the saved business data to obtain the current business chain information, and uses the preset second business party private key to sign the current business chain information to obtain the current business chain signature result;
[0126] Optionally, in this embodiment, the current business chain information includes: current business sub-chain information and coin string information;
[0127]
[0128] Step 211: The second service party generates a current service credential according to the current service chain information and the current service chain signature result, and encrypts the current service credential using the first process key to obtain a current service credential ciphertext;
[0129]
[0130] Step 212: The second business party uses the second process key to calculate the second key dispersion factor and the current business credential ciphertext according to the second preset algorithm to obtain the first MAC (message authentication code) data, and sends the second key dispersion factor, the current business credential ciphertext and the first MAC data to the first business party;
[0131] Optionally, in this embodiment, the second preset algorithm is specifically an SM4 algorithm;
[0132]
[0133] Step 213: The first business party receives the second key dispersion factor, the current business credential ciphertext and the first MAC data sent by the second business party, and generates a first process key and a second process key according to a result obtained by performing an XOR operation on the first random number and the second random number and a result obtained by performing an XOR operation on the first key dispersion factor and the second key dispersion factor;
[0134] Optionally, in this embodiment, generating the first process key and the second process key respectively according to the result obtained by performing an XOR operation on the first random number and the second random number and the result obtained by performing an XOR operation on the first key dispersion factor and the second key dispersion factor specifically includes:
[0135] Step B1: The first service party performs an XOR operation on the first key dispersion factor and the second key dispersion factor to obtain a third operation value, and performs an XOR operation on the first random number and the second random number to obtain a fourth operation value;
[0136] Step B2: the first business party obtains the first fixed data, and generates key distributed data according to the third operation value, the fourth operation value and the first fixed data;
[0137] Step B3: the first business party uses a third preset algorithm to perform a hash operation on the key dispersion data to obtain a hash value of the key dispersion data;
[0138] Optionally, in this embodiment, the third preset algorithm is specifically an SM3 algorithm;
[0139] Step B4: the first business party obtains the data on the first 10 bytes from the hash value of the key dispersion data to obtain the first process key, and obtains the data on the last 10 bytes from the hash value of the key dispersion data to obtain the second process key;
[0140] Step 214: The first service party verifies the received first MAC data using the second process key to determine whether the verification is successful. If so, execute step 215; otherwise, return an error message to the second service party.
[0141] Optionally, in this embodiment, the first business party uses the generated second process key to verify the received first MAC data to determine whether the verification is successful, specifically: the first business party uses the second process key to perform an encryption operation on the second key dispersion factor and the current business credential ciphertext according to the second preset algorithm to obtain a first operation value, and determines whether the first operation value and the first MAC data are the same. If so, it is determined that the verification is successful, otherwise, it is determined that the verification is unsuccessful;
[0142] Step 215: The first business party uses the first process key to decrypt the received current business credential ciphertext to obtain the current business credential, and uses the saved second business party public key certificate to verify the current business credential to determine whether the verification is successful. If so, execute step 216; otherwise, return an error message to the second business party.
[0143] Optionally, in this embodiment, the current business credential is verified using the saved public key certificate of the second business party, specifically: the first business party obtains the current business chain signature result from the current business credential, obtains the second business party public key from the saved public key certificate of the second business party, and uses the second business party public key to verify the current business chain signature result;
[0144] Step 216: The first business party generates a current business record according to the saved second business party hardware device name, the second business party hardware device identifier, the timestamp, the business data in the current business voucher, and the current business index, adds the current business record to the business log of the first business party, and generates a business processing result;
[0145] For example: the business processing result is: TranResult = 1;
[0146] Step 217: The first service party uses the first process key to perform an encryption operation on the service processing result to obtain a ciphertext of the service processing result, uses the second process key to perform an encryption operation on the ciphertext of the service processing result according to a second preset algorithm to obtain second MAC data, and sends the ciphertext of the service processing result and the second MAC data to the second service party;
[0147] For example: The ciphertext of the business processing result is: 01;
[0148] The second MAC data is specifically: 0E5EF0DC;
[0149] Step 218: The second business party receives the ciphertext of the business processing result and the second MAC data sent by the first business party, and uses the second process key to verify the received second MAC data to determine whether the verification is successful. If so, execute step 219; otherwise, return an error message to the first business party.
[0150] Optionally, in this embodiment, the received second MAC data is verified using the second process key to determine whether the verification is successful. Specifically, the second service party uses the second process key to perform an encryption operation on the service processing result ciphertext according to the second preset algorithm to obtain a second operation value, and determines whether the second operation value and the second MAC data are the same. If so, it is determined that the verification is successful, otherwise, it is determined that the verification is unsuccessful.
[0151] Step 219: The second business party uses the first process key to decrypt the business processing result ciphertext to obtain the business processing result, and verifies the business processing result to determine whether the verification is successful. If so, execute step 220; otherwise, return an error message to the first business party.
[0152] Optionally, in this embodiment, the second business party verifies the business processing result, specifically: the second business party determines whether the business processing result is a preset value, if yes, determines that the verification is passed, otherwise, determines that the verification is not passed;
[0153] Specifically, in this embodiment, the preset value is 1;
[0154] Step 220: The second business party generates a current business record according to the saved first business party hardware device name, first business party hardware device identifier, business data in the current business credential, timestamp and current business index, and adds the current business record to the business log of the second business party.
[0155] This embodiment provides a method for generating business records. Both business parties generate business indexes according to the random numbers generated by the other party and the random numbers generated by themselves. The business index is no longer transmitted during the entire business interaction process. The business data and timestamp are encrypted and the MAC value is calculated during the transmission process, so that the two business parties can verify each other, ensuring the non-repudiation and non-tamperability of the business records, and realizing that in offline business, both business parties can generate irrevocable, non-tamperable, and non-forgeable business records.
[0156] Example 3
[0157] Embodiment 3 of the present invention provides a method for generating a business record, such as Figure 3 As shown, the following steps are included:
[0158] Step 301: The first service party sends a service initialization instruction including service data and a timestamp to the second service party;
[0159] Optionally, in this embodiment, the first business party is specifically a payer, and the second business party is specifically a payee;
[0160] Step 302: The first business party receives the business data, timestamp, first random number, second business party public key certificate, second business party hardware device name and second business party hardware device identifier sent by the second business party and saves them, obtains the preset trust authority certificate, verifies whether the second business party public key certificate is valid according to the trust authority certificate, if so, executes step 303, otherwise, returns an error message to the second business party;
[0161] Step 303: The first service party generates a second random number, generates a current service index according to the second random number and the saved first random number, and saves the index;
[0162] Optionally, in this embodiment, the current business index is generated and saved according to the second random number and the saved first random number, specifically: the first business party sequentially concatenates the second random number and the saved first random number or sequentially concatenates the saved first random number and the second random number to obtain the current business index and saves it;
[0163] Preferably, in this embodiment, the length of the second random number is 8 bytes;
[0164] Step 304: The first business party generates a first key dispersion factor, obtains a preset first business party public key certificate and a first business party private key, uses the first business party private key to sign the first business party public key certificate, the second random number, and the first key dispersion factor to obtain a first signature result, and sends the first business party public key certificate, the second random number, the first key dispersion factor, and the first signature result to the second business party;
[0165] Optionally, in this embodiment, the first business party public key certificate, the second random number and the first key dispersion factor are signed using the first business party private key to obtain a first signature result, specifically: the first business party signs the first business party public key certificate, the second random number and the first key dispersion factor using the first business party private key according to the first preset algorithm to obtain the first signature result;
[0166] Specifically, in this embodiment, the first preset algorithm is the SM2 algorithm;
[0167] Step 305: The first business party receives the second key dispersion factor, the current business credential ciphertext and the first MAC data sent by the second business party, and generates a first process key and a second process key according to a result obtained by performing an XOR operation on the first random number and the second random number and a result obtained by performing an XOR operation on the first key dispersion factor and the second key dispersion factor;
[0168] Optionally, in this embodiment, generating the first process key and the second process key respectively according to the result obtained by performing an XOR operation on the first random number and the second random number and the result obtained by performing an XOR operation on the first key dispersion factor and the second key dispersion factor specifically includes:
[0169] Step B1: The first service party performs an XOR operation on the first key dispersion factor and the second key dispersion factor to obtain a third operation value, and performs an XOR operation on the first random number and the second random number to obtain a fourth operation value;
[0170] Step B2: the first business party obtains the first fixed data, and generates key distributed data according to the third operation value, the fourth operation value and the first fixed data;
[0171] Step B3: the first business party uses a third preset algorithm to perform a hash operation on the key dispersion data to obtain a hash value of the key dispersion data;
[0172] Optionally, in this embodiment, the third preset algorithm is specifically an SM3 algorithm;
[0173] Step B4: the first business party obtains the data on the first 10 bytes from the hash value of the key dispersion data to obtain the first process key, and obtains the data on the last 10 bytes from the hash value of the key dispersion data to obtain the second process key;
[0174] Step 306: The first service party verifies the received first MAC data using the second process key to determine whether the verification is successful. If so, execute step 307; otherwise, return an error message to the second service party.
[0175] Optionally, in this embodiment, the first business party uses the generated second process key to verify the received first MAC data to determine whether the verification is successful, specifically: the first business party uses the second process key to perform an encryption operation on the second key dispersion factor and the current business credential ciphertext according to the second preset algorithm to obtain a first operation value, and determines whether the first operation value and the first MAC data are the same. If so, it is determined that the verification is successful, otherwise, it is determined that the verification is unsuccessful;
[0176] Step 307: The first business party uses the first process key to decrypt the received current business credential ciphertext to obtain the current business credential, and uses the saved second business party public key certificate to verify the current business credential to determine whether the verification is successful. If so, execute step 308; otherwise, return an error message to the second business party.
[0177] Optionally, in this embodiment, the current business credential is verified using the saved public key certificate of the second business party, specifically: the first business party obtains the current business chain signature result from the current business credential, obtains the second business party public key from the saved public key certificate of the second business party, and uses the second business party public key to verify the current business chain signature result;
[0178] Step 308: The first business party generates a current business record according to the saved second business party hardware device name, the second business party hardware device identifier, the timestamp, the business data in the current business voucher, and the current business index, adds the current business record to the business log of the first business party, and generates a business processing result;
[0179] Step 309: The first business party uses the first process key to perform an encryption operation on the business processing result to obtain a ciphertext of the business processing result, uses the second process key to perform an encryption operation on the ciphertext of the business processing result according to a second preset algorithm to obtain second MAC data, and sends the ciphertext of the business processing result and the second MAC data to the second business party.
[0180] This embodiment provides a method for generating business records. Both business parties generate business indexes according to the random numbers generated by the other party and the random numbers generated by themselves. The business index is no longer transmitted during the entire business interaction process. The business data and timestamp are encrypted and the MAC value is calculated during the transmission process, so that the two business parties can verify each other, ensuring the non-repudiation and non-tamperability of the business records, and realizing that in offline business, both business parties can generate irrevocable, non-tamperable, and non-forgeable business records.
[0181] Example 4
[0182] Embodiment 4 of the present invention provides a method for generating a business record, such as Figure 4 As shown, the following steps are included:
[0183] Step 401: When the second service party receives the service initialization instruction sent by the first service party, it parses the service initialization instruction to obtain service data and timestamp and saves them, and determines whether the service data is legal. If so, it executes step 402; otherwise, it returns an error message to the first service party.
[0184] Optionally, in this embodiment, the business data is specifically the transaction amount;
[0185] Further optionally, determining whether the business data is legal specifically includes: the second business party determining whether the transaction amount in the business data exceeds the card balance;
[0186] Step 402: The second business party generates and saves a first random number, obtains a preset second business party public key certificate, a second business party hardware device name, and a second business party hardware device identifier, and sends business data, a timestamp, a first random number, a second business party public key certificate, a second business party hardware device name, and a second business party hardware device identifier to the first business party;
[0187] Step 403: The second business party receives and saves the first business party public key certificate, the second random number, the first key dispersion factor, and the first signature result sent by the first business party, and verifies the first business party public key certificate and the first signature result respectively. If both are verified successfully, step 404 is executed; otherwise, an error message is returned to the first business party.
[0188] Optionally, in this embodiment, the first business party public key certificate and the first signature result are verified respectively, specifically including: the second business party obtains a preset trust agency certificate, verifies the first business party public key certificate using the trust agency certificate, obtains the first business party public key from the first business party public key certificate, and verifies the first signature result using the first business party public key;
[0189] Step 404: The second service party generates and saves the current service index according to the saved first random number and the second random number;
[0190] Optionally, in this embodiment, step 404 is specifically: the second service party sequentially concatenates the saved first random number and the second random number or sequentially concatenates the saved second random number and the first random number to obtain the current service index and saves it;
[0191] Step 405: The second business party generates a second key dispersion factor, and generates a first process key and a second process key respectively according to a result obtained by performing an XOR operation on the first random number and the second random number and a result obtained by performing an XOR operation on the first key dispersion factor and the second key dispersion factor;
[0192] Preferably, in this embodiment, the second key dispersion factor is specifically a random number with a length of 16 bytes generated by the second business party;
[0193] Optionally, in this embodiment, the first process key and the second process key are generated respectively according to the result obtained by performing an XOR operation on the first random number and the second random number and the result obtained by performing an XOR operation on the first key dispersion factor and the second key dispersion factor, specifically:
[0194] Step A1: The second service party performs an XOR operation on the first key dispersion factor and the second key dispersion factor to obtain a third operation value, and performs an XOR operation on the first random number and the second random number to obtain a fourth operation value;
[0195] Step A2: the second business party obtains the first fixed data, and generates key distributed data according to the third operation value, the fourth operation value and the first fixed data;
[0196] Step A3: the second business party uses a third preset algorithm to perform a hash operation on the key dispersion data to obtain a hash value of the key dispersion data;
[0197] Optionally, in this embodiment, the third preset algorithm is specifically an SM3 algorithm;
[0198] Step A4: the second service party obtains the data on the first 10 bytes from the hash value of the key dispersion data to obtain the first process key, and obtains the data on the last 10 bytes from the hash value of the key dispersion data to obtain the second process key;
[0199] Step 406: The second business party obtains the first business party public key from the saved first business party public key certificate, organizes the current business index, the first business party public key and the saved business data to obtain the current business chain information, and uses the preset second business party private key to sign the current business chain information to obtain the current business chain signature result;
[0200] Optionally, in this embodiment, the current business chain information includes: current business sub-chain information and coin string information;
[0201] Step 407: The second service party generates a current service credential according to the current service chain information and the current service chain signature result, and encrypts the current service credential using the first process key to obtain a current service credential ciphertext;
[0202] Step 408: The second business party uses the second process key to calculate the second key dispersion factor and the current business credential ciphertext according to the second preset algorithm to obtain the first MAC data, and sends the second key dispersion factor, the current business credential ciphertext and the first MAC data to the first business party;
[0203] Optionally, in this embodiment, the second preset algorithm is specifically an SM4 algorithm;
[0204] Step 409: The second business party receives the ciphertext of the business processing result and the second MAC data sent by the first business party, verifies the received second MAC data using the second process key, and determines whether the verification is successful. If so, execute step 410; otherwise, return an error message to the first business party.
[0205] Optionally, in this embodiment, the received second MAC data is verified using the second process key to determine whether the verification is successful. Specifically, the second service party uses the second process key to perform an encryption operation on the service processing result ciphertext according to the second preset algorithm to obtain a second operation value, and determines whether the second operation value and the second MAC data are the same. If so, it is determined that the verification is successful, otherwise, it is determined that the verification is unsuccessful.
[0206] Step 410: The second business party uses the first process key to decrypt the business processing result ciphertext to obtain the business processing result, and verifies the business processing result to determine whether the verification is successful. If so, execute step 411; otherwise, return an error message to the first business party.
[0207] Optionally, in this embodiment, the second business party verifies the business processing result, specifically: the second business party determines whether the business processing result is a preset value, if yes, determines that the verification is passed, otherwise, determines that the verification is not passed;
[0208] Specifically, in this embodiment, the preset value is 1;
[0209] Step 411: The second business party generates a current business record according to the saved first business party hardware device name, first business party hardware device identifier, business data in the current business credential, timestamp and current business index, and adds the current business record to the business log of the second business party.
[0210] This embodiment provides a method for generating business records. Both business parties generate business indexes according to the random numbers generated by the other party and the random numbers generated by themselves. The business index is no longer transmitted during the entire business interaction process. The business data and timestamp are encrypted and the MAC value is calculated during the transmission process, so that the two business parties can verify each other, ensuring the non-repudiation and non-tamperability of the business records, and realizing that in offline business, both business parties can generate irrevocable, non-tamperable, and non-forgeable business records.
[0211] The present invention also provides a system for generating business records, comprising: a first business party and a second business party;
[0212] A first business party, used to execute the method for generating business records in this application;
[0213] The second business party is used to execute the method for generating business records in this application.
[0214] The application also includes a process in which the first business party pre-configures a certificate for the second business party, including the following steps:
[0215] Step K1: The first business party sends the third business party's public key certificate signed by the third business party's root CA to the second business party;
[0216] Step K2: The second business party receives and saves the third business party public key certificate sent by the first business party, and sends a successful receipt response to the first business party;
[0217] Step K3: The first business party sends the first business party's public key certificate signed by the third business party's private key to the second business party;
[0218] Step K4: the second business party receives and saves the second business party public key certificate sent by the first business party, and sends a successful receipt response to the first business party;
[0219] Step K5: The first business party sends the third business party's expression public key certificate signed by the third business party's root CA to the second business party;
[0220] Step K6: The second business party receives and saves the third business party expression public key certificate sent by the first business party, and sends a successful receipt response to the first business party;
[0221] Step K7: the first business party sends to the second business party the first business party expression public key certificate obtained by signing the first business party expression public key using the private key corresponding to the third business party expression public key certificate;
[0222] Step K8: The second business party receives and saves the first business party expression public key certificate sent by the first business party.
[0223] The application also includes an online business process between the first business party, the second business party and the third business party, including the following steps:
[0224] Step R1: The first service party sends an online service initialization instruction including service data and a hardware device identifier of the first service party to the second service party;
[0225] Step R2: The second service party receives and parses the online service initialization instruction sent by the first service party to obtain service data and the hardware device identifier of the first service party, and sends the service counter, the hardware device identifier of the first service party, the saved hardware device identifier of the second service party and the service index to the first service party;
[0226] Step R3: The first service provider sends a hardware device initialization instruction including a service index to the second service provider;
[0227] Step R4: the second business party receives the hardware device initialization instruction sent by the first business party, and sends the business credential and business record to the first business party;
[0228] Step R5: The first business party receives the business voucher and business record sent by the second business party, and determines whether the business voucher is correct. If so, step R6 is executed; otherwise, an error is reported to the second business party.
[0229] Step R6: The first business party searches for the saved personal public key according to the hardware device identifier of the first business party or the hardware device identifier of the second business party, calculates the business face value according to the business voucher, and sends the personal public key, business face value, business index and the first business party identifier to the third business party;
[0230] Step R7: the third business party generates first data according to the saved version number, prefix number and the third business party reserved data as well as the received business face value, business index and the first business party identifier;
[0231] Step R8: The third business party signs the first data using the private key corresponding to the third business party expression signature certificate to obtain a second signature result, generates second data according to the first data and the second signature result, and sends the second data to the first business party;
[0232] Step R9: The first business party generates third data according to the saved public key of the second business party, the retained data of the first business party, and the received second data, signs the third data using the saved private key corresponding to the expression signature certificate of the first business party to obtain a third signature result, generates a coin string according to the third data and the third signature result, and sends a business completion instruction including a business index and a coin string to the second business party;
[0233] Step R10: The second business party parses the received coin string to obtain the third data and the third signature result, and verifies the third signature result using the saved first business party expression public key certificate. If the verification is successful, execute step R11; otherwise, report an error to the first business party;
[0234] Step R11: The second business party parses the third data to obtain the second data, the second business party public key and the first business party reserved data, parses the second data to obtain the first data and the second signature result, and verifies the second signature result using the saved third business party expression public key certificate. If the verification is successful, execute step R12; otherwise, report an error to the first business party;
[0235] Step R12: The second business party determines whether the second business party public key is correct. If so, it updates the business voucher according to the updated coin string and the business face value in the first data. Otherwise, it reports an error to the first business party.
[0236] The present invention also provides an electronic device, such as Figure 5 As shown, it shows a schematic diagram of the structure of an electronic device (such as the first service party or the second service party in Embodiment 1) 500 suitable for implementing various embodiments of the present application. The devices in the embodiments of the present application may include but are not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 5 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0237] like Figure 5As shown, the device 500 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage device 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the electronic device 500 are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0238] Typically, the following devices may be connected to the I / O interface 505: input devices 506 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; output devices 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 508 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 509. The communication devices 509 may allow the device 500 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 5 The device 500 is shown with various devices, but it should be understood that it is not required to implement or have all the devices shown. More or fewer devices may be implemented or have instead.
[0239] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes 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 device 509, or installed from the storage device 508, or installed from the ROM 502. When the computer program is executed by the processing device 501, the above-mentioned functions defined in the method of the embodiment of the present application are executed.
[0240] It should be noted that the computer-readable medium mentioned above in the present application 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 application, 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 application, 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. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, 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 suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0241] The computer-readable medium may be included in the device, or may exist independently without being incorporated into the device.
[0242] The computer-readable medium carries one or more programs. When the one or more programs are executed by the device, the device can execute the method for generating business records in the above embodiment.
[0243] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0244] 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 application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the 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 square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square 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 square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / 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.
[0245] The units involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of a unit does not, in some cases, constitute a limitation on the unit itself.
[0246] The electronic device provided in the present application is applicable to any embodiment of the method for generating business records in the present application, which will not be described in detail here.
[0247] The present invention provides an electronic device, in which two business parties generate business indexes respectively according to the random numbers generated by the other party and the random numbers generated by themselves, and the business index is no longer transmitted during the entire business interaction process. During the transmission process, the business data and timestamp are encrypted and the MAC value is calculated, so that the two business parties can verify each other, ensuring the non-repudiation and non-tamperability of the business records, and realizing that in offline business, the two business parties can generate irrevocable, non-tamperable and non-forgeable business records.
[0248] The present application provides a computer-readable storage medium, which stores computer instructions, and the computer instructions enable a computer to execute the method for generating business records shown in the above embodiment.
[0249] The computer-readable storage medium provided in the present application is applicable to any embodiment of the above-mentioned method for generating business records, which will not be described in detail here.
[0250] The present application provides a computer program product. When the computer program product is run on a computer, the computer is enabled to execute the method for generating business records in the present application.
[0251] The above is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A method for generating a business record, characterized in that: The method comprises the following steps: Step 101: A first service party sends a service initialization instruction including service data and a timestamp to a second service party, and receives and saves a first random number sent by the second service party; Step 102: the first business party generates and saves a second random number and a first key dispersion factor, generates and saves a current business index according to the second random number and the first random number, uses the first business party private key to sign the preset first business party public key certificate, the second random number and the first key dispersion factor to obtain a first signature result, and sends the first business party public key certificate, the second random number, the first key dispersion factor and the first signature result to the second business party; Step 103: The first business party receives the second key dispersion factor, the current business credential ciphertext and the first MAC data sent by the second business party, and generates a first process key and a second process key according to a result obtained by performing an XOR operation on the first random number and the second random number and a result obtained by performing an XOR operation on the first key dispersion factor and the second key dispersion factor; Step 104: The first service party verifies the first MAC data using the second process key. When the verification is successful, execute step 105; Step 105: The first business party uses the first process key to decrypt the received current business credential ciphertext to obtain the current business credential and verifies the current business credential. When the verification passes, a current business record is generated according to the timestamp, the business data in the current business credential and the current business index, the current business record is added to the business log of the first business party, and a business processing result is generated; Step 106: The first business party uses the first process key to encrypt the business processing result to obtain a business processing result ciphertext, uses the second process key to calculate the business processing result ciphertext to obtain second MAC data, and sends the business processing result ciphertext and the second MAC data to the second business party.
2. The method according to claim 1, characterized in that The step 101 further includes: the first business party receives and saves the second business party public key certificate sent by the second business party; Before step 102, the method also includes: the first business party obtains a preset trust authority certificate, verifies whether the second business party public key certificate is valid according to the trust authority certificate, and if so, executes step 102; otherwise, returns an error message to the second business party.
3. The method according to claim 2, characterized in that The first business party uses the first process key to decrypt the received current business credential ciphertext to obtain the current business credential and verify the current business credential. Specifically, the first business party obtains the current business chain signature result from the current business credential, obtains the second business party public key from the saved second business party public key certificate, and uses the second business party public key to verify the current business chain signature result.
4. The method according to claim 1, characterized in that The generating and saving the current business index according to the second random number and the first random number is specifically: the first business party sequentially concatenates the second random number and the saved first random number or sequentially concatenates the saved first random number and the second random number to obtain the current business index and save it.
5. The method according to claim 1, characterized in that The generating a first process key and a second process key respectively according to a result obtained by performing an XOR operation on the first random number and the second random number and a result obtained by performing an XOR operation on the first key dispersion factor and the second key dispersion factor specifically includes: Step B1: the first service party performs an XOR operation on the first key dispersion factor and the second key dispersion factor to obtain a third operation value, and performs an XOR operation on the first random number and the second random number to obtain a fourth operation value; Step B2: the first service party obtains first fixed data, and generates key distribution data according to the third operation value, the fourth operation value and the first fixed data; Step B3: the first service party uses a third preset algorithm to perform a hash operation on the key dispersion data to obtain a hash value of the key dispersion data; Step B4: the first business party obtains data on a first preset byte from the hash value of the key dispersion data to obtain a first process key, and obtains data on a second preset byte from the hash value of the key dispersion data to obtain a second process key.
6. The method according to claim 1, characterized in that The first business party uses the second process key to verify the first MAC data. Specifically, the first business party uses the second process key to perform an encryption operation on the second key dispersion factor and the current business credential ciphertext according to a second preset algorithm to obtain a first operation value, and determines whether the first operation value and the first MAC data are the same. If so, the verification is determined to be successful; otherwise, the verification is determined to be unsuccessful.
7. The method according to claim 1, characterized in that The step 101 further includes: the first business party receives and saves the second business party hardware device name and the second business party hardware device identifier sent by the second business party; The generating of the current business record according to the timestamp, the business data in the current business credential and the current business index is specifically as follows: the first business party generates the current business record according to the saved hardware device name of the second business party, the hardware device identifier of the second business party, the timestamp, the business data in the current business credential and the current business index.
8. A method for generating a business record, characterized in that: The method comprises the following steps: Step S1: When the second service party receives the service initialization instruction sent by the first service party, the second service party parses the service initialization instruction to obtain service data and a timestamp and saves them, generates a first random number and saves it, and sends the first random number to the first service party; Step S2: the second business party receives and saves the first business party public key certificate, the second random number, the first key dispersion factor and the first signature result sent by the first business party, and verifies the first signature result using the first business party public key certificate. If the verification is successful, step S3 is executed; otherwise, an error message is returned to the first business party. Step S3: the second service party generates and saves a current service index according to the first random number and the second random number; Step S4: the second service party generates a second key dispersion factor, and generates a first process key and a second process key respectively according to a result obtained by performing an XOR operation on the first random number and the second random number and a result obtained by performing an XOR operation on the first key dispersion factor and the second key dispersion factor; Step S5: the second business party obtains the first business party public key from the first business party public key certificate, organizes the current business index, the first business party public key and the business data to obtain the current business chain information, and signs the current business chain information to obtain the current business chain signature result; Step S6: the second business party generates a current business credential according to the current business chain information and the current business chain signature result, uses the first process key to encrypt the current business credential to obtain the current business credential ciphertext, uses the second process key to calculate the second key dispersion factor and the current business credential ciphertext to obtain the first MAC data, and sends the second key dispersion factor, the current business credential ciphertext and the first MAC data to the first business party; Step S7: The second service party receives the service processing result ciphertext and the second MAC data sent by the first service party, and verifies the second MAC data using the second process key. When the verification is successful, execute step S8; Step S8: The second business party uses the first process key to decrypt the business processing result ciphertext to obtain the business processing result, and verifies the business processing result. When the verification passes, a current business record is generated according to the timestamp, the business data in the current business credential and the current business index, and the current business record is added to the business log of the second business party.
9. The method according to claim 8, characterized in that Before generating and saving the first random number, the method further includes: the second business party determines whether the business data is legal, and if so, generates and saves the first random number; otherwise, returns an error message to the first business party.
10. The method according to claim 8, characterized in that The first signature result is verified using the public key certificate of the first business party, and the second business party obtains a preset trust agency certificate, and uses the trust agency certificate to verify the first business party public key certificate. If the verification passes, the first signature result is verified using the public key certificate of the first business party. Otherwise, an error message is returned to the first business party.
11. The method according to claim 8, characterized in that The using the first business party public key certificate to verify the first signature result specifically includes: the second business party obtains the first business party public key from the first business party public key certificate, and uses the first business party public key to verify the first signature result.
12. The method according to claim 8, characterized in that The step S3 is specifically as follows: the second business party sequentially concatenates the saved first random number and the second random number or sequentially concatenates the saved second random number and the first random number to obtain the current business index and saves it.
13. The method according to claim 8, characterized in that The generating a first process key and a second process key respectively according to a result obtained by performing an XOR operation on the first random number and the second random number and a result obtained by performing an XOR operation on the first key dispersion factor and the second key dispersion factor specifically includes: Step A1: the second service party performs an XOR operation on the first key dispersion factor and the second key dispersion factor to obtain a third operation value, and performs an XOR operation on the first random number and the second random number to obtain a fourth operation value; Step A2: the second service party obtains the first fixed data, and generates key distribution data according to the third operation value, the fourth operation value and the first fixed data; Step A3: the second service party uses a third preset algorithm to perform a hash operation on the key dispersion data to obtain a hash value of the key dispersion data; Step A4: the second service party obtains data on a first preset byte from the hash value of the key dispersion data to obtain a first process key, and obtains data on a second preset byte from the hash value of the key dispersion data to obtain a second process key.
14. The method according to claim 8, characterized in that The use of the second process key to verify the second MAC data is specifically as follows: the second business party uses the second process key to perform an encryption operation on the business processing result ciphertext according to a second preset algorithm to obtain a second operation value, and determines whether the second operation value and the second MAC data are the same. If so, it is determined that the verification is passed; otherwise, it is determined that the verification is failed.
15. The method according to claim 8, characterized in that The verifying of the business processing result is specifically: the second business party determines whether the business processing result is a preset value, and if so, determines that the verification is passed, otherwise, determines that the verification is not passed.
16. The method according to claim 8, characterized in that The step S2 further includes: the second business party receives and saves the first business party hardware device name and the first business party hardware device identifier sent by the first business party; The generating of the current business record according to the business data in the current business credential, the timestamp and the current business index is specifically: the second business party generates the current business record according to the hardware device name of the first business party, the hardware device identifier of the first business party, the business data in the current business credential, the timestamp and the current business index.
17. A system for generating business records, characterized in that: including a first business party and a second business party; The first service party is used to execute the method according to any one of claims 1 to 7; The second business party is used to execute the method described in any one of claims 8-16.
18. An electronic device, characterized in that: include: Processor and memory; The memory is used to store computer programs; The processor is configured to run the computer program stored in the memory to execute the method according to any one of claims 1 to 7 or any one of claims 8 to 16.
19. A computer-readable storage medium, characterized in that: Used to store a computer program, when the computer program is run on a computer, the computer is caused to execute the method according to any one of claims 1 to 7 or any one of claims 8 to 16.
