A trusted drug traceability method based on public key searchable encryption

By introducing public key searchable encryption and MIIT index structures into drug traceability technology, the problems of information asymmetry and off-chain data security in blockchain traceability technology are solved, and efficient traceability and secure query of drug information are achieved.

CN116777476BActive Publication Date: 2024-11-15YUNNAN UNIVERSITY OF FINANCE AND ECONOMICS
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310687830.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-09
Publication Date
2024-11-15
Estimated Expiration
2043-06-09

AI Technical Summary

Technical Problem

The existing blockchain-based drug traceability technology has shortcomings in information asymmetry and off-chain data security, and lacks effective index processing and on-chain storage cost considerations.

Method used

A trusted traceability method for drug based on public key searchable encryption is proposed. By encrypting drug information, ciphertext and index table are generated, index tree is built using MIIT, and uploading it to cloud server and blockchain, combining it with Smart contracts manage data access rights to realize drug traceability.

Benefits of technology

It enhances the online security and credibility of drug information, improves the availability and search efficiency of encrypted data, supports the trusted verification process of cloud servers and blockchains, and reduces the burden of encryption and decryption of search information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116777476B_ABST
    Figure CN116777476B_ABST
Patent Text Reader

Abstract

The invention discloses a drug trusted traceability method based on public key searchable encryption, including 4 steps: 1. encrypting the collected drug information and log information and extracting keywords to generate drug ciphertext and index table, uploading to cloud server, providing basis for searching encrypted data, i.e. tracing query; 2. generating a checklist of relevant drug information according to the ciphertext and the identity ID of the data uploader, and embedding the checklist into the smart contract of blockchain; 3. uploading the drug ciphertext in Step 1 to the drug traceability chain; 4. when the data queryer wants to query the drug information, the system obtains the keywords and identity ID in the search terms input by the queryer and verifies them, and completes the search behavior after verification; and records the log information generated by the search behavior, and stores it on the chain. The invention introduces public key searchable encryption technology for drug traceability scenarios, so that each node is easy to maintain and monitor, adopts a pre-semantic extraction algorithm, introduces pre-conditions and part-of-speech factors in the method, and effectively improves the accuracy of drug data feature extraction in the model; adopts Merkel inverted index tree structure, improves the search efficiency of multiple keywords, supports the trusted verification process of cloud server and blockchain, and improves the drug data search efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a drug trusted source tracing method based on public key searchable encryption. Background Art

[0002] The pharmaceutical supply chain is complex and involves many participants, which leads to information asymmetry between the participants in the supply chain. It is not easy to achieve true drug traceability. The current blockchain traceability technology still has the following shortcomings in the application of drug traceability: ① The existing blockchain-based searchable encryption model only considers the integration design of algorithm flow and blockchain, and its application scenario is relatively single. ② Most of the existing blockchain traceability research directions focus on the construction of its model architecture and the implementation of smart contracts, ignoring the security and credibility of off-chain data during transmission. ③ The current blockchain-based searchable encryption model has a relatively comprehensive study of the data encryption process, but lacks consideration of off-chain data index processing and on-chain storage costs. Summary of the invention

[0003] In view of the defects existing in the prior art, the present invention proposes a searchable encryption model of drug traceability data based on blockchain (Public key Encryption with Keyword Search model of DrugTraceability data based on Blockchain, DTB-PEKS), which processes drug information and divides it into multiple drug data files, and extracts the index value of keywords for each data file. The data file is encrypted using a public key searchable encryption algorithm to generate ciphertext, and an index tree MIIT is constructed and sent to the cloud server, and the ciphertext is uploaded to the blockchain. In addition, this model can record the number of keyword searches and the search status, and by judging relevant parameters before searching, it can reduce the encryption and decryption burden caused by too much search information. The algorithm can update and trace the data at any time.

[0004] The model design described in the present invention uses Internet of Things technologies such as electronic tags or QR codes to specially mark drugs and collect information for easy recording and management of drug information; the above information is uploaded to the chain; the smart contract is responsible for managing the data access rights of the nodes on the chain and the verification of traceability queries by users such as hospitals and consumers. Finally, the traceability work will be supervised by the highest authority of the Food and Drug Administration and relevant decision-making departments.

[0005] The present invention proposes a drug trusted traceability method based on public key searchable encryption, which includes four steps:

[0006] Step 1: Encrypt the collected drug information and log information and extract keywords to generate drug ciphertext and index table, which are uploaded to the cloud server to provide a basis for searching the encrypted data, i.e., traceability query;

[0007] Step 2: Generate a checklist of relevant drug information based on the ciphertext and the identity ID of the data uploader, and embed the checklist into the smart contract of the blockchain;

[0008] Step 3: Upload the drug ciphertext in Step 1 to the drug traceability chain;

