Voucher data production method and device, electronic equipment and medium
The method and device generate unique credential data using user identifiers, timestamps, and blockchain technology to address the issue of duplicate voucher data, improving the validity and transparency of online activities.
Patent Information
- Application Number
- CN202411119318.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-15
- Publication Date
- 2024-12-20
AI Technical Summary
Existing methods for generating voucher data in online activities lack the necessary validity and uniqueness, leading to potential confusion and inefficiencies due to the generation of identical data for different users or repeated participation by the same user.
A method and device that generate credential data using a user identifier, current timestamp, and a preset encryption algorithm, combined with random number generation and blockchain storage to ensure uniqueness and transparency, including smart contract execution for verification and result determination.
Ensures unique credential data for each user participation, enhances the validity and transparency of online activities by reducing duplicate data generation and ensuring fair, secure, and transparent verification results.
Smart Images

Figure CN119166714A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method, device, electronic equipment and medium for producing voucher data. Background Art
[0002] In various marketing activities, team-building activities or teaching activities, online entertainment activities are often held to increase the fun. Online entertainment activities are referred to as online activities below. For example, online activities include: limited gift distribution activities, lottery user answering activities or lottery user performance activities. When users participate in online activities, they will be assigned a voucher data as the user's voucher for participating in online activities. Users can match the results of their participation in online activities through the voucher data. Since voucher data plays a vital role in online activities, it is very important to ensure the validity of the voucher data generated in online activities. Summary of the invention
[0003] The purpose of the embodiments of the present application is to provide a method, device, electronic device and medium for producing credential data, so as to improve the validity of credential data. The specific technical solution is as follows:
[0004] In a first aspect of an embodiment of the present application, a method for producing credential data is provided. The method is applicable to a device for producing credential data. The method includes:
[0005] receiving a credential data acquisition request sent by the first terminal, wherein the credential data acquisition request includes a user identifier;
[0006] Get the current timestamp;
[0007] Credential data is generated based on the user identification and the current timestamp using a preset encryption algorithm.
[0008] Optionally, after generating the credential data by using a preset encryption algorithm based on the user identifier and the current timestamp, the method further includes:
[0009] Get a random number;
[0010] Based on the random number and a preset value range, a verification result corresponding to the credential data is determined.
[0011] Optionally, determining a verification result corresponding to the credential data based on the random number and a preset value range includes:
[0012] When the random number belongs to the preset value range, determining that the verification result is a verification pass;
[0013] When the random number does not belong to the preset value range, the verification result is determined to be verification failure.
[0014] Optionally, after determining the verification result corresponding to the credential data based on the random number and the preset value range, the method further includes:
[0015] The credential data and the verification result are stored in a blockchain, so that the blockchain node where the blockchain is located responds to the query request of the first terminal and sends the credential data and the verification result to the first terminal.
[0016] Optionally, obtaining a random number includes:
[0017] Generate a random number using a preset random number generation algorithm based on a default random number seed; or,
[0018] The preset random number generation algorithm is used to take the credential data as a random number seed, and a random number is generated based on the random number seed.
[0019] Optionally, obtaining a random number includes:
[0020] Sending an acquisition request to a blockchain node where the blockchain is located, so that the blockchain node executes a first smart contract to generate a random number seed based on block hash values of a preset number of blocks in the blockchain, and generating a random number based on the random number seed;
[0021] Receive an acquisition response sent by the blockchain node, where the acquisition response includes a generated random number.
[0022] Optionally, obtaining a random number includes:
[0023] Sending an acquisition request to a blockchain node where the blockchain is located, wherein the acquisition request includes the credential data, so that the blockchain node executes a first smart contract to generate a random number seed based on the credential data and block hash values of a preset number of blocks in the blockchain, and to generate a random number based on the random number seed;
[0024] Receive an acquisition response sent by the blockchain node, where the acquisition response includes a generated random number.
[0025] Optionally, the generating credential data by using a preset encryption algorithm based on the user identifier and the current timestamp includes:
[0026] Perform splicing processing based on the user identifier and the current timestamp to obtain splicing parameters;
[0027] A hash operation is performed on the concatenated parameters, and a hash value obtained by the hash operation is used as the credential data.
[0028] Optionally, the method further includes:
[0029] The second smart contract is stored in the blockchain, so that the blockchain node where the blockchain is located responds to the generation request of the first terminal, executes the second smart contract to obtain a random number, determines a verification result based on the random number and a preset numerical range, and sends the determined verification result to the first terminal.
[0030] Optionally, the method further includes:
[0031] receiving a verification request sent by the second terminal;
[0032] A verification response is sent to the second terminal, wherein the verification response includes production description information for the credential data, and the production description information indicates a process of generating the credential data and a verification result.
[0033] According to a second aspect of an embodiment of the present application, a device for producing credential data is provided. The device is applicable to a device for producing credential data. The device includes:
[0034] A receiving module, configured to receive a credential data acquisition request sent by a first terminal, wherein the credential data acquisition request includes a user identifier;
[0035] Acquisition module, used to obtain the current timestamp;
[0036] A generating module is used to generate credential data based on the user identification received by the receiving module and the current timestamp obtained by the obtaining module by using a preset encryption algorithm.
[0037] Optionally, the device further comprises:
[0038] The acquisition module is further used to acquire a random number after generating the credential data based on the user identification and the current timestamp by using the preset encryption algorithm;
[0039] A determination module is used to determine a verification result corresponding to the credential data based on the random number and a preset value range.
[0040] Optionally, the determining module is specifically used to:
[0041] When the random number belongs to the preset value range, determining that the verification result is a verification pass;
[0042] When the random number does not belong to the preset value range, the verification result is determined to be verification failure.
[0043] Optionally, the device further comprises:
[0044] A storage module is used to store the credential data and the verification result in a blockchain after determining the verification result corresponding to the credential data based on the random number and a preset numerical range, so that the blockchain node where the blockchain is located responds to the query request of the first terminal and sends the credential data and the verification result to the first terminal.
[0045] Optionally, the acquisition module is specifically used to:
[0046] Generate a random number using a preset random number generation algorithm based on a default random number seed; or,
[0047] The preset random number generation algorithm is used to take the credential data as a random number seed, and a random number is generated based on the random number seed.
[0048] Optionally, the acquisition module is specifically used to:
[0049] Sending an acquisition request to a blockchain node where the blockchain is located, so that the blockchain node executes a first smart contract to generate a random number seed based on block hash values of a preset number of blocks in the blockchain, and generating a random number based on the random number seed;
[0050] Receive an acquisition response sent by the blockchain node, where the acquisition response includes a generated random number.
[0051] Optionally, the acquisition module is specifically used to:
[0052] Sending an acquisition request to a blockchain node where the blockchain is located, wherein the acquisition request includes the credential data, so that the blockchain node executes a first smart contract to generate a random number seed based on the credential data and block hash values of a preset number of blocks in the blockchain, and to generate a random number based on the random number seed;
[0053] Receive an acquisition response sent by the blockchain node, where the acquisition response includes a generated random number.
[0054] Optionally, the generating module is specifically used for:
[0055] Perform splicing processing based on the user identifier and the current timestamp to obtain splicing parameters;
[0056] A hash operation is performed on the concatenated parameters, and a hash value obtained by the hash operation is used as the credential data.
[0057] Optionally, the device further comprises:
[0058] A storage module is used to store the second smart contract in the blockchain, so that the blockchain node where the blockchain is located responds to the generation request of the first terminal, executes the second smart contract to obtain a random number, determines a verification result based on the random number and a preset numerical range, and sends the determined verification result to the first terminal.
[0059] Optionally, the device further comprises:
[0060] The receiving module is further configured to receive a verification request sent by the second terminal;
[0061] The sending module is used to send a verification response to the second terminal, wherein the verification response includes production description information for the credential data, and the production description information indicates a process of generating the credential data and a verification result.
[0062] According to a third aspect of an embodiment of the present application, an electronic device is provided, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0063] Memory, used to store computer programs;
[0064] The processor is used to implement the method for producing credential data as described in any one of the first aspects when executing the program stored in the memory.
[0065] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium. When the computer program is executed by a processor, the method for producing credential data described in any one of the first aspects above is implemented.
[0066] According to a fifth aspect of the embodiments of the present application, there is also provided a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the method for generating credential data as described in any one of the first aspects above.
[0067] The method, device, electronic device and medium for producing credential data provided by the embodiments of the present application can generate credential data based on the user identification and the current timestamp using a preset encryption algorithm after receiving a credential data acquisition request sent by the first terminal. Since the user identifications of different users are different, generating credential data based on the user identification can increase the possibility of different users obtaining different credential data and reduce the situation where different users obtain the same credential data and cause confusion in online activities. Moreover, the generation of credential data also relies on the current timestamp, so that even if the same user requests to generate credential data multiple times, different credential data can be obtained, thereby supporting the same user to participate in online activities multiple times. In addition, the generation of credential data also relies on a preset encryption algorithm, which further reduces the situation where the same credential data is generated. Therefore, the embodiments of the present application increase the possibility of generating different credential data each time and improve the validity of the credential data. BRIEF DESCRIPTION OF THE DRAWINGS
[0068] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.
[0069] Figure 1 A flowchart of a method for producing voucher data provided by an embodiment of the present invention;
[0070] Figure 2 A flowchart of another method for producing voucher data provided by an embodiment of the present invention;
[0071] Figure 3 An exemplary schematic diagram of a credential data production process provided by an embodiment of the present invention;
[0072] Figure 4 A schematic diagram of the structure of a device for producing voucher data provided by an embodiment of the present invention;
[0073] Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0074] The technical solutions in the embodiments of the present invention will be described below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0075] In order to improve the validity of credential data, the embodiment of the present application provides a method for producing credential data. The method is applicable to a device for producing credential data, such as a server or a desktop computer or other electronic device with data processing capabilities. Figure 1 As shown, the method for producing credential data provided in the embodiment of the present application includes the following steps:
[0076] S101: Receive a credential data acquisition request sent by a first terminal, wherein the credential data acquisition request includes a user identifier (ID).
[0077] The first terminal may send a credential data acquisition request to the production device by calling a credential data acquisition interface. Optionally, the credential data acquisition interface may be configured in a web page or an application (APP). For example, the first terminal may display an active web page through a browser, and when it is detected that a user triggers an acquisition button in the active web page, obtain the user ID of the logged-in user of the browser, and call the credential data acquisition interface included in the active web page code, thereby sending a credential data acquisition request carrying the user ID to the production device. For another example, the first terminal may display an active page in the APP, and when it is detected that a user triggers an acquisition button in the active page, obtain the user ID of the logged-in user of the APP, and call the credential data acquisition interface included in the APP code, thereby sending a credential data acquisition request carrying the user ID to the production device.
[0078] The first terminal may be an electronic device with page display capability and network communication capability, such as a mobile phone, a tablet computer, a laptop computer or a desktop computer.
[0079] S102: Get the current timestamp.
[0080] S103: Generate credential data based on the user identification and the current timestamp using a preset encryption algorithm.
[0081] In the embodiment of the present application, the production device can concatenate the user identification and the current timestamp, encrypt the concatenated data using a preset encryption algorithm, and use the encryption result as the credential data. Alternatively, the credential data can be generated by other means, which can be specifically described below.
[0082] The method for producing credential data provided in the embodiment of the present application can generate credential data based on the user identification and the current timestamp using a preset encryption algorithm after receiving a credential data acquisition request sent by the first terminal. Since the user identifications of different users are different, generating credential data based on the user identification can increase the possibility of different users obtaining different credential data and reduce the situation where different users obtain the same credential data and cause confusion in online activities. Moreover, the current timestamp is also relied on when generating credential data, so that even if the same user requests to generate credential data multiple times, different credential data can be obtained, thereby supporting the same user to participate in online activities multiple times. In addition, the generation of credential data also relies on a preset encryption algorithm, which further reduces the situation where the same credential data is generated. Therefore, the embodiment of the present application increases the possibility of generating different credential data each time and improves the validity of the credential data.
[0083] In the embodiment of the present application, the method of generating voucher data by the production device in S103 includes the following steps:
[0084] Step 1: Perform splicing processing based on the user identifier and the current timestamp to obtain splicing parameters.
[0085] In the first implementation, the production device can concatenate the user ID and the current timestamp as concatenation parameters. In this way, the same user can obtain different concatenation parameters when participating in online activities at different times, ensuring that the same user obtains different credential data each time participating in online activities. Therefore, this method allows different users to participate in online activities, while also allowing the same user to participate in online activities multiple times, making the application scope of the embodiments of the present application wider.
[0086] In the second implementation, the production device can obtain the business identifier of the business targeted by the credential data acquisition request. Among them, the production device can obtain the business identifier from the credential data acquisition request, or the production device can obtain the business name from the credential data acquisition request, and then search for the business identifier corresponding to the business name from the correspondence between the pre-stored business name and the business identifier, or the business identifier can be obtained by other means, and the embodiment of the present application does not specifically limit this. Afterwards, the production device can splice the user identifier, the current timestamp and the business identifier as splicing parameters. In this way, the splicing parameters obtained when the same user participates in online activities of different businesses can be different, thereby ensuring that the credential data obtained is different. This method can support online activities of one or more businesses at the same time, making the application scope of the embodiment of the present application wider.
[0087] In a third implementation, the production device may obtain the current activity level, where the current activity level indicates: the level of the online activity that the first terminal requests to participate in. The current activity level may be obtained from the above-mentioned credential data acquisition request. Alternatively, the current activity level corresponding to the user identifier included in the credential data acquisition request may be found from the correspondence between each user identifier and the activity level recorded by the production device. The production device may then concatenate the user identifier, the current timestamp, and the current activity level as a concatenation parameter.
[0088] For example, the type of online activity is a multi-level activity, which includes two levels of online activities. The first level of online activities is held from 9:00 to 10:00, and the second level of online activities is held from 11:00 to 12:00. When the first terminal participates in the online activity, it can determine the level of this activity according to the time period to which the current timestamp belongs, and send a credential data acquisition request carrying the user identifier and the level of this activity to the production device, so that the production device splices the user identifier, the current timestamp and the level of this activity as splicing parameters.
[0089] For another example, the type of online activity is a superimposed activity, which includes multiple rounds of online activities. Each round of online activities only allows users who have passed the verification in the previous round of online activities to participate. When a user participates in an online activity, a credential data acquisition request carrying a user identifier is sent to the production device through the first terminal. The production device checks whether the user identifier exists in the correspondence between each user identifier and the activity level recorded. If not, the activity level corresponding to the user identifier is recorded as 1 in the correspondence, and the user identifier, current timestamp and activity level are spliced as splicing parameters. If the verification result obtained in this way is that the verification is passed, the activity level corresponding to the user identifier in the corresponding relationship is +1. If the verification result obtained in this way is that the verification is not passed, the activity level corresponding to the user identifier in the corresponding relationship is set to 0. If the user identifier exists in the corresponding relationship, it is determined whether the activity level corresponding to the user identifier in the corresponding relationship is 0. If the current activity level is not 0, the user ID, the current timestamp and the current activity level are concatenated as concatenation parameters. If the verification result obtained is a passed verification, the current activity level corresponding to the user ID in the corresponding relationship is increased by 1. If the verification result obtained is a failed verification, the current activity level corresponding to the user ID in the corresponding relationship is set to 0. If the current activity level corresponding to the user ID in the corresponding relationship is 0, it is determined that the first terminal is not allowed to participate in the online activity, and a prompt message is sent to the first terminal to prompt the user that he is not eligible to participate in the activity.
[0090] Step 2: Perform a hash operation on the concatenated parameters, and use the hash value obtained by the hash operation as the credential data.
[0091] The credential data can be expressed as: Hash (concatenated parameters). For example, credential data = Hash (user ID + current timestamp).
[0092] Generally, when the splicing parameters are different, the credential data obtained by hashing the splicing parameters is also different. Therefore, hashing the splicing parameters can generally make the credential data generated each time different, and can distinguish each participation in online activities, making it convenient to record and track each participation in online activities.
[0093] However, in actual scenarios, there is a possibility that the same credential data is obtained by performing hash operations on different splicing parameters. In order to reduce the possibility of hash collision, that is, to reduce the situation where the same credential data is obtained by performing hash operations on different splicing parameters, the preset hash function can be set to a hash function with high collision resistance. For example, the preset hash function is: Secure Hash Algorithm (SHA)-256, SHA-512 or Blake2 hash algorithm.
[0094] Since the user ID is unique and the current timestamp is random, combining the user ID and the current timestamp to obtain the splicing parameter can improve the uniqueness and randomness of the splicing parameter. Moreover, performing a hash operation on the splicing parameter can further improve the uniqueness of the obtained credential data, thereby ensuring the validity of the credential data.
[0095] After the voucher data is generated in the above S103, the production equipment may also verify the voucher data.
[0096] like Figure 2 As shown, the verification method includes the following steps:
[0097] S104: Obtain a random number.
[0098] The value range of the random number is a preset specified value range, for example, the specified value range may be [0, 1].
[0099] S105. Determine a verification result corresponding to the credential data based on the random number and a preset value range.
[0100] The preset numerical range is pre-set according to actual business, and the preset numerical range is a sub-range included in the above-mentioned specified numerical range.
[0101] The verification result can be represented by an identifier. For example, an identifier of 1 indicates that the verification is passed; an identifier of 0 indicates that the verification is not passed. For another example, an identifier of True indicates that the verification is passed; an identifier of False indicates that the verification is not passed.
[0102] In actual application scenarios, the specific meanings of verification results in different online activities are different. For example, when the online activity is a gift distribution activity, if the verification result is passed, it means that the gift is obtained, and if the verification result is failed, it means that the gift is not obtained. For another example, when the online activity is a qualification confirmation activity, if the verification result is passed, it means that the qualification is obtained, and if the verification result is failed, it means that the qualification is not obtained.
[0103] The production equipment can determine that the verification result is a passed verification when the random number falls within a preset value range; otherwise, the production equipment can determine that the verification result is a failed verification when the random number does not fall within the preset value range.
[0104] For example, an organization includes 100 members, each of whom has one opportunity to participate in an online event, and the organization has prepared 10 prizes for this online event. In this case, the total number of participations is 100, and the number of verification passes is 10, so the value range of the random number can be set to [0,1], and the preset value range is [0,0.1]. Assuming that the random number generated by S104 is 0.05, since 0.05 belongs to [0,0.1], the verification result is determined to be passed, that is, the prize can be obtained. Assuming that the random number generated by S104 is 0.2, since 0.2 does not belong to [0,0.1], the verification result is determined to be failed, that is, the prize cannot be obtained.
[0105] In the embodiment of the present application, after receiving the user's credential data acquisition request, the production device can determine the verification result corresponding to the credential data generated this time in real time based on the random number, without waiting until the online activity is over to uniformly determine the verification results corresponding to all credential data. Therefore, the embodiment of the present application can improve the real-time performance of obtaining the verification result and improve the user experience of participating in online activities.
[0106] Since in the embodiment of the present application, the verification result corresponding to the credential data is determined based on a random number, the randomness of each determination of the verification result is guaranteed, that is, it is guaranteed that the verification result corresponding to each credential data is randomly determined, and therefore the probability that the verification result corresponding to each credential data is a verification pass is the same, thereby improving the fairness of online activities.
[0107] In the embodiment of the present application, the above-mentioned S104 production device obtains a random number in the following four ways:
[0108] A method for producing a random number by a production device includes: using a preset random number generation algorithm to generate a random number based on a default random number seed.
[0109] Optionally, the preset random number generation algorithm may be: a strong random number algorithm or a distributed random number algorithm, etc.
[0110] For example, a strong random number generator may be used to generate a random number, wherein the strong random number generator may be a random number generator based on secure random (SecureRandom) or a random number generator based on a physical process such as thermal noise or radioactive decay.
[0111] For example, the distributed random number algorithm may be: a random number generation algorithm based on a consensus protocol, a linear congruential generator (LCG) or a multiplicative congruential generator (MCG), etc.
[0112] Different random number generation algorithms have different default random number seeds. For example, the random number seed can be the current timestamp, or a seed generated based on physical phenomena such as thermal noise or quantum effects of computer hardware such as the central processing unit (CPU) or graphics processing unit (GPU) of the production device.
[0113] Different random number generation algorithms generate random numbers in different ways based on random number seeds. For example, the random number seed may be processed using operations such as bit manipulation, multiplication, addition, modulo, and / or normalization to obtain a random number.
[0114] The embodiment of the present application can generate a random number using a preset random number generation algorithm, thereby ensuring the randomness of each verification result determined based on the random number, and improving the fairness of online activities. Moreover, compared with the pseudo-random number generation algorithm, the preset strong random number algorithm or distributed random number algorithm used in the embodiment of the present application has stronger randomness, making the generated random number more random, and improving the fairness of the subsequent verification results obtained based on the random number.
[0115] The second method for the production device to generate a random number includes: sending an acquisition request to a blockchain node where the blockchain is located, so that the blockchain node executes a first smart contract to generate a random number seed based on a block hash value of a preset number of blocks in the blockchain, and generating a random number based on the random number seed. After that, the production device receives an acquisition response sent by the blockchain node, wherein the acquisition response includes the random number generated by the blockchain node.
[0116] It is understandable that the blockchain node can be an electronic device such as a desktop computer, a laptop or a server. There can be multiple blockchain nodes, each of which can include a complete blockchain copy, the blockchain copy includes multiple blocks, and the first smart contract is stored in one of the blocks. The production device can call the calling interface of the first smart contract to send a request to a blockchain node, so that the blockchain node executes the first smart contract, that is, executes the random number seed generated based on the block hash value of a preset number of blocks in the blockchain, and generates a random number based on the random number seed.
[0117] Optionally, the block hash values of a preset number of blocks in the blockchain can be directly used as the random number seed, or the block hash values of a preset number of blocks can be processed in a preset manner, and the processing result can be used as the random number seed. For example, the block hash values of a preset number of blocks can be added, multiplied, and / or concatenated, and the processing result can be used as the random number seed.
[0118] The random number seed may then be processed using operations such as bit manipulation, multiplication, addition, modulo and / or normalization, and the processing result may be used as the generated random number.
[0119] Optionally, the preset number of blocks in the blockchain can be: the first N blocks in the blockchain and the block where the first smart contract is located, or a random preset number of blocks in the blockchain, or a preset number of blocks selected from the blockchain by other means, which is not specifically limited in the embodiment of the present application. Wherein, N can be set according to actual needs, for example, N is 1000.
[0120] Since the process of generating random numbers is executed in the blockchain, the security and transparency of the random number generation and release process can be guaranteed through the consensus mechanism of the blockchain, making the generated random numbers highly secure, unpredictable, tamper-proof and verifiable, thereby improving the fairness and transparency of the subsequent verification results based on random numbers.
[0121] Since the above-mentioned credential data is obtained based on the user identification and the current timestamp using a preset encryption algorithm, the credential data is random and unique, and can meet the requirements of the random number algorithm for the random number seed. Therefore, the embodiment of the present application can use the credential data to obtain the random number seed.
[0122] Based on this, the third method for producing a random number by a production device includes: using a preset random number generation algorithm, taking the credential data as a random number seed, and generating a random number based on the random number seed.
[0123] The method of generating random numbers based on random number seeds can refer to the above description.
[0124] Since the credential data is random and unique, the unpredictability of the random numbers generated based on the credential data can be improved, that is, the randomness of the generated random numbers is improved, thereby improving the randomness of the verification results determined based on the random numbers, and ensuring the fairness of online activities.
[0125] A fourth method for generating a random number by a production device includes: sending an acquisition request to a blockchain node where a blockchain is located, wherein the acquisition request includes credential data, so that the blockchain node executes a first smart contract to generate a random number seed based on the credential data and a block hash value of a preset number of blocks in the blockchain, and generates a random number based on the random number seed. And receiving an acquisition response sent by the blockchain node, wherein the acquisition response includes the random number generated by the blockchain node.
[0126] Optionally, the credential data and the block hash values of a preset number of blocks in the blockchain can be directly used as the random number seed, or the credential data and the block hash values of a preset number of blocks can be processed in a preset manner, and the processing result can be used as the generated random number seed. For example, the credential data and the block hash values of a preset number of blocks can be added, multiplied, and / or concatenated, and the processing result can be used as the random number seed.
[0127] The random number seed may then be processed using operations such as bit manipulation, multiplication, addition, modulo and / or normalization, and the processing result may be used as the generated random number.
[0128] Since the credential data is random and unique, the unpredictability of the random numbers generated based on the credential data can be improved, that is, the randomness of the generated random numbers is improved, thereby improving the randomness of the verification results determined based on the random numbers. In addition, the process of generating random numbers is executed in the blockchain, which further ensures the security and transparency of the process of generating random numbers and the fairness of online activities.
[0129] In an embodiment of the present application, after the verification result is determined in the above S105, the production equipment may also store the credential data and the verification result in the blockchain, so that the blockchain node where the blockchain is located responds to the query request of the first terminal and sends the credential data and the verification result to the first terminal.
[0130] Optionally, the production equipment can store the credential data and verification results obtained this time in the blockchain in real time, or store the credential data and verification results obtained in this cycle in the blockchain at the end of each cycle. This makes the credential data and verification results public on the blockchain, ensuring the transparency and immutability of the credential data and verification results.
[0131] After the production device stores the credential data and verification results in the blockchain, it can receive the storage location of the credential data and verification results returned by the blockchain node to the production device. The production device can then send the storage location to the first terminal. The query request subsequently sent by the first terminal to the blockchain node can carry the storage location, so that the blockchain node searches for the credential data and verification results at the storage location, and sends the found credential data and verification results to the first terminal.
[0132] In addition to the credential data and verification results, the production equipment may also store other relevant information corresponding to the credential data in the blockchain. For example, other relevant information includes: user identification, current timestamp and business identification based on which the verification result is determined, etc. On this basis, the query request sent by the first terminal to the blockchain node may carry the user identification, so that the blockchain node searches for the credential data and verification results corresponding to the user identification, and sends the found credential data and verification results to the first terminal.
[0133] Before the production equipment stores the credential data, verification results and other related information in the blockchain, the production equipment can also encrypt the credential data, verification results and other related information, and store the encrypted information in the blockchain to improve the security of data storage. For example, the encryption algorithm used for encryption can be SHA-256, etc. By encrypting the credential data, verification results and other related information, the security of the data stored in the blockchain can be improved, the verification results cannot be tampered with, the security and fairness of the verification results can be improved, and cheating can be effectively prevented.
[0134] In the embodiment of the present application, after the production device stores the credential data and the verification result in the blockchain at S105, in addition to the first terminal, other terminals can also send a query request to the blockchain node and receive the credential data and the verification result sent by the blockchain node. For example, other terminals can be: terminals used by users who are willing to participate in online activities, or terminals used by third-party audit or supervision organizations, etc., which are not specifically limited in the embodiment of the present application.
[0135] In the embodiment of the present application, the production equipment stores the credential data and verification results in the blockchain, so that the first terminal can search for the credential data and verification results from the blockchain after participating in the online activity, and display the search results to the user. Thanks to the fact that the data in the blockchain cannot be forged or tampered with at will, and the modification of the data can be traced, the authenticity and credibility of the credential data and verification results stored in the blockchain are guaranteed, the authenticity of the verification results corresponding to the credential data is improved, and the fairness of online activities is improved.
[0136] In the embodiment of the present application, the production device also supports users to verify the fairness of online activities. The methods for users to verify include the following two:
[0137] The first verification method: the production device stores the second smart contract in the blockchain, so that the blockchain node where the blockchain is located responds to the generation request of the first terminal, executes the second smart contract to obtain a random number, and determines the verification result based on the random number and a preset numerical range, and sends the determined verification result to the first terminal.
[0138] After the production equipment stores the second smart contract in the blockchain, when the user wants to verify the fairness of the activity participation process, the first terminal can be used to call the interface of the second smart contract, thereby sending a generation request to the blockchain node, so that the blockchain node executes the second smart contract, that is, executes to obtain a random number, based on the random number and the preset numerical range, determines the verification result, and sends the determined verification result to the first terminal. The first terminal can then display the received verification result. Among them, the way the blockchain node obtains the random number and determines the verification result is the same as the way the production equipment obtains the random number and determines the verification result, which can be referred to the above description.
[0139] In addition to the first terminal, other terminals may also call the second smart contract in the blockchain. For example, other terminals may be terminals used by users who are willing to participate in online activities, or terminals used by third-party audit or supervision organizations, etc., which are not specifically limited in the embodiments of the present application.
[0140] In an embodiment of the present application, the production equipment can store the second smart contract in the blockchain in advance. After that, after the online activity starts, whenever a credential data acquisition request sent by the first terminal is received, the verification result can be obtained through the second smart contract in the blockchain when executing S104 to S105.
[0141] The embodiment of the present application deploys the second smart contract on the blockchain, so that users can call the second smart contract by themselves through the terminal to verify the fairness of the verification results obtained during the activity participation process, thereby improving the transparency and verifiability of online activities. This method enhances the image of the organization that holds online activities, enhances brand trust, and reduces operational and legal risks. It also enhances the user's trust in the verification results of online activities and the organization, and enhances the user's enthusiasm for participating in online activities.
[0142] The second verification method: the production device receives the verification request sent by the second terminal and sends a verification response to the second terminal, wherein the verification response includes production description information of the voucher data, and the production description information indicates the process of generating the voucher data and the verification result.
[0143] The first terminal in S101 above and the second terminal here can be the same terminal or different terminals. That is, the terminal that has participated in the online activity or the terminal that has not participated in the online activity can send a verification request to the production device to verify the process of participating in the online activity by itself. That is, the embodiment of the present application allows users who have participated in online activities, users who are willing to participate in online activities, and users of third-party audit or supervision organizations to verify the fairness of the process of determining credential data and verification results in the embodiment of the present application.
[0144] The production description information may describe the process of obtaining the verification result in the form of text and / or pictures. The production description information may include: a formula for generating voucher data, a description of the process of determining the verification result, a description of the random number generation algorithm, and a random number seed used by the random number generation algorithm.
[0145] For example, the production description information includes: credential data = hash (user ID + current timestamp); if the random number is ≤0.1, the verification passes, and if the random number is >0.1, the verification fails; the aaa random number generation algorithm is used, and the calling interface of the algorithm is the bbb interface. When calling the bbb interface, a credential data must be transmitted, and the random number seed used by the aaa algorithm = (credential data + block hash value of the previous N blocks).
[0146] The embodiment of the present application can send production description information to users, making the process of participating in online activities more transparent. Users can verify the fairness of generated credential data and verification results based on the production description information, thereby improving the transparency and verifiability of credential data and verification results. This method enhances the image of the organization that holds online activities, enhances brand trust, and reduces operational and legal risks. It also enhances users' trust in verification results and trust in the organization, and enhances users' enthusiasm for participating in online activities.
[0147] See also Figure 3 , the following is combined with actual scenarios, taking the online activity as an online lottery activity as an example, to illustrate the method for producing voucher data provided in the embodiment of the present application:
[0148] The production equipment includes: user interface module, lottery processing module, random number generation module, encryption storage module and blockchain publishing module.
[0149] When the terminal detects that the user indicates to participate in the online activity, it calls the lottery interface to send a voucher data acquisition request to the user interface module. After receiving the voucher data acquisition request sent by the terminal, the user interface module sends the user identifier included in the voucher data acquisition request to the lottery processing module.
[0150] The lottery processing module obtains the current timestamp, concatenates the user ID and the current timestamp to obtain concatenation parameters, performs a hash operation on the concatenation parameters, and uses the hash value as the voucher data, which represents the lottery number. The lottery processing module then sends the voucher data to the random number generation module.
[0151] The random number generation module sends a request to obtain the credential data to the blockchain node, so that the blockchain node executes the first smart contract to generate a random number seed based on the credential data and the block hash value of a preset number of blocks in the blockchain, and generates a random number based on the random number seed. After that, the random number generation module receives the random number sent by the blockchain node. Then, it is determined whether the random number is ≤0.1. If so, it is determined that the lottery result corresponding to the credential data is a winning result, otherwise it is determined that the lottery result corresponding to the credential data is a non-winning result, and the lottery result is sent to the encryption storage module.
[0152] The encryption storage module encrypts the credential data, lottery results and other related information, sends the encrypted data to the terminal, and stores the encrypted data in the blockchain.
[0153] The blockchain publishing module periodically stores the encrypted data of this period into the blockchain.
[0154] Based on the same inventive concept, corresponding to the above method embodiment, the present application embodiment also provides a device for producing credential data, which is applicable to a device for producing credential data, such as Figure 4 As shown, the device includes: a receiving module 401, an acquisition module 402 and a generation module 403;
[0155] The receiving module 401 is used to receive a credential data acquisition request sent by the first terminal, where the credential data acquisition request includes a user identifier;
[0156] The acquisition module 402 is used to acquire the current timestamp;
[0157] The generating module 403 is used to generate credential data based on the user identification received by the receiving module 401 and the current timestamp obtained by the obtaining module 402 by using a preset encryption algorithm.
[0158] Optionally, the device may further include:
[0159] The acquisition module 402 is further used to obtain a random number after generating the credential data based on the user identification and the current timestamp using a preset encryption algorithm;
[0160] The determination module is used to determine the verification result corresponding to the credential data based on the random number and the preset value range.
[0161] Optionally, determine the module, specifically for:
[0162] When the random number falls within the preset value range, determining the verification result as verification passed;
[0163] When the random number does not fall within the preset value range, the verification result is determined to be verification failure.
[0164] Optionally, the device may further include:
[0165] The storage module is used to store the credential data and the verification result in the blockchain after determining the verification result corresponding to the credential data based on the random number and the preset numerical range, so that the blockchain node where the blockchain is located responds to the query request of the first terminal and sends the credential data and the verification result to the first terminal.
[0166] Optionally, the acquisition module 402 is specifically used to:
[0167] Generate a random number using a preset random number generation algorithm based on a default random number seed; or,
[0168] Utilize the preset random number generation algorithm, take the credential data as the random number seed, and generate a random number based on the random number seed.
[0169] Optionally, the acquisition module 402 is specifically used to:
[0170] Sending an acquisition request to a blockchain node where the blockchain is located, so that the blockchain node executes a first smart contract to generate a random number seed based on block hash values of a preset number of blocks in the blockchain, and generating a random number based on the random number seed;
[0171] Receive the get response sent by the blockchain node, which includes the generated random number.
[0172] Optionally, the acquisition module 402 is specifically used to:
[0173] Sending an acquisition request to a blockchain node where the blockchain is located, wherein the acquisition request includes credential data, so that the blockchain node executes a first smart contract to generate a random number seed based on the credential data and block hash values of a preset number of blocks in the blockchain, and to generate a random number based on the random number seed;
[0174] Receive the get response sent by the blockchain node, which includes the generated random number.
[0175] Optionally, the generating module 403 is specifically used for:
[0176] Perform splicing processing based on the user ID and the current timestamp to obtain splicing parameters;
[0177] Perform a hash operation on the concatenated parameters, and use the hash value obtained by the hash operation as the credential data.
[0178] Optionally, the device may further include:
[0179] The storage module is used to store the second smart contract in the blockchain, so that the blockchain node where the blockchain is located responds to the generation request of the first terminal, executes the second smart contract to obtain a random number, determines a verification result based on the random number and a preset numerical range, and sends the determined verification result to the first terminal.
[0180] Optionally, the device may further include:
[0181] The receiving module 401 is further configured to receive a verification request sent by the second terminal;
[0182] The sending module is used to send a verification response to the second terminal, where the verification response includes production description information for the credential data, and the production description information indicates a process of generating the credential data and a verification result.
[0183] The embodiment of the present invention further provides an electronic device, such as Figure 5 As shown, it includes a processor 501, a communication interface 502, a memory 503 and a communication bus 504, wherein the processor 501, the communication interface 502, and the memory 503 communicate with each other through the communication bus 504.
[0184] Memory 503, used for storing computer programs;
[0185] The processor 501 is used to implement the method executed by the production equipment in the above method embodiment when executing the program stored in the memory 503.
[0186] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0187] The communication interface is used for communication between the above electronic device and other devices.
[0188] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0189] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0190] In another embodiment provided by the present invention, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the method for producing credential data described in any of the above embodiments is implemented.
[0191] In another embodiment provided by the present invention, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute the method for generating credential data described in any one of the above embodiments.
[0192] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.
[0193] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0194] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0195] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A method for producing voucher data, It is characterized in that The method is applicable to a device for producing voucher data, and the method comprises: receiving a credential data acquisition request sent by the first terminal, wherein the credential data acquisition request includes a user identifier; Get the current timestamp; Credential data is generated based on the user identification and the current timestamp using a preset encryption algorithm.
2. The method according to claim 1, It is characterized in that After generating the credential data based on the user identification and the current timestamp using a preset encryption algorithm, the method further includes: Get a random number; Based on the random number and a preset value range, a verification result corresponding to the credential data is determined.
3. The method according to claim 2, It is characterized in that The determining, based on the random number and the preset value range, a verification result corresponding to the credential data includes: When the random number belongs to the preset value range, determining that the verification result is a verification pass; When the random number does not belong to the preset value range, the verification result is determined to be verification failure.
4. The method according to claim 2, It is characterized in that After determining the verification result corresponding to the credential data based on the random number and the preset value range, the method further includes: The credential data and the verification result are stored in a blockchain, so that the blockchain node where the blockchain is located responds to the query request of the first terminal and sends the credential data and the verification result to the first terminal.
5. The method according to any one of claims 2 to 4, It is characterized in that The obtaining of a random number comprises: Generate a random number using a preset random number generation algorithm based on a default random number seed; or, The preset random number generation algorithm is used to take the credential data as a random number seed, and a random number is generated based on the random number seed.
6. The method according to claim 4, It is characterized in that The obtaining of a random number comprises: Sending an acquisition request to a blockchain node where the blockchain is located, so that the blockchain node executes a first smart contract to generate a random number seed based on block hash values of a preset number of blocks in the blockchain, and generating a random number based on the random number seed; Receive an acquisition response sent by the blockchain node, where the acquisition response includes a generated random number.
7. The method according to claim 4, It is characterized in that The obtaining of a random number comprises: Sending an acquisition request to a blockchain node where the blockchain is located, wherein the acquisition request includes the credential data, so that the blockchain node executes a first smart contract to generate a random number seed based on the credential data and block hash values of a preset number of blocks in the blockchain, and to generate a random number based on the random number seed; Receive an acquisition response sent by the blockchain node, where the acquisition response includes a generated random number.
8. The method according to claim 1, It is characterized in that The generating credential data based on the user identification and the current timestamp by using a preset encryption algorithm includes: Perform splicing processing based on the user identifier and the current timestamp to obtain splicing parameters; A hash operation is performed on the concatenated parameters, and a hash value obtained by the hash operation is used as the credential data.
9. The method according to claim 4, It is characterized in that The method further comprises: The second smart contract is stored in the blockchain, so that the blockchain node where the blockchain is located responds to the generation request of the first terminal, executes the second smart contract to obtain a random number, determines a verification result based on the random number and a preset numerical range, and sends the determined verification result to the first terminal.
10. The method according to any one of claims 2 to 4, It is characterized in that The method further comprises: receiving a verification request sent by the second terminal; A verification response is sent to the second terminal, wherein the verification response includes production description information for the credential data, and the production description information indicates a process of generating the credential data and a verification result.
11. A device for producing voucher data, It is characterized in that The device is applicable to a device for producing voucher data, and the device comprises: A receiving module, configured to receive a credential data acquisition request sent by a first terminal, wherein the credential data acquisition request includes a user identifier; Acquisition module, used to obtain the current timestamp; A generating module is used to generate credential data based on the user identification received by the receiving module and the current timestamp obtained by the obtaining module by using a preset encryption algorithm.
12. An electronic device, It is characterized in that It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method according to any one of claims 1 to 10 when executing a program stored in a memory.
13. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 10 is implemented.
Citation Information
Patent Citations
Method and device of drawing lottery through using blockchain
CN109636998A
Electronic invoice circulation management method, device and system based on block chain
CN111429191A
Data processing method, blockchain node equipment, electronic equipment and computer program
CN111865587A
Searchable encryption method based on block chain and electronic equipment
CN112732789A
Security authentication method and device and storage medium
CN116070204A
