Blockchain-based mass interface call log evidence storage and traceability method and system
By introducing blockchain technology into the data sharing model, generating unique identifiers and calculating hash values, the problem of storing and tracing massive interface call logs is solved, and reliable storage and traceability effects are achieved.
Patent Information
- Application Number
- CN202410567053.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-09
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2044-05-09
AI Technical Summary
In the data sharing model, there are difficulties in preserving and tracing massive interface call logs, which are difficult to solve effectively with existing technologies.
Through blockchain technology, combined with the caller, provider, service gateway, Kafka cluster, logstash, log collection system and ES system, a log ID with a unique identifier is generated, and the hash value of the call log is calculated and stored, using the tamper-proof nature of the blockchain for evidence storage and traceability.
It realizes the trusted storage and traceability of massive interface call logs, ensures the integrity and reliability of log information, and uses the tamper-proof characteristics of blockchain to realize the trusted traceability of interface calls.
Smart Images

Figure CN118487740B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of block chain, in particular to a mass interface call log evidence storage and traceability method and system based on block chain. BACKGROUND
[0002] As a relatively mature supporting technology, the block chain technology has been applied in the government field at present, deepens the application scene innovation of block chain in the data sharing field, and can provide basic support for subsequent "block chain+" other scenes.
[0003] The difficulty of mass interface call log evidence storage and the difficulty of data sharing traceability in the data sharing mode are technical problems to be solved. SUMMARY
[0004] The technical task of the present application is to solve the technical problems of the difficulty of mass interface call log evidence storage and the difficulty of data sharing traceability in the data sharing mode by providing a mass interface call log evidence storage and traceability method and system based on block chain in view of the above shortcomings.
[0005] In the first aspect, the present application provides a mass interface call log evidence storage and traceability method based on block chain, which is applied between a calling party, a providing party, a service gateway, a Kafka cluster, a logstash, a log collection system, an ES system and a block chain, and the method comprises the following steps:
[0006] The calling party and the providing party perform data calling through the service gateway, for each data calling, the service gateway pushes the corresponding calling log to the Kafka cluster, and each calling log has a log ID as a unique identifier;
[0007] The Kafka cluster consumes the calling log, converts the calling log through consumption, and stores the consumed calling log in batches to the ES system through the logstash;
[0008] The log collection system calls the Kafka cluster to consume the calling log, calculates the hash value of each calling log, assembles the hash values of the batch calling logs, calculates the hash value again, obtains the total hash value, uploads the total hash value corresponding to the batch calling logs to the block chain, the block chain returns the transaction hash value to the log collection system, and the log collection system returns the transaction hash value to the ES system and associates the transaction hash value with the corresponding batch calling log;
[0009] For the calling log to be traced, the corresponding transaction hash value and the batch calling log to which the calling log belongs are queried from the ES system based on the log ID, the corresponding total hash value is queried from the blockchain based on the transaction hash value, and the total hash value of the batch calling log is calculated by calling the trusted third party, and the obtained total hash value is compared with the total hash value queried from the blockchain. If they are consistent, it is determined that the calling log is trustworthy.
[0010] As a preferred, for the calling log, a unique identifier is generated as a log ID based on the calling date and time of the data call corresponding to the calling log.
[0011] As a preferred, when the calling log is consumed by the Kafka cluster, the calling log is converted into a json format, and the json format calling log is spliced to obtain a string form calling log.
[0012] As a preferred, for each calling log, the log ID, the log recording party, the hash value, the calling start time and the calling end data are stored as evidence data into the ES system, and the batch calling log is stored in the ES system in the form of a log list.
[0013] In a second aspect, the present application provides a mass interface calling log evidence tracing system based on a blockchain, which comprises a service gateway, a Kafka cluster, a logstash, a log collection system, an ES system and a blockchain.
[0014] The service gateway is used for pushing the corresponding calling log to the Kafka cluster for each data call between the calling party and the providing party, and each calling log has a log ID as a unique identifier.
[0015] The Kafka cluster is used for consuming the calling log, converting the calling log through consumption, and storing the consumed calling log in batches into the ES system through the logstash.
[0016] The log collection system is used for calling the Kafka cluster to consume the calling log, calculating the hash value of each calling log, splicing the hash values of the batch calling logs and then calculating the hash value to obtain a total hash value, and uploading the total hash value of the batch calling log to the blockchain. Correspondingly, the blockchain is used for returning the transaction hash value to the log collection system, and the log collection system is used for returning the transaction hash value to the ES system and associating it with the corresponding batch calling log.
[0017] For the calling log to be verified and traced, the ES system is used to query the corresponding transaction hash value and the batch calling log to which the calling log belongs based on the log ID, to query the corresponding total hash value from the blockchain based on the transaction hash value, and to call a trusted third party to calculate the total hash value of the batch calling log, and to compare the obtained total hash value with the total hash value queried from the blockchain, and if consistent, it is determined that the calling log is trusted.
[0018] As a preferred, for the calling log, the service gateway is used to generate a unique identifier as the log ID based on the calling date and time of the data calling corresponding to the calling log.
[0019] As a preferred, the Kafka cluster is used to convert the calling log into a json format, and to assemble the calling log in the json format to obtain a calling log in a string form.
[0020] As a preferred, for each calling log, the log ID, the log recording party, the hash value, the calling start time and the calling end data corresponding to the calling log are stored as evidence data in the ES system, and the calling log is stored in the ES system in the form of a log list.
[0021] The mass interface calling log evidence storage and tracing method and system based on the blockchain have the following advantages: the log ID, the log recording party, the hash value, the calling start time and the calling end data of the calling log are stored as evidence data in the ES system, the information of the calling log can be queried through the ES system, at the same time, the hash value of the batch calling log is assembled to calculate the total hash value, and the total hash value and the transaction hash value are stored in the blockchain, when verifying, the total hash value of the batch calling log is calculated and compared with the total hash value stored in the blockchain, the evidence storage and tracing of the mass interface calling log are realized, and the trusted tracing of the interface calling is realized by using the tamper-proofing property of the blockchain. BRIEF DESCRIPTION OF DRAWINGS
[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without any creative effort.
[0023] The present application will be further described below in conjunction with the drawings.
[0024] Figure 1 A flowchart of a mass interface calling log evidence storage and tracing method based on a blockchain for embodiment 1;
[0025] Figure 2 A principle block diagram of the blockchain-based mass interface call log evidence storage and traceability method of embodiment 1;
[0026] Figure 3 A flow block diagram of the call log evidence storage in the blockchain-based mass interface call log evidence storage and traceability method of embodiment 1;
[0027] Figure 4 A flow block diagram of the call log on-chain in the blockchain-based mass interface call log evidence storage and traceability method of embodiment 1;
[0028] Figure 5 A flow block diagram of the call log traceability in the blockchain-based mass interface call log evidence storage and traceability method of embodiment 1;
[0029] Figure 6 A hash value comparison schematic diagram in the blockchain-based mass interface call log evidence storage and traceability method of embodiment 1;
[0030] Figure 7 A traceability process schematic diagram of the blockchain-based mass interface call log evidence storage and traceability method of embodiment 1. DETAILED DESCRIPTION
[0031] The present application will be further described below in conjunction with the drawings and specific embodiments, so that those skilled in the art can better understand the present application and implement it, but the embodiments are not limiting to the present application, and the technical features in the embodiments and the embodiments can be combined with each other without conflict.
[0032] The embodiment of the present application provides a blockchain-based mass interface call log evidence storage and traceability method and system, which is used to solve the technical problems of mass interface call log evidence storage and data sharing traceability in the data sharing mode.
[0033] Embodiment 1:
[0034] The blockchain-based mass interface call log evidence storage and traceability method of the present application is applied between the calling party, the providing party, the service gateway, the Kafka cluster, the logstash, the log collection system, the ES system and the blockchain, as shown in Figure 1 and Figure 2 The method comprises the following steps:
[0035] S100, the calling party and the providing party perform data calling through the service gateway, for each data calling, the service gateway pushes the corresponding calling log to the Kafka cluster, and each calling log corresponds to a log ID as a unique identifier;
[0036] S200, the Kafka cluster consumes the call log, formats the call log through consumption, and stores the consumed call log in batches to the ES system through logstash;
[0037] S300, the log collection system calls the consumed call log of the Kafka cluster, calculates the hash value of each call log, assembles the hash values of the batch call logs, calculates the hash value again to obtain a total hash value, uploads the total hash value corresponding to the batch call log to the blockchain, the blockchain returns a transaction hash value to the log collection system, and the log collection system returns the transaction hash value to the ES system and associates it with the corresponding batch call log;
[0038] S400, for the call log to be verified, the corresponding transaction hash value and the batch call log to which it belongs are queried from the ES system based on the log ID, the corresponding total hash value is queried from the blockchain based on the transaction hash value, and the total hash value of the corresponding batch call log is calculated by calling a trusted third party. Compare the total hash value obtained with the total hash value queried from the blockchain. If they are consistent, the call log is determined to be trustworthy.
[0039] In step S100 of the embodiment, for the call log, the service gateway generates a unique identifier as a log ID based on the call date and time of the data call corresponding to the call log.
[0040] As a specific implementation, a unique request ID is generated for each interface call request, which is used as a log ID as a unique identifier for the call log. The reference format is as follows: call date and time + hash({VERSION} + {URL}) + {random number}.
[0041] In step S200, when the Kafka cluster consumes the call log, the call log is converted to json format, and the json format call log is assembled to obtain a call log in string form. Among them, the format assembly information is:
[0042]
[0043] The above json is converted to a string (toJSONString()) and sent to the log collection system. Among them, for each call log, the log ID, the log recording party, the hash value, the call start time and the call end data are stored as evidence data in the ES system, and the batch call log is stored in the ES system in the form of a log list.
[0044] For example, Figure 3 and Figure 4The step S300 shown is to store the evidence, calculate the hash value of the batch call log, and assemble the batch call log hash to calculate the total hash value, and chain the total hash value. As a specific implementation, for 1000 call logs, the transaction hash and the hash value of 1000 logs are stored into the es using the following format
[0045]
[0046] As shown in Figure 5 Step S400 is tracing, as a specific implementation of tracing, according to the log ID, the log list chained in the ES system, and the transaction hash value chained, the total hash value stored in the blockchain is found according to the transaction hash value, the hash of each log is calculated according to the log list, and the corresponding 1000 log hash values are assembled to calculate the hash to obtain the total hash of the off-chain log. Finally, the hash stored on the chain and the hash calculated by the off-chain log are compared. If they are consistent, the log has not been tampered with, and the content of the log is the calling information at that time, and the content is reliable. If they are not consistent, the log has been tampered with, and the current log information is not reliable. The log comparison result is shown in Figure 6 .
[0047] For the above tracing process, the relevant information can be displayed through a page, specifically, as shown in Figure 7 In the tracing detail page, the calling log and the batch chained log list are displayed, and the log content can be copied. The user can give the log to a trusted third party to calculate the hash according to the same hash calculation method. Confirm the correctness of the hash value displayed on the page.
[0048] Embodiment 2
[0049] The application discloses a mass interface call log evidence storage and tracing system based on a blockchain, which comprises a service gateway, a Kafka cluster, a logstash, a log collection system, an ES system and a blockchain. The system can execute the method disclosed in embodiment 1 to realize the evidence storage and tracing of the call log.
[0050] The calling party and the providing party perform data calling through the service gateway. For each data calling, the service gateway is used for pushing the corresponding calling log to the Kafka cluster, and each calling log corresponds to a log ID as a unique identifier.
[0051] For the calling log, the service gateway generates a unique identifier as the log ID based on the calling date and time of the calling log corresponding to the data calling.
[0052] As a specific implementation, a unique request ID is generated for each interface call request, which is used as a log ID as a unique identifier of the call log. The reference format is as follows: call date and time + hash({VERSION} + {URL}) + {random number}.
[0053] The Kafka cluster is used to consume the call log, convert the call log by consumption, and store the consumed call log in batches to the ES system through logstash.
[0054] When the Kafka cluster consumes the call log, it is used to convert the call log into a json format, and the json format call log is assembled to obtain a string form call log. Among them, the format assembly information:
[0055]
[0056] The above json is converted to a string (toJSONString()) and sent to the log collection system. Among them, for each call log, the log ID, log record party, hash value, call start time and call end data are stored as evidence data in the ES system, and batch call logs are stored in the ES system in the form of a log list.
[0057] The log collection system is used to call the consumed call log of the Kafka cluster, calculate the hash value of each call log, and assemble the hash values of batch call logs to calculate the total hash value, and upload the total hash value corresponding to the batch call log to the blockchain. Correspondingly, the blockchain is used to return the transaction hash value to the log collection system, and the log collection system is used to return the transaction hash value to the ES system and associate it with the corresponding batch call log.
[0058] The log collection system and the blockchain are used to realize the evidence storage, and the log collection system is used to calculate the hash value of the batch call log, and the total hash value is calculated after assembling the batch call log hash, and the total hash value is uploaded to the chain. As a specific implementation, for 1000 call logs, the transaction hash and the hash value of 1000 logs are stored in the es using the following format
[0059]
[0060]
[0061] For the calling log to be traced, the ES system is used to query the corresponding transaction hash value and the batch calling log to which it belongs based on the log ID, to query the corresponding total hash value from the blockchain based on the transaction hash value, and to call a trusted third party to calculate the total hash value of the batch calling log, and to compare the total hash value obtained with the total hash value queried from the blockchain. If they are consistent, the calling log is determined to be trusted.
[0062] The ES system, the log collection system and the blockchain cooperate to realize tracing. As a specific implementation of tracing, according to the log ID, a list of logs uploaded to the chain is found in the ES system, and a transaction hash value uploaded to the chain is found according to the transaction hash value. According to the transaction hash value, a total hash value stored in the blockchain is found. According to the log list, the hash of each log is queried and calculated, and then the hash values of the corresponding 1000 logs are spliced to calculate the hash to obtain the total hash of the off-chain log. Finally, the hash stored in the chain and the hash calculated by the off-chain log are compared. If they are consistent, the log has not been tampered with, and the content of the log is the calling information at that time, and the content is trusted. If they are not consistent, the log has been tampered with, and the current log information is not trusted.
[0063] For the above tracing process, relevant information can be displayed through a page. Specifically, in the detail page of the tracing, the calling log of the tracing and the batch log list uploaded to the chain are displayed, and the log content can be copied. The user can give the log to a trusted third party to calculate the hash according to the same hash calculation method to confirm the correctness of the hash value displayed on the page.
[0064] The above has shown and described the present application in detail through the accompanying drawings and preferred embodiments, but the present application is not limited to these disclosed embodiments. Based on the above embodiments, those skilled in the art can know that the means in the above different embodiments can be combined to obtain more embodiments of the present application, and these embodiments are also within the protection scope of the present application.
Claims
1. A blockchain-based method for tracing the origin of massive interface call logs, characterized in that: Applied between the caller, provider, service gateway, Kafka cluster, logstash, log collection system, ES system and blockchain, the method includes the following steps: The caller and provider make data calls through the service gateway. For each data call, the service gateway pushes the corresponding call log to the Kafka cluster. Each call log has a log ID as a unique identifier. The Kafka cluster consumes call logs, converts the call log format through consumption, and stores the consumed call logs in batches to the ES system through Logstash. The log collection system calls the Kafka cluster to read the consumed call logs, calculates the hash value of each call log, assembles the hash values of the batch call logs, calculates the hash value again, and obtains the total hash value. The total hash value corresponding to the batch call log is uploaded to the blockchain. The blockchain returns the transaction hash value to the log collection system, and the log collection system returns the transaction hash value to the ES system and associates it with the corresponding batch call log. For call logs to be verified and traced, the corresponding transaction hash value and the batch call log to which it belongs are queried from the ES system based on the log ID. The corresponding total hash value is queried from the blockchain based on the transaction hash value, and a trusted third party is called to calculate the total hash value of the corresponding batch call log. The obtained total hash value is compared with the total hash value queried from the blockchain. If they are consistent, the call log is determined to be credible.
2. The blockchain-based massive interface call log evidence tracing method according to claim 1 is characterized in that: For the call log, a unique identifier is generated as the log ID based on the call date and time of the call log corresponding to the data call.
3. The blockchain-based massive interface call log evidence tracing method according to claim 1 is characterized in that: When consuming call logs through the Kafka cluster, the call logs are converted into JSON format and assembled into string format.
4. The blockchain-based massive interface call log evidence tracing method according to claim 1 is characterized in that: For each call log, the log ID, log recorder, hash value, call start time, and call end data are stored in the ES system as evidence data. Batch call logs are stored in the ES system in the form of log lists.
5. A blockchain-based massive interface call log evidence tracing system, characterized by: Including service gateway, Kafka cluster, logstash, log collection system, ES system and blockchain; The caller and provider make data calls through the service gateway. For each data call, the service gateway is used to push the corresponding call log to the Kafka cluster. Each call log has a log ID as a unique identifier. The Kafka cluster is used to consume call logs, convert the call log format through consumption, and store the consumed call logs in batches to the ES system through Logstash. The log collection system is used to call the Kafka cluster to read the call logs after consumption, calculate the hash value of each call log, assemble the hash values of the batch call logs, calculate the hash value again, obtain the total hash value, and upload the total hash value corresponding to the batch call logs to the blockchain; correspondingly, the blockchain is used to return the transaction hash value to the log collection system, and the log collection system is used to return the transaction hash value to the ES system and associate it with the corresponding batch call log; For call logs that need to be verified and traced, the ES system is used to query the corresponding transaction hash value and the batch call log to which it belongs based on the log ID. It is used to query the corresponding total hash value from the blockchain based on the transaction hash value, and call a trusted third party to calculate the total hash value of the corresponding batch call log. The obtained total hash value is compared with the total hash value queried from the blockchain. If they are consistent, the call log is determined to be credible.
6. The blockchain-based massive interface call log evidence tracing system according to claim 5 is characterized in that: For the call log, the service gateway is used to generate a unique identifier as a log ID based on the call date and time of the call corresponding to the data in the call log.
7. The blockchain-based massive interface call log evidence tracing system according to claim 5 is characterized in that: The Kafka cluster is used to convert the call log into json format, and assemble the call log in json format to obtain the call log in string form.
8. The blockchain-based massive interface call log evidence tracing system according to claim 5 is characterized in that: For each call log, the log ID, log recorder, hash value, call start time, and call end data corresponding to the call log are stored in the ES system as evidence data. The call log is stored in the ES system in the form of a log list.
Citation Information
Patent Citations
Government information collaborative sharing scheme for introducing Kafka cluster based on block chain
CN115913529A
Data synchronization method and device, electronic equipment and computer readable medium
CN117194562A