[0009] Step 4: When the data queryer wants to query drug information, the system obtains the keywords and identity ID in the search terms entered by the queryer and verifies them. After verification, the search behavior is completed; the log information generated by this search behavior is recorded and stored on the chain;

[0010] In the Step 1, the drug keywords are extracted using the Pre-semantic Extraction (PSE) algorithm, and the drug keyword index is generated using MIIT.

[0011] In the above Step 1, the collected drug information and log information are encrypted and keywords are extracted to generate drug ciphertext and index table. The specific steps are as follows:

[0012] The preparation algorithm is used to divide the drug arrival information M into multiple data files, and the data files are searchably encrypted through the traceability system to generate the ciphertext E m , and extract keywords w from multiple data files to generate file-block identifiers BP i ∈{0, 1} l , where l is the data file M i length, and generates the index MIIT and keyword status table Map; the hospital client will BP i (E i ) is stored in the blockchain, and the index MII is generated and stored in the cloud server;

[0013] The Step 4 is divided into a trapdoor information generation phase and a search phase;

[0014] Among them, the trapdoor information generation stage is divided into two steps:

[0015] Step 4-1. When the patient searches for the plaintext keyword Drug_a, the client system first obtains its state Map and calculates the search token K ts =H1(Drug_a||ts); and determine the search state S; where ts represents the number of searches;

[0016] Step 4-2: If S is "Y", it means that drug A has been searched before. The blockchain retains the last search record. The traceability system encrypts the search token and encrypts it with the patient ID. PMerge to generate a trapdoor and send it to the blockchain, which uses the private key sk b Successfully decrypted and obtained the search key K ts After that, it means that the blockchain has received the correct trapdoor information; at this time, the blockchain will correspond to the key K ts The ciphertext E m After encryption, the blockchain returns E m ′, to the client system;

[0017] If S is "N", it means that the information of drug A has not been searched after being uploaded or updated, and the cloud server needs to calculate the search results first; the patient client calculates the new index pointer IP t and the last search token K ts-к , same as patient ID P The merged trapdoor is sent to the cloud server; at the same time, the patient client changes the corresponding search status to "Y";

[0018] The search phase is divided into three steps:

[0019] Step 4-3, when S is "N", that is, the information of drug A has not been searched, the patient client sends a trapdoor to the cloud server. After the cloud server obtains the trapdoor, it obtains the ciphertext block pointer BP related to the keyword Drug_a from the index MIIT m and index pointer IP t , the calculation result is searched for token K ts , User ID P And all ciphertexts E m Corresponding random number a t and verification code V t Send to blockchain;

[0020] Step 4-4: After receiving the search results and verifying the results, the blockchain retrieves the last search ciphertext E from the Record. m And perform asymmetric encryption to convert E m 'Return to the patient client; at the same time, record the search result, that is, the search token and ciphertext;

[0021] Step 4-5, the patient client receives E m ' and read the header fileγ K′ , using its own private key Dec(E′ m ,sk P ) performs asymmetric decryption to generate γ K , calculate and use the key K, get the key γ and calculate the symmetric key K e , calculate SDec(K e , M′), calculate the drug arrival information M.

[0022] Preferably, the pre-semantic extraction (PSE) algorithm in Step 1 introduces preconditions and part-of-speech factors, and constructs a tree index structure of keywords, and the formula is as follows:

[0023]

[0024] Among them, condition1 = contain ('add'∧'delete'∧'update'∧'check') means that the words "add, delete, modify and check" appear in the data, indicating that this data is log data, then pre i Assign a value of 1;

[0025] Term Frequency (TF) represents the probability of a word appearing in document D, as shown in the formula:

[0026]

[0027] Among them, the molecule N i,j The word t i In the document d j The number of times it appears in the denominator ∑ k N k,j This means that in document d j The total number of occurrences of all words in ;

[0028] Inverse Document Frequency (IDF) indicates the probability of a word t being included in the corpus. i The reciprocal of the number of documents is calculated as follows:

[0029]

[0030] Where |D| represents the total number of documents in the corpus, |{j:t i ∈d j}| means containing the word t i The number of documents; if the word does not appear in the corpus, the divisor will be 0, so add 1 here to avoid this problem;

[0031] According to the two data types, the weight of medical data (pos_med i ) and log data weight (pos_log i ) is used for classification and assignment, and the weight of the part of speech of keyword i is distinguished, and the weight of the part of speech is defined. The weight of keywords of different parts of speech is defined as follows:

[0032]

[0033]

[0034] in:

[0035] adj. is an adjective β is the adjective weight;

[0036] adv. is an adverb γ is an adjective weight;

[0037] v. is a verb δ is an adjective weight;

[0038] n is a noun α is an adjective weight;

[0039] num is a number and ε is the adjective weight;

[0040] The calculation formula of feature word weight is:

[0041]

[0042] The beneficial effects of the present invention are:

[0043] The present invention introduces public key searchable encryption technology for drug traceability scenarios, making each node easy to maintain and monitor, and the drug information on the chain can be queried by any node, thereby enhancing the security and credibility of online drug data and improving the availability of encrypted data. Secondly, an improved keyword extraction method, called the pre-semantic extraction algorithm, is used to introduce preconditions and part-of-speech factors into the method, effectively improving the accuracy of drug data feature extraction in the model. Then, a Merkel inverted index tree structure is proposed, which improves the search efficiency of multiple keywords by introducing inverted lists, Merkle trees, hash pointers and other technologies, supports the trusted verification process of cloud servers and blockchains, and improves the efficiency of drug data search.

[0044] Due to the encryption and decryption speed issues of the searchable encryption method and the data storage issues, the DTB-PEKS model needs to process the drug information and divide it into multiple drug data files, and extract the index value of the keyword for each data file. Then, the public key searchable encryption algorithm is used to encrypt the data file to generate ciphertext, build the index tree MIIT and send it to the cloud server, and the ciphertext is uploaded to the blockchain. In addition, this model can record the number of keyword searches and the search status, and by judging the relevant parameters before searching, it can reduce the encryption and decryption burden caused by too much search information. The algorithm can update and trace the data at any time. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Figure 1 The interactive process of drug information tracking;

[0046] Figure 2 Drug traceability architecture based on blockchain;

[0047] Figure 3 MIIT structure diagram;

[0048] Figure 4 Sequence diagram of ciphertext upload and search;

[0049] Figure 5 Data interaction process;

[0050] Figure 6 Network diagram of the pharmaceutical supply chain;

[0051] Figure 7 Ciphertext decryption process. DETAILED DESCRIPTION

[0052] The present invention is further described in detail below in conjunction with specific embodiments:

[0053] DTB-PEKS model introduction:

[0054] (1) DTB-PEKS model architecture: It includes five layers, namely, data layer, network layer, consensus layer, contract layer and application layer. The data layer is the core layer, which collects relevant drug information, such as image information, non-repetitive drug batch numbers, query operation logs and independent traceability numbers (consisting of product category, production date, expiration date, batch number and other related information), provides a basis for subsequent traceability queries, and encrypts the collected information and stores it on the chain. In the network layer, it mainly provides a basis for the transmission of drug information. The consensus layer conducts consensus and data verification on drug information that needs to be uploaded to the chain. The contract layer is the working method of the entire blockchain, specifically smart contracts, to set permission sets and traceability query verification lists. The application layer provides users with an interface of a traceability blockchain to conduct traceability queries and supervision of drug information.

[0055] (2) DTB-PEKS Participating Entities: The participating entities of the drug traceability blockchain are classified based on their roles: data upload generators, such as pharmaceutical factories, distributors / logistics providers, hospitals, pharmacies, and consumers; data traceability queryers, such as hospitals, pharmacies, and consumers; data supervisors, such as drug regulatory agencies and blockchain managers. The specific descriptions are as follows:

[0056] ① The data uploader is responsible for the collection of drug information and the storage of information on the chain. The collected drug information is standardized and encrypted on the chain through the system, and keywords and encryption operations are performed on the collected drug information, and it is uploaded to the traceability blockchain and cloud server. The blockchain publishes the received information through a point-to-point network, and stores it in the data layer after consensus verification, so as to achieve data unification of all block nodes and provide a basis for subsequent traceability and supervision.

[0057] ②The data query party is the destination of the data flow and receives drug information. The query party interacts with the application layer, works at the front end of the system, and obtains drug information to realize traceability query. Although all node entities can view drug traceability information, different entities have different functions and permissions. Smart contracts at the contract layer are required to restrict the query party's access and operation rights to data. For example, consumers only have the right to upload drug experience, query drug batch number and manufacturer qualification traceability information, but have no right to view other information.

[0058] ③ For data regulators, such as the Food and Drug Administration, they have access to all drug traceability information in order to supervise the illegal behavior of other nodes and pursue their legal responsibilities. In addition, each participating entity must register on the blockchain and obtain a unique identity, which consists of asymmetric cryptography public and private keys, and associate each storage, query and other transactions to enhance the authenticity and transparency of traceability.

[0059] (3) DTB-PEKS workflow: In the proposed model, the work of the drug traceability blockchain is mainly divided into two modes: storage on the chain and traceability query.

[0060] ① Storage on-chain mode: After the data generator completes data collection, the information is extracted for keywords and an index table is generated. The drug information is encrypted to generate ciphertext and checklists to reduce the risk of data leakage. After consensus and verification, the ciphertext and checklist are stored on the blockchain, and the stored information is used for traceability and other research and analysis. The ciphertext and index table are uploaded to the cloud server to provide a basis for the searchable encryption model.

[0061] ②Traceability query mode: When ordinary participants query a drug, such as entering "ibuprofen" for query, the system will initiate a search request to the cloud server, and the cloud server will respond to the request, calculate the search results and send them to the blockchain smart contract for verification. The verification will return the traceability information related to "ibuprofen" to the participant, completing the traceability query. The participant's platform interface will show entries related to the drug name "ibuprofen tablets" or "ibuprofen capsules" as well as information such as its manufacturer, production date / batch number, and drug ingredients / usage.

[0062] Because, from drug production to the final end of consumer, each uploaded drug information and search record will initiate a data transmission process and generate a data operation transaction, which will be used for subsequent traceability tracking of the same drug keywords.

[0063] (4) DTB-PEKS information interaction: In the DTB-PEKS model, only the information interaction of the drug traceability chain is considered. The information types mainly include drug information and log information. Drug information refers to relevant information with the purpose of inquiry and the drug as the main body, such as production batch number, logistics status, and sales information. Log information refers to relevant information with the purpose of traceability and the visitor as the main body. It is mainly automatically generated by the database software to record every drug data change and query, mainly including visitor ID, access operation, and access data pointer.

[0064] The information interaction process is divided into 4 steps:

[0065] Step 1: Encrypt the collected drug information and log information and extract keywords to generate drug ciphertext and index table, which are uploaded to the cloud server to provide a basis for searching encrypted data, i.e., traceability query.

[0066] Step 2: Generate a checklist of relevant drug information based on the ciphertext and the identity ID of the data uploader, and embed the checklist into the smart contract of the blockchain.

[0067] Step 3: Upload the drug ciphertext in Step 1 to the drug traceability chain.

[0068] Step 4: When the data queryer wants to query the drug information, the system obtains the keywords and identity ID in the search terms entered by the queryer and verifies them. After verification, the search behavior is completed. The log information generated by this search behavior is recorded and stored on the chain.

[0069] In Step 1 and Step 4, due to privacy protection, cloud server storage and other issues, drug data and log information need to be streamlined, and semantic information is extracted from off-chain data before being stored on-chain to improve storage efficiency. In addition, by establishing a collaborative relationship between on-chain and off-chain data and building an index list, the efficiency of on-chain data access is improved.

[0070] In Step 1, the extraction of drug keywords adopts the Precondition Semantic Extraction (PSE) algorithm, which introduces preconditions and part-of-speech factors to improve the accuracy of feature extraction, solve the problem of the lack of semantic understanding in traditional keyword extraction algorithms, and build a keyword tree index structure based on this.

[0071] The formula is as follows:

[0072]

[0073] Among them, condition1 = contain ('add'∧'delete'∧'update'∧'check') means that the words "add, delete, modify and check" appear in the data, indicating that this data is log data, then pre i Assign a value of 1.

[0074] Term Frequency (TF) represents the probability of a word appearing in document D, as shown in the formula:

[0075]

[0076] Among them, the molecule N i,j The word t i In the document d j The number of times it appears in the denominator ∑ k N k,j This means that in document d j The sum of the occurrences of all words in .

[0077] Inverse Document Frequency (IDF) indicates the probability of a word t being included in the corpus. i The reciprocal of the number of documents is calculated as follows:

[0078]

[0079] Where |D| represents the total number of documents in the corpus, |{j:t i ∈d j}| means containing the word t i If the word does not appear in the corpus, the divisor will be 0, so we add 1 here to avoid this problem.

[0080] According to the two data types, the weight of medical data (pos_med i ) and log data weight (pos_log i ) is used for classification and assignment, and the weight of the part of speech of keyword i is distinguished, and the weight of the part of speech is defined. The weight of keywords of different parts of speech is defined as follows:

[0081]

[0082]

[0083] in:

[0084] adj. is an adjective β is the adjective weight;

[0085] adv. is an adverb γ is an adjective weight;

[0086] v. is a verb δ is an adjective weight;

[0087] n is a noun α is an adjective weight;

[0088] num is a number and ε is the adjective weight;

[0089] Therefore, the calculation formula for our feature word weight is:

[0090]

[0091] In Step 1, the index generation of drug keywords is constructed using MIIT.

[0092] After keyword extraction, a global inverted list containing three attributes will be used, namely: keyword identifier Key, block identifier BlockPointer and its hash value. Among them, because of the index structure of the blockchain, BlockPointer is used to point to the block where the data is located, which is also our main search content. Due to the trust problem of drug data interaction between blockchain and cloud server, the present invention designs a Merkle Inverted Index Tree (MIIT), which combines inverted lists, Merkle trees, hash pointers and other technologies, and more efficiently performs multi-keyword searches on chain data. According to the appendable nature of the blockchain, the MIIT structure is dynamically constructed, and the structure of MIIT will be updated every time a new block is generated.

[0093] After keyword extraction from off-chain data, the extracted off-chain data is used as the basis to establish an index structure through the on-chain block, and the cloud server stores and calculates the search results, and keeps the index generation and update. In the search module of the present invention, the on-chain index structure is generated or changed following the block generation. Therefore, an inverted tree index structure of keywords is constructed based on the off-chain data, and the inverted index is used to quickly query a single keyword, and to realize the search of multiple keywords, a tree structure is used to present it.

[0094] There are two different types of nodes in MIIT: leaf nodes and branch nodes. The structure is as follows: Figure 3 As shown. Each node contains a hash value. For a leaf node, this hash value is a hash operation performed on the keyword and block pointer stored in the leaf node, as shown in the formula:

[0095] hash leaf =hash(key||blockpointer)

[0096] For a branch node, the hash value is a hash operation of the keyword, block pointer, and child node hash value. The formula is:

[0097] hash branch =hash[key||blockpointer||hash(child)]

[0098] The branch node stores index-related information and a hash pointer to the block, and provides a pointer to the next layer of nodes. The leaf node is located at the bottom of MIIT, representing the end of a search path. The search results are stored in the leaf node, and the result is a hash pointer pointing to the block where the data corresponding to the transaction is located. If a node is a branch node, in addition to containing a pointer to the next layer, the node itself also contains the corresponding search results. At the same time, when there is only one node in MIIT, this node is a leaf node, and if there is a child node, it is a branch node.

[0099] In order to save storage space, the present invention does not store information related to the inverted index in the block, because MIIT contains all keyword-related information. If you want to restore the inverted list as a newly added node, you can use MIIT to restore it locally, or connect to another full node to synchronize its inverted list, and then use your own MIIT for verification.

[0100] The present invention proposes a drug trusted traceability method based on public key searchable encryption. The method includes the following four functional modules: Key Generating Center (KGC), Client, Blockchain and Cloud Server. The specific introduction is as follows:

[0101] (1) Key Generating Center (KGC). KGC is a third-party organization responsible for managing and generating keys. It generates corresponding private keys and public keys for the identity IDs of users and blockchain managers. It is authoritative, trustworthy and fair. At the same time, the key generation center publishes the public parameters of the system.

[0102] (2) Client. The client includes users with different roles, such as data upload users, data search users, etc. After the client passes the digital signature issued by CA certification, it can complete operations such as uploading, searching, querying, and updating drug data in the system.

[0103] ① Data upload: When users upload drug data, the client system divides the data into multiple data files, encrypts and extracts keywords from the multiple data files, generates ciphertext and index, and uploads them to the cloud server. At the same time, the ciphertext is uploaded to the blockchain.

[0104] ②Data search: When a user initiates a search request for a keyword, the client system processes the request, and after calculation, sends the corresponding information to the cloud server or blockchain based on the result. After calculation and verification by the cloud server and blockchain, the returned value is used to decrypt the file.

[0105] ③Data update: During the data upload phase, after extracting the keywords of the drug data that needs to be updated, add the data to the cloud server and the chain.

[0106] (3) Blockchain. In the present invention, the blockchain verifies the search results uploaded by the cloud server. After the verification is passed, the search service fee is paid to the cloud server and the encrypted results are returned to the client. At the same time, the blockchain records the search results, which is conducive to repeated queries of the same keywords and saves computing resources.

[0107] (4) Cloud Server (CS). Responsible for the indexing and ciphertext storage in this model, accepting search requests from clients and sending the calculated search results to the blockchain.

[0108] In this model, all operations are completed in the form of transactions, ensuring that the operations cannot be tampered with and cannot be denied. At the same time, the cloud server must honestly perform the search request service. In order to avoid misconduct such as the client falsely claiming that the result is wrong and refusing to pay the service fee, any node in the blockchain can verify the content of the transaction.

[0109] IDs of all participating nodes in the pharmaceutical supply chain u and blockchain administrator ID b You need to obtain your own private key and public key. According to the operation method of data, it is divided into two stages: upload and search.

[0110] (1) During the drug data upload phase, the hospital client encrypts the drug arrival information M, extracts the keyword w, and generates a block-file identifier BP i , the hospital client will block the data ciphertext i - file identifier BP i (E i ) is stored in the blockchain, and the generated index MII and other related data are stored in the cloud server.

[0111] (2) In the search phase, if a pharmacist wants to check whether "Enteric-coated Aspirin Tablets" are in the hospital's drug warehouse, he or she can enter the drug in the system, and "Aspirin", "Enteric-coated" and "Tablets" can all be used as search keywords w'. The hospital system retrieves the number of searches for w' in the search status table. After judgment, if there is a search record for "Aspirin", "Enteric-coated" and "Tablets", the trapdoor is sent to the blockchain smart contract, and the last search result is directly returned to the hospital system; if not, the trapdoor needs to be sent to the cloud server to calculate the search result, and then the blockchain verifies the search result and returns the ciphertext to the client. After decryption, the client obtains the warehouse information M, that is, the warehouse or logistics information of "Enteric-coated Aspirin Tablets". Finally, the blockchain records this search and generates a record table Record as a basis for third-party supervision.

[0112] Based on the data operation logic, the model is divided into four stages: the preparation stage (Setup), the key generation stage (KeyGen), the trapdoor generation stage (TtapdoorGen), and the search stage (Search):

[0113] 1. Preparation phase: Using the setup algorithm Setup(λ), the client divides the drug arrival information M into multiple data files M1, M2, M3, …, M n , expressed as M = {M1, M2, M3, ..., M n}; The traceability system performs searchable encryption on the data file to generate ciphertext E m , and extract keywords w, w∈W from multiple data files to generate file-block identifier BP i ∈{0, 1} l , where l is the data file M i length, and generates the index MIIT and keyword status table Map; the hospital client will BP i (E i ) is stored in the blockchain, and the index MII and other related data are generated and stored in the cloud server;

[0114] The generation order of the traceability system is a large prime number p (p>2 λ ) Multiplication group G1, G2, g is the generator of G1, generating a bilinear map Select 4 collision-resistant hash functions, as shown in the formula:

[0115]

[0116] λ is a security parameter, randomly selected As the system private key, calculate the system public key as

[0117] Publish public parameters of the traceability system At the same time, the blockchain manager will deploy smart contracts;

[0118] Among them, H1, H2, and H3 represent three collision-resistant hash functions;

[0119] pk represents the system public key;

[0120] sk represents the system private key,

[0121] Z p * represents a non-zero finite field of p, i.e., {1, ..., p-1}, where p is a prime number;

[0122] R Z p * represents a finite field of p nonzero real numbers.

[0123] 2. Key generation phase: Assume there are m participating nodes, m can be changed dynamically, m∈N + , then 1≤u≤m. At the same time, the system private key is encrypted to generate the system master key, the formula is as follows:

[0124]

[0125] Where N + Represents the set of positive integers, which is the value range of m.

[0126] m is the number of participating nodes, indicating the total number of users, and m is used as a condition for u;

[0127] u represents the user tag, 1≤u≤m; it represents a certain user;

[0128] DTparams is the public parameter of the traceability system;

[0129] ID hosp is the node identity;

[0130] pk b It is the public key of the blockchain manager;

[0131] sk is the system private key;

[0132] Drug_w is a plaintext keyword

[0133] M is the information of drug arrival in warehouse;

[0134] K is the system master key;

[0135] pk v It's pk γ , pk represents the system public key, where

[0136] Represents the exponential H1 operation of g. Where H1(a) represents the collision-resistant hash operation with input a.

[0137] Step 1: The traceability system initializes the empty set Map and index MII, where Map is used to record the update times t, search times ts, search status S and index pointer IP of the plaintext keyword Drug_w. t , MII is used to store block pointers and random numbers; at the same time, initialize the above parameters and generate random numbers

[0138] Among them: a t Represents the random number in the tth search;

[0139] γ is a random number;

[0140] R Z p * represents a finite field of p non-zero real numbers where

[0141] The hospital's drug traceability system sends [ID hosp , H1(ID hosp )] to the key generation center, which verifies through hash and calculates (sk hosp , pk hosp ), the key generation center returns (sk hosp , pk hosp ) Drug traceability system for hospitals.

[0142] sk hosp =H1(ID hosp ) sk

[0143]

[0144] Where ID hosp Indicates the identity ID of the user marked as hosp (hospital system).

[0145] H1(ID hosp ) indicates that the input is ID hosp The collision-resistant hash function H1 operation.

[0146] sk hosp Represents the private key of the user marked as hosp (hospital system).

[0147] pk hosp Represents the public key of the user marked as hosp (hospital system).

[0148] Step 2: Construct a pseudo-random hash function, such as H f(x) = H2(f||x);

[0149] Where f represents the unknown function and x represents the unknown number.

[0150] The hospital's drug traceability system generates a search token K ts , Index pointer IP t and the symmetric key K e :

[0151] K ts =H1(Dtug_w||ts)

[0152] K e =H1(γ)

[0153]

[0154] Generate index pointer IP t and its ciphertext eIP t , and generate the ciphertext M′ by symmetric encryption of the drug arrival information M, and K Splice to M'header to form data ciphertext E m ;

[0155] Among them, H Kts () contains K ts The pseudo-random function of the components is Calculated

[0156] γ is a random number.

[0157] Ciphertext eIP i Indicates IP t The encrypted ciphertext is EncryptIP t Abbreviation for E m Indicates the ciphertext after data M is encrypted, which is the abbreviation of Encrypt M.

[0158]

[0159] E m =γ K ||M′=γ K ||SEnc(M,K e )

[0160] K e is a symmetric key;

[0161] SENc() represents the symmetric encryption function, which is the abbreviation of Symmetric Encryption;

[0162] Step 3: The hospital sends the relevant data to the blockchain and cloud server, and uploads MII[IPt ]←{eIP t , BP m , a t} to the cloud server and upload the ciphertext E m To the blockchain smart contract, the hospital has successfully uploaded the drug data;

[0163] Among them, IP t is the index pointer;

[0164] a t represents the random number in the tth search, where

[0165] BP m The block-file identifier representing the data M is the abbreviation of BlockPointer.

[0166] The relevant algorithm is as follows:

[0167]

[0168]

[0169] 3. Trapdoor information generation stage:

[0170] Step 1: When the patient searches for the plaintext keyword Drug_a, the client system first obtains its state Map and calculates the search token K ts =H1(Drug-a||ts); and determine the search state S;

[0171] ts represents the number of searches.

[0172] Step 2: If S is "Y", it means that drug A has been searched before. The blockchain retains the last search record, so the traceability system encrypts the search token and associates it with the patient ID. P Merge to generate trapdoor T, send it to the blockchain, and the blockchain uses the private key sk b Successfully decrypted and obtained the search key K ts After that, the decryption formula is as follows

[0173] K ts = Dec(T1, sk b ) (19)

[0174] E′ m =Enc(γ K , pk b )||M′ (20)

[0175] This means that the blockchain has received the correct trapdoor information; at this point, the blockchain will correspond to the key K ts The ciphertext Em After encryption, the blockchain returns E m ′, to the client system;

[0176] E m ′ represents the ciphertext after the Enc() encryption operation.

[0177] Dec() represents the symmetric decryption function.

[0178] T1 is a component of the trapdoor and is a variable, which is represented in lines 4 and 11 of the algorithm TrapdoorGen().

[0179] sk b is the private key;

[0180] Enc() represents a symmetric encryption function.

[0181] If S is "N", it means that the information of drug A has not been searched after being uploaded or updated, and the cloud server needs to calculate the search results first; the patient client calculates the new index pointer IP t and the last search token K ts-1 , same as patient ID P Merge to generate a trapdoor T, and send T to the cloud server; at the same time, the patient client changes the corresponding search status to "Y";

[0182]

[0183] Among them: DTparams is the system common parameters;

[0184] pk b It is the public key of the blockchain manager;

[0185] sk is the system private key;

[0186] Drug_w is a plaintext keyword

[0187] ID P is the patient identity; the relevant algorithm is as follows:

[0188]

[0189] 4. Search phase: taking system public parameters DTparams and trapdoor information T as input;

[0190] Step 1: From the algorithm TrapdoorGen(), it can be seen that when S is "N", that is, the information of drug A has not been searched, the patient client sends the trapdoor T to the cloud server. After the cloud server obtains the trapdoor T, it obtains the ciphertext block pointer BP related to the keyword Drug-a from the index MIIT. m and index pointer IPt , the calculation result is searched for token K ts , User ID P And all ciphertexts E m Corresponding random number a t and verification code V t Send to blockchain:

[0191]

[0192] Step 2: After receiving the search results and verifying the results, the blockchain retrieves the last search ciphertext E from the Record. m And perform asymmetric encryption to convert E m 'Return to the patient client; at the same time, record the search result, that is, the search token and ciphertext;

[0193] Step 3: The patient client receives E m ' and read the header fileγ K′ , using its own private key Dec(E′ m ,sk P ) performs asymmetric decryption to generate γ K , calculate and use the key K, get the key γ and calculate the symmetric key K e , calculate SDec(K e , M′), calculate the drug arrival information M, the decryption process is as follows Figure 7 :

[0194] The relevant algorithm is as follows:

[0195]

[0196]

[0197] The above descriptions are only some specific implementation methods of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by any person familiar with the art within the technical scope disclosed in the present invention should be covered within the protection scope of the present invention.

Claims

1. A drug trusted traceability method based on public key searchable encryption, characterized in that It consists of 4 steps: Step 1: Encrypt the collected drug information and log information and extract keywords to generate drug ciphertext and index table, which are uploaded to the cloud server to provide a basis for searching the encrypted data, i.e., traceability query; Step 2: Generate a checklist of relevant drug information based on the ciphertext and the identity ID of the data uploader, and embed the checklist into the smart contract of the blockchain; Step 3: Upload the drug ciphertext in Step 1 to the drug traceability chain; Step 4: When the data queryer wants to query drug information, the system obtains the keywords and identity ID in the search terms entered by the queryer and verifies them. After verification, the search behavior is completed; the log information generated by this search behavior is recorded and stored on the chain; In the Step 1, the drug keywords are extracted using the Pre-semantic Extraction (PSE) algorithm, and the drug keyword index is generated using the Merkle Inverted Index Tree (MIIT) construction; The MIIT performs multi-keyword search on the on-chain data by combining inverted lists, Merkle trees, and hash pointer technologies; the MIIT structure is dynamically constructed, and the MIIT structure is updated every time a new block is generated; after keyword extraction of off-chain data, the extracted off-chain data is used as the basis to establish an index structure through on-chain blocks, and the cloud server stores and calculates search results, and keeps the index generation and update; There are two different types of nodes in the MIIT: leaf nodes and branch nodes. Each node contains a hash value. For a leaf node, the hash value is a hash operation performed on the keyword and block pointer stored in the leaf node. Branch node, the hash value is a hash operation of the keyword, block pointer and child node hash value; the branch node stores index related information and hash pointer pointing to the block, and provides a pointer to the next layer of nodes; The leaf node is located at the bottom layer of MIIT, representing the end of a search path. The search results are stored in the leaf node, and the result is a hash pointer pointing to the block where the data corresponding to the exchange is located. If a node is a branch node, in addition to containing a pointer to the next layer, the node itself also contains the corresponding search results. When there is only one node in MIIT, this node is a leaf node. If there is a child node, it is a branch node. In the above Step 1, the collected drug information and log information are encrypted and keywords are extracted to generate drug ciphertext and index table. The specific steps are as follows: The preparation algorithm is used to divide the drug arrival information M into multiple data files, and the data files are searchably encrypted through the traceability system to generate the ciphertext E m , and extract keywords w from multiple data files to generate file-block identifiers BP i ∈{0,1} l , where l is the data file M i length, and generates the index MIIT and keyword status table Map; the hospital client will BP i (E i ) is stored in the blockchain, and the index MIIT is generated and stored in the cloud server; The Step 4 is divided into a trapdoor information generation phase and a search phase; Among them, the trapdoor information generation stage is divided into two steps: Step 4-1. When the patient searches for the plaintext keyword Drug_a, the client system first obtains its state Map and calculates the search token K ts =H1(Drug_a||ts)_; and determine the search state S; where ts represents the number of searches; Step 4-2: If S is "Y", it means that drug A has been searched before. The blockchain retains the last search record. The traceability system encrypts the search token and associates it with the patient ID. P Merge to generate trapdoor T, send it to the blockchain, and the blockchain uses the private key sk b Successfully decrypted and obtained the search key K ts After that, it means that the blockchain has received the correct trapdoor information; at this time, the blockchain will correspond to the key K ts The ciphertext E m After encryption, the blockchain returns E m ', to the client system; If S is "N", it means that the information of drug A has not been searched after being uploaded or updated, and the cloud server needs to calculate the search results first; the patient client calculates the new index pointer IP t and the last search token K ts-1 , same as patient ID P The trapdoor T is generated by merging, and T is sent to the cloud server; at the same time, the patient client changes the corresponding search status to "Y"; The search phase is divided into three steps: Step 4-3, when S is "N", that is, the information of drug A has not been searched, the patient client sends the trapdoor T to the cloud server. After the cloud server obtains the trapdoor T, it obtains the ciphertext block pointer BP related to the keyword Drug_a from the index MIIT m and index pointer IP t , the calculation result is searched for token K ts , User ID P And all ciphertexts E m Corresponding random number a t and verification code V t Send to blockchain; Step 4-4: After receiving the search results and verifying the results, the blockchain retrieves the last search ciphertext E from the Record. m And perform asymmetric encryption to convert E m 'Return to the patient client; at the same time, record the search results, that is, the search token and ciphertext; Step 4-5, the patient client receives E m ' and read the header fileγ K , using its own private key Dec(E' m ,sk P ) performs asymmetric decryption to generate γ K , calculate and use the key K, get the key γ and calculate the symmetric key K e , calculate SDec(K e ,M'), calculate the drug arrival information M; The PSE algorithm described in Step 1 introduces preconditions and part-of-speech factors and constructs a tree index structure of keywords. The formula is as follows: Among them, condition1 = contain ('add'∧'delete'∧'update'∧'check') means that the words "add, delete, modify and check" appear in the data, indicating that this data is log data, then pre i Assign a value of 1; Term Frequency (TF) represents the probability of a word appearing in document D, as shown in the formula: Among them, the molecule N i,j The word t i In the document d j The number of times it appears in the denominator ∑ k N k,j This means that in document d j The total number of occurrences of all words in ; Inverse Document Frequency (IDF) indicates the probability of a word t being included in the corpus. i The reciprocal of the number of documents is calculated as follows: Where |D| represents the total number of documents in the corpus, |{j:t i ∈d j }| means containing the word t i The number of documents; if the word does not appear in the corpus, the divisor will be 0, so add 1 here to avoid this problem; According to the two data types, the weight of medical data (pos_med i ) and log data weight (pos_log i ) is used for classification and assignment, and the weight of the part of speech of keyword i is distinguished, and the weight of the part of speech is defined. The weight of keywords of different parts of speech is defined as follows: in: adj. is an adjective β is the adjective weight; adv. is an adverb γ is an adjective weight; v. is a verb δ is an adjective weight; n is a noun α is an adjective weight; num is a number and ε is the adjective weight; The calculation formula of feature word weight is: